#include <iomanip.h>
#include <stdlib.h>
-char *VERSION;
-char *PACKAGE;
-
-VERSION = "1.1.2";
-PACKAGE = "GameServ";
+char *PACKAGE = "GameServ";
+char *VERSION = "1.1.7";
int sock;
long timestamp;
printf("Server: %s\n",buffer);
- init_monsters();
init_masters();
load_gs_dbase();
load_timestamp();
- int loadtime = time(NULL);
+ long int loadtime = time(NULL);
+ long int currentTime;
+ long int oldTime = loadtime;
bool loaded = false;
+ if (load_monsters() == false)
+ goto end;
+
while (connected) {
if (sock_gets(sock,buffer,sizeof(buffer)) == -1) {
connected = 0;
cout << "Server: " << buffer << endl << flush;
- // Wait five seconds then we're loaded.
+ // Wait N seconds then we're loaded.
if (!loaded)
{
- if (time(NULL) >= 5 + loadtime)
+ if (time(NULL) >= welcomedelay + loadtime)
loaded = true;
}
+ // Save the player data every updateperiod seconds
+ currentTime = time(NULL);
+ if (currentTime - oldTime >= updateperiod)
+ {
+ oldTime = currentTime;
+ save_gs_dbase();
+ }
+
if (stricmp(cmd, "PING") == 0) {
char *timestamp;
timestamp = strtok(NULL, "");
raw("PONG %s", timestamp);
+ } else if (stricmp(cmd, "VERSION") == 0) {
+ char *server;
+ server = strtok(NULL, " ");
+ server++;
+ raw(":%s 351 %s %s %s. %s", servername, source+1, PACKAGE, VERSION, servername);
} else if (strncmp(cmd, "NICK", 4) == 0) {
if (buffer[0] == ':')
{
nick = strtok(NULL, " ");
newuser = new aClient(nick);
if (loaded)
- notice(s_GameServ, nick, "Hello, %s! This network utilizes a services package called GameServ. For info on how to play the game, type /msg %S help.");
+ notice(s_GameServ, nick, welcomemsg, nick);
clients.insertAtBack(newuser);
delete newuser;
aClient *quitter;
if ((quitter = find(source + 1)))
clients.remove(quitter);
- if ((quitter = findplayer(source + 1)))
- quitter->setNick("NULL");
+ if ((quitter = findIRCplayer(source + 1)))
+ {
+ quitter->setNick("!NULL!");
+ quitter->stats->user = NULL; // Unidentify them
+ }
} else if (stricmp(cmd, "PRIVMSG") == 0) {
char *rest, *dest;
// source << endl;
}
}
+
+ end:
+
save_gs_dbase();
save_timestamp();
+
delete_monsters();
delete_masters();
return client;
}
+aClient *findIRCplayer(const char *nick)
+{
+ ListNode <aClient> *newPtr;
+ aClient *p = NULL;
+
+ for (newPtr = players.First(); newPtr; newPtr = newPtr->Next())
+ {
+ p = newPtr->getData();
+ if (stricmp(p->getNick(), nick) == 0)
+ return p;
+ p = NULL;
+ }
+ return NULL;
+}
aClient *findplayer(const char *name)
{
ListNode <aClient> *newPtr;