diff --git a/src/game/game.cpp b/src/game/game.cpp index 13770ce..a2d21a1 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -580,6 +580,38 @@ namespace game return Dvar_RegisterVariant(name, game::DVAR_TYPE_STRING, flags, dvar_value, limits, desc); } + const char* Dvar_ValueToString(dvar_s* dvar, DvarValue dvarValue) + { + static const auto call_addr = SELECT(0x0, 0x5ECAB0); + + const char* answer; + + __asm + { + push dvarValue; + mov ecx, dvar; + call call_addr; + mov answer, eax; + add esp, 0x4; + } + + return answer; + } + + void Dvar_SetVariant(dvar_s* dvar, DvarValue val, DvarSetSource dvarSetSource) + { + static const auto call_addr = SELECT(0x0, 0x5EDA40); + + __asm + { + push dvarSetSource; + push val; + push dvar; + call call_addr; + add esp, 0xC; + } + } + int Path_FindPath(path_t* pPath, team_t eTeam, float* vStartPos, float* vGoalPos, int bAllowNegotiationLinks) { static const auto call_addr = SELECT(0x0, 0x4CF280); @@ -725,7 +757,7 @@ namespace game unsigned int __cdecl Path_ConvertNodeToIndex(const game::pathnode_t* node) { - return node - (*game::gameWorldCurrent)->path.nodes; + return node - (*gameWorldCurrent)->path.nodes; } game::pathnode_t* Path_GetNegotiationNode(const game::path_t* pPath) @@ -837,6 +869,58 @@ namespace game return gScrVarGlob[inst].childVariables[GetArrayVariableIndex(unsignedValue, inst, parentId)].hash.id; } + unsigned int __cdecl Scr_GetFunc(scriptInstance_t inst, unsigned int index) + { + VariableValue* value; // [esp+0h] [ebp-4h] + + if (index >= gScrVmPub[inst].outparamcount) + { + Scr_Error(utils::string::va("parameter %d does not exist", index + 1), inst, false); + return 0; + } + value = &gScrVmPub[inst].top[-index]; + if (value->type != VAR_FUNCTION) + { + gScrVarPub[inst].error_index = index + 1; + Scr_Error(utils::string::va("type %s is not a function", var_typename[value->type]), inst, false); + return 0; + } + return value->u.intValue - (unsigned int)gScrVarPub[inst].programBuffer; + } + + void Dvar_Reset(DvarSetSource dvarSetSource, dvar_s* dvar) + { + return Dvar_SetVariant(dvar, dvar->reset, dvarSetSource); + } + + void SV_SendServerCommand(client_s* clientArg, svscmd_type type, char* Format, ...) + { + client_s* i; // esi + va_list ArgList; // [esp+18h] [ebp+Ch] BYREF + + va_start(ArgList, Format); + _vsnprintf(tempServerCommandBuf, 0x20000u, Format, ArgList); + if (clientArg) + { + SV_AddServerCommand(clientArg, type, tempServerCommandBuf); + } + else + { + if ((*com_dedicated)->current.integer && !strncmp(tempServerCommandBuf, "print", 5u)) + { + Com_PrintF(CON_CHANNEL_SERVER, "broadcast: %s\n", SV_ExpandNewlines()); + } + for (auto i = 0; i < (*sv_maxclients)->current.integer; ++i) + { + auto client = &svs->clients[i]; + if (client->header.state >= CS_PRIMED) + { + SV_AddServerCommand(client, type, tempServerCommandBuf); + } + } + } + } + void Sentient_GetVelocity(sentient_s* self, float* vVelOut) { static const auto call_addr = SELECT(0x0, 0x5662A0); diff --git a/src/game/game.hpp b/src/game/game.hpp index 44d59a9..f6c4c3b 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -38,6 +38,8 @@ namespace game dvar_s* Dvar_RegisterInt(const char* name, int value, int min, int max, DvarFlags flags, const char* desc); dvar_s* Dvar_RegisterString(const char* name, const char* value, DvarFlags flags, const char* desc); + const char* Dvar_ValueToString(dvar_s* dvar, DvarValue dvarValue); + void Dvar_SetVariant(dvar_s* dvar, DvarValue val, DvarSetSource dvarSetSource); int Scr_GetInt(game::scriptInstance_t inst, unsigned int arg_index); void Scr_AddInt(game::scriptInstance_t inst, int value); @@ -99,6 +101,9 @@ namespace game VariableUnion Scr_GetObject(unsigned int index, scriptInstance_t inst); unsigned int GetArraySize(scriptInstance_t inst, unsigned int id); unsigned int GetArrayVariable(scriptInstance_t inst, unsigned int parentId, unsigned int unsignedValue); + unsigned int __cdecl Scr_GetFunc(scriptInstance_t inst, unsigned int index); + void Dvar_Reset(DvarSetSource dvarSetSource, dvar_s* dvar); + void SV_SendServerCommand(client_s* clientArg, svscmd_type type, char* Format, ...); void Sentient_GetVelocity(sentient_s* self, float* vVelOut); diff --git a/src/game/structs.hpp b/src/game/structs.hpp index b97648a..d724ed1 100644 --- a/src/game/structs.hpp +++ b/src/game/structs.hpp @@ -126,6 +126,81 @@ namespace game CON_BUILTIN_CHANNEL_COUNT = 0x22, }; + enum svscmd_type + { + SV_CMD_CAN_IGNORE = 0x0, + SV_CMD_RELIABLE = 0x1, + }; + + enum deployableCommand_t + { + DEPLOYABLE_CMD_NONE = 0x0, + DEPLOYABLE_CMD_WATER_SHEETING_FX = 0x21, + DEPLOYABLE_CMD_ROPE = 0x23, + DEPLOYABLE_CMD_WATER_PLOP = 0x24, + DEPLOYABLE_CMD_ELECTRIFIED = 0x28, + DEPLOYABLE_CMD_TELEPORTED = 0x29, + DEPLOYABLE_CMD_ENTITY_EVENT = 0x2A, + DEPLOYABLE_CMD_WATER_DROPS = 0x30, + DEPLOYABLE_CMD_BRIEFING_POPUP = 0x31, + DEPLOYABLE_CMD_PHYS_GRAVITY_DIR = 0x32, + DEPLOYABLE_CMD_CLEAR_CONFIGSTRING_RANGE = 0x33, + DEPLOYABLE_CMD_DOUBLE_VISION = 0x34, + DEPLOYABLE_CMD_GENERATE_CLIENT_SAVE = 0x35, + DEPLOYABLE_CMD_CLIENTSYS_STATE_CHANGE = 0x39, + DEPLOYABLE_CMD_COMMIT_CLIENT_SAVE = 0x3A, + DEPLOYABLE_CMD_RESET_CLIENTINFO = 0x3F, + DEPLOYABLE_CMD_EXPLODER = 0x40, + DEPLOYABLE_CMD_UNK1 = 0x41, + DEPLOYABLE_CMD_MAPRESTART_SAVE_PERSIST = 0x42, + DEPLOYABLE_CMD_SWITCH_OFFHAND = 0x43, + DEPLOYABLE_CMD_DEACTIVATE_REVERB = 0x44, + DEPLOYABLE_CMD_SET_CHANNEL_VOLUME = 0x45, + DEPLOYABLE_CMD_DEACTIVATE_CHANNEL_VOLUME = 0x46, + DEPLOYABLE_CMD_MENU_SHOW_NOTIFY = 0x4A, + DEPLOYABLE_CMD_PLAYER_MUTE = 0x4B, + DEPLOYABLE_CMD_CLOSE_INGAME_MENU = 0x4C, + DEPLOYABLE_CMD_SET_STAT_CHANGED = 0x4E, + DEPLOYABLE_CMD_RESET_GUN_PITCH = 0x4F, + DEPLOYABLE_CMD_START_AMPLIFY = 0x51, + DEPLOYABLE_CMD_STOP_AMPLIFY = 0x52, + DEPLOYABLE_CMD_REACHED_CHECKPOINT = 0x53, + DEPLOYABLE_CMD_RETICLE_START_LOCKON = 0x54, + DEPLOYABLE_CMD_FADE = 0x55, + DEPLOYABLE_CMD_OBJECTIVE_STATE = 0x56, + DEPLOYABLE_CMD_BURN = 0x57, + DEPLOYABLE_CMD_SLOW_TIMESCALE_OVER_TIME = 0x58, + DEPLOYABLE_CMD_DEATH_SCREEN = 0x59, + DEPLOYABLE_CMD_COOP_MESSAGE = 0x5E, + DEPLOYABLE_CMD_SWITCH_WEAPON = 0x61, + DEPLOYABLE_CMD_TAKE = 0x61, + DEPLOYABLE_CMD_PARSE_SCORES = 0x62, + DEPLOYABLE_CMD_ANNOUNCMENT = 0x63, + DEPLOYABLE_CMD_CONFIGSTRING_MODIFIED = 0x64, + DEPLOYABLE_CMD_GAMEMESSAGE = 0x65, + DEPLOYABLE_CMD_GAMEMESSAGE2 = 0x66, + DEPLOYABLE_CMD_BOLD_GAMEMESSAGE = 0x67, + DEPLOYABLE_CMD_CHATMESSAGE = 0x68, + DEPLOYABLE_CMD_DYN_ENT_DESTROYED = 0x6A, + DEPLOYABLE_CMD_SYSCMD_EQ = 0x6C, + DEPLOYABLE_CMD_SVSCMD_EQ_DEACTIVATE = 0x6D, + DEPLOYABLE_CMD_STOP_LOCAL_SOUND = 0x6B, + DEPLOYABLE_CMD_MAPRESTART_NO_SAVE_PERSIST = 0x6E, + DEPLOYABLE_CMD_SOUND_FADE = 0x71, + DEPLOYABLE_CMD_ACTIVATE_REVERB = 0x72, + DEPLOYABLE_CMD_PLAY_LOCAL_SOUND = 0x73, + DEPLOYABLE_CMD_OPEN_MENU = 0x74, + DEPLOYABLE_CMD_CLOSE_MENU = 0x75, + DEPLOYABLE_CMD_SET_CLIENT_DVAR = 0x76, + DEPLOYABLE_CMD_CL_DISCONNECT = 0x77, + DEPLOYABLE_CMD_COPY_INTO_BIG_CONFIGSTRING = 0x78, + DEPLOYABLE_CMD_CONCAT_BIG_CONFIGSTRING = 0x79, + DEPLOYABLE_CMD_CONCAT_BIG_CONFIGSTRING2 = 0x7A, + DEPLOYABLE_CMD_SHOW_VIEWMODEL = 0x7B, + DEPLOYABLE_CMD_FADING_BLUR = 0x7C, + DEPLOYABLE_CMD_HIDE_VIEWMODEL = 0x7D, + }; + struct CmdArgs { int nesting; @@ -143,6 +218,13 @@ namespace game void(__cdecl* function)(); }; + enum DvarSetSource + { + DVAR_SOURCE_INTERNAL = 0x0, + DVAR_SOURCE_EXTERNAL = 0x1, + DVAR_SOURCE_SCRIPT = 0x2, + }; + enum DvarFlags : unsigned __int16 { DVAR_FLAG_NONE = 0x0, @@ -4287,4 +4369,55 @@ namespace game unsigned __int16 Data3; unsigned __int8 Data4[8]; }; + + struct __declspec(align(4)) challenge_s + { + netadr_s adr; + int challenge; + int time; + int pingTime; + int firstTime; + int firstPing; + int connected; + int guid; + char PBguid[33]; + char clientPBguid[33]; + }; + + struct __declspec(align(16)) serverStatic_s + { + int cachedSnapshotFrames; + char gap4[22524]; + int field_5800; + char gap5804[1489916]; + int initialized; + int time; + int snapFlagServerBit; + int field_17140C; + client_s clients[4]; + int numSnapshotEntities; + int numSnapshotClients; + int numSnapshotActors; + int nextSnapshotEntities[4]; + int nextSnapshotClients[4]; + int nextSnapshotActors[4]; + entityState_s snapshotEntities[21504]; + clientState_s snapshotClients[4][64]; + actorState_s snapshotActors[4][512]; + int nextCachedSnapshotEntities; + int nextCachedSnapshotClients; + int awdd; + int nextCachedSnapshotFrames; + char gap_8D7D1C[136256]; + int nextHeartbeatTime; + char gap_8F9160[4]; + challenge_s challenges[1024]; + int numSnapshotAnimCmds; + int nextSnapshotAnimCmds[4]; + animCmdState_s snapshotAnimCmds[4][16384]; + int acaw; + int OOBProf; + char gap_BD7180[1791]; + char field_BD787F; + }; } \ No newline at end of file diff --git a/src/game/symbols.hpp b/src/game/symbols.hpp index c7c75f5..a7a26dc 100644 --- a/src/game/symbols.hpp +++ b/src/game/symbols.hpp @@ -8,6 +8,9 @@ namespace game WEAK symbol Com_PrintF{ 0x0, 0x59A2C0 }; WEAK symbol Dvar_RegisterVariant{ 0x0, 0x5EED90 }; + WEAK symbol Dvar_FindMalleableVar{ 0x0, 0x5EDE30 }; + WEAK symbol SV_AddServerCommand{ 0x0, 0x633D30 }; + WEAK symbol SV_ExpandNewlines{ 0x0, 0x633AD0 }; WEAK symbol Scr_AddArray { 0x0, 0x69AA50 }; WEAK symbol SL_GetStringOfSize { 0x0, 0x68DE50 }; @@ -16,8 +19,11 @@ namespace game // Variables + WEAK symbol tempServerCommandBuf{ 0x0, 0x2FCDC00 }; + WEAK symbol cmd_functions{ 0x0, 0x1F416F4 }; WEAK symbol cmd_args{ 0x0, 0x1F41670 }; + WEAK symbol svs{ 0x0, 0x23D5C80 }; WEAK symbol gameWorldCurrent{ 0x0, 0x8E1D80 }; WEAK symbol g_path{ 0x0, 0x1F2F700 }; WEAK symbol g_entities{ 0x0, 0x176C6F0 }; @@ -40,11 +46,13 @@ namespace game WEAK symbol com_developer{ 0x0, 0x1F55288 }; WEAK symbol com_logfile{ 0x0, 0x1F552BC }; WEAK symbol com_developer_script{ 0x0, 0x1F9646C }; + WEAK symbol com_dedicated{ 0x0, 0x212B2F4 }; WEAK symbol ai_pathNegotiationOverlapCost{ 0x0, 0x18FB224 }; WEAK symbol fs_homepath{ 0x0, 0x2123C1C }; WEAK symbol fs_game{ 0x0, 0x2122B00 }; WEAK symbol useFastFile{ 0x0, 0x1F552FC }; WEAK symbol sv_running{ 0x0, 0x1F552DC }; + WEAK symbol sv_maxclients{ 0x0, 0x23D5C30 }; WEAK symbol g_connectpaths{ 0x0, 0x18ECF8C }; WEAK symbol r_reflectionProbeGenerate{ 0x0, 0x3BFD478 };