| 292 | } |
| 293 | |
| 294 | void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper) |
| 295 | { |
| 296 | if (!ucmd) |
| 297 | { |
| 298 | RETURN_META(MRES_IGNORED); |
| 299 | } |
| 300 | |
| 301 | bool hasUsercmdsPreFwds = (m_usercmdsPreFwd->GetFunctionCount() > 0); |
| 302 | bool hasUsercmdsFwds = (m_usercmdsFwd->GetFunctionCount() > 0); |
| 303 | |
| 304 | if (!hasUsercmdsPreFwds && !hasUsercmdsFwds) |
| 305 | { |
| 306 | RETURN_META(MRES_IGNORED); |
| 307 | } |
| 308 | |
| 309 | CBaseEntity *pEntity = META_IFACEPTR(CBaseEntity); |
| 310 | |
| 311 | if (!pEntity) |
| 312 | { |
| 313 | RETURN_META(MRES_IGNORED); |
| 314 | } |
| 315 | |
| 316 | edict_t *pEdict = gameents->BaseEntityToEdict(pEntity); |
| 317 | |
| 318 | if (!pEdict) |
| 319 | { |
| 320 | RETURN_META(MRES_IGNORED); |
| 321 | } |
| 322 | |
| 323 | int client = IndexOfEdict(pEdict); |
| 324 | |
| 325 | |
| 326 | cell_t result = 0; |
| 327 | /* Impulse is a byte so we copy it back manually */ |
| 328 | cell_t impulse = ucmd->impulse; |
| 329 | cell_t vel[3] = {sp_ftoc(ucmd->forwardmove), sp_ftoc(ucmd->sidemove), sp_ftoc(ucmd->upmove)}; |
| 330 | cell_t angles[3] = {sp_ftoc(ucmd->viewangles.x), sp_ftoc(ucmd->viewangles.y), sp_ftoc(ucmd->viewangles.z)}; |
| 331 | cell_t mouse[2] = {ucmd->mousedx, ucmd->mousedy}; |
| 332 | |
| 333 | if (hasUsercmdsPreFwds) |
| 334 | { |
| 335 | m_usercmdsPreFwd->PushCell(client); |
| 336 | m_usercmdsPreFwd->PushCell(ucmd->buttons); |
| 337 | m_usercmdsPreFwd->PushCell(ucmd->impulse); |
| 338 | m_usercmdsPreFwd->PushArray(vel, 3); |
| 339 | m_usercmdsPreFwd->PushArray(angles, 3); |
| 340 | m_usercmdsPreFwd->PushCell(ucmd->weaponselect); |
| 341 | m_usercmdsPreFwd->PushCell(ucmd->weaponsubtype); |
| 342 | m_usercmdsPreFwd->PushCell(ucmd->command_number); |
| 343 | m_usercmdsPreFwd->PushCell(ucmd->tick_count); |
| 344 | m_usercmdsPreFwd->PushCell(ucmd->random_seed); |
| 345 | m_usercmdsPreFwd->PushArray(mouse, 2); |
| 346 | m_usercmdsPreFwd->Execute(); |
| 347 | } |
| 348 | |
| 349 | if (hasUsercmdsFwds) |
| 350 | { |
| 351 | m_usercmdsFwd->PushCell(client); |
nothing calls this directly
no test coverage detected