From 2ac2bae63e91ef9d3cfa095e83091b1283c2e988 Mon Sep 17 00:00:00 2001 From: Stephen Toon Date: Tue, 23 Aug 2016 21:58:33 -0400 Subject: [PATCH 01/13] Start of Insurgency support. --- src/core/modules/cvars/insurgency/cvars.h | 50 + .../effects/insurgency/effects_base_wrap.h | 54 + src/core/modules/engines/insurgency/engines.h | 90 ++ .../modules/engines/insurgency/engines_wrap.h | 99 ++ .../entities/blade/entities_constants_wrap.h | 10 + .../entities/bms/entities_constants_wrap.h | 10 + .../entities/csgo/entities_constants_wrap.h | 10 + .../entities/entities_constants_wrap.cpp | 6 + .../modules/entities/insurgency/entities.h | 117 ++ .../insurgency/entities_constants_wrap.h | 100 ++ .../entities/insurgency/entities_datamaps.h | 59 + .../insurgency/entities_datamaps_wrap.h | 72 ++ .../insurgency/entities_factories_wrap.h | 55 + .../entities/insurgency/entities_props.h | 49 + .../entities/insurgency/entities_props_wrap.h | 80 ++ .../entities/insurgency/entities_wrap.h | 49 + .../entities/l4d2/entities_constants_wrap.h | 10 + .../orangebox/entities_constants_wrap.h | 10 + .../modules/globals/insurgency/globals_wrap.h | 56 + src/core/modules/keyvalues/keyvalues_wrap.cpp | 2 +- src/core/modules/messages/messages.cpp | 2 +- .../insurgency/players_constants_wrap.h | 56 + .../modules/players/insurgency/players_wrap.h | 39 + .../modules/steam/insurgency/steam_wrap.h | 70 ++ .../insurgency/weapons_constants_wrap.h | 40 + .../weapons/insurgency/weapons_scripts_wrap.h | 39 + src/core/patches/insurgency/patches.cpp | 35 + .../patches/insurgency/undefined_symbols.h | 65 ++ src/core/sp_main.cpp | 8 +- src/core/sp_main.h | 4 +- src/loader/loader_main.cpp | 4 +- src/loader/loader_main.h | 4 +- src/makefiles/branch/insurgency.cmake | 10 + src/patches/insurgency/public/networkvar.h | 823 +++++++++++++ src/patches/insurgency/public/tier1/convar.h | 1016 +++++++++++++++++ 35 files changed, 3191 insertions(+), 12 deletions(-) create mode 100644 src/core/modules/cvars/insurgency/cvars.h create mode 100644 src/core/modules/effects/insurgency/effects_base_wrap.h create mode 100644 src/core/modules/engines/insurgency/engines.h create mode 100644 src/core/modules/engines/insurgency/engines_wrap.h create mode 100644 src/core/modules/entities/insurgency/entities.h create mode 100644 src/core/modules/entities/insurgency/entities_constants_wrap.h create mode 100644 src/core/modules/entities/insurgency/entities_datamaps.h create mode 100644 src/core/modules/entities/insurgency/entities_datamaps_wrap.h create mode 100644 src/core/modules/entities/insurgency/entities_factories_wrap.h create mode 100644 src/core/modules/entities/insurgency/entities_props.h create mode 100644 src/core/modules/entities/insurgency/entities_props_wrap.h create mode 100644 src/core/modules/entities/insurgency/entities_wrap.h create mode 100644 src/core/modules/globals/insurgency/globals_wrap.h create mode 100644 src/core/modules/players/insurgency/players_constants_wrap.h create mode 100644 src/core/modules/players/insurgency/players_wrap.h create mode 100644 src/core/modules/steam/insurgency/steam_wrap.h create mode 100644 src/core/modules/weapons/insurgency/weapons_constants_wrap.h create mode 100644 src/core/modules/weapons/insurgency/weapons_scripts_wrap.h create mode 100644 src/core/patches/insurgency/patches.cpp create mode 100644 src/core/patches/insurgency/undefined_symbols.h create mode 100644 src/makefiles/branch/insurgency.cmake create mode 100644 src/patches/insurgency/public/networkvar.h create mode 100644 src/patches/insurgency/public/tier1/convar.h diff --git a/src/core/modules/cvars/insurgency/cvars.h b/src/core/modules/cvars/insurgency/cvars.h new file mode 100644 index 000000000..813d1fe23 --- /dev/null +++ b/src/core/modules/cvars/insurgency/cvars.h @@ -0,0 +1,50 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2014 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _CVARS_INSURGENCY_H +#define _CVARS_INSURGENCY_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "icvar.h" + + +//----------------------------------------------------------------------------- +// ICVar extension class. +//----------------------------------------------------------------------------- +class ICVarExt +{ +public: + static ConCommandBase* GetCommands(ICvar* pCvar) + { + ICvar::Iterator iter(pCvar); + iter.SetFirst(); + return iter.Get(); + }; +}; + +#endif // _CVARS_INSURGENCY_H diff --git a/src/core/modules/effects/insurgency/effects_base_wrap.h b/src/core/modules/effects/insurgency/effects_base_wrap.h new file mode 100644 index 000000000..4618f1e27 --- /dev/null +++ b/src/core/modules/effects/insurgency/effects_base_wrap.h @@ -0,0 +1,54 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2012-2015 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _EFFECTS_BASE_WRAP_INSURGENCY_H +#define _EFFECTS_BASE_WRAP_INSURGENCY_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "game/shared/itempents.h" +#include "toolframework/itoolentity.h" +#include "game/server/basetempentity.h" + + +//----------------------------------------------------------------------------- +// External variables. +//----------------------------------------------------------------------------- +extern IServerTools *servertools; + + +//----------------------------------------------------------------------------- +// Exports CBaseTempEntity. +//----------------------------------------------------------------------------- +template +void export_engine_specific_temp_entity(T _base, U TempEntity) +{ + // Nothing specific to Insurgency... +} + + +#endif // _EFFECTS_BASE_WRAP_INSURGENCY_H diff --git a/src/core/modules/engines/insurgency/engines.h b/src/core/modules/engines/insurgency/engines.h new file mode 100644 index 000000000..2557e5627 --- /dev/null +++ b/src/core/modules/engines/insurgency/engines.h @@ -0,0 +1,90 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2014 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _ENGINES_INSURGENCY_H +#define _ENGINES_INSURGENCY_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "engine/IEngineSound.h" + + +//----------------------------------------------------------------------------- +// IVEngineServer extension class. +//----------------------------------------------------------------------------- +class GameIVEngineServerExt +{ +public: + static bool IsMapValid(IVEngineServer* pServer, const char* map_name) + { + return pServer->IsMapValid(map_name); + } +}; + + +//----------------------------------------------------------------------------- +// IEngineSound extension class. +//----------------------------------------------------------------------------- +class IEngineSoundExt +{ +public: + static void EmitSound(IEngineSound* pEngineSound, IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSample, + float flVolume, float flAttenuation, int iFlags, int iPitch, const Vector *pOrigin, const Vector *pDirection, + tuple origins, bool bUpdatePositions, float soundtime, int speakerentity) + { + CUtlVector *pUtlVecOrigins = NULL; + CUtlVector vecOrigins; + if (len(origins) > 0) + { + pUtlVecOrigins = &vecOrigins; + for(int i=0; i < len(origins); i++) + { + vecOrigins.AddToTail(extract(origins[i])); + } + } + + pEngineSound->EmitSound(filter, iEntIndex, iChannel, pSample, -1, pSample, flVolume, flAttenuation, 0, iFlags, iPitch, pOrigin, pDirection, + pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity); + } + + static void StopSound(IEngineSound* pEngineSound, int iEntIndex, int iChannel, const char *pSample) + { + pEngineSound->StopSound(iEntIndex, iChannel, pSample, -1); + } +}; + + +//--------------------------------------------------------------------------------- +// IEngineTrace +//--------------------------------------------------------------------------------- +inline int GetPointContents(const Vector &vecAbsPosition, IHandleEntity** ppEntity) +{ + return enginetrace->GetPointContents(vecAbsPosition, MASK_ALL, ppEntity); +} + + +#endif // _ENGINES_INSURGENCY_H diff --git a/src/core/modules/engines/insurgency/engines_wrap.h b/src/core/modules/engines/insurgency/engines_wrap.h new file mode 100644 index 000000000..840c6df16 --- /dev/null +++ b/src/core/modules/engines/insurgency/engines_wrap.h @@ -0,0 +1,99 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2014 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _ENGINES_WRAP_INSURGENCY_H +#define _ENGINES_WRAP_INSURGENCY_H + +//--------------------------------------------------------------------------------- +// Includes. +//--------------------------------------------------------------------------------- +#include "eiface.h" +#include "engine/IEngineSound.h" +#include "engine/IEngineTrace.h" + + +//--------------------------------------------------------------------------------- +// External variables. +//--------------------------------------------------------------------------------- +extern IEngineTrace* enginetrace; + + +//--------------------------------------------------------------------------------- +// IVEngineServer visitor function. +//--------------------------------------------------------------------------------- +template +T IVEngineServer_Visitor(T cls) +{ + cls + .add_property("game_server_steamid", + make_function( + &IVEngineServer::GetGameServerSteamID, + reference_existing_object_policy() + ), + "Returns the SteamID of the game server." + ) + + .add_property("server_version", + &IVEngineServer::GetServerVersion, + "Returns the version of the server." + ) + + .def("create_fake_client_ex", + &IVEngineServer::CreateFakeClientEx, + reference_existing_object_policy() + ) + + .add_property("server", + make_function( + &IVEngineServer::GetIServer, + reference_existing_object_policy() + ) + ) + + .add_property("achievement_mgr", + make_function( + &IVEngineServer::GetAchievementMgr, + reference_existing_object_policy() + ), + &IVEngineServer::SetAchievementMgr, + "Return the achievement manager." + ) + ; + + return cls; +} + + +//--------------------------------------------------------------------------------- +// IEngineSound visitor function. +//--------------------------------------------------------------------------------- +template +T IEngineSound_Visitor(T cls) +{ + return cls; +} + +#endif // _ENGINES_WRAP_INSURGENCY_H diff --git a/src/core/modules/entities/blade/entities_constants_wrap.h b/src/core/modules/entities/blade/entities_constants_wrap.h index fac77a4a8..b3b33fb61 100644 --- a/src/core/modules/entities/blade/entities_constants_wrap.h +++ b/src/core/modules/entities/blade/entities_constants_wrap.h @@ -43,6 +43,16 @@ void export_engine_specific_damage_types(T _constants) } +//----------------------------------------------------------------------------- +// Exports entity state flags. +//----------------------------------------------------------------------------- +template +void export_engine_specific_entity_state_flags(T _constants) +{ + // Nothing specific to Blade... +} + + //----------------------------------------------------------------------------- // Exports SolidFlags_t. //----------------------------------------------------------------------------- diff --git a/src/core/modules/entities/bms/entities_constants_wrap.h b/src/core/modules/entities/bms/entities_constants_wrap.h index 7de3462e2..9d0f20691 100644 --- a/src/core/modules/entities/bms/entities_constants_wrap.h +++ b/src/core/modules/entities/bms/entities_constants_wrap.h @@ -43,6 +43,16 @@ void export_engine_specific_damage_types(T _constants) } +//----------------------------------------------------------------------------- +// Exports entity state flags. +//----------------------------------------------------------------------------- +template +void export_engine_specific_entity_state_flags(T _constants) +{ + // Nothing specific to BMS... +} + + //----------------------------------------------------------------------------- // Exports SolidFlags_t. //----------------------------------------------------------------------------- diff --git a/src/core/modules/entities/csgo/entities_constants_wrap.h b/src/core/modules/entities/csgo/entities_constants_wrap.h index 1392edbef..2d46f37fe 100644 --- a/src/core/modules/entities/csgo/entities_constants_wrap.h +++ b/src/core/modules/entities/csgo/entities_constants_wrap.h @@ -44,6 +44,16 @@ void export_engine_specific_damage_types(T _constants) } +//----------------------------------------------------------------------------- +// Exports entity state flags. +//----------------------------------------------------------------------------- +template +void export_engine_specific_entity_state_flags(T _constants) +{ + // Nothing specific to CS:GO... +} + + //----------------------------------------------------------------------------- // Exports SolidFlags_t. //----------------------------------------------------------------------------- diff --git a/src/core/modules/entities/entities_constants_wrap.cpp b/src/core/modules/entities/entities_constants_wrap.cpp index 0adec6121..f47b07917 100644 --- a/src/core/modules/entities/entities_constants_wrap.cpp +++ b/src/core/modules/entities/entities_constants_wrap.cpp @@ -159,6 +159,12 @@ void export_entity_states(scope _constants) _constants.attr("FL_DISSOLVING") = FL_DISSOLVING; _constants.attr("FL_TRANSRAGDOLL") = FL_TRANSRAGDOLL; _constants.attr("FL_UNBLOCKABLE_BY_PLAYER") = FL_UNBLOCKABLE_BY_PLAYER; + + // Insurgency specific constants... + _constants.attr("FL_FREEZING") = -LONG_MAX; + + // Engine specific stuff... + export_engine_specific_entity_state_flags(_constants); } diff --git a/src/core/modules/entities/insurgency/entities.h b/src/core/modules/entities/insurgency/entities.h new file mode 100644 index 000000000..b93ca8c83 --- /dev/null +++ b/src/core/modules/entities/insurgency/entities.h @@ -0,0 +1,117 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2015 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _ENTITIES_INSURGENCY_H +#define _ENTITIES_INSURGENCY_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "dt_send.h" +#include "server_class.h" +#include "game/shared/ehandle.h" +#include "isaverestore.h" +#include "datamap.h" +#include "game/shared/takedamageinfo.h" + + +//----------------------------------------------------------------------------- +// CTakeDamageInfo wrapper class. +//----------------------------------------------------------------------------- +class TakeDamageInfoWrapper: public TakeDamageInfoBaseWrapper +{ +public: + int get_penetrated() + { + return m_iObjectsPenetrated; + } + + void set_penetrated(int iPenetrated) + { + m_iObjectsPenetrated = iPenetrated; + } + + uint32 get_bullet() + { + return m_uiBulletID; + } + + void set_bullet(uint32 uiBullet) + { + m_uiBulletID = uiBullet; + } + + uint8 get_recoil() + { + return m_uiRecoilIndex; + } + + void set_recoil(uint8 uiRecoil) + { + m_uiRecoilIndex = uiRecoil; + } +}; + + +//----------------------------------------------------------------------------- +// CTakeDamageInfo extension class. +//----------------------------------------------------------------------------- +class TakeDamageInfoExt +{ +public: + static int get_penetrated(CTakeDamageInfo *pTakeDamageInfo) + { + return ((TakeDamageInfoWrapper *)pTakeDamageInfo)->get_penetrated(); + } + + static void set_penetrated(CTakeDamageInfo *pTakeDamageInfo, int iPenetrated) + { + ((TakeDamageInfoWrapper *)pTakeDamageInfo)->set_penetrated(iPenetrated); + } + + static uint32 get_bullet(CTakeDamageInfo *pTakeDamageInfo) + { + return ((TakeDamageInfoWrapper *)pTakeDamageInfo)->get_bullet(); + } + + static void set_bullet(CTakeDamageInfo *pTakeDamageInfo, uint32 uiBullet) + { + ((TakeDamageInfoWrapper *)pTakeDamageInfo)->set_bullet(uiBullet); + } + + static uint8 get_recoil(CTakeDamageInfo *pTakeDamageInfo) + { + return ((TakeDamageInfoWrapper *)pTakeDamageInfo)->get_recoil(); + } + + static void set_recoil(CTakeDamageInfo *pTakeDamageInfo, uint8 uiRecoil) + { + ((TakeDamageInfoWrapper *)pTakeDamageInfo)->set_recoil(uiRecoil); + } +}; + + +#endif // _ENTITIES_INSURGENCY_H diff --git a/src/core/modules/entities/insurgency/entities_constants_wrap.h b/src/core/modules/entities/insurgency/entities_constants_wrap.h new file mode 100644 index 000000000..20dba22cd --- /dev/null +++ b/src/core/modules/entities/insurgency/entities_constants_wrap.h @@ -0,0 +1,100 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2015 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _ENTITIES_CONSTANTS_INSURGENCY_WRAP_H +#define _ENTITIES_CONSTANTS_INSURGENCY_WRAP_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "utilities/wrap_macros.h" + + +//----------------------------------------------------------------------------- +// Exports damage types. +//----------------------------------------------------------------------------- +template +void export_engine_specific_damage_types(T _constants) +{ + // Nothing specific to Insurgency... +} + + +//----------------------------------------------------------------------------- +// Exports entity state flags. +//----------------------------------------------------------------------------- +template +void export_engine_specific_entity_state_flags(T _constants) +{ + _constants.attr("FL_FREEZING") = FL_FREEZING; +} + + +//----------------------------------------------------------------------------- +// Exports SolidFlags_t. +//----------------------------------------------------------------------------- +template +void export_engine_specific_solid_flags(T _constants, U SolidFlags) +{ + SolidFlags.value("TRIGGER_TOUCH_PLAYER", FSOLID_TRIGGER_TOUCH_PLAYER); + SolidFlags.value("NOT_MOVEABLE", FSOLID_NOT_MOVEABLE); +} + + +//----------------------------------------------------------------------------- +// Exports entity effects. +//----------------------------------------------------------------------------- +template +void export_engine_specific_entity_effects(T _constants) +{ + // Nothing specific to Insurgency... +} + + +//----------------------------------------------------------------------------- +// Exports RenderFx_t. +//----------------------------------------------------------------------------- +template +void export_engine_specific_render_effects(T _constants, U RenderEffects) +{ + RenderEffects.value("FADE_OUT", kRenderFxFadeOut); + RenderEffects.value("FADE_IN", kRenderFxFadeIn); + RenderEffects.value("PULSE_FAST_WIDER", kRenderFxPulseFastWider); +} + + +//----------------------------------------------------------------------------- +// Exports Collision_Group_t. +//----------------------------------------------------------------------------- +template +void export_engine_specific_collision_group(T _constants, U CollisionGroup) +{ + CollisionGroup.value("PZ_CLIP", COLLISION_GROUP_PZ_CLIP); + CollisionGroup.value("DEBRIS_BLOCK_PROJECTILE", COLLISION_GROUP_DEBRIS_BLOCK_PROJECTILE); +} + + +#endif // _ENTITIES_CONSTANTS_INSURGENCY_WRAP_H diff --git a/src/core/modules/entities/insurgency/entities_datamaps.h b/src/core/modules/entities/insurgency/entities_datamaps.h new file mode 100644 index 000000000..ba0ac5930 --- /dev/null +++ b/src/core/modules/entities/insurgency/entities_datamaps.h @@ -0,0 +1,59 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2014 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _ENTITIES_DATAMAP_INSURGENCY_H +#define _ENTITIES_DATAMAP_INSURGENCY_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "datamap.h" + + +//----------------------------------------------------------------------------- +// typedescription_t extension class. +//----------------------------------------------------------------------------- +class TypeDescriptionExt +{ +public: + static int get_offset(const typedescription_t& pTypeDesc) + { + return pTypeDesc.fieldOffset; + } + + static int get_flat_offset(const typedescription_t& pTypeDesc) + { + return pTypeDesc.flatOffset[TD_OFFSET_NORMAL]; + } + + static int get_packed_offset(const typedescription_t& pTypeDesc) + { + return pTypeDesc.flatOffset[TD_OFFSET_PACKED]; + } +}; + + +#endif // _ENTITIES_DATAMAP_INSURGENCY_WRAP_H diff --git a/src/core/modules/entities/insurgency/entities_datamaps_wrap.h b/src/core/modules/entities/insurgency/entities_datamaps_wrap.h new file mode 100644 index 000000000..e81437b1a --- /dev/null +++ b/src/core/modules/entities/insurgency/entities_datamaps_wrap.h @@ -0,0 +1,72 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2014 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _ENTITIES_DATAMAPS_INSURGENCY_H +#define _ENTITIES_DATAMAPS_INSURGENCY_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "entities_datamaps.h" + + +//----------------------------------------------------------------------------- +// Exports datamap_t. +//----------------------------------------------------------------------------- +template +void export_engine_specific_datamap(T _datamaps, U DataMap) +{ + DataMap.def_readonly("packed_size", &datamap_t::m_nPackedSize); + + // TODO: Expose optimized_datamap_t... + // DataMap.def_readonly("optimized_datamap", &datamap_t::m_pOptimizedDataMap); +} + + +//----------------------------------------------------------------------------- +// Exports typedescription_t. +//----------------------------------------------------------------------------- +template +void export_engine_specific_type_description(T _datamaps, U TypeDescription) +{ + TypeDescription.add_property("flat_offset", &TypeDescriptionExt::get_flat_offset); + TypeDescription.add_property("packed_offset", &TypeDescriptionExt::get_packed_offset); + TypeDescription.def_readonly("flat_group", &typedescription_t::flatGroup); +} + + +//----------------------------------------------------------------------------- +// Exports fieldtype_t. +//----------------------------------------------------------------------------- +template +void export_engine_specific_field_types(T _datamaps, U FieldTypes) +{ + FieldTypes.value("INTEGER64", FIELD_INTEGER64); + FieldTypes.value("VECTOR4D", FIELD_VECTOR4D); +} + + +#endif // _ENTITIES_DATAMAPS_INSURGENCY_H diff --git a/src/core/modules/entities/insurgency/entities_factories_wrap.h b/src/core/modules/entities/insurgency/entities_factories_wrap.h new file mode 100644 index 000000000..6e508a4d1 --- /dev/null +++ b/src/core/modules/entities/insurgency/entities_factories_wrap.h @@ -0,0 +1,55 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2014 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _ENTITIES_FACTORIES_WRAP_INSURGENCY_H +#define _ENTITIES_FACTORIES_WRAP_INSURGENCY_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "utilities/wrap_macros.h" +#include "toolframework/itoolentity.h" +#include "utilities/conversions.h" +#include "modules/memory/memory_tools.h" + + +//----------------------------------------------------------------------------- +// External variables. +//----------------------------------------------------------------------------- +extern IServerTools *servertools; + + +//----------------------------------------------------------------------------- +// Exports CEntityFactoryDictionary. +//----------------------------------------------------------------------------- +template +void export_engine_specific_entity_factory_dictionary(T _factories, U EntityFactoryDictionary) +{ + // Nothing specific to Insurgency... +} + + +#endif // _ENTITIES_FACTORIES_WRAP_INSURGENCY_H diff --git a/src/core/modules/entities/insurgency/entities_props.h b/src/core/modules/entities/insurgency/entities_props.h new file mode 100644 index 000000000..27317f4aa --- /dev/null +++ b/src/core/modules/entities/insurgency/entities_props.h @@ -0,0 +1,49 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2015 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _ENTITIES_PROPS_INSURGENCY_H +#define _ENTITIES_PROPS_INSURGENCY_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "server_class.h" + + +//----------------------------------------------------------------------------- +// ServerClass extension class. +//----------------------------------------------------------------------------- +class ServerClassExt +{ +public: + static const char *get_name(ServerClass *pServerClass) + { + return (const char *)pServerClass->m_pNetworkName; + } +}; + + +#endif // _ENTITIES_PROPS_INSURGENCY_H diff --git a/src/core/modules/entities/insurgency/entities_props_wrap.h b/src/core/modules/entities/insurgency/entities_props_wrap.h new file mode 100644 index 000000000..b8bbb3b83 --- /dev/null +++ b/src/core/modules/entities/insurgency/entities_props_wrap.h @@ -0,0 +1,80 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2015 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _ENTITIES_PROPS_WRAP_INSURGENCY_H +#define _ENTITIES_PROPS_WRAP_INSURGENCY_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "dt_common.h" +#include "dt_send.h" +#include "entities_props.h" + + +//----------------------------------------------------------------------------- +// Expose ServerClass. +//----------------------------------------------------------------------------- +template +void export_engine_specific_server_class(T _props, U ServerClass_) +{ + ServerClass_.add_property("name", &ServerClassExt::get_name); +} + + +//----------------------------------------------------------------------------- +// Expose SendProp. +//----------------------------------------------------------------------------- +template +void export_engine_specific_send_prop(T _props, U SendProp_) +{ + SendProp_.add_property("priority", &SendProp::GetPriority); + SendProp_.def("get_priority", &SendProp::GetPriority); +} + + +//----------------------------------------------------------------------------- +// Expose SendPropType. +//----------------------------------------------------------------------------- +template +void export_engine_specific_send_prop_types(T _props, U SendPropType_) +{ + SendPropType_.value("INT64", DPT_Int64); +} + + +//----------------------------------------------------------------------------- +// Expose SendPropVariant. +//----------------------------------------------------------------------------- +template +void export_engine_specific_send_prop_variant(T _props, U SendPropVariant) +{ + SendPropVariant.def("get_int64", &SendPropVariantExt::get_typed_value); + SendPropVariant.def("get_int64", &SendPropVariantExt::get_typed_value); +} + + +#endif // _ENTITIES_PROPS_WRAP_INSURGENCY_H diff --git a/src/core/modules/entities/insurgency/entities_wrap.h b/src/core/modules/entities/insurgency/entities_wrap.h new file mode 100644 index 000000000..217f87c16 --- /dev/null +++ b/src/core/modules/entities/insurgency/entities_wrap.h @@ -0,0 +1,49 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2014 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _ENTITIES_WRAP_INSURGENCY_H +#define _ENTITIES_WRAP_INSURGENCY_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "entities.h" + + +//----------------------------------------------------------------------------- +// Exports CTakeDamageInfo. +//----------------------------------------------------------------------------- +template +void export_engine_specific_take_damage_info(T _entities, U TakeDamageInfo) +{ + TakeDamageInfo.add_property("radius", &CTakeDamageInfo::GetRadius, &CTakeDamageInfo::SetRadius); + TakeDamageInfo.add_property("penetrated", &TakeDamageInfoExt::get_penetrated, &TakeDamageInfoExt::set_penetrated); + TakeDamageInfo.add_property("bullet", &TakeDamageInfoExt::get_bullet, &TakeDamageInfoExt::set_bullet); + TakeDamageInfo.add_property("recoil", &TakeDamageInfoExt::get_recoil, &TakeDamageInfoExt::set_recoil); +} + + +#endif // _ENTITIES_WRAP_INSURGENCY_H diff --git a/src/core/modules/entities/l4d2/entities_constants_wrap.h b/src/core/modules/entities/l4d2/entities_constants_wrap.h index 8c7075f3c..f502a8812 100644 --- a/src/core/modules/entities/l4d2/entities_constants_wrap.h +++ b/src/core/modules/entities/l4d2/entities_constants_wrap.h @@ -43,6 +43,16 @@ void export_engine_specific_damage_types(T _constants) } +//----------------------------------------------------------------------------- +// Exports entity state flags. +//----------------------------------------------------------------------------- +template +void export_engine_specific_entity_state_flags(T _constants) +{ + // Nothing specific to Left4Dead2... +} + + //----------------------------------------------------------------------------- // Exports SolidFlags_t. //----------------------------------------------------------------------------- diff --git a/src/core/modules/entities/orangebox/entities_constants_wrap.h b/src/core/modules/entities/orangebox/entities_constants_wrap.h index 591f3fa72..4a69138f0 100644 --- a/src/core/modules/entities/orangebox/entities_constants_wrap.h +++ b/src/core/modules/entities/orangebox/entities_constants_wrap.h @@ -46,6 +46,16 @@ void export_engine_specific_damage_types(T _constants) } +//----------------------------------------------------------------------------- +// Exports entity state flags. +//----------------------------------------------------------------------------- +template +void export_engine_specific_entity_state_flags(T _constants) +{ + // Nothing specific to OrangeBox... +} + + //----------------------------------------------------------------------------- // Exports SolidFlags_t. //----------------------------------------------------------------------------- diff --git a/src/core/modules/globals/insurgency/globals_wrap.h b/src/core/modules/globals/insurgency/globals_wrap.h new file mode 100644 index 000000000..bd8fa3e12 --- /dev/null +++ b/src/core/modules/globals/insurgency/globals_wrap.h @@ -0,0 +1,56 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2012 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _GLOBALS_WRAP_INSURGENCY_H +#define _GLOBALS_WRAP_INSURGENCY_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "edict.h" + + +//----------------------------------------------------------------------------- +// CGlobalVarsBase visitor method. +//----------------------------------------------------------------------------- +template +T GlobalsBase_Visitor(T cls) +{ + return cls; +} + + +//----------------------------------------------------------------------------- +// CGlobalVars visitor method. +//----------------------------------------------------------------------------- +template +T Globals_Visitor(T cls) +{ + return cls; +} + + +#endif // _GLOBALS_WRAP_INSURGENCY_H diff --git a/src/core/modules/keyvalues/keyvalues_wrap.cpp b/src/core/modules/keyvalues/keyvalues_wrap.cpp index 0b455b3a1..0b9874e1e 100644 --- a/src/core/modules/keyvalues/keyvalues_wrap.cpp +++ b/src/core/modules/keyvalues/keyvalues_wrap.cpp @@ -309,7 +309,7 @@ void export_keyvalues_types(scope _keyvalues) KeyValuesType.value("COLOR", KeyValues::TYPE_COLOR); KeyValuesType.value("UNINT64", KeyValues::TYPE_UINT64); -#ifdef ENGINE_CSGO +#if defined(ENGINE_CSGO) || defined(ENGINE_INSURGENCY) // TODO: Move this to a engine specific file KeyValuesType.value("COMPILED_INT_BYTE", KeyValues::TYPE_COMPILED_INT_BYTE); KeyValuesType.value("COMPILED_INT_0", KeyValues::TYPE_COMPILED_INT_0); diff --git a/src/core/modules/messages/messages.cpp b/src/core/modules/messages/messages.cpp index 2cda01e11..5550fe3a8 100644 --- a/src/core/modules/messages/messages.cpp +++ b/src/core/modules/messages/messages.cpp @@ -63,7 +63,7 @@ CUserMessage::CUserMessage(IRecipientFilter& recipients, const char* message_nam BOOST_RAISE_EXCEPTION(PyExc_NameError, "Invalid message name: '%s'.", message_name); } - #if defined(ENGINE_LEFT4DEAD2) || defined(ENGINE_BLADE) + #if defined(ENGINE_LEFT4DEAD2) || defined(ENGINE_BLADE) || defined(ENGINE_INSURGENCY) m_buffer = engine->UserMessageBegin(&recipients, m_index, message_name); #else m_buffer = engine->UserMessageBegin(&recipients, m_index); diff --git a/src/core/modules/players/insurgency/players_constants_wrap.h b/src/core/modules/players/insurgency/players_constants_wrap.h new file mode 100644 index 000000000..012402403 --- /dev/null +++ b/src/core/modules/players/insurgency/players_constants_wrap.h @@ -0,0 +1,56 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2015 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _PLAYERS_CONSTANTS_INSURGENCY_WRAP_H +#define _PLAYERS_CONSTANTS_INSURGENCY_WRAP_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "utilities/wrap_macros.h" + + +//----------------------------------------------------------------------------- +// Exports DamageTypes. +//----------------------------------------------------------------------------- +template +void export_engine_specific_player_buttons(T _constants) +{ + // Nothing specific to Insurgency... +} + + +//----------------------------------------------------------------------------- +// Exports HideHudFlags +//----------------------------------------------------------------------------- +template +void export_engine_specific_hide_hud_flags(T _constants) +{ + // Nothing specific to Insurgency... +} + + +#endif // _PLAYERS_CONSTANTS_INSURGENCY_WRAP_H diff --git a/src/core/modules/players/insurgency/players_wrap.h b/src/core/modules/players/insurgency/players_wrap.h new file mode 100644 index 000000000..0dbbb4750 --- /dev/null +++ b/src/core/modules/players/insurgency/players_wrap.h @@ -0,0 +1,39 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2012-2015 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _PLAYERS_WRAP_INSURGENCY_H +#define _PLAYERS_WRAP_INSURGENCY_H + + +//----------------------------------------------------------------------------- +// IPlayerInfo extension class +//----------------------------------------------------------------------------- +template +void export_engine_specific_user_cmd(scope _players, T UserCmd) +{ +} + +#endif // _PLAYERS_WRAP_INSURGENCY_H diff --git a/src/core/modules/steam/insurgency/steam_wrap.h b/src/core/modules/steam/insurgency/steam_wrap.h new file mode 100644 index 000000000..1168b969b --- /dev/null +++ b/src/core/modules/steam/insurgency/steam_wrap.h @@ -0,0 +1,70 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2015 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _STEAM_WRAP_INSURGENCY_H +#define _STEAM_WRAP_INSURGENCY_H + +template +void export_engine_specific_steamid(scope _steam, T SteamID) +{ + SteamID.def( + "create_blank_anonymous_user_account", + &CSteamID::CreateBlankAnonUserLogon, + "Create an anonymous user login to be filled in by the AM.", + ("universe") + ); + + SteamID.def( + "is_lobby", + &CSteamID::IsLobby, + "Return True if this is a lobby account ID." + ); + + SteamID.def( + "is_anonymous_account", + &CSteamID::BAnonAccount, + "Return True if this is an anonymous account." + ); + + SteamID.def( + "is_anonymous_user_account", + &CSteamID::BAnonUserAccount, + "Return True if this is an anonymous user account." + ); +} + +template +void export_engine_specific_universe(scope _steam, T Universe) +{ + Universe.value("RC", k_EUniverseRC); +} + +template +void export_engine_specific_account_type(scope _steam, T AccountType) +{ +} + +#endif // _STEAM_WRAP_INSURGENCY_H diff --git a/src/core/modules/weapons/insurgency/weapons_constants_wrap.h b/src/core/modules/weapons/insurgency/weapons_constants_wrap.h new file mode 100644 index 000000000..e801b1200 --- /dev/null +++ b/src/core/modules/weapons/insurgency/weapons_constants_wrap.h @@ -0,0 +1,40 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2015 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _WEAPONS_CONSTANTS_INSURGENCY_WRAP_H +#define _WEAPONS_CONSTANTS_INSURGENCY_WRAP_H + +//----------------------------------------------------------------------------- +// Exports WeaponSound_t. +//----------------------------------------------------------------------------- +template +void export_engine_specific_weapon_sound(T _constants, U WeaponSound) +{ + WeaponSound.value("FAST_RELOAD", FAST_RELOAD); +} + + +#endif // _WEAPONS_CONSTANTS_INSURGENCY_WRAP_H diff --git a/src/core/modules/weapons/insurgency/weapons_scripts_wrap.h b/src/core/modules/weapons/insurgency/weapons_scripts_wrap.h new file mode 100644 index 000000000..e757cdcc9 --- /dev/null +++ b/src/core/modules/weapons/insurgency/weapons_scripts_wrap.h @@ -0,0 +1,39 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2015 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef _WEAPONS_SCRIPTS_INSURGENCY_WRAP_H +#define _WEAPONS_SCRIPTS_INSURGENCY_WRAP_H + +//----------------------------------------------------------------------------- +// Expose WeaponDataBase_t. +//----------------------------------------------------------------------------- +template +void export_engine_specific_weapon_database(T _scripts) +{ + // Nothing specific to Insurgency... +} + +#endif // _WEAPONS_SCRIPTS_INSURGENCY_WRAP_H diff --git a/src/core/patches/insurgency/patches.cpp b/src/core/patches/insurgency/patches.cpp new file mode 100644 index 000000000..a4fe5121b --- /dev/null +++ b/src/core/patches/insurgency/patches.cpp @@ -0,0 +1,35 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2012 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#include "convar.h" +#ifndef PATCH_CONVAR_H_PUBLIC_FLAGS +#error "Make ConCommandBase::m_nFlags public." +#endif + +#include "utilities/baseentity.h" +#ifndef PATCH_NETWORK_HANDLE_BASE_DEFINITION +#error "We need the CNetworkHandle definition..." +#endif diff --git a/src/core/patches/insurgency/undefined_symbols.h b/src/core/patches/insurgency/undefined_symbols.h new file mode 100644 index 000000000..642c04462 --- /dev/null +++ b/src/core/patches/insurgency/undefined_symbols.h @@ -0,0 +1,65 @@ +/** +* ============================================================================= +* Source Python +* Copyright (C) 2015 Source Python Development Team. All rights reserved. +* ============================================================================= +* +* This program is free software; you can redistribute it and/or modify it under +* the terms of the GNU General Public License, version 3.0, as published by the +* Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along with +* this program. If not, see . +* +* As a special exception, the Source Python Team gives you permission +* to link the code of this program (as well as its derivative works) to +* "Half-Life 2," the "Source Engine," and any Game MODs that run on software +* by the Valve Corporation. You must obey the GNU General Public License in +* all respects for all other code used. Additionally, the Source.Python +* Development Team grants this exception to all derivative works. +*/ + +#ifndef UNDEFINED_SYMBOLS_INSURGENCY_H +#define UNDEFINED_SYMBOLS_INSURGENCY_H + +//----------------------------------------------------------------------------- +// Includes. +//----------------------------------------------------------------------------- +#include "dt_send.h" +#include "game/shared/ehandle.h" +#include "isaverestore.h" +#include "datamap.h" +#include "game/shared/takedamageinfo.h" + + +//----------------------------------------------------------------------------- +// CTakeDamageInfo constructor declaration. +//----------------------------------------------------------------------------- +CTakeDamageInfo::CTakeDamageInfo() +{ + m_vecDamageForce = vec3_origin; + m_vecDamagePosition = vec3_origin; + m_vecReportedPosition = vec3_origin; + m_hInflictor = NULL; + m_hAttacker = NULL; + m_hWeapon = NULL; + m_flDamage = 0.0f; + m_flMaxDamage = 0.0f; + m_flBaseDamage = BASEDAMAGE_NOT_SPECIFIED; + m_bitsDamageType = 0; + m_iDamageCustom = 0; + m_iDamageStats = 0; + m_iAmmoType = -1; + m_flRadius = 0.0f; + m_iDamagedOtherPlayers = 0; + m_iObjectsPenetrated = 0; + m_uiBulletID = 0; + m_uiRecoilIndex = 0; +} + +#endif // _UNDEFINED_SYMBOLS_INSURGENCY_H diff --git a/src/core/sp_main.cpp b/src/core/sp_main.cpp index 8f6da379d..5122d937c 100644 --- a/src/core/sp_main.cpp +++ b/src/core/sp_main.cpp @@ -195,7 +195,7 @@ CSourcePython::~CSourcePython() //----------------------------------------------------------------------------- bool CSourcePython::Load( CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory ) { -#if defined(ENGINE_CSGO) || defined(ENGINE_BLADE) +#if defined(ENGINE_CSGO) || defined(ENGINE_BLADE) || defined(ENGINE_INSURGENCY) DevMsg(1, MSG_PREFIX "Connecting interfaces...\n"); ConnectInterfaces(&interfaceFactory, 1); #else @@ -275,7 +275,7 @@ void CSourcePython::Unload( void ) ConVar_Unregister( ); // New in CSGO... -#if defined(ENGINE_CSGO) || defined(ENGINE_BLADE) +#if defined(ENGINE_CSGO) || defined(ENGINE_BLADE) || defined(ENGINE_INSURGENCY) DevMsg(1, MSG_PREFIX "Disconnecting interfaces...\n"); DisconnectInterfaces(); #else @@ -448,7 +448,7 @@ PLUGIN_RESULT CSourcePython::ClientCommand( edict_t *pEntity, const CCommand &ar //----------------------------------------------------------------------------- // Alien Swarm. //----------------------------------------------------------------------------- -#if defined(ENGINE_CSGO) || defined(ENGINE_BLADE) +#if defined(ENGINE_CSGO) || defined(ENGINE_BLADE) || defined(ENGINE_INSURGENCY) void CSourcePython::ClientFullyConnect( edict_t *pEntity ) { unsigned int iEntityIndex; @@ -459,7 +459,7 @@ void CSourcePython::ClientFullyConnect( edict_t *pEntity ) } #endif -#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE) +#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE) || defined(ENGINE_INSURGENCY) void CSourcePython::OnEdictAllocated( edict_t *edict ) { unsigned int iEntityIndex; diff --git a/src/core/sp_main.h b/src/core/sp_main.h index f85d158ef..9613622aa 100644 --- a/src/core/sp_main.h +++ b/src/core/sp_main.h @@ -80,11 +80,11 @@ class CSourcePython: public IServerPluginCallbacks, public IEntityListener, publ // ------------------------------------------- // Alien Swarm. // ------------------------------------------- -#if defined(ENGINE_CSGO) || defined(ENGINE_BLADE) +#if defined(ENGINE_CSGO) || defined(ENGINE_BLADE) || defined(ENGINE_INSURGENCY) virtual void ClientFullyConnect( edict_t *pEntity ); #endif -#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE) +#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE) || defined(ENGINE_INSURGENCY) virtual void OnEdictAllocated( edict_t *edict ); virtual void OnEdictFreed( const edict_t *edict ); #endif diff --git a/src/loader/loader_main.cpp b/src/loader/loader_main.cpp index af43be668..416087427 100644 --- a/src/loader/loader_main.cpp +++ b/src/loader/loader_main.cpp @@ -422,7 +422,7 @@ PLUGIN_RESULT CSourcePython::ClientCommand( edict_t *pEntity, const CCommand &ar //--------------------------------------------------------------------------------- // Alien Swarm. //--------------------------------------------------------------------------------- -#if defined(ENGINE_CSGO) || defined(ENGINE_BLADE) +#if defined(ENGINE_CSGO) || defined(ENGINE_BLADE) || defined(ENGINE_INSURGENCY) void CSourcePython::ClientFullyConnect( edict_t *pEntity ) { if (m_pCorePlugin != NULL) @@ -432,7 +432,7 @@ void CSourcePython::ClientFullyConnect( edict_t *pEntity ) } #endif -#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE) +#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE) || defined(ENGINE_INSURGENCY) void CSourcePython::OnEdictAllocated( edict_t *edict ) { if (m_pCorePlugin != NULL) diff --git a/src/loader/loader_main.h b/src/loader/loader_main.h index 6aff9c333..15622d211 100644 --- a/src/loader/loader_main.h +++ b/src/loader/loader_main.h @@ -92,11 +92,11 @@ class CSourcePython: public IServerPluginCallbacks // ------------------------------------------- // Counter-Strike: Global Offensive // ------------------------------------------- -#if defined(ENGINE_CSGO) || defined(ENGINE_BLADE) +#if defined(ENGINE_CSGO) || defined(ENGINE_BLADE) || defined(ENGINE_INSURGENCY) virtual void ClientFullyConnect( edict_t *pEntity ); #endif -#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE) +#if defined(ENGINE_CSGO) || defined(ENGINE_BMS) || defined(ENGINE_BLADE) || defined(ENGINE_INSURGENCY) virtual void OnEdictAllocated( edict_t *edict ); virtual void OnEdictFreed( const edict_t *edict ); #endif diff --git a/src/makefiles/branch/insurgency.cmake b/src/makefiles/branch/insurgency.cmake new file mode 100644 index 000000000..309cfe980 --- /dev/null +++ b/src/makefiles/branch/insurgency.cmake @@ -0,0 +1,10 @@ +# ------------------------------------------------------------------ +# File: src/makefiles/branch/insurgency.cmake +# Purpose: This is the CMake file for the insurgency branch. +# ------------------------------------------------------------------ + +# ------------------------------------------------------------------ +# Set the engine version. +# ------------------------------------------------------------------ +Set(SOURCE_ENGINE "insurgency") +add_definitions(-DENGINE_INSURGENCY) \ No newline at end of file diff --git a/src/patches/insurgency/public/networkvar.h b/src/patches/insurgency/public/networkvar.h new file mode 100644 index 000000000..3c0516277 --- /dev/null +++ b/src/patches/insurgency/public/networkvar.h @@ -0,0 +1,823 @@ +//========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// + +#ifndef NETWORKVAR_H +#define NETWORKVAR_H +#ifdef _WIN32 +#pragma once +#endif + + +#include "tier0/dbg.h" +#include "convar.h" + +#if defined( CLIENT_DLL ) || defined( GAME_DLL ) + #include "basehandle.h" +#endif + +#ifdef _MSC_VER +#pragma warning( disable : 4284 ) // warning C4284: return type for 'CNetworkVarT::operator ->' is 'int *' (ie; not a UDT or reference to a UDT. Will produce errors if applied using infix notation) +#endif + +#define MyOffsetOf( type, var ) ( (int)&((type*)0)->var ) + +#ifdef _DEBUG + #undef new + extern bool g_bUseNetworkVars; + #define CHECK_USENETWORKVARS if(g_bUseNetworkVars) +#else + #define CHECK_USENETWORKVARS // don't check for g_bUseNetworkVars +#endif + + + +// network vars use memcmp when fields are set. To ensure proper behavior your +// object's memory should be initialized to zero. This happens for entities automatically +// use this for other classes. +class CMemZeroOnNew +{ +public: + void *operator new( size_t nSize ) + { + void *pMem = MemAlloc_Alloc( nSize ); + V_memset( pMem, 0, nSize ); + return pMem; + } + + void* operator new( size_t nSize, int nBlockUse, const char *pFileName, int nLine ) + { + void *pMem = MemAlloc_Alloc( nSize, pFileName, nLine ); + V_memset( pMem, 0, nSize ); + return pMem; + } + + void operator delete(void *pData) + { + if ( pData ) + { + g_pMemAlloc->Free(pData); + } + } + + void operator delete( void* pData, int nBlockUse, const char *pFileName, int nLine ) + { + if ( pData ) + { + g_pMemAlloc->Free(pData, pFileName, nLine ); + } + } +}; + + +inline int InternalCheckDeclareClass( const char *pClassName, const char *pClassNameMatch, void *pTestPtr, void *pBasePtr ) +{ + // This makes sure that casting from ThisClass to BaseClass works right. You'll get a compiler error if it doesn't + // work at all, and you'll get a runtime error if you use multiple inheritance. + Assert( pTestPtr == pBasePtr ); + + // This is triggered by IMPLEMENT_SERVER_CLASS. It does DLLClassName::CheckDeclareClass( #DLLClassName ). + // If they didn't do a DECLARE_CLASS in DLLClassName, then it'll be calling its base class's version + // and the class names won't match. + Assert( (void*)pClassName == (void*)pClassNameMatch ); + return 0; +} + + +template +inline int CheckDeclareClass_Access( T *, const char *pShouldBe ) +{ + return T::CheckDeclareClass( pShouldBe ); +} + +#ifndef _STATIC_LINKED +#ifdef _MSC_VER +#if defined(_DEBUG) && (_MSC_VER > 1200 ) + #define VALIDATE_DECLARE_CLASS 1 +#endif +#endif +#endif + +#ifdef VALIDATE_DECLARE_CLASS + + #define DECLARE_CLASS( className, baseClassName ) \ + typedef baseClassName BaseClass; \ + typedef className ThisClass; \ + template friend int CheckDeclareClass_Access(T *, const char *pShouldBe); \ + static int CheckDeclareClass( const char *pShouldBe ) \ + { \ + InternalCheckDeclareClass( pShouldBe, #className, (ThisClass*)0xFFFFF, (BaseClass*)(ThisClass*)0xFFFFF ); \ + return CheckDeclareClass_Access( (BaseClass *)NULL, #baseClassName ); \ + } + + // Use this macro when you have a base class, but it's part of a library that doesn't use network vars + // or any of the things that use ThisClass or BaseClass. + #define DECLARE_CLASS_GAMEROOT( className, baseClassName ) \ + typedef baseClassName BaseClass; \ + typedef className ThisClass; \ + template friend int CheckDeclareClass_Access(T *, const char *pShouldBe); \ + static int CheckDeclareClass( const char *pShouldBe ) \ + { \ + return InternalCheckDeclareClass( pShouldBe, #className, (ThisClass*)0xFFFFF, (BaseClass*)(ThisClass*)0xFFFFF ); \ + } + + // Deprecated macro formerly used to work around VC++98 bug + #define DECLARE_CLASS_NOFRIEND( className, baseClassName ) \ + DECLARE_CLASS( className, baseClassName ) + + #define DECLARE_CLASS_NOBASE( className ) \ + typedef className ThisClass; \ + template friend int CheckDeclareClass_Access(T *, const char *pShouldBe); \ + static int CheckDeclareClass( const char *pShouldBe ) \ + { \ + return InternalCheckDeclareClass( pShouldBe, #className, 0, 0 ); \ + } + +#else + #define DECLARE_CLASS( className, baseClassName ) \ + typedef baseClassName BaseClass; \ + typedef className ThisClass; + + #define DECLARE_CLASS_GAMEROOT( className, baseClassName ) DECLARE_CLASS( className, baseClassName ) + #define DECLARE_CLASS_NOFRIEND( className, baseClassName ) DECLARE_CLASS( className, baseClassName ) + + #define DECLARE_CLASS_NOBASE( className ) typedef className ThisClass; +#endif + + + + +// All classes that contain CNetworkVars need a NetworkStateChanged() function. If the class is not an entity, +// it needs to forward the call to the entity it's in. These macros can help. + + // These macros setup an entity pointer in your class. Use IMPLEMENT_NETWORKVAR_CHAIN before you do + // anything inside the class itself. + class CBaseEntity; + class CAutoInitEntPtr + { + public: + CAutoInitEntPtr() + { + m_pEnt = NULL; + } + CBaseEntity *m_pEnt; + }; + + //TODO: Currently, these don't get the benefit of tracking changes to individual vars. + // Would be nice if they did. + #define DECLARE_NETWORKVAR_CHAIN() \ + CAutoInitEntPtr __m_pChainEntity; \ + void NetworkStateChanged() { CHECK_USENETWORKVARS __m_pChainEntity.m_pEnt->NetworkStateChanged(); } \ + void NetworkStateChanged( void *pVar ) { CHECK_USENETWORKVARS __m_pChainEntity.m_pEnt->NetworkStateChanged(); } + + #define IMPLEMENT_NETWORKVAR_CHAIN( varName ) \ + (varName)->__m_pChainEntity.m_pEnt = this; + + + +// Use this macro when you want to embed a structure inside your entity and have CNetworkVars in it. +template< class T > +static inline void DispatchNetworkStateChanged( T *pObj ) +{ + CHECK_USENETWORKVARS pObj->NetworkStateChanged(); +} +template< class T > +static inline void DispatchNetworkStateChanged( T *pObj, void *pVar ) +{ + CHECK_USENETWORKVARS pObj->NetworkStateChanged( pVar ); +} + + +#define DECLARE_EMBEDDED_NETWORKVAR() \ + template friend int ServerClassInit(T *); \ + template friend int ClientClassInit(T *); \ + virtual void NetworkStateChanged() {} virtual void NetworkStateChanged( void *pProp ) {} + +// NOTE: Assignment operator is disabled because it doesn't call copy constructors of scalar types within the aggregate, so they are not marked changed +#define CNetworkVarEmbedded( type, name ) \ + class NetworkVar_##name; \ + friend class NetworkVar_##name; \ + static inline int GetOffset_##name() { return MyOffsetOf(ThisClass,name); } \ + typedef ThisClass ThisClass_##name; \ + class NetworkVar_##name : public type \ + { \ + template< class T > NetworkVar_##name& operator=( const T &val ) { *((type*)this) = val; return *this; } \ + public: \ + void CopyFrom( const type &src ) { *((type *)this) = src; NetworkStateChanged(); } \ + type & GetForModify( void ) { NetworkStateChanged(); return *((type *)this); } \ + virtual void NetworkStateChanged() \ + { \ + DispatchNetworkStateChanged( (ThisClass_##name*)( ((char*)this) - GetOffset_##name() ) ); \ + } \ + virtual void NetworkStateChanged( void *pVar ) \ + { \ + DispatchNetworkStateChanged( (ThisClass_##name*)( ((char*)this) - GetOffset_##name() ), pVar ); \ + } \ + }; \ + NetworkVar_##name name; + + + +template< class Type, class Changer > +class CNetworkVarBase +{ +public: + CNetworkVarBase() + { + } + + FORCEINLINE explicit CNetworkVarBase( Type val ) + : m_Value( val ) + { + NetworkStateChanged(); + } + + FORCEINLINE const Type& SetDirect( const Type &val ) + { + NetworkStateChanged(); + m_Value = val; + return m_Value; + } + + FORCEINLINE const Type& Set( const Type &val ) + { + if ( m_Value != val ) + { + NetworkStateChanged(); + m_Value = val; + } + return m_Value; + } + + template< class C > + FORCEINLINE const Type& operator=( const C &val ) + { + return Set( ( const Type )val ); + } + + template< class C > + FORCEINLINE const Type& operator=( const CNetworkVarBase< C, Changer > &val ) + { + return Set( ( const Type )val.m_Value ); + } + + FORCEINLINE Type& GetForModify() + { + NetworkStateChanged(); + return m_Value; + } + + template< class C > + FORCEINLINE const Type& operator+=( const C &val ) + { + return Set( m_Value + ( const Type )val ); + } + + template< class C > + FORCEINLINE const Type& operator-=( const C &val ) + { + return Set( m_Value - ( const Type )val ); + } + + template< class C > + FORCEINLINE const Type& operator/=( const C &val ) + { + return Set( m_Value / ( const Type )val ); + } + + template< class C > + FORCEINLINE const Type& operator*=( const C &val ) + { + return Set( m_Value * ( const Type )val ); + } + + template< class C > + FORCEINLINE const Type& operator^=( const C &val ) + { + return Set( m_Value ^ ( const Type )val ); + } + + template< class C > + FORCEINLINE const Type& operator|=( const C &val ) + { + return Set( m_Value | ( const Type )val ); + } + + FORCEINLINE const Type& operator++() + { + return (*this += 1); + } + + FORCEINLINE Type operator--() + { + return (*this -= 1); + } + + FORCEINLINE Type operator++( int ) // postfix version.. + { + Type val = m_Value; + (*this += 1); + return val; + } + + FORCEINLINE Type operator--( int ) // postfix version.. + { + Type val = m_Value; + (*this -= 1); + return val; + } + + // For some reason the compiler only generates type conversion warnings for this operator when used like + // CNetworkVarBase = 0x1 + // (it warns about converting from an int to an unsigned char). + template< class C > + FORCEINLINE const Type& operator&=( const C &val ) + { + return Set( m_Value & ( const Type )val ); + } + + FORCEINLINE operator const Type&() const + { + return m_Value; + } + + FORCEINLINE const Type& Get() const + { + return m_Value; + } + + FORCEINLINE const Type* operator->() const + { + return &m_Value; + } + + Type m_Value; + +protected: + FORCEINLINE void NetworkStateChanged() + { + Changer::NetworkStateChanged( this ); + } +}; + +template< class Type, class Changer > +class CNetworkColor32Base : public CNetworkVarBase< Type, Changer > +{ + typedef CNetworkVarBase< Type, Changer > base; +public: + inline void Init( byte rVal, byte gVal, byte bVal ) + { + SetR( rVal ); + SetG( gVal ); + SetB( bVal ); + } + inline void Init( byte rVal, byte gVal, byte bVal, byte aVal ) + { + SetR( rVal ); + SetG( gVal ); + SetB( bVal ); + SetA( aVal ); + } + + const Type& operator=( const Type &val ) + { + return Set( val ); + } + + const Type& operator=( const CNetworkColor32Base &val ) + { + return base::Set( val.m_Value ); + } + + inline byte GetR() const { return this->m_Value.r; } + inline byte GetG() const { return this->m_Value.g; } + inline byte GetB() const { return this->m_Value.b; } + inline byte GetA() const { return this->m_Value.a; } + inline void SetR( byte val ) { SetVal( this->m_Value.r, val ); } + inline void SetG( byte val ) { SetVal( this->m_Value.g, val ); } + inline void SetB( byte val ) { SetVal( this->m_Value.b, val ); } + inline void SetA( byte val ) { SetVal( this->m_Value.a, val ); } + +protected: + inline void SetVal( byte &out, const byte &in ) + { + if ( out != in ) + { + this->NetworkStateChanged(); + out = in; + } + } +}; + + +// Network vector wrapper. +template< class Type, class Changer > +class CNetworkVectorBase : public CNetworkVarBase< Type, Changer > +{ + typedef CNetworkVarBase< Type, Changer > base; +public: + FORCEINLINE void Init( float ix=0, float iy=0, float iz=0 ) + { + base::Set( Type( ix, iy, iz ) ); + } + + FORCEINLINE const Type& operator=( const Type &val ) + { + return base::Set( val ); + } + + FORCEINLINE const Type& operator=( const CNetworkVectorBase &val ) + { + return base::Set( val.m_Value ); + } + + FORCEINLINE float GetX() const { return this->m_Value.x; } + FORCEINLINE float GetY() const { return this->m_Value.y; } + FORCEINLINE float GetZ() const { return this->m_Value.z; } + FORCEINLINE float operator[]( int i ) const { return this->m_Value[i]; } + + FORCEINLINE void SetX( float val ) { DetectChange( this->m_Value.x, val ); } + FORCEINLINE void SetY( float val ) { DetectChange( this->m_Value.y, val ); } + FORCEINLINE void SetZ( float val ) { DetectChange( this->m_Value.z, val ); } + FORCEINLINE void Set( int i, float val ) { DetectChange( this->m_Value[i], val ); } + + FORCEINLINE bool operator==( const Type &val ) const + { + return this->m_Value == (Type)val; + } + + FORCEINLINE bool operator!=( const Type &val ) const + { + return this->m_Value != (Type)val; + } + + FORCEINLINE const Type operator+( const Type &val ) const + { + return this->m_Value + val; + } + + FORCEINLINE const Type operator-( const Type &val ) const + { + return this->m_Value - val; + } + + FORCEINLINE const Type operator*( const Type &val ) const + { + return this->m_Value * val; + } + + FORCEINLINE const Type& operator*=( float val ) + { + return base::Set( this->m_Value * val ); + } + + FORCEINLINE const Type operator*( float val ) const + { + return this->m_Value * val; + } + + FORCEINLINE const Type operator/( const Type &val ) const + { + return this->m_Value / val; + } + +private: + FORCEINLINE void DetectChange( float &out, float in ) + { + if ( out != in ) + { + this->NetworkStateChanged(); + out = in; + } + } +}; + + +// Network vector wrapper. +template< class Type, class Changer > +class CNetworkQuaternionBase : public CNetworkVarBase< Type, Changer > +{ + typedef CNetworkVarBase< Type, Changer > base; +public: + inline void Init( float ix=0, float iy=0, float iz=0, float iw = 0 ) + { + base::Set( Quaternion( ix, iy, iz, iw ) ); + } + + const Type& operator=( const Type &val ) + { + return Set( val ); + } + + const Type& operator=( const CNetworkQuaternionBase &val ) + { + return Set( val.m_Value ); + } + + inline float GetX() const { return this->m_Value.x; } + inline float GetY() const { return this->m_Value.y; } + inline float GetZ() const { return this->m_Value.z; } + inline float GetW() const { return this->m_Value.w; } + inline float operator[]( int i ) const { return this->m_Value[i]; } + + inline void SetX( float val ) { DetectChange( this->m_Value.x, val ); } + inline void SetY( float val ) { DetectChange( this->m_Value.y, val ); } + inline void SetZ( float val ) { DetectChange( this->m_Value.z, val ); } + inline void SetW( float val ) { DetectChange( this->m_Value.w, val ); } + inline void Set( int i, float val ) { DetectChange( this->m_Value[i], val ); } + + bool operator==( const Type &val ) const + { + return this->m_Value == (Type)val; + } + + bool operator!=( const Type &val ) const + { + return this->m_Value != (Type)val; + } + + const Type operator+( const Type &val ) const + { + return this->m_Value + val; + } + + const Type operator-( const Type &val ) const + { + return this->m_Value - val; + } + + const Type operator*( const Type &val ) const + { + return this->m_Value * val; + } + + const Type& operator*=( float val ) + { + return Set( this->m_Value * val ); + } + + const Type operator*( float val ) const + { + return this->m_Value * val; + } + + const Type operator/( const Type &val ) const + { + return this->m_Value / val; + } + +private: + inline void DetectChange( float &out, float in ) + { + if ( out != in ) + { + this->NetworkStateChanged(); + out = in; + } + } +}; + + +#define PATCH_NETWORK_HANDLE_BASE_DEFINITION +// Network ehandle wrapper. +#if 1 + template< class Type, class Changer > + class CNetworkHandleBase : public CNetworkVarBase< CBaseHandle, Changer > + { + typedef CNetworkVarBase< CBaseHandle, Changer > base; + public: + const Type* operator=( const Type *val ) + { + return Set( val ); + } + + const Type& operator=( const CNetworkHandleBase &val ) + { + const CBaseHandle &handle = CNetworkVarBase::Set( val.m_Value ); + return *(const Type*)handle.Get(); + } + + bool operator !() const + { + return !this->m_Value.Get(); + } + + operator Type*() const + { + return static_cast< Type* >( this->m_Value.Get() ); + } + + const Type* Set( const Type *val ) + { + if ( CNetworkHandleBase::m_Value != val ) + { + this->NetworkStateChanged(); + CNetworkHandleBase::m_Value = val; + } + return val; + } + + Type* Get() const + { + return reinterpret_cast< Type* >( CNetworkHandleBase::m_Value.Get() ); + } + + Type* operator->() const + { + return static_cast< Type* >( CNetworkHandleBase::m_Value.Get() ); + } + + bool operator==( const Type *val ) const + { + return CNetworkHandleBase::m_Value == val; + } + + bool operator!=( const Type *val ) const + { + return CNetworkHandleBase::m_Value != val; + } + }; + + + + #define CNetworkHandle( type, name ) CNetworkHandleInternal( type, name, NetworkStateChanged ) + + #define CNetworkHandleInternal( type, name, stateChangedFn ) \ + NETWORK_VAR_START( type, name ) \ + NETWORK_VAR_END( type, name, CNetworkHandleBase, stateChangedFn ) +#endif + + +// Use this macro to define a network variable. +#define CNetworkVar( type, name ) \ + NETWORK_VAR_START( type, name ) \ + NETWORK_VAR_END( type, name, CNetworkVarBase, NetworkStateChanged ) + + +// Use this macro when you have a base class with a variable, and it doesn't have that variable in a SendTable, +// but a derived class does. Then, the entity is only flagged as changed when the variable is changed in +// an entity that wants to transmit the variable. + #define CNetworkVarForDerived( type, name ) \ + virtual void NetworkStateChanged_##name() {} \ + virtual void NetworkStateChanged_##name( void *pVar ) {} \ + NETWORK_VAR_START( type, name ) \ + NETWORK_VAR_END( type, name, CNetworkVarBase, NetworkStateChanged_##name ) + + #define CNetworkVectorForDerived( name ) \ + virtual void NetworkStateChanged_##name() {} \ + virtual void NetworkStateChanged_##name( void *pVar ) {} \ + CNetworkVectorInternal( Vector, name, NetworkStateChanged_##name ) + + #define CNetworkHandleForDerived( type, name ) \ + virtual void NetworkStateChanged_##name() {} \ + virtual void NetworkStateChanged_##name( void *pVar ) {} \ + CNetworkHandleInternal( type, name, NetworkStateChanged_##name ) + + #define CNetworkArrayForDerived( type, name, count ) \ + virtual void NetworkStateChanged_##name() {} \ + virtual void NetworkStateChanged_##name( void *pVar ) {} \ + CNetworkArrayInternal( type, name, count, NetworkStateChanged_##name ) + + #define IMPLEMENT_NETWORK_VAR_FOR_DERIVED( name ) \ + virtual void NetworkStateChanged_##name() { CHECK_USENETWORKVARS NetworkStateChanged(); } \ + virtual void NetworkStateChanged_##name( void *pVar ) { CHECK_USENETWORKVARS NetworkStateChanged( pVar ); } + + +// This virtualizes the change detection on the variable, but it is ON by default. +// Use this when you have a base class in which MOST of its derived classes use this variable +// in their SendTables, but there are a couple that don't (and they +// can use DISABLE_NETWORK_VAR_FOR_DERIVED). + #define CNetworkVarForDerived_OnByDefault( type, name ) \ + virtual void NetworkStateChanged_##name() { CHECK_USENETWORKVARS NetworkStateChanged(); } \ + virtual void NetworkStateChanged_##name( void *pVar ) { CHECK_USENETWORKVARS NetworkStateChanged( pVar ); } \ + NETWORK_VAR_START( type, name ) \ + NETWORK_VAR_END( type, name, CNetworkVarBase, NetworkStateChanged_##name ) + + #define DISABLE_NETWORK_VAR_FOR_DERIVED( name ) \ + virtual void NetworkStateChanged_##name() {} \ + virtual void NetworkStateChanged_##name( void *pVar ) {} + + + +// Vectors + some convenient helper functions. +#define CNetworkVector( name ) CNetworkVectorInternal( Vector, name, NetworkStateChanged ) +#define CNetworkQAngle( name ) CNetworkVectorInternal( QAngle, name, NetworkStateChanged ) + +#define CNetworkVectorInternal( type, name, stateChangedFn ) \ + NETWORK_VAR_START( type, name ) \ + NETWORK_VAR_END( type, name, CNetworkVectorBase, stateChangedFn ) + +#define CNetworkQuaternion( name ) \ + NETWORK_VAR_START( Quaternion, name ) \ + NETWORK_VAR_END( Quaternion, name, CNetworkQuaternionBase, NetworkStateChanged ) + +// Helper for color32's. Contains GetR(), SetR(), etc.. functions. +#define CNetworkColor32( name ) \ + NETWORK_VAR_START( color32, name ) \ + NETWORK_VAR_END( color32, name, CNetworkColor32Base, NetworkStateChanged ) + + +#define CNetworkString( name, length ) \ + class NetworkVar_##name; \ + friend class NetworkVar_##name; \ + typedef ThisClass MakeANetworkVar_##name; \ + class NetworkVar_##name \ + { \ + public: \ + operator const char*() const { return m_Value; } \ + const char* Get() const { return m_Value; } \ + char* GetForModify() \ + { \ + NetworkStateChanged(); \ + return m_Value; \ + } \ + protected: \ + inline void NetworkStateChanged() \ + { \ + CHECK_USENETWORKVARS ((ThisClass*)(((char*)this) - MyOffsetOf(ThisClass,name)))->NetworkStateChanged(); \ + } \ + private: \ + char m_Value[length]; \ + }; \ + NetworkVar_##name name; + + + + +// Use this to define networked arrays. +// You can access elements for reading with operator[], and you can set elements with the Set() function. +#define CNetworkArrayInternal( type, name, count, stateChangedFn ) \ + class NetworkVar_##name; \ + friend class NetworkVar_##name; \ + typedef ThisClass MakeANetworkVar_##name; \ + class NetworkVar_##name \ + { \ + public: \ + template friend int ServerClassInit(T *); \ + const type& operator[]( int i ) const \ + { \ + return Get( i ); \ + } \ + \ + const type& Get( int i ) const \ + { \ + Assert( i >= 0 && i < count ); \ + return m_Value[i]; \ + } \ + \ + type& GetForModify( int i ) \ + { \ + Assert( i >= 0 && i < count ); \ + NetworkStateChanged( i ); \ + return m_Value[i]; \ + } \ + \ + void Set( int i, const type &val ) \ + { \ + Assert( i >= 0 && i < count ); \ + if( memcmp( &m_Value[i], &val, sizeof(type) ) ) \ + { \ + NetworkStateChanged( i ); \ + m_Value[i] = val; \ + } \ + } \ + const type* Base() const { return m_Value; } \ + int Count() const { return count; } \ + type m_Value[count]; \ + protected: \ + inline void NetworkStateChanged( int index ) \ + { \ + CHECK_USENETWORKVARS ((ThisClass*)(((char*)this) - MyOffsetOf(ThisClass,name)))->stateChangedFn( &m_Value[index] ); \ + } \ + }; \ + NetworkVar_##name name; + + +#define CNetworkArray( type, name, count ) CNetworkArrayInternal( type, name, count, NetworkStateChanged ) + + +// Internal macros used in definitions of network vars. +#define NETWORK_VAR_START( type, name ) \ + class NetworkVar_##name; \ + friend class NetworkVar_##name; \ + typedef ThisClass MakeANetworkVar_##name; \ + class NetworkVar_##name \ + { \ + public: \ + template friend int ServerClassInit(T *); + + +#define NETWORK_VAR_END( type, name, base, stateChangedFn ) \ + public: \ + static inline void NetworkStateChanged( void *ptr ) \ + { \ + CHECK_USENETWORKVARS ((ThisClass*)(((char*)ptr) - MyOffsetOf(ThisClass,name)))->stateChangedFn( ptr ); \ + } \ + }; \ + base< type, NetworkVar_##name > name; + + + +#endif // NETWORKVAR_H diff --git a/src/patches/insurgency/public/tier1/convar.h b/src/patches/insurgency/public/tier1/convar.h new file mode 100644 index 000000000..5b46e7407 --- /dev/null +++ b/src/patches/insurgency/public/tier1/convar.h @@ -0,0 +1,1016 @@ +//===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======// +// +// Purpose: +// +// $Workfile: $ +// $Date: $ +// +//----------------------------------------------------------------------------- +// $NoKeywords: $ +//===========================================================================// + +#ifndef CONVAR_H +#define CONVAR_H + +#if _WIN32 +#pragma once +#endif + +#include "tier0/dbg.h" +#include "tier1/iconvar.h" +#include "tier1/utlvector.h" +#include "tier1/utlstring.h" +#include "Color.h" +#include "icvar.h" + +#ifdef _WIN32 +#define FORCEINLINE_CVAR FORCEINLINE +#elif POSIX +#define FORCEINLINE_CVAR inline +#else +#error "implement me" +#endif + + +//----------------------------------------------------------------------------- +// Uncomment me to test for threading issues for material system convars +// NOTE: You want to disable all threading when you do this +// +host_thread_mode 0 +r_threaded_particles 0 +sv_parallel_packentities 0 +sv_disable_querycache 0 +//----------------------------------------------------------------------------- +//#define CONVAR_TEST_MATERIAL_THREAD_CONVARS 1 + + +//----------------------------------------------------------------------------- +// Forward declarations +//----------------------------------------------------------------------------- +class ConVar; +class CCommand; +class ConCommand; +class ConCommandBase; +struct characterset_t; + + + +//----------------------------------------------------------------------------- +// Any executable that wants to use ConVars need to implement one of +// these to hook up access to console variables. +//----------------------------------------------------------------------------- +class IConCommandBaseAccessor +{ +public: + // Flags is a combination of FCVAR flags in cvar.h. + // hOut is filled in with a handle to the variable. + virtual bool RegisterConCommandBase( ConCommandBase *pVar ) = 0; +}; + + +//----------------------------------------------------------------------------- +// Helper method for console development +//----------------------------------------------------------------------------- +#if defined( _X360 ) +void ConVar_PublishToVXConsole(); +#endif + + +//----------------------------------------------------------------------------- +// Called when a ConCommand needs to execute +//----------------------------------------------------------------------------- +typedef void ( *FnCommandCallbackV1_t )( void ); +typedef void ( *FnCommandCallback_t )( const CCommand &command ); + +#define COMMAND_COMPLETION_MAXITEMS 64 +#define COMMAND_COMPLETION_ITEM_LENGTH 64 + +//----------------------------------------------------------------------------- +// Returns 0 to COMMAND_COMPLETION_MAXITEMS worth of completion strings +//----------------------------------------------------------------------------- +typedef int ( *FnCommandCompletionCallback )( const char *partial, char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] ); + + +//----------------------------------------------------------------------------- +// Interface version +//----------------------------------------------------------------------------- +class ICommandCallback +{ +public: + virtual void CommandCallback( const CCommand &command ) = 0; +}; + +class ICommandCompletionCallback +{ +public: + virtual int CommandCompletionCallback( const char *pPartial, CUtlVector< CUtlString > &commands ) = 0; +}; + +//----------------------------------------------------------------------------- +// Purpose: The base console invoked command/cvar interface +//----------------------------------------------------------------------------- +class ConCommandBase +{ + friend class CCvar; + friend class ConVar; + friend class ConCommand; + friend void ConVar_Register( int nCVarFlag, IConCommandBaseAccessor *pAccessor ); + friend void ConVar_PublishToVXConsole(); + + // FIXME: Remove when ConVar changes are done + friend class CDefaultCvar; + +public: + ConCommandBase( void ); + ConCommandBase( const char *pName, const char *pHelpString = 0, + int flags = 0 ); + + virtual ~ConCommandBase( void ); + + virtual bool IsCommand( void ) const; + + // Check flag + virtual bool IsFlagSet( int flag ) const; + // Set flag + virtual void AddFlags( int flags ); + // Clear flag + virtual void RemoveFlags( int flags ); + + virtual int GetFlags() const; + + // Return name of cvar + virtual const char *GetName( void ) const; + + // Return help text for cvar + virtual const char *GetHelpText( void ) const; + + // Deal with next pointer + const ConCommandBase *GetNext( void ) const; + ConCommandBase *GetNext( void ); + + virtual bool IsRegistered( void ) const; + + // Returns the DLL identifier + virtual CVarDLLIdentifier_t GetDLLIdentifier() const; + +protected: + virtual void Create( const char *pName, const char *pHelpString = 0, + int flags = 0 ); + + // Used internally by OneTimeInit to initialize/shutdown + virtual void Init(); + void Shutdown(); + + // Internal copy routine ( uses new operator from correct module ) + char *CopyString( const char *from ); + +private: + // Next ConVar in chain + // Prior to register, it points to the next convar in the DLL. + // Once registered, though, m_pNext is reset to point to the next + // convar in the global list + ConCommandBase *m_pNext; + + // Has the cvar been added to the global list? + bool m_bRegistered; + + // Static data + const char *m_pszName; + const char *m_pszHelpString; + +#define PATCH_CONVAR_H_PUBLIC_FLAGS +public: + // ConVar flags + int m_nFlags; + +protected: + // ConVars add themselves to this list for the executable. + // Then ConVar_Register runs through all the console variables + // and registers them into a global list stored in vstdlib.dll + static ConCommandBase *s_pConCommandBases; + + // ConVars in this executable use this 'global' to access values. + static IConCommandBaseAccessor *s_pAccessor; +}; + + +//----------------------------------------------------------------------------- +// Command tokenizer +//----------------------------------------------------------------------------- +class CCommand +{ +public: + CCommand(); + CCommand( int nArgC, const char **ppArgV ); + bool Tokenize( const char *pCommand, characterset_t *pBreakSet = NULL ); + void Reset(); + + int ArgC() const; + const char **ArgV() const; + const char *ArgS() const; // All args that occur after the 0th arg, in string form + const char *GetCommandString() const; // The entire command in string form, including the 0th arg + const char *operator[]( int nIndex ) const; // Gets at arguments + const char *Arg( int nIndex ) const; // Gets at arguments + + // Helper functions to parse arguments to commands. + const char* FindArg( const char *pName ) const; + int FindArgInt( const char *pName, int nDefaultVal ) const; + + static int MaxCommandLength(); + static characterset_t* DefaultBreakSet(); + +private: + enum + { + COMMAND_MAX_ARGC = 64, + COMMAND_MAX_LENGTH = 512, + }; + + int m_nArgc; + int m_nArgv0Size; + char m_pArgSBuffer[ COMMAND_MAX_LENGTH ]; + char m_pArgvBuffer[ COMMAND_MAX_LENGTH ]; + const char* m_ppArgv[ COMMAND_MAX_ARGC ]; +}; + +inline int CCommand::MaxCommandLength() +{ + return COMMAND_MAX_LENGTH - 1; +} + +inline int CCommand::ArgC() const +{ + return m_nArgc; +} + +inline const char **CCommand::ArgV() const +{ + return m_nArgc ? (const char**)m_ppArgv : NULL; +} + +inline const char *CCommand::ArgS() const +{ + return m_nArgv0Size ? &m_pArgSBuffer[m_nArgv0Size] : ""; +} + +inline const char *CCommand::GetCommandString() const +{ + return m_nArgc ? m_pArgSBuffer : ""; +} + +inline const char *CCommand::Arg( int nIndex ) const +{ + // FIXME: Many command handlers appear to not be particularly careful + // about checking for valid argc range. For now, we're going to + // do the extra check and return an empty string if it's out of range + if ( nIndex < 0 || nIndex >= m_nArgc ) + return ""; + return m_ppArgv[nIndex]; +} + +inline const char *CCommand::operator[]( int nIndex ) const +{ + return Arg( nIndex ); +} + + +//----------------------------------------------------------------------------- +// Purpose: The console invoked command +//----------------------------------------------------------------------------- +class ConCommand : public ConCommandBase +{ +friend class CCvar; + +public: + typedef ConCommandBase BaseClass; + + ConCommand( const char *pName, FnCommandCallbackV1_t callback, + const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 ); + ConCommand( const char *pName, FnCommandCallback_t callback, + const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 ); + ConCommand( const char *pName, ICommandCallback *pCallback, + const char *pHelpString = 0, int flags = 0, ICommandCompletionCallback *pCommandCompletionCallback = 0 ); + + virtual ~ConCommand( void ); + + virtual bool IsCommand( void ) const; + + virtual int AutoCompleteSuggest( const char *partial, CUtlVector< CUtlString > &commands ); + + virtual bool CanAutoComplete( void ); + + // Invoke the function + virtual void Dispatch( const CCommand &command ); + +private: + // NOTE: To maintain backward compat, we have to be very careful: + // All public virtual methods must appear in the same order always + // since engine code will be calling into this code, which *does not match* + // in the mod code; it's using slightly different, but compatible versions + // of this class. Also: Be very careful about adding new fields to this class. + // Those fields will not exist in the version of this class that is instanced + // in mod code. + + // Call this function when executing the command + union + { + FnCommandCallbackV1_t m_fnCommandCallbackV1; + FnCommandCallback_t m_fnCommandCallback; + ICommandCallback *m_pCommandCallback; + }; + + union + { + FnCommandCompletionCallback m_fnCompletionCallback; + ICommandCompletionCallback *m_pCommandCompletionCallback; + }; + + bool m_bHasCompletionCallback : 1; + bool m_bUsingNewCommandCallback : 1; + bool m_bUsingCommandCallbackInterface : 1; +}; + + +//----------------------------------------------------------------------------- +// Purpose: A console variable +//----------------------------------------------------------------------------- +class ConVar : public ConCommandBase, public IConVar +{ +friend class CCvar; +friend class ConVarRef; +friend class SplitScreenConVarRef; + +public: + typedef ConCommandBase BaseClass; + + ConVar( const char *pName, const char *pDefaultValue, int flags = 0); + + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString ); + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax ); + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, FnChangeCallback_t callback ); + ConVar( const char *pName, const char *pDefaultValue, int flags, + const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax, + FnChangeCallback_t callback ); + + virtual ~ConVar( void ); + + virtual bool IsFlagSet( int flag ) const; + virtual const char* GetHelpText( void ) const; + virtual bool IsRegistered( void ) const; + virtual const char *GetName( void ) const; + // Return name of command (usually == GetName(), except in case of FCVAR_SS_ADDED vars + virtual const char *GetBaseName( void ) const; + virtual int GetSplitScreenPlayerSlot() const; + + virtual void AddFlags( int flags ); + virtual int GetFlags() const; + virtual bool IsCommand( void ) const; + + // Install a change callback (there shouldn't already be one....) + void InstallChangeCallback( FnChangeCallback_t callback, bool bInvoke = true ); + void RemoveChangeCallback( FnChangeCallback_t callbackToRemove ); + + int GetChangeCallbackCount() const { return m_pParent->m_fnChangeCallbacks.Count(); } + FnChangeCallback_t GetChangeCallback( int slot ) const { return m_pParent->m_fnChangeCallbacks[ slot ]; } + + // Retrieve value + virtual float GetFloat( void ) const; + virtual int GetInt( void ) const; + FORCEINLINE_CVAR Color GetColor( void ) const; + FORCEINLINE_CVAR bool GetBool() const { return !!GetInt(); } + FORCEINLINE_CVAR char const *GetString( void ) const; + + // Compiler driven selection for template use + template T Get( void ) const; + template T Get( T * ) const; + + // Any function that allocates/frees memory needs to be virtual or else you'll have crashes + // from alloc/free across dll/exe boundaries. + + // These just call into the IConCommandBaseAccessor to check flags and set the var (which ends up calling InternalSetValue). + virtual void SetValue( const char *value ); + virtual void SetValue( float value ); + virtual void SetValue( int value ); + virtual void SetValue( Color value ); + + // Reset to default value + void Revert( void ); + + // True if it has a min/max setting + bool HasMin() const; + bool HasMax() const; + + bool GetMin( float& minVal ) const; + bool GetMax( float& maxVal ) const; + + float GetMinValue() const; + float GetMaxValue() const; + + const char *GetDefault( void ) const; + + // Value + struct CVValue_t + { + char *m_pszString; + int m_StringLength; + + // Values + float m_fValue; + int m_nValue; + }; + + FORCEINLINE_CVAR CVValue_t &GetRawValue() + { + return m_Value; + } + FORCEINLINE_CVAR const CVValue_t &GetRawValue() const + { + return m_Value; + } + +private: + bool InternalSetColorFromString( const char *value ); + // Called by CCvar when the value of a var is changing. + virtual void InternalSetValue(const char *value); + // For CVARs marked FCVAR_NEVER_AS_STRING + virtual void InternalSetFloatValue( float fNewValue ); + virtual void InternalSetIntValue( int nValue ); + virtual void InternalSetColorValue( Color value ); + + virtual bool ClampValue( float& value ); + virtual void ChangeStringValue( const char *tempVal, float flOldValue ); + + virtual void Create( const char *pName, const char *pDefaultValue, int flags = 0, + const char *pHelpString = 0, bool bMin = false, float fMin = 0.0, + bool bMax = false, float fMax = false, FnChangeCallback_t callback = 0 ); + + // Used internally by OneTimeInit to initialize. + virtual void Init(); + + + +protected: + + // This either points to "this" or it points to the original declaration of a ConVar. + // This allows ConVars to exist in separate modules, and they all use the first one to be declared. + // m_pParent->m_pParent must equal m_pParent (ie: m_pParent must be the root, or original, ConVar). + ConVar *m_pParent; + + // Static data + const char *m_pszDefaultValue; + + CVValue_t m_Value; + + // Min/Max values + bool m_bHasMin; + float m_fMinVal; + bool m_bHasMax; + float m_fMaxVal; + + // Call this function when ConVar changes + CUtlVector< FnChangeCallback_t > m_fnChangeCallbacks; +}; + + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as a float +// Output : float +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR float ConVar::GetFloat( void ) const +{ +#ifdef CONVAR_TEST_MATERIAL_THREAD_CONVARS + Assert( ThreadInMainThread() || IsFlagSet( FCVAR_MATERIAL_THREAD_MASK | FCVAR_ACCESSIBLE_FROM_THREADS ) ); +#endif + return m_pParent->m_Value.m_fValue; +} + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as an int +// Output : int +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR int ConVar::GetInt( void ) const +{ +#ifdef CONVAR_TEST_MATERIAL_THREAD_CONVARS + Assert( ThreadInMainThread() || IsFlagSet( FCVAR_MATERIAL_THREAD_MASK | FCVAR_ACCESSIBLE_FROM_THREADS ) ); +#endif + return m_pParent->m_Value.m_nValue; +} + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as a color +// Output : Color +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR Color ConVar::GetColor( void ) const +{ +#ifdef CONVAR_TEST_MATERIAL_THREAD_CONVARS + Assert( ThreadInMainThread() || IsFlagSet( FCVAR_MATERIAL_THREAD_MASK | FCVAR_ACCESSIBLE_FROM_THREADS ) ); +#endif + unsigned char *pColorElement = ((unsigned char *)&m_pParent->m_Value.m_nValue); + return Color( pColorElement[0], pColorElement[1], pColorElement[2], pColorElement[3] ); +} + + +//----------------------------------------------------------------------------- + +template <> FORCEINLINE_CVAR float ConVar::Get( void ) const { return GetFloat(); } +template <> FORCEINLINE_CVAR int ConVar::Get( void ) const { return GetInt(); } +template <> FORCEINLINE_CVAR bool ConVar::Get( void ) const { return GetBool(); } +template <> FORCEINLINE_CVAR const char * ConVar::Get( void ) const { return GetString(); } +template <> FORCEINLINE_CVAR float ConVar::Get( float *p ) const { return ( *p = GetFloat() ); } +template <> FORCEINLINE_CVAR int ConVar::Get( int *p ) const { return ( *p = GetInt() ); } +template <> FORCEINLINE_CVAR bool ConVar::Get( bool *p ) const { return ( *p = GetBool() ); } +template <> FORCEINLINE_CVAR const char * ConVar::Get( char const **p ) const { return ( *p = GetString() ); } + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc. +// Output : const char * +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR const char *ConVar::GetString( void ) const +{ +#ifdef CONVAR_TEST_MATERIAL_THREAD_CONVARS + Assert( ThreadInMainThread() || IsFlagSet( FCVAR_MATERIAL_THREAD_MASK | FCVAR_ACCESSIBLE_FROM_THREADS ) ); +#endif + if ( m_nFlags & FCVAR_NEVER_AS_STRING ) + return "FCVAR_NEVER_AS_STRING"; + + char const *str = m_pParent->m_Value.m_pszString; + return str ? str : ""; +} + +class CSplitScreenAddedConVar : public ConVar +{ + typedef ConVar BaseClass; +public: + CSplitScreenAddedConVar( int nSplitScreenSlot, const char *pName, const ConVar *pBaseVar ) : + BaseClass + ( + pName, + pBaseVar->GetDefault(), + // Keep basevar flags, except remove _SS and add _SS_ADDED instead + ( pBaseVar->GetFlags() & ~FCVAR_SS ) | FCVAR_SS_ADDED, + pBaseVar->GetHelpText(), + pBaseVar->HasMin(), + pBaseVar->GetMinValue(), + pBaseVar->HasMax(), + pBaseVar->GetMaxValue() + ), + m_pBaseVar( pBaseVar ), + m_nSplitScreenSlot( nSplitScreenSlot ) + { + for ( int i = 0; i < pBaseVar->GetChangeCallbackCount(); ++i ) + { + InstallChangeCallback( pBaseVar->GetChangeCallback( i ), false ); + } + Assert( nSplitScreenSlot >= 1 ); + Assert( nSplitScreenSlot < MAX_SPLITSCREEN_CLIENTS ); + Assert( m_pBaseVar ); + Assert( IsFlagSet( FCVAR_SS_ADDED ) ); + Assert( !IsFlagSet( FCVAR_SS ) ); + } + + const ConVar *GetBaseVar() const; + virtual const char *GetBaseName() const; + void SetSplitScreenPlayerSlot( int nSlot ); + virtual int GetSplitScreenPlayerSlot() const; + +protected: + + const ConVar *m_pBaseVar; + int m_nSplitScreenSlot; +}; + +FORCEINLINE_CVAR const ConVar *CSplitScreenAddedConVar::GetBaseVar() const +{ + Assert( m_pBaseVar ); + return m_pBaseVar; +} + +FORCEINLINE_CVAR const char *CSplitScreenAddedConVar::GetBaseName() const +{ + Assert( m_pBaseVar ); + return m_pBaseVar->GetName(); +} + +FORCEINLINE_CVAR void CSplitScreenAddedConVar::SetSplitScreenPlayerSlot( int nSlot ) +{ + m_nSplitScreenSlot = nSlot; +} + +FORCEINLINE_CVAR int CSplitScreenAddedConVar::GetSplitScreenPlayerSlot() const +{ + return m_nSplitScreenSlot; +} + +//----------------------------------------------------------------------------- +// Used to read/write convars that already exist (replaces the FindVar method) +//----------------------------------------------------------------------------- +class ConVarRef +{ +public: + ConVarRef( const char *pName ); + ConVarRef( const char *pName, bool bIgnoreMissing ); + ConVarRef( IConVar *pConVar ); + + void Init( const char *pName, bool bIgnoreMissing ); + bool IsValid() const; + bool IsFlagSet( int nFlags ) const; + IConVar *GetLinkedConVar(); + + // Get/Set value + float GetFloat( void ) const; + int GetInt( void ) const; + Color GetColor( void ) const; + bool GetBool() const { return !!GetInt(); } + const char *GetString( void ) const; + + void SetValue( const char *pValue ); + void SetValue( float flValue ); + void SetValue( int nValue ); + void SetValue( Color value ); + void SetValue( bool bValue ); + + const char *GetName() const; + + const char *GetDefault() const; + + const char *GetBaseName() const; + + int GetSplitScreenPlayerSlot() const; + +private: + // High-speed method to read convar data + IConVar *m_pConVar; + ConVar *m_pConVarState; +}; + + +//----------------------------------------------------------------------------- +// Did we find an existing convar of that name? +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR bool ConVarRef::IsFlagSet( int nFlags ) const +{ + return ( m_pConVar->IsFlagSet( nFlags ) != 0 ); +} + +FORCEINLINE_CVAR IConVar *ConVarRef::GetLinkedConVar() +{ + return m_pConVar; +} + +FORCEINLINE_CVAR const char *ConVarRef::GetName() const +{ + return m_pConVar->GetName(); +} + +FORCEINLINE_CVAR const char *ConVarRef::GetBaseName() const +{ + return m_pConVar->GetBaseName(); +} + +FORCEINLINE_CVAR int ConVarRef::GetSplitScreenPlayerSlot() const +{ + return m_pConVar->GetSplitScreenPlayerSlot(); +} + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as a float +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR float ConVarRef::GetFloat( void ) const +{ + return m_pConVarState->m_Value.m_fValue; +} + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as an int +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR int ConVarRef::GetInt( void ) const +{ + return m_pConVarState->m_Value.m_nValue; +} + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as a color +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR Color ConVarRef::GetColor( void ) const +{ + return m_pConVarState->GetColor(); +} + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc. +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR const char *ConVarRef::GetString( void ) const +{ + Assert( !IsFlagSet( FCVAR_NEVER_AS_STRING ) ); + return m_pConVarState->m_Value.m_pszString; +} + + +FORCEINLINE_CVAR void ConVarRef::SetValue( const char *pValue ) +{ + m_pConVar->SetValue( pValue ); +} + +FORCEINLINE_CVAR void ConVarRef::SetValue( float flValue ) +{ + m_pConVar->SetValue( flValue ); +} + +FORCEINLINE_CVAR void ConVarRef::SetValue( int nValue ) +{ + m_pConVar->SetValue( nValue ); +} + +FORCEINLINE_CVAR void ConVarRef::SetValue( Color value ) +{ + m_pConVar->SetValue( value ); +} + +FORCEINLINE_CVAR void ConVarRef::SetValue( bool bValue ) +{ + m_pConVar->SetValue( bValue ? 1 : 0 ); +} + +FORCEINLINE_CVAR const char *ConVarRef::GetDefault() const +{ + return m_pConVarState->m_pszDefaultValue; +} + +//----------------------------------------------------------------------------- +// Helper for referencing splitscreen convars (i.e., "name" and "name2") +//----------------------------------------------------------------------------- +class SplitScreenConVarRef +{ +public: + SplitScreenConVarRef( const char *pName ); + SplitScreenConVarRef( const char *pName, bool bIgnoreMissing ); + SplitScreenConVarRef( IConVar *pConVar ); + + void Init( const char *pName, bool bIgnoreMissing ); + bool IsValid() const; + bool IsFlagSet( int nFlags ) const; + + // Get/Set value + float GetFloat( int nSlot ) const; + int GetInt( int nSlot ) const; + Color GetColor( int nSlot ) const; + bool GetBool( int nSlot ) const { return !!GetInt( nSlot ); } + const char *GetString( int nSlot ) const; + + void SetValue( int nSlot, const char *pValue ); + void SetValue( int nSlot, float flValue ); + void SetValue( int nSlot, int nValue ); + void SetValue( int nSlot, Color value ); + void SetValue( int nSlot, bool bValue ); + + const char *GetName( int nSlot ) const; + + const char *GetDefault() const; + + const char *GetBaseName() const; + +private: + struct cv_t + { + IConVar *m_pConVar; + ConVar *m_pConVarState; + }; + + cv_t m_Info[ MAX_SPLITSCREEN_CLIENTS ]; +}; + +//----------------------------------------------------------------------------- +// Did we find an existing convar of that name? +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR bool SplitScreenConVarRef::IsFlagSet( int nFlags ) const +{ + return ( m_Info[ 0 ].m_pConVar->IsFlagSet( nFlags ) != 0 ); +} + +FORCEINLINE_CVAR const char *SplitScreenConVarRef::GetName( int nSlot ) const +{ + return m_Info[ nSlot ].m_pConVar->GetName(); +} + +FORCEINLINE_CVAR const char *SplitScreenConVarRef::GetBaseName() const +{ + return m_Info[ 0 ].m_pConVar->GetBaseName(); +} + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as a float +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR float SplitScreenConVarRef::GetFloat( int nSlot ) const +{ + return m_Info[ nSlot ].m_pConVarState->m_Value.m_fValue; +} + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as an int +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR int SplitScreenConVarRef::GetInt( int nSlot ) const +{ + return m_Info[ nSlot ].m_pConVarState->m_Value.m_nValue; +} + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as an int +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR Color SplitScreenConVarRef::GetColor( int nSlot ) const +{ + return m_Info[ nSlot ].m_pConVarState->GetColor(); +} + +//----------------------------------------------------------------------------- +// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc. +//----------------------------------------------------------------------------- +FORCEINLINE_CVAR const char *SplitScreenConVarRef::GetString( int nSlot ) const +{ + Assert( !IsFlagSet( FCVAR_NEVER_AS_STRING ) ); + return m_Info[ nSlot ].m_pConVarState->m_Value.m_pszString; +} + + +FORCEINLINE_CVAR void SplitScreenConVarRef::SetValue( int nSlot, const char *pValue ) +{ + m_Info[ nSlot ].m_pConVar->SetValue( pValue ); +} + +FORCEINLINE_CVAR void SplitScreenConVarRef::SetValue( int nSlot, float flValue ) +{ + m_Info[ nSlot ].m_pConVar->SetValue( flValue ); +} + +FORCEINLINE_CVAR void SplitScreenConVarRef::SetValue( int nSlot, int nValue ) +{ + m_Info[ nSlot ].m_pConVar->SetValue( nValue ); +} + +FORCEINLINE_CVAR void SplitScreenConVarRef::SetValue( int nSlot, Color value ) +{ + m_Info[ nSlot ].m_pConVar->SetValue( value ); +} + +FORCEINLINE_CVAR void SplitScreenConVarRef::SetValue( int nSlot, bool bValue ) +{ + m_Info[ nSlot ].m_pConVar->SetValue( bValue ? 1 : 0 ); +} + +FORCEINLINE_CVAR const char *SplitScreenConVarRef::GetDefault() const +{ + return m_Info[ 0 ].m_pConVarState->m_pszDefaultValue; +} + +//----------------------------------------------------------------------------- +// Called by the framework to register ConCommands with the ICVar +//----------------------------------------------------------------------------- +void ConVar_Register( int nCVarFlag = 0, IConCommandBaseAccessor *pAccessor = NULL ); +void ConVar_Unregister( ); + + +//----------------------------------------------------------------------------- +// Utility methods +//----------------------------------------------------------------------------- +void ConVar_PrintDescription( const ConCommandBase *pVar ); + + +//----------------------------------------------------------------------------- +// Purpose: Utility class to quickly allow ConCommands to call member methods +//----------------------------------------------------------------------------- +#ifdef _MSC_VER +#pragma warning (disable : 4355 ) +#endif + +template< class T > +class CConCommandMemberAccessor : public ConCommand, public ICommandCallback, public ICommandCompletionCallback +{ + typedef ConCommand BaseClass; + typedef void ( T::*FnMemberCommandCallback_t )( const CCommand &command ); + typedef int ( T::*FnMemberCommandCompletionCallback_t )( const char *pPartial, CUtlVector< CUtlString > &commands ); + +public: + CConCommandMemberAccessor( T* pOwner, const char *pName, FnMemberCommandCallback_t callback, const char *pHelpString = 0, + int flags = 0, FnMemberCommandCompletionCallback_t completionFunc = 0 ) : + BaseClass( pName, this, pHelpString, flags, ( completionFunc != 0 ) ? this : NULL ) + { + m_pOwner = pOwner; + m_Func = callback; + m_CompletionFunc = completionFunc; + } + + ~CConCommandMemberAccessor() + { + Shutdown(); + } + + void SetOwner( T* pOwner ) + { + m_pOwner = pOwner; + } + + virtual void CommandCallback( const CCommand &command ) + { + Assert( m_pOwner && m_Func ); + (m_pOwner->*m_Func)( command ); + } + + virtual int CommandCompletionCallback( const char *pPartial, CUtlVector< CUtlString > &commands ) + { + Assert( m_pOwner && m_CompletionFunc ); + return (m_pOwner->*m_CompletionFunc)( pPartial, commands ); + } + +private: + T* m_pOwner; + FnMemberCommandCallback_t m_Func; + FnMemberCommandCompletionCallback_t m_CompletionFunc; +}; + +#ifdef _MSC_VER +#pragma warning ( default : 4355 ) +#endif + +//----------------------------------------------------------------------------- +// Purpose: Utility macros to quicky generate a simple console command +//----------------------------------------------------------------------------- +#define CON_COMMAND( name, description ) \ + static void name( const CCommand &args ); \ + static ConCommand name##_command( #name, name, description ); \ + static void name( const CCommand &args ) + +#ifdef CLIENT_DLL + #define CON_COMMAND_SHARED( name, description ) \ + static void name( const CCommand &args ); \ + static ConCommand name##_command_client( #name "_client", name, description ); \ + static void name( const CCommand &args ) +#else + #define CON_COMMAND_SHARED( name, description ) \ + static void name( const CCommand &args ); \ + static ConCommand name##_command( #name, name, description ); \ + static void name( const CCommand &args ) +#endif + + +#define CON_COMMAND_F( name, description, flags ) \ + static void name( const CCommand &args ); \ + static ConCommand name##_command( #name, name, description, flags ); \ + static void name( const CCommand &args ) + +#ifdef CLIENT_DLL + #define CON_COMMAND_F_SHARED( name, description, flags ) \ + static void name( const CCommand &args ); \ + static ConCommand name##_command_client( #name "_client", name, description, flags ); \ + static void name( const CCommand &args ) +#else + #define CON_COMMAND_F_SHARED( name, description, flags ) \ + static void name( const CCommand &args ); \ + static ConCommand name##_command( #name, name, description, flags ); \ + static void name( const CCommand &args ) +#endif + + +#define CON_COMMAND_F_COMPLETION( name, description, flags, completion ) \ + static void name( const CCommand &args ); \ + static ConCommand name##_command( #name, name, description, flags, completion ); \ + static void name( const CCommand &args ) + +#ifdef CLIENT_DLL + #define CON_COMMAND_F_COMPLETION_SHARED( name, description, flags, completion ) \ + static void name( const CCommand &args ); \ + static ConCommand name##_command_client( #name "_client", name, description, flags, completion ); \ + static void name( const CCommand &args ) +#else + #define CON_COMMAND_F_COMPLETION_SHARED( name, description, flags, completion ) \ + static void name( const CCommand &args ); \ + static ConCommand name##_command( #name, name, description, flags, completion ); \ + static void name( const CCommand &args ) +#endif + + +#define CON_COMMAND_EXTERN( name, _funcname, description ) \ + void _funcname( const CCommand &args ); \ + static ConCommand name##_command( #name, _funcname, description ); \ + void _funcname( const CCommand &args ) + +#define CON_COMMAND_EXTERN_F( name, _funcname, description, flags ) \ + void _funcname( const CCommand &args ); \ + static ConCommand name##_command( #name, _funcname, description, flags ); \ + void _funcname( const CCommand &args ) + +#define CON_COMMAND_MEMBER_F( _thisclass, name, _funcname, description, flags ) \ + void _funcname( const CCommand &args ); \ + friend class CCommandMemberInitializer_##_funcname; \ + class CCommandMemberInitializer_##_funcname \ + { \ + public: \ + CCommandMemberInitializer_##_funcname() : m_ConCommandAccessor( NULL, name, &_thisclass::_funcname, description, flags ) \ + { \ + m_ConCommandAccessor.SetOwner( GET_OUTER( _thisclass, m_##_funcname##_register ) ); \ + } \ + private: \ + CConCommandMemberAccessor< _thisclass > m_ConCommandAccessor; \ + }; \ + \ + CCommandMemberInitializer_##_funcname m_##_funcname##_register; \ + + +#endif // CONVAR_H From 083c904d429ad9583d3483426feacfcb0d3d7a5b Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Fri, 16 Jun 2017 20:46:27 +0200 Subject: [PATCH 02/13] Added missing engine specific export function --- .../modules/engines/insurgency/engines_wrap.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/core/modules/engines/insurgency/engines_wrap.h b/src/core/modules/engines/insurgency/engines_wrap.h index 840c6df16..6884b92b4 100644 --- a/src/core/modules/engines/insurgency/engines_wrap.h +++ b/src/core/modules/engines/insurgency/engines_wrap.h @@ -96,4 +96,20 @@ T IEngineSound_Visitor(T cls) return cls; } + +//----------------------------------------------------------------------------- +// Exports IServerGameDLL. +//----------------------------------------------------------------------------- +template +void export_engine_specific_server_game_dll(T _server, U ServerGameDLL) +{ + // Methods... + ServerGameDLL.def("server_hibernation_update", &IServerGameDLL::ServerHibernationUpdate); + + // Class info... + BEGIN_CLASS_INFO(IServerGameDLL) + FUNCTION_INFO(ServerHibernationUpdate) + END_CLASS_INFO() +} + #endif // _ENGINES_WRAP_INSURGENCY_H From 0466a0cd8979a0833f0e667fcdcdc2a4db1e5f4b Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Fri, 16 Jun 2017 20:46:57 +0200 Subject: [PATCH 03/13] Added missing interfaces.lib linkage --- src/makefiles/win32/win32.base.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/makefiles/win32/win32.base.cmake b/src/makefiles/win32/win32.base.cmake index 1677fb006..dddf8c3ed 100644 --- a/src/makefiles/win32/win32.base.cmake +++ b/src/makefiles/win32/win32.base.cmake @@ -64,7 +64,7 @@ Set(SOURCEPYTHON_LINK_LIBRARIES ) # CSGO Engine adds in interfaces.lib -If( SOURCE_ENGINE MATCHES "csgo" OR SOURCE_ENGINE MATCHES "blade") +If( SOURCE_ENGINE MATCHES "csgo" OR SOURCE_ENGINE MATCHES "blade" OR SOURCE_ENGINE MATCHES "insurgency") Set(SOURCEPYTHON_LINK_LIBRARIES ${SOURCEPYTHON_LINK_LIBRARIES} ${SOURCESDK_LIB}/public/interfaces.lib From 234a407051b7a6aca7249633694d7914a50c7c9f Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Fri, 16 Jun 2017 21:30:45 +0200 Subject: [PATCH 04/13] Added missing libraries --- src/makefiles/linux/linux.base.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/makefiles/linux/linux.base.cmake b/src/makefiles/linux/linux.base.cmake index 96ce0a492..25e443358 100644 --- a/src/makefiles/linux/linux.base.cmake +++ b/src/makefiles/linux/linux.base.cmake @@ -83,6 +83,15 @@ If(SOURCE_ENGINE MATCHES "csgo" OR SOURCE_ENGINE MATCHES "blade") ) EndIf() +If(SOURCE_ENGINE MATCHES "insurgency") + Set(SOURCEPYTHON_LINK_LIBRARIES + "${SOURCEPYTHON_LINK_LIBRARIES}" + ${SOURCESDK_LIB}/linux/interfaces_i486.a + ${SOURCESDK_LIB}/linux/libtier0_srv.so + ${SOURCESDK_LIB}/linux/libvstdlib_srv.so + ) +EndIf() + If(SOURCE_ENGINE MATCHES "csgo") Set(SOURCEPYTHON_LINK_LIBRARIES "${SOURCEPYTHON_LINK_LIBRARIES}" From a259fe7ae3876801bbd86cc0452bada6269e1d87 Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Sat, 17 Jun 2017 09:16:10 +0200 Subject: [PATCH 05/13] Fixed an error during loading process --- .../source-python/packages/source-python/listeners/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/source-python/packages/source-python/listeners/__init__.py b/addons/source-python/packages/source-python/listeners/__init__.py index 0ac1c0730..d27221daf 100644 --- a/addons/source-python/packages/source-python/listeners/__init__.py +++ b/addons/source-python/packages/source-python/listeners/__init__.py @@ -533,7 +533,7 @@ def _pre_call_global_change_callbacks(args): # Get the function name to hook... if SOURCE_ENGINE in ('bms', 'orangebox'): _hibernation_function_name = 'SetServerHibernation' -elif SOURCE_ENGINE in ('blade', 'csgo', 'l4d2'): +elif SOURCE_ENGINE in ('blade', 'csgo', 'l4d2', 'insurgency'): _hibernation_function_name = 'ServerHibernationUpdate' else: # To remind us to add newly supported engines... From 9bf399c485ad7ce2170a771f6feb267560557ea6 Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Sat, 17 Jun 2017 09:59:30 +0200 Subject: [PATCH 06/13] Added game data for insurgency --- .../memory/insurgency/global_pointers.ini | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 addons/source-python/data/source-python/memory/insurgency/global_pointers.ini diff --git a/addons/source-python/data/source-python/memory/insurgency/global_pointers.ini b/addons/source-python/data/source-python/memory/insurgency/global_pointers.ini new file mode 100644 index 000000000..680d574a2 --- /dev/null +++ b/addons/source-python/data/source-python/memory/insurgency/global_pointers.ini @@ -0,0 +1,33 @@ +# ../data/source-python/memory/insurgency/global_pointers.ini + +[CEntityFactoryDictionary] +binary = server +identifier_linux = _ZZ23EntityFactoryDictionaryvE15s_EntityFactory +identifier_windows = A1 2A 2A 2A 2A A8 01 75 2A 83 C8 01 B9 2A 2A 2A 2A A3 2A 2A 2A 2A +offset_windows = 13 +level_windows = 1 + +[CGlobalEntityList] +binary = server +identifier_linux = gEntList +# CFuncElevator::InputMoveToFloor +identifier_windows = 55 8B EC 57 8B F9 80 BF 30 04 00 00 00 +offset_windows = 140 +level_windows = 1 + +[IServer] +binary = bin/engine +identifier_linux = sv +# CVEngineServer::LightStyle +identifier_windows = 55 8B EC 53 8B 5D 0C 56 57 85 DB +offset_windows = 27 +level_windows = 1 + +[CBaseTempEntity] +binary = server +identifier_linux = _ZN15CBaseTempEntity15s_pTempEntitiesE +# CBaseTempEntity::PrecacheTempEnts +identifier_windows = 56 8B 35 2A 2A 2A 2A 85 F6 74 2A EB 2A +offset_windows = 3 +level_windows = 2 +level_linux = 1 From a7296446372448ea7fa3893b5dc744758fe2a9a9 Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Sat, 17 Jun 2017 10:05:36 +0200 Subject: [PATCH 07/13] Added game data for insurgency --- .../entity_output/insurgency/CBaseEntityOutput.ini | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 addons/source-python/data/source-python/entity_output/insurgency/CBaseEntityOutput.ini diff --git a/addons/source-python/data/source-python/entity_output/insurgency/CBaseEntityOutput.ini b/addons/source-python/data/source-python/entity_output/insurgency/CBaseEntityOutput.ini new file mode 100644 index 000000000..6b7ccfb58 --- /dev/null +++ b/addons/source-python/data/source-python/entity_output/insurgency/CBaseEntityOutput.ini @@ -0,0 +1,10 @@ +# ../data/source-python/entity_output/insurgency/CBaseEntityOutput.ini + +binary = server + +[function] + [[fire_output]] + identifier_linux = _ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f + identifier_windows = 55 8B EC 83 EC 20 53 8B C1 + arguments_linux = POINTER, POINTER, POINTER, FLOAT + arguments_windows = INT, INT, INT, INT, POINTER, POINTER, POINTER, FLOAT \ No newline at end of file From fe35b22d55a4377e45a8f2d1dea2619235cca232 Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Sat, 17 Jun 2017 10:15:54 +0200 Subject: [PATCH 08/13] Added more data for insurgency --- .../insurgency/CBaseCombatCharacter.ini | 8 ++++ .../entities/insurgency/CBaseCombatWeapon.ini | 11 +++++ .../entities/insurgency/CBaseEntity.ini | 44 +++++++++++++++++++ .../entities/insurgency/CBasePlayer.ini | 44 +++++++++++++++++++ .../entities/insurgency/CINSPlayer.ini | 7 +++ 5 files changed, 114 insertions(+) create mode 100644 addons/source-python/data/source-python/entities/insurgency/CBaseCombatCharacter.ini create mode 100644 addons/source-python/data/source-python/entities/insurgency/CBaseCombatWeapon.ini create mode 100644 addons/source-python/data/source-python/entities/insurgency/CBaseEntity.ini create mode 100644 addons/source-python/data/source-python/entities/insurgency/CBasePlayer.ini create mode 100644 addons/source-python/data/source-python/entities/insurgency/CINSPlayer.ini diff --git a/addons/source-python/data/source-python/entities/insurgency/CBaseCombatCharacter.ini b/addons/source-python/data/source-python/entities/insurgency/CBaseCombatCharacter.ini new file mode 100644 index 000000000..2b5a1d6ad --- /dev/null +++ b/addons/source-python/data/source-python/entities/insurgency/CBaseCombatCharacter.ini @@ -0,0 +1,8 @@ +[virtual_function] + + # _ZN20CBaseCombatCharacter13Weapon_SwitchEP17CBaseCombatWeaponi + [[weapon_switch]] + offset_linux = 285 + offset_windows = 284 + arguments = POINTER, INT + return_type = BOOL diff --git a/addons/source-python/data/source-python/entities/insurgency/CBaseCombatWeapon.ini b/addons/source-python/data/source-python/entities/insurgency/CBaseCombatWeapon.ini new file mode 100644 index 000000000..8003b3eba --- /dev/null +++ b/addons/source-python/data/source-python/entities/insurgency/CBaseCombatWeapon.ini @@ -0,0 +1,11 @@ +[virtual_function] + + # _ZN17CBaseCombatWeapon13PrimaryAttackEv + [[primary_attack]] + offset_linux = 286 + offset_windows = 285 + + # _ZN17CBaseCombatWeapon13SecondaryAttackEv + [[secondary_attack]] + offset_linux = 287 + offset_windows = 286 diff --git a/addons/source-python/data/source-python/entities/insurgency/CBaseEntity.ini b/addons/source-python/data/source-python/entities/insurgency/CBaseEntity.ini new file mode 100644 index 000000000..d2cbb0a9a --- /dev/null +++ b/addons/source-python/data/source-python/entities/insurgency/CBaseEntity.ini @@ -0,0 +1,44 @@ +[virtual_function] + + # _ZN11CBaseEntity9SetParentEPS_i + [[set_parent]] + offset_linux = 37 + offset_windows = 36 + arguments = POINTER, INT + + # _ZN11CBaseEntity12OnTakeDamageERK15CTakeDamageInfo + [[on_take_damage]] + offset_linux = 68 + offset_windows = 67 + arguments = POINTER + return_type = INT + + # _ZN11CBaseEntity8TeleportEPK6VectorPK6QAngleS2_ + [[teleport]] + offset_linux = 116 + offset_windows = 115 + arguments = POINTER, POINTER, POINTER, BOOL + + # _ZN11CBaseEntity11SetTransmitEP18CCheckTransmitInfob + [[set_transmit]] + offset_linux = 21 + offset_windows = 20 + arguments = POINTER, BOOL + + # _ZN11CBaseEntity10StartTouchEPS_ + [[start_touch]] + offset_linux = 105 + offset_windows = 104 + arguments = POINTER + + # _ZN11CBaseEntity5TouchEPS_ + [[touch]] + offset_linux = 106 + offset_windows = 105 + arguments = POINTER + + # _ZN11CBaseEntity8EndTouchEPS_ + [[end_touch]] + offset_linux = 107 + offset_windows = 106 + arguments = POINTER diff --git a/addons/source-python/data/source-python/entities/insurgency/CBasePlayer.ini b/addons/source-python/data/source-python/entities/insurgency/CBasePlayer.ini new file mode 100644 index 000000000..12ed63076 --- /dev/null +++ b/addons/source-python/data/source-python/entities/insurgency/CBasePlayer.ini @@ -0,0 +1,44 @@ +[virtual_function] + + # _ZN11CBasePlayer10BumpWeaponEP17CBaseCombatWeapon + [[bump_weapon]] + offset_linux = 438 + offset_windows = 437 + arguments = POINTER + return_type = BOOL + + # _ZN11CBasePlayer11Weapon_DropEP17CBaseCombatWeaponPK6VectorS4_ + [[drop_weapon]] + offset_linux = 284 + offset_windows = 283 + arguments = POINTER, POINTER, POINTER + + # _ZN11CBasePlayer13GiveNamedItemEPKcibP11CBaseEntity + [[give_named_item]] + offset_linux = 442 + offset_windows = 441 + arguments = STRING, INT, BOOL + return_type = POINTER + + # _ZN11CBasePlayer16PlayerRunCommandEP8CUserCmdP11IMoveHelper + [[run_command]] + offset_linux = 461 + offset_windows = 460 + arguments = POINTER, POINTER + + # _ZN11CBasePlayer8PreThinkEv + [[pre_think]] + offset_linux = 362 + offset_windows = 361 + + # _ZN11CBasePlayer9PostThinkEv + [[post_think]] + offset_linux = 363 + offset_windows = 362 + + +[property] + + [[view_offset]] + name = m_vecViewOffset[0] + type = Vector diff --git a/addons/source-python/data/source-python/entities/insurgency/CINSPlayer.ini b/addons/source-python/data/source-python/entities/insurgency/CINSPlayer.ini new file mode 100644 index 000000000..7df9a6a72 --- /dev/null +++ b/addons/source-python/data/source-python/entities/insurgency/CINSPlayer.ini @@ -0,0 +1,7 @@ +[property] + + ragdoll = m_hRagdoll + + [[eye_angle]] + name = m_angEyeAngles[0] + type = QAngle From ab2d6bc172be59fd99d233f929223cfe2dcdec02 Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Sat, 17 Jun 2017 10:18:04 +0200 Subject: [PATCH 09/13] Added data for insurgency --- .../data/source-python/client/insurgency/CBaseClient.ini | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 addons/source-python/data/source-python/client/insurgency/CBaseClient.ini diff --git a/addons/source-python/data/source-python/client/insurgency/CBaseClient.ini b/addons/source-python/data/source-python/client/insurgency/CBaseClient.ini new file mode 100644 index 000000000..f2be2f077 --- /dev/null +++ b/addons/source-python/data/source-python/client/insurgency/CBaseClient.ini @@ -0,0 +1,7 @@ +# ../data/source-python/client/insurgency/CBaseClient.ini + +[virtual_function] + [[set_name]] + offset_linux = 68 + offset_windows = 21 + arguments = STRING From 50aa3eb30be804e114e16b759e24c52606efa62e Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Sat, 17 Jun 2017 12:14:17 +0200 Subject: [PATCH 10/13] Fixed a crash and updated docu --- .../source/developing/module_tutorials/listeners.rst | 2 +- src/core/sp_main.cpp | 4 +++- src/core/sp_main.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/addons/source-python/docs/source-python/source/developing/module_tutorials/listeners.rst b/addons/source-python/docs/source-python/source/developing/module_tutorials/listeners.rst index 701bc8044..dd88dde6b 100644 --- a/addons/source-python/docs/source-python/source/developing/module_tutorials/listeners.rst +++ b/addons/source-python/docs/source-python/source/developing/module_tutorials/listeners.rst @@ -111,7 +111,7 @@ Called when a combined model gets precached. def on_combiner_precache(cache_data_type, model_handle): pass -.. note:: This listener only gets called in CS:GO. +.. note:: This listener only gets called in CS:GO and Insurgency. OnConVarChanged diff --git a/src/core/sp_main.cpp b/src/core/sp_main.cpp index e15c654ea..42a8d6105 100644 --- a/src/core/sp_main.cpp +++ b/src/core/sp_main.cpp @@ -519,7 +519,7 @@ void CSourcePython::OnDataUnloaded( MDLCacheDataType_t type, MDLHandle_t handle CALL_LISTENERS(OnDataUnloaded, type, handle); } -#ifdef ENGINE_CSGO +#if defined(ENGINE_CSGO) || defined(ENGINE_INSURGENCY) void CSourcePython::OnCombinerPreCache(MDLCacheDataType_t type, MDLHandle_t handle ) { if (m_pOldMDLCacheNotifier) @@ -536,7 +536,9 @@ bool CSourcePython::ShouldSupressLoadWarning(MDLHandle_t handle) return result; } +#endif +#if defined(ENGINE_CSGO) bool CSourcePython::BNetworkCryptKeyCheckRequired( uint32 unFromIP, uint16 usFromPort, uint32 unAccountIdProvidedByClient, bool bClientWantsToUseCryptKey ) { diff --git a/src/core/sp_main.h b/src/core/sp_main.h index ce1ae5898..dc54589b1 100644 --- a/src/core/sp_main.h +++ b/src/core/sp_main.h @@ -118,7 +118,7 @@ class CSourcePython: public IServerPluginCallbacks, public IEntityListener, publ // ------------------------------------------- virtual void OnDataLoaded( MDLCacheDataType_t type, MDLHandle_t handle ); virtual void OnDataUnloaded( MDLCacheDataType_t type, MDLHandle_t handle ); -#ifdef ENGINE_CSGO +#if defined(ENGINE_CSGO) || defined(ENGINE_INSURGENCY) virtual void OnCombinerPreCache(MDLCacheDataType_t type, MDLHandle_t handle ); virtual bool ShouldSupressLoadWarning(MDLHandle_t handle); #endif From b8bf30747e10b6f6940e8c238dea326582ddd77a Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Mon, 19 Jun 2017 21:27:17 +0200 Subject: [PATCH 11/13] Fixed compiler error due to updates from master --- .../entities/insurgency/entities_constants_wrap.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/modules/entities/insurgency/entities_constants_wrap.h b/src/core/modules/entities/insurgency/entities_constants_wrap.h index 20dba22cd..58ba73879 100644 --- a/src/core/modules/entities/insurgency/entities_constants_wrap.h +++ b/src/core/modules/entities/insurgency/entities_constants_wrap.h @@ -74,6 +74,16 @@ void export_engine_specific_entity_effects(T _constants) } +//----------------------------------------------------------------------------- +// Exports RenderMode_t. +//----------------------------------------------------------------------------- +template +void export_engine_specific_render_mode(T _constants, U RenderEffects) +{ + // Nothing specific to Insurgency... +} + + //----------------------------------------------------------------------------- // Exports RenderFx_t. //----------------------------------------------------------------------------- From f51bd8d2f8d3f972f878d3ef271bfae265e148c9 Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Mon, 25 Dec 2017 17:02:21 +0100 Subject: [PATCH 12/13] Fixed event descriptor stuff --- src/core/modules/events/events_generator.cpp | 3 +++ src/core/modules/events/events_generator.h | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/core/modules/events/events_generator.cpp b/src/core/modules/events/events_generator.cpp index ddc4d48ce..4aa11cfcf 100644 --- a/src/core/modules/events/events_generator.cpp +++ b/src/core/modules/events/events_generator.cpp @@ -40,6 +40,9 @@ const char* CGameEventDescriptor::GetName() #if defined(ENGINE_CSGO) || defined(ENGINE_LEFT4DEAD2) || defined(ENGINE_BLADE) CGameEventManager2* manager = (CGameEventManager2*) gameeventmanager; return manager->event_names[name_index].key; +#elif defined(ENGINE_INSURGENCY) + CGameEventManager2* manager = (CGameEventManager2*) gameeventmanager; + return manager->events.GetElementName(this->eventid); #else return name; #endif diff --git a/src/core/modules/events/events_generator.h b/src/core/modules/events/events_generator.h index 90a0fc3e2..d2686f657 100644 --- a/src/core/modules/events/events_generator.h +++ b/src/core/modules/events/events_generator.h @@ -38,6 +38,7 @@ using namespace boost::python; #include "igameevents.h" #include "tier1/utlmap.h" #include "tier1/utlvector.h" +#include "tier1/utldict.h" //----------------------------------------------------------------------------- @@ -95,6 +96,15 @@ class CGameEventDescriptor bool reliable; // 33 char unknown[18]; // 34 // Total size: 52 +#elif defined(ENGINE_INSURGENCY) + int eventid; // 0 - Same like name_index - OK + int name_index; // 4 - OK + KeyValues *keys; // 8 - OK + CUtlVector listeners; // 12 + bool local; // 32 + bool reliable; // 33 + char unknown[22]; // 34 + // Total size: 56 #else char name[MAX_EVENT_NAME_LENGTH]; // 0 int eventid; // 32 @@ -118,6 +128,9 @@ class CGameEventManager2: public IGameEventManager2 #if defined(ENGINE_CSGO) || defined(ENGINE_LEFT4DEAD2) || defined(ENGINE_BLADE) char unknown[96]; CUtlRBTree< CUtlMap::Node_t, int > event_names; +#elif defined (ENGINE_INSURGENCY) + char unknown[96]; + CUtlDict events; #endif }; From 5fe56d58982d58b47163e75ad32435dec8af1c13 Mon Sep 17 00:00:00 2001 From: Ayuto22 Date: Mon, 25 Dec 2017 17:04:44 +0100 Subject: [PATCH 13/13] Added event documentation for Insurgency --- .../source/developing/events/insurgency.rst | 1596 +++++++++++++++++ 1 file changed, 1596 insertions(+) create mode 100644 addons/source-python/docs/source-python/source/developing/events/insurgency.rst diff --git a/addons/source-python/docs/source-python/source/developing/events/insurgency.rst b/addons/source-python/docs/source-python/source/developing/events/insurgency.rst new file mode 100644 index 000000000..4cf6cca95 --- /dev/null +++ b/addons/source-python/docs/source-python/source/developing/events/insurgency.rst @@ -0,0 +1,1596 @@ +Insurgency +========== + +This is a summary of all known Insurgency events. + + +achievement_earned +------------------ + +=========== ==================================================== ======= +Name Description Type +=========== ==================================================== ======= +achievement short +player byte +=========== ==================================================== ======= + + +achievement_info_loaded +----------------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +artillery_called +---------------- + +================= ==================================================== ======= +Name Description Type +================= ==================================================== ======= +lethal bool +radio_player short +requesting_player short +target_x float +target_y float +target_z float +team short +type string +================= ==================================================== ======= + + +artillery_failed +---------------- + +================= ==================================================== ======= +Name Description Type +================= ==================================================== ======= +lethal bool +radio_player short +reason string +requesting_player short +team short +type string +================= ==================================================== ======= + + +artillery_requested +------------------- + +================= ==================================================== ======= +Name Description Type +================= ==================================================== ======= +lethal bool +radio_player short +requesting_player short +target_x float +target_y float +target_z float +team short +type string +================= ==================================================== ======= + + +break_breakable +--------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +entindex long +material byte +userid short +======== ==================================================== ======= + + +break_prop +---------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +entindex long +userid short +======== ==================================================== ======= + + +client_disconnect +----------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +controlpoint_captured +--------------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +cappers string +cp byte +cpname string +oldteam byte +priority short +team byte +======== ==================================================== ======= + + +controlpoint_endtouch +--------------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +area byte +owner short +player short +team short +====== ==================================================== ======= + + +controlpoint_initialized +------------------------ + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +controlpoint_neutralized +------------------------ + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +cappers string +cp byte +cpname string +oldteam byte +priority short +team byte +======== ==================================================== ======= + + +controlpoint_regroup_available +------------------------------ + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +cp byte +team short +==== ==================================================== ======= + + +controlpoint_regroup_triggered +------------------------------ + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +cp byte +player short +team short +====== ==================================================== ======= + + +controlpoint_starttouch +----------------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +area byte +object short +owner short +player short +team short +type short +====== ==================================================== ======= + + +door_moving +----------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +entindex long +userid short +======== ==================================================== ======= + + +enter_spawnzone +--------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +userid short +====== ==================================================== ======= + + +entity_killed +------------- + +================== ==================================================== ======= +Name Description Type +================== ==================================================== ======= +damagebits long +entindex_attacker long +entindex_inflictor long +entindex_killed long +================== ==================================================== ======= + + +entity_visible +-------------- + +========== ==================================================== ======= +Name Description Type +========== ==================================================== ======= +classname string +entityname string +subject short +userid short +========== ==================================================== ======= + + +exit_spawnzone +-------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +userid short +====== ==================================================== ======= + + +flag_captured +------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +cp short +priority short +userid short +======== ==================================================== ======= + + +flag_drop +--------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +priority short +userid short +======== ==================================================== ======= + + +flag_pickup +----------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +priority short +userid short +======== ==================================================== ======= + + +flag_reset +---------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +priority short +team short +======== ==================================================== ======= + + +flag_returned +------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +priority short +userid short +======== ==================================================== ======= + + +freezecam_started +----------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +game_end +-------- + +=========== ==================================================== ======= +Name Description Type +=========== ==================================================== ======= +team1_score short +team2_score short +winner byte +=========== ==================================================== ======= + + +game_init +--------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +game_newmap +----------- + +======= ==================================================== ======= +Name Description Type +======= ==================================================== ======= +mapname string +======= ==================================================== ======= + + +game_start +---------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +priority short +======== ==================================================== ======= + + +game_teams_switched +------------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +gameinstructor_draw +------------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +gameinstructor_nodraw +--------------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +grenade_detonate +---------------- + +=============== ==================================================== ======= +Name Description Type +=============== ==================================================== ======= +effectedEnemies short +entityid long +id short +userid short +x float +y float +z float +=============== ==================================================== ======= + + +grenade_thrown +-------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +entityid long +id short +userid short +======== ==================================================== ======= + + +hide_freezepanel +---------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +hltv_cameraman +-------------- + +===== ==================================================== ======= +Name Description Type +===== ==================================================== ======= +index short +===== ==================================================== ======= + + +hltv_changed_mode +----------------- + +========== ==================================================== ======= +Name Description Type +========== ==================================================== ======= +newmode long +obs_target long +oldmode long +========== ==================================================== ======= + + +hltv_chase +---------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +distance short +inertia byte +ineye byte +phi short +target1 short +target2 short +theta short +======== ==================================================== ======= + + +hltv_chat +--------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +text string +==== ==================================================== ======= + + +hltv_fixed +---------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +fov float +offset short +phi short +posx long +posy long +posz long +target short +theta short +====== ==================================================== ======= + + +hltv_message +------------ + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +text string +==== ==================================================== ======= + + +hltv_rank_camera +---------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +index byte +rank float +target short +====== ==================================================== ======= + + +hltv_rank_entity +---------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +index short +rank float +target short +====== ==================================================== ======= + + +hltv_status +----------- + +======= ==================================================== ======= +Name Description Type +======= ==================================================== ======= +clients long +master string +proxies short +slots long +======= ==================================================== ======= + + +hltv_title +---------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +text string +==== ==================================================== ======= + + +hostname_changed +---------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +hostname string +======== ==================================================== ======= + + +instructor_ai_difficulty +------------------------ + +============= ==================================================== ======= +Name Description Type +============= ==================================================== ======= +ai_win bool +rounds_failed byte +============= ==================================================== ======= + + +instructor_server_hint_create +----------------------------- + +======================== ==================================================== ======= +Name Description Type +======================== ==================================================== ======= +hint_activator_caption string +hint_activator_userid short +hint_allow_nodraw_target bool +hint_binding string +hint_caption string +hint_color string +hint_flags long +hint_forcecaption bool +hint_gamepad_binding string +hint_icon_offscreen string +hint_icon_offset float +hint_icon_onscreen string +hint_local_player_only bool +hint_name string +hint_nooffscreen bool +hint_range float +hint_replace_key string +hint_target long +hint_timeout short +======================== ==================================================== ======= + + +instructor_server_hint_stop +--------------------------- + +========= ==================================================== ======= +Name Description Type +========= ==================================================== ======= +hint_name string +========= ==================================================== ======= + + +inventory_close +--------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +inventory_open +-------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +map_transition +-------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +missile_detonate +---------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +entityid long +id short +userid short +x float +y float +z float +======== ==================================================== ======= + + +missile_launched +---------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +entityid long +id short +userid short +======== ==================================================== ======= + + +nav_blocked +----------- + +======= ==================================================== ======= +Name Description Type +======= ==================================================== ======= +area long +blocked bool +======= ==================================================== ======= + + +nav_generate +------------ + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +object_destroyed +---------------- + +============ ==================================================== ======= +Name Description Type +============ ==================================================== ======= +assister byte +attacker byte +attackerteam byte +cp short +index short +team byte +type byte +weapon string +weaponid short +============ ==================================================== ======= + + +player_activate +--------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +userid short +====== ==================================================== ======= + + +player_avenged_teammate +----------------------- + +================= ==================================================== ======= +Name Description Type +================= ==================================================== ======= +avenged_player_id short +avenger_id short +================= ==================================================== ======= + + +player_blind +------------ + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +userid short +====== ==================================================== ======= + + +player_changename +----------------- + +======= ==================================================== ======= +Name Description Type +======= ==================================================== ======= +newname string +oldname string +userid short +======= ==================================================== ======= + + +player_connect +-------------- + +========= ==================================================== ======= +Name Description Type +========= ==================================================== ======= +address string +bot short +index byte +name string +networkid string +userid short +========= ==================================================== ======= + + +player_connect_full +------------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +index byte +userid short +====== ==================================================== ======= + + +player_death +------------ + +============ ==================================================== ======= +Name Description Type +============ ==================================================== ======= +assister short +attacker short +attackerteam short +customkill short +damagebits long +deathflags short +lives short +priority short +team short +userid short +weapon string +weaponid short +x float +y float +z float +============ ==================================================== ======= + + +player_decal +------------ + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +userid short +====== ==================================================== ======= + + +player_disconnect +----------------- + +========= ==================================================== ======= +Name Description Type +========= ==================================================== ======= +bot short +name string +networkid string +reason string +userid short +========= ==================================================== ======= + + +player_drop +----------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +entity short +userid short +====== ==================================================== ======= + + +player_falldamage +----------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +damage float +userid short +====== ==================================================== ======= + + +player_first_spawn +------------------ + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +userid short +====== ==================================================== ======= + + +player_footstep +--------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +userid short +====== ==================================================== ======= + + +player_hintmessage +------------------ + +=========== ==================================================== ======= +Name Description Type +=========== ==================================================== ======= +hintmessage string +=========== ==================================================== ======= + + +player_hurt +----------- + +========== ==================================================== ======= +Name Description Type +========== ==================================================== ======= +attacker short +damagebits long +dmg_health short +health byte +hitgroup short +priority short +userid short +weapon string +weaponid short +========== ==================================================== ======= + + +player_info +----------- + +========= ==================================================== ======= +Name Description Type +========= ==================================================== ======= +bot bool +index byte +name string +networkid string +userid short +========= ==================================================== ======= + + +player_jump +----------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +userid short +====== ==================================================== ======= + + +player_pick_squad +----------------- + +============== ==================================================== ======= +Name Description Type +============== ==================================================== ======= +class_template string +squad byte +squad_slot byte +userid short +============== ==================================================== ======= + + +player_receive_supply +--------------------- + +======= ==================================================== ======= +Name Description Type +======= ==================================================== ======= +ammount short +userid short +======= ==================================================== ======= + + +player_say +---------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +text string +userid short +====== ==================================================== ======= + + +player_spawn +------------ + +======= ==================================================== ======= +Name Description Type +======= ==================================================== ======= +teamnum short +userid short +======= ==================================================== ======= + + +player_stats_updated +-------------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +player_suppressed +----------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +attacker short +victim short +======== ==================================================== ======= + + +player_team +----------- + +========== ==================================================== ======= +Name Description Type +========== ==================================================== ======= +autoteam bool +disconnect bool +isbot bool +oldteam byte +silent bool +team byte +userid short +========== ==================================================== ======= + + +player_use +---------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +entity short +userid short +====== ==================================================== ======= + + +radio_requested +--------------- + +================= ==================================================== ======= +Name Description Type +================= ==================================================== ======= +requesting_player short +team short +================= ==================================================== ======= + + +ragdoll_dissolved +----------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +entindex long +======== ==================================================== ======= + + +rank_mgr_ranks_calculated +------------------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +read_game_titledata +------------------- + +============ ==================================================== ======= +Name Description Type +============ ==================================================== ======= +controllerId short +============ ==================================================== ======= + + +reset_game_titledata +-------------------- + +============ ==================================================== ======= +Name Description Type +============ ==================================================== ======= +controllerId short +============ ==================================================== ======= + + +round_begin +----------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +round_end +--------- + +============== ==================================================== ======= +Name Description Type +============== ==================================================== ======= +message string +message_string string +reason byte +winner byte +============== ==================================================== ======= + + +round_freeze_end +---------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +round_level_advanced +-------------------- + +===== ==================================================== ======= +Name Description Type +===== ==================================================== ======= +level short +===== ==================================================== ======= + + +round_restart +------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +round_start +----------- + +========= ==================================================== ======= +Name Description Type +========= ==================================================== ======= +gametype short +lives short +priority short +timelimit short +========= ==================================================== ======= + + +round_start_pre_entity +---------------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +round_timer_changed +------------------- + +===== ==================================================== ======= +Name Description Type +===== ==================================================== ======= +delta float +===== ==================================================== ======= + + +server_addban +------------- + +========= ==================================================== ======= +Name Description Type +========= ==================================================== ======= +by string +duration string +ip string +kicked bool +name string +networkid string +userid short +========= ==================================================== ======= + + +server_cvar +----------- + +========= ==================================================== ======= +Name Description Type +========= ==================================================== ======= +cvarname string +cvarvalue string +========= ==================================================== ======= + + +server_message +-------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +text string +==== ==================================================== ======= + + +server_pre_shutdown +------------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +reason string +====== ==================================================== ======= + + +server_removeban +---------------- + +========= ==================================================== ======= +Name Description Type +========= ==================================================== ======= +by string +ip string +networkid string +========= ==================================================== ======= + + +server_shutdown +--------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +reason string +====== ==================================================== ======= + + +server_spawn +------------ + +========== ==================================================== ======= +Name Description Type +========== ==================================================== ======= +address string +dedicated bool +game string +hostname string +mapname string +maxplayers long +os string +password bool +port short +========== ==================================================== ======= + + +set_instructor_group_enabled +---------------------------- + +======= ==================================================== ======= +Name Description Type +======= ==================================================== ======= +enabled short +group string +======= ==================================================== ======= + + +show_freezepanel +---------------- + +============ ==================================================== ======= +Name Description Type +============ ==================================================== ======= +damage_given short +damage_taken short +hits_given short +hits_taken short +killer short +victim short +============ ==================================================== ======= + + +smoke_grenade_expire +-------------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +entityid long +id short +userid short +x float +y float +z float +======== ==================================================== ======= + + +spec_mode_updated +----------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +spec_target_updated +------------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +stat_leaderboard_updated +------------------------ + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +stat_local_load_finish +---------------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +stat_local_load_start +--------------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +stat_summary_updated +-------------------- + +=========== ==================================================== ======= +Name Description Type +=========== ==================================================== ======= +localplayer bool +=========== ==================================================== ======= + + +teamplay_broadcast_audio +------------------------ + +===== ==================================================== ======= +Name Description Type +===== ==================================================== ======= +sound string +team byte +===== ==================================================== ======= + + +theater_loaded +-------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +time_class +---------- + +======= ==================================================== ======= +Name Description Type +======= ==================================================== ======= +class short +seconds float +userid short +======= ==================================================== ======= + + +time_weapon +----------- + +======= ==================================================== ======= +Name Description Type +======= ==================================================== ======= +seconds float +userid short +weapon short +======= ==================================================== ======= + + +training_timer +-------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +duration float +======== ==================================================== ======= + + +user_data_downloaded +-------------------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +==== ==================================================== ======= + + +vote_cast +--------- + +=========== ==================================================== ======= +Name Description Type +=========== ==================================================== ======= +entityid long +team short +vote_option byte +=========== ==================================================== ======= + + +vote_changed +------------ + +============== ==================================================== ======= +Name Description Type +============== ==================================================== ======= +potentialVotes byte +vote_option1 byte +vote_option2 byte +vote_option3 byte +vote_option4 byte +vote_option5 byte +============== ==================================================== ======= + + +vote_failed +----------- + +==== ==================================================== ======= +Name Description Type +==== ==================================================== ======= +team byte +==== ==================================================== ======= + + +vote_options +------------ + +======= ==================================================== ======= +Name Description Type +======= ==================================================== ======= +count byte +option1 string +option2 string +option3 string +option4 string +option5 string +======= ==================================================== ======= + + +vote_passed +----------- + +======= ==================================================== ======= +Name Description Type +======= ==================================================== ======= +details string +param1 string +team byte +======= ==================================================== ======= + + +vote_started +------------ + +========= ==================================================== ======= +Name Description Type +========= ==================================================== ======= +initiator long +issue string +param1 string +team byte +========= ==================================================== ======= + + +weapon_deploy +------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +userid short +weaponid short +======== ==================================================== ======= + + +weapon_fire +----------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +shots byte +userid short +weaponid short +======== ==================================================== ======= + + +weapon_fire_on_empty +-------------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +userid short +weapon string +====== ==================================================== ======= + + +weapon_firemode +--------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +firemode byte +userid short +weaponid short +======== ==================================================== ======= + + +weapon_focus_enter +------------------ + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +userid short +weaponid short +======== ==================================================== ======= + + +weapon_focus_exit +----------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +userid short +weaponid short +======== ==================================================== ======= + + +weapon_holster +-------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +userid short +weaponid short +======== ==================================================== ======= + + +weapon_ironsight +---------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +userid short +weaponid short +======== ==================================================== ======= + + +weapon_lower_sight +------------------ + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +userid short +weaponid short +======== ==================================================== ======= + + +weapon_outofammo +---------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +userid short +====== ==================================================== ======= + + +weapon_pickup +------------- + +======== ==================================================== ======= +Name Description Type +======== ==================================================== ======= +userid short +weaponid short +======== ==================================================== ======= + + +weapon_reload +------------- + +====== ==================================================== ======= +Name Description Type +====== ==================================================== ======= +userid short +====== ==================================================== ======= + + +write_game_titledata +-------------------- + +============ ==================================================== ======= +Name Description Type +============ ==================================================== ======= +controllerId short +============ ==================================================== =======