]> jfr.im git - irc/gameservirc.git/commitdiff
just syncing the cvs
authorkainazzzo <redacted>
Sun, 3 Apr 2005 01:54:51 +0000 (01:54 +0000)
committerkainazzzo <redacted>
Sun, 3 Apr 2005 01:54:51 +0000 (01:54 +0000)
git-svn-id: https://svn.code.sf.net/p/gameservirc/code/trunk@300 bc333340-6410-0410-a689-9d09f3c113fa

gameserv/Changes
gameserv/gameserv.cpp
gameserv/player.cpp
gameserv/player.h

index 01d5923216d334cd056bd2a6f83aadee2ba093ae..d626eedcb061e06a2172a906fb79fc4ca1d12a85 100644 (file)
@@ -1,3 +1,5 @@
+Version 1.2.6
+* Added a /msg GameServ SET command with various options - kain
 Version 1.2.5
 * All level master data is now being stored in data/masters.dat - kain
 * Added a new config file directive that allows you to specify whether or
index 9dbcce4f4bf698b6dcbce53788a263afa3521916..2087c33a7acbf6cedf15a4a0d5859ccbebd4da53 100644 (file)
@@ -110,6 +110,7 @@ void do_play(char *u);
 void do_quitg(char *u);
 void do_reset(char *u);
 void do_run(char *u);
+void do_set(char *u);
 void do_stats(char *u);
 void do_store(char *u);
 void do_tavern(char *u);
@@ -216,6 +217,8 @@ void gameserv(char *source, char *buf)
        do_identify(source);
     } else if (stricmp(cmd, "HELP") == 0) {
        do_help(source);
+    } else if (stricmp(cmd, "SET") == 0) {
+       do_set(source);
     } else if (stricmp(cmd, "STATS") == 0) {
        do_stats(source);
     } else if (stricmp(cmd, "SHUTDOWN") == 0) {
@@ -650,6 +653,128 @@ void do_list(char *u)
        notice(s_GameServ, u, "End of List");
 
 }
+void do_set(char *u)
+{
+  aClient *user, *target;
+  char *name = strtok(NULL, " ");
+  char *cmd = strtok(NULL, " ");
+  char *cmd2;
+  
+  if (!(user = find(u)))
+    {
+      notice(s_GameServ, u, "Fatal error. Cannot find aClient. "\
+            "Buf: %s LOGOUT", u);
+      return;
+    }
+  else if (isIgnore(user))
+    {
+#ifdef DEBUGMODE
+      log("Ignoring %s.", user->getNick());
+#endif
+      return;
+    }
+  else if (!name)
+    {
+      notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|WEAPON|ARMOR|HP POTIONS|STRENGTH POTIONS|DEFENSE POTIONS|HEALING POTIONS|ALIVE|SEEN MASTER} {STRING|NUMBER|ON|OFF}");
+      return;
+    }
+  else if (!(target = findplayer(name)))
+    {
+      // Back the pointers up... they didn't send a name probably
+      cmd2= cmd;
+      cmd = name;
+      target = user;
+
+      if (!is_playing(user))
+       {
+         notice(s_GameServ, u, "You must be playing to set things for yourself!");
+         return;
+       }
+    }
+  else
+    {
+      cmd2 = strtok(NULL, " ");
+    }
+
+  // Regardless of the previous if/else, if it got here, we know we have the cmd pointer at the right spot.
+  if (stricmp(cmd, "PASSWORD") == 0)
+    {
+      // Person is looking to change their password
+      // If they're an admin, or it's theirself, allow it
+      // cmd2 is pointing to the password now
+      if (isAdmin(user) || user == target)
+       {
+         target->stats->setPassword(cmd2);
+         notice(s_GameServ, u, "Password successfully changed");
+       }
+      else if (user != target && !isAdmin(user))
+       {
+         notice(s_GameServ, u, "You must be a %S admin to set other peoples' passwords.");
+         return;
+       }
+    }
+  else if (stricmp(cmd, "BANK") == 0 || stricmp(cmd, "BALANCE") == 0)
+    {
+      if (!isAdmin(user))
+       {
+         notice(s_GameServ, u, "Admins Only!");
+         return;
+       }
+      else if (stricmp(cmd, "BANK") == 0)
+       {
+         cmd2 = strtok(NULL, " "); // Need an extra parameter for set bank balance
+       }
+      else
+       {
+         target->stats->bank = stringtoint(cmd2);
+         notice(s_GameServ, u, "Balance changed!");
+       }
+    }
+  else if (stricmp(cmd, "PLAYER") == 0)
+    {
+      if (!isAdmin(user))
+       {
+         notice(s_GameServ, u, "Admins Only!");
+         return;
+       }
+      else if (stricmp(cmd2, "FIGHTS") != 0)
+       {
+         notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] PLAYER FIGHTS <number>");
+         return;
+       }
+      else
+       {
+         cmd2 = strtok(NULL, " ");
+         target->stats->player_fights = stringtoint(cmd2);
+         notice(s_GameServ, u, "Player fights changed!");
+       }         
+    }
+  else if (stricmp(cmd, "FOREST") == 0)
+    {
+      if (!isAdmin(user))
+       {
+         notice(s_GameServ, u, "Admins Only!");
+         return;
+       }
+      else if (stricmp(cmd2, "FIGHTS") != 0)
+       {
+         notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] FOREST FIGHTS <number>");
+         return;
+       }
+      else
+       {
+         cmd2 = strtok(NULL, " ");
+         target->stats->player_fights = stringtoint(cmd2);
+         notice(s_GameServ, u, "Player fights changed!");
+       }         
+    }
+  else
+    {
+      notice(s_GameServ, u, "Unknown command: SET %s", cmd);
+      notice(s_GameServ, u, "SYNTAX: /msg %S SET [NAME] {PASSWORD|BANK BALANCE|PLAYER FIGHTS|FOREST FIGHTS|GOLD|STRENGTH|DEFENSE|HP|MAXHP|EXP|LEVEL|WEAPON|ARMOR|HP POTIONS|STRENGTH POTIONS|DEFENSE POTIONS|HEALING POTIONS|ALIVE|SEEN MASTER} {STRING|NUMBER|ON|OFF}");
+      return;
+    }
+}
 
 void do_logout(char *u)
 {
@@ -766,13 +891,6 @@ void do_register(char *u)
     name = strtok(NULL, " ");
     password = strtok(NULL, " ");
 
-    static char saltChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";
-    static char salt[3];
-    
-    salt[0] = saltChars[rand() % strlen(saltChars)];
-    salt[1] = saltChars[rand() % strlen(saltChars)];
-    salt[2] = '\0';
-
     if (!name)
     {
        notice(s_GameServ, u, "SYNTAX: /msg %S REGISTER NAME PASSWORD");
@@ -805,7 +923,7 @@ void do_register(char *u)
            user->stats = new Player(user);
            user->stats->client = user; // Set the backwards pointer
            user->stats->reset(); // set the user up
-           user->stats->password = crypt(password, salt);
+           user->stats->setPassword(password);
            user->stats->name = name;
            unsigned long hv = iHASH((unsigned char *) name);
            updateTS(user->stats);
index e7376376312c76eb0a1adde48edd0293121ebc20..df3aaed9c7cd4e8557f2879ae0eb972939cb7d20 100644 (file)
@@ -89,6 +89,18 @@ Player::~Player()
        delete output;
     #endif
 }
+void Player::setPassword(const char *p)
+{
+      static char saltChars[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV\
+WXYZ0123456789./";
+      static char salt[3];
+
+      salt[0] = saltChars[rand() % strlen(saltChars)];
+      salt[1] = saltChars[rand() % strlen(saltChars)];
+      salt[2] = '\0';
+
+      password = crypt(p, salt);
+}
 
 void Player::setData(Player *right)
 {
index c2a149e796033158a016d384c02590c38840a61a..0425406c2983d5afacbc4aeb92f444d356c0b87d 100644 (file)
@@ -19,6 +19,7 @@ public:
     Player(string);
     ~Player();
     void setData(Player *);
+    void setPassword(const char *p);
     void reset();
 
     long int getFlags() { return flags; };          // Returns the Client's current flags