Wrong Tile Index being set in CMap::RegenerateForestTile

Bug #1437798 reported by Andre Novellino Gouvêa
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Stratagus
Won't Fix
Undecided
Unassigned

Bug Description

The wrong Tile Index is being set in CMap::RegenerateForestTile. The two instances of setTileIndex in that function are as such:

topMf.setTileIndex(*Map.Tileset, Map.Tileset->getTopOneTreeTile(), 0);
[...]
mf.setTileIndex(*Map.Tileset, Map.Tileset->getBottomOneTreeTile(), 0);

But getTopOneTreeTile() and getBottomOneTreeTile() do not return tile indexes at all, but the graphic tile (i.e., which frame of the tileset to get the tile's graphic from, rather than the actual tile index of that sort of tile). To solve this, doing the following is needed: first, replace those instances of setTileIndex with these ones:

topMf.setTileIndex(*Map.Tileset, Map.Tileset->getDefaultWoodTileIndex(), 0);
[...]
mf.setTileIndex(*Map.Tileset, Map.Tileset->getDefaultWoodTileIndex(), 0);

...and then, add the following function to tileset.cpp (I added it just below CTileset::getDefaultTileIndex()):

unsigned int CTileset::getDefaultWoodTileIndex() const
{
 const int n = tiles.size();
 int solid = 0;
 for (int i = 0; i < n;) {
  const CTile &tile = tiles[i];
  const CTileInfo &tileinfo = tile.tileinfo;
  if (tileinfo.BaseTerrain && tileinfo.MixTerrain) {
   i += 256;
  } else {
   if (tileinfo.BaseTerrain != 0 && tileinfo.MixTerrain == 0) {
    if (tile.flag & MapFieldForest) {
     solid = i;
    }
   }
   i += 16;
  }
 }
 return solid;
}

...and of course, that function in tileset.h:

unsigned int getDefaultWoodTileIndex() const;

...and that's all :)

Revision history for this message
timfelgentreff (timfelgentreff) wrote : Moving to GitHub

This project was moved to https://github.com/Wargus/stratagus. All issues were migrated there.

Changed in stratagus:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.