]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/gameserv.cpp
Fixed some p10, bugs, and gameserv is now running as a true daemon with pid outputtin...
[irc/gameservirc.git] / gameserv / gameserv.cpp
index 55401dc443e39fcf1a3f564a89b863fb437a7766..494481f3ed4d63f0bbe4923de7a4a4a97f8060f3 100644 (file)
@@ -231,9 +231,9 @@ void gameserv(char *source, char *buf)
        {
            save_gs_dbase();
            #ifdef P10
-               raw("[] SQ %s 0 :leaving", servername);
+               raw("[] SQ %s 0 :leaving: %s used the Shutdown command.", servername, user->getRealNick());
            #else
-               raw("SQUIT %s :leaving", servername);
+               raw("SQUIT %s :leaving: %s used the Shutdown command.", servername, u);
            #endif
        }
     } else if (stricmp(cmd, "SAVE") == 0) {
@@ -530,7 +530,15 @@ void do_list(char *u)
        notice(s_GameServ, u, "People Playing:");
        while(temp)
        {
-           notice(s_GameServ, u, "IRC: %s     Game: %s", temp->getData()->getNick(), temp->getData()->stats->name);
+
+           #ifdef P10
+           notice(s_GameServ, u, "IRC: %s     Game: %s", temp->getData()->getRealNick(), 
+                  temp->getData()->stats->name);
+           #else
+           notice(s_GameServ, u, "IRC: %s     Game: %s", temp->getData()->getNick(), 
+                  temp->getData()->stats->name);
+           #endif
+
            temp = temp->Next();
        }
        notice(s_GameServ, u, "End of List");
@@ -1998,9 +2006,8 @@ void display_players(char *u)
        aClient *battle = ni->stats->battle;
 
        notice(s_GameServ, u, "Your Hitpoints: \ 2%d\ 2", ni->stats->hp);
-       notice(s_GameServ, u, "%s's Hitpoints: \ 2%d\ 2", battle->getNick()
+       notice(s_GameServ, u, "%s's Hitpoints: \ 2%d\ 2", battle->stats->name
                                                        battle->stats->hp);
-
        notice(s_GameServ, u, "Here are your commands:");
        notice(s_GameServ, u, "/msg %S attack");
        notice(s_GameServ, u, "/msg %S run");
@@ -2014,7 +2021,7 @@ void display_players(aClient *user)
     {
        aClient *battle = user->stats->battle;
        notice(s_GameServ, u, "Your Hitpoints: \ 2%d\ 2", user->stats->hp);
-       notice(s_GameServ, u, "%s's Hitpoints: \ 2%d\ 2", battle->getNick(), battle->stats->hp);
+       notice(s_GameServ, u, "%s's Hitpoints: \ 2%d\ 2", battle->stats->name, battle->stats->hp);
        notice(s_GameServ, u, "Here are your commands:");
        notice(s_GameServ, u, "/msg %S attack");
        notice(s_GameServ, u, "/msg %S run");
@@ -2118,7 +2125,7 @@ void do_fight(char *u)
        notice(s_GameServ, u, "Fatal error. Contact a(n) %S admin. buf: %s", strtok(NULL, ""));
        return;
     }
-    else if (!(battle = find(nick)))
+    else if (!(battle = findbyrealnick(nick)))
     {
        notice(s_GameServ, u, "You can't attack %s while they aren't playing!", nick);
        return;
@@ -2137,7 +2144,7 @@ void do_fight(char *u)
  *       ni->yourturn = 1;
  *       battle->yourturn = 0;
  *       notice(s_GameServ, u, "You decide to fight %s while they're not online!",
- *                battle->getNick());
+ *                battle->stats->name);
  *       display_players(u);
  *   }
  */
@@ -2169,10 +2176,10 @@ void do_fight(char *u)
        clearYourTurn(battle->stats);
 
        // Initiate Battle sequence!
-        notice(s_GameServ, u, "You challenge %s to an online duel!", battle->getNick());
-        notice(s_GameServ, battle->getNick(), "%s has challenged you to an online duel!", u);
-        notice(s_GameServ, battle->getNick(), "%s gets to go first because he initiated!", u);
-        notice(s_GameServ, battle->getNick(), "Please wait while %s decides what to do.", u);
+        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(), "Please wait while %s decides what to do.", ni->stats->name);
         display_players(u);
     }
 }
@@ -2637,39 +2644,40 @@ void do_attack(char *u)
    }
 * end offline fighting */
 
-   if (is_playing(battle->getNick()))
+   if (is_playing(battle))
    {
     if (!isYourTurn(ni->stats))
     {
         notice(s_GameServ, u, "Please wait until %s decides what to do!", 
-               battle->getNick());
+               battle->stats->name);
         return;
     }
     if (hit > 0)
     {
-        notice(s_GameServ, u, "You attack \1f%s\1f for \ 2%d\ 2 points!", battle->getNick(), hit);
+        notice(s_GameServ, u, "You attack \1f%s\1f for \ 2%d\ 2 points!", battle->stats->name, hit);
 
         notice(s_GameServ, battle->getNick(), "%s has hit you with their %s for "\
-                                             "\ 2%d\ 2 damage!", u, weapons[ni->stats->weapon]
-                                             hit);
+                                             "\ 2%d\ 2 damage!", ni->stats->name
+                                             weapons[ni->stats->weapon], hit);
        clearYourTurn(ni->stats);
        setYourTurn(battle->stats);
         display_players(battle->getNick());
     }
     else
     {
-        notice(s_GameServ, u, "You miss \1f%s\1f completely!", battle->getNick());
-        notice(s_GameServ, battle->getNick(), "%s misses you completely!", u);
+        notice(s_GameServ, u, "You miss \1f%s\1f completely!", battle->stats->name);
+        notice(s_GameServ, battle->getNick(), "%s misses you completely!", ni->stats->name);
        clearYourTurn(ni->stats);
        setYourTurn(battle->stats);
         display_players(battle->getNick());
     }
     if (hit >= battle->stats->hp)
     {
-        notice(s_GameServ, u, "You have killed \ 2%s\ 2!", battle->getNick());
+        notice(s_GameServ, u, "You have killed \ 2%s\ 2!", battle->stats->name);
         notice(s_GameServ, u, "You recieve \ 2%d\ 2 experience and \ 2%ld\ 2 gold!",
                 (long int)(battle->stats->exp * .10), battle->stats->gold);
-        notice(s_GameServ, battle->getNick(), "You have been killed by \ 2%s\ 2!", u);
+        notice(s_GameServ, battle->getNick(), "You have been killed by \ 2%s\ 2!", 
+               ni->stats->name);
         battle->stats->hp = 0;
         clearAlive(battle->stats);
 
@@ -2697,7 +2705,7 @@ void do_attack(char *u)
             notice(s_GameServ, battle->getNick(), "You lose ten percent of your experience!");
 
             notice(s_GameServ, battle->getNick(), "However, %s could not carry all of your "\
-                       "gold.", u);
+                       "gold.", ni->stats->name);
 
             notice(s_GameServ, battle->getNick(), "Luckily, you still have \ 2%ld\ 2 gold "\
                        "left. All is not lost!", battle->stats->gold);
@@ -2715,13 +2723,14 @@ void do_attack(char *u)
        clearYourTurn(ni->stats);
        setYourTurn(battle->stats);
         notice(s_GameServ, u, "Please wait while %s decides what to do!", 
-               battle->getNick());
+               battle->stats->name);
 
         return;
     }
    }
   }
 }
+
 void do_heal(char *u)
 {
     aClient *ni;
@@ -2923,6 +2932,9 @@ int load_gs_dbase()
        password = strtok(NULL, " ");
        strcpy(p->password, password);
        temp->setNick("!NULL!");
+       #ifdef P10
+       temp->setRealNick("!NULL!");
+       #endif
 
        p->inventory.reset(); // Set inventory to all 0s
        // Old player databases didn't have these three extra values
@@ -3189,7 +3201,7 @@ void showinventory(aClient *from, aClient *to)
     if (is_playing(from))
     {
        Pouch *p = &from->stats->inventory;
-       notice(s_GameServ, nick, "Inventory for %s:", from->getNick());
+       notice(s_GameServ, nick, "Inventory for %s:", from->stats->name);
        notice(s_GameServ, nick, " Healing Potions: %d", p->Healing());
        notice(s_GameServ, nick, "Strength Potions: %d", p->Strength());
        notice(s_GameServ, nick, " Defense Potions: %d", p->Defense());
@@ -3666,16 +3678,24 @@ void do_refresh(char *u)
        notice(s_GameServ, u, "Refreshing everyone's stats!");
        refreshall();
     }
-    else if ((user = find(nick)))
+    else if ((user = findbyrealnick(nick)))
     {
        if (is_playing(user))
        {
+           #ifdef P10
+           notice(s_GameServ, u, "Refreshing %s.", user->getRealNick());
+           #else
            notice(s_GameServ, u, "Refreshing %s.", user->getNick());
+           #endif
            refresh(user->stats);
        }
        else
        {
+           #ifdef P10
+           notice(s_GameServ, u, "%s is not playing.", user->getRealNick());
+           #else
            notice(s_GameServ, u, "%s is not playing.", user->getNick());
+           #endif
        }
     }
     else
@@ -3735,16 +3755,24 @@ void do_reset(char *u)
        notice(s_GameServ, u, "Resetting everyone's stats!");
        resetall();
     }
-    else if ((user = find(nick)))
+    else if ((user = findbyrealnick(nick)))
     {
        if (is_playing(user))
        {
+           #ifdef P10
+           notice(s_GameServ, u, "Resetting %s.", user->getRealNick());
+           #else
            notice(s_GameServ, u, "Resetting %s.", user->getNick());
+           #endif
            reset(user->stats);
        }
        else
        {
+           #ifdef P10
+           notice(s_GameServ, u, "%s is not playing.", user->getRealNick());
+           #else
            notice(s_GameServ, u, "%s is not playing.", user->getNick());
+           #endif
        }
     }
     else
@@ -3843,7 +3871,11 @@ void do_admin(char *u)
     {
        notice(s_GameServ, u, "Password accepted. You now have administrator privledges.");
        setAdmin(user);
+       #ifdef P10
+       log("%s became an administrator.", user->getRealNick());
+       #else
        log("%s became an administrator.", user->getNick());
+       #endif
     }
     else
     {