Don't count deleted players (patched from develop)

This commit is contained in:
slawkens 2022-05-31 11:54:56 +02:00
parent 084256ce01
commit e2575c3612
3 changed files with 13 additions and 4 deletions

View File

@ -138,7 +138,7 @@ class CreateCharacter
if(empty($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')) 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>!'; $errors[] = 'You have too many characters on your account <b>('.$number_of_players_on_account.'/'.config('characters_per_account').')</b>!';
} }

View File

@ -733,7 +733,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
* @return OTS_Players_List List of players from current account. * @return OTS_Players_List List of players from current account.
* @throws E_OTS_NotLoaded If account is not loaded. * @throws E_OTS_NotLoaded If account is not loaded.
*/ */
public function getPlayersList() public function getPlayersList($withDeleted = true)
{ {
if( !isset($this->data['id']) ) if( !isset($this->data['id']) )
{ {
@ -744,6 +744,15 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
$filter = new OTS_SQLFilter(); $filter = new OTS_SQLFilter();
$filter->compareField('account_id', (int) $this->data['id']); $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 // creates list object
$list = new OTS_Players_List(); $list = new OTS_Players_List();
$list->setFilter($filter); $list->setFilter($filter);

View File

@ -2,7 +2,7 @@ Please choose a name{% if config.character_samples|length > 1 %}, vocation{% end
{% if config.character_towns|length > 1 %}, town{% endif %} {% if config.character_towns|length > 1 %}, town{% endif %}
and sex for your character. <br/> 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. 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> <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 %} {% endif %}
<br/><br/> <br/><br/>
@ -145,4 +145,4 @@ In any case the name must not violate the naming conventions stated in the <a hr
</td> </td>
</tr> </tr>
</table> </table>
<script type="text/javascript" src="tools/check_name.js"></script> <script type="text/javascript" src="tools/check_name.js"></script>