Facepunch / garrysmod-issues

Garry's Mod issue tracker
147 stars 56 forks source link

GM:KeyPress/Release being called out of prediction in singleplayer #5844

Closed TankNut closed 6 months ago

TankNut commented 7 months ago

Details

Protocol version 24
Exe version 2023.06.28 (garrysmod)
Exe build: 11:36:52 Apr  4 2024 (9280) (4000)
GMod version 2024.04.19, branch: dev, multicore: 1
Windows 32bit

Tested on dev, also happening on main branch.

GM:KeyPress/Release are being called out of prediction in singleplayer, contradicting what the wiki says.

Steps to reproduce

hook.Add("KeyPress", "Test", function(...) print(CLIENT and "Client" or "Server", GetPredictionPlayer(), ...) end)

Singleplayer

Server  Player [1][TankNut] Player [1][TankNut] 8
Client  [NULL Entity]   Player [1][TankNut] 8

Multiplayer (Listen server, P2P)

Server  Player [1][TankNut] Player [1][TankNut] 8
Client  Player [1][TankNut] Player [1][TankNut] 8

debug.traceback() (Identical on both realms)

stack traceback:
    lua_run:1: in function 'v'
    lua/includes/modules/hook.lua:96: in function <lua/includes/modules/hook.lua:79>
robotboy655 commented 6 months ago

This is done on purpose, so that the hooks are still called in singleplayer clientside.

TankNut commented 6 months ago

All good, it's easy enough to filter out with IsValid(GetPredictionPlayer()) so it didn't cause any real issues in the end.