diff --git a/hwe/_119.php b/hwe/_119.php index 513301d1..206a45dc 100644 --- a/hwe/_119.php +++ b/hwe/_119.php @@ -14,7 +14,7 @@ $gameStor = KVStorage::getStorage($db, 'game_env'); [$turntime, $tnmt_time] = $gameStor->getValuesAsArray(['turntime','tnmt_time']); -$plock = $db->queryFirstField('SELECT plock FROM plock'); +$plock = $db->queryFirstField('SELECT plock FROM plock WHERE `type` ="GAME"'); ?> diff --git a/hwe/func.php b/hwe/func.php index dfbe9057..d6ca6911 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -472,7 +472,8 @@ function getCommandTable(General $general) return $result; } -function getChiefCommandTable(General $general){ +function getChiefCommandTable(General $general) +{ $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); $gameStor->turnOnCache(); @@ -1121,7 +1122,7 @@ function CheckOverhead() function isLock() { - return DB::db()->queryFirstField("SELECT plock from plock limit 1") != 0; + return DB::db()->queryFirstField("SELECT plock from plock WHERE `type`='GAME'") != 0; } function tryLock(): bool @@ -1133,7 +1134,7 @@ function tryLock(): bool $db->update('plock', [ 'plock' => 1, 'locktime' => TimeUtil::now(true) - ], 'plock=0'); + ], 'plock=0 AND type="GAME"'); return $db->affectedRows() > 0; } @@ -1144,7 +1145,7 @@ function unlock(): bool $db = DB::db(); $db->update('plock', [ 'plock' => 0 - ], true); + ], 'type="GAME"'); return $db->affectedRows() > 0; } @@ -1581,7 +1582,7 @@ function giveRandomUniqueItem(General $general, string $acquireType): bool } } - foreach($db->queryAllLists('SELECT namespace, count(*) as cnt FROM `storage` WHERE namespace LIKE "ut_%" GROUP BY namespace') as [$uniqueNS, $cnt]){ + foreach ($db->queryAllLists('SELECT namespace, count(*) as cnt FROM `storage` WHERE namespace LIKE "ut_%" GROUP BY namespace') as [$uniqueNS, $cnt]) { $itemCode = substr($uniqueNS, 3); $itemClass = buildItemClass($itemCode); if (!$itemClass) { @@ -1590,7 +1591,7 @@ function giveRandomUniqueItem(General $general, string $acquireType): bool if ($itemClass->isBuyable()) { continue; } - $occupiedUnique[$itemCode] = ($occupiedUnique[$itemCode]??0) + $cnt; + $occupiedUnique[$itemCode] = ($occupiedUnique[$itemCode] ?? 0) + $cnt; } foreach (GameConst::$allItems as $itemType => $itemCategories) { @@ -1632,7 +1633,7 @@ function giveRandomUniqueItem(General $general, string $acquireType): bool $relMonthByInit = Util::joinYearMonth($year, $month) - Util::joinYearMonth($initYear, $initMonth); $availableBuyUnique = $relMonthByInit >= GameConst::$minMonthToAllowInheritItem; - if($availableBuyUnique){ + if ($availableBuyUnique) { $general->setAuxVar('inheritRandomUnique', null); } } diff --git a/hwe/index.php b/hwe/index.php index cd3ae7a6..a7512320 100644 --- a/hwe/index.php +++ b/hwe/index.php @@ -47,7 +47,7 @@ if ($me['newmsg'] == 1 || $me['newvote'] == 1) { ], 'owner=%i', $userID); } -$plock = boolval($db->queryFirstField('SELECT plock FROM plock LIMIT 1')); +$plock = boolval($db->queryFirstField('SELECT plock FROM plock WHERE `type`="GAME" LIMIT 1')); $con = checkLimit($me['con']); if ($con >= 2) { @@ -189,11 +189,11 @@ if (!$otherTextInfo) {