diff options
author | Michael Smith <mikesmiffy128@gmail.com> | 2024-08-22 00:02:48 +0100 |
---|---|---|
committer | Michael Smith <mikesmiffy128@gmail.com> | 2024-08-23 20:40:01 +0100 |
commit | cf0354eb8e043fcd9c6c17756701972f948a16f1 (patch) | |
tree | de931afc161f43e95d040ae655a6a2081aeb4ff2 /gamedata | |
parent | 78323e416f79ef9c26bbd742082627bc45e116c1 (diff) |
Rewrite the gamedata and entprops systems entirely
This removes the horrible janky old KeyValues parser and replaces it
with a couple of trivial ad-hoc text parsers. In doing so, make the
format of the actual gamedata files more human-friendly too.
We also gain support for nested SendTables in mkentprops, which are
required to get at various things like player velocity. And, the actual
string matching is made more efficient (or, at least, more scalable) by
way of a cool radix tree thing which generates a bunch of switch cases
on distinct characters.
Diffstat (limited to 'gamedata')
-rw-r--r-- | gamedata/engine.kv | 181 | ||||
-rw-r--r-- | gamedata/engine.txt | 162 | ||||
-rw-r--r-- | gamedata/entprops.kv | 9 | ||||
-rw-r--r-- | gamedata/entprops.txt | 8 | ||||
-rw-r--r-- | gamedata/gamelib.kv | 57 | ||||
-rw-r--r-- | gamedata/gamelib.txt | 46 | ||||
-rw-r--r-- | gamedata/inputsystem.kv | 17 | ||||
-rw-r--r-- | gamedata/inputsystem.txt | 12 | ||||
-rw-r--r-- | gamedata/matchmaking.kv | 11 | ||||
-rw-r--r-- | gamedata/matchmaking.txt | 7 | ||||
-rw-r--r-- | gamedata/vgui2.kv | 7 | ||||
-rw-r--r-- | gamedata/vgui2.txt | 7 | ||||
-rw-r--r-- | gamedata/vguimatsurface.kv | 69 | ||||
-rw-r--r-- | gamedata/vguimatsurface.txt | 49 |
14 files changed, 291 insertions, 351 deletions
diff --git a/gamedata/engine.kv b/gamedata/engine.kv deleted file mode 100644 index 304b218..0000000 --- a/gamedata/engine.kv +++ /dev/null @@ -1,181 +0,0 @@ -// = engine library = - -// ICvar -// XXX: const and non-const entries might be flipped here on Windows, not 100% -// sure. kind of just choosing not to care thusfar, as it still works the same! -vtidx_AllocateDLLIdentifier { default 5 Portal2 8 } -vtidx_RegisterConCommand { default 6 Portal2 9 } -vtidx_UnregisterConCommands { default 8 Portal2 11 } -//vtidx_FindComandBase { default 10 Portal2 13 } // unused -vtidx_FindVar { default 12 Portal2 15 } -//vtidx_FindVar_const { default 13 Portal2 16 } // e.g. this might be wrong(???) -vtidx_FindCommand { default 14 Portal2 17 } -vtidx_CallGlobalChangeCallbacks { default 20 L4Dx 18 Portal2 21 } -vtidx_ConsoleColorPrintf { OrangeBoxbased 23 L4Dx 21 Portal2 24 } - -// CDemoRecorder -vtidx_StartRecording 2 -vtidx_SetSignonState 3 -vtidx_StopRecording 7 -vtidx_RecordPacket 11 - -// VEngineClient -vtidx_IsInGame { - Client015 26 - Client014 { - L4D2 28 - 2013 26 - } - Client013 { - L4D1 27 - default 26 - } - // TODO(compat): unconfirmed, and OE support isn't really a thing yet anyway - //Client012 28 -} -vtidx_GetGameDirectory { - Client015 35 // current portal 2 - Client014 { - L4D2 73 // YES IT'S SEVENTY THREE ALL OF A SUDDEN. - 2013 35 - } - Client013 { - L4Dx 36 // AND THEN THEY CHANGED IT BACK LATER! (on 2.0.4.1) - default 35 // <- most things have this! - } - Client012 37 // dmomm, ep1, ... -} -vtidx_GetEngineBuildNumber { - Client013 { - L4D2 99 - Portal2 100 - } - Client014 { - L4D2 31 - 2013 98 - } - Portal1_3420 91 - // TODO(compat): we'll need these... but need to detect first - //Portal1_5135 102 - //L4D1_1005 99 - //L4D1_Steam 97 -} - -// IGameUIFuncs -vtidx_GetDesktopResolution 5 - -// IGame/CGame -vtidx_DispatchAllStoredGameMessages 16 - -// VEngineServer -vtidx_PEntityOfEntIndex { OrangeBox 19 } // probably OE too but??? -vtidx_ServerCommand { OrangeBoxbased 36 } - -sz_edict { - default 20 - L4Dbased 16 // see engineapi.h comment -} - -// vgui::Panel -vtidx_SetPaintEnabled { - default 67 - Client013 { - L4D1 68 - L4D2 { - default 71 - L4D2_2147plus 72 - } - } - Client014 { - L4D2 70 - } -} -vtidx_Paint { - default 123 - Client014 { L4D2 126 } // 2000 - Client013 { - L4D2 { - default 127 // 2045 - L4D2_2147plus 128 - } - } -} - -// SendProp -sz_SendProp { - // wrapping all these in 005 for right now. - // will need at least 009 as well at some point! - SrvDLL005 { - OrangeBox 76 - L4D1 80 - L4D2 84 - Portal2 84 - } - //2013 80 // TODO(compat): not sure about 2013/009 yet -} -off_SP_varname { - SrvDLL005 { - OrangeBox 44 - //L4Dbased 48 // TODO(compat): haven't tested Survivors - // for now do this instead: - L4D 48 - Portal2 48 - } - //2013 48 // TODO(compat): not sure about 2013/009 yet pt2 -} -off_SP_offset { - SrvDLL005 { - OrangeBox 68 - L4D1 72 - L4D2 76 - Portal2 76 - } - //2013 72 // TODO(compat): not sure about 2013/009 yet pt3 -} - -// CBaseServer/CGameServer -vtidx_GetSpawnCount { - //OrangeBox "13 + NVDTOR" // not used right now anyway - L4D1 "13 + NVDTOR" - L4D2 "14 + NVDTOR" // GetTimescale() added, pushed it down - // rest untested, add later if/when actually needed for something -} - -// IEngineVGuiInternal/CEngineVGui -vtidx_GetPanel NVDTOR -vtidx_VGuiConnect { // note: the actual name is Connect() but that's too generic - default "3 + NVDTOR" - L4Dbased { - default "4 + NVDTOR" // ActivateGameUI added - L4DS "5 + NVDTOR" // some other crap added, god knows - } -} -vtidx_VGuiIsInitialized { // likewise, function is just called IsInitialized() - default "6 + NVDTOR" - L4Dbased { - default "7 + NVDTOR" - L4DS "8 + NVDTOR" - } -} - -// CDedicatedServerAPI -vtidx_RunFrame 7 - -// IEngine -vtidx_Frame "4 + NVDTOR" - -// CEngineTool -vtidx_GetRealTime { - default 34 // HL2, P1, L4D1, BMS - // OE, DMoMM 24 - L4D2 35 - Portal2 36 -} -vtidx_HostFrameTime { - default 35 - // OE, DMoMM 25 - L4D2 38 - Portal2 39 -} - -// vi: sw=4 ts=4 noet tw=80 cc=80 ft=text diff --git a/gamedata/engine.txt b/gamedata/engine.txt new file mode 100644 index 0000000..b5186a6 --- /dev/null +++ b/gamedata/engine.txt @@ -0,0 +1,162 @@ +# ICvar +# XXX: const and non-const entries might be flipped here on Windows, not 100% +# sure. kind of just choosing not to care thusfar, as it still works the same! +vtidx_AllocateDLLIdentifier 5 + Portal2 8 +vtidx_RegisterConCommand 6 + Portal2 9 +vtidx_UnregisterConCommands 8 + Portal2 11 +# unused: +#vtidx_FindCommandBase 10 +# Portal2 13 +vtidx_FindVar 12 + Portal2 15 +vtidx_FindCommand 14 + Portal2 17 +vtidx_CallGlobalChangeCallbacks 20 + L4Dx 18 + Portal2 21 +vtidx_ConsoleColorPrintf + OrangeBoxbased 23 + L4Dx 21 + Portal2 24 + +# CDemoRecorder +vtidx_StartRecording 2 +vtidx_SetSignonState 3 +vtidx_StopRecording 7 +vtidx_RecordPacket 11 + +# VEngineClient +vtidx_IsInGame + Client015 26 + Client014 + L4D2 28 + 2013 26 + Client013 26 + L4D1 27 + # TODO(compat): unconfirmed, and OE support isn't really a thing yet anyway + #Client012 28 +vtidx_GetGameDirectory + Client015 35 # current Portal 2 + Client014 + L4D2 73 # YES IT'S SEVENTY THREE SOMEHOW ALL OF A SUDDEN. + 2013 35 + Client013 35 + L4Dx 36 # AND THEY ACTUALLY CHANGED IT BACK LATER! (on 2.0.4.1) + Client012 37 # dmomm, ep1, ... +vtidx_GetEngineBuildNumber + Client013 + L4D2 99 + Portal2 100 + Client014 + L4D2 31 + 2013 98 + Portal1_3420 91 + # TODO(compat): we'll need these... but need to detect first + #Portal1_5135 102 + #L4D1_1005 99 + #L4D1_Steam 97 + +# IGameUIFuncs +vtidx_GetDesktopResolution 5 + +# IGame/CGame +vtidx_DispatchAllStoredGameMessages 16 + +# VEngineServer +vtidx_PEntityOfEntIndex + OrangeBox 19 # probably OE too but ?? +vtidx_ServerCommand + OrangeBoxbased 36 + +sz_edict 20 + L4Dbased 16 + +# vgui::Panel +vtidx_SetPaintEnabled 67 + Client013 + L4D1 68 + L4D2 71 + L4D2_2147plus 72 + Client014 + L4D2 70 +vtidx_Paint 123 + Client014 + L4D2 126 # 2000 + Client013 + L4D2 127 # 2045 + L4D2_2147plus 128 + +# SendProp +sz_SendProp + # wrapping all these in 005 for right now. + # will need at least 009 as well at some point! + SrvDLL005 + OrangeBox 76 + L4D1 80 + L4D2 84 + Portal2 84 + #2013 80 # TODO(compat): not sure about 2013/009 yet +off_SP_type 8 +off_SP_varname + SrvDLL005 + OrangeBox 44 + #L4Dbased 48 # TODO(compat): haven't tested Survivors + # for now do this instead: + L4D 48 + Portal2 48 + #2013 48 # TODO(compat): not sure about 2013/009 yet pt2 +off_SP_subtable + SrvDLL005 + OrangeBox 64 + L4D1 68 + L4D2 72 + Portal2 72 + #2013 68 # TODO(compat): not sure about 2013/009 yet pt3 +off_SP_offset + SrvDLL005 + OrangeBox 68 + L4D1 72 + L4D2 76 + Portal2 76 + #2013 72 # TODO(compat): not sure about 2013/009 yet pt4 + +DT_DataTable 5 # constant value from SendPropType enum (XXX: name okay???) + L4Dbased 6 + +# CBaseServer/CGameServer +vtidx_GetSpawnCount + #OrangeBox 13 + NVDTOR # not used right now anyway + L4D1 13 + NVDTOR + L4D2 14 + NVDTOR # GetTimescale() added, pushed it down + # rest untested, add later if/when actually needed for something + +# IEngineVGuiInternal/CEngineVGui +vtidx_GetPanel NVDTOR +# note: actual name of this function is Connect() but that's too generic +vtidx_VGuiConnect 3 + NVDTOR + L4Dbased 4 + NVDTOR # ActivateGameUI added + L4DS 5 + NVDTOR # some other crap added, god knows +vtidx_VGuiIsInitialized 6 + NVDTOR # this is also just called IsInitialized() + L4Dbased 7 + NVDTOR + L4DS 8 + NVDTOR + +# CDedicatedServerAPI +vtidx_RunFrame 7 + +# IEngine +vtidx_Frame 4 + NVDTOR + +# CEngineTool +vtidx_GetRealTime 34 # HL2, P1, L4D1, BMS + # OE, DMoMM 24 + L4D2 35 + Portal2 36 +vtidx_HostFrameTime 35 + # OE, DMoMM 25 + L4D2 38 + Portal2 39 + +# vi: sw=4 ts=4 noet tw=80 cc=80 diff --git a/gamedata/entprops.kv b/gamedata/entprops.kv deleted file mode 100644 index 942d9c9..0000000 --- a/gamedata/entprops.kv +++ /dev/null @@ -1,9 +0,0 @@ -// This follows a different format to the other gamedata files. -// It simply assigns variable names to network table property name strings. -// Network names are classname/propname, e.g. CBasePlayer/m_fWhatever - -off_entpos CBaseEntity/m_vecOrigin -// look angles, currently just for L4D1/2, can add other games as needed -off_eyeang "CCSPlayer/m_angEyeAngles[0]" - -// vi: sw=4 ts=4 noet tw=80 cc=80 ft=text diff --git a/gamedata/entprops.txt b/gamedata/entprops.txt new file mode 100644 index 0000000..5d6bd7c --- /dev/null +++ b/gamedata/entprops.txt @@ -0,0 +1,8 @@ +# Format: variable sendtable[/subtable/...]/property +# Example: off_coolvar CClassName/m_pSubTableThing/m_fCoolVariable + +off_entpos CBaseEntity/m_vecOrigin +# look angles, currently just for L4D1/2, can add other games as needed +off_eyeang CCSPlayer/m_angEyeAngles[0] + +# vi: sw=4 ts=4 noet tw=80 cc=80 diff --git a/gamedata/gamelib.kv b/gamedata/gamelib.kv deleted file mode 100644 index 7f53383..0000000 --- a/gamedata/gamelib.kv +++ /dev/null @@ -1,57 +0,0 @@ -// = client and server libraries = - -// CGameMovement -vtidx_CheckJumpButton { - Portal1_3420 "22 + NVDTOR" - 2013 "28 + NVDTOR" - L4D "32 + NVDTOR" - L4DS "33 + NVDTOR" - Portal2 "35 + NVDTOR" -} -off_mv { - default 8 - Portal1_3420 4 -} - -// IServerGameDLL -vtidx_GetAllServerClasses { - default 10 - 2013 11 - // TODO(compat): BMS 11 -} - -// I(Server|Client)Unknown -vtidx_GetBaseEntity "4 + NVDTOR" - -// CBaseEntity or CBasePlayer or something -off_netprop_statechanged { L4D 88 } -off_simtime { L4D 128 } -vtidx_Spawn { - L4D2 { - default "22 + NVDTOR" - TheLastStand "23 + NVDTOR" - } -} -vtidx_Teleport { - L4D "104 + NVDTOR" - L4D2 { - default "116 + NVDTOR" // TODO(linux): might actually be 119!?!? - TheLastStand "117 + NVDTOR" // I dunno why JAiZ changed this - } -} - -// CGlobalVars -off_curtime 12 -off_edicts { L4D 88 } - -// IServerGameDLL -vtidx_GameFrame 4 -vtidx_GameShutdown 7 - -// CDirector -vtidx_OnGameplayStart { - L4D2 11 // note: just happens the same on linux! - L4D1 11 // TODO(linux): unknown whether or not this is the same -} - -// vi: sw=4 ts=4 noet tw=80 cc=80 ft=text diff --git a/gamedata/gamelib.txt b/gamedata/gamelib.txt new file mode 100644 index 0000000..35d5551 --- /dev/null +++ b/gamedata/gamelib.txt @@ -0,0 +1,46 @@ +# CGameMovement +vtidx_CheckJumpButton + Portal1_3420 22 + NVDTOR + 2013 28 + NVDTOR + L4D 32 + NVDTOR + L4DS 33 + NVDTOR + Portal2 35 + NVDTOR +off_mv 8 + Portal1_3420 4 + +# IServerGameDLL +vtidx_GetAllServerClasses 10 + 2013 11 + # TODO(compat): BMS 11 + +# I(Server|Client)Unknown +vtidx_GetBaseEntity 4 + NVDTOR + +# CBaseEntity or CBasePlayer or something +off_netprop_statechanged + L4D 88 +off_simtime + L4D 128 +vtidx_Spawn + L4D2 22 + NVDTOR + TheLastStand 23 + NVDTOR +vtidx_Teleport + L4D 104 + NVDTOR + L4D2 116 + NVDTOR # TODO(linux): might actually be 119!?!? + TheLastStand 117 + NVDTOR # I dunno why JAiZ changed this + +# CGlobalVars +off_curtime 12 +off_edicts + L4D 88 + +# IServerGameDLL +vtidx_GameFrame 4 +vtidx_GameShutdown 7 + +# CDirector +vtidx_OnGameplayStart + L4D2 11 # note: just happens the same on linux! + L4D1 11 + +# vi: sw=4 ts=4 noet tw=80 cc=80 diff --git a/gamedata/inputsystem.kv b/gamedata/inputsystem.kv deleted file mode 100644 index 3c13e09..0000000 --- a/gamedata/inputsystem.kv +++ /dev/null @@ -1,17 +0,0 @@ -// = inputsystem library = - -vtidx_SleepUntilInput { - default 31 // TODO(compat): don't really know yet if this causes any issues - Portal2 34 // IAppSystem changes -} - -// XXX: This function won't always exist even when has_ is true. -// It's only used by rinput.c after checking that m_rawinput exists. -vtidx_GetRawMouseAccumulators { - L4D1 39 - L4D2 37 - 2013 39 - Portal2 50 -} - -// vi: sw=4 ts=4 noet tw=80 cc=80 ft=text diff --git a/gamedata/inputsystem.txt b/gamedata/inputsystem.txt new file mode 100644 index 0000000..65bca21 --- /dev/null +++ b/gamedata/inputsystem.txt @@ -0,0 +1,12 @@ +vtidx_SleepUntilInput 31 # TODO(compat): unsure if this causes any issues yet + Portal2 34 # IAppSystem changes + +# XXX: This function won't always exist even when has_ is true. +# It's only used by rinput.c after checking that m_rawinput exists. +vtidx_GetRawMouseAccumulators + L4D1 39 + L4D2 37 + 2013 39 + Portal2 50 + +# vi: sw=4 ts=4 noet tw=80 cc=80 diff --git a/gamedata/matchmaking.kv b/gamedata/matchmaking.kv deleted file mode 100644 index 8ee618d..0000000 --- a/gamedata/matchmaking.kv +++ /dev/null @@ -1,11 +0,0 @@ -// = matchmaking library = - -// IMatchFramework -vtidx_GetMatchNetworkMsgController { - L4D 10 // NOTE: probably same for aswarm or p2 except with IAppSystem shift -} - -// IMatchNetworkMsgController -vtidx_GetActiveGameServerDetails { L4D 1 } - -// vi: sw=4 ts=4 noet tw=80 cc=80 ft=text diff --git a/gamedata/matchmaking.txt b/gamedata/matchmaking.txt new file mode 100644 index 0000000..2c93120 --- /dev/null +++ b/gamedata/matchmaking.txt @@ -0,0 +1,7 @@ +# IMatchFramework +vtidx_GetMatchNetworkMsgController + L4D 10 # NOTE: probably same for aswarm or p2 except with IAppSystem shift +vtidx_GetActiveGameServerDetails + L4D 1 + +# vi: sw=4 ts=4 noet tw=80 cc=80 diff --git a/gamedata/vgui2.kv b/gamedata/vgui2.kv deleted file mode 100644 index 6fd55a3..0000000 --- a/gamedata/vgui2.kv +++ /dev/null @@ -1,7 +0,0 @@ -// = vgui2 library = - -// ISchemeManager -vtidx_GetIScheme 8 - -// IScheme -vtidx_GetFont 3 diff --git a/gamedata/vgui2.txt b/gamedata/vgui2.txt new file mode 100644 index 0000000..91aba01 --- /dev/null +++ b/gamedata/vgui2.txt @@ -0,0 +1,7 @@ +# ISchemeManager +vtidx_GetIScheme 8 + +# IScheme +vtidx_GetFont 3 + +# vi: sw=4 ts=4 noet tw=80 cc=80 diff --git a/gamedata/vguimatsurface.kv b/gamedata/vguimatsurface.kv deleted file mode 100644 index 19857be..0000000 --- a/gamedata/vguimatsurface.kv +++ /dev/null @@ -1,69 +0,0 @@ -// = vguimatsurface library = - -// ISurface -vtidx_DrawSetColor { - OrangeBoxbased 10 - L4D 10 -} -vtidx_DrawFilledRect { - OrangeBoxbased 12 - L4D 12 -} -vtidx_DrawOutlinedRect { - OrangeBoxbased 14 - L4D 14 -} -vtidx_DrawLine { - OrangeBoxbased 15 - L4D 15 -} -vtidx_DrawPolyLine { - OrangeBoxbased 16 - L4D 16 -} -vtidx_DrawSetTextFont { - OrangeBoxbased 17 - L4D 17 -} -vtidx_DrawSetTextColor { - OrangeBoxbased 18 - L4D 18 -} -vtidx_DrawSetTextPos { - OrangeBoxbased 20 - L4D 20 -} -vtidx_DrawPrintText { - OrangeBoxbased 22 - L4D 22 -} -vtidx_GetScreenSize { - OrangeBoxbased 37 - L4D { - default 37 - L4D2_2147plus 35 - } -} -// Unused: currently no good way to create custom fonts without leaking them -//vtidx_CreateFont { -// OrangeBoxbased 64 -// L4D { -// default 64 -// L4D2_2147plus 63 -// } -//} -//vtidx_SetFontGlyphSet { -// OrangeBoxbased 65 -// L4D { -// default 65 -// L4D2_2147plus 64 -// } -//} -vtidx_GetFontTall { - OrangeBoxbased 67 - L4D 67 -} -vtidx_GetCharacterWidth { - OrangeBoxbased 71 - L4D 71 -} diff --git a/gamedata/vguimatsurface.txt b/gamedata/vguimatsurface.txt new file mode 100644 index 0000000..a9dc3f2 --- /dev/null +++ b/gamedata/vguimatsurface.txt @@ -0,0 +1,49 @@ +# ISurface +vtidx_DrawSetColor + OrangeBoxbased 10 + L4D 10 +vtidx_DrawFilledRect + OrangeBoxbased 12 + L4D 12 +vtidx_DrawOutlinedRect + OrangeBoxbased 14 + L4D 14 +vtidx_DrawLine + OrangeBoxbased 15 + L4D 15 +vtidx_DrawPolyLine + OrangeBoxbased 16 + L4D 16 +vtidx_DrawSetTextFont + OrangeBoxbased 17 + L4D 17 +vtidx_DrawSetTextColor + OrangeBoxbased 18 + L4D 18 +vtidx_DrawSetTextPos + OrangeBoxbased 20 + L4D 20 +vtidx_DrawPrintText + OrangeBoxbased 22 + L4D 22 +vtidx_GetScreenSize + OrangeBoxbased 37 + L4D 37 + L4D2_2147plus 35 +# Unused: currently no good way to create custom fonts without leaking them +#vtidx_CreateFont +# OrangeBoxbased 64 +# L4D 64 +# L4D2_2147plus 63 +#vtidx_SetFontGlyphSet +# OrangeBoxbased 65 +# L4D 65 +# L4D2_2147plus 64 +vtidx_GetFontTall + OrangeBoxbased 67 + L4D 67 +vtidx_GetCharacterWidth + OrangeBoxbased 71 + L4D 71 + +# vi: sw=4 ts=4 noet tw=80 cc=80 |