long int stringtoint(char *number);
char *spaces(int len, char *seperator);
-void refresh(aClient *ni);
+void refresh(Player *p);
void refreshall();
void reset(aClient *ni);
void init_masters();
int strbonus[11] = {5, 7, 10, 12, 20, 35, 50, 75, 110, 150, 200};
int defbonus[11] = {2, 3, 5, 10, 15, 22, 35, 60, 80, 120, 150};
-
void gameserv(char *source, char *buf)
{
char *cmd;
cmd++; // Get rid of that : at the beginning of the :text (command)
cout << "Source: " << source << "\ncmd: " << cmd << endl;
+ long int mn = midnight();
+
+ if (mn > timestamp)
+ {
+ refreshall();
+ timestamp = mn;
+ save_timestamp();
+ }
+
if (strnicmp(cmd, ":\1PING", 6) == 0)
{
- char *timestamp;
- timestamp = strtok(NULL, "\1");
- notice(s_GameServ, source, "\1PING %s\1", timestamp);
+ char *ts;
+ ts = strtok(NULL, "\1");
+ notice(s_GameServ, source, "\1PING %s\1", ts);
} else if (stricmp(cmd, ":\1VERSION\1") == 0) {
notice(s_GameServ, source, "\1VERSION GameServ v1.0b\1");
} else if (stricmp(cmd, "SEARCH") == 0) {
} else if (stricmp(cmd, "STATS") == 0) {
do_stats(source);
} else if (stricmp(cmd, "SHUTDOWN") == 0) {
- save_gs_dbase();
- raw("SQUIT %s :leaving", servername);
+ char *pass = strtok(NULL, " ");
+ if (pass != NULL && (stricmp(pass, adminpass) == 0))
+ {
+ save_gs_dbase();
+ raw("SQUIT %s :leaving", servername);
+ }
+ else
+ {
+ notice(s_GameServ, source, "SYNTAX: /msg %S SHUTDOWN <password>");
+ }
} else if (stricmp(cmd, "SAVE") == 0) {
- save_gs_dbase();
+ char *pass = strtok(NULL, " ");
+ if (pass != NULL && (stricmp(pass, adminpass) == 0))
+ {
+ save_gs_dbase();
+ }
+ else
+ {
+ notice(s_GameServ, source, "SYNTAX: /msg %S SAVE <password>");
+ }
} else if (stricmp(cmd, "LOAD") == 0) {
- load_gs_dbase();
+ char *pass = strtok(NULL, " ");
+ if (pass != NULL && (stricmp(pass, adminpass) == 0))
+ {
+ load_gs_dbase();
+ }
+ else
+ {
+ notice(s_GameServ, source, "SYNTAX: /msg %S LOAD <password>");
+ }
} else if (stricmp(cmd, "RAW") == 0) {
- char *rest = strtok(NULL, "");
- raw(rest);
+ char *pass = strtok(NULL, " ");
+ if (pass != NULL && (stricmp(pass, adminpass) == 0))
+ {
+ char *rest = strtok(NULL, "");
+ raw("%s", rest);
+ }
+ else
+ {
+ notice(s_GameServ, source, "SYNTAX: /msg %S RAW <password> <raw>");
+ }
+ } else if (stricmp(cmd, "TESTSTAMP") == 0) {
+ char *pass = strtok(NULL, " ");
+ if (pass != NULL && (stricmp(pass, adminpass) == 0))
+ {
+ mn = time(NULL);
+ notice(s_GameServ, source, "Resetting timestamp");
+ }
+ else
+ notice(s_GameServ, source, "SYNTAX: /msg %S TESTSTAMP <password>");
}
source--; // Bring the : back so we don't leak memory
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;
+
+ p->hp = p->maxhp;
+ p->forest_fights = 100;
+ p->player_fights = 3;
+ p->alive = true;
+}