[10820] Speedup and cleanup quest counters update code.

* Always use QuestStatus data for current counters set
  This let be sure that that we not have non sync values in client view and server state.
* Remove some access functions for quest update fields that expected to be only updated/set.
This commit is contained in:
VladimirMangos 2010-12-03 06:06:02 +03:00
parent d560503a03
commit 534d43daa1
3 changed files with 10 additions and 13 deletions

View file

@ -14524,7 +14524,7 @@ void Player::KilledMonsterCredit( uint32 entry, ObjectGuid guid )
if (q_status.uState != QUEST_NEW)
q_status.uState = QUEST_CHANGED;
SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, curkillcount, addkillcount);
SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, q_status.m_creatureOrGOcount[j]);
}
if (CanCompleteQuest( questid ))
@ -14600,7 +14600,7 @@ void Player::CastedCreatureOrGO( uint32 entry, ObjectGuid guid, uint32 spell_id,
if (q_status.uState != QUEST_NEW)
q_status.uState = QUEST_CHANGED;
SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, curCastCount, addCastCount);
SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, q_status.m_creatureOrGOcount[j]);
}
if (CanCompleteQuest(questid))
@ -14654,7 +14654,7 @@ void Player::TalkedToCreature( uint32 entry, ObjectGuid guid )
q_status.m_creatureOrGOcount[j] = curTalkCount + addTalkCount;
if (q_status.uState != QUEST_NEW) q_status.uState = QUEST_CHANGED;
SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, curTalkCount, addTalkCount);
SendQuestUpdateAddCreatureOrGo( qInfo, guid, j, q_status.m_creatureOrGOcount[j]);
}
if ( CanCompleteQuest( questid ) )
CompleteQuest( questid );
@ -14901,9 +14901,9 @@ void Player::SendQuestUpdateAddItem( Quest const* /*pQuest*/, uint32 /*item_idx*
GetSession()->SendPacket( &data );
}
void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, ObjectGuid guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count )
void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, ObjectGuid guid, uint32 creatureOrGO_idx, uint32 count)
{
MANGOS_ASSERT(old_count + add_count < 65536 && "mob/GO count store in 16 bits 2^16 = 65536 (0..65536)");
MANGOS_ASSERT(count < 65536 && "mob/GO count store in 16 bits 2^16 = 65536 (0..65536)");
int32 entry = pQuest->ReqCreatureOrGOId[ creatureOrGO_idx ];
if (entry < 0)
@ -14914,14 +14914,14 @@ void Player::SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, ObjectGuid gui
DEBUG_LOG( "WORLD: Sent SMSG_QUESTUPDATE_ADD_KILL" );
data << uint32(pQuest->GetQuestId());
data << uint32(entry);
data << uint32(old_count + add_count);
data << uint32(count);
data << uint32(pQuest->ReqCreatureOrGOCount[ creatureOrGO_idx ]);
data << guid;
GetSession()->SendPacket(&data);
uint16 log_slot = FindQuestSlot( pQuest->GetQuestId() );
if( log_slot < MAX_QUEST_LOG_SIZE)
SetQuestSlotCounter(log_slot,creatureOrGO_idx,GetQuestSlotCounter(log_slot,creatureOrGO_idx)+add_count);
if (log_slot < MAX_QUEST_LOG_SIZE)
SetQuestSlotCounter(log_slot, creatureOrGO_idx, count);
}
/*********************************************************/

View file

@ -1447,9 +1447,6 @@ class MANGOS_DLL_SPEC Player : public Unit
uint16 FindQuestSlot( uint32 quest_id ) const;
uint32 GetQuestSlotQuestId(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET); }
uint32 GetQuestSlotState(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_STATE_OFFSET); }
uint16 GetQuestSlotCounter(uint16 slot, uint8 counter) const { return (uint16)(GetUInt64Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_COUNTS_OFFSET) >> (counter * 16)); }
uint32 GetQuestSlotTime(uint16 slot) const { return GetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_TIME_OFFSET); }
void SetQuestSlot(uint16 slot, uint32 quest_id, uint32 timer = 0)
{
SetUInt32Value(PLAYER_QUEST_LOG_1_1 + slot * MAX_QUEST_OFFSET + QUEST_ID_OFFSET, quest_id);
@ -1503,7 +1500,7 @@ class MANGOS_DLL_SPEC Player : public Unit
void SendQuestConfirmAccept(Quest const* pQuest, Player* pReceiver);
void SendPushToPartyResponse( Player *pPlayer, uint32 msg );
void SendQuestUpdateAddItem( Quest const* pQuest, uint32 item_idx, uint32 count );
void SendQuestUpdateAddCreatureOrGo( Quest const* pQuest, ObjectGuid guid, uint32 creatureOrGO_idx, uint32 old_count, uint32 add_count );
void SendQuestUpdateAddCreatureOrGo(Quest const* pQuest, ObjectGuid guid, uint32 creatureOrGO_idx, uint32 count);
uint64 GetDivider() { return m_divider; }
void SetDivider( uint64 guid ) { m_divider = guid; }

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10819"
#define REVISION_NR "10820"
#endif // __REVISION_NR_H__