fix correct dummy-tunings now

This commit is contained in:
HMH 2014-05-03 02:30:05 +02:00 committed by def
parent 1704e27828
commit addfe47d4c
5 changed files with 42 additions and 7 deletions

View file

@ -169,7 +169,7 @@ public:
virtual void OnRender() = 0;
virtual void OnStateChange(int NewState, int OldState) = 0;
virtual void OnConnected() = 0;
virtual void OnMessage(int MsgID, CUnpacker *pUnpacker) = 0;
virtual void OnMessage(int MsgID, CUnpacker *pUnpacker, bool IsDummy = 0) = 0;
virtual void OnPredict() = 0;
virtual void OnActivateEditor() = 0;

View file

@ -1735,6 +1735,37 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
}
}
void CClient::ProcessServerPacketDummy(CNetChunk *pPacket)
{
CUnpacker Unpacker;
Unpacker.Reset(pPacket->m_pData, pPacket->m_DataSize);
// unpack msgid and system flag
int Msg = Unpacker.GetInt();
int Sys = Msg&1;
Msg >>= 1;
if(Unpacker.Error())
return;
if(Sys)
{
// system message
if(Msg == NETMSG_MAP_CHANGE || Msg == NETMSG_MAP_DATA || Msg == NETMSG_PING || Msg == NETMSG_RCON_CMD_ADD || Msg == NETMSG_RCON_CMD_REM || Msg == NETMSG_RCON_AUTH_STATUS || Msg == NETMSG_RCON_LINE || Msg == NETMSG_PING_REPLY || Msg == NETMSG_INPUTTIMING || Msg == NETMSG_SNAP || Msg == NETMSG_SNAPSINGLE || Msg == NETMSG_SNAPEMPTY)
{
return; // no need of all that stuff for the dummy
}
else if(Msg == NETMSG_CON_READY)
{
GameClient()->OnConnected();
}
}
else
{
GameClient()->OnMessage(Msg, &Unpacker, 1);
}
}
void CClient::PumpNetwork()
{
for(int i=0; i<2; i++)
@ -1779,12 +1810,12 @@ void CClient::PumpNetwork()
if(g_Config.m_ClDummy)
ProcessServerPacket(&Packet); //self
else
ProcessConnlessPacket(&Packet); //multiclient
ProcessServerPacketDummy(&Packet); //multiclient
}
else
{
if(g_Config.m_ClDummy)
ProcessConnlessPacket(&Packet); //multiclient
ProcessServerPacketDummy(&Packet); //multiclient
else
ProcessServerPacket(&Packet); //self
}

View file

@ -280,6 +280,7 @@ public:
void ProcessConnlessPacket(CNetChunk *pPacket);
void ProcessServerPacket(CNetChunk *pPacket);
void ProcessServerPacketDummy(CNetChunk *pPacket);
virtual int MapDownloadAmount() { return m_MapdownloadAmount; }
virtual int MapDownloadTotalsize() { return m_MapdownloadTotalsize; }

View file

@ -593,10 +593,10 @@ void CGameClient::OnRelease()
m_All.m_paComponents[i]->OnRelease();
}
void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy)
{
// special messages
if(MsgId == NETMSGTYPE_SV_EXTRAPROJECTILE)
if(MsgId == NETMSGTYPE_SV_EXTRAPROJECTILE && !IsDummy)
{
int Num = pUnpacker->GetInt();
@ -631,10 +631,13 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker)
m_ServerMode = SERVERMODE_PURE;
// apply new tuning
m_Tuning[g_Config.m_ClDummy] = NewTuning;
m_Tuning[IsDummy ? !g_Config.m_ClDummy : g_Config.m_ClDummy] = NewTuning;
return;
}
if(IsDummy)
return; // no need of all that stuff for the dummy
void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgId, pUnpacker);
if(!pRawMsg)
{

View file

@ -219,7 +219,7 @@ public:
virtual void OnInit();
virtual void OnConsoleInit();
virtual void OnStateChange(int NewState, int OldState);
virtual void OnMessage(int MsgId, CUnpacker *pUnpacker);
virtual void OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy = 0);
virtual void OnNewSnapshot();
virtual void OnPredict();
virtual void OnActivateEditor();