# HG changeset patch # User Alys Brooks # Date 2022-12-27 06:31:07 # Node ID c453ca31e403d0bc619e3c6553dd57dcd3d5195f # Parent 61b56ab85b41c0585038f4ecaaac53c790e008d0 Small tweak for performance. Did some easy changes that seem to make a small difference. diff --git a/isometric-park-fna/FNAGame.cs b/isometric-park-fna/FNAGame.cs --- a/isometric-park-fna/FNAGame.cs +++ b/isometric-park-fna/FNAGame.cs @@ -723,9 +723,9 @@ for (int i = 0; i < this.simulation.map.MapHeight; i++) { - for (int j = 0; j < this.simulation.map.MapWidth; j += 1) + for (int j = 0; j < this.simulation.map.MapWidth; j++) { - drawTileAt(i, j, 1, 1, Color.White, batch); + drawTileAt(i, j, 1, 1, Color.White, batch); this.tilesDrawn++; } } @@ -836,27 +836,32 @@ stopWatch2 = new Stopwatch(); stopWatch2.Start(); #region draw_trees + //Pulling these out seems to make it marginally faster. + List row; + Cell curent_cell; if (this.showTrees) { for (int i = 0; i < this.simulation.map.MapHeight; i++) { + row = this.simulation.map.cells[i]; for (int j = 0; j < this.simulation.map.MapWidth; j += 1) { - if (this.simulation.map.cells[i][j].HasTree) + curent_cell = row[j]; + if (curent_cell.HasTree) { //until we actually simulate: - if (this.simulation.map.cells[i][j].Type == TreeType.GenericDeciduous) { + if (curent_cell.Type == TreeType.GenericDeciduous) { drawTileAt(i, j, 252, 2); // 142, , 262 } - else if (this.simulation.map.cells[i][j].Type == TreeType.Oak) { + else if (curent_cell.Type == TreeType.Oak) { drawTileAt(i, j, 142, 2); } - else if (this.simulation.map.cells[i][j].Type == TreeType.GenericShrub) { + else if (curent_cell.Type == TreeType.GenericShrub) { drawTileAt(i, j, 210, 2); } else { drawTileAt(i, j, 122, 2); //122, 203, 221 } } - else if (this.simulation.map.cells[i][j].Status == CellStatus.DeadTree) { + else if (curent_cell.Status == CellStatus.DeadTree) { drawTileAt(i, j, 141, 2); } }