Add two new directives to campaign definition files: 'loading' that gives a level
file to read, and 'package' that gives a .wz file in campaign folder to mount. Campaign definition files can now also be read from 'campaigns' in the user write folder.master
parent
8d5b07485f
commit
348cdfcda8
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "lib/framework/input.h"
|
||||
#include "lib/framework/wzconfig.h"
|
||||
#include "lib/framework/physfs_ext.h"
|
||||
#include "lib/ivis_opengl/bitimage.h"
|
||||
#include "lib/ivis_opengl/pieblitfunc.h"
|
||||
#include "lib/ivis_opengl/piestate.h"
|
||||
|
@ -71,6 +72,8 @@ struct CAMPAIGN_FILE
|
|||
QString level;
|
||||
QString video;
|
||||
QString captions;
|
||||
QString package;
|
||||
QString loading;
|
||||
};
|
||||
|
||||
// ////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -275,10 +278,16 @@ static QList<CAMPAIGN_FILE> readCampaignFiles()
|
|||
CAMPAIGN_FILE c;
|
||||
QString filename("campaigns/");
|
||||
filename += *i;
|
||||
if (!filename.endsWith(".ini"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
WzConfig ini(filename, WzConfig::ReadOnlyAndRequired);
|
||||
ini.beginGroup("campaign");
|
||||
c.name = ini.value("name").toString();
|
||||
c.level = ini.value("level").toString();
|
||||
c.package = ini.value("package").toString();
|
||||
c.loading = ini.value("loading").toString();
|
||||
ini.endGroup();
|
||||
ini.beginGroup("intro");
|
||||
c.video = ini.value("video").toString();
|
||||
|
@ -323,6 +332,30 @@ static void frontEndNewGame(int which)
|
|||
seq_AddSeqToList(list[which].video.toUtf8().constData(), NULL, list[which].captions.toUtf8().constData(), false);
|
||||
seq_StartNextFullScreenVideo();
|
||||
}
|
||||
if (!list[which].package.isEmpty())
|
||||
{
|
||||
QString path;
|
||||
path += PHYSFS_getWriteDir();
|
||||
path += PHYSFS_getDirSeparator();
|
||||
path += "campaigns";
|
||||
path += PHYSFS_getDirSeparator();
|
||||
path += list[which].package;
|
||||
if (!PHYSFS_mount(path.toUtf8().constData(), NULL, PHYSFS_APPEND))
|
||||
{
|
||||
debug(LOG_ERROR, "Failed to load campaign mod \"%s\": %s",
|
||||
path.toUtf8().constData(), PHYSFS_getLastError());
|
||||
}
|
||||
}
|
||||
if (!list[which].loading.isEmpty())
|
||||
{
|
||||
debug(LOG_WZ, "Adding campaign mod level \"%s\"", list[which].loading.toUtf8().constData());
|
||||
if (!loadLevFile(list[which].loading.toUtf8().constData(), mod_campaign, false, NULL))
|
||||
{
|
||||
debug(LOG_ERROR, "Failed to load %s", list[which].loading.toUtf8().constData());
|
||||
return;
|
||||
}
|
||||
}
|
||||
debug(LOG_WZ, "Loading campaign mod -- %s", aLevelName);
|
||||
changeTitleMode(STARTGAME);
|
||||
}
|
||||
|
||||
|
|
10
src/init.cpp
10
src/init.cpp
|
@ -136,7 +136,7 @@ static bool InitialiseGlobals(void)
|
|||
}
|
||||
|
||||
|
||||
static bool loadLevFile(const char* filename, searchPathMode datadir, bool ignoreWrf, char const *realFileName)
|
||||
bool loadLevFile(const char* filename, searchPathMode datadir, bool ignoreWrf, char const *realFileName)
|
||||
{
|
||||
char *pBuffer;
|
||||
UDWORD size;
|
||||
|
@ -152,12 +152,12 @@ static bool loadLevFile(const char* filename, searchPathMode datadir, bool ignor
|
|||
|
||||
if (!PHYSFS_exists(filename) || !loadFile(filename, &pBuffer, &size))
|
||||
{
|
||||
debug(LOG_ERROR, "loadLevFile: File not found: %s\n", filename);
|
||||
debug(LOG_ERROR, "File not found: %s\n", filename);
|
||||
return false; // only in NDEBUG case
|
||||
}
|
||||
if (!levParse(pBuffer, size, datadir, ignoreWrf, realFileName))
|
||||
{
|
||||
debug(LOG_ERROR, "loadLevFile: Parse error in %s\n", filename);
|
||||
debug(LOG_ERROR, "Parse error in %s\n", filename);
|
||||
return false;
|
||||
}
|
||||
free(pBuffer);
|
||||
|
@ -166,7 +166,7 @@ static bool loadLevFile(const char* filename, searchPathMode datadir, bool ignor
|
|||
}
|
||||
|
||||
|
||||
void cleanSearchPath( void )
|
||||
static void cleanSearchPath()
|
||||
{
|
||||
wzSearchPath * curSearchPath = searchPathRegistry, * tmpSearchPath = NULL;
|
||||
|
||||
|
@ -271,6 +271,7 @@ bool rebuildSearchPath(searchPathMode mode, bool force, const char *current_map)
|
|||
#endif // DEBUG
|
||||
// Remove maps and mods
|
||||
removeSubdirs( curSearchPath->path, "maps", NULL );
|
||||
removeSubdirs( curSearchPath->path, "campaigns", NULL );
|
||||
removeSubdirs( curSearchPath->path, "mods/music", NULL );
|
||||
removeSubdirs( curSearchPath->path, "mods/global", NULL );
|
||||
removeSubdirs( curSearchPath->path, "mods/campaign", NULL );
|
||||
|
@ -326,6 +327,7 @@ bool rebuildSearchPath(searchPathMode mode, bool force, const char *current_map)
|
|||
// Add global and campaign mods
|
||||
PHYSFS_addToSearchPath( curSearchPath->path, PHYSFS_APPEND );
|
||||
|
||||
addSubdirs( curSearchPath->path, "campaigns", PHYSFS_APPEND, NULL, false );
|
||||
addSubdirs( curSearchPath->path, "mods/music", PHYSFS_APPEND, NULL, false );
|
||||
addSubdirs( curSearchPath->path, "mods/global", PHYSFS_APPEND, use_override_mods?override_mods:global_mods, true );
|
||||
addSubdirs( curSearchPath->path, "mods", PHYSFS_APPEND, use_override_mods?override_mods:global_mods, true );
|
||||
|
|
|
@ -56,12 +56,13 @@ struct wzSearchPath
|
|||
|
||||
enum searchPathMode { mod_clean, mod_campaign, mod_multiplay, mod_override };
|
||||
|
||||
void cleanSearchPath( void );
|
||||
void registerSearchPath( const char path[], unsigned int priority );
|
||||
bool rebuildSearchPath(searchPathMode mode, bool force, const char *current_map = NULL);
|
||||
|
||||
bool buildMapList(void);
|
||||
|
||||
bool loadLevFile(const char* filename, searchPathMode datadir, bool ignoreWrf, char const *realFileName);
|
||||
|
||||
extern IMAGEFILE *FrontImages;
|
||||
|
||||
#endif // __INCLUDED_SRC_INIT_H__
|
||||
|
|
Loading…
Reference in New Issue