+
+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->bank, p->gold);
+
+}
+
+void refreshall()
+{
+ ListNode <aClient> *it;
+ Player *p;
+
+ it = players.First();
+
+ while (it)
+ {
+ p = it->getData()->stats;
+ refresh(p);
+ it = it->Next();
+ }
+}
+
+void refresh(Player *p)
+{
+ if (!p)
+ return;
+
+ if (p->hp < p->maxhp)
+ p->hp = p->maxhp;
+ p->forest_fights = forestfights;
+ p->player_fights = 3;
+ setAlive(p);
+ clearMaster(p);
+}
+
+void do_refresh(char *u)
+{
+ char *nick = strtok(NULL, " ");
+ aClient *user;
+
+ if (!(user = find(u)))
+ {
+ notice(s_GameServ, u, "Error: aClient not found. Contact a %S admin");
+ #ifdef DEBUGMODE
+ log("Error: aClient not found: %s", u);
+ #endif
+ return;
+ }
+ else if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "You must be a %S admin to use this command!");
+ return;
+ }
+ if (!nick)
+ {
+ notice(s_GameServ, u, "SYNTAX: REFRESH {ALL | NICK}");
+ return;
+ }
+ else if (stricmp(nick, "ALL") == 0)
+ {
+ notice(s_GameServ, u, "Refreshing everyone's stats!");
+ refreshall();
+ }
+ else if ((user = find(nick)))
+ {
+ if (is_playing(user))
+ {
+ notice(s_GameServ, u, "Refreshing %s.", user->getNick());
+ refresh(user->stats);
+ }
+ else
+ {
+ notice(s_GameServ, u, "%s is not playing.", user->getNick());
+ }
+ }
+ else
+ {
+ notice(s_GameServ, u, "Nick %s not found.", nick);
+ return;
+ }
+}
+
+
+void resetall()
+{
+ ListNode <aClient> *it;
+ Player *p;
+
+ it = players.First();
+
+ while (it)
+ {
+ p = it->getData()->stats;
+ reset(p);
+ it = it->Next();
+ }
+}
+
+void reset(Player *p)
+{
+ if (!p)
+ return;
+
+ p->reset();
+}
+
+void do_reset(char *u)
+{
+ char *nick = strtok(NULL, " ");
+ aClient *user;
+
+ if (!(user = find(u)))
+ {
+ notice(s_GameServ, u, "Error: aClient not found. Contact a %S admin");
+ #ifdef DEBUGMODE
+ log("Error: aClient not found: %s", u);
+ #endif
+ return;
+ }
+ else if (!isAdmin(user))
+ {
+ notice(s_GameServ, u, "You must be a %S admin to use this command!");
+ return;
+ }
+ if (!nick)
+ {
+ notice(s_GameServ, u, "SYNTAX: RESET {ALL | NICK}");
+ return;
+ }
+ else if (stricmp(nick, "ALL") == 0)
+ {
+ notice(s_GameServ, u, "Resetting everyone's stats!");
+ resetall();
+ }
+ else if ((user = find(nick)))
+ {
+ if (is_playing(user))
+ {
+ notice(s_GameServ, u, "Resetting %s.", user->getNick());
+ reset(user->stats);
+ }
+ else
+ {
+ notice(s_GameServ, u, "%s is not playing.", user->getNick());
+ }
+ }
+ else
+ {
+ notice(s_GameServ, u, "Nick %s not found.", nick);
+ return;
+ }
+}
+
+void do_help(char *u)
+{
+ char *cmd = strtok(NULL, " ");
+
+ 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)
+{
+ aClient *user;
+ char *pass = strtok(NULL, " ");
+
+ if (!(user = find(u)))
+ {
+ #ifdef DEBUGMODE
+ log("Error: aClient not found: %s", u);
+ #endif
+ notice(s_GameServ, u, "Error: aClient not found. Contact %S admin.");
+ return;
+ }
+ if (!pass)
+ {
+ notice(s_GameServ, u, "SYNTAX: \ 2ADMIN\ 2 \ 2\1fpassword\1f\ 2");
+ return;
+ }
+
+ if (isAdmin(user))
+ {
+ notice(s_GameServ, u, "You already have administrator privledges.");
+ return;
+ }
+ else if (strcmp(pass, adminpass) == 0)
+ {
+ notice(s_GameServ, u, "Password accepted. You now have administrator privledges.");
+ setAdmin(user);
+ }
+ else
+ {
+ notice(s_GameServ, u, "Invalid password. Remember: case sensitive");
+ return;
+ }
+}
+
+bool load_monsters()
+{
+ ifstream infile;
+ infile.open("monsters.dat");
+
+ char *buf;
+
+ if (infile.fail())
+ {
+ log("Error opening monsters.dat");
+ return false;
+ }
+ init_monsters();
+ buf = new char[2048];
+
+ for (int l = 0; l < REALLEVELS; l++)
+ {
+ for (int m = 0; m < MONSTERS;)
+ {
+ infile.getline(buf, 2048);
+ if (buf[0] == '\n' || buf[0] == '\0' || buf[0] == '#')
+ continue;
+ else
+ {
+ strcpy(monsters[l][m]->name, strtok(buf, "~"));
+ strcpy(monsters[l][m]->weapon, strtok(NULL, "~"));
+ monsters[l][m]->strength = stringtoint(strtok(NULL, "~"));
+ monsters[l][m]->gold = stringtoint(strtok(NULL, "~"));
+ monsters[l][m]->exp = stringtoint(strtok(NULL, "~"));
+ monsters[l][m]->maxhp = stringtoint(strtok(NULL, "~"));
+ monsters[l][m]->hp = monsters[l][m]->maxhp;
+ strcpy(monsters[l][m]->death, strtok(NULL, ""));
+ m++;
+ }
+ }
+ }
+ delete [] buf;
+return true;
+}