| 318 | } |
| 319 | |
| 320 | void CClient::SendInput() |
| 321 | { |
| 322 | int64_t Now = time_get(); |
| 323 | |
| 324 | if(m_aPredTick[g_Config.m_ClDummy] <= 0) |
| 325 | return; |
| 326 | |
| 327 | bool Force = false; |
| 328 | // fetch input |
| 329 | for(int Dummy = 0; Dummy < NUM_DUMMIES; Dummy++) |
| 330 | { |
| 331 | if(!DummyConnected() && Dummy != 0) |
| 332 | { |
| 333 | break; |
| 334 | } |
| 335 | int i = g_Config.m_ClDummy ^ Dummy; |
| 336 | int Size = GameClient()->OnSnapInput(m_aInputs[i][m_aCurrentInput[i]].m_aData, Dummy, Force); |
| 337 | |
| 338 | if(Size) |
| 339 | { |
| 340 | // pack input |
| 341 | CMsgPacker Msg(NETMSG_INPUT, true); |
| 342 | Msg.AddInt(m_aAckGameTick[i]); |
| 343 | Msg.AddInt(m_aPredTick[g_Config.m_ClDummy]); |
| 344 | Msg.AddInt(Size); |
| 345 | |
| 346 | m_aInputs[i][m_aCurrentInput[i]].m_Tick = m_aPredTick[g_Config.m_ClDummy]; |
| 347 | m_aInputs[i][m_aCurrentInput[i]].m_PredictedTime = m_PredictedTime.Get(Now); |
| 348 | m_aInputs[i][m_aCurrentInput[i]].m_PredictionMargin = PredictionMargin() * time_freq() / 1000; |
| 349 | m_aInputs[i][m_aCurrentInput[i]].m_Time = Now; |
| 350 | |
| 351 | // pack it |
| 352 | for(int k = 0; k < Size / 4; k++) |
| 353 | { |
| 354 | static const int FlagsOffset = offsetof(CNetObj_PlayerInput, m_PlayerFlags) / sizeof(int); |
| 355 | if(k == FlagsOffset && IsSixup()) |
| 356 | { |
| 357 | int PlayerFlags = m_aInputs[i][m_aCurrentInput[i]].m_aData[k]; |
| 358 | Msg.AddInt(PlayerFlags_SixToSeven(PlayerFlags)); |
| 359 | } |
| 360 | else |
| 361 | { |
| 362 | Msg.AddInt(m_aInputs[i][m_aCurrentInput[i]].m_aData[k]); |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | m_aCurrentInput[i]++; |
| 367 | m_aCurrentInput[i] %= 200; |
| 368 | |
| 369 | SendMsg(i, &Msg, MSGFLAG_FLUSH); |
| 370 | // ugly workaround for dummy. we need to send input with dummy to prevent |
| 371 | // prediction time resets. but if we do it too often, then it's |
| 372 | // impossible to use grenade with frozen dummy that gets hammered... |
| 373 | if(g_Config.m_ClDummyCopyMoves || m_aCurrentInput[i] % 2) |
| 374 | Force = true; |
| 375 | } |
| 376 | } |
| 377 | } |
nothing calls this directly
no test coverage detected