Skip to content

Commit

Permalink
Resource tiles now automatically have the default resource amount of …
Browse files Browse the repository at this point in the history
…their respective resource as the value
  • Loading branch information
Andrettin committed Apr 10, 2016
1 parent 2e6a909 commit 41979cf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/editor/editloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2260,8 +2260,10 @@ void CEditor::Init()
//Wyrmgus start
// Map.Fields[i].setTileIndex(*Map.Tileset, defaultTile, 0);
int value = 0;
if ((tileset.tiles[tileset.getTileNumber(defaultTile, true, false)].flag & MapFieldForest) || (tileset.tiles[tileset.getTileNumber(defaultTile, true, false)].flag & MapFieldRocks)) {
value = 100;
if (tileset.tiles[tileset.getTileNumber(defaultTile, true, false)].flag & MapFieldForest) {
value = DefaultResourceAmounts[WoodCost];
} else if (tileset.tiles[tileset.getTileNumber(defaultTile, true, false)].flag & MapFieldRocks) {
value = DefaultResourceAmounts[StoneCost];
}
Map.Fields[i].setTileIndex(*Map.Tileset, tileset.getTileNumber(defaultTile, true, false), value);
//Wyrmgus end
Expand Down
6 changes: 4 additions & 2 deletions src/editor/edmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ void EditorChangeTile(const Vec2i &pos, int tileIndex, int d)
//Wyrmgus start
// mf.setTileIndex(*Map.Tileset, tile, 0);
int value = 0;
if ((Map.Tileset->tiles[tile].flag & MapFieldForest) || (Map.Tileset->tiles[tile].flag & MapFieldRocks)) {
value = 500;
if (Map.Tileset->tiles[tile].flag & MapFieldForest) {
value = DefaultResourceAmounts[WoodCost];
} else if (Map.Tileset->tiles[tile].flag & MapFieldRocks) {
value = DefaultResourceAmounts[StoneCost];
}
mf.setTileIndex(*Map.Tileset, tile, value);
//Wyrmgus end
Expand Down
16 changes: 8 additions & 8 deletions src/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,31 +726,31 @@ void CMap::RegenerateForestTile(const Vec2i &pos)
&& ((std::find(this->Tileset->removedTreeTiles.begin(), this->Tileset->removedTreeTiles.end(), horizontalMf.getGraphicTile()) != this->Tileset->removedTreeTiles.end() && (horizontalMf.getFlag() & MapFieldStumps) && horizontalMf.Value >= ForestRegeneration && !(horizontalMf.Flags & occupedFlag)) || (horizontalMf.getFlag() & MapFieldForest))
) {
DebugPrint("Real place wood\n");
verticalMf.setTileIndex(*Map.Tileset, Map.Tileset->getDefaultWoodTileIndex(), 500);
verticalMf.setTileIndex(*Map.Tileset, Map.Tileset->getDefaultWoodTileIndex(), DefaultResourceAmounts[WoodCost]);
verticalMf.setGraphicTile(Map.Tileset->tiles[Map.Tileset->getDefaultWoodTileIndex()].tile);
verticalMf.playerInfo.SeenTile = verticalMf.getGraphicTile();
verticalMf.Value = 500;
verticalMf.Value = DefaultResourceAmounts[WoodCost];
UI.Minimap.UpdateSeenXY(pos + verticalOffset);
UI.Minimap.UpdateXY(pos + verticalOffset);

diagonalMf.setTileIndex(*Map.Tileset, Map.Tileset->getDefaultWoodTileIndex(), 500);
diagonalMf.setTileIndex(*Map.Tileset, Map.Tileset->getDefaultWoodTileIndex(), DefaultResourceAmounts[WoodCost]);
diagonalMf.setGraphicTile(Map.Tileset->tiles[Map.Tileset->getDefaultWoodTileIndex()].tile);
diagonalMf.playerInfo.SeenTile = diagonalMf.getGraphicTile();
diagonalMf.Value = 500;
diagonalMf.Value = DefaultResourceAmounts[WoodCost];
UI.Minimap.UpdateSeenXY(pos + diagonalOffset);
UI.Minimap.UpdateXY(pos + diagonalOffset);

horizontalMf.setTileIndex(*Map.Tileset, Map.Tileset->getDefaultWoodTileIndex(), 500);
horizontalMf.setTileIndex(*Map.Tileset, Map.Tileset->getDefaultWoodTileIndex(), DefaultResourceAmounts[WoodCost]);
horizontalMf.setGraphicTile(Map.Tileset->tiles[Map.Tileset->getDefaultWoodTileIndex()].tile);
horizontalMf.playerInfo.SeenTile = horizontalMf.getGraphicTile();
horizontalMf.Value = 500;
horizontalMf.Value = DefaultResourceAmounts[WoodCost];
UI.Minimap.UpdateSeenXY(pos + horizontalOffset);
UI.Minimap.UpdateXY(pos + horizontalOffset);

mf.setTileIndex(*Map.Tileset, Map.Tileset->getDefaultWoodTileIndex(), 500);
mf.setTileIndex(*Map.Tileset, Map.Tileset->getDefaultWoodTileIndex(), DefaultResourceAmounts[WoodCost]);
mf.setGraphicTile(Map.Tileset->tiles[Map.Tileset->getDefaultWoodTileIndex()].tile);
mf.playerInfo.SeenTile = mf.getGraphicTile();
mf.Value = 500;
mf.Value = DefaultResourceAmounts[WoodCost];
UI.Minimap.UpdateSeenXY(pos);
UI.Minimap.UpdateXY(pos);

Expand Down
18 changes: 18 additions & 0 deletions src/map/script_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,20 @@ static int CclSetForestRegeneration(lua_State *l)
{
LuaCheckArgs(l, 1);
int i = LuaToNumber(l, 1);
//Wyrmgus start
/*
if (i < 0 || i > 255) {
PrintFunction();
fprintf(stdout, "Regeneration speed should be 0 - 255\n");
i = 100;
}
*/
if (i < 0) {
PrintFunction();
fprintf(stdout, "Regeneration speed should be greater than 0\n");
i = 100;
}
//Wyrmgus end
const int old = ForestRegeneration;
ForestRegeneration = i;

Expand Down Expand Up @@ -372,6 +381,15 @@ void SetTile(unsigned int tileIndex, const Vec2i &pos, int value)
//Wyrmgus end
return;
}

//Wyrmgus start
//wood and rock tiles must always begin with the default value for their respective resource types
if (Map.Tileset->tiles[tileIndex].flag & MapFieldForest) {
value = DefaultResourceAmounts[WoodCost];
} else if (Map.Tileset->tiles[tileIndex].flag & MapFieldRocks) {
value = DefaultResourceAmounts[StoneCost];
}
//Wyrmgus end

if (Map.Fields) {
CMapField &mf = *Map.Field(pos);
Expand Down

0 comments on commit 41979cf

Please sign in to comment.