Change indexes into tile arrays to be stored as bytes to save memory.
The index value needs only be big enough to handle all defined terrain types. This is a low number so we can save memory by defining it as a byte. This particularly saves memory for the CustomTerrain field in the Map class, which defines a cell layer for the map using tile indexes, so we can reduce the size of that layer 4x as a result.
This commit is contained in:
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
foreach (var kvp in TerrainSpeeds)
|
||||
{
|
||||
int index;
|
||||
byte index;
|
||||
if (tileSet.TryGetTerrainIndex(kvp.Key, out index))
|
||||
info[index] = kvp.Value;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
return int.MaxValue;
|
||||
|
||||
var index = world.Map.GetTerrainIndex(cell);
|
||||
if (index == -1)
|
||||
if (index == byte.MaxValue)
|
||||
return int.MaxValue;
|
||||
|
||||
return TilesetTerrainInfo[world.TileSet][index].Cost;
|
||||
@@ -526,7 +526,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
public int MovementSpeedForCell(Actor self, CPos cell)
|
||||
{
|
||||
var index = self.World.Map.GetTerrainIndex(cell);
|
||||
if (index == -1)
|
||||
if (index == byte.MaxValue)
|
||||
return 0;
|
||||
|
||||
// TODO: Convert to integers
|
||||
|
||||
Reference in New Issue
Block a user