Skip to content

Commit

Permalink
Some bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ostaf committed Oct 19, 2013
1 parent 3ef489e commit 0307ed0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
10 changes: 4 additions & 6 deletions ClientServices/Map/MapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,12 @@ public void Init()

public bool LoadTileMap(NetIncomingMessage message)
{
var _mapLoadWidth = message.ReadInt32();
var _mapLoadHeight = message.ReadInt32();
int _mapWidth = message.ReadInt32();
int _mapHeight = message.ReadInt32();

_mapWidth = _mapLoadWidth;
_mapHeight = _mapLoadHeight;

_tileArray = new RectangleTree<Tile>(TilePos,
new Rectangle(-(_mapWidth/2)*TileSpacing, -(_mapHeight/2)*TileSpacing,
new Rectangle(0, 0,
_mapWidth*TileSpacing, _mapHeight*TileSpacing));

while (message.PositionInBytes < message.LengthBytes)
Expand All @@ -101,7 +99,7 @@ public bool LoadTileMap(NetIncomingMessage message)
_tileArray.Add(newTile);
}

foreach (Tile t in _tileArray.GetItems(new Rectangle(0, 0, _mapLoadWidth * TileSpacing, _mapLoadHeight * TileSpacing)))
foreach (Tile t in _tileArray.GetItems(new Rectangle(0, 0, _mapWidth * TileSpacing, _mapHeight * TileSpacing)))
{
t.surroundingTiles[0] = GetTileN(t.Position.X, t.Position.Y);
t.surroundingTiles[1] = GetTileE(t.Position.X, t.Position.Y);
Expand Down
10 changes: 2 additions & 8 deletions ServerServices/Atmos/AtmosManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,9 @@ public void InitializeGasCells()
t.GasCell.InitSTP();
}

foreach(Tile t in m.GetITilesIn(new RectangleF(0, 0, m.GetMapWidth() * m.GetTileSpacing(), m.GetMapHeight() * m.GetTileSpacing())))
foreach(Tile t in m.GetITilesIn(m.GetWorldArea()))
{
t.gasCell = new GasCell(t);
if(t.StartWithAtmos)
{
t.gasCell.InitSTP();
t.gasCell.SetNeighbours(m);
}

t.gasCell.SetNeighbours(m);
}
}

Expand Down
5 changes: 3 additions & 2 deletions ServerServices/Atmos/GasCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,13 @@ public void CalculateNextGasAmount(IMapManager m)
if (Math.Abs(i) + Math.Abs(j) == 2) //If its a corner
{
if (!neighbours[i + 1, 1].GasPermeable && !neighbours[1, j + 1].GasPermeable)
//&& !m.GetTileFromIndex(arrX + i, arrY).GasPermeable && !m.GetTileFromIndex(arrX, arrY + i).GasPermeable)
{
// And it is a corner separated from us by 2 blocking walls
continue; //Don't process it. These cells are not connected.
}
}

if (neighbor == null || neighbor.Calculated) // if neighbor's already been calculated, skip it
if (neighbor.Calculated) // if neighbor's already been calculated, skip it
continue;

if (neighbor.attachedTile.GasPermeable)
Expand Down
6 changes: 2 additions & 4 deletions ServerServices/Map/MapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,7 @@ private bool LoadMap(string filename)

worldArea = new RectangleF(0, 0, mapWidth * tileSpacing, mapHeight * tileSpacing);

tileArray = new RectangleTree<Tile>(TilePos, new Rectangle(-(mapWidth / 2) * tileSpacing, -(mapHeight / 2) * tileSpacing,
mapWidth * tileSpacing, mapHeight * tileSpacing));
tileArray = new RectangleTree<Tile>(TilePos, new Rectangle(0, 0, mapWidth * tileSpacing, mapHeight * tileSpacing));

while (!sr.EndOfStream)
{
Expand All @@ -490,8 +489,7 @@ private void NewMap()
LogManager.Log("Cannot find map. Generating blank map.", LogLevel.Warning);
mapWidth = 50;
mapHeight = 50;
tileArray = new RectangleTree<Tile>(TilePos, new Rectangle(-(mapWidth / 2) * tileSpacing, -(mapHeight / 2) * tileSpacing,
mapWidth * tileSpacing, mapHeight * tileSpacing));
tileArray = new RectangleTree<Tile>(TilePos, new Rectangle(0, 0, mapWidth * tileSpacing, mapHeight * tileSpacing));

worldArea = new RectangleF(0, 0, mapWidth * tileSpacing, mapHeight * tileSpacing);

Expand Down

0 comments on commit 0307ed0

Please sign in to comment.