Page 1 of 1

::time bug

Posted: Sat Nov 02, 2024 9:13 am
by Sedi
As already mentioned in the BUGS doc, the ::time command gives an inaccurate count for play time. The root cause is that play_time is updated every time the player is saved. This should only be updated on logout.

player.c starting line 201 possible changes:

Code: Select all

void
player_save(struct player *p)
{
	if (p->login_date != 0) {
		(void)database_save_player(&p->mob.server->database, p);
	}
}

void
player_destroy(struct player *p)
{
	if (p->login_date != 0) {
		p->play_time += (time(NULL) - p->login_date);
	}
	player_save(p);
	...
}
It looks like you originally had this, but accidentally introduced the bug with this commit when adding routine saving.

The ::time command is already setup to include the current login session, so no changes would be necessary there.

Re: ::time bug

Posted: Sat Nov 02, 2024 9:17 am
by Stormy
Nice catch!

Re: ::time bug

Posted: Sat Nov 02, 2024 5:41 pm
by Sedi
Unfortunately it means that everyone's current play time cannot be recovered and has to be reset. Was hoping it was just going to be a display error.