Skip to content

Commit

Permalink
fix random map gen: treat new_map_x and new_map_y in Spring map dimen…
Browse files Browse the repository at this point in the history
…sions size rather than double that
  • Loading branch information
gajop committed May 9, 2020
1 parent 38e6e43 commit dfae8af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions doc/changelog.txt
Expand Up @@ -174,6 +174,7 @@ Misc:
- IME editing support for those with the proper SDL2 version/IME tool combination
! Made lockluaui.txt obsolete: no longer necessary for it to exists in order to enable VFS for LuaUI
- use SHA2 rather than CRC32 content hashes
! blank map params: new_map_x and new_map_y are now in map dimension sizes rather than map dimension * 2. new_map_z renamed to new_map_y

Fixes:
- fix #1968 (units not moving in direction of next queued [build-]command if current order blocked)
Expand Down
14 changes: 8 additions & 6 deletions rts/Map/Generation/SimpleMapGenerator.cpp
Expand Up @@ -25,20 +25,22 @@ void CSimpleMapGenerator::GenerateInfo()
}

const std::string* newMapXStr = mapOpts.try_get("new_map_x");
const std::string* newMapZStr = mapOpts.try_get("new_map_z");
const std::string* newMapYStr = mapOpts.try_get("new_map_y");

if (newMapXStr == nullptr || newMapZStr == nullptr) {
if (newMapXStr == nullptr || newMapYStr == nullptr) {
mapSize = int2(1, 1);
return;
}


try {
const int newMapX = std::stoi(*newMapXStr);
const int newMapZ = std::stoi(*newMapZStr);
// mapSize coordinates are actually 2x the spring map dimensions
// Example: 10x10 map has mapSize = (5, 5)
const int newMapX = std::stoi(*newMapXStr) / 2;
const int newMapY = std::stoi(*newMapYStr) / 2;

if (newMapX > 0 && newMapZ > 0)
mapSize = int2(newMapX, newMapZ);
if (newMapX > 0 && newMapY > 0)
mapSize = int2(newMapX, newMapY);

} catch (...) {
mapSize = int2(1, 1);
Expand Down

0 comments on commit dfae8af

Please sign in to comment.