Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 4 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
Commits on Aug 08, 2011
@cybersphinx cybersphinx Revert the mapmod support.
Revert "Merge branch 't/2.3/mapmod' into 2.3"

This reverts commit 65d968c, reversing
changes made to fe46419.

Refs #2610.
ca7d25f
@cybersphinx cybersphinx Load maps last, so files in them don't override game data.
Refs #2825.
1838d20
@cybersphinx cybersphinx Redo mapmod support.
Based on Zarel's earlier patch. Also adds support for unzipped maps in
their own subdirectory.

Refs #2825.

Conflicts:

	src/main.c
b01a8ba
@cybersphinx cybersphinx Don't remove file extensions from mod names.
Fixes loading of savegames with a mod, whether the mod is loaded from
the command line or not.

Old savegames won't work unfortunately, and savegames started with a .wz
mod won't continue if that mod gets expanded later.

Fixes #2735, closes #2825, #2610.

Conflicts:

	src/main.c
5886695
Showing with 54 additions and 66 deletions.
  1. +0 −4 src/game.c
  2. +26 −7 src/init.c
  3. +3 −3 src/levels.c
  4. +21 −48 src/main.c
  5. +3 −2 src/main.h
  6. +1 −2 src/modding.h
View
4 src/game.c
@@ -4505,10 +4505,6 @@ bool gameLoadV(PHYSFS_file* fileHandle, unsigned int version)
if (version >= VERSION_38)
{
setOverrideMods(saveGameData.modList);
- if (saveGameData.sGame.map[0])
- {
- setOverrideMap(saveGameData.sGame.map, saveGameData.sGame.maxPlayers);
- }
}
// All savegames from version 34 or before are little endian so swap them. All
View
33 src/init.c
@@ -234,7 +234,7 @@ BOOL rebuildSearchPath( searchPathMode mode, BOOL force )
char tmpstr[PATH_MAX] = "\0";
if (mode != current_mode || force ||
- (use_override_mods && strcmp(override_mod_list, getModList())) || use_override_map)
+ (use_override_mods && strcmp(override_mod_list, getModList())))
{
if (mode != mod_clean)
{
@@ -354,14 +354,22 @@ BOOL rebuildSearchPath( searchPathMode mode, BOOL force )
curSearchPath = searchPathRegistry;
while (curSearchPath->lowerPriority)
curSearchPath = curSearchPath->lowerPriority;
+ // Add the selected map first, for mapmod support
+ while (curSearchPath)
+ {
+ addSubdirs(curSearchPath->path, "maps", PHYSFS_APPEND, current_map, false);
+ curSearchPath = curSearchPath->higherPriority;
+ }
+ curSearchPath = searchPathRegistry;
+ while (curSearchPath->lowerPriority)
+ curSearchPath = curSearchPath->lowerPriority;
while( curSearchPath )
{
#ifdef DEBUG
debug(LOG_WZ, "Adding [%s] to search path", curSearchPath->path);
#endif // DEBUG
- // Add maps and global and multiplay mods
+ // Add global and multiplay mods
PHYSFS_addToSearchPath( curSearchPath->path, PHYSFS_APPEND );
- addSubdirs( curSearchPath->path, "maps", PHYSFS_APPEND, use_override_map?override_map: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 );
@@ -390,18 +398,27 @@ BOOL rebuildSearchPath( searchPathMode mode, BOOL force )
curSearchPath = curSearchPath->higherPriority;
}
+ curSearchPath = searchPathRegistry;
+ while (curSearchPath->lowerPriority)
+ curSearchPath = curSearchPath->lowerPriority;
+ // Add maps last, so files in them don't override game data
+ while (curSearchPath)
+ {
+ addSubdirs(curSearchPath->path, "maps", PHYSFS_APPEND, NULL, false);
+ curSearchPath = curSearchPath->higherPriority;
+ }
break;
default:
debug(LOG_ERROR, "Can't switch to unknown mods %i", mode);
return false;
}
- if ((use_override_mods || use_override_map) && mode != mod_clean)
+ if (use_override_mods && mode != mod_clean)
{
- if (use_override_mods && strcmp(getModList(),override_mod_list))
+ if (strcmp(getModList(),override_mod_list))
{
debug(LOG_POPUP, _("The required mod could not be loaded: %s\n\nWarzone will try to load the game without it."), override_mod_list);
}
- clearOverrides();
+ clearOverrideMods();
current_mode = mod_override;
}
@@ -416,7 +433,7 @@ BOOL rebuildSearchPath( searchPathMode mode, BOOL force )
else if (use_override_mods)
{
// override mods are already the same as current mods, so no need to do anything
- clearOverrides();
+ clearOverrideMods();
}
return true;
}
@@ -893,6 +910,8 @@ BOOL stageOneShutDown(void)
debug(LOG_TEXTURE, "=== stageOneShutDown ===");
pie_TexShutDown();
+ // no map for the main menu
+ setCurrentMap((char*)"", 1);
// Use mod_multiplay as the default (campaign might have set it to mod_singleplayer)
rebuildSearchPath( mod_multiplay, true );
pie_TexInit(); // restart it
View
6 src/levels.c
@@ -47,7 +47,7 @@
#include "research.h"
#include "lib/framework/lexer_input.h"
#include "effects.h"
-#include "modding.h"
+#include "main.h"
extern int lev_get_lineno(void);
extern char* lev_get_text(void);
@@ -678,8 +678,8 @@ BOOL levLoadData(const char* name, char *pSaveName, GAME_TYPE saveType)
}
}
- setOverrideMap(psNewLevel->pName, psNewLevel->players);
- if (!rebuildSearchPath(psNewLevel->dataDir, false))
+ setCurrentMap(psNewLevel->pName, psNewLevel->players);
+ if (!rebuildSearchPath(psNewLevel->dataDir, true))
{
return false;
}
View
69 src/main.c
@@ -107,8 +107,8 @@ char * multiplay_mods[MAX_MODS] = { NULL };
char * override_mods[MAX_MODS] = { NULL };
char * override_mod_list = NULL;
bool use_override_mods = false;
-char * override_map[2] = { NULL };
-bool use_override_map = false;
+
+char *current_map[3] = { NULL };
char * loaded_mods[MAX_MODS] = { NULL };
char * mod_list = NULL;
@@ -252,29 +252,34 @@ void setOverrideMods(char * modlist)
override_mod_list = modlist;
use_override_mods = true;
}
-void setOverrideMap(char* map, int maxPlayers)
+
+void setCurrentMap(char* map, int maxPlayers)
{
+ free(current_map[0]);
+ free(current_map[1]);
// Transform "Sk-Rush-T2" into "4c-Rush.wz" so it can be matched by the map loader
- override_map[0] = (char*)malloc(strlen(map)+1+7);
- snprintf(override_map[0], 3, "%d", maxPlayers);
- strcat(override_map[0],"c-");
+ current_map[0] = (char*)malloc(strlen(map) + 1 + 7);
+ snprintf(current_map[0], 3, "%d", maxPlayers);
+ strcat(current_map[0], "c-");
if (strncmp(map, "Sk-", 3) == 0)
{
- strcat(override_map[0],map+3);
+ strcat(current_map[0], map + 3);
}
else
{
- strcat(override_map[0],map);
+ strcat(current_map[0], map);
}
- if (strncmp(override_map[0]+strlen(override_map[0])-3,"-T",2) == 0)
+ if (strncmp(current_map[0] + strlen(current_map[0]) - 3, "-T", 2) == 0)
{
- override_map[0][strlen(override_map[0])-3] = '\0';
+ current_map[0][strlen(current_map[0]) - 3] = '\0';
}
- strcat(override_map[0],".wz");
- override_map[1] = NULL;
- use_override_map = true;
+ current_map[1] = (char*)malloc(strlen(map) + 1 + 7);
+ strcpy(current_map[1], current_map[0]);
+ strcat(current_map[1],".wz");
+ current_map[2] = NULL;
}
-void clearOverrides(void)
+
+void clearOverrideMods(void)
{
int i;
use_override_mods = false;
@@ -284,49 +289,17 @@ void clearOverrides(void)
}
override_mods[0] = NULL;
override_mod_list = NULL;
-
- if (override_map[0])
- {
- free(override_map[0]);
- override_map[0] = NULL;
- }
- use_override_map = false;
}
void addLoadedMod(const char * modname)
{
char * mod = strdup(modname);
- int i, modlen;
+ int i;
if (num_loaded_mods >= MAX_MODS)
{
// mod list full
return;
}
- modlen = strlen(mod);
- if (modlen >= 3 && strcmp(&mod[modlen-3], ".wz")==0)
- {
- // remove ".wz" from end
- mod[modlen-3] = 0;
- modlen -= 3;
- }
- if (modlen >= 4 && strcmp(&mod[modlen-4], ".cam")==0)
- {
- // remove ".cam.wz" from end
- mod[modlen-4] = 0;
- modlen -= 4;
- }
- else if (modlen >= 4 && strcmp(&mod[modlen-4], ".mod")==0)
- {
- // remove ".mod.wz" from end
- mod[modlen-4] = 0;
- modlen -= 4;
- }
- else if (modlen >= 5 && strcmp(&mod[modlen-5], ".gmod")==0)
- {
- // remove ".gmod.wz" from end
- mod[modlen-5] = 0;
- modlen -= 5;
- }
// Yes, this is an online insertion sort.
// I swear, for the numbers of mods this is going to be dealing with
// (i.e. 0 to 2), it really is faster than, say, Quicksort.
@@ -736,7 +709,7 @@ static void startGameLoop(void)
{
SetGameMode(GS_NORMAL);
- if (!levLoadData(aLevelName, NULL, GTYPE_SCENARIO_START))
+ if (!levLoadData(aLevelName, NULL, 0))
{
debug( LOG_FATAL, "Shutting down after failure" );
exit(EXIT_FAILURE);
View
5 src/main.h
@@ -49,7 +49,8 @@ extern char * multiplay_mods[MAX_MODS];
extern char * override_mods[MAX_MODS];
extern char * override_mod_list;
extern bool use_override_mods;
-extern char * override_map[2];
-extern bool use_override_map;
+
+void setCurrentMap(char* map, int maxPlayers);
+extern char *current_map[3];
#endif // __INCLUDED_SRC_MAIN_H__
View
3 src/modding.h
@@ -26,8 +26,7 @@ void removeSubdirs( const char * basedir, const char * subdir, char * checkList[
void printSearchPath( void );
void setOverrideMods(char * modlist);
-void setOverrideMap(char* map, int maxPlayers);
-void clearOverrides(void);
+void clearOverrideMods(void);
void addLoadedMod(const char * modname);
void clearLoadedMods(void);

No commit comments for this range

Something went wrong with that request. Please try again.