Fix for servers that don't have the cap & conditions columns

This commit is contained in:
slawkens
2026-01-04 16:21:24 +01:00
parent 8b4d4fc627
commit 1faba9ed52
3 changed files with 23 additions and 11 deletions

View File

@@ -35,6 +35,7 @@ $skills = array(
$hasBlessingsColumn = $db->hasColumn('players', 'blessings'); $hasBlessingsColumn = $db->hasColumn('players', 'blessings');
$hasBlessingColumn = $db->hasColumn('players', 'blessings1'); $hasBlessingColumn = $db->hasColumn('players', 'blessings1');
$hasLookAddons = $db->hasColumn('players', 'lookaddons'); $hasLookAddons = $db->hasColumn('players', 'lookaddons');
$hasCapColumn = $db->hasColumn('players', 'cap');
$skull_type = array("None", "Yellow", "Green", "White", "Red", "Black", "Orange"); $skull_type = array("None", "Yellow", "Green", "White", "Red", "Black", "Orange");
?> ?>
@@ -167,8 +168,11 @@ else if (isset($_REQUEST['search'])) {
$town = $_POST['town']; $town = $_POST['town'];
verify_number($town, 'Town', 11); verify_number($town, 'Town', 11);
$capacity = $_POST['capacity']; if ($hasCapColumn) {
verify_number($capacity, 'Capacity', 11); $capacity = $_POST['capacity'];
verify_number($capacity, 'Capacity', 11);
}
$sex = $_POST['sex']; $sex = $_POST['sex'];
verify_number($sex, 'Sex', 1); verify_number($sex, 'Sex', 1);
@@ -282,7 +286,11 @@ else if (isset($_REQUEST['search'])) {
$player->setPosZ($pos_z); $player->setPosZ($pos_z);
$player->setSoul($soul); $player->setSoul($soul);
$player->setTownId($town); $player->setTownId($town);
$player->setCap($capacity);
if ($hasCapColumn) {
$player->setCap($capacity);
}
$player->setSex($sex); $player->setSex($sex);
$player->setLastLogin($lastlogin); $player->setLastLogin($lastlogin);
$player->setLastLogout($lastlogout); $player->setLastLogout($lastlogout);
@@ -561,10 +569,12 @@ else if (isset($_REQUEST['search'])) {
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<?php if($hasCapColumn): ?>
<div class="col-12 col-sm-12 col-lg-6"> <div class="col-12 col-sm-12 col-lg-6">
<label for="capacity" class="control-label">Capacity:</label> <label for="capacity" class="control-label">Capacity:</label>
<input type="text" class="form-control" id="capacity" name="capacity" autocomplete="off" size="3" maxlength="11" value="<?php echo $player->getCap(); ?>"/> <input type="text" class="form-control" id="capacity" name="capacity" autocomplete="off" size="3" maxlength="11" value="<?php echo $player->getCap(); ?>"/>
</div> </div>
<?php endif; ?>
<div class="col-12 col-sm-12 col-lg-6"> <div class="col-12 col-sm-12 col-lg-6">
<label for="soul" class="control-label">Soul:</label> <label for="soul" class="control-label">Soul:</label>
<input type="text" class="form-control" id="soul" name="soul" autocomplete="off" size="3" maxlength="10" value="<?php echo $player->getSoul(); ?>"/> <input type="text" class="form-control" id="soul" name="soul" autocomplete="off" size="3" maxlength="10" value="<?php echo $player->getSoul(); ?>"/>

View File

@@ -1390,12 +1390,7 @@ class OTS_Player extends OTS_Row_DAO
*/ */
public function getCap() public function getCap()
{ {
if( !isset($this->data['cap']) ) return $this->data['cap'] ?? 0;
{
throw new E_OTS_NotLoaded();
}
return $this->data['cap'];
} }
/** /**

View File

@@ -149,7 +149,10 @@ class CreateCharacter
if($db->hasColumn('players', 'direction')) if($db->hasColumn('players', 'direction'))
$player->setDirection($playerSample->getDirection()); $player->setDirection($playerSample->getDirection());
$player->setConditions($playerSample->getConditions()); if($db->hasColumn('players', 'conditions')) {
$player->setConditions($playerSample->getConditions());
}
$rank = $playerSample->getRank(); $rank = $playerSample->getRank();
if($rank->isLoaded()) { if($rank->isLoaded()) {
$player->setRank($playerSample->getRank()); $player->setRank($playerSample->getRank());
@@ -183,7 +186,11 @@ class CreateCharacter
$player->setLookHead($playerSample->getLookHead()); $player->setLookHead($playerSample->getLookHead());
$player->setLookLegs($playerSample->getLookLegs()); $player->setLookLegs($playerSample->getLookLegs());
$player->setLookType($playerSample->getLookType()); $player->setLookType($playerSample->getLookType());
$player->setCap($playerSample->getCap());
if($db->hasColumn('players', 'cap')) {
$player->setCap($playerSample->getCap());
}
$player->setBalance(0); $player->setBalance(0);
$player->setPosX(0); $player->setPosX(0);
$player->setPosY(0); $player->setPosY(0);