]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/gameserv.cpp
Fixed a bug that allowed more than one person to register the same player name
[irc/gameservirc.git] / gameserv / gameserv.cpp
index ac5b632611c04c204fed64513a49298aaf449f09..485937c8504b9ea383c6ab19e2808bae55b9b198 100644 (file)
@@ -160,7 +160,7 @@ void gameserv(char *source, char *buf)
     {
         refreshall();
         day = curday;
-       save_day();
+       save_day(); // here i come to save the day!
     }
 
     if (strnicmp(cmd, "\1PING", 6) == 0)
@@ -286,6 +286,7 @@ void gameserv(char *source, char *buf)
            else
                display_help(source, cmd);
        }
+    #ifdef DEBUGMODE
     } else if (stricmp(cmd, "RAW") == 0) {
        aClient *user;
 
@@ -303,6 +304,7 @@ void gameserv(char *source, char *buf)
            char *rest = strtok(NULL, "");
            raw("%s", rest);
        }
+    #endif
     } else {
        notice(s_GameServ, source, "Unknown command \002%s\002. Type /msg %S \002HELP\002 to get a list of commands.", cmd);
     } 
@@ -536,7 +538,6 @@ void do_list(char *u)
        notice(s_GameServ, u, "People Playing:");
        while(temp)
        {
-
            #ifdef P10
            notice(s_GameServ, u, "IRC: %s     Game: %s", temp->getData()->getRealNick(), 
                   temp->getData()->stats->name);
@@ -575,6 +576,11 @@ void do_register(char *u)
     {
        notice(s_GameServ, u, "SYNTAX: /msg %S REGISTER NAME PASSWORD");
     }
+    else if ((user = findplayer(name)))
+    {
+       notice(s_GameServ, u, "%s is already registered!", name);
+       notice(s_GameServ, u, "Choose another name!");
+    }
     else if ((user = find(u)))
     {
        p = findplayer(u);
@@ -614,18 +620,17 @@ void do_identify(char *u)
     }
     else if (!(p = findplayer(name)) || !p->stats)
            notice(s_GameServ, u, "Player %s not found", name);
+    else if (p->stats->user != NULL && !isAdmin(user))
+    {
+       notice(s_GameServ, u, "That player has already identified.");
+       return;
+    }
     else if (!check_password(name, password) && !isAdmin(user))
     {
            notice(s_GameServ, u, "Password incorrect");
     }
-    else
-    {
-       if (p->stats->user && !isAdmin(user))
-       {
-           notice(s_GameServ, u, "That player has already identified.");
-           return;
-       }
-        if (!user->stats)
+    else {
+       if (!user->stats)
         {
            ListNode<aClient> *temp;
            temp = players.Find(p);
@@ -973,14 +978,14 @@ void do_fight(char *u)
        notice(s_GameServ, u, "Fatal error. Contact a(n) %S admin. buf: %s", strtok(NULL, ""));
        return;
     }
-    else if (!(battle = findbyrealnick(nick)))
+    else if (!is_playing(ni))
     {
-       notice(s_GameServ, u, "You can't attack %s while they aren't playing!", nick);
+       notice(s_GameServ, u, "You are not playing!");
        return;
     }
-    else if (!is_playing(ni))
+    else if (!(battle = findplayer(nick)))
     {
-       notice(s_GameServ, u, "You are not playing!");
+       notice(s_GameServ, u, "You can't attack %s while they aren't playing!", nick);
        return;
     }
 /*
@@ -1016,6 +1021,22 @@ void do_fight(char *u)
        notice(s_GameServ, u, "%s is fighting %s already!", battle->stats->name, battle->stats->fight->name);
        return;
     }
+    else if (ni->stats->level - battle->stats->level > maxbfightdistance)
+    {
+       // You can't fight someone below you by more than X level(s)
+       // level 12 can fight level (12 - X) but not < (12 - X)
+       notice(s_GameServ, u, "You may not fight %s. You're too strong!", 
+               battle->stats->level);
+       return;
+    }
+    else if (battle->stats->level - ni->stats->level > maxafightdistance)
+    {
+       // You can't fight someone above you by more than X level(S)
+       // level 1 can fight level (1 + X), but not > (1 + X)
+       notice(s_GameServ, u, "%s, do you really have a death wish? Try the forest you "\
+               "weakling!", ni->stats->name);
+       return;
+    }
     else if (is_playing(ni) && is_playing(battle) && stricmp(ni->stats->name, battle->stats->name) != 0)
     {
        // Set your battle pointer to the other player
@@ -1031,7 +1052,8 @@ void do_fight(char *u)
        // Initiate Battle sequence!
         notice(s_GameServ, u, "You challenge %s to an online duel!", battle->stats->name);
         notice(s_GameServ, battle->getNick(), "%s has challenged you to an online duel!", ni->stats->name);
-        notice(s_GameServ, battle->getNick(), "%s gets to go first because he initiated!", ni->stats->name);
+        notice(s_GameServ, battle->getNick(), "%s gets to go first "\
+                       "because they initiated!", ni->stats->name);
         notice(s_GameServ, battle->getNick(), "Please wait while %s decides what to do.", ni->stats->name);
         display_players(u);
     }
@@ -1814,7 +1836,7 @@ int load_gs_dbase()
        tempname = strtok(NULL, " ");
        if (tempname)
            p->inventory.setHP(stringtoint(tempname));
-
+       temp->stats->user = NULL;
        players.insertAtBack(temp);
        delete temp;
     }