From 5b7bc2a5c30cf30e31cfcb7f1bd09cde28f32606 Mon Sep 17 00:00:00 2001 From: Roy Shum Date: Wed, 8 Nov 2017 14:20:48 +0800 Subject: [PATCH 1/3] improve performance on updatestore --- GameEngine/Automation.php | 69 ++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 37 deletions(-) diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 972b1408..929ec046 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -166,7 +166,6 @@ class Automation { } public function __construct() { - $this->procNewClimbers(); $this->ClearUser(); $this->ClearInactive(); @@ -4404,48 +4403,44 @@ class Automation { // by SlimShady95, aka Manuel Mannhardt < manuel_mannhardt@web.de > UPDATED FROM songeriux < haroldas.snei@gmail.com > private function updateStore() { global $bid10, $bid38, $bid11, $bid39; - $result = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'fdata`'); - while ($row = mysqli_fetch_assoc($result)) - { + $dataStore = []; + + while ($row = mysqli_fetch_assoc($result)) { $ress = $crop = 0; - for ($i = 19; $i < 40; ++$i) - { - if ($row['f' . $i . 't'] == 10) - { - $ress += ((isset($bid10[$row['f' . $i]]) && isset($bid10[$row['f' . $i]]['attri'])) ? $bid10[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0); - } - - if ($row['f' . $i . 't'] == 38) - { - $ress += ((isset($bid38[$row['f' . $i]]) && isset($bid38[$row['f' . $i]]['attri'])) ? $bid38[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0); - } - - - - if ($row['f' . $i . 't'] == 11) - { - $crop += ((isset($bid11[$row['f' . $i]]) && isset($bid11[$row['f' . $i]]['attri'])) ? $bid11[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0); - } - - if ($row['f' . $i . 't'] == 39) - { - $crop += ((isset($bid39[$row['f' . $i]]) && isset($bid39[$row['f' . $i]]['attri'])) ? $bid39[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0); + for ($i = 19; $i < 40; ++$i) { + $bidVar = 'bid'; + switch ($row["f$i". 't']) { + case 10: + case 38: + $bidVar .= $row["f$i". 't']; + if (isset($$bidVar[$row["f$i"]]) && isset($$bidVar[$row["f$i"]]['attri'])) { + $ress += $$bidVar[$row["f$i"]]['attri'] * STORAGE_MULTIPLIER; + } + break; + case 11: + case 39: + $bidVar .= $row["f$i". 't']; + if (isset($$bidVar[$row["f$i"]]) && isset($$bidVar[$row["f$i"]]['attri'])) { + $crop += $$bidVar[$row["f$i"]]['attri'] * STORAGE_MULTIPLIER; + } + break; } } - if ($ress == 0) - { - $ress = 800 * STORAGE_MULTIPLIER; - } - - if ($crop == 0) - { - $crop = 800 * STORAGE_MULTIPLIER; - } - - mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'vdata` SET `maxstore` = ' . (int) $ress . ', `maxcrop` = ' . (int) $crop . ' WHERE `wref` = ' . (int) $row['vref']) or die(mysqli_error($database->dblink)); + $ress = $ress?: 800 * STORAGE_MULTIPLIER; + $crop = $crop?: 800 * STORAGE_MULTIPLIER; + $dataStore[] = [$ress, $crop, $row['vref']]; } + + mysqli_begin_transaction($GLOBALS['link']) or die(mysqli_error($database->dblink));; + $sql = 'UPDATE ' .TB_PREFIX. 'vdata SET maxstore = ?, maxcrop = ? WHERE `wref` = ?'; + $stmt = mysqli_prepare($GLOBALS['link'], $sql); + foreach ($dataStore as $data) { + $stmt->bind_param('iii', $data[0], $data[1], $data[2]); + $stmt->execute() or die(mysqli_error($database->dblink)); + } + mysqli_commit($GLOBALS['link']) or die(mysqli_error($database->dblink)); } private function oasisResourcesProduce() { From 2b177540668ee91ce1ee052bed35ab4a77e4adc5 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Wed, 8 Nov 2017 08:06:27 +0100 Subject: [PATCH 2/3] fix: message sending always comes from nature --- GameEngine/Alliance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GameEngine/Alliance.php b/GameEngine/Alliance.php index 3be8e244..95d94973 100755 --- a/GameEngine/Alliance.php +++ b/GameEngine/Alliance.php @@ -489,7 +489,7 @@ class Alliance { // send the new founder an in-game message, notifying them of their election $database->sendMessage( $newleader, - 1, + 2, 'You are now leader of your alliance', "Hi!\n\nThis is to inform you that the former leader of your alliance - ".$database->escape($session->username).", has decided to quit and elected you as his replacement. You now gain full access, administration and responsibilities to your alliance.\n\nGood luck!\n\nYours sincerely,\nServer Robot :)", 0, From 136a8c55b92536e18326ab5d6659f29ac8f8d89f Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Wed, 8 Nov 2017 08:54:12 +0100 Subject: [PATCH 3/3] fix: quest 6 does not send a message with original quests set Closes #315 --- Templates/Ajax/quest_core.tpl | 7 +++++++ Templates/Ajax/quest_core25.tpl | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/Templates/Ajax/quest_core.tpl b/Templates/Ajax/quest_core.tpl index 3ac270b0..8276bfaf 100644 --- a/Templates/Ajax/quest_core.tpl +++ b/Templates/Ajax/quest_core.tpl @@ -112,6 +112,7 @@ if (isset($qact)){ $Subject="Message From The Taskmaster"; $Subject=Q6_SUBJECT; $Message=Q6_MESSAGE; + $database->sendMessage($session->userinfo['id'],4,$Subject,$Message,0,0,0,0,0); $RB=true; //Give Reward $database->modifyResource($session->villages[0],50,60,30,30,1); @@ -486,6 +487,9 @@ $temp['uid']=$session->userinfo['id']; $ranking->procRankReq($temp); $displayarray = $database->getUserArray($temp['uid'],1); $rRes=$ranking->searchRank($displayarray['username'],"username"); +if (!isset($rSubmited)) { + $rSubmited = null; +} if ($rRes!=$rSubmited && $rRes !== 'Multihunter'){?> {"markup":"\n\t\t

\"\"<\/h1>
”<\/i>

<\/div>
\"\/>
<\/span><\/div>\n\t\t

<\/div>\n\t\t","number":-4,"reward":false,"qgsrc":"q_luserinfo['tribe'];?>","msrc":"","altstep":99} @@ -507,6 +511,9 @@ if ($ironL<1 || $clayL<1){?> unread || $RB==true){?> {"markup":"\n\t\t

\"\" <\/h1>
”<\/i>

<\/div>
<\/span><\/div>\n\t\t

<\/div>\n\t\t","number":"-6","reward":false,"qgsrc":"q_luserinfo['tribe'];?>","msrc":"i2","altstep":99} diff --git a/Templates/Ajax/quest_core25.tpl b/Templates/Ajax/quest_core25.tpl index 4e78a792..8c98ebe4 100644 --- a/Templates/Ajax/quest_core25.tpl +++ b/Templates/Ajax/quest_core25.tpl @@ -468,6 +468,9 @@ $temp['uid']=$session->userinfo['id']; $ranking->procRankReq($temp); $displayarray = $database->getUserArray($temp['uid'],1); $rRes=$ranking->searchRank($displayarray['username'],"username"); +if (!isset($rSubmited)) { + $rSubmited = null; +} if ($rRes!=$rSubmited && $rRes !== 'Multihunter'){?> {"markup":"\n\t\t

\"\"<\/h1>
”<\/i>

<\/div>
\"\/>
<\/span><\/div>\n\t\t

<\/div>\n\t\t","number":-4,"reward":false,"qgsrc":"q_luserinfo['tribe'];?>","msrc":"","altstep":99} @@ -489,6 +492,9 @@ if ($ironL<1 || $clayL<1){?> unread || $RB==true){?> {"markup":"\n\t\t

\"\" <\/h1>
”<\/i>

<\/div>
<\/span><\/div>\n\t\t

<\/div>\n\t\t","number":"-6","reward":false,"qgsrc":"q_luserinfo['tribe'];?>","msrc":"i2","altstep":99}