fix bug #955096 - cannot restart saved mission

This commit is contained in:
nehalmistry 2004-05-26 00:27:19 +00:00
parent b3e277d1c1
commit 3085f278ef
3 changed files with 23 additions and 15 deletions

View file

@ -63,6 +63,7 @@
#include "campaign.h"
#include "trigger.h"
#include "commands.h"
#include "iocompat.h"
#include "script.h"
@ -84,34 +85,40 @@ local int LcmPreventRecurse; /// prevent recursion through LoadGameMap
/**
** Load a Stratagus map.
**
** @param filename map filename
** @param mapname map filename
** @param map map loaded
*/
local void LoadStratagusMap(const char* filename,
local void LoadStratagusMap(const char* mapname,
WorldMap* map __attribute__((unused)))
{
char mapfull[PATH_MAX];
strcpy(mapfull, StratagusLibPath);
strcat(mapfull, "/");
strcat(mapfull, mapname);
if (LcmPreventRecurse) {
fprintf(stderr,"recursive use of load Stratagus map!\n");
ExitFatal(-1);
}
InitPlayers();
LcmPreventRecurse = 1;
LuaLoadFile(filename);
LuaLoadFile(mapfull);
LcmPreventRecurse = 0;
#if 0
// Not true if multiplayer levels!
if (!ThisPlayer) { /// ARI: bomb if nothing was loaded!
fprintf(stderr, "%s: invalid Stratagus map\n", filename);
fprintf(stderr, "%s: invalid Stratagus map\n", mapname);
ExitFatal(-1);
}
// FIXME: Retrieve map->Info from somewhere... If LoadPud is used in CCL it magically is set there :)
#endif
if (!TheMap.Width || !TheMap.Height) {
fprintf(stderr, "%s: invalid Stratagus map\n", filename);
fprintf(stderr, "%s: invalid Stratagus map\n", mapname);
ExitFatal(-1);
}
TheMap.Info->Filename = strdup(filename);
TheMap.Info->Filename = strdup(mapname);
}
/**
@ -320,9 +327,6 @@ global void CreateGame(char* filename, WorldMap* map)
// Or at least this is what valgrind says.
strcpy(CurrentMapPath, filename);
}
if (filename[0] != '/' && filename[0] != '.') {
s = filename = strdcat3(StratagusLibPath, "/", filename);
}
//
// Load the map.

View file

@ -65,6 +65,7 @@
#include "player.h"
#include "unit.h"
#include "pud.h"
#include "iocompat.h"
#include "iolib.h"
#include "settings.h"
#include "network.h"
@ -802,14 +803,19 @@ global void LoadPud(const char* pud,WorldMap* map)
uint32_t length;
char header[5];
char buf[1024];
char pudfull[PATH_MAX];
int width;
int height;
int aiopps;
strcpy(pudfull, StratagusLibPath);
strcat(pudfull, "/");
strcat(pudfull, pud);
if (!map->Info) {
map->Info = GetPudInfo(pud);
map->Info = GetPudInfo(pudfull);
}
if( !(input=CLopen(pud,CL_OPEN_READ)) ) {
if( !(input=CLopen(pudfull,CL_OPEN_READ)) ) {
fprintf(stderr,"Try ./path/name\n");
fprintf(stderr,"pud: CLopen(%s): %s\n", pud, strerror(errno));
ExitFatal(-1);

View file

@ -1014,7 +1014,6 @@ local int CclSyncRand(lua_State* l)
local int CclLoadPud(lua_State* l)
{
const char* name;
char buffer[1024];
if (SaveGameLoading) {
return 0;
@ -1024,7 +1023,7 @@ local int CclLoadPud(lua_State* l)
LuaError(l, "incorrect argument");
}
name = LuaToString(l, 1);
LoadPud(LibraryFileName(name, buffer), &TheMap);
LoadPud(name, &TheMap);
// FIXME: LoadPud should return an error
return 0;
@ -1038,14 +1037,13 @@ local int CclLoadPud(lua_State* l)
local int CclLoadMap(lua_State* l)
{
const char* name;
char buffer[1024];
if (lua_gettop(l) != 1) {
LuaError(l, "incorrect argument");
}
name = LuaToString(l, 1);
if (strcasestr(name, ".pud")) {
LoadPud(LibraryFileName(name, buffer), &TheMap);
LoadPud(name, &TheMap);
}
// FIXME: LoadPud should return an error