Index: binaries/data/mods/public/maps/random/rmgen/library.js
===================================================================
--- binaries/data/mods/public/maps/random/rmgen/library.js	(revision 14157)
+++ binaries/data/mods/public/maps/random/rmgen/library.js	(working copy)
@@ -11,6 +11,7 @@
 const HEIGHT_UNITS_PER_METRE = 732;
 const MIN_MAP_SIZE = 128;
 const MAX_MAP_SIZE = 512;
+const FALLBACK_CIV = "athen";
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 //	Utility functions
@@ -395,7 +396,11 @@
 
 function getCivCode(player)
 {
-	return g_MapSettings.PlayerData[player].Civ;
+	if (g_MapSettings.PlayerData[player].Civ)
+		return g_MapSettings.PlayerData[player].Civ;
+
+	warn("undefined civ specified for player " + (player + 1) + ", falling back to '" + FALLBACK_CIV + "'");
+	return FALLBACK_CIV;
 }
 
 function areAllies(player1, player2)
@@ -470,8 +475,8 @@
 	var civ = getCivCode(player);
 	if (!g_CivData[civ] || !g_CivData[civ].StartEntities || !g_CivData[civ].StartEntities.length)
 	{
-		warn("Invalid or unimplemented civ '"+civ+"' specified, falling back to 'athen'");
-		civ = "athen";
+		warn("Invalid or unimplemented civ '"+civ+"' specified, falling back to '" + FALLBACK_CIV + "'");
+		civ = FALLBACK_CIV;
 	}
 	
 	return g_CivData[civ].StartEntities;
Index: binaries/data/mods/public/maps/random/rmgen/wall_builder.js
===================================================================
--- binaries/data/mods/public/maps/random/rmgen/wall_builder.js	(revision 14157)
+++ binaries/data/mods/public/maps/random/rmgen/wall_builder.js	(working copy)
@@ -429,7 +429,7 @@
 	if (playerId == 0)
 		style = (style || "palisades");
 	else
-		style = (style || g_MapSettings.PlayerData[playerId-1].Civ);
+		style = (style || getCivCode(playerId-1));
 	orientation = (orientation || 0);
 	// Get wall alignment
 	var AM = getWallAlignment(startX, startY, wall, style, orientation);
@@ -461,7 +461,7 @@
 	if (playerId == 0)
 		style = (style || "palisades");
 	else
-		style = (style || g_MapSettings.PlayerData[playerId-1].Civ);
+		style = (style || getCivCode(playerId-1));
 	orientation = (orientation || 0);
 	// Calculate center if fortress.centerToFirstElement is undefined (default)
 	var centerToFirstElement = fortress.centerToFirstElement;
@@ -486,7 +486,7 @@
 	if (playerId == 0)
 		style = (style || "palisades");
 	else
-		style = (style || g_MapSettings.PlayerData[playerId-1].Civ);
+		style = (style || getCivCode(playerId-1));
 	orientation = (orientation || 0);
 	// Call placeCustomFortress with the given arguments
 	placeCustomFortress(centerX, centerY, fortressTypes[type], style, playerId, orientation);
@@ -514,7 +514,7 @@
 	if (playerId == 0)
 		style = (style || "palisades");
 	else
-		style = (style || g_MapSettings.PlayerData[playerId-1].Civ);
+		style = (style || getCivCode(playerId-1));
 	endWithFirst = typeof endWithFirst == "undefined" ? true : endWithFirst;
 	// Check arguments
 	for (var elementIndex = 0; elementIndex < wallPart.length; elementIndex++)
@@ -604,7 +604,7 @@
 	if (playerId == 0)
 		style = (style || "palisades");
 	else
-		style = (style || g_MapSettings.PlayerData[playerId-1].Civ);
+		style = (style || getCivCode(playerId-1));
 	orientation = (orientation || 0);
 	maxAngle = (maxAngle || 2*PI);
 	if (endWithFirst === undefined)
@@ -715,7 +715,7 @@
 	if (playerId == 0)
 		style = (style || "palisades");
 	else
-		style = (style || g_MapSettings.PlayerData[playerId-1].Civ);
+		style = (style || getCivCode(playerId-1));
 	orientation = (orientation || 0);
 	numCorners = (numCorners || 8);
 	skipFirstWall = (skipFirstWall || true);
@@ -773,7 +773,7 @@
 	if (playerId == 0)
 		style = (style || "palisades");
 	else
-		style = (style || g_MapSettings.PlayerData[playerId-1].Civ);
+		style = (style || getCivCode(playerId-1));
 	// Generating a generic wall part assortment with each wall part including 1 gate enlengthend by walls and towers
 	// NOTE: It might be a good idea to write an own function for that...
 	var defaultWallPartsAssortment = [["wallShort"], ["wall"], ["wallLong"], ["gate", "tower", "wallShort"]];
@@ -892,7 +892,7 @@
 	if (playerId == 0)
 		style = (style || "palisades");
 	else
-		style = (style || g_MapSettings.PlayerData[playerId-1].Civ);
+		style = (style || getCivCode(playerId-1));
 	irregularity = (irregularity || 1/2);
 	gateOccurence = (gateOccurence || 3);
 	maxTrys = (maxTrys || 100);
