]> jfr.im git - irc/gameservirc.git/commitdiff
fixed a couple of bugs
authorkainazzzo <redacted>
Mon, 27 Mar 2006 19:48:31 +0000 (19:48 +0000)
committerkainazzzo <redacted>
Mon, 27 Mar 2006 19:48:31 +0000 (19:48 +0000)
git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@432 bc333340-6410-0410-a689-9d09f3c113fa

gameserv/Changes
gameserv/gameserv.cpp
gameserv/tcpclient.cpp

index 9b29693a46ee896b87f6d7a0e48cf5f3be138d49..bb6b4a8a05d21acdf5ce851af27b40d8d0201185 100644 (file)
@@ -1,3 +1,7 @@
+Version 1.3.4
+* Fixed a bug causing players' HP to be set to 10 on gameserv load - Kain (thanks Mauritz)
+* Removed the timestamp update from the following commands if the player is fighting:
+    STATS, Inventory, and equip - Kain
 Version 1.3.3
 * Added a parameter to the USE command that allows you to specify how many items to
     use at once - Kain
index 174dd7b1d958f715d782743bd8edbcf972334a0c..55da3f5acf0addfaf924d8d847001a84796fc01a 100644 (file)
@@ -1259,6 +1259,9 @@ void do_register(char *u)
                  // Log the player in
                  setPlaying(user);
 
+                 // Start the player at the beginning
+                 reset(user->stats);
+                 
                  // Add the stick and clothes
                  tempItem = findItemByID(3001);
                  user->stats->inventory->addItem((*Items.begin()))->use(user->stats); // Add the stick
@@ -1377,7 +1380,8 @@ void do_stats(char *u)
                }
          else
                {
-                 updateTS(user->stats);
+                 if (!is_fighting(user))
+                       updateTS(user->stats);
                  showstats(u, user->stats->getName().c_str());
                }
     }
@@ -1771,7 +1775,8 @@ void do_equip(char *u)
       return;
     }
   id = stringtoint(item);
-  updateTS(user->stats);
+  if (!is_fighting(user))
+       updateTS(user->stats);
   p = user->stats->inventory;
 
 
@@ -1794,6 +1799,7 @@ void do_equip(char *u)
                equip->use(user->stats);
       }
 }
+
 void do_use(char *u)
 {
   aClient *user;
@@ -2460,8 +2466,9 @@ int load_gs_dbase()
          p->setExp(stringtoint(strtok(NULL, " ")));
          p->setGold(stringtoint(strtok(NULL, " ")));
          p->setBank(stringtoint(strtok(NULL, " ")));
-         p->setHP(stringtoint(strtok(NULL, " ")));
+         tempnum = stringtoint(strtok(NULL, " "));
          p->setMaxHP(stringtoint(strtok(NULL, " ")));
+         p->setHP(tempnum);
          p->setStrength(stringtoint(strtok(NULL, " ")));
          p->setDefense(stringtoint(strtok(NULL, " ")));
          p->setForestFights(stringtoint(strtok(NULL, " ")));
@@ -2758,7 +2765,8 @@ void do_inventory(char *u)
          notice(s_GameServ, u, "You must be playing to check your inventory!");
          return;
     }
-  updateTS(user->stats);
+  if (!is_fighting(user))
+       updateTS(user->stats);
   showinventory(user->stats, user);
 }
 
@@ -3477,14 +3485,15 @@ void resetall()
 void reset(Player *p)
 {
   item *tempItem;
+
   if (!p)
        return;
   
   p->reset();
+  // Add the stick and clothes
   tempItem = findItemByID(3001);
   p->inventory->addItem((*Items.begin()))->use(p); // Add the stick
-  p->inventory->addItem(tempItem)->use(p); // Add Clothes
-  
+  p->inventory->addItem(tempItem)->use(p); // Add Clothes      
 }
 
 void updateTS(Player *p)
index 044f430ddacfb4f0e2f042c1c042583a7feb4b41..b07cef9ca5c59241a9599ecf1ff67e8a53371295 100644 (file)
@@ -33,7 +33,7 @@
 using namespace std;
 
 char *PACKAGE = "GameServ";
-char *VERSION = "1.3.2 +devel";
+char *VERSION = "1.3.3 +devel";
 
 int sock;
 long lastrefresh;
@@ -183,11 +183,12 @@ int main(int argc, char *argv[])
          ignore_pipe();
          sock = conn(remoteserver, remoteport, localhost, 0);
          //    sock = make_connection(remoteport, SOCK_STREAM, remoteserver);
-         if (sock == -1) {
-               fprintf(stderr,"make_connection failed.\n");
-               unload_config_file();
-               return -1;
-         }
+         if (sock == -1)
+               {
+                 fprintf(stderr,"make_connection failed.\n");
+                 unload_config_file();
+                 return -1;
+               }
          log("%S socket connected.");
          
 #ifdef UNREAL
@@ -276,7 +277,9 @@ int main(int argc, char *argv[])
                          cmd = strtok(NULL, " ");
                        }
                  else
-                       cmd = strtok(buf, " ");
+                       {
+                         cmd = strtok(buf, " ");
+                       }
 #else
                  source = strtok(buf, " ");
                  cmd = strtok(NULL, " ");
@@ -307,7 +310,7 @@ int main(int argc, char *argv[])
 
                  // Refresh players and clear news if the time is up
                  currentTime = time(NULL);
-
+                 
                  if (isRolloverForestFights())
                        {
                          if (currentTime - lastrollover >= rolloverperiod)
@@ -347,46 +350,57 @@ int main(int argc, char *argv[])
                  
                  
 #if !defined(P10)
-       if (stricmp(cmd, "PING") == 0) {
-           char *timestamp;
-           timestamp = strtok(NULL, "");
-           raw("PONG %s", timestamp);
-      #else
-       if (stricmp(cmd, "G") == 0) {
-           char *timestamp;
-           timestamp = strtok(NULL, " ");
-           raw("[] Z [] %s 0 %s", timestamp + 1, timestamp);
-      #endif
-       #ifdef P10
-       } else if (stricmp(cmd, "EB") == 0) {
-           raw("[] EA");
-       #endif
-       } else if (stricmp(cmd, "VERSION") == 0) {
-           char *server;
-           server = strtok(NULL, " ");
-           server++;
-           raw(":%s 351 %s %s_%s. %s", servername, source+1, PACKAGE, VERSION, servername);
-      #if !defined(P10)
-       } else if (strncmp(cmd, "NICK", 4) == 0) {
-         if (buffer[0] == ':')
-           {
-                 aClient *tempPtr;
-                 if ((tempPtr = find((source + 1))))
+                 if (stricmp(cmd, "PING") == 0)
                        {
-                         char *nick;
-                         unsigned long oldhv, newhv;
-                         nick = strtok(NULL, " ");
-                         oldhv = iHASH((unsigned char *) tempPtr->getNick());
-                         newhv = iHASH((unsigned char *) nick);
-                         tempPtr->setNick(nick);
-                         clients[oldhv].remove(tempPtr);
-                         clients[newhv].push_back(tempPtr);
+                         char *timestamp;
+                         timestamp = strtok(NULL, "");
+                         raw("PONG %s", timestamp);
                        }
-           }
-         else
-           {
-                 char *nick;
-      #else
+#else
+                 // P10 Ping
+                 if (stricmp(cmd, "G") == 0)
+                       {
+                         char *timestamp;
+                         timestamp = strtok(NULL, " ");
+                         raw("[] Z [] %s 0 %s", timestamp + 1, timestamp);
+                       }
+#endif
+#ifdef P10
+                 else if (stricmp(cmd, "EB") == 0)
+                       {
+                         raw("[] EA");
+                       }
+#endif
+                 else if (stricmp(cmd, "VERSION") == 0)
+                       {
+                         char *server;
+                         server = strtok(NULL, " ");
+                         server++;
+                         raw(":%s 351 %s %s_%s. %s", servername, source+1, PACKAGE, VERSION, servername);
+                       }
+                 // Code indenting is clean up until here!
+#if !defined(P10)
+                 else if (strncmp(cmd, "NICK", 4) == 0)
+                       {
+                         if (buffer[0] == ':')
+                               {
+                                 aClient *tempPtr;
+                                 if ((tempPtr = find((source + 1))))
+                                       {
+                                         char *nick;
+                                         unsigned long oldhv, newhv;
+                                         nick = strtok(NULL, " ");
+                                         oldhv = iHASH((unsigned char *) tempPtr->getNick());
+                                         newhv = iHASH((unsigned char *) nick);
+                                         tempPtr->setNick(nick);
+                                         clients[oldhv].remove(tempPtr);
+                                         clients[newhv].push_back(tempPtr);
+                                       }
+                               }
+                         else
+                               {
+                                 char *nick;
+#else
        } else if (stricmp(cmd, "N") == 0 && strlen(source) == 2) {
            {   
                char *nick, *realnick;
@@ -397,10 +411,9 @@ int main(int argc, char *argv[])
 
                if (nick[0] == '+')
                {
-                   #ifdef DEBUGMODE
+#ifdef DEBUGMODE
                    log ("aClient has modes");
-                   #endif
-
+#endif
                    // Searching for the +r mode (extra parameter)
                    for (unsigned int count = 1; count < strlen(nick); count++)
                    {
@@ -412,16 +425,16 @@ int main(int argc, char *argv[])
                    }
                    nick = strtok(NULL, " ");
                }
-      #endif
+#endif
                aClient *newuser;
 
                nick = strtok(NULL, " ");
 
-               #ifdef P10
+#ifdef P10
                    newuser = new aClient(nick, realnick);
-               #else
+#else
                    newuser = new aClient(nick);
-               #endif
+#endif
 
 
                        if (loaded)
@@ -474,10 +487,10 @@ int main(int argc, char *argv[])
 #endif
                clients[hv].push_back(newuser);
            }
-      #if defined(P10)
+#if defined(P10)
        } else if (stricmp(cmd, "Q") == 0) {
 //         unsigned long hv = sHASH((unsigned char *) source);
-      #else
+#else
        } else if (stricmp(cmd, "QUIT") == 0)
          {
 
@@ -496,8 +509,6 @@ int main(int argc, char *argv[])
                        goto end;
                  }
 
-               
-               notice(s_GameServ, "Kain", "Nick: %s", quitter->getNick());
                clients[hv].remove(quitter);
                //              logout(quitter);
 
@@ -506,7 +517,7 @@ int main(int argc, char *argv[])
            if (z == ':')
                  source--;
 
-      #if defined(P10)
+#if defined(P10)
        } else if (stricmp(cmd, "P") == 0) {
            char *rest, *dest;
            char *longname;
@@ -526,7 +537,7 @@ int main(int argc, char *argv[])
                delete [] longname;
                forest(source, rest);
            }
-      #else
+#else
        } else if (stricmp(cmd, "PRIVMSG") == 0) {
            char *rest, *dest;
            dest = strtok(NULL, " ");
@@ -535,12 +546,12 @@ int main(int argc, char *argv[])
                gameserv(source, rest);
            else if (stricmp(dest, c_Forest) == 0 && isListenOnCF())
                forest(source, rest);
-      #endif
-      #if defined(P10)
+#endif
+#if defined(P10)
        } else if (stricmp(cmd, "J") == 0) {
-      #else
+#else
        } else if (stricmp(cmd, "JOIN") == 0) {
-      #endif
+#endif
            char *channel;
            aClient *joiner;
            channel = strtok(NULL, " ");
@@ -554,23 +565,23 @@ int main(int argc, char *argv[])
 
            if (stricmp(channel, c_Forest) == 0 && is_playing(joiner))
            {
-               #ifdef DEBUGMODE
-                   log("Player %s (IRC: %s) joined %s", 
-                       joiner->stats->getName().c_str(), 
-                       #ifdef P10
-                           joiner->getRealNick(),
-                       #else
-                           joiner->getNick(),
-                       #endif
-                       c_Forest);
-               #endif
-               raw(":%S MODE %s +v %s", c_Forest, (source));
+#ifdef DEBUGMODE
+                 log("Player %s (IRC: %s) joined %s", 
+                         joiner->stats->getName().c_str(), 
+#ifdef P10
+                         joiner->getRealNick(),
+#else
+                         joiner->getNick(),
+#endif
+                         c_Forest);
+#endif
+                 raw(":%S MODE %s +v %s", c_Forest, (source));
            }
 
            if (z == ':')
                source--;
 
-       #if defined(BAHAMUT)
+#if defined(BAHAMUT)
        } else if (stricmp(cmd, "SJOIN") == 0) {
            char *channel, *nick, *tmp, *rest;
            strtok(NULL, " "); // Ignore the TS
@@ -596,9 +607,9 @@ int main(int argc, char *argv[])
            }
 #endif
        } else {
-           #ifdef DEBUGMODE
+#ifdef DEBUGMODE
                log("Unrecognized Message: cmd = %s   source = %s", cmd, source);
-           #endif
+#endif
        }
   }
 
@@ -614,9 +625,9 @@ int main(int argc, char *argv[])
 
   delete_monsters();
 
-  #ifdef DEBUGMODE
+#ifdef DEBUGMODE
       log("<CLOSED>");
-  #endif
+#endif
 
   close(sock);
   unload_config_file();
@@ -757,7 +768,7 @@ aClient *findbynick(const char *nick)
   for (iter = clients[hv].begin(); iter != clients[hv].end(); iter++)
     {
          client = (*iter);
-       #ifdef P10
+#ifdef P10
          if (strcmp(client->getNick(), nick) == 0)
 #else
            if (stricmp(client->getNick(), nick) == 0)
@@ -850,15 +861,15 @@ void load_lastrefresh()
     infile.open(".gsrefresh");
     if (infile.fail())
     {
-       #ifdef DEBUGMODE
+#ifdef DEBUGMODE
            log("Error opening .gsrefresh");
-       #endif
+#endif
 
        generate:
        long mytime = time(NULL);
-       #ifdef DEBUGMODE
+#ifdef DEBUGMODE
            log("Generating new refresh time");
-       #endif
+#endif
 
        // Just a safety measure... tho no one should
        // get anywhere near the actual time as their refreshperiod