diff --git a/src/editor/editloop.cpp b/src/editor/editloop.cpp index 74268b2e1..5f2782e73 100644 --- a/src/editor/editloop.cpp +++ b/src/editor/editloop.cpp @@ -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 diff --git a/src/editor/edmap.cpp b/src/editor/edmap.cpp index 53a8b3f97..1b5c389ab 100644 --- a/src/editor/edmap.cpp +++ b/src/editor/edmap.cpp @@ -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 diff --git a/src/map/map.cpp b/src/map/map.cpp index 40900c9d0..f21a2f783 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -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); diff --git a/src/map/script_map.cpp b/src/map/script_map.cpp index 4c66b05e6..03129546e 100644 --- a/src/map/script_map.cpp +++ b/src/map/script_map.cpp @@ -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; @@ -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);