Redwall: Warlords

Discussion => Help / Bugs => Bugs => Topic started by: Shadow on June 26, 2013, 07:07:56 AM

Title: Reg timing bugs
Post by: Shadow on June 26, 2013, 07:07:56 AM
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.
Title: Re: Reg timing bugs
Post by: taekwondokid42 on June 26, 2013, 09:08:19 AM
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.
Title: Re: Reg timing bugs
Post by: windhound on June 26, 2013, 10:47:23 AM
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 (http://windhound.org/rwlbeta/source.php?script=reg/turns), 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. 
Title: Re: Reg timing bugs
Post by: Shadow on June 26, 2013, 10:50:01 AM
I can poke it this weekend if you don't get there first.
Title: Re: Reg timing bugs
Post by: Firetooth on June 26, 2013, 11:33:08 AM
Would it be possible to manually set volkov up as emp again, to make up for the 10 days lost?