]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/gameserv.cpp
I've begun to add daily news and split up gameserv.cpp a bit
[irc/gameservirc.git] / gameserv / gameserv.cpp
index d7a0f3117b507a9562095cbd84ffafc78d0d0584..4374857a454d5be9e064a24e27c57171cf47d214 100644 (file)
@@ -3,7 +3,6 @@
 #include "extern.h"
 #include "flags.h"
 #include "list.h"
-#include "myString.h"
 #include "sockhelp.h"
 
 #include <cctype>
@@ -23,13 +22,6 @@ using std::ios;
 
 #endif
 
-// this will be hash.cpp start
-// thank you wcampbel
-unsigned long sHASH(const unsigned char *name);
-unsigned long iHASH(const unsigned char *name);
-List<aClient> players[U_TABLE_SIZE];
-// this will be hash.cpp end
-
 
 Monster *monsters[LEVELS][MONSTERS];   // Monsters per level. Total = MONSTERS * LEVELS
 Monster boss;                          // The boss monster
@@ -225,16 +217,6 @@ void gameserv(char *source, char *buf)
        do_tavern(source);
     } else if (stricmp(cmd, "LIST") == 0) {
        do_list(source);
-    #ifdef DEBUGMODE
-    } else if (stricmp(cmd, "PRINT") == 0) {
-       List<myString> news;
-       myString *st;
-       st = new myString("This is a test");
-       cout << news.insertAtBack_RLN(st)->getData() << endl;
-       cout << st << endl;
-       news.print();
-       delete st;
-    #endif
     } else if (stricmp(cmd, "LOGOUT") == 0) {
        do_logout(source);
     } else if (stricmp(cmd, "REGISTER") == 0) {
@@ -892,7 +874,8 @@ void do_identify(char *u)
        setPlaying(user); // set the playing flag
 
        temp->setPtr(user);
-       notice(s_GameServ, u, "Password Accepted. Identified.");            
+       notice(s_GameServ, u, "Password Accepted. Identified.");
+       showNews(u, todaysnews);
     }
 }
 
@@ -1661,7 +1644,12 @@ void do_attack(char *u)
     if (hit >= fight->hp)
     {
         if (master_fight(ni))
+       {
             notice(s_GameServ, u, "You have bested %s!", fight->name);
+           addNews(todaysnews, "%s has bested %s and moved "\
+                   "to level %d", ni->stats->name, fight->name,
+                   (ni->stats->level + 1));
+       }
         else
             notice(s_GameServ, u, "You have killed \ 2%s\ 2!", fight->name);
 
@@ -1731,6 +1719,8 @@ void do_attack(char *u)
                 notice(s_GameServ, u, "You have been \ 2\1fkilled\1f\ 2 by %s!", fight->name);
                 notice(s_GameServ, u, "You lose all gold on hand and lose 10 percent "\
                         "of your experience!");
+               addNews(todaysnews, "%s has been killed by %s!",
+                       ni->stats->name, fight->name);
                 ni->stats->gold = 0;
                 ni->stats->exp -= (long int)(ni->stats->exp * .10);
                ni->stats->hp = 0;
@@ -1742,6 +1732,8 @@ void do_attack(char *u)
             {
                 notice(s_GameServ, u, "%s has bested you! You will have to wait "\
                         "until tomorrow to try again", ni->stats->master->name);
+               addNews(todaysnews, "%s tried to best %s and failed!",
+                       ni->stats->name, fight->name);
                 ni->stats->fight = NULL;
                 ni->stats->master = NULL;
                return;
@@ -1857,18 +1849,13 @@ void do_attack(char *u)
         notice(s_GameServ, battle->getNick(), "%s has hit you with their %s for "\
                                              "\ 2%d\ 2 damage!", ni->stats->name, 
                                              weapons[ni->stats->weapon], hit);
-       clearYourTurn(ni->stats);
-       setYourTurn(battle->stats);
-        display_players(battle);
     }
     else
     {
         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);
     }
+
     if (hit >= battle->stats->hp)
     {
         notice(s_GameServ, u, "You have killed \ 2%s\ 2!", battle->stats->name);
@@ -1910,6 +1897,8 @@ void do_attack(char *u)
 
             ni->stats->gold = 2000000000;
         }
+       clearYourTurn(ni->stats);
+       clearYourTurn(battle->stats);
        battle->stats->battle = NULL;
         ni->stats->battle = NULL;
         return;
@@ -1920,9 +1909,9 @@ void do_attack(char *u)
             battle->stats->hp -= hit;
        clearYourTurn(ni->stats);
        setYourTurn(battle->stats);
+        display_players(battle);
         notice(s_GameServ, u, "Please wait while %s decides what to do!", 
                battle->stats->name);
-
         return;
     }
    }
@@ -3428,35 +3417,3 @@ bool load_monsters()
     delete [] buf;
 return true;
 }
-
-// this will be hash.cpp start
-// thank you wcampbel
-unsigned long sHASH(const unsigned char *name)
-{
-  unsigned long h = 0, g;
-
-  while (*name)
-  {
-    h = (h << 4) + (*name++); // Case sensitive for numerics
-    if ((g = (h & 0xF0000000)))
-      h ^= g >> 24;
-    h &= ~g;
-  }
-  return h % U_TABLE_SIZE;
-}
-
-unsigned long iHASH(const unsigned char *name)
-{
-  unsigned long h = 0, g;
-
-  while (*name)
-  {
-    h = (h << 4) + tolower(*name++);
-    if ((g = (h & 0xF0000000)))
-      h ^= g >> 24;
-    h &= ~g;
-  }
-  return h % U_TABLE_SIZE;
-}
-
-// this will be hash.cpp end