]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/gameserv.cpp
Fixed a bug in check_idles() in tcpclient.cpp causing is_playing(0x0) to be called...
[irc/gameservirc.git] / gameserv / gameserv.cpp
index 91eb7069080edd5cc481ed467e2a0fe85256cab2..f8dd0c47f7125c3eb2add34a376bcc11c6b54f2f 100644 (file)
@@ -54,7 +54,7 @@ bool check_password(char *name, char *plaintext); // Finds a password for the gi
 
 bool shuttingdown;
 bool timedOut(Player *p);
-void  updateTS(Player *p);
+void updateTS(Player *p);
 void timeOutEvent(Player *p);
 
 bool is_playing(char *u); // True if the given nickname in the clients list is playing.
@@ -804,6 +804,9 @@ void do_register(char *u)
            temp = players[hv].insertAtBack_RLN(user);
            temp->setPtr(user); // This is an extra step, but necessary for now
 
+           // Update the last login time
+           user->stats->lastlogin = time(NULL);
+
            notice(s_GameServ, u, "Player %s registered with password %s.", user->stats->name, password);
            notice(s_GameServ, u, "Write this password down. If you lose it, there is no way to retrieve it!");
            log("Nickname %s registered player %s.", u, user->stats->name);
@@ -879,6 +882,10 @@ void do_identify(char *u)
        setPlaying(user); // set the playing flag
 
        temp->setPtr(user);
+
+       // Update the last login time
+       user->stats->lastlogin = time(NULL);
+
        notice(s_GameServ, u, "Password Accepted. Identified.");
        showNews(u, todaysnews);
     }
@@ -2105,7 +2112,8 @@ int save_gs_dbase()
                << it->armor << ' ' << it->weapon << ' '
                << it->forest_fights << ' ' << it->player_fights <<  ' ' 
                << it->getFlags() << ' ' << it->password << ' ' << it->inventory.Healing()
-               << ' ' << it->inventory.Strength() << ' ' << it->inventory.Defense() << ' ' << it->inventory.HP() << endl;
+               << ' ' << it->inventory.Strength() << ' ' << it->inventory.Defense() << ' ' << it->inventory.HP()
+               << ' ' << it->lastlogin << endl;
        ptr = ptr->Next();
     }
    }
@@ -2189,6 +2197,13 @@ int load_gs_dbase()
        tempname = strtok(NULL, " ");
        if (tempname)
            p->inventory.setHP(stringtoint(tempname));
+
+        tempname = strtok(NULL, " ");
+       if (tempname)
+           p->lastlogin = stringtoint(tempname);
+       else
+           p->lastlogin = time(NULL);
+
        unsigned long hv = iHASH((unsigned char *) temp->stats->name);
 
        temp->stats->client = NULL;