Fixes filter behavior in setup when switching map type.
Fixes broken texture in Latium rms. Adds demo keyword to rms test. Fixes default rms lighting with new model. This was SVN commit r9127.
This commit is contained in:
parent
daad510013
commit
0dfc72bc2c
@ -124,9 +124,13 @@ function initMain()
|
|||||||
// Set a default map
|
// Set a default map
|
||||||
// TODO: This should be remembered from the last session
|
// TODO: This should be remembered from the last session
|
||||||
if (!g_IsNetworked)
|
if (!g_IsNetworked)
|
||||||
|
{
|
||||||
g_GameAttributes.map = "Death Canyon";
|
g_GameAttributes.map = "Death Canyon";
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
g_GameAttributes.map = "Median Oasis";
|
g_GameAttributes.map = "Median Oasis";
|
||||||
|
}
|
||||||
|
|
||||||
mapTypes.selected = 0;
|
mapTypes.selected = 0;
|
||||||
mapFilters.selected = 0;
|
mapFilters.selected = 0;
|
||||||
@ -147,10 +151,14 @@ function initMain()
|
|||||||
victoryConditions.onSelectionChange = function()
|
victoryConditions.onSelectionChange = function()
|
||||||
{ // Update attributes so other players can see change
|
{ // Update attributes so other players can see change
|
||||||
if (this.selected != -1)
|
if (this.selected != -1)
|
||||||
|
{
|
||||||
g_GameAttributes.settings.GameType = this.list_data[this.selected];
|
g_GameAttributes.settings.GameType = this.list_data[this.selected];
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_IsInGuiUpdate)
|
if (!g_IsInGuiUpdate)
|
||||||
|
{
|
||||||
updateGameAttributes();
|
updateGameAttributes();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
victoryConditions.selected = -1;
|
victoryConditions.selected = -1;
|
||||||
|
|
||||||
@ -160,10 +168,14 @@ function initMain()
|
|||||||
mapSize.onSelectionChange = function()
|
mapSize.onSelectionChange = function()
|
||||||
{ // Update attributes so other players can see change
|
{ // Update attributes so other players can see change
|
||||||
if (this.selected != -1)
|
if (this.selected != -1)
|
||||||
|
{
|
||||||
g_GameAttributes.settings.Size = this.list_data[this.selected];
|
g_GameAttributes.settings.Size = this.list_data[this.selected];
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_IsInGuiUpdate)
|
if (!g_IsInGuiUpdate)
|
||||||
|
{
|
||||||
updateGameAttributes();
|
updateGameAttributes();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
mapSize.selected = 1;
|
mapSize.selected = 1;
|
||||||
|
|
||||||
@ -172,7 +184,9 @@ function initMain()
|
|||||||
g_GameAttributes.settings.RevealMap = this.checked;
|
g_GameAttributes.settings.RevealMap = this.checked;
|
||||||
|
|
||||||
if (!g_IsInGuiUpdate)
|
if (!g_IsInGuiUpdate)
|
||||||
|
{
|
||||||
updateGameAttributes();
|
updateGameAttributes();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
getGUIObjectByName("lockTeams").onPress = function()
|
getGUIObjectByName("lockTeams").onPress = function()
|
||||||
@ -180,7 +194,9 @@ function initMain()
|
|||||||
g_GameAttributes.settings.LockTeams = this.checked;
|
g_GameAttributes.settings.LockTeams = this.checked;
|
||||||
|
|
||||||
if (!g_IsInGuiUpdate)
|
if (!g_IsInGuiUpdate)
|
||||||
|
{
|
||||||
updateGameAttributes();
|
updateGameAttributes();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -235,10 +251,14 @@ function initMain()
|
|||||||
team.onSelectionChange = function()
|
team.onSelectionChange = function()
|
||||||
{ // Update team
|
{ // Update team
|
||||||
if (this.selected != -1)
|
if (this.selected != -1)
|
||||||
|
{
|
||||||
g_GameAttributes.settings.PlayerData[playerSlot].Team = this.selected - 1;
|
g_GameAttributes.settings.PlayerData[playerSlot].Team = this.selected - 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_IsInGuiUpdate)
|
if (!g_IsInGuiUpdate)
|
||||||
|
{
|
||||||
updateGameAttributes();
|
updateGameAttributes();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set events
|
// Set events
|
||||||
@ -246,10 +266,14 @@ function initMain()
|
|||||||
civ.onSelectionChange = function()
|
civ.onSelectionChange = function()
|
||||||
{ // Update civ
|
{ // Update civ
|
||||||
if (this.selected != -1)
|
if (this.selected != -1)
|
||||||
|
{
|
||||||
g_GameAttributes.settings.PlayerData[playerSlot].Civ = this.list_data[this.selected];
|
g_GameAttributes.settings.PlayerData[playerSlot].Civ = this.list_data[this.selected];
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_IsInGuiUpdate)
|
if (!g_IsInGuiUpdate)
|
||||||
|
{
|
||||||
updateGameAttributes();
|
updateGameAttributes();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +313,9 @@ function handleNetMessage(message)
|
|||||||
|
|
||||||
case "gamesetup":
|
case "gamesetup":
|
||||||
if (message.data) // (the host gets undefined data on first connect, so skip that)
|
if (message.data) // (the host gets undefined data on first connect, so skip that)
|
||||||
|
{
|
||||||
g_GameAttributes = message.data;
|
g_GameAttributes = message.data;
|
||||||
|
}
|
||||||
|
|
||||||
onGameAttributesChange();
|
onGameAttributesChange();
|
||||||
break;
|
break;
|
||||||
@ -297,11 +323,19 @@ function handleNetMessage(message)
|
|||||||
case "players":
|
case "players":
|
||||||
// Find and report all joinings/leavings
|
// Find and report all joinings/leavings
|
||||||
for (var host in message.hosts)
|
for (var host in message.hosts)
|
||||||
|
{
|
||||||
if (! g_PlayerAssignments[host])
|
if (! g_PlayerAssignments[host])
|
||||||
|
{
|
||||||
addChatMessage({ "type": "connect", "username": message.hosts[host].name });
|
addChatMessage({ "type": "connect", "username": message.hosts[host].name });
|
||||||
|
}
|
||||||
|
}
|
||||||
for (var host in g_PlayerAssignments)
|
for (var host in g_PlayerAssignments)
|
||||||
|
{
|
||||||
if (! message.hosts[host])
|
if (! message.hosts[host])
|
||||||
|
{
|
||||||
addChatMessage({ "type": "disconnect", "guid": host });
|
addChatMessage({ "type": "disconnect", "guid": host });
|
||||||
|
}
|
||||||
|
}
|
||||||
// Update the player list
|
// Update the player list
|
||||||
g_PlayerAssignments = message.hosts;
|
g_PlayerAssignments = message.hosts;
|
||||||
updatePlayerList();
|
updatePlayerList();
|
||||||
@ -342,11 +376,15 @@ function getMapDisplayName(map)
|
|||||||
function getSetting(settings, defaults, property)
|
function getSetting(settings, defaults, property)
|
||||||
{
|
{
|
||||||
if (settings && (property in settings))
|
if (settings && (property in settings))
|
||||||
|
{
|
||||||
return settings[property];
|
return settings[property];
|
||||||
|
}
|
||||||
|
|
||||||
// Use defaults
|
// Use defaults
|
||||||
if (defaults && (property in defaults))
|
if (defaults && (property in defaults))
|
||||||
|
{
|
||||||
return defaults[property];
|
return defaults[property];
|
||||||
|
}
|
||||||
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@ -406,8 +444,10 @@ function initMapNameList()
|
|||||||
var mapData = loadMapData(file);
|
var mapData = loadMapData(file);
|
||||||
|
|
||||||
if (g_GameAttributes.mapFilter && mapData && testFilter(g_GameAttributes.mapFilter, mapData.settings))
|
if (g_GameAttributes.mapFilter && mapData && testFilter(g_GameAttributes.mapFilter, mapData.settings))
|
||||||
|
{
|
||||||
mapList.push({ "name": getMapDisplayName(file), "file": file });
|
mapList.push({ "name": getMapDisplayName(file), "file": file });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Alphabetically sort the list, ignoring case
|
// Alphabetically sort the list, ignoring case
|
||||||
mapList.sort(sortNameIgnoreCase);
|
mapList.sort(sortNameIgnoreCase);
|
||||||
@ -419,7 +459,9 @@ function initMapNameList()
|
|||||||
var selected = mapListFiles.indexOf(g_GameAttributes.map);
|
var selected = mapListFiles.indexOf(g_GameAttributes.map);
|
||||||
// Default to the first element if list is not empty and we can't find the one we searched for
|
// Default to the first element if list is not empty and we can't find the one we searched for
|
||||||
if (selected == -1 && mapList.length)
|
if (selected == -1 && mapList.length)
|
||||||
|
{
|
||||||
selected = 0;
|
selected = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Update the list control
|
// Update the list control
|
||||||
mapSelectionBox.list = mapListNames;
|
mapSelectionBox.list = mapListNames;
|
||||||
@ -430,7 +472,9 @@ function initMapNameList()
|
|||||||
function loadMapData(name)
|
function loadMapData(name)
|
||||||
{
|
{
|
||||||
if (!name)
|
if (!name)
|
||||||
|
{
|
||||||
return undefined;
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_MapData[name])
|
if (!g_MapData[name])
|
||||||
{
|
{
|
||||||
@ -481,7 +525,9 @@ function onTick()
|
|||||||
{
|
{
|
||||||
var message = Engine.PollNetworkClient();
|
var message = Engine.PollNetworkClient();
|
||||||
if (!message)
|
if (!message)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
handleNetMessage(message);
|
handleNetMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -492,15 +538,21 @@ function selectNumPlayers(num)
|
|||||||
{
|
{
|
||||||
// Avoid recursion
|
// Avoid recursion
|
||||||
if (g_IsInGuiUpdate)
|
if (g_IsInGuiUpdate)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Network clients can't change number of players
|
// Network clients can't change number of players
|
||||||
if (g_IsNetworked && !g_IsController)
|
if (g_IsNetworked && !g_IsController)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Only meaningful for random maps
|
// Only meaningful for random maps
|
||||||
if (g_GameAttributes.mapType != "random")
|
if (g_GameAttributes.mapType != "random")
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Update player data
|
// Update player data
|
||||||
var pData = g_GameAttributes.settings.PlayerData;
|
var pData = g_GameAttributes.settings.PlayerData;
|
||||||
@ -522,13 +574,18 @@ function selectMapType(type)
|
|||||||
{
|
{
|
||||||
// Avoid recursion
|
// Avoid recursion
|
||||||
if (g_IsInGuiUpdate)
|
if (g_IsInGuiUpdate)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Network clients can't change map type
|
// Network clients can't change map type
|
||||||
if (g_IsNetworked && !g_IsController)
|
if (g_IsNetworked && !g_IsController)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
g_GameAttributes.mapType = type;
|
g_GameAttributes.mapType = type;
|
||||||
|
g_GameAttributes.map = undefined;
|
||||||
|
|
||||||
// Clear old map data
|
// Clear old map data
|
||||||
g_MapData = {};
|
g_MapData = {};
|
||||||
@ -558,11 +615,15 @@ function selectMapFilter(filterName)
|
|||||||
{
|
{
|
||||||
// Avoid recursion
|
// Avoid recursion
|
||||||
if (g_IsInGuiUpdate)
|
if (g_IsInGuiUpdate)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Network clients can't change map filter
|
// Network clients can't change map filter
|
||||||
if (g_IsNetworked && !g_IsController)
|
if (g_IsNetworked && !g_IsController)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
g_GameAttributes.mapFilter = filterName;
|
g_GameAttributes.mapFilter = filterName;
|
||||||
|
|
||||||
@ -576,15 +637,21 @@ function selectMap(name)
|
|||||||
{
|
{
|
||||||
// Avoid recursion
|
// Avoid recursion
|
||||||
if (g_IsInGuiUpdate)
|
if (g_IsInGuiUpdate)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Network clients can't change map
|
// Network clients can't change map
|
||||||
if (g_IsNetworked && !g_IsController)
|
if (g_IsNetworked && !g_IsController)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Return if we have no map
|
// Return if we have no map
|
||||||
if (!name)
|
if (!name)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
g_GameAttributes.map = name;
|
g_GameAttributes.map = name;
|
||||||
|
|
||||||
@ -629,9 +696,11 @@ function selectMap(name)
|
|||||||
var player = g_PlayerAssignments[guid].player;
|
var player = g_PlayerAssignments[guid].player;
|
||||||
|
|
||||||
if (player <= MAX_PLAYERS && player > numPlayers)
|
if (player <= MAX_PLAYERS && player > numPlayers)
|
||||||
|
{
|
||||||
Engine.AssignNetworkPlayer(player, "");
|
Engine.AssignNetworkPlayer(player, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateGameAttributes();
|
updateGameAttributes();
|
||||||
}
|
}
|
||||||
@ -644,6 +713,12 @@ function launchGame()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check that we have a map
|
||||||
|
if (!g_GameAttributes.map)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_IsNetworked)
|
if (g_IsNetworked)
|
||||||
{
|
{
|
||||||
Engine.SetNetworkGameAttributes(g_GameAttributes);
|
Engine.SetNetworkGameAttributes(g_GameAttributes);
|
||||||
@ -658,8 +733,10 @@ function launchGame()
|
|||||||
{
|
{
|
||||||
var assignBox = getGUIObjectByName("playerAssignment["+i+"]");
|
var assignBox = getGUIObjectByName("playerAssignment["+i+"]");
|
||||||
if (assignBox.list_data[assignBox.selected] == "local")
|
if (assignBox.list_data[assignBox.selected] == "local")
|
||||||
|
{
|
||||||
playerID = i+1;
|
playerID = i+1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Remove extra player data
|
// Remove extra player data
|
||||||
g_GameAttributes.settings.PlayerData = g_GameAttributes.settings.PlayerData.slice(0, numPlayers);
|
g_GameAttributes.settings.PlayerData = g_GameAttributes.settings.PlayerData.slice(0, numPlayers);
|
||||||
|
|
||||||
@ -836,10 +913,14 @@ function onGameAttributesChange()
|
|||||||
function updateGameAttributes()
|
function updateGameAttributes()
|
||||||
{
|
{
|
||||||
if (g_IsNetworked)
|
if (g_IsNetworked)
|
||||||
|
{
|
||||||
Engine.SetNetworkGameAttributes(g_GameAttributes);
|
Engine.SetNetworkGameAttributes(g_GameAttributes);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
onGameAttributesChange();
|
onGameAttributesChange();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updatePlayerList()
|
function updatePlayerList()
|
||||||
{
|
{
|
||||||
@ -891,9 +972,13 @@ function updatePlayerList()
|
|||||||
{
|
{
|
||||||
var aiId = g_GameAttributes.settings.PlayerData[playerSlot].AI;
|
var aiId = g_GameAttributes.settings.PlayerData[playerSlot].AI;
|
||||||
if (aiId)
|
if (aiId)
|
||||||
|
{
|
||||||
selection = aiAssignments[aiId];
|
selection = aiAssignments[aiId];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
selection = noAssignment;
|
selection = noAssignment;
|
||||||
|
}
|
||||||
|
|
||||||
// Since no human is assigned, show the AI config button
|
// Since no human is assigned, show the AI config button
|
||||||
if (g_IsController)
|
if (g_IsController)
|
||||||
@ -908,10 +993,14 @@ function updatePlayerList()
|
|||||||
g_GameAttributes.settings.PlayerData[playerSlot].AI = ai.id;
|
g_GameAttributes.settings.PlayerData[playerSlot].AI = ai.id;
|
||||||
|
|
||||||
if (g_IsNetworked)
|
if (g_IsNetworked)
|
||||||
|
{
|
||||||
Engine.SetNetworkGameAttributes(g_GameAttributes);
|
Engine.SetNetworkGameAttributes(g_GameAttributes);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
updatePlayerList();
|
updatePlayerList();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -924,15 +1013,19 @@ function updatePlayerList()
|
|||||||
{
|
{
|
||||||
g_GameAttributes.settings.PlayerData[playerSlot].AI = "";
|
g_GameAttributes.settings.PlayerData[playerSlot].AI = "";
|
||||||
if (g_IsNetworked)
|
if (g_IsNetworked)
|
||||||
|
{
|
||||||
Engine.SetNetworkGameAttributes(g_GameAttributes);
|
Engine.SetNetworkGameAttributes(g_GameAttributes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var assignBox = getGUIObjectByName("playerAssignment["+i+"]");
|
var assignBox = getGUIObjectByName("playerAssignment["+i+"]");
|
||||||
assignBox.list = hostNameList;
|
assignBox.list = hostNameList;
|
||||||
assignBox.list_data = hostGuidList;
|
assignBox.list_data = hostGuidList;
|
||||||
if (assignBox.selected != selection)
|
if (assignBox.selected != selection)
|
||||||
|
{
|
||||||
assignBox.selected = selection;
|
assignBox.selected = selection;
|
||||||
|
}
|
||||||
|
|
||||||
if (g_IsNetworked && g_IsController)
|
if (g_IsNetworked && g_IsController)
|
||||||
{
|
{
|
||||||
@ -1108,13 +1201,17 @@ function testFilter(name, mapSettings)
|
|||||||
function keywordTestAND(keywords, matches)
|
function keywordTestAND(keywords, matches)
|
||||||
{
|
{
|
||||||
if (!keywords || !matches)
|
if (!keywords || !matches)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (var m = 0; m < matches.length; ++m)
|
for (var m = 0; m < matches.length; ++m)
|
||||||
{ // Fail on not match
|
{ // Fail on not match
|
||||||
if (keywords.indexOf(matches[m]) == -1)
|
if (keywords.indexOf(matches[m]) == -1)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1122,12 +1219,16 @@ function keywordTestAND(keywords, matches)
|
|||||||
function keywordTestOR(keywords, matches)
|
function keywordTestOR(keywords, matches)
|
||||||
{
|
{
|
||||||
if (!keywords || !matches)
|
if (!keywords || !matches)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (var m = 0; m < matches.length; ++m)
|
for (var m = 0; m < matches.length; ++m)
|
||||||
{ // Success on match
|
{ // Success on match
|
||||||
if (keywords.indexOf(matches[m]) != -1)
|
if (keywords.indexOf(matches[m]) != -1)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ const tOceanCoral = "medit_sea_coral_plants";
|
|||||||
const tBeachWet = "medit_sand_wet";
|
const tBeachWet = "medit_sand_wet";
|
||||||
const tBeachDry = "medit_sand";
|
const tBeachDry = "medit_sand";
|
||||||
const tBeachGrass = "medit_rocks_grass";
|
const tBeachGrass = "medit_rocks_grass";
|
||||||
const tBeachCliff = "cliff_medit_beach";
|
const tBeachCliff = "medit_dirt";
|
||||||
const tGrassDry = ["medit_grass_field_brown", "medit_grass_field_dry", "medit_grass_field_b"];
|
const tGrassDry = ["medit_grass_field_brown", "medit_grass_field_dry", "medit_grass_field_b"];
|
||||||
const tGrass = ["medit_grass_field_dry", "medit_grass_field_brown", "medit_grass_field_b"];
|
const tGrass = ["medit_grass_field_dry", "medit_grass_field_brown", "medit_grass_field_b"];
|
||||||
const tGrassLush = ["grass_temperate_dry_tufts", "medit_grass_flowers"];
|
const tGrassLush = ["grass_temperate_dry_tufts", "medit_grass_flowers"];
|
||||||
@ -116,7 +116,7 @@ for (var i=1; i <= numPlayers; i++)
|
|||||||
// create TC and starting units
|
// create TC and starting units
|
||||||
// TODO: Get civ specific starting units
|
// TODO: Get civ specific starting units
|
||||||
var civ = getCivCode(i - 1);
|
var civ = getCivCode(i - 1);
|
||||||
placeObject("structures/"+civ + "_civil_centre", i, ix, iy, PI*3/4);
|
placeObject(ix, iy, "structures/"+civ + "_civil_centre", i, PI*3/4);
|
||||||
var group = new SimpleGroup(
|
var group = new SimpleGroup(
|
||||||
[new SimpleObject("units/"+civ+"_support_female_citizen", 3,3, 5,5)],
|
[new SimpleObject("units/"+civ+"_support_female_citizen", 3,3, 5,5)],
|
||||||
true, null, ix, iy
|
true, null, ix, iy
|
||||||
@ -413,7 +413,7 @@ for (var ix=0; ix<mapSize; ix++)
|
|||||||
t = (maxH - minH > 1.2) ? tGrassCliff : tGrassDry;
|
t = (maxH - minH > 1.2) ? tGrassCliff : tGrassDry;
|
||||||
if (maxH - minH < 0.5 && randFloat() < 0.03)
|
if (maxH - minH < 0.5 && randFloat() < 0.03)
|
||||||
{
|
{
|
||||||
placeObject(aGrassDry, 0, ix+randFloat(), iy+randFloat(), randFloat()*2*PI);
|
placeObject(ix+randFloat(), iy+randFloat(), aGrassDry, 0, randFloat()*2*PI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (grassNoise > 0.61)
|
else if (grassNoise > 0.61)
|
||||||
@ -424,7 +424,7 @@ for (var ix=0; ix<mapSize; ix++)
|
|||||||
{
|
{
|
||||||
if ((maxH - minH) < 0.5 && randFloat() < 0.05)
|
if ((maxH - minH) < 0.5 && randFloat() < 0.05)
|
||||||
{
|
{
|
||||||
placeObject(aGrass, 0, ix+randFloat(), iy+randFloat(), randFloat()*2*PI);
|
placeObject(ix+randFloat(), iy+randFloat(), aGrass, 0, randFloat()*2*PI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
"settings" : {
|
"settings" : {
|
||||||
"Name" : "New RMS Test",
|
"Name" : "New RMS Test",
|
||||||
"Script" : "new_rms_test.js",
|
"Script" : "new_rms_test.js",
|
||||||
"Description" : "A test of the new integrated random map generator!",
|
"Description" : "A basic test of the random map generator - not playable",
|
||||||
"BaseTerrain" : "grass1_spring",
|
"BaseTerrain" : "grass1_spring",
|
||||||
"BaseHeight" : 0,
|
"BaseHeight" : 0,
|
||||||
|
"Keywords": ["demo"],
|
||||||
"XXXXXX" : "Optionally define other things here, like we would for a scenario"
|
"XXXXXX" : "Optionally define other things here, like we would for a scenario"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,12 +27,12 @@ function tilesToFraction(t)
|
|||||||
|
|
||||||
function fractionToSize(f)
|
function fractionToSize(f)
|
||||||
{
|
{
|
||||||
return getMapSizeSqr() * f;
|
return getMapArea() * f;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sizeToFraction(s)
|
function sizeToFraction(s)
|
||||||
{
|
{
|
||||||
return s / getMapSizeSqr();
|
return s / getMapArea();
|
||||||
}
|
}
|
||||||
|
|
||||||
function cos(x)
|
function cos(x)
|
||||||
@ -162,7 +162,7 @@ function createAreas(centeredPlacer, painter, constraint, num, retryFactor)
|
|||||||
bad++;
|
bad++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return good;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createObjectGroups(placer, player, constraint, num, retryFactor)
|
function createObjectGroups(placer, player, constraint, num, retryFactor)
|
||||||
@ -245,7 +245,7 @@ function createSimpleTerrain(terrain)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function placeObject(type, player, x, y, angle)
|
function placeObject(x, y, type, player, angle)
|
||||||
{
|
{
|
||||||
g_Map.addObjects(new Entity(type, player, x, y, angle));
|
g_Map.addObjects(new Entity(type, player, x, y, angle));
|
||||||
}
|
}
|
||||||
@ -297,7 +297,7 @@ function getMapSize()
|
|||||||
return g_Map.size;
|
return g_Map.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMapSizeSqr()
|
function getMapArea()
|
||||||
{
|
{
|
||||||
return g_Map.size*g_Map.size;
|
return g_Map.size*g_Map.size;
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ var g_Map;
|
|||||||
|
|
||||||
var g_Environment = {
|
var g_Environment = {
|
||||||
SkySet: "default",
|
SkySet: "default",
|
||||||
SunColour: {r: 1.5, g: 1.5, b: 1.5, a: 0},
|
SunColour: {r: 0.749020, g: 0.749020, b: 0.749020, a: 0},
|
||||||
SunElevation: 0.785398,
|
SunElevation: 0.785398,
|
||||||
SunRotation: 5.49779,
|
SunRotation: 5.49779,
|
||||||
TerrainAmbientColour: {r: 0.313726, g: 0.376471, b: 0.521569, a: 0},
|
TerrainAmbientColour: {r: 0.501961, g: 0.501961, b: 0.501961, a: 0},
|
||||||
UnitsAmbientColour: {r: 0.501961, g: 0.501961, b: 0.501961, a: 0},
|
UnitsAmbientColour: {r: 0.501961, g: 0.501961, b: 0.501961, a: 0},
|
||||||
Water: {
|
Water: {
|
||||||
WaterBody: {
|
WaterBody: {
|
||||||
|
@ -15,9 +15,10 @@ function ClumpPlacer(size, coherence, smoothness, failFraction, x, y)
|
|||||||
|
|
||||||
ClumpPlacer.prototype.place = function(constraint)
|
ClumpPlacer.prototype.place = function(constraint)
|
||||||
{
|
{
|
||||||
|
// Preliminary bounds check
|
||||||
if (!g_Map.validT(this.x, this.y) || !constraint.allows(this.x, this.y))
|
if (!g_Map.validT(this.x, this.y) || !constraint.allows(this.x, this.y))
|
||||||
{
|
{
|
||||||
return false;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
var retVec = [];
|
var retVec = [];
|
||||||
@ -42,6 +43,7 @@ ClumpPlacer.prototype.place = function(constraint)
|
|||||||
var ctrlCoords = new Float32Array(ctrlPts+1); //float32
|
var ctrlCoords = new Float32Array(ctrlPts+1); //float32
|
||||||
var ctrlVals = new Float32Array(ctrlPts+1); //float32
|
var ctrlVals = new Float32Array(ctrlPts+1); //float32
|
||||||
|
|
||||||
|
// Generate some interpolated noise
|
||||||
for (var i=0; i < ctrlPts; i++)
|
for (var i=0; i < ctrlPts; i++)
|
||||||
{
|
{
|
||||||
ctrlCoords[i] = i * perim / ctrlPts;
|
ctrlCoords[i] = i * perim / ctrlPts;
|
||||||
@ -59,6 +61,7 @@ ClumpPlacer.prototype.place = function(constraint)
|
|||||||
looped = 1;
|
looped = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cubic interpolation of ctrlVals
|
||||||
var t = (i - ctrlCoords[c]) / ((looped ? perim : ctrlCoords[(c+1)%ctrlPts]) - ctrlCoords[c]);
|
var t = (i - ctrlCoords[c]) / ((looped ? perim : ctrlCoords[(c+1)%ctrlPts]) - ctrlCoords[c]);
|
||||||
var v0 = ctrlVals[(c+ctrlPts-1)%ctrlPts];
|
var v0 = ctrlVals[(c+ctrlPts-1)%ctrlPts];
|
||||||
var v1 = ctrlVals[c];
|
var v1 = ctrlVals[c];
|
||||||
@ -123,6 +126,13 @@ function RectPlacer(x1, y1, x2, y2)
|
|||||||
|
|
||||||
RectPlacer.prototype.place = function(constraint)
|
RectPlacer.prototype.place = function(constraint)
|
||||||
{
|
{
|
||||||
|
// Preliminary bounds check
|
||||||
|
if (!g_Map.validT(this.x1, this.y1) || !constraint.allows(this.x1, this.y1) ||
|
||||||
|
!g_Map.validT(this.x2, this.y2) || !constraint.allows(this.x2, this.y2))
|
||||||
|
{
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
var ret = [];
|
var ret = [];
|
||||||
|
|
||||||
var x2 = this.x2;
|
var x2 = this.x2;
|
||||||
@ -144,7 +154,6 @@ RectPlacer.prototype.place = function(constraint)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user