shithub: choc

Download patch

ref: b8d2d8bb8b3cf1b5475e8c9be292248f140b2126
parent: 4fba2ab2ddda75a05c70ac95531504edfafdf8c8
author: Simon Howard <fraggle@gmail.com>
date: Tue Sep 20 16:48:09 EDT 2011

Display a warning message when trying to join a server playing a game
that we don't have the IWAD for.

Subversion-branch: /branches/v2-branch
Subversion-revision: 2389

--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -759,3 +759,33 @@
     return "unknown.wad";
 }
 
+char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode)
+{
+    int i;
+
+    for (i = 0; i < arrlen(iwads); ++i)
+    {
+        if (iwads[i].mission == mission && iwads[i].mode == mode)
+        {
+            return iwads[i].name;
+        }
+    }
+
+    return "unknown.wad";
+}
+
+char *D_SuggestGameName(GameMission_t mission, GameMode_t mode)
+{
+    int i;
+
+    for (i = 0; i < arrlen(iwads); ++i)
+    {
+        if (iwads[i].mission == mission && iwads[i].mode == mode)
+        {
+            return iwads[i].description;
+        }
+    }
+
+    return "Unknown game?";
+}
+
--- a/src/d_iwad.h
+++ b/src/d_iwad.h
@@ -50,6 +50,8 @@
 char *D_FindIWAD(int mask, GameMission_t *mission);
 iwad_t **D_FindAllIWADs(int mask);
 char *D_SaveGameIWADName(GameMission_t gamemission);
+char *D_SuggestIWADName(GameMission_t mission, GameMode_t mode);
+char *D_SuggestGameName(GameMission_t mission, GameMode_t mode);
 
 #endif
 
--- a/src/setup/multiplayer.c
+++ b/src/setup/multiplayer.c
@@ -783,8 +783,7 @@
 
     // Auto-choose IWAD if there is already a player connected.
 
-    if (querydata->num_players > 0
-     && !(querydata->gamemission == doom && querydata->gamemode == shareware))
+    if (querydata->num_players > 0)
     {
         for (i = 0; found_iwads[i] != NULL; ++i)
         {
@@ -794,6 +793,22 @@
                 found_iwad_selected = i;
                 break;
             }
+        }
+
+        if (found_iwads[i] == NULL)
+        {
+            TXT_MessageBox(NULL,
+                           "The game on this server seems to be:\n"
+                           "\n"
+                           "   %s\n"
+                           "\n"
+                           "but the IWAD file %s is not found!\n"
+                           "Without the required IWAD file, it may not be\n"
+                           "possible to join this game.",
+                           D_SuggestGameName(querydata->gamemission,
+                                             querydata->gamemode),
+                           D_SuggestIWADName(querydata->gamemission,
+                                             querydata->gamemode));
         }
     }