fix regenrate oasis troops

This commit is contained in:
yi12345
2013-07-23 01:11:37 +03:00
parent f1157b588d
commit 33730f5cbb
4 changed files with 20 additions and 6 deletions
+3 -2
View File
@@ -4341,11 +4341,12 @@ $crannyimg = "<img src=\"".GP_LOCATE."img/g/g23.gif\" height=\"20\" width=\"15\"
private function regenerateOasisTroops() { private function regenerateOasisTroops() {
global $database; global $database;
$time = time(); $time = time();
$q = "SELECT * FROM " . TB_PREFIX . "odata where conqured = 0 and $time - lastupdated > 3600"; $time2 = NATURE_REGTIME;
$q = "SELECT * FROM " . TB_PREFIX . "odata where conqured = 0 and $time - lastupdated2 > $time2";
$array = $database->query_return($q); $array = $database->query_return($q);
foreach($array as $oasis) { foreach($array as $oasis) {
$database->populateOasisUnits($oasis['wref'],$oasis['high']); $database->populateOasisUnits($oasis['wref'],$oasis['high']);
$database->updateOasis($oasis['wref']); $database->updateOasis2($oasis['wref']);
} }
} }
+7 -1
View File
@@ -1461,12 +1461,18 @@ class MYSQL_DB {
$q = "UPDATE " . TB_PREFIX . "vdata set lastupdate = $time where wref = $vid"; $q = "UPDATE " . TB_PREFIX . "vdata set lastupdate = $time where wref = $vid";
return mysql_query($q, $this->connection); return mysql_query($q, $this->connection);
} }
function updateOasis($vid) { function updateOasis($vid) {
$time = time(); $time = time();
$q = "UPDATE " . TB_PREFIX . "odata set lastupdated = $time where wref = $vid"; $q = "UPDATE " . TB_PREFIX . "odata set lastupdated = $time where wref = $vid";
return mysql_query($q, $this->connection); return mysql_query($q, $this->connection);
} }
function updateOasis2($vid) {
$time = time();
$q = "UPDATE " . TB_PREFIX . "odata set lastupdated2 = $time where wref = $vid";
return mysql_query($q, $this->connection);
}
function setVillageName($vid, $name) { function setVillageName($vid, $name) {
if(!empty($name)) if(!empty($name))
@@ -2823,7 +2829,7 @@ class MYSQL_DB {
$wid = $row['id']; $wid = $row['id'];
$basearray = $this->getOMInfo($wid); $basearray = $this->getOMInfo($wid);
//We switch type of oasis and instert record with apropriate infomation. //We switch type of oasis and instert record with apropriate infomation.
$q = "INSERT into " . TB_PREFIX . "odata VALUES ('" . $basearray['id'] . "'," . $basearray['oasistype'] . ",0,800,800,800,800,800,800," . time() . ",100,2,'Unoccupied Oasis',".rand(0,2).")"; $q = "INSERT into " . TB_PREFIX . "odata VALUES ('" . $basearray['id'] . "'," . $basearray['oasistype'] . ",0,800,800,800,800,800,800," . time() . "," . time() . ",100,2,'Unoccupied Oasis',".rand(0,2).")";
$result = mysql_query($q, $this->connection); $result = mysql_query($q, $this->connection);
} }
} }
+7 -1
View File
@@ -1464,12 +1464,18 @@ class MYSQLi_DB {
$q = "UPDATE " . TB_PREFIX . "vdata set lastupdate = $time where wref = $vid"; $q = "UPDATE " . TB_PREFIX . "vdata set lastupdate = $time where wref = $vid";
return mysqli_query($this->connection, $q); return mysqli_query($this->connection, $q);
} }
function updateOasis($vid) { function updateOasis($vid) {
$time = time(); $time = time();
$q = "UPDATE " . TB_PREFIX . "odata set lastupdated = $time where wref = $vid"; $q = "UPDATE " . TB_PREFIX . "odata set lastupdated = $time where wref = $vid";
return mysqli_query($this->connection, $q); return mysqli_query($this->connection, $q);
} }
function updateOasis2($vid) {
$time = time();
$q = "UPDATE " . TB_PREFIX . "odata set lastupdated2 = $time where wref = $vid";
return mysqli_query($this->connection, $q);
}
function setVillageName($vid, $name) { function setVillageName($vid, $name) {
if(!empty($name)) if(!empty($name))
@@ -2826,7 +2832,7 @@ class MYSQLi_DB {
$wid = $row['id']; $wid = $row['id'];
$basearray = $this->getOMInfo($wid); $basearray = $this->getOMInfo($wid);
//We switch type of oasis and instert record with apropriate infomation. //We switch type of oasis and instert record with apropriate infomation.
$q = "INSERT into " . TB_PREFIX . "odata VALUES ('" . $basearray['id'] . "'," . $basearray['oasistype'] . ",0,800,800,800,800,800,800," . time() . ",100,2,'Unoccupied Oasis',".rand(0,2).")"; $q = "INSERT into " . TB_PREFIX . "odata VALUES ('" . $basearray['id'] . "'," . $basearray['oasistype'] . ",0,800,800,800,800,800,800," . time() . "," . time() . ",100,2,'Unoccupied Oasis',".rand(0,2).")";
$result = mysqli_query($this->connection, $q); $result = mysqli_query($this->connection, $q);
} }
} }
+1
View File
@@ -1036,6 +1036,7 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%odata` (
`crop` int(11) unsigned NOT NULL, `crop` int(11) unsigned NOT NULL,
`maxcrop` int(11) unsigned NOT NULL, `maxcrop` int(11) unsigned NOT NULL,
`lastupdated` int(11) unsigned NOT NULL, `lastupdated` int(11) unsigned NOT NULL,
`lastupdated2` int(11) unsigned NOT NULL,
`loyalty` int(11) NOT NULL DEFAULT '100', `loyalty` int(11) NOT NULL DEFAULT '100',
`owner` int(11) unsigned NOT NULL DEFAULT '2', `owner` int(11) unsigned NOT NULL DEFAULT '2',
`name` varchar(32) NOT NULL DEFAULT 'Unoccupied Oasis', `name` varchar(32) NOT NULL DEFAULT 'Unoccupied Oasis',