Empire attack limit

Started by Proxy, June 06, 2014, 04:53:40 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Proxy

When I logged in to do my run like normal, I noticed some empires were maxed-out on their attack limits. These empires have in common that they have yet to have made an attack.
I last did my run around 2:50 pm, it is 12 hours after the fact and empires have not come off their limits (still maxed)

#9 http://imgur.com/jvW9XvW

#10 http://imgur.com/yxbJPcV

#11 http://imgur.com/O8vwLam

However it seems that empires that have indeed attacked do have their limit count go down as normal:

#12 http://imgur.com/OGaV3wJ

It was an inconvenience as I decided to run and completely unloaded my troops to the public market/mercs, leaving myself undefended before noticing the issue. Nothing detrimental, but hopefully this post can fix the problem for future runs other empires may have :)


Shadow

apparently this is not just for emps now...

I wonder is some deprecated sql is catching up to us. did anything on the server update recently that you know of windy?
<=holbs-.. ..-holbs=> <=holbs-..

windhound

Argh.
I kinda figured it was happening to everyone, but that the code that nukes your [attacks] when you attack someone else alleviated it.

It's weird, because it appears to work occasionally.  Fairly sure the emp unmaxxed by two on it's own, and turns are def. running.

That's such a simple piece of code...


dbquery("UPDATE $playerdb SET attacks=(attacks-2) WHERE attacks>0;");
dbquery("UPDATE $playerdb SET attacks=0 WHERE attacks > $theme[attack_limit] OR attacks < 0;");


Which means the problem is likely in dbquery

// Execute a database query (with error checking)
// This function is used to execute ALL mysql_queries within the game
function dbquery($query) {
    global $link, $stats, $admin, $irongate;
    $oquery = $query;
    $query = trim($query);
    $quoted = false;
    $nquery = "";
    if ($irongate) {
        $numericcounter = 0;
        $querytype = strtoupper(substr($query, 0, strpos($query, " ")));
    }
    for ($i = 0; $i < strlen($query); $i++) {
        if ((substr($query, $i, 1) == "\"") && (substr($nquery, -1) != "\\"))
            $quoted = !$quoted;
        if ((!$quoted) && (substr($query, $i, 1) == ";"))
            break;
        if (($irongate) && ($querytype == "UPDATE")) {
            if ((!$quoted) && (!$inwhereclause) && (strtoupper(substr($query, $i, 5)) == "WHERE")) {
                $inwhereclause = true;
                $whereclause = substr($query, $i);
            }
            if ((!$quoted) && (strtoupper(substr($query, $i, 5)) == "LIMIT"))
                $limited = $i;
            if ((!$quoted) && (is_numeric(substr($query, $i, 1))))
                $numericcounter++;
            if ((!$quoted) && ($numericcounter > 0) && (!is_numeric(substr($query, $i, 1)))) {
                if ($numericcounter >= 7)
                    $assurelimit = true;
                $numericcounter = 0;
            }
        }
        $nquery .= substr($query, $i, 1);
    }
    if (($assurelimit) && ($limited > 0))
        $nquery = substr($nquery, 0, $limited) . "LIMIT 1;";
    else if ($assurelimit)
        $nquery .= " LIMIT 1";
    $query = "$nquery;";
    $giveback = mysql_query($query);
    if ($admin) {
        $addon = "<BR><tt>$query</tt>";
        if ($oquery != $query)
            $addon .= "<hr><tt>$oquery</tt>";
    }
    if (mysql_errno ())
        theEnd("MySQL Query Error (<i>" . mysql_errno() . "</i>) " . mysql_error() . "$addon");
    $stats[queries]++;
    return $giveback;
}


http://us2.php.net/mysql_query
mysql_query is depreciated (shocking) but not yet removed. 
Should fix that eventually, but shouldn't be causing problems atm?

As an isolation step should probably just comment out the dbquery line and code in a mysqli_query() directly.  If that works (and it should) go back and poke the dbquery function (it exists because security).

Just odd. Because if dbquery is actually broken it should be affecting much more of the game.

Can't edit from here, just browsing old code - http://rwlbeta.windhound.org/source.php?script=turbo/funcs

If you'd like to take a swipe at it Shadow please do, otherwise I'll poke it later.
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'm actually going away for the weekend, so the earliest I can get to this is Monday. But I will definitely take a look then.
<=holbs-.. ..-holbs=> <=holbs-..