]> jfr.im git - irc/gameservirc.git/commitdiff
Added messages.cpp and find.cpp, which contain functions from gameserv.cpp
authorkainazzzo <redacted>
Sun, 21 Jan 2007 18:00:53 +0000 (18:00 +0000)
committerkainazzzo <redacted>
Sun, 21 Jan 2007 18:00:53 +0000 (18:00 +0000)
Updated the help files to reflect new notice() and raw() functions needing
<S instead of %S to replace with the s_GameServ nick

git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@469 bc333340-6410-0410-a689-9d09f3c113fa

41 files changed:
gameserv/.depend
gameserv/Makefile.in
gameserv/extern.h
gameserv/find.cpp [new file with mode: 0644]
gameserv/gameserv.cpp
gameserv/gameserv.example.conf
gameserv/helpfiles/admin
gameserv/helpfiles/admin_commands
gameserv/helpfiles/attack
gameserv/helpfiles/bank
gameserv/helpfiles/check
gameserv/helpfiles/dragon
gameserv/helpfiles/equip
gameserv/helpfiles/fight
gameserv/helpfiles/heal
gameserv/helpfiles/help
gameserv/helpfiles/identify
gameserv/helpfiles/inventory
gameserv/helpfiles/list
gameserv/helpfiles/load
gameserv/helpfiles/logout
gameserv/helpfiles/master
gameserv/helpfiles/news
gameserv/helpfiles/raw
gameserv/helpfiles/refresh
gameserv/helpfiles/register
gameserv/helpfiles/reset
gameserv/helpfiles/run
gameserv/helpfiles/save
gameserv/helpfiles/search
gameserv/helpfiles/set
gameserv/helpfiles/shutdown
gameserv/helpfiles/stats
gameserv/helpfiles/store
gameserv/helpfiles/tavern
gameserv/helpfiles/use
gameserv/messages.cpp [new file with mode: 0644]
gameserv/player.cpp
gameserv/player.h
gameserv/toplist.cpp
gameserv/toplist.h

index e67d8ca0dea6474ed07564144ca5f68f3c0e97c9..db8ce72fad1836b1ac62b4339b550e90ab9c8833 100644 (file)
@@ -1,28 +1,31 @@
 aClient.o: aClient.cpp aClient.h options.h player.h script.h extern.h \
- config.h
 config.h
 config.o: config.cpp extern.h config.h options.h flags.h
-c_forest.o: c_forest.cpp aClient.h options.h player.h script.h \
- extern.h config.h flags.h item.h level.h pouch.h sockhelp.h
-do_attack.o: do_attack.cpp aClient.h options.h player.h script.h \
- extern.h config.h flags.h level.h item.h
-gameserv.o: gameserv.cpp aClient.h options.h player.h script.h \
- config.h extern.h pouch.h flags.h level.h sockhelp.h item.h toplist.h
-hash.o: hash.cpp extern.h config.h options.h aClient.h player.h \
- script.h
+c_forest.o: c_forest.cpp aClient.h options.h player.h script.h extern.h \
+  config.h flags.h item.h level.h pouch.h sockhelp.h
+do_attack.o: do_attack.cpp aClient.h options.h player.h script.h extern.h \
+  config.h flags.h level.h item.h
+find.o: find.cpp extern.h config.h options.h item.h level.h player.h \
+  script.h
+gameserv.o: gameserv.cpp aClient.h options.h player.h script.h config.h \
+  extern.h pouch.h flags.h level.h sockhelp.h item.h toplist.h
+hash.o: hash.cpp extern.h config.h options.h aClient.h player.h script.h
 item.o: item.cpp item.h level.h player.h script.h extern.h config.h \
- options.h
 options.h
 level.o: level.cpp item.h level.h player.h script.h extern.h config.h \
- options.h
 options.h
 log.o: log.cpp extern.h config.h options.h
 news.o: news.cpp extern.h config.h options.h
 pouch.o: pouch.cpp extern.h config.h options.h pouch.h item.h level.h \
- player.h script.h
 player.h script.h
 player.o: player.cpp item.h level.h player.h script.h pouch.h extern.h \
- config.h options.h flags.h
 config.h options.h flags.h
 script.o: script.cpp script.h extern.h config.h options.h player.h
 sockhelp.o: sockhelp.cpp sockhelp.h extern.h config.h options.h
+messages.o: messages.cpp aClient.h options.h player.h script.h item.h \
+  level.h pouch.h extern.h config.h sockhelp.h flags.h
 toplist.o: toplist.cpp toplist.h player.h script.h
 tcpclient.o: tcpclient.cpp sockhelp.h options.h aClient.h player.h \
- script.h extern.h config.h flags.h item.h level.h toplist.h
 script.h extern.h config.h flags.h item.h level.h toplist.h
 devel.o: devel.cpp options.h aClient.h player.h script.h extern.h \
- config.h flags.h item.h level.h pouch.h
 config.h flags.h item.h level.h pouch.h
index a06b814888f4ffb0d2eb34edee78846c8b59d688..424426bc7f7c7126e6436b253c09d410a7367e09 100644 (file)
@@ -25,6 +25,7 @@ TSRCS =       aClient.cpp \
        config.cpp \
        c_forest.cpp \
        do_attack.cpp \
+       find.cpp \
        gameserv.cpp \
        hash.cpp \
        item.cpp \
@@ -35,6 +36,7 @@ TSRCS =       aClient.cpp \
        player.cpp \
        script.cpp \
        sockhelp.cpp \
+       messages.cpp \
        toplist.cpp
 
 CONSOLESRCS = $(TSRCS) $(CONSOLEDRIVER)
index 7a31bc0cf1dc275400d6f05403d36b0209503c6f..89216e942f1b1deb8342dae927247809ca7bb0d6 100644 (file)
@@ -118,6 +118,13 @@ E unsigned int maxnicklen;
 E list<Player*> players[U_TABLE_SIZE];
 E list<aClient*> clients[U_TABLE_SIZE];
 E list<string> todaysnews;
+E list<item*> store;              // The list of items available at the store
+
+/* find.cpp begin */
+E item *findItemByID(int id);
+E item *findStoreItemByID(int id);
+E tavernItem *findTavernItemByID(int id);
+/* find.cpp end   */
 
 /** tcpclient.cpp **/
 E void check_idles();
diff --git a/gameserv/find.cpp b/gameserv/find.cpp
new file mode 100644 (file)
index 0000000..7ee4c5d
--- /dev/null
@@ -0,0 +1,58 @@
+/* This file contains functions related to searching */
+
+#include "extern.h"
+#include "item.h"
+
+
+item *findItemByID(int id)
+{
+  list<item*>::iterator item_iterator;
+  
+  item_iterator = Items.begin();
+  
+  while (item_iterator != Items.end())
+    {
+      if ((*item_iterator)->getID() == id)
+               {
+                 return (*item_iterator);
+               }
+      item_iterator++;
+    }
+  return NULL;
+}
+
+item *findStoreItemByID(int id)
+{
+  list<item*>::iterator item_iterator;
+  
+  item_iterator = store.begin();
+  
+  while (item_iterator != store.end())
+    {
+      if ((*item_iterator)->getID() == id)
+               {
+                 return (*item_iterator);
+               }
+      item_iterator++;
+    }
+  return NULL;
+}
+
+tavernItem *findTavernItemByID(int id)
+{
+  list<tavernItem>::iterator item_iterator;
+  
+  item_iterator = tavern.begin();
+  
+  while (item_iterator != tavern.end())
+    {
+      if ((*item_iterator).getItem()->getID() == id)
+               {
+                 return &(*item_iterator);
+               }
+      item_iterator++;
+    }
+  return NULL;
+}
+
+
index 55b9e388f6fd3735913197cafc625eb3f78b6239..1ddbd545dc207a44db8af09ae4f3765e3a4f6fc4 100644 (file)
@@ -33,7 +33,7 @@ Monster dragon;                               // The current dragon
 Level levels[LEVELS];                  // The newest way to store monsters
 list<item*> Items;                      // The master list of items
 list<tavernItem> tavern;                // The list of items available at the tavern
-list<item*> store;                      // The list of items available at the store
+
 toplist myToplist;          // List of the top 10 players
 
 // Database functions
@@ -45,10 +45,6 @@ int load_store();
 int load_dragon();
 int save_dragon();
 
-item *findItemByID(int id);
-item *findStoreItemByID(int id);
-tavernItem *findTavernItemByID(int id);
-
 // String functions
 #ifndef HAVE_STRTOK
 char *strtok(char *str, const char *delim);
@@ -438,64 +434,8 @@ int stricmp(const char *s1, const char *s2)
     return 1;
 }
 
-void showstats(const char *u, const char *nick)
-{
-    aClient *sender = find(u);
-       Player *p;
-    char *buf;
-    buf = new char[50];
-    char *space;
 
 
-    if (!(p = findplayer(nick)))
-         {
-        notice(s_GameServ, u, "%s not found", nick);
-         }
-    else
-         {
-        notice(s_GameServ, sender->getNick(), "Stats for %s:", p->getName().c_str());
-               
-        sprintf(buf, "Experience: %ld", p->getExp());
-        space = spaces(strlen(buf), " ");
-        notice(s_GameServ, sender->getNick(), "%s%sLevel: %d",  buf, space,
-                          p->getLevel());
-        delete [] space;
-               
-        sprintf(buf, "Gold: %ld", p->getGold());
-        space = spaces(strlen(buf), " ");
-        notice(s_GameServ, sender->getNick(), "%s%sGold in Bank: %ld", buf, space, p->getBank());
-        delete [] space;
-               
-        notice(s_GameServ, sender->getNick(), "Hit Points: %d of %d", p->getHP(),
-                          p->getMaxHP());
-               
-        sprintf(buf, "Strength: %d", p->getStrength());
-        space = spaces(strlen(buf), " ");
-        notice(s_GameServ, sender->getNick(), "%s%sDefense: %d",
-                          buf, space, p->getDefense());
-        delete [] space;
-               
-        sprintf(buf, "Armor: %s", (p->getArmor() ? p->getArmor()->getName().c_str() : "Nothing"));
-        space = spaces(strlen(buf), " ");
-               
-        notice(s_GameServ, sender->getNick(), "%s%sWeapon: %s", buf, space,
-                          (p->getWeapon() ? p->getWeapon()->getName().c_str() : "Fists"));
-               
-        delete [] space;
-               
-        sprintf(buf, "Forest Fights: %d", p->getForestFights());
-        space = spaces(strlen(buf), " ");
-        notice(s_GameServ, sender->getNick(), "%s%sPlayer Fights: %d", buf, space, p->getPlayerFights());
-        delete [] space;
-               if (p->getClient() == sender || isAdmin(sender))
-                 {
-                       showinventory(p, sender);
-                 }
-         }
-
-    delete [] buf;
-}
-
 char *spaces(int len, char *seperator)
 {
     char *final;
@@ -507,118 +447,6 @@ char *spaces(int len, char *seperator)
     return final;
 }
 
-void raw(const char *fmt, ...)
-{
-    va_list args;
-    char *input, *buffer;
-    const char *t = fmt;
-    input = new char[2048];
-    buffer = new char[1024];
-    va_start(args, fmt);
-    vsnprintf(buffer, 1024, fmt, args);
-    va_end(args);
-
-    memset(input, 0, sizeof(input)); // Initialize to NULL
-    for (t = buffer; *t; t++)
-    {
-       if (*t == '<')
-       {
-           switch(*++t) {
-            case 'S': sprintf(input, "%s%s", input, s_GameServ); break;
-           }
-       }
-       else
-       {
-           sprintf(input, "%s%c", input, *t);
-       }
-
-    }
-    #ifdef DEBUGMODE
-       log("Input: %s", input);
-    #endif
-
-    sprintf(input, "%s%s", input, "\r\n");
-    sock_puts(sock, input);
-    delete [] input;
-    delete [] buffer;
-}
-/* Send a NOTICE from the given source to the given nick. */
-
-void notice(const char *source, const char *dest, const char *fmt, ...)
-{
-    if (fmt[0] == '\0')
-        return;
-
-    char *commanduse;
-    commanduse = new char[16];
-
-    #ifdef P10
-        if (isUsePrivmsg())
-            strcpy(commanduse, "P");
-        else
-            strcpy(commanduse, "O");
-    #else
-
-        if (isUsePrivmsg())
-            strcpy(commanduse, "PRIVMSG");
-        else
-            strcpy(commanduse, "NOTICE");
-    #endif
-
-    va_list args;
-    char *input, *buffer;
-    const char *t = fmt;
-    input = new char[2048];
-    buffer = new char[1024];
-    va_start(args, fmt);
-    vsnprintf(buffer, 1024, fmt, args);
-    va_end(args);
-
-    if (dest[0] == ':')
-    {
-        dest++;
-
-      #if !defined(P10)
-        sprintf(input, ":%s %s %s :", source, commanduse, dest);
-      #else
-        sprintf(input, "%s %s %s :", gsnum, commanduse, dest);
-      #endif
-
-        dest--;
-    }
-    else
-    {
-      #if !defined(P10)
-        sprintf(input, ":%s %s %s :", source, commanduse, dest);
-      #else
-        sprintf(input, "%s %s %s :", gsnum, commanduse, dest);
-      #endif
-    }
-    log("buffer: %s", buffer);
-    for (t = buffer; *t; t++)
-    {
-        if (*t == '<')
-        {
-            if(*(++t) == 'S')
-            {
-             sprintf(input, "%s%s", input, s_GameServ);
-            }
-        }
-        else
-        {
-            sprintf(input, "%s%c", input, *t);
-        }
-
-    }
-    #ifdef DEBUGMODE
-        log("Input: %s", input);
-    #endif
-    sprintf(input, "%s%s", input, "\r\n");
-    sock_puts(sock, input);
-    delete [] commanduse;
-    delete [] input;
-    delete [] buffer;
-}
 
 
 int strnicmp(const char *s1, const char *s2, size_t len)
@@ -705,25 +533,31 @@ void do_list(char *u)
          return;
     }
   
-  if (cmd != NULL && stricmp(cmd, "TOP") == 0)
+  if (cmd == NULL || stricmp(cmd, "TOP") == 0)
   {
-     list<Player>::iterator iter;
-     bool header = false;
+    list<PlayerWrapper>::iterator iter;
+    bool header = false;
+
+    if (myToplist.empty())
+      {
+         notice(s_GameServ, u, "There are no players");
+         return;
+      }
+    myToplist.sort();
+    myToplist.reverse();
      
-     iter = myToplist.begin();
+    iter = myToplist.begin();
      
-     while (iter != myToplist.end())
-     {
-        
-        p = &(*iter);
+    while (iter != myToplist.end())
+    {
         if (!header)
         {
            notice(s_GameServ, u, "Top Players");
            header = true;
 
         }
-        notice(s_GameServ, u, "Name: %s  Level: %d", 
-        p->getName().c_str(), p->getLevel());
+        notice(s_GameServ, u, "Level: %2d Exp: %10d Name: %s", 
+        (*iter).getLevel(), (*iter).getExp(), (*iter).getName().c_str());
         iter++;
      }
   }
@@ -1511,47 +1345,6 @@ void delete_monsters()
        levels[x].monsters.clear();
 }
 
-void display_monster(char *u)
-{
-  if (is_playing(u))
-    {
-         aClient *user = find(u);
-         Player *ni = user->stats;
-         
-         notice(s_GameServ, u, "Your Hitpoints: \ 2%d\ 2", ni->getHP());
-         notice(s_GameServ, u, "%s's Hitpoints: \ 2%d\ 2", ni->getMonster()->name.c_str(), ni->getMonster()->hp);
-         notice(s_GameServ, u, "Here are your commands:");
-         notice(s_GameServ, u, "/msg <S attack");
-         notice(s_GameServ, u, "/msg <S run");
-         notice(s_GameServ, u, "What will you do?");
-    }
-}
-
-void display_players(char *u)
-{
-  aClient *user;
-  if (!(user = find(u)))
-    {
-         log("Fatal error in display_players(): Couldn't find %s", u);
-    }
-  else
-       display_players(user);
-}
-
-void display_players(aClient *user)
-{
-  char *u = user->getNick();
-  if (is_playing(user) && player_fight(user))
-    {
-         aClient *battle = user->stats->getBattle();
-         notice(s_GameServ, u, "Your Hitpoints: \ 2%d\ 2", user->stats->getHP());
-         notice(s_GameServ, u, "%s's Hitpoints: \ 2%d\ 2", battle->stats->getName().c_str(), battle->stats->getHP());
-         notice(s_GameServ, u, "Here are your commands:");
-         notice(s_GameServ, u, "/msg <S attack");
-         notice(s_GameServ, u, "/msg <S run");
-         notice(s_GameServ, u, "What will you do?");
-    }
-}
 
 
 bool is_playing(char *u)
@@ -2832,50 +2625,6 @@ void do_inventory(char *u)
   showinventory(user->stats, user);
 }
 
-void showinventory(Player *from, aClient *to)
-{
-  char *nick;
-  if (!to || !from)
-       {
-         return;
-       }
-
-  nick = to->getNick();
-  
-  if (from->inventory->isEmpty())
-       {
-         notice(s_GameServ, nick, "You aren't carrying anything");
-         return;
-       }
-  
-  list <itemContainer> *items;
-  items = from->inventory->getItems();
-  
-  list <itemContainer>::iterator item_iter, item_iter2;
-  item_iter = items->begin();
-  
-  notice(s_GameServ, nick, "Inventory for %s:", from->getName().c_str());
-  long count;
-  while (item_iter != items->end())
-       {
-         // Display a list of counted items so as not to show an extra line for duplicate items
-         count = 0;
-         item_iter2 = item_iter;
-         while (item_iter != items->end() && (*item_iter) == (*item_iter2))
-           {
-             if ((*item_iter) == (*item_iter2))
-                       {
-                         ++count;
-                       }
-             else
-                       {
-                         break;
-                       }
-             ++item_iter;
-           }
-         notice(s_GameServ, nick, "%ld.) %s (%ld)", (*item_iter2).getItem()->getID(), (*item_iter2).getItem()->getName().c_str(), count);
-       }
-}
 
 void do_tavern(char *u)
 {
@@ -3385,53 +3134,6 @@ void see_master(char *u)
     }
 }
 
-void showTavern(aClient *user)
-{
-  Player *p;
-  list<tavernItem>::iterator item_iterator;
-  item *tempItem;
-  
-  p = user->stats;
-  
-  if (!p)
-    return;
-  
-  item_iterator = tavern.begin();
-  if (tavern.empty())
-    {
-      notice(s_GameServ, user->getNick(), "Tavern is empty");
-      return;
-    }
-  
-  while (item_iterator != tavern.end())
-    {
-      if (p->getLevel() < (*item_iterator).getLevel())
-               {
-                 item_iterator++;
-                 continue;
-               }
-      tempItem = (*item_iterator).getItem();
-      notice(s_GameServ, user->getNick(), "%d. %s for %ld gold", tempItem->getID(), tempItem->getName().c_str(), tempItem->price());
-      item_iterator++;
-    }
-}
-
-void showBankBalance(const char *u)
-{
-  aClient *user;
-  Player *p;
-  
-  if (!(user = find(u)))
-       return;
-  
-  p = user->stats;
-  
-  if (!p)
-       return;
-  
-  notice(s_GameServ, u, "Account Balance: %ld     Gold On hand: %ld", p->getBank(), p->getGold());
-}
-
 void rolloverall()
 {
   list<Player*>::iterator iter;
@@ -3728,61 +3430,7 @@ void do_help(char *u)
   display_help(u, cmd);
 }
 
-void display_help(char *u, char *file)
-{
-  ifstream infile;
-  char *buf;
-  
-  if (!file)
-    {
-         infile.open("helpfiles/help");
-         if (infile.fail())
-               {
-                 log("Error opening helpfiles/help");
-                 notice(s_GameServ, u, "Error opening helpfiles/help");
-                 return;
-               }
-         buf = new char[1024];
-         while(infile.getline(buf, 1024))
-               {
-                 // Written this way, it will process <S in the helpfiles
-                 // Instead of notice(s_GameServ, u, "%s", buf);
-                 notice(s_GameServ, u, buf);
-               }
-         
-         // Minor recursion
-         aClient *user = find(u);
-         if (user && isAdmin(user))
-           display_help(u, "admin_commands");
-    }
-  else
-    {
-         char *filename;
-         filename = new char[strlen(file) + 11];
-         strcpy(filename, "helpfiles/");
-         strcat(filename, file);
-         
-         for (unsigned int x = 10; x < strlen(filename); x++)
-           filename[x] = tolower(filename[x]);
-         
-         infile.open(filename);
-         delete [] filename;
-         if (infile.fail())
-               {
-                 notice(s_GameServ, u, "No help for \ 2%s\ 2", file);
-                 return;
-               }
-         buf = new char[1024];
-         while(infile.getline(buf, 1024))
-               {
-                 // Written this way, it will process <S in the helpfiles
-                 // Instead of notice(s_GameServ, u, "%s", buf);
-                 notice(s_GameServ, u, buf);
-               }
-    }
-  infile.close();
-  delete [] buf;
-}
+
 
 void do_admin(char *u)
 {
@@ -3891,53 +3539,4 @@ bool load_monsters()
   return true;
 }
 
-item *findItemByID(int id)
-{
-  list<item*>::iterator item_iterator;
-  
-  item_iterator = Items.begin();
-  
-  while (item_iterator != Items.end())
-    {
-      if ((*item_iterator)->getID() == id)
-               {
-                 return (*item_iterator);
-               }
-      item_iterator++;
-    }
-  return NULL;
-}
-
-item *findStoreItemByID(int id)
-{
-  list<item*>::iterator item_iterator;
-  
-  item_iterator = store.begin();
-  
-  while (item_iterator != store.end())
-    {
-      if ((*item_iterator)->getID() == id)
-               {
-                 return (*item_iterator);
-               }
-      item_iterator++;
-    }
-  return NULL;
-}
 
-tavernItem *findTavernItemByID(int id)
-{
-  list<tavernItem>::iterator item_iterator;
-  
-  item_iterator = tavern.begin();
-  
-  while (item_iterator != tavern.end())
-    {
-      if ((*item_iterator).getItem()->getID() == id)
-               {
-                 return &(*item_iterator);
-               }
-      item_iterator++;
-    }
-  return NULL;
-}
index bc1c6a846479b962d3268e1659c281838e01877b..d14a10b470fb05bf00f805f14bc6f3fb1a7d30f0 100644 (file)
@@ -65,8 +65,10 @@ welcomedelay 10
 # one %s. Do not put any %d %ld or other %s into this string! You will
 # break something, because there will be a leftover argument when it is
 # called in tcpclient.cpp, because that expects one %s and nothing else.
+# You can use <S as many times as you want, though, because that is automatically
+# Replaced with the s_GameServ variable.
 # *****Comment this out to disable sending a welcome message*****
-welcomemsg Hello, %s! This network utilizes a services package called GameServ. For info on how to play the game, type /msg %S help.
+welcomemsg Hello, %s! This network utilizes a services package called GameServ. For info on how to play the game, type /msg <S help.
 
 # This is an optional config file entry that allows you to specify
 # up to 32 servers that gameserv should completly ignore.
index d3605dab5126163e828c2b2c74f38dd4bf968a1f..4d57f826eb0ca27b852356ddf943383a2e85ebea 100644 (file)
@@ -1,7 +1,7 @@
 This command enables you to identify yourself as a(n) %S administrator.
 After you identify this way, you can perform all administrator commands listed in:
-/msg %\ 2HELP\ 2 \ 2\1fadmin_commands\1f\ 2
+/msg <\ 2HELP\ 2 \ 2\1fadmin_commands\1f\ 2
 -
 SYNTAX: \ 2ADMIN\ 2 \ 2\1fpassword\1f\ 2
-Example: /msg %\ 2ADMIN\ 2 \ 2\1ffakepass\1f\ 2
+Example: /msg <\ 2ADMIN\ 2 \ 2\1ffakepass\1f\ 2
 
index f688f73c02f5fb2a9013f5ec9d5cef7f15c5d41d..1f93daa24538575b4503a55b73f30e295a3b42d0 100644 (file)
@@ -1,6 +1,6 @@
-Welcome to %S!
+Welcome to <S!
 
-Here are the commands available to only %S administrators:
+Here are the commands available to only <S administrators:
 
     \ 2LOAD\ 2            \1fPerform a manual load of the players or monsters data file\1f
     \ 2RAW\ 2             \1fSend a raw string through the GameServ pseudo server\1f
@@ -8,6 +8,6 @@ Here are the commands available to only %S administrators:
     \ 2RESET\ 2           \1fCompletely resets all players' or a single player's stats back to Level 1\1f
     \ 2SAVE\ 2            \1fPerform a manual save on the players data file\1f
     \ 2SET\ 2             \1fSet various settings on a person's character\1f
-    \ 2SHUTDOWN\ 2        \1fSave data and shut down %S\1f
+    \ 2SHUTDOWN\ 2        \1fSave data and shut down <S\1f
 
-Further help on individual commands can be accessed by typing /msg %\ 2HELP\ 2 \ 2\1fcommand\1f\ 2
+Further help on individual commands can be accessed by typing /msg <\ 2HELP\ 2 \ 2\1fcommand\1f\ 2
index 083f8ba81b2a651d391e2e6020513237297cc5a1..4fa699b4c420a84010f6c8c4b383e6dda2cb80d5 100644 (file)
@@ -3,4 +3,4 @@ Damage is based on your strength rating, and your weapon.
 When you attack, if you win, the fight is over.
 If your opponent still has hit points, it is their turn and you must wait for them to attack or run.
 SYNTAX: \ 2ATTACK\ 2
-Example: /msg %\ 2ATTACK\ 2
+Example: /msg <\ 2ATTACK\ 2
index a1789cda1ca27e57af3ea9b99f26730b68f97bca..6594782dbd79ba6c564bb3fc407794c358f7a2a3 100644 (file)
@@ -2,5 +2,5 @@ You have an account at a bank with a maximum limit of 2,000,000,000 gold pieces.
 You may withdraw and deposit funds at any point in the game except for in the middle
 of a fight.
 SYNTAX: \ 2BANK\ 2 {\ 2\1fWITHDRAW\1f\ 2 | \ 2\1fDEPOSIT\1f\ 2} {\ 2\1f#\1f\ 2 | \ 2\1fALL\1f\ 2}
-Example: /msg %\ 2BANK\ 2 \ 2\1fwithdraw\1f\ 2 \ 2\1fall\1f\ 2
-Example: /msg %\ 2BANK\ 2 \ 2\1fdeposit\1f\ 2 \ 2\1f400\1f\ 2
+Example: /msg <\ 2BANK\ 2 \ 2\1fwithdraw\1f\ 2 \ 2\1fall\1f\ 2
+Example: /msg <\ 2BANK\ 2 \ 2\1fdeposit\1f\ 2 \ 2\1f400\1f\ 2
index cf4a807758b0cf7a11c1847ff92c88359010c331..8892586279c1b6f0558844554d6e74b4c2ae5eb5 100644 (file)
@@ -1,3 +1,3 @@
 Shows how long until the next refresh
 SYNTAX: \ 2CHECK\ 2
-Example: /msg \ 2%S\ 2 \ 2\1fCHECK\1f\ 2
+Example: /msg \ 2<S\ 2 \ 2\1fCHECK\1f\ 2
index 18e88324ed0926cafd18916a2296f9349b50f9e1..e64552c7de01ccf779753f47fd850216b44dd432 100644 (file)
@@ -2,4 +2,4 @@ This command lets you fight the DRAGON, therefore completing your quest!
 If you can beat the dragon, you will be awarded VERY generously!
 
 SYNTAX: \ 2DRAGON\ 2 
-Example: /msg %\ 2DRAGON\ 2
+Example: /msg <\ 2DRAGON\ 2
index e8a6aaae5a7a2c02751589d67c915f9a0dc732ff..f79f5c8a94a0109ec3c3800c794a32aa8336e2bf 100644 (file)
@@ -1,6 +1,6 @@
 The equip command allows you to equip various weapons and armor to use them in battle. You may equip during battle if it's your turn. 
 The number you use must correspond to an item in your inventory.
 
-SYNTAX: /msg %\ 2EQUIP\ 2 \ 2\1fNUMBER\1f\ 2
+SYNTAX: /msg <\ 2EQUIP\ 2 \ 2\1fNUMBER\1f\ 2
 
-Example: /msg %S EQUIP 1
+Example: /msg <S EQUIP 1
index 7c4f2bdd981d8bdd5b1b09cb4b3b9ef6523e59f2..ebcc6f176c6f29ce3caecc32741e80d8a631a6d8 100644 (file)
@@ -4,4 +4,4 @@ The person who attacks the other player gets the advantage of striking first.
 When you lose to another player, the player takes all the gold you have on hand.
 It is wise to keep your money in the bank for this reason.
 SYNTAX: \ 2FIGHT\ 2 \ 2\1fplayer\1f\ 2
-Example: /msg %\ 2FIGHT\ 2 \ 2\1fircnick\1f\ 2
+Example: /msg <\ 2FIGHT\ 2 \ 2\1fircnick\1f\ 2
index 6f3bf8fd2c1ba88886391f5144a27527a5d90a68..140d039c8b78470e1352d0ed786b718a7950fe60 100644 (file)
@@ -2,5 +2,5 @@ Heal yourself of as many hit points as you want for a price per hit point. As yo
 levels, the price for healing goes up. You can either heal all possible points, or
 chose an arbitrary number of hit points for healing.
 SYNTAX: \ 2HEAL\ 2 {\ 2\1f#\1f\ 2 | \ 2\1fALL\1f\ 2}
-Example: /msg %\ 2HEAL\ 2 \ 2\1fall\1f\ 2
-Example: /msg %\ 2HEAL\ 2 \ 2\1f34\1f\ 2
+Example: /msg <\ 2HEAL\ 2 \ 2\1fall\1f\ 2
+Example: /msg <\ 2HEAL\ 2 \ 2\1f34\1f\ 2
index 4e3675ad23aacc86852309d5a47499ff8a44544c..0c06f906464a14281c0f120bd57cad1c85328c2a 100644 (file)
@@ -1,4 +1,4 @@
-Welcome to %S!
+Welcome to <S!
 
 Here are the basic commands available to everyone:
 
@@ -13,7 +13,7 @@ Here are the basic commands available to everyone:
     \ 2IDENTIFY\ 2        \1fIdentify yourself with a previously registered login\1f
     \ 2INVENTORY\ 2       \1fView your inventory\1f
     \ 2LIST\ 2            \1fList who is currently in the realm\1f
-    \ 2LOGOUT\ 2          \1fLets you stop playing %S without quitting\1f
+    \ 2LOGOUT\ 2          \1fLets you stop playing <S without quitting\1f
     \ 2MASTER\ 2          \1fQuestion and fight your master to gain a level\1f
     \ 2NEWS\ 2            \1fView the daily happenings\1f
     \ 2REGISTER\ 2        \1fRegister a login and join the realm\1f
@@ -24,4 +24,4 @@ Here are the basic commands available to everyone:
     \ 2TAVERN\ 2          \1fBuy and Sell Potions\1f
     \ 2USE\ 2             \1fUse Items in your Inventory\1f
 
-Further help on individual commands can be accessed by typing /msg %\ 2HELP\ 2 \ 2\1fcommand\1f\ 2
+Further help on individual commands can be accessed by typing /msg <\ 2HELP\ 2 \ 2\1fcommand\1f\ 2
index 7ef9b7322b44aa50a07314351cbd3c4ab3d35cb4..9279a5e4c630ae907e9b313808b1bd4062650147 100644 (file)
@@ -1,5 +1,5 @@
-This command enables you to restart playing on %S after having logged off of IRC.
-You must be the owner of an already registered %S player name.
+This command enables you to restart playing on <S after having logged off of IRC.
+You must be the owner of an already registered <S player name.
 This is where remembering your password from the register command is needed.
 SYNTAX: \ 2IDENTIFY\ 2 \ 2\1fplayername\1f\ 2 \ 2\1fpassword\1f\ 2
-Example: /msg %\ 2IDENTIFY\ 2 \ 2\1fKiller\1f\ 2 \ 2\1fkillerpassword\1f\ 2
+Example: /msg <\ 2IDENTIFY\ 2 \ 2\1fKiller\1f\ 2 \ 2\1fkillerpassword\1f\ 2
index 35d4e3ec820547f4d9f6de98d7b2eceffab23a16..9baea4af30e35efd1305e1e56ae3e57570a1214e 100644 (file)
@@ -1,4 +1,4 @@
 The inventory command allows a player to check their inventory to see how
 many potions they have on hand. You may check your inventory during a fight.
 
-SYNTAX: /msg %\ 2INVENTORY\ 2
+SYNTAX: /msg <\ 2INVENTORY\ 2
index 49a1d20910869d08b10d99c7519cae6b1dc239fc..cd2d89ae4e4776b5114113afa7a155cb6d0f4f99 100644 (file)
@@ -1,6 +1,6 @@
 Lists the current players in the realm and their IRC Nicknames.
-Just /msg %S LIST lists all players currently logged in.
-/msg %S LIST ALL lists all existing players.
+Just /msg <S LIST lists all players currently logged in.
+/msg <S LIST ALL lists all existing players.
 SYNTAX: \ 2LIST\ 2 [\ 2\1fALL\1f\ 2]
-Example: /msg %\ 2LIST\ 2
-Example: /msg %\ 2LIST\ 2 \ 2ALL\ 2
+Example: /msg <\ 2LIST\ 2
+Example: /msg <\ 2LIST\ 2 \ 2ALL\ 2
index 6d4847a828383ee9b2f26f3e9241de4a54c52c82..0a710f59b0d1e8a9f97f67d7a4b7a16d74d8a31b 100644 (file)
@@ -1,4 +1,4 @@
-This command manually loads the %S database file with all player stats or the monsterdata file.
+This command manually loads the <S database file with all player stats or the monsterdata file.
 SYNTAX: \ 2LOAD\ 2 \1f[MONSTERS]\1f
-Example: /msg %\ 2LOAD\ 2
-Example: /msg %\ 2LOAD \1fMONSTERS\1f\ 2
+Example: /msg <\ 2LOAD\ 2
+Example: /msg <\ 2LOAD \1fMONSTERS\1f\ 2
index b31cfad21b65a8ffe5ef6ed54b3d55545cca41cc..2ec62d05bf8592a8f3615be088263fb39821583f 100644 (file)
@@ -1,4 +1,4 @@
 This command allows players to stop playing without needing to quit the IRC Server.
-Only %S admins may logout other players.
+Only <S admins may logout other players.
 SYNTAX: \ 2LOGOUT\ 2 [\1fname\1f]
-Example: /msg %\ 2LOGOUT\ 2
+Example: /msg <\ 2LOGOUT\ 2
index 286370af6942e7a7af1ab34bdc58780f77e65d9e..e8013f9d3bd16fb74c110222f6df39bd24868962 100644 (file)
@@ -10,5 +10,5 @@ wait until the next day to fight your master again.
 If you lose, you are not dead, and your hit points to not diminish, but your master
 has won, and you must wait until the next day to fight them again.
 SYNTAX: \ 2MASTER\ 2 {\ 2\1fQUESTION\1f\ 2 | \ 2\1fFIGHT\1f\ 2}
-Example: /msg %\ 2MASTER\ 2 \ 2\1fquestion\1f\ 2
-Example: /msg %\ 2MASTER\ 2 \ 2\1ffight\1f\ 2
+Example: /msg <\ 2MASTER\ 2 \ 2\1fquestion\1f\ 2
+Example: /msg <\ 2MASTER\ 2 \ 2\1ffight\1f\ 2
index a58f7c95eb8e0dcfd1f7dbca17755f5a9869cfcf..fa979991a9aa7ec89c26250a9da00c225aaa0d9b 100644 (file)
@@ -1,3 +1,3 @@
 Shows today's daily happenings
 SYNTAX: \ 2NEWS\ 2
-Example: /msg \ 2%S\ 2 \ 2\1fNEWS\1f\ 2
+Example: /msg \ 2<S\ 2 \ 2\1fNEWS\1f\ 2
index fccfa8d28a5b0e297b6e48cba5b140c775dd0356..62f236eb4afa71d2970330712bec7c82e2323f08 100644 (file)
@@ -1,3 +1,3 @@
-Sends a string of unformatted text to the uplink via %S's server link.
+Sends a string of unformatted text to the uplink via <S's server link.
 SYNTAX: \ 2RAW \1ftext\1f\ 2
-Example: /msg %S \ 2RAW\ 2 :%S PRIVMSG #Channel :Hello Everyone :)
+Example: /msg <S \ 2RAW\ 2 :<S PRIVMSG #Channel :Hello Everyone :)
index bf1a1f3b70601338569ad5a1250497354834ae27..b0e56ed143b91a1ec4a38dabeb5808e12077a824 100644 (file)
@@ -1,5 +1,5 @@
 This command refreshes all or one of the people playing in the realm.
 Forest fights, player fights, master fight, and your hit points are maxed out.
 SYNTAX: \ 2REFRESH\ 2 {\ 2\1fALL\1f\ 2 | \ 2\1fNICK\1f\ 2}
-Example: /msg %\ 2REFRESH\ 2 \ 2\1fall\1f\ 2
-Example: /msg %\ 2REFRESH\ 2 \ 2\1fkiller\1f\ 2
+Example: /msg <\ 2REFRESH\ 2 \ 2\1fall\1f\ 2
+Example: /msg <\ 2REFRESH\ 2 \ 2\1fkiller\1f\ 2
index 8f58e1fa124617e3859a9a6be363cabd430039e5..025dbf2fcc0240747ab2b7016adaceeba99dcc3b 100644 (file)
@@ -1,8 +1,8 @@
-This is the command you must use to register your nickname with %S as a player.
-You provide a password, and %S responds by telling you that you are registered.
+This is the command you must use to register your nickname with <S as a player.
+You provide a password, and <S responds by telling you that you are registered.
 \ 2\1fWrite down your password!\1f\ 2
 Passwords are encrypted and stored in the player data file.
 This encryption can not be reversed.
 In other words: If you lose your password, there is no way to get it back.
 SYNTAX: \ 2REGISTER\ 2 \ 2\1fname\1f\ 2 \ 2\1fpassword\1f\ 2
-Example: /msg %\ 2REGISTER\ 2 \ 2\1fKiller\1f\ 2 \ 2\1ffakepass\1f\ 2
+Example: /msg <\ 2REGISTER\ 2 \ 2\1fKiller\1f\ 2 \ 2\1ffakepass\1f\ 2
index ea233a2611fab3c8cb7152b0bf7bb3afce699b4f..51e79ce38b686958b281bbbb35fd97a9ca1586ba 100644 (file)
@@ -3,5 +3,5 @@ Forest fights, player fights, master fight, and your hit points are reset.
 The player or all players have to restart the game from the beginning.
 This is useful for dealing with problematic players and bugs!
 SYNTAX: \ 2RESET\ 2 {\ 2\1fALL\1f\ 2 | \ 2\1fNICK\1f\ 2}
-Example: /msg %\ 2RESET\ 2 \ 2\1fall\1f\ 2
-Example: /msg %\ 2RESET\ 2 \ 2\1fkiller\1f\ 2
+Example: /msg <\ 2RESET\ 2 \ 2\1fall\1f\ 2
+Example: /msg <\ 2RESET\ 2 \ 2\1fkiller\1f\ 2
index 798fd620824eb00d22ea97f82046e18637b20f92..d5f5e74ee5c5530e7eaaa1209de22fda6097e6d5 100644 (file)
@@ -2,4 +2,4 @@ If you find yourself about to lose a battle, or if you know your enemy is too st
 run is the command that lets you flee from the fight. You still lose one forest fight
 or one player fight for the day, however, and any hit points lost do not replenish automatically.
 SYNTAX: \ 2RUN\ 2
-Example: /msg %\ 2RUN\ 2
+Example: /msg <\ 2RUN\ 2
index 7347c36d7dae94de4f0215fc0c094a1c1b9b036d..57337fa439f0919b75a36a1a9607fa35f8451ee5 100644 (file)
@@ -1,3 +1,3 @@
-This command manually saves the %S players' statistical database.
+This command manually saves the <S players' statistical database.
 SYNTAX: \ 2SAVE\ 2
-Example: /msg %\ 2SAVE\ 2
+Example: /msg <\ 2SAVE\ 2
index ef26e882ac41fe0781a3a840d6f5ed53327ab6a3..a8d006aa1a4f1c229e0536fe0be13519ad95db9e 100644 (file)
@@ -3,4 +3,4 @@ Once you're in a fight, you may then use the attack or run commands.
 When you defeat a monster, you gain experience and gold.
 Gold can be used to buy things from the store, and experience is needed to gain levels.
 SYNTAX: \ 2SEARCH FOREST\ 2
-Example: /msg %\ 2SEARCH FOREST\ 2
+Example: /msg <\ 2SEARCH FOREST\ 2
index 33482cd3a37ef2f16a6b41ebe21f91fbbb988d7d..eb42ff71b840986131a83ca6160fb7a1292e1f2d 100644 (file)
@@ -1,8 +1,8 @@
 This command lets you, as an admin, set every aspect of a player's stats
 to a custom value.
 
-SYNTAX: SYNTAX: /msg %S SET [NAME] {\ 2PASSWORD\ 2|\ 2BANK BALANCE\ 2|\ 2PLAYER FIGHTS\ 2|\ 2FOREST FIGHTS\ 2|\ 2GOLD\ 2|\ 2STRENGTH\ 2|\ 2DEFENSE\ 2|\ 2HP\ 2|\ 2MAXHP\ 2|\ 2EXP\ 2|\ 2LEVEL\ 2|\ 2ALIVE\ 2|\ 2WEAPON\ 2|\ 2ARMOR\ 2|\ 2SEEN MASTER\ 2} {\ 2STRING\ 2|\ 2NUMBER\ 2|\ 2TRUE\ 2|\ 2FALSE\ 2}
+SYNTAX: SYNTAX: /msg <S SET [NAME] {\ 2PASSWORD\ 2|\ 2BANK BALANCE\ 2|\ 2PLAYER FIGHTS\ 2|\ 2FOREST FIGHTS\ 2|\ 2GOLD\ 2|\ 2STRENGTH\ 2|\ 2DEFENSE\ 2|\ 2HP\ 2|\ 2MAXHP\ 2|\ 2EXP\ 2|\ 2LEVEL\ 2|\ 2ALIVE\ 2|\ 2WEAPON\ 2|\ 2ARMOR\ 2|\ 2SEEN MASTER\ 2} {\ 2STRING\ 2|\ 2NUMBER\ 2|\ 2TRUE\ 2|\ 2FALSE\ 2}
 
-Example: /msg %\ 2SET GOLD \1f1000\1f\ 2
-Example: /msg %\ 2SET Kain \1fHEALING POTIONS\1f \1f100\1f\ 2
-Example: /msg %\ 2SET Kain Alive \1fTRUE\1f\ 2
+Example: /msg <\ 2SET GOLD \1f1000\1f\ 2
+Example: /msg <\ 2SET Kain \1fHEALING POTIONS\1f \1f100\1f\ 2
+Example: /msg <\ 2SET Kain Alive \1fTRUE\1f\ 2
index ea3a33982a1861ed1f15c8a3f3d4d2f23ae5a08c..e5cdba91c7279f983916042144354f74a10bbbbb 100644 (file)
@@ -1,3 +1,3 @@
-This command shuts down %S while saving the database of player statistics for later.
+This command shuts down <S while saving the database of player statistics for later.
 SYNTAX: \ 2SHUTDOWN\ 2
-Example: /msg %\ 2SHUTDOWN\ 2
+Example: /msg <\ 2SHUTDOWN\ 2
index 9cb1c6c9ad89224ad41e74abc620d24f5eb95191..29fd44cb69e5cc9cb3a0d7b0b7e0ee6b475281a2 100644 (file)
@@ -1,4 +1,4 @@
-Get a list of %S related stats on you or another player in the realm.
+Get a list of <S related stats on you or another player in the realm.
 SYNTAX: \ 2STATS\ 2 [\ 2\1fplayername\1f\ 2]
-Example: /msg %\ 2STATS\ 2
-Example: /msg %\ 2STATS\ 2 \ 2\1fBob\1f\ 2
+Example: /msg <\ 2STATS\ 2
+Example: /msg <\ 2STATS\ 2 \ 2\1fBob\1f\ 2
index f03326e7f388530ff5832054633dcadf832e9a8c..81cd59449d3c62eed34bff064cf6c783c37a1c8e 100644 (file)
@@ -1,4 +1,4 @@
-This is perhaps the most complex command in %S from a user's perspective. 
+This is perhaps the most complex command in <S from a user's perspective. 
 There are three modes for this command: \ 2LIST\ 2\ 2BUY\ 2, and \ 2SELL\ 2
 You will want to list weapons or armors before attempting to purchase a 
 new piece of equipment so that you have an idea of the prices involved.
@@ -6,6 +6,6 @@ You have to sell your weapons/armor before you buy new equipment.
 SYNTAX: \ 2STORE\ 2 \ 2\1fLIST\1f\ 2 {\ 2\1fWEAPONS\1f\ 2 | \ 2\1fARMOR\1f\ 2}
 SYNTAX: \ 2STORE\ 2 \ 2\1fBUY\1f\ 2 {\ 2\1fWEAPON\1f\ 2 | \ 2\1fARMOR\1f\ 2\ 2\1f#\1f\ 2
 SYNTAX: \ 2STORE\ 2 \ 2\1fSELL\1f\ 2 {\ 2\1fWEAPON\1f\ 2 | \ 2\1fARMOR\1f\ 2}
-Example: /msg %\ 2STORE\ 2 \ 2\1flist\1f\ 2 \ 2\1fweapons\1f\ 2
-Example: /msg %\ 2STORE\ 2 \ 2\1fbuy\1f\ 2 \ 2\1fweapon\1f\ 2 \ 215\ 2
-Example: /msg %\ 2STORE\ 2 \ 2\1fsell\1f\ 2 \ 2\1farmor\1f\ 2
+Example: /msg <\ 2STORE\ 2 \ 2\1flist\1f\ 2 \ 2\1fweapons\1f\ 2
+Example: /msg <\ 2STORE\ 2 \ 2\1fbuy\1f\ 2 \ 2\1fweapon\1f\ 2 \ 215\ 2
+Example: /msg <\ 2STORE\ 2 \ 2\1fsell\1f\ 2 \ 2\1farmor\1f\ 2
index 7af931b76680e07b1ff1138d0c3b037194b4c3c5..dab63d2f4d73d5a0dedf49162d9f9f58f31a480a 100644 (file)
@@ -3,7 +3,7 @@ The items can be used throughout the game for things such as strength
 boosts and healing.
 
 SYNTAX: \ 2TAVERN\ 2 [LIST | BUY {NUMBER} <NUMBER OF ITEMS TO BUY>]
-Example: /msg %\ 2TAVERN\ 2
-Example: /msg %\ 2TAVERN\ 2 \ 2\1flist\1f\ 2
-Example: /msg %\ 2TAVERN\ 2 \ 2\1fbuy\1f\ 2 \ 26001\ 2
-Example: /msg %\ 2TAVERN\ 2 \ 2\1fbuy\1f\ 2 \ 26001\ 2 100
+Example: /msg <\ 2TAVERN\ 2
+Example: /msg <\ 2TAVERN\ 2 \ 2\1flist\1f\ 2
+Example: /msg <\ 2TAVERN\ 2 \ 2\1fbuy\1f\ 2 \ 26001\ 2
+Example: /msg <\ 2TAVERN\ 2 \ 2\1fbuy\1f\ 2 \ 26001\ 2 100
index 13a8e655977d5aad255a64585b4c1ea554322594..6bdfe84e5831a8510593bb5d8993984fd058a07e 100644 (file)
@@ -1,4 +1,4 @@
 This command lets you use items and potions that you may be carrying.
 
-SYNTAX: /msg %S USE \ 2NUMBER\ 2
-Example: /msg %\ 2USE 6001\ 2
+SYNTAX: /msg <S USE \ 2NUMBER\ 2
+Example: /msg <\ 2USE 6001\ 2
diff --git a/gameserv/messages.cpp b/gameserv/messages.cpp
new file mode 100644 (file)
index 0000000..002ecfd
--- /dev/null
@@ -0,0 +1,376 @@
+/* This file contains only functions related to sending messages over the
+    ircd socket */
+#include "aClient.h"
+#include "player.h"
+#include "item.h"
+#include "pouch.h"
+#include "extern.h"
+#include "sockhelp.h"
+#include "flags.h"
+
+#include <fstream>
+
+using namespace std;
+
+void raw(const char *fmt, ...)
+{
+    va_list args;
+    char *input, *buffer;
+    const char *t = fmt;
+    input = new char[2048];
+    buffer = new char[1024];
+    va_start(args, fmt);
+    vsnprintf(buffer, 1024, fmt, args);
+    va_end(args);
+
+    memset(input, 0, sizeof(input)); // Initialize to NULL
+    for (t = buffer; *t; t++)
+    {
+       if (*t == '<')
+       {
+           switch(*++t) {
+            case 'S': sprintf(input, "%s%s", input, s_GameServ); break;
+           }
+       }
+       else
+       {
+           sprintf(input, "%s%c", input, *t);
+       }
+
+    }
+    #ifdef DEBUGMODE
+       log("Input: %s", input);
+    #endif
+
+    sprintf(input, "%s%s", input, "\r\n");
+    sock_puts(sock, input);
+    delete [] input;
+    delete [] buffer;
+}
+/* Send a NOTICE from the given source to the given nick. */
+
+void notice(const char *source, const char *dest, const char *fmt, ...)
+{
+    if (fmt[0] == '\0')
+        return;
+
+    char *commanduse;
+    commanduse = new char[16];
+
+    #ifdef P10
+        if (isUsePrivmsg())
+            strcpy(commanduse, "P");
+        else
+            strcpy(commanduse, "O");
+    #else
+
+        if (isUsePrivmsg())
+            strcpy(commanduse, "PRIVMSG");
+        else
+            strcpy(commanduse, "NOTICE");
+    #endif
+
+    va_list args;
+    char *input, *buffer;
+    const char *t = fmt;
+    input = new char[2048];
+    buffer = new char[1024];
+    va_start(args, fmt);
+    vsnprintf(buffer, 1024, fmt, args);
+    va_end(args);
+
+    if (dest[0] == ':')
+    {
+        dest++;
+
+      #if !defined(P10)
+        sprintf(input, ":%s %s %s :", source, commanduse, dest);
+      #else
+        sprintf(input, "%s %s %s :", gsnum, commanduse, dest);
+      #endif
+
+        dest--;
+    }
+    else
+    {
+      #if !defined(P10)
+        sprintf(input, ":%s %s %s :", source, commanduse, dest);
+      #else
+        sprintf(input, "%s %s %s :", gsnum, commanduse, dest);
+      #endif
+    }
+    log("buffer: %s", buffer);
+    for (t = buffer; *t; t++)
+    {
+        if (*t == '<')
+        {
+            if(*(++t) == 'S')
+            {
+             sprintf(input, "%s%s", input, s_GameServ);
+            }
+        }
+        else
+        {
+            sprintf(input, "%s%c", input, *t);
+        }
+
+    }
+    #ifdef DEBUGMODE
+        log("Input: %s", input);
+    #endif
+    sprintf(input, "%s%s", input, "\r\n");
+    sock_puts(sock, input);
+    delete [] commanduse;
+    delete [] input;
+    delete [] buffer;
+}
+
+void showstats(const char *u, const char *nick)
+{
+    aClient *sender = find(u);
+       Player *p;
+    char *buf;
+    buf = new char[50];
+    char *space;
+
+
+    if (!(p = findplayer(nick)))
+         {
+        notice(s_GameServ, u, "%s not found", nick);
+         }
+    else
+         {
+        notice(s_GameServ, sender->getNick(), "Stats for %s:", p->getName().c_str());
+               
+        sprintf(buf, "Experience: %ld", p->getExp());
+        space = spaces(strlen(buf), " ");
+        notice(s_GameServ, sender->getNick(), "%s%sLevel: %d",  buf, space,
+                          p->getLevel());
+        delete [] space;
+               
+        sprintf(buf, "Gold: %ld", p->getGold());
+        space = spaces(strlen(buf), " ");
+        notice(s_GameServ, sender->getNick(), "%s%sGold in Bank: %ld", buf, space, p->getBank());
+        delete [] space;
+               
+        notice(s_GameServ, sender->getNick(), "Hit Points: %d of %d", p->getHP(),
+                          p->getMaxHP());
+               
+        sprintf(buf, "Strength: %d", p->getStrength());
+        space = spaces(strlen(buf), " ");
+        notice(s_GameServ, sender->getNick(), "%s%sDefense: %d",
+                          buf, space, p->getDefense());
+        delete [] space;
+               
+        sprintf(buf, "Armor: %s", (p->getArmor() ? p->getArmor()->getName().c_str() : "Nothing"));
+        space = spaces(strlen(buf), " ");
+               
+        notice(s_GameServ, sender->getNick(), "%s%sWeapon: %s", buf, space,
+                          (p->getWeapon() ? p->getWeapon()->getName().c_str() : "Fists"));
+               
+        delete [] space;
+               
+        sprintf(buf, "Forest Fights: %d", p->getForestFights());
+        space = spaces(strlen(buf), " ");
+        notice(s_GameServ, sender->getNick(), "%s%sPlayer Fights: %d", buf, space, p->getPlayerFights());
+        delete [] space;
+               if (p->getClient() == sender || isAdmin(sender))
+                 {
+                       showinventory(p, sender);
+                 }
+         }
+
+    delete [] buf;
+}
+
+void display_monster(char *u)
+{
+  if (is_playing(u))
+    {
+         aClient *user = find(u);
+         Player *ni = user->stats;
+         
+         notice(s_GameServ, u, "Your Hitpoints: \ 2%d\ 2", ni->getHP());
+         notice(s_GameServ, u, "%s's Hitpoints: \ 2%d\ 2", ni->getMonster()->name.c_str(), ni->getMonster()->hp);
+         notice(s_GameServ, u, "Here are your commands:");
+         notice(s_GameServ, u, "/msg <S attack");
+         notice(s_GameServ, u, "/msg <S run");
+         notice(s_GameServ, u, "What will you do?");
+    }
+}
+
+void display_players(char *u)
+{
+  aClient *user;
+  if (!(user = find(u)))
+    {
+         log("Fatal error in display_players(): Couldn't find %s", u);
+    }
+  else
+       display_players(user);
+}
+
+void display_players(aClient *user)
+{
+  char *u = user->getNick();
+  if (is_playing(user) && player_fight(user))
+    {
+         aClient *battle = user->stats->getBattle();
+         notice(s_GameServ, u, "Your Hitpoints: \ 2%d\ 2", user->stats->getHP());
+         notice(s_GameServ, u, "%s's Hitpoints: \ 2%d\ 2", battle->stats->getName().c_str(), battle->stats->getHP());
+         notice(s_GameServ, u, "Here are your commands:");
+         notice(s_GameServ, u, "/msg <S attack");
+         notice(s_GameServ, u, "/msg <S run");
+         notice(s_GameServ, u, "What will you do?");
+    }
+}
+
+void showinventory(Player *from, aClient *to)
+{
+  char *nick;
+  if (!to || !from)
+       {
+         return;
+       }
+
+  nick = to->getNick();
+  
+  if (from->inventory->isEmpty())
+       {
+         notice(s_GameServ, nick, "You aren't carrying anything");
+         return;
+       }
+  
+  list <itemContainer> *items;
+  items = from->inventory->getItems();
+  
+  list <itemContainer>::iterator item_iter, item_iter2;
+  item_iter = items->begin();
+  
+  notice(s_GameServ, nick, "Inventory for %s:", from->getName().c_str());
+  long count;
+  while (item_iter != items->end())
+       {
+         // Display a list of counted items so as not to show an extra line for duplicate items
+         count = 0;
+         item_iter2 = item_iter;
+         while (item_iter != items->end() && (*item_iter) == (*item_iter2))
+           {
+             if ((*item_iter) == (*item_iter2))
+                       {
+                         ++count;
+                       }
+             else
+                       {
+                         break;
+                       }
+             ++item_iter;
+           }
+         notice(s_GameServ, nick, "%ld.) %s (%ld)", (*item_iter2).getItem()->getID(), (*item_iter2).getItem()->getName().c_str(), count);
+       }
+}
+
+
+void showTavern(aClient *user)
+{
+  Player *p;
+  list<tavernItem>::iterator item_iterator;
+  item *tempItem;
+  
+  p = user->stats;
+  
+  if (!p)
+    return;
+  
+  item_iterator = tavern.begin();
+  if (tavern.empty())
+    {
+      notice(s_GameServ, user->getNick(), "Tavern is empty");
+      return;
+    }
+  
+  while (item_iterator != tavern.end())
+    {
+      if (p->getLevel() < (*item_iterator).getLevel())
+               {
+                 item_iterator++;
+                 continue;
+               }
+      tempItem = (*item_iterator).getItem();
+      notice(s_GameServ, user->getNick(), "%d. %s for %ld gold", tempItem->getID(), tempItem->getName().c_str(), tempItem->price());
+      item_iterator++;
+    }
+}
+
+void showBankBalance(const char *u)
+{
+  aClient *user;
+  Player *p;
+  
+  if (!(user = find(u)))
+       return;
+  
+  p = user->stats;
+  
+  if (!p)
+       return;
+  
+  notice(s_GameServ, u, "Account Balance: %ld     Gold On hand: %ld", p->getBank(), p->getGold());
+}
+
+void display_help(char *u, char *file)
+{
+  ifstream infile;
+  char *buf;
+  
+  if (!file)
+    {
+         infile.open("helpfiles/help");
+         if (infile.fail())
+               {
+                 log("Error opening helpfiles/help");
+                 notice(s_GameServ, u, "Error opening helpfiles/help");
+                 return;
+               }
+         buf = new char[1024];
+         while(infile.getline(buf, 1024))
+               {
+                 // Written this way, it will process <S in the helpfiles
+                 // Instead of notice(s_GameServ, u, "%s", buf);
+                 notice(s_GameServ, u, buf);
+               }
+         
+         // Minor recursion
+         aClient *user = find(u);
+         if (user && isAdmin(user))
+           display_help(u, "admin_commands");
+    }
+  else
+    {
+         char *filename;
+         filename = new char[strlen(file) + 11];
+         strcpy(filename, "helpfiles/");
+         strcat(filename, file);
+         
+         for (unsigned int x = 10; x < strlen(filename); x++)
+           filename[x] = tolower(filename[x]);
+         
+         infile.open(filename);
+         delete [] filename;
+         if (infile.fail())
+               {
+                 notice(s_GameServ, u, "No help for \ 2%s\ 2", file);
+                 return;
+               }
+         buf = new char[1024];
+         while(infile.getline(buf, 1024))
+               {
+                 // Written this way, it will process <S in the helpfiles
+                 // Instead of notice(s_GameServ, u, "%s", buf);
+                 notice(s_GameServ, u, buf);
+               }
+    }
+  infile.close();
+  delete [] buf;
+}
+
index 0f1c8007410bf4a66eba45dba84c1f8437e1ae45..457056f722c08cd7706293931a4e7108f2786b6a 100644 (file)
@@ -510,7 +510,7 @@ void Player::delBattle()
   battle = NULL;
 }
 
-bool Player::operator <(Player &right)
+bool Player::operator < (Player &right)
 {
   if (getLevel() < right.getLevel())
        {
index 192577eff6b42f9b858afa3477bfaa53294a02f4..2e76b7614c61f8c5d14515995f3374ed5cd4579e 100644 (file)
@@ -112,7 +112,7 @@ public:
   long int lastcommand;        // timestamp for the last command typed
   long int lastlogin;          // timestamp for the last login
 
-  bool operator <(Player &right);
+  bool operator < (Player &right);
   
 private:
   string name;         // Player's Name
index 3f4cd194d29a78d9615a0ca953fd310a5d06d185..2c6e0eb4ec669a64a84ed6e1535847f12554cb87 100644 (file)
@@ -23,13 +23,15 @@ toplist::~toplist()
 }
 
 void toplist::insertPlayer(Player *p)
-{
-  myList.push_front(*p);
-//  sort();
+{\r
+   PlayerWrapper *pw;\r
+   pw = new PlayerWrapper(p);
+   myList.push_front(*pw);
+   sort();
 
-  // Reverse the list since list::sort() uses the < operator
-  myList.reverse();
-  //prune();
+   // Reverse the list since list::sort() uses the < operator
+   reverse();
+   prune();
 }
 
 void toplist::setCount(int c)
@@ -41,10 +43,14 @@ void toplist::sort()
 {
   myList.sort();
 }
-
+\r
+void toplist::reverse()\r
+{\r
+   myList.reverse();\r
+}
 void toplist::prune()
 {
-  list<Player>::iterator it;
+  list<PlayerWrapper>::iterator it;
   it = myList.begin();
 
   for (int x = 0; it != myList.end(); x++, it++)
@@ -57,13 +63,44 @@ void toplist::prune()
        }
 }
 
-list<Player>::iterator toplist::begin()
+list<PlayerWrapper>::iterator toplist::begin()
 {
   return myList.begin();
 }
 \r
 \r
-list<Player>::iterator toplist::end()\r
+list<PlayerWrapper>::iterator toplist::end()\r
 {\r
   return myList.end();\r
 }\r
+\r
+bool toplist::empty()\r
+{\r
+    return myList.empty();\r
+}\r
+\r
+bool PlayerWrapper::operator < (PlayerWrapper &right)\r
+{\r
+   return (*p < *right.p);\r
+}\r
+\r
+PlayerWrapper::PlayerWrapper()\r
+{\r
+   p = NULL;\r
+}\r
+\r
+PlayerWrapper::PlayerWrapper(Player *pl)\r
+{\r
+   p = pl;\r
+}\r
+\r
+PlayerWrapper::~PlayerWrapper()\r
+{\r
+   p = NULL;\r
+}\r
+\r
+void PlayerWrapper::setPlayer(Player *pl)\r
+{\r
+   p = pl;\r
+}\r
+\r
index 15d865bae6b99dea4d62229c6d7e9a2e0f940aed..449d1914676e5ac0c311e23e829ae679a1949300 100644 (file)
@@ -1,14 +1,53 @@
 #ifndef TOPLIST_H
 #define TOPLIST_H
 
-#include <list>
+#include <list>\r
+#include <string>\r
+#include "player.h"
 
 using namespace std;
 
 // Forward declaration
-class Player;
+class Player;\r
+class aClient;\r
+class Monster;\r
+class item;\r
 
-class toplist {
+class PlayerWrapper\r
+{\r
+   public:\r
+   PlayerWrapper();\r
+   PlayerWrapper(Player *pl);\r
+   ~PlayerWrapper();\r
+   \r
+   void setPlayer(Player *pl);\r
+   \r
+   string getName() { return p->getName(); };\r
+   int getLevel() { return p->getLevel(); };\r
+   long int getExp() { return p->getExp(); };\r
+   long int getGold() { return p->getGold(); };\r
+   long int getBank() { return p->getBank(); };\r
+   int getHP() { return p->getHP(); };\r
+   int getMaxHP() { return p->getMaxHP(); };\r
+   int getStrength() { return p->getStrength(); };\r
+   int getDefense() { return p->getDefense(); };\r
+   int getForestFights() { return p->getForestFights(); };\r
+   int getPlayerFights() { return p->getPlayerFights(); };\r
+   string getPassword() { return p->getPassword(); };\r
+\r
+   aClient *getClient() { return p->getClient(); };\r
+   Monster *getMonster() { return p->getMonster(); };\r
+   Monster *getMaster() { return p->getMaster(); };\r
+   aClient *getBattle() { return p->getBattle(); };\r
+\r
+   bool operator < (PlayerWrapper &right);\r
+   \r
+   private:\r
+   Player *p;\r
+};\r
+
+class toplist \r
+{
 public:
   // Default Constructor
   toplist();
@@ -30,17 +69,23 @@ public:
   void sort();
 
   // Prune the list so it's not larger than the count
-  void prune();
+  void prune();\r
+  \r
+  void reverse();
 
-  list<Player>::iterator begin();\r
-  list<Player>::iterator end();
+  list<PlayerWrapper>::iterator begin();\r
+  list<PlayerWrapper>::iterator end();\r
+  bool empty();
 
 private:
 
   // The actual list of players
-  list<Player> myList;
+  list<PlayerWrapper> myList;
 
   // The number of players to keep in the list
   int count;
-};
+};\r
+\r
+\r
+
 #endif