Skip to content

Commit

Permalink
d3xp: Compatibility with OpenCoop custom maps (oc_customs)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stradex committed Mar 17, 2021
1 parent e03cdfc commit 5ceaab4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 17 deletions.
70 changes: 53 additions & 17 deletions d3xp/MultiplayerGame.cpp
Expand Up @@ -2429,10 +2429,11 @@ const char* idMultiplayerGame::HandleGuiCommands( const char *_menuCommand ) {
} else if ( !idStr::Icmp( cmd, "MAPScan" ) ) {
const char *gametype = gameLocal.serverInfo.GetString( "si_gameType" );
if ( gametype == NULL || *gametype == 0 || idStr::Icmp( gametype, "singleplayer" ) == 0 ) {
gametype = "Deathmatch";
gametype = "Coop";
}

int i, num;
int i, j, num;
bool canAddMapToList = false;
idStr si_map = gameLocal.serverInfo.GetString("si_map");
const idDict *dict;

Expand All @@ -2441,27 +2442,42 @@ const char* idMultiplayerGame::HandleGuiCommands( const char *_menuCommand ) {
num = fileSystem->GetNumMaps();
for ( i = 0; i < num; i++ ) {
dict = fileSystem->GetMapDecl( i );
if ( dict ) {
canAddMapToList = false;
if (!dict) {
continue;
}

if (gameLocal.mpGame.IsGametypeCoopBased()) {
if (dict->GetBool(gametype)) {
canAddMapToList = true;
} else {
for (j = 0; opencoop_gameTypes[j]; j++) {
if (dict->GetBool(opencoop_gameTypes[j])) {
canAddMapToList = true;
break;
}
}
}
} else {
// any MP gametype supported
bool isMP = false;
int igt = GAME_SP + 1;
while ( si_gameTypeArgs[ igt ] ) {
if ( dict->GetBool( si_gameTypeArgs[ igt ] ) ) {
isMP = true;
while (si_gameTypeArgs[igt]) {
if (dict->GetBool(si_gameTypeArgs[igt])) {
canAddMapToList = true;
break;
}
igt++;
}
if ( isMP ) {
const char *mapName = dict->GetString( "name" );
if ( mapName[0] == '\0' ) {
mapName = dict->GetString( "path" );
}
mapName = common->GetLanguageDict()->GetString( mapName );
mapList->Add( i, mapName );
if ( !si_map.Icmp( dict->GetString( "path" ) ) ) {
mapList->SetSelection( mapList->Num() - 1 );
}
}
if (canAddMapToList) {
const char* mapName = dict->GetString("name");
if (mapName[0] == '\0') {
mapName = dict->GetString("path");
}
mapName = common->GetLanguageDict()->GetString(mapName);
mapList->Add(i, mapName);
if (!si_map.Icmp(dict->GetString("path"))) {
mapList->SetSelection(mapList->Num() - 1);
}
}
}
Expand Down Expand Up @@ -4519,6 +4535,16 @@ void idMultiplayerGame::SetBestGametype( const char * map ) {
return;
}

//Stradex BEGIN: little hack to allow OpenCoop custom maps to be played
if (idStr::Icmp(gametype, "Survival") == 0 || idStr::Icmp(gametype, "Coop") == 0) {
for (j = 0; opencoop_gameTypes[j]; j++) {
if (mapDef->dict.GetBool(opencoop_gameTypes[j])) {
return;
}
}
}
//Stradex END

for ( j = 1; si_gameTypeArgs[ j ]; j++ ) {
if ( mapDef->dict.GetBool( si_gameTypeArgs[ j ] ) ) {
si_gameType.SetString( si_gameTypeArgs[ j ] );
Expand Down Expand Up @@ -4571,6 +4597,16 @@ idStr idMultiplayerGame::GetBestGametype( const char* map, const char* gametype
}
}

//Stradex BEGIN: little hack to allow OpenCoop custom maps to be played
if (idStr::Icmp(gametype, "Survival") == 0 || idStr::Icmp(gametype, "Coop") == 0) {
for (j = 0; opencoop_gameTypes[j]; j++) {
if (mapDef->dict.GetBool(opencoop_gameTypes[j])) {
return gametype;
}
}
}
//Stradex END

// error out, no valid gametype
return "deathmatch";
}
Expand Down
2 changes: 2 additions & 0 deletions d3xp/gamesys/SysCvar.cpp
Expand Up @@ -53,6 +53,8 @@ const char *si_gameTypeArgs[] = { "singleplayer", "deathmatch", "Tourney", "Tea
const char *si_gameTypeArgs[] = { "singleplayer", "deathmatch", "Tourney", "Team DM", "Last Man", NULL };
#endif

const char* opencoop_gameTypes[] = { "oc_d3xp", "oc_customs", "oc_doom3", NULL }; //Stradex: to allow OpenCoop custom maps to run without need any modifications to the mapDef

const char *si_readyArgs[] = { "Not Ready", "Ready", NULL };
const char *si_spectateArgs[] = { "Play", "Spectate", NULL };

Expand Down
2 changes: 2 additions & 0 deletions d3xp/gamesys/SysCvar.h
Expand Up @@ -323,6 +323,8 @@ extern idCVar g_mod_version;

extern const char *si_gameTypeArgs[];

extern const char* opencoop_gameTypes[];

extern const char *ui_skinArgs[];

#endif /* !__SYS_CVAR_H__ */

0 comments on commit 5ceaab4

Please sign in to comment.