Skip to content

Commit

Permalink
Fix placement of droids produced when offworld.
Browse files Browse the repository at this point in the history
If a droid was produced while the player was in an away mission, saved,
and then reloaded, the droid would appear in a corner of the map.

Fixes ticket:3907.
  • Loading branch information
KJeff01 committed Dec 8, 2017
1 parent 3312e06 commit fc172d8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/game.cpp
Expand Up @@ -3793,7 +3793,7 @@ bool gameLoadV(PHYSFS_file *fileHandle, unsigned int version)
}

// -----------------------------------------------------------------------------------------
// Load main game data from JSON. Only implement stuff here that we actually use instead of
// Load main game data from JSON. Only implement stuff here that we actually use instead of
// the binary blobbery.
static bool loadMainFile(const std::string &fileName)
{
Expand Down Expand Up @@ -4559,8 +4559,11 @@ static bool loadSaveDroid(const char *pFileName, DROID **ppsCurrentDroidLists)
}

// If droid is on a mission, calling with the saved position might cause an assertion. Or something like that.
pos.x = clip(pos.x, world_coord(1), world_coord(mapWidth - 1));
pos.y = clip(pos.y, world_coord(1), world_coord(mapHeight - 1));
if (!onMission)
{
pos.x = clip(pos.x, world_coord(1), world_coord(mapWidth - 1));
pos.y = clip(pos.y, world_coord(1), world_coord(mapHeight - 1));
}

/* Create the Droid */
turnOffMultiMsg(true);
Expand Down

0 comments on commit fc172d8

Please sign in to comment.