mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 17:54:48 +01:00
DBLayer:
- Implement QueryCallback_2 template for ACE_Future callbacks using 2 parameters for the callback function - Make MSG_LIST_STABLED_PETS´s handler use async query instead of blocking query --HG-- branch : trunk
This commit is contained in:
@@ -1015,4 +1015,14 @@ void WorldSession::ProcessQueryCallbacks()
|
||||
HandleAddIgnoreOpcodeCallBack(result);
|
||||
m_addIgnoreCallback.cancel();
|
||||
}
|
||||
|
||||
//- SendStabledPet
|
||||
if (m_sendStabledPetCallback.IsReady())
|
||||
{
|
||||
WorldPacket* param1 = m_sendStabledPetCallback.GetFirstParam();
|
||||
uint8 param2 = m_sendStabledPetCallback.GetSecondParam();
|
||||
m_sendStabledPetCallback.GetResult(result);
|
||||
SendStablePetCallback(result, param1, param2);
|
||||
m_sendStabledPetCallback.FreeResult();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,6 +218,7 @@ class WorldSession
|
||||
// Pet
|
||||
void SendPetNameQuery(uint64 guid, uint32 petnumber);
|
||||
void SendStablePet(uint64 guid);
|
||||
void SendStablePetCallback(QueryResult_AutoPtr result, WorldPacket* data, uint8 num);
|
||||
void SendStableResult(uint8 guid);
|
||||
bool CheckStableMaster(uint64 guid);
|
||||
|
||||
@@ -805,6 +806,7 @@ class WorldSession
|
||||
QueryResultFuture m_addIgnoreCallback;
|
||||
QueryCallback<std::string> m_charRenameCallback;
|
||||
QueryCallback<std::string> m_addFriendCallback;
|
||||
QueryCallback_2<WorldPacket*, uint8> m_sendStabledPetCallback;
|
||||
QueryResultHolderFuture m_charLoginCallback;
|
||||
|
||||
private:
|
||||
|
||||
@@ -76,4 +76,61 @@ class QueryCallback
|
||||
ParamType param;
|
||||
};
|
||||
|
||||
template <typename ParamType1, typename ParamType2>
|
||||
class QueryCallback_2
|
||||
{
|
||||
public:
|
||||
QueryCallback_2() {}
|
||||
|
||||
void SetFutureResult(QueryResultFuture value)
|
||||
{
|
||||
result = value;
|
||||
}
|
||||
|
||||
QueryResultFuture GetFutureResult()
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
int IsReady()
|
||||
{
|
||||
return result.ready();
|
||||
}
|
||||
|
||||
void GetResult(QueryResult_AutoPtr& res)
|
||||
{
|
||||
result.get(res);
|
||||
}
|
||||
|
||||
void FreeResult()
|
||||
{
|
||||
result.cancel();
|
||||
}
|
||||
|
||||
void SetFirstParam(ParamType1 value)
|
||||
{
|
||||
param_1 = value;
|
||||
}
|
||||
|
||||
void SetSecondParam(ParamType2 value)
|
||||
{
|
||||
param_2 = value;
|
||||
}
|
||||
|
||||
ParamType1 GetFirstParam()
|
||||
{
|
||||
return param_1;
|
||||
}
|
||||
|
||||
ParamType2 GetSecondParam()
|
||||
{
|
||||
return param_2;
|
||||
}
|
||||
|
||||
private:
|
||||
QueryResultFuture result;
|
||||
ParamType1 param_1;
|
||||
ParamType2 param_2;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user