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);
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) {
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)
{
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");
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);