mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 21:26:23 +00:00
converted all tabs to 4 spaces
This commit is contained in:
@@ -20,43 +20,43 @@ bool AuctionListOwnerItemsDelayEvent::Execute(uint64 e_time, uint32 p_time)
|
||||
|
||||
bool AuctionListItemsDelayEvent::Execute()
|
||||
{
|
||||
Player* plr = ObjectAccessor::FindPlayer(_playerguid);
|
||||
if (!plr || !plr->IsInWorld() || plr->IsDuringRemoveFromWorld() || plr->IsBeingTeleported())
|
||||
return true;
|
||||
Player* plr = ObjectAccessor::FindPlayer(_playerguid);
|
||||
if (!plr || !plr->IsInWorld() || plr->IsDuringRemoveFromWorld() || plr->IsBeingTeleported())
|
||||
return true;
|
||||
|
||||
Creature* creature = plr->GetNPCIfCanInteractWith(_creatureguid, UNIT_NPC_FLAG_AUCTIONEER);
|
||||
if (!creature)
|
||||
return true;
|
||||
Creature* creature = plr->GetNPCIfCanInteractWith(_creatureguid, UNIT_NPC_FLAG_AUCTIONEER);
|
||||
if (!creature)
|
||||
return true;
|
||||
|
||||
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
|
||||
AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());
|
||||
|
||||
//sLog->outDebug("Auctionhouse search (GUID: %u TypeId: %u)",, list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u",
|
||||
// GUID_LOPART(guid), GuidHigh2TypeId(GUID_HIPART(guid)), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
|
||||
//sLog->outDebug("Auctionhouse search (GUID: %u TypeId: %u)",, list from: %u, searchedname: %s, levelmin: %u, levelmax: %u, auctionSlotID: %u, auctionMainCategory: %u, auctionSubCategory: %u, quality: %u, usable: %u",
|
||||
// GUID_LOPART(guid), GuidHigh2TypeId(GUID_HIPART(guid)), listfrom, searchedname.c_str(), levelmin, levelmax, auctionSlotID, auctionMainCategory, auctionSubCategory, quality, usable);
|
||||
|
||||
WorldPacket data(SMSG_AUCTION_LIST_RESULT, (4+4+4)+50*((16+MAX_INSPECTED_ENCHANTMENT_SLOT*3)*4));
|
||||
uint32 count = 0;
|
||||
uint32 totalcount = 0;
|
||||
data << (uint32) 0;
|
||||
WorldPacket data(SMSG_AUCTION_LIST_RESULT, (4+4+4)+50*((16+MAX_INSPECTED_ENCHANTMENT_SLOT*3)*4));
|
||||
uint32 count = 0;
|
||||
uint32 totalcount = 0;
|
||||
data << (uint32) 0;
|
||||
|
||||
// converting string that we try to find to lower case
|
||||
std::wstring wsearchedname;
|
||||
if (!Utf8toWStr(_searchedname, wsearchedname))
|
||||
return true;
|
||||
// converting string that we try to find to lower case
|
||||
std::wstring wsearchedname;
|
||||
if (!Utf8toWStr(_searchedname, wsearchedname))
|
||||
return true;
|
||||
|
||||
wstrToLower(wsearchedname);
|
||||
wstrToLower(wsearchedname);
|
||||
|
||||
bool result = auctionHouse->BuildListAuctionItems(data, plr,
|
||||
wsearchedname, _listfrom, _levelmin, _levelmax, _usable,
|
||||
_auctionSlotID, _auctionMainCategory, _auctionSubCategory, _quality,
|
||||
count, totalcount, _getAll);
|
||||
bool result = auctionHouse->BuildListAuctionItems(data, plr,
|
||||
wsearchedname, _listfrom, _levelmin, _levelmax, _usable,
|
||||
_auctionSlotID, _auctionMainCategory, _auctionSubCategory, _quality,
|
||||
count, totalcount, _getAll);
|
||||
|
||||
if (!result)
|
||||
return false;
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
data.put<uint32>(0, count);
|
||||
data << (uint32) totalcount;
|
||||
data << (uint32) 300; // clientside search cooldown [ms] (gray search button)
|
||||
plr->GetSession()->SendPacket(&data);
|
||||
data.put<uint32>(0, count);
|
||||
data << (uint32) totalcount;
|
||||
data << (uint32) 300; // clientside search cooldown [ms] (gray search button)
|
||||
plr->GetSession()->SendPacket(&data);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5,63 +5,63 @@
|
||||
|
||||
class AuctionListOwnerItemsDelayEvent : public BasicEvent
|
||||
{
|
||||
public:
|
||||
AuctionListOwnerItemsDelayEvent(WorldPacket& d, uint64 guid, bool o) : data(d), playerguid(guid), owner(o) {}
|
||||
virtual ~AuctionListOwnerItemsDelayEvent() {}
|
||||
public:
|
||||
AuctionListOwnerItemsDelayEvent(WorldPacket& d, uint64 guid, bool o) : data(d), playerguid(guid), owner(o) {}
|
||||
virtual ~AuctionListOwnerItemsDelayEvent() {}
|
||||
|
||||
virtual bool Execute(uint64 e_time, uint32 p_time);
|
||||
virtual void Abort(uint64 e_time) {}
|
||||
virtual bool Execute(uint64 e_time, uint32 p_time);
|
||||
virtual void Abort(uint64 e_time) {}
|
||||
|
||||
private:
|
||||
WorldPacket data;
|
||||
uint64 playerguid;
|
||||
bool owner;
|
||||
private:
|
||||
WorldPacket data;
|
||||
uint64 playerguid;
|
||||
bool owner;
|
||||
};
|
||||
|
||||
class AuctionListItemsDelayEvent
|
||||
{
|
||||
public:
|
||||
AuctionListItemsDelayEvent(uint32 msTimer, uint64 playerguid, uint64 creatureguid, std::string searchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint8 usable, uint32 auctionSlotID, uint32 auctionMainCategory, uint32 auctionSubCategory, uint32 quality, uint8 getAll) :
|
||||
_msTimer(msTimer), _playerguid(playerguid), _creatureguid(creatureguid), _searchedname(searchedname), _listfrom(listfrom), _levelmin(levelmin), _levelmax(levelmax), _usable(usable), _auctionSlotID(auctionSlotID), _auctionMainCategory(auctionMainCategory), _auctionSubCategory(auctionSubCategory), _quality(quality), _getAll(getAll) { }
|
||||
AuctionListItemsDelayEvent(uint32 msTimer, uint64 playerguid, uint64 creatureguid, std::string searchedname, uint32 listfrom, uint8 levelmin, uint8 levelmax, uint8 usable, uint32 auctionSlotID, uint32 auctionMainCategory, uint32 auctionSubCategory, uint32 quality, uint8 getAll) :
|
||||
_msTimer(msTimer), _playerguid(playerguid), _creatureguid(creatureguid), _searchedname(searchedname), _listfrom(listfrom), _levelmin(levelmin), _levelmax(levelmax), _usable(usable), _auctionSlotID(auctionSlotID), _auctionMainCategory(auctionMainCategory), _auctionSubCategory(auctionSubCategory), _quality(quality), _getAll(getAll) { }
|
||||
|
||||
bool Execute();
|
||||
bool Execute();
|
||||
|
||||
uint32 _msTimer;
|
||||
uint64 _playerguid;
|
||||
uint64 _creatureguid;
|
||||
std::string _searchedname;
|
||||
uint32 _listfrom;
|
||||
uint8 _levelmin;
|
||||
uint8 _levelmax;
|
||||
uint8 _usable;
|
||||
uint32 _auctionSlotID;
|
||||
uint32 _auctionMainCategory;
|
||||
uint32 _auctionSubCategory;
|
||||
uint32 _quality;
|
||||
uint8 _getAll;
|
||||
uint32 _msTimer;
|
||||
uint64 _playerguid;
|
||||
uint64 _creatureguid;
|
||||
std::string _searchedname;
|
||||
uint32 _listfrom;
|
||||
uint8 _levelmin;
|
||||
uint8 _levelmax;
|
||||
uint8 _usable;
|
||||
uint32 _auctionSlotID;
|
||||
uint32 _auctionMainCategory;
|
||||
uint32 _auctionSubCategory;
|
||||
uint32 _quality;
|
||||
uint8 _getAll;
|
||||
};
|
||||
|
||||
class AsyncAuctionListingMgr
|
||||
{
|
||||
public:
|
||||
static void Update(uint32 diff) { auctionListingDiff += diff; }
|
||||
static uint32 GetDiff() { return auctionListingDiff; }
|
||||
static void ResetDiff() { auctionListingDiff = 0; }
|
||||
static bool IsAuctionListingAllowed() { return auctionListingAllowed; }
|
||||
static void SetAuctionListingAllowed(bool a) { auctionListingAllowed = a; }
|
||||
static void Update(uint32 diff) { auctionListingDiff += diff; }
|
||||
static uint32 GetDiff() { return auctionListingDiff; }
|
||||
static void ResetDiff() { auctionListingDiff = 0; }
|
||||
static bool IsAuctionListingAllowed() { return auctionListingAllowed; }
|
||||
static void SetAuctionListingAllowed(bool a) { auctionListingAllowed = a; }
|
||||
|
||||
static std::list<AuctionListItemsDelayEvent> & GetList() { return auctionListingList; }
|
||||
static std::list<AuctionListItemsDelayEvent> & GetTempList() { return auctionListingListTemp; }
|
||||
static ACE_Thread_Mutex& GetLock() { return auctionListingLock; }
|
||||
static ACE_Thread_Mutex& GetTempLock() { return auctionListingTempLock; }
|
||||
static std::list<AuctionListItemsDelayEvent> & GetList() { return auctionListingList; }
|
||||
static std::list<AuctionListItemsDelayEvent> & GetTempList() { return auctionListingListTemp; }
|
||||
static ACE_Thread_Mutex& GetLock() { return auctionListingLock; }
|
||||
static ACE_Thread_Mutex& GetTempLock() { return auctionListingTempLock; }
|
||||
|
||||
private:
|
||||
static uint32 auctionListingDiff;
|
||||
static bool auctionListingAllowed;
|
||||
static std::list<AuctionListItemsDelayEvent> auctionListingList;
|
||||
static std::list<AuctionListItemsDelayEvent> auctionListingListTemp;
|
||||
static ACE_Thread_Mutex auctionListingLock;
|
||||
static ACE_Thread_Mutex auctionListingTempLock;
|
||||
static uint32 auctionListingDiff;
|
||||
static bool auctionListingAllowed;
|
||||
static std::list<AuctionListItemsDelayEvent> auctionListingList;
|
||||
static std::list<AuctionListItemsDelayEvent> auctionListingListTemp;
|
||||
static ACE_Thread_Mutex auctionListingLock;
|
||||
static ACE_Thread_Mutex auctionListingTempLock;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,62 +8,62 @@
|
||||
class AvgDiffTracker
|
||||
{
|
||||
public:
|
||||
AvgDiffTracker() : total(0), index(0), average(0) { memset(&tab, 0, sizeof(tab)); max[0] = 0; max[1] = 0; }
|
||||
AvgDiffTracker() : total(0), index(0), average(0) { memset(&tab, 0, sizeof(tab)); max[0] = 0; max[1] = 0; }
|
||||
|
||||
uint32 getAverage()
|
||||
{
|
||||
return average;
|
||||
}
|
||||
uint32 getAverage()
|
||||
{
|
||||
return average;
|
||||
}
|
||||
|
||||
uint32 getTimeWeightedAverage()
|
||||
{
|
||||
if (tab[AVG_DIFF_COUNT-1] == 0)
|
||||
return 0;
|
||||
uint32 getTimeWeightedAverage()
|
||||
{
|
||||
if (tab[AVG_DIFF_COUNT-1] == 0)
|
||||
return 0;
|
||||
|
||||
uint32 sum = 0, weightsum = 0;
|
||||
for (uint32 i=0; i<AVG_DIFF_COUNT; ++i)
|
||||
{
|
||||
sum += tab[i]*tab[i];
|
||||
weightsum += tab[i];
|
||||
}
|
||||
return sum/weightsum;
|
||||
}
|
||||
uint32 sum = 0, weightsum = 0;
|
||||
for (uint32 i=0; i<AVG_DIFF_COUNT; ++i)
|
||||
{
|
||||
sum += tab[i]*tab[i];
|
||||
weightsum += tab[i];
|
||||
}
|
||||
return sum/weightsum;
|
||||
}
|
||||
|
||||
uint32 getMax()
|
||||
{
|
||||
return max[0] > max[1] ? max[0] : max[1];
|
||||
}
|
||||
uint32 getMax()
|
||||
{
|
||||
return max[0] > max[1] ? max[0] : max[1];
|
||||
}
|
||||
|
||||
void Update(uint32 diff)
|
||||
{
|
||||
if (diff < 1)
|
||||
diff = 1;
|
||||
total -= tab[index];
|
||||
total += diff;
|
||||
tab[index] = diff;
|
||||
if (diff > max[0])
|
||||
max[0] = diff;
|
||||
if (++index >= AVG_DIFF_COUNT)
|
||||
{
|
||||
index = 0;
|
||||
max[1] = max[0];
|
||||
max[0] = 0;
|
||||
}
|
||||
void Update(uint32 diff)
|
||||
{
|
||||
if (diff < 1)
|
||||
diff = 1;
|
||||
total -= tab[index];
|
||||
total += diff;
|
||||
tab[index] = diff;
|
||||
if (diff > max[0])
|
||||
max[0] = diff;
|
||||
if (++index >= AVG_DIFF_COUNT)
|
||||
{
|
||||
index = 0;
|
||||
max[1] = max[0];
|
||||
max[0] = 0;
|
||||
}
|
||||
|
||||
if (tab[AVG_DIFF_COUNT-1])
|
||||
average = total/AVG_DIFF_COUNT;
|
||||
else if (index)
|
||||
average = total/index;
|
||||
else
|
||||
average = 0;
|
||||
}
|
||||
if (tab[AVG_DIFF_COUNT-1])
|
||||
average = total/AVG_DIFF_COUNT;
|
||||
else if (index)
|
||||
average = total/index;
|
||||
else
|
||||
average = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32 tab[AVG_DIFF_COUNT];
|
||||
uint32 total;
|
||||
uint32 index;
|
||||
uint32 max[2];
|
||||
uint32 average;
|
||||
uint32 tab[AVG_DIFF_COUNT];
|
||||
uint32 total;
|
||||
uint32 index;
|
||||
uint32 max[2];
|
||||
uint32 average;
|
||||
};
|
||||
|
||||
extern AvgDiffTracker avgDiffTracker;
|
||||
|
||||
@@ -4,8 +4,8 @@ uint8 DynamicVisibilityMgr::visibilitySettingsIndex = 0;
|
||||
|
||||
void DynamicVisibilityMgr::Update(uint32 sessionCount)
|
||||
{
|
||||
if (sessionCount >= (visibilitySettingsIndex+1)*((uint32)VISIBILITY_SETTINGS_PLAYER_INTERVAL) && visibilitySettingsIndex < VISIBILITY_SETTINGS_MAX_INTERVAL_NUM-1)
|
||||
++visibilitySettingsIndex;
|
||||
else if (visibilitySettingsIndex && sessionCount < visibilitySettingsIndex*((uint32)VISIBILITY_SETTINGS_PLAYER_INTERVAL)-100)
|
||||
--visibilitySettingsIndex;
|
||||
if (sessionCount >= (visibilitySettingsIndex+1)*((uint32)VISIBILITY_SETTINGS_PLAYER_INTERVAL) && visibilitySettingsIndex < VISIBILITY_SETTINGS_MAX_INTERVAL_NUM-1)
|
||||
++visibilitySettingsIndex;
|
||||
else if (visibilitySettingsIndex && sessionCount < visibilitySettingsIndex*((uint32)VISIBILITY_SETTINGS_PLAYER_INTERVAL)-100)
|
||||
--visibilitySettingsIndex;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
struct VisibilitySettingData
|
||||
{
|
||||
uint32 visibilityNotifyDelay;
|
||||
uint32 aiNotifyDelay;
|
||||
float requiredMoveDistanceSq;
|
||||
uint32 visibilityNotifyDelay;
|
||||
uint32 aiNotifyDelay;
|
||||
float requiredMoveDistanceSq;
|
||||
};
|
||||
|
||||
// pussywizard: dynamic visibility settings
|
||||
@@ -18,24 +18,24 @@ struct VisibilitySettingData
|
||||
#define VISIBILITY_SETTINGS_MAX_INTERVAL_NUM 7
|
||||
const VisibilitySettingData VisibilitySettings[VISIBILITY_SETTINGS_MAX_INTERVAL_NUM][5] =
|
||||
{
|
||||
{ {300, 150, 1.0f}, {300, 150, 1.0f}, {300, 150, 1.0f}, {300, 150, 1.0f}, {300, 150, 1.0f} }, // 0-499
|
||||
{ {400, 200, 2.25f}, {400, 200, 2.25f}, {400, 200, 2.25f}, {300, 150, 1.0f}, {300, 150, 1.0f} }, // 500-999
|
||||
{ {500, 250, 4.0f}, {500, 250, 4.0f}, {500, 250, 4.0f}, {400, 200, 2.25f}, {300, 150, 1.0f} }, // 1000-1499
|
||||
{ {700, 350, 6.25f}, {700, 350, 6.25f}, {700, 350, 6.25f}, {600, 300, 6.25f}, {300, 200, 1.0f} }, // 1500-1999
|
||||
{ {1000, 500, 16.0f}, {1000, 500, 16.0f}, {1000, 500, 16.0f}, {1000, 500, 16.0f}, {300, 250, 1.0f} }, // 2000-2499
|
||||
{ {1000, 500, 16.0f}, {1000, 500, 16.0f}, {1000, 500, 16.0f}, {1000, 500, 16.0f}, {300, 350, 1.0f} }, // 2500-2999
|
||||
{ {1200, 550, 20.0f}, {1200, 550, 25.0f}, {1200, 550, 25.0f}, {1100, 550, 16.0f}, {300, 350, 1.0f} } // 3000+
|
||||
{ {300, 150, 1.0f}, {300, 150, 1.0f}, {300, 150, 1.0f}, {300, 150, 1.0f}, {300, 150, 1.0f} }, // 0-499
|
||||
{ {400, 200, 2.25f}, {400, 200, 2.25f}, {400, 200, 2.25f}, {300, 150, 1.0f}, {300, 150, 1.0f} }, // 500-999
|
||||
{ {500, 250, 4.0f}, {500, 250, 4.0f}, {500, 250, 4.0f}, {400, 200, 2.25f}, {300, 150, 1.0f} }, // 1000-1499
|
||||
{ {700, 350, 6.25f}, {700, 350, 6.25f}, {700, 350, 6.25f}, {600, 300, 6.25f}, {300, 200, 1.0f} }, // 1500-1999
|
||||
{ {1000, 500, 16.0f}, {1000, 500, 16.0f}, {1000, 500, 16.0f}, {1000, 500, 16.0f}, {300, 250, 1.0f} }, // 2000-2499
|
||||
{ {1000, 500, 16.0f}, {1000, 500, 16.0f}, {1000, 500, 16.0f}, {1000, 500, 16.0f}, {300, 350, 1.0f} }, // 2500-2999
|
||||
{ {1200, 550, 20.0f}, {1200, 550, 25.0f}, {1200, 550, 25.0f}, {1100, 550, 16.0f}, {300, 350, 1.0f} } // 3000+
|
||||
};
|
||||
|
||||
class DynamicVisibilityMgr
|
||||
{
|
||||
public:
|
||||
static void Update(uint32 sessionCount);
|
||||
static uint32 GetVisibilityNotifyDelay(uint32 map_type) { return VisibilitySettings[visibilitySettingsIndex][map_type].visibilityNotifyDelay; }
|
||||
static uint32 GetAINotifyDelay(uint32 map_type) { return VisibilitySettings[visibilitySettingsIndex][map_type].aiNotifyDelay; }
|
||||
static float GetReqMoveDistSq(uint32 map_type) { return VisibilitySettings[visibilitySettingsIndex][map_type].requiredMoveDistanceSq; }
|
||||
static void Update(uint32 sessionCount);
|
||||
static uint32 GetVisibilityNotifyDelay(uint32 map_type) { return VisibilitySettings[visibilitySettingsIndex][map_type].visibilityNotifyDelay; }
|
||||
static uint32 GetAINotifyDelay(uint32 map_type) { return VisibilitySettings[visibilitySettingsIndex][map_type].aiNotifyDelay; }
|
||||
static float GetReqMoveDistSq(uint32 map_type) { return VisibilitySettings[visibilitySettingsIndex][map_type].requiredMoveDistanceSq; }
|
||||
protected:
|
||||
static uint8 visibilitySettingsIndex;
|
||||
static uint8 visibilitySettingsIndex;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,58 +9,58 @@ ACE_Thread_Mutex SavingSystemMgr::_savingLock;
|
||||
|
||||
void SavingSystemMgr::Update(uint32 diff)
|
||||
{
|
||||
if (GetSavingMaxValue() > GetSavingCurrentValue())
|
||||
{
|
||||
const uint32 step = 120;
|
||||
if (GetSavingMaxValue() > GetSavingCurrentValue())
|
||||
{
|
||||
const uint32 step = 120;
|
||||
|
||||
float multiplicator;
|
||||
uint32 playerCount = sWorld->GetPlayerCount();
|
||||
if (!playerCount)
|
||||
{
|
||||
m_savingCurrentValue = 0;
|
||||
m_savingMaxValueAssigned = 0;
|
||||
m_savingDiffSum = 0;
|
||||
m_savingSkipList.clear();
|
||||
return;
|
||||
}
|
||||
float multiplicator;
|
||||
uint32 playerCount = sWorld->GetPlayerCount();
|
||||
if (!playerCount)
|
||||
{
|
||||
m_savingCurrentValue = 0;
|
||||
m_savingMaxValueAssigned = 0;
|
||||
m_savingDiffSum = 0;
|
||||
m_savingSkipList.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetSavingMaxValue()-GetSavingCurrentValue() > playerCount+m_savingSkipList.size()) // this should not happen, but just in case
|
||||
m_savingMaxValueAssigned = m_savingCurrentValue+playerCount+m_savingSkipList.size();
|
||||
if (GetSavingMaxValue()-GetSavingCurrentValue() > playerCount+m_savingSkipList.size()) // this should not happen, but just in case
|
||||
m_savingMaxValueAssigned = m_savingCurrentValue+playerCount+m_savingSkipList.size();
|
||||
|
||||
if (playerCount <= 1500) // every 2min
|
||||
multiplicator = 1000.0f / playerCount;
|
||||
else if (playerCount <= 2500) // every 3min
|
||||
multiplicator = 1500.0f / playerCount;
|
||||
else if (playerCount <= 2750) // every 4min
|
||||
multiplicator = 2000.0f / playerCount;
|
||||
else if (playerCount <= 3000) // every 6min
|
||||
multiplicator = 3000.0f / playerCount;
|
||||
else if (playerCount <= 3250) // every 7min
|
||||
multiplicator = 3500.0f / playerCount;
|
||||
else // every 8min
|
||||
multiplicator = 4000.0f / playerCount;
|
||||
if (playerCount <= 1500) // every 2min
|
||||
multiplicator = 1000.0f / playerCount;
|
||||
else if (playerCount <= 2500) // every 3min
|
||||
multiplicator = 1500.0f / playerCount;
|
||||
else if (playerCount <= 2750) // every 4min
|
||||
multiplicator = 2000.0f / playerCount;
|
||||
else if (playerCount <= 3000) // every 6min
|
||||
multiplicator = 3000.0f / playerCount;
|
||||
else if (playerCount <= 3250) // every 7min
|
||||
multiplicator = 3500.0f / playerCount;
|
||||
else // every 8min
|
||||
multiplicator = 4000.0f / playerCount;
|
||||
|
||||
m_savingDiffSum += diff;
|
||||
while (m_savingDiffSum >= (uint32)(step*multiplicator))
|
||||
{
|
||||
IncreaseSavingCurrentValue(1);
|
||||
m_savingDiffSum += diff;
|
||||
while (m_savingDiffSum >= (uint32)(step*multiplicator))
|
||||
{
|
||||
IncreaseSavingCurrentValue(1);
|
||||
|
||||
while (m_savingSkipList.size() && *(m_savingSkipList.begin()) <= GetSavingCurrentValue())
|
||||
{
|
||||
IncreaseSavingCurrentValue(1);
|
||||
m_savingSkipList.pop_front();
|
||||
}
|
||||
while (m_savingSkipList.size() && *(m_savingSkipList.begin()) <= GetSavingCurrentValue())
|
||||
{
|
||||
IncreaseSavingCurrentValue(1);
|
||||
m_savingSkipList.pop_front();
|
||||
}
|
||||
|
||||
m_savingDiffSum -= (uint32)(step*multiplicator);
|
||||
m_savingDiffSum -= (uint32)(step*multiplicator);
|
||||
|
||||
if (GetSavingCurrentValue() > GetSavingMaxValue())
|
||||
{
|
||||
m_savingDiffSum = 0;
|
||||
break;
|
||||
}
|
||||
if (GetSavingCurrentValue() > GetSavingMaxValue())
|
||||
{
|
||||
m_savingDiffSum = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (m_savingDiffSum > 60000)
|
||||
m_savingDiffSum = 60000;
|
||||
}
|
||||
}
|
||||
if (m_savingDiffSum > 60000)
|
||||
m_savingDiffSum = 60000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,20 +8,20 @@
|
||||
class SavingSystemMgr
|
||||
{
|
||||
public:
|
||||
static void Update(uint32 diff);
|
||||
static void Update(uint32 diff);
|
||||
|
||||
static uint32 GetSavingCurrentValue() { return m_savingCurrentValue; } // modified only during single thread
|
||||
static uint32 GetSavingMaxValue() { return m_savingMaxValueAssigned; } // modified only during single thread
|
||||
static void IncreaseSavingCurrentValue(uint32 inc) { m_savingCurrentValue += inc; } // used and modified only during single thread
|
||||
static uint32 IncreaseSavingMaxValue(uint32 inc) { TRINITY_GUARD(ACE_Thread_Mutex, _savingLock); return (m_savingMaxValueAssigned += inc); }
|
||||
static void InsertToSavingSkipListIfNeeded(uint32 id) { if (id > m_savingCurrentValue) { TRINITY_GUARD(ACE_Thread_Mutex, _savingLock); m_savingSkipList.push_back(id); } }
|
||||
static uint32 GetSavingCurrentValue() { return m_savingCurrentValue; } // modified only during single thread
|
||||
static uint32 GetSavingMaxValue() { return m_savingMaxValueAssigned; } // modified only during single thread
|
||||
static void IncreaseSavingCurrentValue(uint32 inc) { m_savingCurrentValue += inc; } // used and modified only during single thread
|
||||
static uint32 IncreaseSavingMaxValue(uint32 inc) { TRINITY_GUARD(ACE_Thread_Mutex, _savingLock); return (m_savingMaxValueAssigned += inc); }
|
||||
static void InsertToSavingSkipListIfNeeded(uint32 id) { if (id > m_savingCurrentValue) { TRINITY_GUARD(ACE_Thread_Mutex, _savingLock); m_savingSkipList.push_back(id); } }
|
||||
|
||||
protected:
|
||||
static uint32 m_savingCurrentValue;
|
||||
static uint32 m_savingMaxValueAssigned;
|
||||
static uint32 m_savingDiffSum;
|
||||
static std::list<uint32> m_savingSkipList;
|
||||
static ACE_Thread_Mutex _savingLock;
|
||||
static uint32 m_savingCurrentValue;
|
||||
static uint32 m_savingMaxValueAssigned;
|
||||
static uint32 m_savingDiffSum;
|
||||
static std::list<uint32> m_savingSkipList;
|
||||
static ACE_Thread_Mutex _savingLock;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,39 +8,39 @@ std::vector<WhoListPlayerInfo> WhoListCacheMgr::m_whoOpcodeList;
|
||||
|
||||
void WhoListCacheMgr::Update()
|
||||
{
|
||||
// clear current list
|
||||
m_whoOpcodeList.clear();
|
||||
m_whoOpcodeList.reserve(sWorld->GetPlayerCount()+1);
|
||||
// clear current list
|
||||
m_whoOpcodeList.clear();
|
||||
m_whoOpcodeList.reserve(sWorld->GetPlayerCount()+1);
|
||||
|
||||
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->second->FindMap() || itr->second->GetSession()->PlayerLoading())
|
||||
continue;
|
||||
TRINITY_READ_GUARD(HashMapHolder<Player>::LockType, *HashMapHolder<Player>::GetLock());
|
||||
HashMapHolder<Player>::MapType const& m = sObjectAccessor->GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr)
|
||||
{
|
||||
if (!itr->second->FindMap() || itr->second->GetSession()->PlayerLoading())
|
||||
continue;
|
||||
|
||||
if (itr->second->GetSession()->GetSecurity() > SEC_PLAYER)
|
||||
continue;
|
||||
if (itr->second->GetSession()->GetSecurity() > SEC_PLAYER)
|
||||
continue;
|
||||
|
||||
std::string pname = itr->second->GetName();
|
||||
std::wstring wpname;
|
||||
if (!Utf8toWStr(pname, wpname))
|
||||
continue;
|
||||
wstrToLower(wpname);
|
||||
std::string pname = itr->second->GetName();
|
||||
std::wstring wpname;
|
||||
if (!Utf8toWStr(pname, wpname))
|
||||
continue;
|
||||
wstrToLower(wpname);
|
||||
|
||||
std::string gname = sGuildMgr->GetGuildNameById(itr->second->GetGuildId());
|
||||
std::wstring wgname;
|
||||
if (!Utf8toWStr(gname, wgname))
|
||||
continue;
|
||||
wstrToLower(wgname);
|
||||
std::string gname = sGuildMgr->GetGuildNameById(itr->second->GetGuildId());
|
||||
std::wstring wgname;
|
||||
if (!Utf8toWStr(gname, wgname))
|
||||
continue;
|
||||
wstrToLower(wgname);
|
||||
|
||||
std::string aname;
|
||||
if (AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(itr->second->GetZoneId()))
|
||||
aname = areaEntry->area_name[sWorld->GetDefaultDbcLocale()];
|
||||
std::string aname;
|
||||
if (AreaTableEntry const* areaEntry = GetAreaEntryByAreaID(itr->second->GetZoneId()))
|
||||
aname = areaEntry->area_name[sWorld->GetDefaultDbcLocale()];
|
||||
|
||||
if (itr->second->IsSpectator())
|
||||
aname = "Dalaran";
|
||||
if (itr->second->IsSpectator())
|
||||
aname = "Dalaran";
|
||||
|
||||
m_whoOpcodeList.push_back( WhoListPlayerInfo(itr->second->GetTeamId(), itr->second->GetSession()->GetSecurity(), itr->second->getLevel(), itr->second->getClass(), itr->second->getRace(), (itr->second->IsSpectator() ? 4395 /*Dalaran*/ : itr->second->GetZoneId()), itr->second->getGender(), wpname, wgname, aname, pname, gname) );
|
||||
}
|
||||
m_whoOpcodeList.push_back( WhoListPlayerInfo(itr->second->GetTeamId(), itr->second->GetSession()->GetSecurity(), itr->second->getLevel(), itr->second->getClass(), itr->second->getRace(), (itr->second->IsSpectator() ? 4395 /*Dalaran*/ : itr->second->GetZoneId()), itr->second->getGender(), wpname, wgname, aname, pname, gname) );
|
||||
}
|
||||
}
|
||||
@@ -5,31 +5,31 @@
|
||||
|
||||
struct WhoListPlayerInfo
|
||||
{
|
||||
TeamId teamId;
|
||||
AccountTypes security;
|
||||
uint8 level;
|
||||
uint8 clas;
|
||||
uint8 race;
|
||||
uint32 zoneid;
|
||||
uint8 gender;
|
||||
std::wstring wpname;
|
||||
std::wstring wgname;
|
||||
std::string aname;
|
||||
std::string pname;
|
||||
std::string gname;
|
||||
TeamId teamId;
|
||||
AccountTypes security;
|
||||
uint8 level;
|
||||
uint8 clas;
|
||||
uint8 race;
|
||||
uint32 zoneid;
|
||||
uint8 gender;
|
||||
std::wstring wpname;
|
||||
std::wstring wgname;
|
||||
std::string aname;
|
||||
std::string pname;
|
||||
std::string gname;
|
||||
|
||||
WhoListPlayerInfo(TeamId teamId, AccountTypes security, uint8 level, uint8 clas, uint8 race, uint32 zoneid, uint8 gender, std::wstring wpname, std::wstring wgname, std::string aname, std::string pname, std::string gname) :
|
||||
teamId(teamId), security(security), level(level), clas(clas), race(race), zoneid(zoneid), gender(gender), wpname(wpname), wgname(wgname), aname(aname), pname(pname), gname(gname) {}
|
||||
WhoListPlayerInfo(TeamId teamId, AccountTypes security, uint8 level, uint8 clas, uint8 race, uint32 zoneid, uint8 gender, std::wstring wpname, std::wstring wgname, std::string aname, std::string pname, std::string gname) :
|
||||
teamId(teamId), security(security), level(level), clas(clas), race(race), zoneid(zoneid), gender(gender), wpname(wpname), wgname(wgname), aname(aname), pname(pname), gname(gname) {}
|
||||
};
|
||||
|
||||
class WhoListCacheMgr
|
||||
{
|
||||
public:
|
||||
static void Update();
|
||||
static std::vector<WhoListPlayerInfo> * GetWhoList() { return &m_whoOpcodeList; }
|
||||
static void Update();
|
||||
static std::vector<WhoListPlayerInfo> * GetWhoList() { return &m_whoOpcodeList; }
|
||||
|
||||
protected:
|
||||
static std::vector<WhoListPlayerInfo> m_whoOpcodeList;
|
||||
static std::vector<WhoListPlayerInfo> m_whoOpcodeList;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user