Worked around issue where gotoroom() is called with WC->CurRoom.name and the contents...
authorArt Cancro <ajc@uncensored.citadel.org>
Wed, 27 Jul 2011 20:35:02 +0000 (16:35 -0400)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 21:43:51 +0000 (21:43 +0000)
webcit/roomops.c

index 3d1e3a12c27bbfbbe4e86461b74b70606eeeca0f..b93a4910dae0f249182604160dc92974e39cc5bf 100644 (file)
@@ -186,18 +186,30 @@ long gotoroom(const StrBuf *gname)
        StrBuf *Buf;
        static long ls = (-1L);
        long err = 0;
+       int room_name_supplied = 0;
+       int is_baseroom = 0;
 
        /* store ungoto information */
-       if (StrLength(gname) > 0)
+       if (StrLength(gname) > 0) {
+               room_name_supplied = 1;
+       }
+       if (room_name_supplied) {
                strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
+               if (!strcasecmp(ChrPtr(gname), "_BASEROOM_")) {
+                       is_baseroom = 1;
+               }
+       }
        WCC->uglsn = ls;
        Buf = NewStrBuf();
 
        /* move to the new room */
-       if (StrLength(gname) > 0)
+       if (room_name_supplied) {
                serv_printf("GOTO %s", ChrPtr(gname));
-       else /* or just refresh the current state... */
+       }
+       else {
+               /* or just refresh the current state... */
                serv_printf("GOTO 00000000000000000000");
+       }
        StrBuf_ServGetln(Buf);
        if  (GetServerStatus(Buf, &err) != 2) {
                serv_puts("GOTO _BASEROOM_");
@@ -215,11 +227,11 @@ long gotoroom(const StrBuf *gname)
        FlushFolder(&WCC->CurRoom);
        ParseGoto(&WCC->CurRoom, Buf);
 
-       if (StrLength(gname) > 0)
-       {
+       if (room_name_supplied) {
                remove_march(WCC->CurRoom.name);
-               if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
+               if (is_baseroom) {
                        remove_march(gname);
+               }
        }
        FreeStrBuf(&Buf);