]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
error handling in watchbsp (contributed by ilm)
authortimo <timo@8a3a26a2-13c4-0310-b231-cf6edde360e5>
Mon, 14 Apr 2008 20:15:34 +0000 (20:15 +0000)
committertimo <timo@8a3a26a2-13c4-0310-b231-cf6edde360e5>
Mon, 14 Apr 2008 20:15:34 +0000 (20:15 +0000)
git-svn-id: https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/branches/ZeroRadiant@250 8a3a26a2-13c4-0310-b231-cf6edde360e5

libs/l_net/l_net.c
libs/l_net/l_net_berkeley.c
radiant/watchbsp.cpp

index 9ead6652d210d8cb31ceee33cf4d701667bb20ec..a8a595718495aea4b8335c5f71f3e4cab61e8e96 100644 (file)
@@ -346,7 +346,9 @@ void Net_MyAddress(address_t *address)
 //===========================================================================
 int Net_Setup(void)
 {
-       WINS_Init();
+       if( !WINS_Init() )
+               return qfalse;
+
        //
        WinPrint("my address is %s\n", WINS_MyAddress());
        //
index 2d4d33bc2cef1a6e152416de70840421390351c2..e7d0b96191a992c2c689e0621dcb5088fc9ebeec 100644 (file)
@@ -175,6 +175,14 @@ int WINS_Init(void)
        // determine my name & address
        gethostname(buff, MAXHOSTNAMELEN);
        local = gethostbyname(buff);
+
+       // When hostname can not be resolved, return gracefully
+       if( local == 0 )
+       {
+               WinError("WINS_Init: Unable to resolve hostname\n");
+               return 0;
+       }
+
        myAddr = *(int *)local->h_addr_list[0];
 
        // if the quake hostname isn't set, set it to the machine name
index 314921a386517d8784fb569cda3022e5045a575f..2c85e57abdafeee9c71ee0b92db862ba4d04d0ca 100644 (file)
@@ -305,10 +305,13 @@ bool CWatchBSP::SetupListening()
   }
 #endif
   Sys_Printf("Setting up\n");
-       Net_Setup();
-       m_pListenSocket = Net_ListenSocket(39000);
+  if( !Net_Setup() )
+    return false;
+
+  m_pListenSocket = Net_ListenSocket(39000);
   if (m_pListenSocket == NULL)
     return false;
+
   Sys_Printf("Listening...\n");
   return true;
 }