::time bug

Discuss development and share patches.
Post Reply
Sedi
Posts: 2
Joined: Sat Nov 02, 2024 7:33 am

::time bug

Post 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.
Stormy
Site Admin
Posts: 109
Joined: Wed Oct 02, 2024 6:37 pm

Re: ::time bug

Post by Stormy »

Nice catch!
Sedi
Posts: 2
Joined: Sat Nov 02, 2024 7:33 am

Re: ::time bug

Post 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.
Post Reply