Jump to content

Custum Patch Question


tim

Recommended Posts

I wrote a little patch now the Question is this the right way to insert this to code ?

commit 898f02a4744b29c770f1d89256b04c46b82257c8
Author: tim4 <123 @test.de>
Date:   Wed Jan 12 08:10:55 2011 +0100

   Timed LVL up Patch
   Signed-off-by: tim4 <123 @test.de>

diff --git a/src/game/Language.h b/src/game/Language.h
index eeba52b..b957d55 100644
--- a/src/game/Language.h
+++ b/src/game/Language.h
@@ -909,8 +909,9 @@ enum MangosStrings
    //                                    10000-10999

    // Use for custom patches             11000-11999
+    LANG_LP_RUPT_MESSAGE                = 11100,//WLK RP LUPT system v0.3M - message

-    // NOT RESERVED IDS                   12000-1999999999
+    // NOT RESERVED IDS                   12000-1999999999
    // `db_script_string` table index     2000000000-2000009999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID)
    // For other tables maybe             2000010000-2147483647 (max index)
};
diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp
index a37b6fc..2ffefb3 100644
--- a/src/game/ObjectAccessor.cpp
+++ b/src/game/ObjectAccessor.cpp
@@ -35,6 +35,7 @@
#include "Opcodes.h"
#include "ObjectGuid.h"
#include "World.h"
+#include "Language.h" // WLK RP LUPT system v0.3 - MaNGOS

#include <cmath>

@@ -102,8 +103,7 @@ ObjectAccessor::FindPlayerByName(const char *name)
    return NULL;
}

-void
-ObjectAccessor::SaveAllPlayers()
+void ObjectAccessor::SaveAllPlayers()
{
    HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
    HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
@@ -111,6 +111,72 @@ ObjectAccessor::SaveAllPlayers()
        itr->second->SaveToDB();
}

+void ObjectAccessor::PlayerLevelByTime() // WLK RP LUPT system v0.3M 
+{ 
+    uint8 confMaxLevel = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); 
+    uint8 confAgeForLevel = sWorld.getConfig(CONFIG_UINT32_RP_LUPT_AGE_FOR_LEVEL); 
+    bool  confMsgEnabled = sWorld.getConfig(CONFIG_BOOL_RP_LUPT_MSG_ENABLED); 
+ 
+    HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock()); 
+    HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers(); 
+    for (HashMapHolder<Player>::MapType::iterator iter = m.begin(); iter != m.end(); ++iter) 
+    { 
+     // If player is online & has played time 
+        if (iter->second->IsInWorld() && iter->second->GetLevelPlayedTime() >= confAgeForLevel) 
+        { 
+         // If player isn't in AFK mode & isn't in combat & is alive & has lower level than max level 
+            if(!iter->second->isAFK() && !iter->second->isInCombat() && iter->second->isAlive() && 
+                iter->second->getLevel() < confMaxLevel) 
+            { 
+                uint8 level = iter->second->getLevel() + 1; 
+ 
+                iter->second->GiveLevel(level);             // Give new level 
+                iter->second->InitTalentForLevel();         // Init talents for new level 
+                iter->second->SetUInt32Value(PLAYER_XP, 0); // Reset XP bar 
+                iter->second->SaveToDB(true);               // Save player to DB (now works properly) 
+ 
+             // RP LUPT system v0.3 - system messages 
+                if(confMsgEnabled) 
+                { 
+                    std::stringstream ss; 
+                    uint32 bytes = 0; 
+                    bytes |= uint8(level);                          // level 
+                    bytes |= uint8(iter->second->getRace())  <<  8; // race 
+                    bytes |= uint8(iter->second->getClass()) << 16; // class 
+ 
+                    if(!sWorld.GetLuptMessagesData(bytes)) 
+                    { 
+                        bytes = 0;                  // reset byte value 
+                        bytes |= uint8(level);      // level 
+                        bytes |= uint8(-1) <<  8;   // all races 
+                        bytes |= uint8(-1) << 16;   // all classes 
+                        if(!sWorld.GetLuptMessagesData(bytes)) 
+                            return; 
+                    } 
+ 
+                    ss << iter->second->GetName() << ": " << sWorld.GetLuptMessagesData(bytes)->msgText; 
+ 
+                    switch(sWorld.GetLuptMessagesData(bytes)->msgType) 
+                    { 
+                    case 1: 
+                        sWorld.SendWorldText(LANG_LP_RUPT_MESSAGE, ss.str().c_str()); 
+                        break; 
+                    case 2: 
+                        sWorld.SendServerMessage(SERVER_MSG_CUSTOM, ss.str().c_str(), NULL); 
+                        break; 
+                    case 3: 
+                        sWorld.SendWorldText(LANG_LP_RUPT_MESSAGE, ss.str().c_str()); 
+                        sWorld.SendServerMessage(SERVER_MSG_CUSTOM, ss.str().c_str(), NULL); 
+                        break; 
+                    default: 
+                        break; 
+                    } 
+                } 
+            } 
+        } 
+    } 
+}
+
void ObjectAccessor::KickPlayer(ObjectGuid guid)
{
    if (Player* p = HashMapHolder<Player>::Find(guid))
diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h
index 5307b70..66802a9 100644
--- a/src/game/ObjectAccessor.h
+++ b/src/game/ObjectAccessor.h
@@ -119,7 +119,8 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
        }

        void SaveAllPlayers();
-
+        void PlayerLevelByTime(); // WLK RP LUPT system v0.3M
+        
        // Pet access
        static Pet* FindPet(ObjectGuid guid);               // if need pet at specific map better use Map::GetPet

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index a23d4b1..93f5e94 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -17451,13 +17451,21 @@ bool Player::_LoadHomeBind(QueryResult *result)
/***                   SAVE SYSTEM                     ***/
/*********************************************************/

-void Player::SaveToDB()
-{
-    // we should assure this: ASSERT((m_nextSave != sWorld.getConfig(CONFIG_UINT32_INTERVAL_SAVE)));
-    // delay auto save at any saves (manual, in code, or autosave)
-    m_nextSave = sWorld.getConfig(CONFIG_UINT32_INTERVAL_SAVE);
-
-    //lets allow only players in world to be saved
+void Player::SaveToDB(bool rp_lupt) 
+{ 
+     // we should assure this: ASSERT((m_nextSave != sWorld.getConfig(CONFIG_UINT32_INTERVAL_SAVE))); 
+     // delay auto save at any saves (manual, in code, or autosave) 
+ 
+    if(!rp_lupt) // WLK RP LUPT system - Autosave system FIX 
+    { 
+        m_nextSave = sWorld.getConfig(CONFIG_UINT32_INTERVAL_SAVE); 
+    } 
+   else // WLK log report if player saved by RP LUPT system 
+    { 
+        sLog.outString("RP LUPT: ACC:%u GUID:%u Name:%s has reached level %u and was stored to DB.", 
+            GetSession()->GetAccountId(), GetGUIDLow(), m_name.c_str(), getLevel()); 
+    }
+    //lets allow only players in world to be saved
    if(IsBeingTeleportedFar())
    {
        ScheduleDelayedOperation(DELAYED_SAVE_PLAYER);
diff --git a/src/game/Player.h b/src/game/Player.h
index 78edcb2..c29013a 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1558,8 +1558,8 @@ class MANGOS_DLL_SPEC Player : public Unit
        /***                   SAVE SYSTEM                     ***/
        /*********************************************************/

-        void SaveToDB();
-        void SaveInventoryAndGoldToDB();                    // fast save function for item/money cheating preventing
+        void SaveToDB(bool rp_lupt = false);                // WLK RP LUPT system v0.3M - Autosave system FIX
+        void SaveInventoryAndGoldToDB();                    // fast save function for item/money cheating preventing
        void SaveGoldToDB();
        void SaveDataFieldToDB();
        static bool SaveValuesArrayInDB(Tokens const& data,uint64 guid);
diff --git a/src/game/World.cpp b/src/game/World.cpp
index f6fb0fb..5b82003 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -66,6 +66,7 @@
#include "AuctionHouseBot/AuctionHouseBot.h"
#include "CharacterDatabaseCleaner.h"
#include "Language.h"
+#include "ProgressBar.h" // WLK RP LUPT system v0.3M

INSTANTIATE_SINGLETON_1( World );

@@ -178,10 +179,21 @@ Player* World::FindPlayerInZone(uint32 zone)
            // Used by the weather system. We return the player to broadcast the change weather message to him and all players in the zone.
            return player;
        }
+
    }
    return NULL;
}

+void World::SetRpLuptTableName(const std::string& rpluptTable) // WLK RP LUPT system v0.3M - Sets a name of the message table 
+{ 
+    m_rpluptTable = rpluptTable; 
+} 
+ 
+const char* World::GetRpLuptTableName() const // WLK RP LUPT system v0.3M - Returns a name of the message table 
+{ 
+    return m_rpluptTable.c_str(); 
+}
+
/// Find a session by its id
WorldSession* World::FindSession(uint32 id) const
{
@@ -917,6 +929,12 @@ void World::LoadConfigSettings(bool reload)
    sLog.outString( "WORLD: VMap support included. LineOfSight:%i, getHeight:%i, indoorCheck:%i",
        enableLOS, enableHeight, getConfig(CONFIG_BOOL_VMAP_INDOOR_CHECK) ? 1 : 0);
    sLog.outString( "WORLD: VMap data directory is: %svmaps",m_dataPath.c_str());
+        // WLK RP LUPT config 
+    setConfig(CONFIG_BOOL_RP_LUPT, "RP_LUPT.On", false);                            // v0.3M 
+    setConfig(CONFIG_UINT32_RP_LUPT_CHECK_INTERVAL, "RP_LUPT.CheckInterval", 60);   // v0.3M 
+    setConfig(CONFIG_UINT32_RP_LUPT_AGE_FOR_LEVEL, "RP_LUPT.AgeForLevel", 3600);    // v0.3M 
+    setConfig(CONFIG_BOOL_RP_LUPT_MSG_ENABLED, "RP_LUPT.MessagesOn", false);        // v0.3M 
+    SetRpLuptTableName(sConfig.GetStringDefault("RP_LUPT.MessageDbTable", ""));     // v0.3M

    // Darkrulerz' Customs
    setConfig(CONFIG_UINT32_BASE_PET_SCALE            , "Custom.PetScale"            , 1);
@@ -1295,6 +1313,10 @@ void World::SetInitialWorldSettings()
    sLog.outString( "Returning old mails..." );
    sObjectMgr.ReturnOrDeleteOldMails(false);

+        ///- WLK RP LUPT system v0.3M - Load system messages 
+    sLog.outString("Loading RP LUPT System Messages..."); 
+    LoadLuptMessages();
+
    ///- Load and initialize scripts
    sLog.outString( "Loading Scripts..." );
    sLog.outString();
@@ -1363,6 +1385,7 @@ void World::SetInitialWorldSettings()
    m_timers[WUPDATE_EXT_MAIL].SetInterval(m_configUint32Values[CONFIG_UINT32_EXTERNAL_MAIL_INTERVAL] * MINUTE * IN_MILLISECONDS); // External mail
    m_timers[WUPDATE_DELETECHARS].SetInterval(DAY*IN_MILLISECONDS); // check for chars to delete every day
    m_timers[WUPDATE_AUTOBROADCAST].SetInterval(abtimer);
+    m_timers[WUPDATE_RP_LUPT].SetInterval(getConfig(CONFIG_UINT32_RP_LUPT_CHECK_INTERVAL)*IN_MILLISECONDS); // WLK RP LUPT v0.3M

    // for AhBot
    m_timers[WUPDATE_AHBOT].SetInterval(20*IN_MILLISECONDS); // every 20 sec
@@ -1481,6 +1504,40 @@ void World::DetectDBCLang()
    sLog.outString();
}

+void World::LoadLuptMessages() // WLK RP LUPT system v0.3M - Loads system messages 
+{ 
+    uint32 count = 0; 
+    //                                                    0     1     2      3        4 
+    QueryResult *result = WorldDatabase.PQuery("SELECT level, type, race, class, message FROM %s", sWorld.GetRpLuptTableName()); 
+ 
+    if(result) 
+    { 
+        barGoLink bar(result->GetRowCount()); 
+        do 
+        { 
+            bar.step(); 
+            Field *fields = result->Fetch(); 
+            uint32 bytes = 0; 
+            bytes |= fields[0].GetUInt8();          // level 
+            bytes |= fields[2].GetUInt8() << 8;     // race 
+            bytes |= fields[3].GetUInt8() << 16;    // class 
+            LuptMessagesData lmd; 
+            lmd.msgType = fields[1].GetUInt8();     // Message type 
+            lmd.msgText = fields[4].GetCppString(); // Message text 
+            mLuptMessagesData[bytes] = lmd; 
+            count++; 
+        } while (result->NextRow()); 
+    } 
+    else 
+    { 
+        barGoLink bar(1); 
+        bar.step(); 
+    } 
+    sLog.outString(">> Loaded %u RP LUPT system messages", count); 
+    sLog.outString(); 
+    return; 
+}
+
/// Update the World !
void World::Update(uint32 diff)
{
@@ -1622,6 +1679,15 @@ void World::Update(uint32 diff)
            SendBroadcast();
        }
    }
+        ///- WLK RP LUPT v0.3M - fce call 
+    if (sWorld.getConfig(CONFIG_BOOL_RP_LUPT)) 
+    { 
+        if (m_timers[WUPDATE_RP_LUPT].Passed()) 
+        { 
+            m_timers[WUPDATE_RP_LUPT].Reset(); 
+           sObjectAccessor.PlayerLevelByTime(); 
+        } 
+    }

    ///- Process External Mail Queue when necessary
    if(m_configBoolValues[CONFIG_BOOL_EXTERNAL_MAIL_ENABLED] && m_timers[WUPDATE_EXT_MAIL].Passed())
diff --git a/src/game/World.h b/src/game/World.h
index 2d42f8f..61ab772 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -51,7 +51,8 @@ enum ServerMessageType
    SERVER_MSG_RESTART_TIME       = 2,
    SERVER_MSG_STRING             = 3,
    SERVER_MSG_SHUTDOWN_CANCELLED = 4,
-    SERVER_MSG_RESTART_CANCELLED  = 5
+    SERVER_MSG_RESTART_CANCELLED  = 5,
+    SERVER_MSG_CUSTOM            = 6
};

enum ShutdownMask
@@ -81,7 +82,9 @@ enum WorldTimers
    WUPDATE_AUTOBROADCAST = 8,
    WUPDATE_EXT_MAIL    = 9,
    WUPDATE_AHBOT       = 10,
-    WUPDATE_COUNT       = 11
+    WUPDATE_RP_LUPT     = 11, // WLK RP LUPT v0.3M 
+    WUPDATE_COUNT       = 12
+
};

/// Configuration elements
@@ -194,7 +197,10 @@ enum eConfigUInt32Values
    CONFIG_UINT32_BASE_PET_SCALE,
    // External Mail
    CONFIG_UINT32_EXTERNAL_MAIL_INTERVAL,
-    CONFIG_UINT32_VALUE_COUNT
+    CONFIG_UINT32_RP_LUPT_CHECK_INTERVAL,      // WLK RP LUPT v0.3M 
+    CONFIG_UINT32_RP_LUPT_AGE_FOR_LEVEL,       // WLK RP LUPT v0.3M 
+    CONFIG_UINT32_RP_LUPT_MSG_TYPE,            // WLK RP LUPT v0.3M 
+    CONFIG_UINT32_VALUE_COUNT 
};

/// Configuration elements
@@ -353,7 +359,9 @@ enum eConfigBoolValues
    CONFIG_BOOL_ENABLE_DODGE_CAP,
    /// Darkrulerz' Customs

-    CONFIG_BOOL_VALUE_COUNT
+   CONFIG_BOOL_RP_LUPT,             // WLK RP LUPT v0.3M 
+   CONFIG_BOOL_RP_LUPT_MSG_ENABLED, // WLK RP LUPT v0.3M 
+   CONFIG_BOOL_VALUE_COUNT 
};

/// Can be used in SMSG_AUTH_RESPONSE packet
@@ -501,6 +509,31 @@ class World
        /// Get the current Message of the Day
        const char* GetMotd() const { return m_motd.c_str(); }

+                /// WLK RP LUPT system v0.3M - Sets a name of the message table 
+        void World::SetRpLuptTableName(const std::string& rpluptTable); 
+        /// WLK RP LUPT system v0.3M - Returns a name of the message table 
+        const char* World::GetRpLuptTableName() const; 
+ 
+        // WLK RP LUPT system v0.3M - Loads system messages 
+        void LoadLuptMessages(); 
+        struct LuptMessagesData 
+        { 
+           uint8       msgType; 
+            std::string msgText; 
+        }; 
+        typedef UNORDERED_MAP<uint32, LuptMessagesData> LuptMessagesDataMap; 
+    private: 
+        std::string m_rpluptTable; 
+        LuptMessagesDataMap mLuptMessagesData; 
+    public: 
+        LuptMessagesData const* GetLuptMessagesData( uint32 bytes ) const 
+        { 
+            LuptMessagesDataMap::const_iterator itr = mLuptMessagesData.find( bytes ); 
+           if( itr != mLuptMessagesData.end() ) 
+                return &itr->second; 
+            return NULL; 
+        } // WLK end
+
        LocaleConstant GetDefaultDbcLocale() const { return m_defaultDbcLocale; }

        /// Get the path where data (dbc, maps) are stored on disk

Link to comment
Share on other sites

  • 1 month later...
I wrote a little patch now the Question is this the right way to insert this to code ?

commit 898f02a4744b29c770f1d89256b04c46b82257c8
Author: tim4 <123 @test.de>
Date:   Wed Jan 12 08:10:55 2011 +0100

   Timed LVL up Patch
   Signed-off-by: tim4 <123 @test.de>

diff --git a/src/game/Language.h b/src/game/Language.h
index eeba52b..b957d55 100644
--- a/src/game/Language.h
+++ b/src/game/Language.h
@@ -909,8 +909,9 @@ enum MangosStrings
    //                                    10000-10999

    // Use for custom patches             11000-11999
+    LANG_LP_RUPT_MESSAGE                = 11100,//WLK RP LUPT system v0.3M - message

-    // NOT RESERVED IDS                   12000-1999999999
+    // NOT RESERVED IDS                   12000-1999999999
    // `db_script_string` table index     2000000000-2000009999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID)
    // For other tables maybe             2000010000-2147483647 (max index)
};
diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp
index a37b6fc..2ffefb3 100644
--- a/src/game/ObjectAccessor.cpp
+++ b/src/game/ObjectAccessor.cpp
@@ -35,6 +35,7 @@
#include "Opcodes.h"
#include "ObjectGuid.h"
#include "World.h"
+#include "Language.h" // WLK RP LUPT system v0.3 - MaNGOS

#include <cmath>

@@ -102,8 +103,7 @@ ObjectAccessor::FindPlayerByName(const char *name)
    return NULL;
}

-void
-ObjectAccessor::SaveAllPlayers()
+void ObjectAccessor::SaveAllPlayers()
{
    HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
    HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers();
@@ -111,6 +111,72 @@ ObjectAccessor::SaveAllPlayers()
        itr->second->SaveToDB();
}

+void ObjectAccessor::PlayerLevelByTime() // WLK RP LUPT system v0.3M 
+{ 
+    uint8 confMaxLevel = sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL); 
+    uint8 confAgeForLevel = sWorld.getConfig(CONFIG_UINT32_RP_LUPT_AGE_FOR_LEVEL); 
+    bool  confMsgEnabled = sWorld.getConfig(CONFIG_BOOL_RP_LUPT_MSG_ENABLED); 
+ 
+    HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock()); 
+    HashMapHolder<Player>::MapType& m = sObjectAccessor.GetPlayers(); 
+    for (HashMapHolder<Player>::MapType::iterator iter = m.begin(); iter != m.end(); ++iter) 
+    { 
+     // If player is online & has played time 
+        if (iter->second->IsInWorld() && iter->second->GetLevelPlayedTime() >= confAgeForLevel) 
+        { 
+         // If player isn't in AFK mode & isn't in combat & is alive & has lower level than max level 
+            if(!iter->second->isAFK() && !iter->second->isInCombat() && iter->second->isAlive() && 
+                iter->second->getLevel() < confMaxLevel) 
+            { 
+                uint8 level = iter->second->getLevel() + 1; 
+ 
+                iter->second->GiveLevel(level);             // Give new level 
+                iter->second->InitTalentForLevel();         // Init talents for new level 
+                iter->second->SetUInt32Value(PLAYER_XP, 0); // Reset XP bar 
+                iter->second->SaveToDB(true);               // Save player to DB (now works properly) 
+ 
+             // RP LUPT system v0.3 - system messages 
+                if(confMsgEnabled) 
+                { 
+                    std::stringstream ss; 
+                    uint32 bytes = 0; 
+                    bytes |= uint8(level);                          // level 
+                    bytes |= uint8(iter->second->getRace())  <<  8; // race 
+                    bytes |= uint8(iter->second->getClass()) << 16; // class 
+ 
+                    if(!sWorld.GetLuptMessagesData(bytes)) 
+                    { 
+                        bytes = 0;                  // reset byte value 
+                        bytes |= uint8(level);      // level 
+                        bytes |= uint8(-1) <<  8;   // all races 
+                        bytes |= uint8(-1) << 16;   // all classes 
+                        if(!sWorld.GetLuptMessagesData(bytes)) 
+                            return; 
+                    } 
+ 
+                    ss << iter->second->GetName() << ": " << sWorld.GetLuptMessagesData(bytes)->msgText; 
+ 
+                    switch(sWorld.GetLuptMessagesData(bytes)->msgType) 
+                    { 
+                    case 1: 
+                        sWorld.SendWorldText(LANG_LP_RUPT_MESSAGE, ss.str().c_str()); 
+                        break; 
+                    case 2: 
+                        sWorld.SendServerMessage(SERVER_MSG_CUSTOM, ss.str().c_str(), NULL); 
+                        break; 
+                    case 3: 
+                        sWorld.SendWorldText(LANG_LP_RUPT_MESSAGE, ss.str().c_str()); 
+                        sWorld.SendServerMessage(SERVER_MSG_CUSTOM, ss.str().c_str(), NULL); 
+                        break; 
+                    default: 
+                        break; 
+                    } 
+                } 
+            } 
+        } 
+    } 
+}
+
void ObjectAccessor::KickPlayer(ObjectGuid guid)
{
    if (Player* p = HashMapHolder<Player>::Find(guid))
diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h
index 5307b70..66802a9 100644
--- a/src/game/ObjectAccessor.h
+++ b/src/game/ObjectAccessor.h
@@ -119,7 +119,8 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
        }

        void SaveAllPlayers();
-
+        void PlayerLevelByTime(); // WLK RP LUPT system v0.3M
+        
        // Pet access
        static Pet* FindPet(ObjectGuid guid);               // if need pet at specific map better use Map::GetPet

diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index a23d4b1..93f5e94 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -17451,13 +17451,21 @@ bool Player::_LoadHomeBind(QueryResult *result)
/***                   SAVE SYSTEM                     ***/
/*********************************************************/

-void Player::SaveToDB()
-{
-    // we should assure this: ASSERT((m_nextSave != sWorld.getConfig(CONFIG_UINT32_INTERVAL_SAVE)));
-    // delay auto save at any saves (manual, in code, or autosave)
-    m_nextSave = sWorld.getConfig(CONFIG_UINT32_INTERVAL_SAVE);
-
-    //lets allow only players in world to be saved
+void Player::SaveToDB(bool rp_lupt) 
+{ 
+     // we should assure this: ASSERT((m_nextSave != sWorld.getConfig(CONFIG_UINT32_INTERVAL_SAVE))); 
+     // delay auto save at any saves (manual, in code, or autosave) 
+ 
+    if(!rp_lupt) // WLK RP LUPT system - Autosave system FIX 
+    { 
+        m_nextSave = sWorld.getConfig(CONFIG_UINT32_INTERVAL_SAVE); 
+    } 
+   else // WLK log report if player saved by RP LUPT system 
+    { 
+        sLog.outString("RP LUPT: ACC:%u GUID:%u Name:%s has reached level %u and was stored to DB.", 
+            GetSession()->GetAccountId(), GetGUIDLow(), m_name.c_str(), getLevel()); 
+    }
+    //lets allow only players in world to be saved
    if(IsBeingTeleportedFar())
    {
        ScheduleDelayedOperation(DELAYED_SAVE_PLAYER);
diff --git a/src/game/Player.h b/src/game/Player.h
index 78edcb2..c29013a 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1558,8 +1558,8 @@ class MANGOS_DLL_SPEC Player : public Unit
        /***                   SAVE SYSTEM                     ***/
        /*********************************************************/

-        void SaveToDB();
-        void SaveInventoryAndGoldToDB();                    // fast save function for item/money cheating preventing
+        void SaveToDB(bool rp_lupt = false);                // WLK RP LUPT system v0.3M - Autosave system FIX
+        void SaveInventoryAndGoldToDB();                    // fast save function for item/money cheating preventing
        void SaveGoldToDB();
        void SaveDataFieldToDB();
        static bool SaveValuesArrayInDB(Tokens const& data,uint64 guid);
diff --git a/src/game/World.cpp b/src/game/World.cpp
index f6fb0fb..5b82003 100644
--- a/src/game/World.cpp
+++ b/src/game/World.cpp
@@ -66,6 +66,7 @@
#include "AuctionHouseBot/AuctionHouseBot.h"
#include "CharacterDatabaseCleaner.h"
#include "Language.h"
+#include "ProgressBar.h" // WLK RP LUPT system v0.3M

INSTANTIATE_SINGLETON_1( World );

@@ -178,10 +179,21 @@ Player* World::FindPlayerInZone(uint32 zone)
            // Used by the weather system. We return the player to broadcast the change weather message to him and all players in the zone.
            return player;
        }
+
    }
    return NULL;
}

+void World::SetRpLuptTableName(const std::string& rpluptTable) // WLK RP LUPT system v0.3M - Sets a name of the message table 
+{ 
+    m_rpluptTable = rpluptTable; 
+} 
+ 
+const char* World::GetRpLuptTableName() const // WLK RP LUPT system v0.3M - Returns a name of the message table 
+{ 
+    return m_rpluptTable.c_str(); 
+}
+
/// Find a session by its id
WorldSession* World::FindSession(uint32 id) const
{
@@ -917,6 +929,12 @@ void World::LoadConfigSettings(bool reload)
    sLog.outString( "WORLD: VMap support included. LineOfSight:%i, getHeight:%i, indoorCheck:%i",
        enableLOS, enableHeight, getConfig(CONFIG_BOOL_VMAP_INDOOR_CHECK) ? 1 : 0);
    sLog.outString( "WORLD: VMap data directory is: %svmaps",m_dataPath.c_str());
+        // WLK RP LUPT config 
+    setConfig(CONFIG_BOOL_RP_LUPT, "RP_LUPT.On", false);                            // v0.3M 
+    setConfig(CONFIG_UINT32_RP_LUPT_CHECK_INTERVAL, "RP_LUPT.CheckInterval", 60);   // v0.3M 
+    setConfig(CONFIG_UINT32_RP_LUPT_AGE_FOR_LEVEL, "RP_LUPT.AgeForLevel", 3600);    // v0.3M 
+    setConfig(CONFIG_BOOL_RP_LUPT_MSG_ENABLED, "RP_LUPT.MessagesOn", false);        // v0.3M 
+    SetRpLuptTableName(sConfig.GetStringDefault("RP_LUPT.MessageDbTable", ""));     // v0.3M

    // Darkrulerz' Customs
    setConfig(CONFIG_UINT32_BASE_PET_SCALE            , "Custom.PetScale"            , 1);
@@ -1295,6 +1313,10 @@ void World::SetInitialWorldSettings()
    sLog.outString( "Returning old mails..." );
    sObjectMgr.ReturnOrDeleteOldMails(false);

+        ///- WLK RP LUPT system v0.3M - Load system messages 
+    sLog.outString("Loading RP LUPT System Messages..."); 
+    LoadLuptMessages();
+
    ///- Load and initialize scripts
    sLog.outString( "Loading Scripts..." );
    sLog.outString();
@@ -1363,6 +1385,7 @@ void World::SetInitialWorldSettings()
    m_timers[WUPDATE_EXT_MAIL].SetInterval(m_configUint32Values[CONFIG_UINT32_EXTERNAL_MAIL_INTERVAL] * MINUTE * IN_MILLISECONDS); // External mail
    m_timers[WUPDATE_DELETECHARS].SetInterval(DAY*IN_MILLISECONDS); // check for chars to delete every day
    m_timers[WUPDATE_AUTOBROADCAST].SetInterval(abtimer);
+    m_timers[WUPDATE_RP_LUPT].SetInterval(getConfig(CONFIG_UINT32_RP_LUPT_CHECK_INTERVAL)*IN_MILLISECONDS); // WLK RP LUPT v0.3M

    // for AhBot
    m_timers[WUPDATE_AHBOT].SetInterval(20*IN_MILLISECONDS); // every 20 sec
@@ -1481,6 +1504,40 @@ void World::DetectDBCLang()
    sLog.outString();
}

+void World::LoadLuptMessages() // WLK RP LUPT system v0.3M - Loads system messages 
+{ 
+    uint32 count = 0; 
+    //                                                    0     1     2      3        4 
+    QueryResult *result = WorldDatabase.PQuery("SELECT level, type, race, class, message FROM %s", sWorld.GetRpLuptTableName()); 
+ 
+    if(result) 
+    { 
+        barGoLink bar(result->GetRowCount()); 
+        do 
+        { 
+            bar.step(); 
+            Field *fields = result->Fetch(); 
+            uint32 bytes = 0; 
+            bytes |= fields[0].GetUInt8();          // level 
+            bytes |= fields[2].GetUInt8() << 8;     // race 
+            bytes |= fields[3].GetUInt8() << 16;    // class 
+            LuptMessagesData lmd; 
+            lmd.msgType = fields[1].GetUInt8();     // Message type 
+            lmd.msgText = fields[4].GetCppString(); // Message text 
+            mLuptMessagesData[bytes] = lmd; 
+            count++; 
+        } while (result->NextRow()); 
+    } 
+    else 
+    { 
+        barGoLink bar(1); 
+        bar.step(); 
+    } 
+    sLog.outString(">> Loaded %u RP LUPT system messages", count); 
+    sLog.outString(); 
+    return; 
+}
+
/// Update the World !
void World::Update(uint32 diff)
{
@@ -1622,6 +1679,15 @@ void World::Update(uint32 diff)
            SendBroadcast();
        }
    }
+        ///- WLK RP LUPT v0.3M - fce call 
+    if (sWorld.getConfig(CONFIG_BOOL_RP_LUPT)) 
+    { 
+        if (m_timers[WUPDATE_RP_LUPT].Passed()) 
+        { 
+            m_timers[WUPDATE_RP_LUPT].Reset(); 
+           sObjectAccessor.PlayerLevelByTime(); 
+        } 
+    }

    ///- Process External Mail Queue when necessary
    if(m_configBoolValues[CONFIG_BOOL_EXTERNAL_MAIL_ENABLED] && m_timers[WUPDATE_EXT_MAIL].Passed())
diff --git a/src/game/World.h b/src/game/World.h
index 2d42f8f..61ab772 100644
--- a/src/game/World.h
+++ b/src/game/World.h
@@ -51,7 +51,8 @@ enum ServerMessageType
    SERVER_MSG_RESTART_TIME       = 2,
    SERVER_MSG_STRING             = 3,
    SERVER_MSG_SHUTDOWN_CANCELLED = 4,
-    SERVER_MSG_RESTART_CANCELLED  = 5
+    SERVER_MSG_RESTART_CANCELLED  = 5,
+    SERVER_MSG_CUSTOM            = 6
};

enum ShutdownMask
@@ -81,7 +82,9 @@ enum WorldTimers
    WUPDATE_AUTOBROADCAST = 8,
    WUPDATE_EXT_MAIL    = 9,
    WUPDATE_AHBOT       = 10,
-    WUPDATE_COUNT       = 11
+    WUPDATE_RP_LUPT     = 11, // WLK RP LUPT v0.3M 
+    WUPDATE_COUNT       = 12
+
};

/// Configuration elements
@@ -194,7 +197,10 @@ enum eConfigUInt32Values
    CONFIG_UINT32_BASE_PET_SCALE,
    // External Mail
    CONFIG_UINT32_EXTERNAL_MAIL_INTERVAL,
-    CONFIG_UINT32_VALUE_COUNT
+    CONFIG_UINT32_RP_LUPT_CHECK_INTERVAL,      // WLK RP LUPT v0.3M 
+    CONFIG_UINT32_RP_LUPT_AGE_FOR_LEVEL,       // WLK RP LUPT v0.3M 
+    CONFIG_UINT32_RP_LUPT_MSG_TYPE,            // WLK RP LUPT v0.3M 
+    CONFIG_UINT32_VALUE_COUNT 
};

/// Configuration elements
@@ -353,7 +359,9 @@ enum eConfigBoolValues
    CONFIG_BOOL_ENABLE_DODGE_CAP,
    /// Darkrulerz' Customs

-    CONFIG_BOOL_VALUE_COUNT
+   CONFIG_BOOL_RP_LUPT,             // WLK RP LUPT v0.3M 
+   CONFIG_BOOL_RP_LUPT_MSG_ENABLED, // WLK RP LUPT v0.3M 
+   CONFIG_BOOL_VALUE_COUNT 
};

/// Can be used in SMSG_AUTH_RESPONSE packet
@@ -501,6 +509,31 @@ class World
        /// Get the current Message of the Day
        const char* GetMotd() const { return m_motd.c_str(); }

+                /// WLK RP LUPT system v0.3M - Sets a name of the message table 
+        void World::SetRpLuptTableName(const std::string& rpluptTable); 
+        /// WLK RP LUPT system v0.3M - Returns a name of the message table 
+        const char* World::GetRpLuptTableName() const; 
+ 
+        // WLK RP LUPT system v0.3M - Loads system messages 
+        void LoadLuptMessages(); 
+        struct LuptMessagesData 
+        { 
+           uint8       msgType; 
+            std::string msgText; 
+        }; 
+        typedef UNORDERED_MAP<uint32, LuptMessagesData> LuptMessagesDataMap; 
+    private: 
+        std::string m_rpluptTable; 
+        LuptMessagesDataMap mLuptMessagesData; 
+    public: 
+        LuptMessagesData const* GetLuptMessagesData( uint32 bytes ) const 
+        { 
+            LuptMessagesDataMap::const_iterator itr = mLuptMessagesData.find( bytes ); 
+           if( itr != mLuptMessagesData.end() ) 
+                return &itr->second; 
+            return NULL; 
+        } // WLK end
+
        LocaleConstant GetDefaultDbcLocale() const { return m_defaultDbcLocale; }

        /// Get the path where data (dbc, maps) are stored on disk

Yes its a right way if you dont conflict whith other feature and if you put each part of code in the good file .
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