Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit b01a8ba7c18845dca6d96a17071d2e2e78210f65 1 parent 1838d20
@cybersphinx cybersphinx authored
Showing with 46 additions and 1 deletion.
  1. +11 −0 src/init.c
  2. +3 −1 src/levels.c
  3. +29 −0 src/main.c
  4. +3 −0  src/main.h
View
11 src/init.c
@@ -354,6 +354,15 @@ 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
@@ -901,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
4 src/levels.c
@@ -47,6 +47,7 @@
#include "research.h"
#include "lib/framework/lexer_input.h"
#include "effects.h"
+#include "main.h"
extern int lev_get_lineno(void);
extern char* lev_get_text(void);
@@ -677,7 +678,8 @@ BOOL levLoadData(const char* name, char *pSaveName, GAME_TYPE saveType)
}
}
- if (!rebuildSearchPath(psNewLevel->dataDir, false))
+ setCurrentMap(psNewLevel->pName, psNewLevel->players);
+ if (!rebuildSearchPath(psNewLevel->dataDir, true))
{
return false;
}
View
29 src/main.c
@@ -108,6 +108,8 @@ char * override_mods[MAX_MODS] = { NULL };
char * override_mod_list = NULL;
bool use_override_mods = false;
+char *current_map[3] = { NULL };
+
char * loaded_mods[MAX_MODS] = { NULL };
char * mod_list = NULL;
bool customDebugfile = false; // Default false: user has NOT specified where to store the stdout/err file.
@@ -250,6 +252,33 @@ void setOverrideMods(char * modlist)
override_mod_list = modlist;
use_override_mods = true;
}
+
+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
+ 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(current_map[0], map + 3);
+ }
+ else
+ {
+ strcat(current_map[0], map);
+ }
+ if (strncmp(current_map[0] + strlen(current_map[0]) - 3, "-T", 2) == 0)
+ {
+ current_map[0][strlen(current_map[0]) - 3] = '\0';
+ }
+ 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 clearOverrideMods(void)
{
int i;
View
3  src/main.h
@@ -50,4 +50,7 @@ extern char * override_mods[MAX_MODS];
extern char * override_mod_list;
extern bool use_override_mods;
+void setCurrentMap(char* map, int maxPlayers);
+extern char *current_map[3];
+
#endif // __INCLUDED_SRC_MAIN_H__
Please sign in to comment.
Something went wrong with that request. Please try again.