Reg timing bugs

Started by Shadow, June 26, 2013, 07:07:56 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Shadow

Putting this here so I don't forget and/or to poke other admins into doing it for me ^_^:

Volkov lost his crown after only about 10 minutes out of first (should be 12 hours). During that time, it said that Sharp was 14 hours away from becoming emp despite only being in first for those 10 minute (should be 10 days).

The clan lock-in timer seems to be messed up as well, saying that volkov has not been clanned for 72 hours already. We aren't quite as certain of this one since we don't have a precise joining time, though.
<=holbs-.. ..-holbs=> <=holbs-..

taekwondokid42

It also happened in turbo last month where Snare somehow ended up with Sevz crown, even though sevz was not brought out of emperorship for more than a few minutes.

windhound

Really?  Always thought the timer was supposed to reset if you vacated the top spot for even a moment.
Guess not.

The time eqns in php are somewhat odd, as they're based on the number of seconds since the Unix Epoch (Jan 1st 1970).  Just...  eh.

The relevant code is in turns.php, ctrl+f "emperor tracking" (browser viewing, no line numbers here).  I'm assuming this reg dump is somewhat current, as reg hasn't been messed with in a looong while and my windhound.org test server is relatively new.

The variables are set in const correctly, 24*10 for emptime (heh), 12 for unemptime.

Oh, this looks wrong
    // if current emp drops out of top 10
    else if(sqleval("SELECT COUNT(*) FROM $playerdb WHERE emp=1 AND rank>10;"))


should be rank < 10
given its nearly last in an if/else tree I wouldn't think that'd get hit very often, but it does appear to be wrong

Also

dbquery("UPDATE $playerdb SET emp=0, emptime=0 WHERE num=$last_emp[num];");

in the second block, it appears to reset the previous emp without consulting unemptime

Actually, the second block is probably the biggest problem, it has this line

dbquery("UPDATE $playerdb SET emp=1, emptime=$time WHERE rank=1;");

which sets an emp (emp = 1) and sets emptime with relatively little oversight.

I really don't like that if/else tree, sets itself up for unexpected conditions.
Shadow, if you've got the time by all means.  Otherwise I might try to flatten it later, I think it can be made into a case statement which would be cleaner and easier to follow.  Once one of those if/else statements is true it ignores the remainder -- even if they're also true.

Be curious to peek at the database later, I think there may be multiple users flagged as emps. 
A Goldfish has an attention span of 3 seconds...  so do I
~ In the beginning there was nothing, which exploded ~
There are only 10 types of people in the world: Those who understand binary, and those who don't

Shadow

I can poke it this weekend if you don't get there first.
<=holbs-.. ..-holbs=> <=holbs-..

Firetooth

Would it be possible to manually set volkov up as emp again, to make up for the 10 days lost?
Quote from: Sevah on January 02, 2018, 03:51:57 PM
I'm currently in top position by a huge margin BUT I'm intentionally dropping down to the bottom.