]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/gameserv.cpp
updated the Change log w/ new additions
[irc/gameservirc.git] / gameserv / gameserv.cpp
index 3a8d5aaa047116755d3f48aaa64f88d2f7a564df..05ac73953b5b33518fc5e1718163c5d05e633b1e 100644 (file)
@@ -4,7 +4,6 @@
 #include "player.h"
 #include "pouch.h"
 #include "flags.h"
-#include "list.h"
 #include "level.h"
 #include "sockhelp.h"
 #include "item.h"
@@ -1212,6 +1211,10 @@ void do_register(char *u)
     {
          notice(s_GameServ, u, "SYNTAX: /msg %S REGISTER NAME PASSWORD");
     }
+  else if (strlen(name) > maxnicklen)
+       {
+         notice(s_GameServ, u, "Name too long. Maximum length: %d", maxnicklen);
+       }
   else if (!alphaNumeric(name))
        {
          notice(s_GameServ, u, "That is not a valid name. Please use only AlphaNumeric (A-Z, 0-9) characters!");
@@ -1517,16 +1520,19 @@ bool is_playing(char *u)
 
 bool is_playing(aClient *user)
 {
-  
-  if (!user || !user->stats)
+  if (!user)
     {
          return false;
     }
-  else if (user->stats->getClient() != user)
+  else if (!user->stats)
+       {
+         return false;
+       }
+  else if (!FL_is_playing(user))
     {
          return false;
     }
-  else if (!FL_is_playing(user))
+  else if (user->stats->getClient() != user)
     {
          return false;
     }
@@ -1566,9 +1572,9 @@ bool player_fight(aClient *user)
 {
   if (!is_playing(user))
        return false;
-  else if (user->stats->getBattle() != NULL && is_playing(user->stats->getBattle()))
+  else if (is_playing(user->stats->getBattle()))
     {
-         return user->stats->getBattle()->stats != NULL;
+         return true;
     }
   return false;
 }
@@ -3178,7 +3184,7 @@ void do_dragon(char *u)
   notice(s_GameServ, u, "Just then you notice the eye begin to "\
                 "glare orange! The tooth is moving... but it is still too "\
                 "dark for you to make out.... THE DRAGON! You see it!");
-  p->setMonster(new Monster(dragon));
+  p->setMonster(&dragon);
   setDragonFight(p);
   display_monster(u);
 }
@@ -3323,11 +3329,9 @@ void see_master(char *u)
   
   if (!is_fighting(user) && is_playing(user))
     {
-         Monster *temp;
          Player *p = user->stats;
-         temp = new Monster(levels[p->getLevel() - 1].master);
-         p->setMyMaster(temp);
-         p->setMonster(temp);
+         p->setMyMaster(&levels[p->getLevel() - 1].master);
+         p->setMonster(&levels[p->getLevel() - 1].master);
          display_monster(u);  // Since master is the same structure, use this function
     }
 }
@@ -3515,6 +3519,7 @@ void updateTS(Player *p)
 #ifdef DEBUGMODE
   log("New timestamp for %s: %ld", p->getName().c_str(), p->lastcommand);
 #endif
+  PF_cleartimedout(p);
   
 }
 
@@ -3539,12 +3544,12 @@ void timeOutEvent(Player *p)
        return;
   
   char *nick = p->getClient()->getNick();
-  
+
   if (player_fight(p->getClient()) && isYourTurn(p))
     {
          // Check to see if they were the idler or if it was the other 
          // person
-         if (p->lastcommand != p->getBattle()->stats->lastcommand)
+         if (!PF_timedout(p->getBattle()->stats))
                {
                  // This person's last command was given earlier,
                  // so this person is the idler
@@ -3559,7 +3564,7 @@ void timeOutEvent(Player *p)
                  // Chance to wake up, but if the other player doesn't
                  // Attack now, they both get logged out.
                  updateTS(p);
-                 p->getBattle()->stats->lastcommand = p->lastcommand;
+                 PF_settimedout(p);
                  display_players(p->getBattle());
                  return;
                }
@@ -3777,7 +3782,10 @@ bool load_levels()
     {
          sprintf(filename, "data/levels/level%d.dat", x);
          if (levels[x - 1].loadLevel(filename) == false)
-           return false;
+               {
+                 delete []filename;
+                 return false;
+               }
     }
   
   delete []filename;
@@ -3800,6 +3808,8 @@ bool load_monsters()
          if (!infile)
                {
                  log("Error opening %s", filename);
+                 delete []filename;
+                 delete []buf;
                  return false;
                }