Skip to content

Commit

Permalink
Merge branch 'bugfixes'
Browse files Browse the repository at this point in the history
  • Loading branch information
perim committed Jul 5, 2015
2 parents b68db4b + 6f2f5d9 commit c884568
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 15 deletions.
24 changes: 20 additions & 4 deletions src/clparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ typedef enum
CLI_MOD_GLOB,
CLI_MOD_CA,
CLI_MOD_MP,
CLI_SAVEGAME,
CLI_LOADSKIRMISH,
CLI_LOADCAMPAIGN,
CLI_WINDOW,
CLI_VERSION,
CLI_RESOLUTION,
Expand Down Expand Up @@ -252,7 +253,8 @@ static const struct poptOption *getOptionsTable(void)
{ "mod_mp", '\0', POPT_ARG_STRING, NULL, CLI_MOD_MP, N_("Enable a multiplay only mod"), N_("mod") },
{ "noassert", '\0', POPT_ARG_NONE, NULL, CLI_NOASSERT, N_("Disable asserts"), NULL },
{ "crash", '\0', POPT_ARG_NONE, NULL, CLI_CRASH, N_("Causes a crash to test the crash handler"), NULL },
{ "savegame", '\0', POPT_ARG_STRING, NULL, CLI_SAVEGAME, N_("Load a saved game"), N_("savegame") },
{ "loadskirmish",'\0', POPT_ARG_STRING, NULL, CLI_LOADSKIRMISH, N_("Load a saved skirmish game"), N_("savegame") },
{ "loadcampaign",'\0', POPT_ARG_STRING, NULL, CLI_LOADCAMPAIGN, N_("Load a saved campaign game"), N_("savegame") },
{ "window", '\0', POPT_ARG_NONE, NULL, CLI_WINDOW, N_("Play in windowed mode"), NULL },
{ "version", '\0', POPT_ARG_NONE, NULL, CLI_VERSION, N_("Show version information and exit"), NULL },
{ "resolution", '\0', POPT_ARG_STRING, NULL, CLI_RESOLUTION, N_("Set the resolution to use"), N_("WIDTHxHEIGHT") },
Expand Down Expand Up @@ -564,14 +566,28 @@ bool ParseCommandLine(int argc, const char **argv)
war_SetHeight(height);
break;
}
case CLI_SAVEGAME:
case CLI_LOADSKIRMISH:
// retrieve the game name
token = poptGetOptArg(poptCon);
if (token == NULL)
{
qFatal("Unrecognised savegame name");
}
snprintf(saveGameName, sizeof(saveGameName), "%s/%s", SaveGamePath, token);
snprintf(saveGameName, sizeof(saveGameName), "%s/skirmish/%s.gam", SaveGamePath, token);
SPinit();
bMultiPlayer = true;
game.type = SKIRMISH; // tutorial is skirmish for some reason
SetGameMode(GS_SAVEGAMELOAD);
break;
case CLI_LOADCAMPAIGN:
// retrieve the game name
token = poptGetOptArg(poptCon);
if (token == NULL)
{
qFatal("Unrecognised savegame name");
}
snprintf(saveGameName, sizeof(saveGameName), "%s/campaign/%s.gam", SaveGamePath, token);
SPinit();
SetGameMode(GS_SAVEGAMELOAD);
break;

Expand Down
2 changes: 1 addition & 1 deletion src/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ static void loadOK(void)
}
}

static void SPinit(void)
void SPinit()
{
uint8_t playercolor;

Expand Down
2 changes: 2 additions & 0 deletions src/frontend.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,6 @@ enum

};

void SPinit();

#endif // __INCLUDED_SRC_FRONTEND_H__
6 changes: 2 additions & 4 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,8 @@ static bool deserializePlayer(PHYSFS_file *fileHandle, PLAYER *serializePlayer,
if (player < game.maxPlayers)
{
serializePlayer->ai = matchAIbyName(aiName);
if (serializePlayer->ai == AI_NOT_FOUND)
{
debug(LOG_ERROR, "AI \"%s\" not found -- script loading will fail (player %d / %d)", aiName, player, game.maxPlayers);
}
ASSERT(serializePlayer->ai != AI_NOT_FOUND, "AI \"%s\" not found -- script loading will fail (player %d / %d)",
aiName, player, game.maxPlayers);
}
serializePlayer->position = position;
serializePlayer->colour = colour;
Expand Down
4 changes: 2 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ bool systemInitialise(void)

pie_InitRadar();

readAIs();

return true;
}

Expand Down Expand Up @@ -788,8 +790,6 @@ bool frontendInitialise(const char *ResourceFile)
return false;
}

readAIs();

if (!scrTabInitialise()) // Initialise the script system
{
return false;
Expand Down
6 changes: 2 additions & 4 deletions src/multiint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ void loadMultiScripts()
sstrcat(aPathName, "/");

// Reset assigned counter
std::vector<AIDATA>::iterator it;
for (it = aidata.begin(); it < aidata.end(); it++)
for (auto it = aidata.begin(); it < aidata.end(); ++it)
{
(*it).assigned = 0;
}
Expand Down Expand Up @@ -626,14 +625,13 @@ void loadMapPreview(bool hideInterface)

int matchAIbyName(const char *name)
{
std::vector<AIDATA>::iterator it;
int i = 0;

if (name[0] == '\0')
{
return AI_CLOSED;
}
for (it = aidata.begin(); it < aidata.end(); it++, i++)
for (auto it = aidata.cbegin(); it < aidata.cend(); ++it, i++)
{
if (strncasecmp(name, (*it).name, MAX_LEN_AI_NAME) == 0)
{
Expand Down

0 comments on commit c884568

Please sign in to comment.