Skip to content

Commit

Permalink
Don't count deleted players (patched from develop)
Browse files Browse the repository at this point in the history
  • Loading branch information
slawkens committed May 31, 2022
1 parent 084256c commit e2575c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion system/libs/CreateCharacter.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public function doCreate($name, $sex, $vocation, $town, $account, &$errors)

if(empty($errors))
{
$number_of_players_on_account = $account->getPlayersList()->count();
$number_of_players_on_account = $account->getPlayersList(false)->count();
if($number_of_players_on_account >= config('characters_per_account'))
$errors[] = 'You have too many characters on your account <b>('.$number_of_players_on_account.'/'.config('characters_per_account').')</b>!';
}
Expand Down
11 changes: 10 additions & 1 deletion system/libs/pot/OTS_Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public function getPlayers()
* @return OTS_Players_List List of players from current account.
* @throws E_OTS_NotLoaded If account is not loaded.
*/
public function getPlayersList()
public function getPlayersList($withDeleted = true)
{
if( !isset($this->data['id']) )
{
Expand All @@ -744,6 +744,15 @@ public function getPlayersList()
$filter = new OTS_SQLFilter();
$filter->compareField('account_id', (int) $this->data['id']);

if(!$withDeleted) {
global $db;
if($db->hasColumn('players', 'deletion')) {
$filter->compareField('deletion', 0);
} else {
$filter->compareField('deleted', 0);
}
}

// creates list object
$list = new OTS_Players_List();
$list->setFilter($filter);
Expand Down
4 changes: 2 additions & 2 deletions system/templates/account.create_character.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Please choose a name{% if config.character_samples|length > 1 %}, vocation{% end
{% if config.character_towns|length > 1 %}, town{% endif %}
and sex for your character. <br/>
In any case the name must not violate the naming conventions stated in the <a href="?subtopic=rules" target="_blank" >{{ config.lua.serverName }} Rules</a>, or your character might get deleted or name locked.
{% if account_logged.getPlayersList()|length >= config.characters_per_account %}
{% if account_logged.getPlayersList(false)|length >= config.characters_per_account %}
<b><span style="color: red"> You have maximum number of characters per account on your account. Delete one before you make new.</span></b>
{% endif %}
<br/><br/>
Expand Down Expand Up @@ -145,4 +145,4 @@ In any case the name must not violate the naming conventions stated in the <a hr
</td>
</tr>
</table>
<script type="text/javascript" src="tools/check_name.js"></script>
<script type="text/javascript" src="tools/check_name.js"></script>

0 comments on commit e2575c3

Please sign in to comment.