+ 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");
+ cout << "Error: aClient not found: " << u << endl;
+ 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 do_help(char *u)
+{
+ char *cmd = strtok(NULL, " ");
+
+ if (cmd)
+ for (unsigned int x = 0; x < strlen(cmd); x++)
+ cmd[x] = tolower(cmd[x]);
+ display_help(u, cmd);
+}
+
+void display_help(char *u, char *file)
+{
+ ifstream infile;
+ char *buf;
+
+ if (!file)
+ {
+ infile.open("helpfiles/help");
+ if (infile.fail())
+ {
+ cout << "Error opening helpfiles/help" << endl;
+ 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) + 12];
+ sprintf(filename, "helpfiles/%s", file);
+ 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)))
+ {
+ cout << "Error: aClient not found: " << u << endl;
+ 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;
+ }