diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 2f0b30eeb..baa33e90e 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -307,6 +307,9 @@ CClient::CClient() : m_DemoPlayer(&m_SnapshotDelta), m_DemoRecorder(&m_SnapshotD m_CurrentInput = 0; m_LastDummy = 0; + m_LocalIDs[0] = -1; + m_LocalIDs[1] = -1; + m_Fire = 0; m_State = IClient::STATE_OFFLINE; m_aServerAddressStr[0] = 0; @@ -433,74 +436,87 @@ void CClient::SendInput() // fetch input int Size = GameClient()->OnSnapInput(m_aInputs[m_CurrentInput].m_aData); - if(!Size) - return; - - // pack input - CMsgPacker Msg(NETMSG_INPUT); - Msg.AddInt(m_AckGameTick[g_Config.m_ClDummy]); - Msg.AddInt(m_PredTick[g_Config.m_ClDummy]); - Msg.AddInt(Size); - - m_aInputs[m_CurrentInput].m_Tick = m_PredTick[g_Config.m_ClDummy]; - m_aInputs[m_CurrentInput].m_PredictedTime = m_PredictedTime[g_Config.m_ClDummy].Get(Now); - m_aInputs[m_CurrentInput].m_Time = Now; - - // pack it - for(int i = 0; i < Size/4; i++) - Msg.AddInt(m_aInputs[m_CurrentInput].m_aData[i]); - - m_CurrentInput++; - m_CurrentInput%=200; - - SendMsgEx(&Msg, MSGFLAG_FLUSH); - - if(m_LastDummy != g_Config.m_ClDummy) + if(Size) { - mem_copy(&DummyInput, &m_aInputs[(m_CurrentInput-2)%200], sizeof(DummyInput)); - m_LastDummy = g_Config.m_ClDummy; - } - - if(m_DummyConnected) - { - // pack input - CMsgPacker Msg(NETMSG_INPUT); - Msg.AddInt(INT_MAX); - Msg.AddInt(INT_MAX); - Msg.AddInt(sizeof(DummyInput)); - - // pack it - for(unsigned int i = 0; i < sizeof(DummyInput)/4; i++) - Msg.AddInt(((int*) &DummyInput)[i]); - - SendMsgExY(&Msg, MSGFLAG_FLUSH, true, !g_Config.m_ClDummy); - } - - /*if(m_DummyConnected && !g_Config.m_ClDummy) - { - static int s_Fire = 0; - CNetObj_PlayerInput DummyData; - mem_zero(&DummyData, sizeof(DummyData)); - - DummyData.m_Fire = s_Fire / 4.8; - DummyData.m_WantedWeapon = WEAPON_HAMMER; - DummyData.m_TargetX = 0; - DummyData.m_TargetY = -10; - - s_Fire++; - // pack input CMsgPacker Msg(NETMSG_INPUT); Msg.AddInt(m_AckGameTick[g_Config.m_ClDummy]); Msg.AddInt(m_PredTick[g_Config.m_ClDummy]); - Msg.AddInt(sizeof(DummyData)); + Msg.AddInt(Size); + + m_aInputs[m_CurrentInput].m_Tick = m_PredTick[g_Config.m_ClDummy]; + m_aInputs[m_CurrentInput].m_PredictedTime = m_PredictedTime[g_Config.m_ClDummy].Get(Now); + m_aInputs[m_CurrentInput].m_Time = Now; // pack it - for(unsigned int i = 0; i < sizeof(DummyData)/4; i++) - Msg.AddInt(((int*) &DummyData)[i]); + for(int i = 0; i < Size/4; i++) + Msg.AddInt(m_aInputs[m_CurrentInput].m_aData[i]); - SendMsgExY(&Msg, MSGFLAG_FLUSH, true, !g_Config.m_ClDummy); - }*/ + m_CurrentInput++; + m_CurrentInput%=200; + + SendMsgEx(&Msg, MSGFLAG_FLUSH); + + if(m_LastDummy != g_Config.m_ClDummy) + { + mem_copy(&DummyInput, &m_aInputs[(m_CurrentInput-2)%200], sizeof(DummyInput)); + m_LastDummy = g_Config.m_ClDummy; + } + } + + if(m_DummyConnected) + { + if(!g_Config.m_ClDummy) + m_LocalIDs[0] = ((CGameClient *)GameClient())->m_Snap.m_LocalClientID; + else + m_LocalIDs[1] = ((CGameClient *)GameClient())->m_Snap.m_LocalClientID; + + m_Fire++; + if((((float) m_Fire / 12.5) - (int ((float) m_Fire / 12.5))) > 0.01) + return; + + if(!g_Config.m_ClDummyHammer) + { + // pack input + CMsgPacker Msg(NETMSG_INPUT); + Msg.AddInt(INT_MAX); + Msg.AddInt(INT_MAX); + Msg.AddInt(sizeof(DummyInput)); + + // pack it + for(unsigned int i = 0; i < sizeof(DummyInput)/4; i++) + Msg.AddInt(((int*) &DummyInput)[i]); + + SendMsgExY(&Msg, MSGFLAG_FLUSH, true, !g_Config.m_ClDummy); + } + else + { + CNetObj_PlayerInput DummyData; + mem_zero(&DummyData, sizeof(DummyData)); + + DummyData.m_Fire = (int) ((float) m_Fire / 12.5); + DummyData.m_WantedWeapon = WEAPON_HAMMER; + + CNetObj_Character Main = ((CGameClient *)GameClient())->m_Snap.m_aCharacters[m_LocalIDs[g_Config.m_ClDummy]].m_Cur; + CNetObj_Character Dummy = ((CGameClient *)GameClient())->m_Snap.m_aCharacters[m_LocalIDs[!g_Config.m_ClDummy]].m_Cur; + vec2 Dir = vec2(Main.m_X - Dummy.m_X, Main.m_Y - Dummy.m_Y); + DummyData.m_Direction = GetAngle(Dir); + DummyData.m_TargetX = Dir.x; + DummyData.m_TargetY = Dir.y; + + // pack input + CMsgPacker Msg(NETMSG_INPUT); + Msg.AddInt(INT_MAX); + Msg.AddInt(INT_MAX); + Msg.AddInt(sizeof(DummyData)); + + // pack it + for(unsigned int i = 0; i < sizeof(DummyData)/4; i++) + Msg.AddInt(((int*) &DummyData)[i]); + + SendMsgExY(&Msg, MSGFLAG_FLUSH, true, !g_Config.m_ClDummy); + } + } } const char *CClient::LatestVersion() diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 934325013..99dcc9741 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -249,6 +249,8 @@ public: int m_DummyConnected; int m_DummyConnecting; int m_LastDummyConnectTime; + int m_LocalIDs[2]; + int m_Fire; virtual void GetServerInfo(CServerInfo *pServerInfo); void ServerInfoRequest(); diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 200f3eef9..18dc6a8db 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -524,6 +524,7 @@ static CKeyInfo gs_aKeys[] = { "Scoreboard", "+scoreboard", 0 }, { "Respawn", "kill", 0 }, { "Toggle Dummy", "toggle cl_dummy 0 1", 0 }, + { "Hammerfly Dummy", "toggle cl_dummy_hammerfly 0 1", 0 }, }; /* This is for scripts/update_localization.py to work, don't remove! @@ -638,9 +639,9 @@ void CMenus::RenderSettingsControls(CUIRect MainView) // voting settings { VotingSettings.VMargin(5.0f, &VotingSettings); - VotingSettings.HSplitTop(MainView.h/3-75.0f, &VotingSettings, &ChatSettings); + VotingSettings.HSplitTop(MainView.h/3-95.0f, &VotingSettings, &ChatSettings); RenderTools()->DrawUIRect(&VotingSettings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); - VotingSettings.Margin(10.0f, &VotingSettings); + VotingSettings.VMargin(10.0f, &VotingSettings); TextRender()->Text(0, VotingSettings.x, VotingSettings.y, 14.0f*UI()->Scale(), Localize("Voting"), -1); @@ -670,7 +671,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView) TextRender()->Text(0, MiscSettings.x, MiscSettings.y, 14.0f*UI()->Scale(), Localize("Miscellaneous"), -1); MiscSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &MiscSettings); - UiDoGetButtons(19, 29, MiscSettings); + UiDoGetButtons(19, 30, MiscSettings); } } diff --git a/src/game/variables.h b/src/game/variables.h index 2ba9726fc..e41dfea82 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -75,7 +75,7 @@ MACRO_CONFIG_INT(DummyColorBody, dummy_color_body, 65408, 0, 0xFFFFFF, CFGFLAG_C MACRO_CONFIG_INT(DummyColorFeet, dummy_color_feet, 65408, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Dummy feet color") MACRO_CONFIG_STR(DummySkin, dummy_skin, 24, "default", CFGFLAG_CLIENT|CFGFLAG_SAVE, "Dummy skin") MACRO_CONFIG_INT(ClDummy, cl_dummy, 0, 0, 1, CFGFLAG_CLIENT, "0 - player / 1 - dummy") -MACRO_CONFIG_INT(ClSelectCountry, cl_select_country, 0, 0, 1, CFGFLAG_CLIENT, "Select Country in Dummy menu") +MACRO_CONFIG_INT(ClDummyHammer, cl_dummy_hammer, 0, 0, 1, CFGFLAG_CLIENT, "Whether dummy is hammering for a hammerfly") // server MACRO_CONFIG_INT(SvWarmup, sv_warmup, 0, 0, 0, CFGFLAG_SERVER, "Number of seconds to do warmup before round starts")