mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-17 00:31:02 +00:00
fix: multi_query doesn't block next queries anymore
This commit is contained in:
+34
-32
@@ -4733,7 +4733,7 @@ $wallimg = "<img src=\"".GP_LOCATE."img/g/g3".$targettribe."Icon.gif\" height=\"
|
|||||||
foreach($array as $oasis) {
|
foreach($array as $oasis) {
|
||||||
$ids[] = $oasis['wref'];
|
$ids[] = $oasis['wref'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$database->regenerateOasisUnits($ids, true);
|
$database->regenerateOasisUnits($ids, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5306,37 +5306,39 @@ $wallimg = "<img src=\"".GP_LOCATE."img/g/g3".$targettribe."Icon.gif\" height=\"
|
|||||||
$time = time();
|
$time = time();
|
||||||
$q = "SELECT * FROM " . TB_PREFIX . "artefacts where type = 8 and active = 1 and lastupdate <= ".($time - 86400);
|
$q = "SELECT * FROM " . TB_PREFIX . "artefacts where type = 8 and active = 1 and lastupdate <= ".($time - 86400);
|
||||||
$array = $database->query_return($q);
|
$array = $database->query_return($q);
|
||||||
foreach($array as $artefact) {
|
if ($array) {
|
||||||
$kind = rand(1,7);
|
foreach($array as $artefact) {
|
||||||
while($kind == 6){
|
$kind = rand(1,7);
|
||||||
$kind = rand(1,7);
|
while($kind == 6){
|
||||||
}
|
$kind = rand(1,7);
|
||||||
if($artefact['size'] != 3){
|
}
|
||||||
$bad_effect = rand(0,1);
|
if($artefact['size'] != 3){
|
||||||
}else{
|
$bad_effect = rand(0,1);
|
||||||
$bad_effect = 0;
|
}else{
|
||||||
}
|
$bad_effect = 0;
|
||||||
switch($kind) {
|
}
|
||||||
case 1:
|
switch($kind) {
|
||||||
$effect = rand(1,5);
|
case 1:
|
||||||
break;
|
$effect = rand(1,5);
|
||||||
case 2:
|
break;
|
||||||
$effect = rand(1,3);
|
case 2:
|
||||||
break;
|
$effect = rand(1,3);
|
||||||
case 3:
|
break;
|
||||||
$effect = rand(3,10);
|
case 3:
|
||||||
break;
|
$effect = rand(3,10);
|
||||||
case 4:
|
break;
|
||||||
$effect = rand(2,4);
|
case 4:
|
||||||
break;
|
$effect = rand(2,4);
|
||||||
case 5:
|
break;
|
||||||
$effect = rand(2,4);
|
case 5:
|
||||||
break;
|
$effect = rand(2,4);
|
||||||
case 7:
|
break;
|
||||||
$effect = rand(1,6);
|
case 7:
|
||||||
break;
|
$effect = rand(1,6);
|
||||||
}
|
break;
|
||||||
mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."artefacts SET kind = ". (int) $kind. ", bad_effect = $bad_effect, effect2 = $effect, lastupdate = $time WHERE id = ".(int) $artefact['id']);
|
}
|
||||||
|
mysqli_query($GLOBALS['link'],"UPDATE ".TB_PREFIX."artefacts SET kind = ". (int) $kind. ", bad_effect = $bad_effect, effect2 = $effect, lastupdate = $time WHERE id = ".(int) $artefact['id']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-9
@@ -908,7 +908,7 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
global $autoprefix;
|
global $autoprefix;
|
||||||
|
|
||||||
if (is_array($wid)) {
|
if (is_array($wid)) {
|
||||||
$wid = implode(',', $wid);
|
$wid = '"'.implode(',', $wid).'"';
|
||||||
} else {
|
} else {
|
||||||
$wid = (int) $wid;
|
$wid = (int) $wid;
|
||||||
}
|
}
|
||||||
@@ -918,10 +918,14 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
$str = file_get_contents($autoprefix."var/db/datagen-oasis-troops-regen.sql");
|
$str = file_get_contents($autoprefix."var/db/datagen-oasis-troops-regen.sql");
|
||||||
$str = preg_replace(["'%PREFIX%'", "'%VILLAGEID%'", "'%NATURE_REG_TIME%'"], [TB_PREFIX, $wid, ($automation ? NATURE_REGTIME : -1)], $str);
|
$str = preg_replace(["'%PREFIX%'", "'%VILLAGEID%'", "'%NATURE_REG_TIME%'"], [TB_PREFIX, $wid, ($automation ? NATURE_REGTIME : -1)], $str);
|
||||||
$result = $this->dblink->multi_query($str);
|
$result = $this->dblink->multi_query($str);
|
||||||
|
|
||||||
|
// fetch results of the multi-query in order to allow subsequent query() and multi_query() calls to work
|
||||||
|
while (mysqli_more_results($this->dblink) && mysqli_next_result($this->dblink)) {;}
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3885,8 +3889,11 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
$str = file_get_contents($autoprefix."var/db/struct.sql");
|
$str = file_get_contents($autoprefix."var/db/struct.sql");
|
||||||
$str = preg_replace("'%PREFIX%'", TB_PREFIX, $str);
|
$str = preg_replace("'%PREFIX%'", TB_PREFIX, $str);
|
||||||
$result = $this->dblink->multi_query($str);
|
$result = $this->dblink->multi_query($str);
|
||||||
|
|
||||||
|
// fetch results of the multi-query in order to allow subsequent query() and multi_query() calls to work
|
||||||
|
while (mysqli_more_results($this->dblink) && mysqli_next_result($this->dblink)) {;}
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
echo mysqli_error($this->dblink); exit;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -3921,14 +3928,12 @@ class MYSQLi_DB implements IDbConnection {
|
|||||||
$str = file_get_contents($autoprefix."var/db/datagen-world-data.sql");
|
$str = file_get_contents($autoprefix."var/db/datagen-world-data.sql");
|
||||||
$str = preg_replace(["'%PREFIX%'", "'%WORLDSIZE%'"], [TB_PREFIX, WORLD_MAX], $str);
|
$str = preg_replace(["'%PREFIX%'", "'%WORLDSIZE%'"], [TB_PREFIX, WORLD_MAX], $str);
|
||||||
$result = $this->dblink->multi_query($str);
|
$result = $this->dblink->multi_query($str);
|
||||||
|
|
||||||
|
// fetch results of the multi-query in order to allow subsequent query() and multi_query() calls to work
|
||||||
|
while (mysqli_more_results($this->dblink) && mysqli_next_result($this->dblink)) {;}
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
|
||||||
// we need to flush the result of our previous multi_query
|
|
||||||
// or the next multi_query in regenerateOasisUnits() will cause
|
|
||||||
// a "Commands out of sync; you can't run this command now" error
|
|
||||||
// more info: https://stackoverflow.com/a/27926561/467164
|
|
||||||
while (mysqli_next_result($this->dblink)) {;}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->regenerateOasisUnits(-1);
|
$result = $this->regenerateOasisUnits(-1);
|
||||||
|
|||||||
@@ -10,6 +10,10 @@
|
|||||||
## ##
|
## ##
|
||||||
#################################################################################
|
#################################################################################
|
||||||
|
|
||||||
|
if(!file_exists('var/installed')) {
|
||||||
|
header("Location: install/");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
include("GameEngine/Account.php");
|
include("GameEngine/Account.php");
|
||||||
|
|||||||
Reference in New Issue
Block a user