foxygit / doom Log in
commit b8d2d8bb8b3cf1b5475e8c9be292248f140b2126
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Tue Sep 20 20:48:09 2011 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Tue Sep 20 20:48:09 2011 +0000

    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
---
 src/d_iwad.c            | 30 ++++++++++++++++++++++++++++++
 src/d_iwad.h            |  2 ++
 src/setup/multiplayer.c | 19 +++++++++++++++++--
 3 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/src/d_iwad.c b/src/d_iwad.c
index d0bfe692..9e7cd5ea 100644
--- a/src/d_iwad.c
+++ b/src/d_iwad.c
@@ -759,3 +759,33 @@ char *D_SaveGameIWADName(GameMission_t gamemission)
     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?";
+}
+
diff --git a/src/d_iwad.h b/src/d_iwad.h
index a7cdf932..c0f7e9c0 100644
--- a/src/d_iwad.h
+++ b/src/d_iwad.h
@@ -50,6 +50,8 @@ char *D_TryFindWADByName(char *filename);
 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

diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c
index 91335c6c..5b3e8da0 100644
--- a/src/setup/multiplayer.c
+++ b/src/setup/multiplayer.c
@@ -783,8 +783,7 @@ static void SelectQueryAddress(TXT_UNCAST_ARG(button),

     // 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)
         {
@@ -795,6 +794,22 @@ static void SelectQueryAddress(TXT_UNCAST_ARG(button),
                 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));
+        }
     }

     // Finished with search.