86 lines
1.8 KiB
C++
86 lines
1.8 KiB
C++
#include "stdafx.h"
|
|
|
|
#include "MsgHandler.h"
|
|
#include <Object/WiseUser.h>
|
|
|
|
MsgHandler* MsgHandler::ms_pInstance = NULL;
|
|
|
|
MsgHandler::MsgHandler()
|
|
{
|
|
_Initialize();
|
|
}
|
|
|
|
MsgHandler::~MsgHandler()
|
|
{
|
|
}
|
|
|
|
void MsgHandler::CreateInstance()
|
|
{
|
|
if(!ms_pInstance)
|
|
{
|
|
ms_pInstance = new MsgHandler;
|
|
}
|
|
}
|
|
|
|
void MsgHandler::DestroyInstance()
|
|
{
|
|
SAFE_DELETE(ms_pInstance);
|
|
}
|
|
|
|
|
|
struct SIG_HANDLER_LIST
|
|
{
|
|
DWORD CODE;
|
|
MsgHandler::MessageHandler HANDLER;
|
|
};
|
|
|
|
# undef DEF_MSG_HANDLER
|
|
# define DEF_MSG_HANDLER(sigtype, subtype) \
|
|
BOOL MSG_HANDLER_##subtype (eSIG_WISEMSG* pSIG_MSG, GameObject* pObject);
|
|
# include "MsgHandler.List.hxx"
|
|
|
|
void MsgHandler::_Initialize()
|
|
{
|
|
# undef DEF_MSG_HANDLER
|
|
# define DEF_MSG_HANDLER(sigtype, subtype) \
|
|
{ MAKEDWORD(sigtype, sSIG_NOTIFY::subtype), (MessageHandler)&(MSG_HANDLER_##subtype) },
|
|
|
|
SIG_HANDLER_LIST stkHandlerLIST[] =
|
|
{
|
|
# include "MsgHandler.List.hxx"
|
|
};
|
|
|
|
const DWORD ENDOFRECORD = MAKEDWORD(eSIG_WISEMSG::EMPTY, sSIG_NOTIFY::NTF_NO_TYPE);
|
|
SIG_HANDLER_LIST* pINFO = stkHandlerLIST;
|
|
while(ENDOFRECORD != pINFO->CODE)
|
|
{
|
|
m_SIGMSG.insert(make_pair(pINFO->CODE, pINFO->HANDLER));
|
|
++pINFO;
|
|
}
|
|
}
|
|
|
|
BOOL MsgHandler::OnMsg(sSIG_WISEBASE* pSIG_MSG, GameObject* pObject)
|
|
{
|
|
eSIG_TYPE rSIGTYPE = pSIG_MSG->SIGTYPE();
|
|
eWISESUBTYPE& rSUBTYPE = pSIG_MSG->SUBTYPE();
|
|
DWORD dwCODE = MAKEDWORD(rSIGTYPE, rSUBTYPE);
|
|
|
|
// (WAVERIX)(WARNING)
|
|
// GameObject로 인식가능한 처리로 변경할 필요가 있다.
|
|
WiseUser* pUser = (WiseUser*)pObject;
|
|
LogicFlowDelegator& rLOGIC = pUser->GetLogicFlow();
|
|
rLOGIC.OnMsg(pSIG_MSG);
|
|
|
|
SIGMSG_MAP_IT itHANDLER = m_SIGMSG.find(dwCODE);
|
|
if(itHANDLER != m_SIGMSG.end())
|
|
{
|
|
MessageHandler& rMSGHANDLER = itHANDLER->second;
|
|
return rMSGHANDLER(pSIG_MSG, pObject);
|
|
}
|
|
DEBUGGING_CODE_L1("Can't Find Handler");
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|