Skip to content

Commit 4102b44

Browse files
committed
* 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
1 parent acf2e2f commit 4102b44

8 files changed

+20
-19
lines changed

system/functions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ function getCreatureName($killer, $showStatus = false, $extendedInfo = false)
559559

560560
$str .= '<font color="'.($player->isOnline() ? 'green' : 'red').'">' . $player->getName() . '</font></b></a>';
561561
if($extendedInfo) {
562-
$str .= '<br><small>'.$player->getLevel().' '.$config['vocations'][$player->getVocation()].'</small>';
562+
$str .= '<br><small>'.$player->getLevel().' '.$player->getVocationName().'</small>';
563563
}
564564
return $str;
565565
}

system/libs/pot/OTS_Player.php

+12-6
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,6 @@ public function load($id, $fields = null, $load_skills = true)
241241
if(!isset($this->data['rank_id']) || $this->data['rank_id'] == NULL)
242242
$this->data['rank_id'] = 0;
243243

244-
if(isset($this->data['promotion'])) {
245-
global $config;
246-
if((int)$this->data['promotion'] > 0)
247-
$this->data['vocation'] += ($this->data['promotion'] * $config['vocations_amount']);
248-
}
249244
// loads skills
250245
if( $this->isLoaded() && $load_skills)
251246
{
@@ -845,6 +840,12 @@ public function getVocation()
845840
throw new E_OTS_NotLoaded();
846841
}
847842

843+
if(isset($this->data['promotion'])) {
844+
global $config;
845+
if((int)$this->data['promotion'] > 0)
846+
return ($this->data['vocation'] + ($this->data['promotion'] * $config['vocations_amount']));
847+
}
848+
848849
return $this->data['vocation'];
849850
}
850851

@@ -2920,7 +2921,12 @@ public function getVocationName()
29202921
}
29212922

29222923
global $config;
2923-
return $config['vocations'][$this->data['vocation']];
2924+
$voc = $this->getVocation();
2925+
if(!isset($config['vocations'][$voc])) {
2926+
return 'Unknown';
2927+
}
2928+
2929+
return $config['vocations'][$voc];
29242930
//return POT::getInstance()->getVocationsList()->getVocationName($this->data['vocation']);
29252931
}
29262932

system/pages/characters.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ function retrieve_former_name($name)
386386
'sex' => $player_sex,
387387
'marriage_enabled' => $config['characters']['marriage_info'] && $db->hasColumn('players', 'marriage'),
388388
'marital_status' => $marital_status,
389-
'vocation' => $config['vocations'][$player->getVocation()],
389+
'vocation' => $player->getVocationName(),
390390
'frags_enabled' => $frags_enabled,
391391
'frags_count' => $frags_count,
392392
'town' => isset($config['towns'][$player->getTownId()]) ? $config['towns'][$player->getTownId()] : null,

system/pages/forum/show_thread.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,7 @@
6363
$post['group'] = $groupName;
6464
$post['player_link'] = getPlayerLink($player->getName());
6565

66-
$post['vocation'] = 'Unknown';
67-
if(isset($config['vocations'][$player->getVocation()])) {
68-
$post['vocation'] = $config['vocations'][$player->getVocation()];
69-
}
66+
$post['vocation'] = $player->getVocationName();
7067

7168
$rank = $player->getRank();
7269
if($rank->isLoaded())

system/pages/guilds/leave_guild.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
{
9595
if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save') {
9696
$player->setRank();
97-
$twig->render('success.html.twig', array(
97+
echo $twig->render('success.html.twig', array(
9898
'title' => 'Leave guild',
9999
'description' => 'Player with name <b>'.$player->getName().'</b> leaved guild <b>'.$guild->getName().'</b>.',
100100
'custom_buttons' => $twig->render('guilds.back_button.html.twig', array(

system/pages/guilds/show.php

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111
defined('MYAAC') or die('Direct access not allowed!');
1212

13+
$title = 'Guilds';
1314
$guild_name = isset($_REQUEST['guild']) ? urldecode($_REQUEST['guild']) : null;
1415
if(!Validator::guildName($guild_name))
1516
$errors[] = Validator::getLastError();
@@ -41,6 +42,7 @@
4142
$players_from_account_in_guild = array();
4243
if($logged)
4344
{
45+
$players_from_account_ids = array();
4446
$account_players = $account_logged->getPlayers();
4547
foreach($account_players as $player)
4648
{

system/templates/account.management.html.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@
164164
{% for player in players %}
165165
{% set i = i + 1 %}
166166
<tr bgcolor="{{ getStyle(i) }}">
167-
<td><a href="{{ getLink('characters/' ~ player.getName()|urlencode) }}">{{ player.getName() }}</a></td><td>{{ player.getLevel() }}</td><td>{{ config.vocations[player.getVocation()] }}</td><td>{{ config.towns[player.getTownId()] }}</td><td>{% if player.getLastLogin() > 0 %}{{ player.getLastLogin|date('d F Y (H:i)') }}{% else %}Never.{% endif %}</td><td>{% if player.isOnline() %}<font color="green">ONLINE</font>{% else %}<font color="red">Offline</font>{% endif %}</td><td>{% if player.isHidden() %}Hidden{% else %}Visible{% endif %}</td><td>[<a href="{{ getLink('account/character/comment/' ~ player.getName|urlencode) }}" >Edit</a>]</td>
167+
<td><a href="{{ getLink('characters/' ~ player.getName()|urlencode) }}">{{ player.getName() }}</a></td><td>{{ player.getLevel() }}</td><td>{{ player.getVocationName() }}</td><td>{{ config.towns[player.getTownId()] }}</td><td>{% if player.getLastLogin() > 0 %}{{ player.getLastLogin|date('d F Y (H:i)') }}{% else %}Never.{% endif %}</td><td>{% if player.isOnline() %}<font color="green">ONLINE</font>{% else %}<font color="red">Offline</font>{% endif %}</td><td>{% if player.isHidden() %}Hidden{% else %}Visible{% endif %}</td><td>[<a href="{{ getLink('account/character/comment/' ~ player.getName|urlencode) }}" >Edit</a>]</td>
168168
</tr>
169169
{% endfor %}
170170
</table>

system/templates/characters.html.twig

+1-5
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,8 @@
385385
<td>
386386
<nobr>{{ i }}.&#160;{{ player.getName() }}{% if player.isDeleted() %}<font color="red"> [DELETED]</font>{% endif %}</nobr>
387387
</td>
388-
{% set vocation = 'Unknown' %}
389-
{% if config.vocations[player.getVocation()] is defined %}
390-
{% set vocation = config.vocations[player.getVocation()] %}
391-
{% endif %}
392388

393-
<td>{{ player.getLevel() }} {{ vocation }}</td>
389+
<td>{{ player.getLevel() }} {{ player.getVocationName() }}</td>
394390
<td>{% if player.isOnline() %}<b><font color="green">Online</font></b>{% endif %}</td>
395391
<td>
396392
<table border="0" cellspacing="0" cellpadding="0">

0 commit comments

Comments
 (0)