+ else
+ 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)
+{
+ aClient *user;
+ char *name = strtok(NULL, " ");
+
+ if (!(user = find(u)))
+ {
+ notice(s_GameServ, u, "Fatal error. Cannot find aClient. "\
+ "Buf: %s LOGOUT", u);
+ log("Could not find aClient Buf: %s LOGOUT",
+ u);
+ return;
+ }
+ else if (isIgnore(user))
+ {
+ #ifdef DEBUGMODE
+ log("Ignoring %s.", user->getNick());
+ #endif
+ return;
+ }
+
+ if (name)
+ {
+ if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "You must be a %S admin to use this command!");
+ }
+ else if (!(user = findplayer(name)))
+ {
+ notice(s_GameServ, u, "Couldn't find a player named %s", name);
+ }
+ else
+ {
+ notice(s_GameServ, u, "Logging out %s", user->stats->name.c_str());
+ logout(user);
+ }
+ }
+ else if (!name)
+ {
+ if (!is_playing(user))
+ {
+ notice(s_GameServ, u, "You're not logged in!");
+ }
+ else if (is_fighting(user))
+ {
+ notice(s_GameServ, u, "You can't logout while fighting!");
+ }
+ else
+ {
+ notice(s_GameServ, u, "You have left the fields. You have lived to kill another day!");
+ logout(user);
+ }
+ }
+}
+
+void logout(aClient *user)
+{
+ if (is_playing(user))
+ {
+ ListNode<aClient> *it;
+ aClient *temp;
+ unsigned long hv = iHASH((unsigned char *) user->stats->name.c_str());
+ it = players[hv].Find(user);
+
+ if (!it)
+ {
+ notice(s_GameServ, user->getNick(), "Fatal error. Contact "\
+ "%S Admin. Cannot find you in the players list.");
+ log("Error on logout(). Can't find %s in the players list",
+ #ifdef P10
+ user->getRealNick()
+ #else
+ user->getNick()
+ #endif
+ );
+ return;
+ }
+
+ temp = new aClient;
+ temp->stats = new Player;
+ temp->stats->setData(user->stats);
+ user->stats->client = NULL;
+
+ if (player_fight(user))
+ user->stats->battle->stats->battle = NULL;
+
+ delete user->stats;
+ user->stats = NULL;
+ temp->stats->client = NULL;
+ #ifdef P10
+ temp->setRealNick("Not Playing");
+ #endif
+ temp->setNick("Not Playing");
+
+ it->setNewPtr(temp);
+ #ifdef DEBUGMODE
+ log("Logged out player %s",
+ #ifdef P10
+ user->getRealNick()
+ #else
+ user->getNick()
+ #endif
+ );
+ #endif
+ }
+ clearPlaying(user);