Remove hardcoded limitation on mapsize everywhere except minimap
This commit is contained in:
@@ -256,6 +256,11 @@ namespace OpenRA.FileFormats
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsInMap(int2 xy)
|
||||||
|
{
|
||||||
|
return IsInMap(xy.X,xy.Y);
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsInMap(int x, int y)
|
public bool IsInMap(int x, int y)
|
||||||
{
|
{
|
||||||
return (x >= XOffset && y >= YOffset && x < XOffset + Width && y < YOffset + Height);
|
return (x >= XOffset && y >= YOffset && x < XOffset + Width && y < YOffset + Height);
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -160,9 +160,9 @@ namespace OpenRA
|
|||||||
|
|
||||||
static CellInfo[ , ] InitCellInfo()
|
static CellInfo[ , ] InitCellInfo()
|
||||||
{
|
{
|
||||||
var cellInfo = new CellInfo[ 128, 128 ];
|
var cellInfo = new CellInfo[ Game.world.Map.MapSize, Game.world.Map.MapSize ];
|
||||||
for( int x = 0 ; x < 128 ; x++ )
|
for( int x = 0 ; x < Game.world.Map.MapSize ; x++ )
|
||||||
for( int y = 0 ; y < 128 ; y++ )
|
for( int y = 0 ; y < Game.world.Map.MapSize ; y++ )
|
||||||
cellInfo[ x, y ] = new CellInfo( float.PositiveInfinity, new int2( x, y ), false );
|
cellInfo[ x, y ] = new CellInfo( float.PositiveInfinity, new int2( x, y ), false );
|
||||||
return cellInfo;
|
return cellInfo;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,22 +30,31 @@ namespace OpenRA
|
|||||||
{
|
{
|
||||||
public class Shroud
|
public class Shroud
|
||||||
{
|
{
|
||||||
bool[,] explored = new bool[128, 128];
|
bool[,] explored;
|
||||||
Sprite[] shadowBits = SpriteSheetBuilder.LoadAllSprites("shadow");
|
Sprite[] shadowBits = SpriteSheetBuilder.LoadAllSprites("shadow");
|
||||||
Sprite[,] sprites = new Sprite[128, 128];
|
Sprite[,] sprites;
|
||||||
|
int gapOpaqueTicks = (int)(Rules.General.GapRegenInterval * 25 * 60);
|
||||||
|
int gapTicks;
|
||||||
|
int[,] gapField;
|
||||||
|
bool[,] gapActive;
|
||||||
|
|
||||||
bool dirty = true;
|
bool dirty = true;
|
||||||
bool hasGPS = false;
|
bool hasGPS = false;
|
||||||
Player owner;
|
Player owner;
|
||||||
Map map;
|
Map map;
|
||||||
public Rectangle? bounds;
|
public Rectangle? bounds;
|
||||||
|
|
||||||
public Shroud(Player owner, Map map) { this.owner = owner; this.map = map; }
|
public Shroud(Player owner, Map map)
|
||||||
|
{
|
||||||
int gapOpaqueTicks = (int)(Rules.General.GapRegenInterval * 25 * 60);
|
this.owner = owner;
|
||||||
int gapTicks;
|
this.map = map;
|
||||||
int[,] gapField = new int[128, 128];
|
|
||||||
bool[,] gapActive = new bool[128, 128];
|
explored = new bool[map.MapSize, map.MapSize];
|
||||||
|
sprites = new Sprite[map.MapSize, map.MapSize];
|
||||||
|
gapField = new int[map.MapSize, map.MapSize];
|
||||||
|
gapActive = new bool[map.MapSize, map.MapSize];
|
||||||
|
}
|
||||||
|
|
||||||
public bool HasGPS
|
public bool HasGPS
|
||||||
{
|
{
|
||||||
get { return hasGPS; }
|
get { return hasGPS; }
|
||||||
@@ -57,7 +66,7 @@ namespace OpenRA
|
|||||||
if (gapTicks > 0) { --gapTicks; return; }
|
if (gapTicks > 0) { --gapTicks; return; }
|
||||||
|
|
||||||
// Clear active flags
|
// Clear active flags
|
||||||
gapActive = new bool[128, 128];
|
gapActive = new bool[map.MapSize, map.MapSize];
|
||||||
foreach (var a in world.Queries.WithTrait<GeneratesGap>().Where(a => owner != a.Actor.Owner))
|
foreach (var a in world.Queries.WithTrait<GeneratesGap>().Where(a => owner != a.Actor.Owner))
|
||||||
foreach (var t in a.Trait.GetShroudedTiles())
|
foreach (var t in a.Trait.GetShroudedTiles())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using OpenRA.GameRules;
|
using OpenRA.GameRules;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
{
|
{
|
||||||
@@ -29,11 +30,17 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public class BuildingInfluence
|
public class BuildingInfluence
|
||||||
{
|
{
|
||||||
bool[,] blocked = new bool[128, 128];
|
bool[,] blocked;
|
||||||
Actor[,] influence = new Actor[128, 128];
|
Actor[,] influence;
|
||||||
|
Map map;
|
||||||
|
|
||||||
public BuildingInfluence( Actor self )
|
public BuildingInfluence( Actor self )
|
||||||
{
|
{
|
||||||
|
map = self.World.Map;
|
||||||
|
|
||||||
|
blocked = new bool[map.MapSize, map.MapSize];
|
||||||
|
influence = new Actor[map.MapSize, map.MapSize];
|
||||||
|
|
||||||
self.World.ActorAdded +=
|
self.World.ActorAdded +=
|
||||||
a => { if (a.traits.Contains<Building>())
|
a => { if (a.traits.Contains<Building>())
|
||||||
ChangeInfluence(a, a.traits.Get<Building>(), true); };
|
ChangeInfluence(a, a.traits.Get<Building>(), true); };
|
||||||
@@ -45,27 +52,22 @@ namespace OpenRA.Traits
|
|||||||
void ChangeInfluence( Actor a, Building building, bool isAdd )
|
void ChangeInfluence( Actor a, Building building, bool isAdd )
|
||||||
{
|
{
|
||||||
foreach( var u in Footprint.UnpathableTiles( a.Info.Name, a.Info.Traits.Get<BuildingInfo>(), a.Location ) )
|
foreach( var u in Footprint.UnpathableTiles( a.Info.Name, a.Info.Traits.Get<BuildingInfo>(), a.Location ) )
|
||||||
if( IsValid( u ) )
|
if( map.IsInMap( u ) )
|
||||||
blocked[ u.X, u.Y ] = isAdd;
|
blocked[ u.X, u.Y ] = isAdd;
|
||||||
|
|
||||||
foreach( var u in Footprint.Tiles( a.Info.Name, a.Info.Traits.Get<BuildingInfo>(), a.Location ) )
|
foreach( var u in Footprint.Tiles( a.Info.Name, a.Info.Traits.Get<BuildingInfo>(), a.Location ) )
|
||||||
if( IsValid( u ) )
|
if( map.IsInMap( u ) )
|
||||||
influence[ u.X, u.Y ] = isAdd ? a : null;
|
influence[ u.X, u.Y ] = isAdd ? a : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsValid(int2 t)
|
|
||||||
{
|
|
||||||
return !(t.X < 0 || t.Y < 0 || t.X >= 128 || t.Y >= 128);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Actor GetBuildingAt(int2 cell)
|
public Actor GetBuildingAt(int2 cell)
|
||||||
{
|
{
|
||||||
if (!IsValid(cell)) return null;
|
if (!map.IsInMap(cell)) return null;
|
||||||
return influence[cell.X, cell.Y];
|
return influence[cell.X, cell.Y];
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanMoveHere(int2 cell)
|
public bool CanMoveHere(int2 cell)
|
||||||
{
|
{
|
||||||
return IsValid(cell) && !blocked[cell.X, cell.Y];
|
return map.IsInMap(cell) && !blocked[cell.X, cell.Y];
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ namespace OpenRA.Traits
|
|||||||
var mini = map.XOffset; var maxi = map.XOffset + map.Width;
|
var mini = map.XOffset; var maxi = map.XOffset + map.Width;
|
||||||
var minj = map.YOffset; var maxj = map.YOffset + map.Height;
|
var minj = map.YOffset; var maxj = map.YOffset + map.Height;
|
||||||
|
|
||||||
var newDensity = new byte[128, 128];
|
var newDensity = new byte[map.MapSize, map.MapSize];
|
||||||
for (int j = minj; j < maxj; j++)
|
for (int j = minj; j < maxj; j++)
|
||||||
for (int i = mini; i < maxi; i++)
|
for (int i = mini; i < maxi; i++)
|
||||||
if (content[i, j].type == info)
|
if (content[i, j].type == info)
|
||||||
@@ -171,7 +171,7 @@ namespace OpenRA.Traits
|
|||||||
var mini = map.XOffset; var maxi = map.XOffset + map.Width;
|
var mini = map.XOffset; var maxi = map.XOffset + map.Width;
|
||||||
var minj = map.YOffset; var maxj = map.YOffset + map.Height;
|
var minj = map.YOffset; var maxj = map.YOffset + map.Height;
|
||||||
|
|
||||||
var growMask = new bool[128, 128];
|
var growMask = new bool[map.MapSize, map.MapSize];
|
||||||
for (int j = minj; j < maxj; j++)
|
for (int j = minj; j < maxj; j++)
|
||||||
for (int i = mini; i < maxi; i++)
|
for (int i = mini; i < maxi; i++)
|
||||||
if (content[i,j].type == null
|
if (content[i,j].type == null
|
||||||
|
|||||||
@@ -32,12 +32,14 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public class UnitInfluence : ITick
|
public class UnitInfluence : ITick
|
||||||
{
|
{
|
||||||
List<Actor>[,] influence = new List<Actor>[128, 128];
|
List<Actor>[,] influence;
|
||||||
|
|
||||||
public UnitInfluence( Actor self )
|
public UnitInfluence( Actor self )
|
||||||
{
|
{
|
||||||
for (int i = 0; i < self.World.Map.MapSize; i++)
|
int size = self.World.Map.MapSize;
|
||||||
for (int j = 0; j < self.World.Map.MapSize; j++)
|
influence = new List<Actor>[size, size];
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
for (int j = 0; j < size; j++)
|
||||||
influence[ i, j ] = new List<Actor>();
|
influence[ i, j ] = new List<Actor>();
|
||||||
|
|
||||||
self.World.ActorRemoved += a => Remove( a, a.traits.GetOrDefault<IOccupySpace>() );
|
self.World.ActorRemoved += a => Remove( a, a.traits.GetOrDefault<IOccupySpace>() );
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ namespace OpenRA
|
|||||||
public readonly TileSet TileSet;
|
public readonly TileSet TileSet;
|
||||||
|
|
||||||
// for tricky things like bridges.
|
// for tricky things like bridges.
|
||||||
public readonly ICustomTerrain[,] customTerrain = new ICustomTerrain[128, 128];
|
public readonly ICustomTerrain[,] customTerrain;
|
||||||
|
|
||||||
public readonly WorldRenderer WorldRenderer;
|
public readonly WorldRenderer WorldRenderer;
|
||||||
internal readonly Minimap Minimap;
|
internal readonly Minimap Minimap;
|
||||||
@@ -76,6 +76,7 @@ namespace OpenRA
|
|||||||
Timer.Time( "----World.ctor" );
|
Timer.Time( "----World.ctor" );
|
||||||
|
|
||||||
Map = new Map( Game.LobbyInfo.GlobalSettings.Map );
|
Map = new Map( Game.LobbyInfo.GlobalSettings.Map );
|
||||||
|
customTerrain = new ICustomTerrain[Map.MapSize, Map.MapSize];
|
||||||
Timer.Time( "new Map: {0}" );
|
Timer.Time( "new Map: {0}" );
|
||||||
|
|
||||||
TheaterInfo theaterInfo = Rules.Info["world"].Traits.WithInterface<TheaterInfo>().Where(t => t.Theater == Map.Theater).FirstOrDefault();
|
TheaterInfo theaterInfo = Rules.Info["world"].Traits.WithInterface<TheaterInfo>().Where(t => t.Theater == Map.Theater).FirstOrDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user