From 4102b443526e643add3b4c60ba1d604c6b442a06 Mon Sep 17 00:00:00 2001 From: slawkens1 Date: Mon, 8 Jan 2018 01:00:56 +0100 Subject: [PATCH] * important fix for servers with promotion column (#36) * caused player.vocation to be resetted when saving player, for example: on change name, accept invite to guild, leave guild * fixed empty success message on leave guild * (internal) using $player->getVocationName() where possible instead of older method * fixed some warning in guild show --- system/functions.php | 2 +- system/libs/pot/OTS_Player.php | 18 ++++++++++++------ system/pages/characters.php | 2 +- system/pages/forum/show_thread.php | 5 +---- system/pages/guilds/leave_guild.php | 2 +- system/pages/guilds/show.php | 2 ++ system/templates/account.management.html.twig | 2 +- system/templates/characters.html.twig | 6 +----- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/system/functions.php b/system/functions.php index 2f6cf84a..03c2d513 100644 --- a/system/functions.php +++ b/system/functions.php @@ -559,7 +559,7 @@ function getCreatureName($killer, $showStatus = false, $extendedInfo = false) $str .= '' . $player->getName() . ''; if($extendedInfo) { - $str .= '
'.$player->getLevel().' '.$config['vocations'][$player->getVocation()].''; + $str .= '
'.$player->getLevel().' '.$player->getVocationName().''; } return $str; } diff --git a/system/libs/pot/OTS_Player.php b/system/libs/pot/OTS_Player.php index d01f7e69..cf8b068e 100644 --- a/system/libs/pot/OTS_Player.php +++ b/system/libs/pot/OTS_Player.php @@ -241,11 +241,6 @@ class OTS_Player extends OTS_Row_DAO if(!isset($this->data['rank_id']) || $this->data['rank_id'] == NULL) $this->data['rank_id'] = 0; - if(isset($this->data['promotion'])) { - global $config; - if((int)$this->data['promotion'] > 0) - $this->data['vocation'] += ($this->data['promotion'] * $config['vocations_amount']); - } // loads skills if( $this->isLoaded() && $load_skills) { @@ -845,6 +840,12 @@ class OTS_Player extends OTS_Row_DAO throw new E_OTS_NotLoaded(); } + if(isset($this->data['promotion'])) { + global $config; + if((int)$this->data['promotion'] > 0) + return ($this->data['vocation'] + ($this->data['promotion'] * $config['vocations_amount'])); + } + return $this->data['vocation']; } @@ -2920,7 +2921,12 @@ class OTS_Player extends OTS_Row_DAO } global $config; - return $config['vocations'][$this->data['vocation']]; + $voc = $this->getVocation(); + if(!isset($config['vocations'][$voc])) { + return 'Unknown'; + } + + return $config['vocations'][$voc]; //return POT::getInstance()->getVocationsList()->getVocationName($this->data['vocation']); } diff --git a/system/pages/characters.php b/system/pages/characters.php index b2b1fc5d..68b7dc5f 100644 --- a/system/pages/characters.php +++ b/system/pages/characters.php @@ -386,7 +386,7 @@ WHERE killers.death_id = '".$death['id']."' ORDER BY killers.final_hit DESC, kil 'sex' => $player_sex, 'marriage_enabled' => $config['characters']['marriage_info'] && $db->hasColumn('players', 'marriage'), 'marital_status' => $marital_status, - 'vocation' => $config['vocations'][$player->getVocation()], + 'vocation' => $player->getVocationName(), 'frags_enabled' => $frags_enabled, 'frags_count' => $frags_count, 'town' => isset($config['towns'][$player->getTownId()]) ? $config['towns'][$player->getTownId()] : null, diff --git a/system/pages/forum/show_thread.php b/system/pages/forum/show_thread.php index 462dfa09..62e77913 100644 --- a/system/pages/forum/show_thread.php +++ b/system/pages/forum/show_thread.php @@ -63,10 +63,7 @@ foreach($posts as &$post) $post['group'] = $groupName; $post['player_link'] = getPlayerLink($player->getName()); - $post['vocation'] = 'Unknown'; - if(isset($config['vocations'][$player->getVocation()])) { - $post['vocation'] = $config['vocations'][$player->getVocation()]; - } + $post['vocation'] = $player->getVocationName(); $rank = $player->getRank(); if($rank->isLoaded()) diff --git a/system/pages/guilds/leave_guild.php b/system/pages/guilds/leave_guild.php index 180f9f82..26782433 100644 --- a/system/pages/guilds/leave_guild.php +++ b/system/pages/guilds/leave_guild.php @@ -94,7 +94,7 @@ else { if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save') { $player->setRank(); - $twig->render('success.html.twig', array( + echo $twig->render('success.html.twig', array( 'title' => 'Leave guild', 'description' => 'Player with name '.$player->getName().' leaved guild '.$guild->getName().'.', 'custom_buttons' => $twig->render('guilds.back_button.html.twig', array( diff --git a/system/pages/guilds/show.php b/system/pages/guilds/show.php index 9fbd57af..da5cbeb0 100644 --- a/system/pages/guilds/show.php +++ b/system/pages/guilds/show.php @@ -10,6 +10,7 @@ */ defined('MYAAC') or die('Direct access not allowed!'); +$title = 'Guilds'; $guild_name = isset($_REQUEST['guild']) ? urldecode($_REQUEST['guild']) : null; if(!Validator::guildName($guild_name)) $errors[] = Validator::getLastError(); @@ -41,6 +42,7 @@ else $players_from_account_in_guild = array(); if($logged) { + $players_from_account_ids = array(); $account_players = $account_logged->getPlayers(); foreach($account_players as $player) { diff --git a/system/templates/account.management.html.twig b/system/templates/account.management.html.twig index 0d705de1..6ff4aa86 100644 --- a/system/templates/account.management.html.twig +++ b/system/templates/account.management.html.twig @@ -164,7 +164,7 @@ {% for player in players %} {% set i = i + 1 %} - {{ player.getName() }}{{ player.getLevel() }}{{ config.vocations[player.getVocation()] }}{{ config.towns[player.getTownId()] }}{% if player.getLastLogin() > 0 %}{{ player.getLastLogin|date('d F Y (H:i)') }}{% else %}Never.{% endif %}{% if player.isOnline() %}ONLINE{% else %}Offline{% endif %}{% if player.isHidden() %}Hidden{% else %}Visible{% endif %}[Edit] + {{ player.getName() }}{{ player.getLevel() }}{{ player.getVocationName() }}{{ config.towns[player.getTownId()] }}{% if player.getLastLogin() > 0 %}{{ player.getLastLogin|date('d F Y (H:i)') }}{% else %}Never.{% endif %}{% if player.isOnline() %}ONLINE{% else %}Offline{% endif %}{% if player.isHidden() %}Hidden{% else %}Visible{% endif %}[Edit] {% endfor %} diff --git a/system/templates/characters.html.twig b/system/templates/characters.html.twig index 7c29ba41..95ca4bd5 100644 --- a/system/templates/characters.html.twig +++ b/system/templates/characters.html.twig @@ -385,12 +385,8 @@ {{ i }}. {{ player.getName() }}{% if player.isDeleted() %} [DELETED]{% endif %} - {% set vocation = 'Unknown' %} - {% if config.vocations[player.getVocation()] is defined %} - {% set vocation = config.vocations[player.getVocation()] %} - {% endif %} - {{ player.getLevel() }} {{ vocation }} + {{ player.getLevel() }} {{ player.getVocationName() }} {% if player.isOnline() %}Online{% endif %}