http://eswow2.start-zone.net/./viewtopic.php?f=8&t=95&p=437#p437
-----------------------------------
Phantoons
Jue 01 Sep, 2011 01:24

Cuenta VIP
-----------------------------------
Hola buenas pues q estoy intentando hacer unos rates de money para usuarios vip o premium como qerais llamarles, el caso esq lo e exo, pero nose siempre q mato a un humanoide ( o cualquier npc q entrege money en su loot) me lleva a crash mirar os dejo todo lo q he exo:

[code linenumbers=false]
 diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index d3c23c6..4d9b23b 100755
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -86,9 +86,9 @@ bool WorldSessionFilter::Process(WorldPacket* packet)
 }
 
 /// WorldSession constructor
-WorldSession::WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter):
+WorldSession::WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, bool ispremium, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter):
 m_muteTime(mute_time), m_timeOutTime(0), _player(NULL), m_Socket(socket
-_security(sec), _accountId(id), m_expansion(expansion), _logoutTime(0),
+_security(sec), _ispremium(ispremium), _accountId(id), m_expansion(expansion), _logoutTime(0),
 m_inQueue(false), m_playerLoading(false), m_playerLogout(false),
 m_playerRecentlyLogout(false), m_playerSave(false),
 m_sessionDbcLocale(sWorld->GetAvailableDbcLocale(locale)),
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index f45ee79..5bf186f 100755
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -214,7 +214,7 @@ class CharacterCreateInfo
 class WorldSession
 {
     public:
-        WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter);
+        WorldSession(uint32 id, WorldSocket *sock, AccountTypes sec, bool ispremium, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter);
         ~WorldSession();
 
         bool PlayerLoading() const { return m_playerLoading; }
@@ -242,6 +242,7 @@ class WorldSession
         void SendClientCacheVersion(uint32 version);
 
         AccountTypes GetSecurity() const { return _security; }
+        bool IsPremium() const { return _ispremium; }
         uint32 GetAccountId() const { return _accountId; }
         Player* GetPlayer() const { return _player; }
         char const* GetPlayerName() const;
@@ -935,6 +936,7 @@ class WorldSession
         AccountTypes _security;
         uint32 _accountId;
         uint8 m_expansion;
+        bool _ispremium;
 
         time_t _logoutTime;
         bool m_inQueue;                                     // session wait in auth.queue
diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp
index b2c8164..c01d5e4 100755
--- a/src/server/game/Server/WorldSocket.cpp
+++ b/src/server/game/Server/WorldSocket.cpp
@@ -777,6 +777,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
     //uint8 expansion = 0;
     LocaleConstant locale;
     std::string account;
+ bool isPremium = false;
     SHA1Hash sha1;
     BigNumber v, s, g, N;
     WorldPacket packet, SendAddonPacked;
@@ -932,6 +933,16 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
         return -1;
     }
 
+    QueryResult premresult =
+        LoginDatabase.PQuery ("SELECT 1 "
+                                "FROM account_premium "
+                                "WHERE id = '%u' "
+                                "AND active = 1",
+                                id);
+    if (premresult) // if account premium
+    {
+        isPremium = true;
+    }
     // Check locked state for server
     AccountTypes allowedAccountType = sWorld->GetPlayerSecurityLimit();
     sLog->outDebug(LOG_FILTER_NETWORKIO, "Allowed Level: %u Player Level %u", allowedAccountType, AccountTypes(security));
@@ -987,7 +998,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
                             safe_account.c_str());
 
     // NOTE ATM the socket is single-threaded, have this in mind ...
-    ACE_NEW_RETURN (m_Session, WorldSession (id, this, AccountTypes(security), expansion, mutetime, locale, recruiter), -1);
+    ACE_NEW_RETURN (m_Session, WorldSession (id, this, AccountTypes(security), isPremium, expansion, mutetime, locale, recruiter), -1);
 
     m_Crypt.Init(&K);
 diff --git a/src/server/shared/Database/Implementation/LoginDatabase.cpp b/src/server/shared/Database/Implementation/LoginDatabase.cpp
index 13cfe09..8b84033 100755
--- a/src/server/shared/Database/Implementation/LoginDatabase.cpp
+++ b/src/server/shared/Database/Implementation/LoginDatabase.cpp
@@ -45,4 +45,5 @@ void LoginDatabaseConnection::DoPrepareStatements()
     PREPARE_STATEMENT(LOGIN_DEL_REALMCHARACTERS, "DELETE FROM realmcharacters WHERE acctid = ? AND realmid = ?", CONNECTION_ASYNC)
     PREPARE_STATEMENT(LOGIN_ADD_REALMCHARACTERS, "INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (?, ?, ?)", CONNECTION_ASYNC)
     PREPARE_STATEMENT(LOGIN_GET_SUM_REALMCHARS, "SELECT SUM(numchars) FROM realmcharacters WHERE acctid = ?", CONNECTION_ASYNC);
+ PREPARE_STATEMENT(LOGIN_SET_ACCOUNT_PREMIUM, "UPDATE account_premium SET active = 0 WHERE unsetdate<=UNIX_TIMESTAMP() AND unsetdate<>setdate", CONNECTION_ASYNC)
 }
diff --git a/src/server/shared/Database/Implementation/LoginDatabase.h b/src/server/shared/Database/Implementation/LoginDatabase.h
index b5f927f..932cc48 100755
--- a/src/server/shared/Database/Implementation/LoginDatabase.h
+++ b/src/server/shared/Database/Implementation/LoginDatabase.h
@@ -65,6 +65,7 @@ enum LoginDatabaseStatements
     LOGIN_DEL_REALMCHARACTERS,
     LOGIN_ADD_REALMCHARACTERS,
     LOGIN_GET_SUM_REALMCHARS,
+ LOGIN_SET_ACCOUNT_PREMIUM,
 
     MAX_LOGINDATABASE_STATEMENTS,
 };
diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp
index a5c41b3..8e7d012 100755
--- a/src/server/game/Loot/LootMgr.cpp
+++ b/src/server/game/Loot/LootMgr.cpp
@@ -20,6 +20,7 @@
 #include "Log.h"
 #include "ObjectMgr.h"
 #include "World.h"
+#include "WorldSession.h"
 #include "Util.h"
 #include "SharedDefines.h"
 #include "SpellMgr.h"
@@ -649,7 +650,7 @@ void Loot::NotifyQuestItemRemoved(uint8 questIndex)
 
 void Loot::generateMoneyLoot(uint32 minAmount, uint32 maxAmount)
 {
-    if (maxAmount > 0)
+     if (maxAmount > 0)
     {
         if (maxAmount <= minAmount)
             gold = uint32(maxAmount * sWorld->getRate(RATE_DROP_MONEY));
@@ -658,6 +659,9 @@ void Loot::generateMoneyLoot(uint32 minAmount, uint32 maxAmount)
         else
             gold = uint32(urand(minAmount >> 8, maxAmount >> 8) * sWorld->getRate(RATE_DROP_MONEY)) << 8;
     }
+ if(GetSession()->IsPremium())
+ gold *= sWorld->getRate(RATE_DROP_MONEY_PREMIUM);
+
 }
 
 LootItem* Loot::LootItemInSlot(uint32 lootSlot, Player* player, QuestItem **qitem, QuestItem **ffaitem, QuestItem **conditem)
diff --git a/src/server/game/Loot/LootMgr.h b/src/server/game/Loot/LootMgr.h
index 28bcf39..00df7e4 100755
--- a/src/server/game/Loot/LootMgr.h
+++ b/src/server/game/Loot/LootMgr.h
@@ -24,6 +24,7 @@
 #include "RefManager.h"
 #include "SharedDefines.h"
 #include "ConditionMgr.h"
+#include "WorldSession.h"
 
 #include <map>
 #include <vector>
@@ -166,6 +167,7 @@ struct QuestItem
 
 struct Loot;
 class LootTemplate;
+class WorldSession;
 
 typedef std::vector<QuestItem> QuestItemList;
 typedef std::vector<LootItem> LootItemList;
@@ -209,6 +211,7 @@ class LootStore
         char const* m_name;
         char const* m_entryName;
         bool m_ratesAllowed;
+
 };
 
 class LootTemplate
@@ -233,7 +236,6 @@ class LootTemplate
         void CheckLootRefs(LootTemplateMap const& store, LootIdSet* ref_set) const;
         bool addConditionItem(Condition* cond);
         bool isReference(uint32 id);
-
     private:
         LootStoreItemList Entries;                          // not grouped only
         LootGroups        Groups;                           // groups have own (optimised) processing, grouped entries go there
@@ -274,6 +276,7 @@ ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv);
 struct Loot
 {
     friend ByteBuffer& operator<<(ByteBuffer& b, LootView const& lv);
+ friend class WorldSession;
 
     QuestItemMap const& GetPlayerQuestItems() const { return PlayerQuestItems; }
     QuestItemMap const& GetPlayerFFAItems() const { return PlayerFFAItems; }
@@ -284,7 +287,6 @@ struct Loot
     uint8 unlootedCount;
     uint64 roundRobinPlayer;                                // GUID of the player having the Round-Robin ownership for the loot. If 0, round robin owner has released.
     LootType loot_type;                                     // required for achievement system
-
     Loot(uint32 _gold = 0) : gold(_gold), unlootedCount(0), loot_type(LOOT_CORPSE) {}
     ~Loot() { clear(); }
 
@@ -337,7 +339,8 @@ struct Loot\par
     uint32 GetMaxSlotInLootFor(Player* player) const;\par
     bool hasItemFor(Player* player) const;\par
     bool hasOverThresholdItem() const;\par
-
+ WorldSession* GetSession() const { return m_session; }
+ WorldSession *m_session;
     private:
         void FillNotNormalLootFor(Player* player, bool presentAtLooting);
         QuestItemList* FillFFALoot(Player* player);
@@ -352,6 +355,7 @@ struct Loot
 
         // All rolls are registered here. They need to know, when the loot is not valid anymore
         LootValidatorRefManager i_LootValidatorRefManager;
+
 };
 
 struct LootView
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 51da821..3e39cf0 100755
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -457,7 +457,8 @@ void World::LoadConfigSettings(bool reload)
     rate_values[RATE_DROP_ITEM_ARTIFACT]   = sConfig->GetFloatDefault("Rate.Drop.Item.Artifact", 1.0f);
     rate_values[RATE_DROP_ITEM_REFERENCED] = sConfig->GetFloatDefault("Rate.Drop.Item.Referenced", 1.0f);
     rate_values[RATE_DROP_ITEM_REFERENCED_AMOUNT]
=sConfig->GetFloatDefault("Rate.Drop.Item.ReferencedAmount", 1.0f);
-    rate_values[RATE_DROP_MONEY]  = sConfig->GetFloatDefault("Rate.Drop.Money", 1.0f);
+    rate_values[RATE_DROP_MONEY]         = sConfig->GetFloatDefault("Rate.Drop.Money", 1.0f);
+    rate_values[RATE_DROP_MONEY_PREMIUM] = sConfig->GetFloatDefault("Rate.Drop.Money.Premium", 1.0f);
     rate_values[RATE_XP_KILL]            = sConfig->GetFloatDefault("Rate.XP.Kill", 1.0f);
     rate_values[RATE_XP_KILL_PREMIUM]    = sConfig->GetFloatDefault("Rate.XP.Kill.Premium", 1.0f);
     rate_values[RATE_XP_QUEST]           = sConfig->GetFloatDefault("Rate.XP.Quest", 1.0f);
diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h
index 5f2b716..c611271 100755
--- a/src/server/game/World/World.h
+++ b/src/server/game/World/World.h
@@ -355,6 +355,7 @@ enum Rates
     RATE_DROP_ITEM_REFERENCED,
     RATE_DROP_ITEM_REFERENCED_AMOUNT,
     RATE_DROP_MONEY,
+  RATE_DROP_MONEY_PREMIUM,
     RATE_XP_KILL,
     RATE_XP_KILL_PREMIUM,
     RATE_XP_QUEST,
diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
index a2a4e24..dfc1ca2 100644
--- a/src/server/worldserver/worldserver.conf.dist
+++ b/src/server/worldserver/worldserver.conf.dist
@@ -2009,6 +2009,7 @@ Rate.Skill.Discovery = 1
 #    Rate.Drop.Item.Artifact
 #    Rate.Drop.Item.Referenced
 #    Rate.Drop.Money
+#    Rate.Drop.Money.Premium
 #        Description: Drop rates for money and items based on quality.
 #        Default:     1 - (Rate.Drop.Item.Poor)
 #                     1 - (Rate.Drop.Item.Normal)
@@ -2029,6 +2030,7 @@ Rate.Drop.Item.Legendary        = 1
 Rate.Drop.Item.Artifact         = 1
 Rate.Drop.Item.Referenced       = 1
 Rate.Drop.Money                 = 1
+Rate.Drop.Money.Premium         = 5
 
 #
 #    Rate.Drop.Item.ReferencedAmount
--
}[/code]

Espero q me podais ayudar, si me equivoco de lugar o de foro decirmelo plis

Saludos^^


