Jump to content

[patch/dev][6501] Limiting Characters per Account


Guest bloutix

Recommended Posts

[Patch]Limiting Characters per Account

What it does: This patch is used to limit the number of characters per Account via the file conf.

This patch is after my previous patch named "Limiting Characters per Realm".

Index: src/game/CharacterHandler.cpp
===================================================================
--- src/game/CharacterHandler.cpp        (revision 6497)
+++ src/game/CharacterHandler.cpp        (working copy)
@@ -223,6 +223,22 @@
                return;
        }

+        QueryResult *resultacct = LoginDatabase.PQuery("SELECT SUM(numchars) FROM realmcharacters WHERE acctid = '%d'", GetAccountId());
+        uint8 acctcharcount = 0;
+        if ( resultacct )
+        {
+                Field *fields=resultacct->Fetch();
+                acctcharcount = fields[0].GetUInt8();
+                delete resultacct;
+
+                if (acctcharcount >= sWorld.getConfig(CONFIG_CHARACTERS_PER_ACCOUNT))
+                {
+                        data << (uint8)CHAR_CREATE_ACCOUNT_LIMIT;
+                        SendPacket( &data );
+                        return;
+                }
+        }
+
        QueryResult *result = CharacterDatabase.PQuery("SELECT COUNT(guid) FROM characters WHERE account = '%d'", GetAccountId());
        uint8 charcount = 0;
        if ( result )
Index: src/game/World.cpp
===================================================================
--- src/game/World.cpp        (revision 6497)
+++ src/game/World.cpp        (working copy)
@@ -463,6 +463,13 @@
        m_configs[CONFIG_STRICT_CHARTER_NAMES] = sConfig.GetIntDefault("StrictCharterNames", 0);
        m_configs[CONFIG_STRICT_PET_NAMES]         = sConfig.GetIntDefault("StrictPetNames",         0);

+        m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = sConfig.GetIntDefault("CharactersPerAccount", 50);
+        if(m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] < 1 || m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] > 50)
+        {
+                sLog.outError("CharacterPerAccount (%i) must be in range 1..50. Set to 50.",m_configs[CONFIG_CHARACTERS_PER_ACCOUNT]);
+                m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = 50;
+        }
+
        m_configs[CONFIG_CHARACTERS_PER_REALM] = sConfig.GetIntDefault("CharactersPerRealm", 10);
        if(m_configs[CONFIG_CHARACTERS_PER_REALM] < 1 || m_configs[CONFIG_CHARACTERS_PER_REALM] > 10)
        {
Index: src/game/World.h
===================================================================
--- src/game/World.h        (revision 6497)
+++ src/game/World.h        (working copy)
@@ -84,6 +84,7 @@
        CONFIG_STRICT_PLAYER_NAMES,
        CONFIG_STRICT_CHARTER_NAMES,
        CONFIG_STRICT_PET_NAMES,
+        CONFIG_CHARACTERS_PER_ACCOUNT,
        CONFIG_CHARACTERS_PER_REALM,
        CONFIG_SKIP_CINEMATICS,
        CONFIG_MAX_PLAYER_LEVEL,
Index: src/mangosd/mangosd.conf.in
===================================================================
--- src/mangosd/mangosd.conf.in        (revision 6497)
+++ src/mangosd/mangosd.conf.in        (working copy)
@@ -376,6 +376,11 @@
#                                     (included in client by default, with active official localization or custom localization fonts in clientdir/Fonts).
#                                 3 basic latin characters + server timezone specific
#
+#        CharactersPerAccount
+#                Limit numbers of characters per account
+#                Default: 50 (client limitation)
+#                                The number must be between 1 and 50
+#
#        CharactersPerRealm
#                Limit numbers of characters for account at realm
#                Default: 10 (client limitation)
@@ -493,6 +498,7 @@
StrictPlayerNames = 0
StrictCharterNames = 0
StrictPetNames = 0
+CharactersPerAccount = 50
CharactersPerRealm = 10
SkipCinematics = 0
MaxPlayerLevel = 70

Rev 2 with with the verification that the value CharactesPerAccount is higher than CharactersPerRealm.

Index: src/game/CharacterHandler.cpp
===================================================================
--- src/game/CharacterHandler.cpp        (revision 6497)
+++ src/game/CharacterHandler.cpp        (working copy)
@@ -223,6 +223,22 @@
                return;
        }

+        QueryResult *resultacct = LoginDatabase.PQuery("SELECT SUM(numchars) FROM realmcharacters WHERE acctid = '%d'", GetAccountId());
+        uint8 acctcharcount = 0;
+        if ( resultacct )
+        {
+                Field *fields=resultacct->Fetch();
+                acctcharcount = fields[0].GetUInt8();
+                delete resultacct;
+
+                if (acctcharcount >= sWorld.getConfig(CONFIG_CHARACTERS_PER_ACCOUNT))
+                {
+                        data << (uint8)CHAR_CREATE_ACCOUNT_LIMIT;
+                        SendPacket( &data );
+                        return;
+                }
+        }
+
        QueryResult *result = CharacterDatabase.PQuery("SELECT COUNT(guid) FROM characters WHERE account = '%d'", GetAccountId());
        uint8 charcount = 0;
        if ( result )
Index: src/game/World.cpp
===================================================================
--- src/game/World.cpp        (revision 6497)
+++ src/game/World.cpp        (working copy)
@@ -463,6 +463,14 @@
        m_configs[CONFIG_STRICT_CHARTER_NAMES] = sConfig.GetIntDefault("StrictCharterNames", 0);
        m_configs[CONFIG_STRICT_PET_NAMES]         = sConfig.GetIntDefault("StrictPetNames",         0);

+        m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = sConfig.GetIntDefault("CharactersPerAccount", 50);
+        if(m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] < 1 || m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] > 50 && [CONFIG_CHARACTERS_PER_REALM] >= [CONFIG_CHARACTERS_PER_ACCOUNT])
+        {
+                sLog.outError("CharacterPerAccount (%i) must be in range 1..50. Set to 50.",m_configs[CONFIG_CHARACTERS_PER_ACCOUNT]);
+                sLog.outError("CharacterPerAccount (%i) must be bigger than CharacterPerRealm.",m_configs[CONFIG_CHARACTERS_PER_ACCOUNT]);
+                m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] = 50;
+        }
+
        m_configs[CONFIG_CHARACTERS_PER_REALM] = sConfig.GetIntDefault("CharactersPerRealm", 10);
        if(m_configs[CONFIG_CHARACTERS_PER_REALM] < 1 || m_configs[CONFIG_CHARACTERS_PER_REALM] > 10)
        {
Index: src/game/World.h
===================================================================
--- src/game/World.h        (revision 6497)
+++ src/game/World.h        (working copy)
@@ -84,6 +84,7 @@
        CONFIG_STRICT_PLAYER_NAMES,
        CONFIG_STRICT_CHARTER_NAMES,
        CONFIG_STRICT_PET_NAMES,
+        CONFIG_CHARACTERS_PER_ACCOUNT,
        CONFIG_CHARACTERS_PER_REALM,
        CONFIG_SKIP_CINEMATICS,
        CONFIG_MAX_PLAYER_LEVEL,
Index: src/mangosd/mangosd.conf.in
===================================================================
--- src/mangosd/mangosd.conf.in        (revision 6497)
+++ src/mangosd/mangosd.conf.in        (working copy)
@@ -376,6 +376,11 @@
#                                     (included in client by default, with active official localization or custom localization fonts in clientdir/Fonts).
#                                 3 basic latin characters + server timezone specific
#
+#        CharactersPerAccount
+#                Limit numbers of characters per account
+#                Default: 50 (client limitation)
+#                                The number must be between 1 and 50
+#
#        CharactersPerRealm
#                Limit numbers of characters for account at realm
#                Default: 10 (client limitation)
@@ -493,6 +498,7 @@
StrictPlayerNames = 0
StrictCharterNames = 0
StrictPetNames = 0
+CharactersPerAccount = 50
CharactersPerRealm = 10
SkipCinematics = 0
MaxPlayerLevel = 70

Sorry for my bad English I'm French.

Sorry an Moderator can rename this topic to [Patch]Limiting Characters per Account? Thanks a lot.

Link to comment
Share on other sites

if(m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] < 1 || m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] > 50 && [CONFIG_CHARACTERS_PER_REALM] >= [CONFIG_CHARACTERS_PER_ACCOUNT])

should be:

if(m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] < 1 || m_configs[CONFIG_CHARACTERS_PER_ACCOUNT] > 50 || m_configs[CONFIG_CHARACTERS_PER_REALM] > m_configs[CONFIG_CHARACTERS_PER_ACCOUNT])

and this:

if (acctcharcount >= sWorld.getConfig(CONFIG_CHARACTERS_PER_ACCOUNT))

should be changed to a > instead of >= to allow having 50 and not only 49 (for example)

And if the patch gets added to svn, imo also rename CharactersPerAccount and CharactersPerRealm to MaxCharactersPerAccount and MaxCharactersPerRealm

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use