From d431a8007dca5dbd91e7f215105949f77fc33d1e Mon Sep 17 00:00:00 2001 From: 0TheSpy Date: Wed, 16 Jun 2021 18:45:17 +0300 Subject: [PATCH] Add files via upload --- SpyCustom/sdk/BuildGroup.h | 143 + SpyCustom/sdk/Button.h | 185 ++ SpyCustom/sdk/ButtonCode.h | 364 +++ SpyCustom/sdk/CGameUI.h | 48 + SpyCustom/sdk/CheckButton.h | 85 + SpyCustom/sdk/Color.h | 85 + SpyCustom/sdk/Controls.h | 103 + SpyCustom/sdk/Cursor.h | 40 + SpyCustom/sdk/Dar.h | 121 + SpyCustom/sdk/EditablePanel.h | 98 + SpyCustom/sdk/FocusNavGroup.h | 49 + SpyCustom/sdk/Frame.h | 198 ++ SpyCustom/sdk/GameEventListener.h | 52 + SpyCustom/sdk/GameEventManager.h | 157 ++ SpyCustom/sdk/animationlayer.h | 335 +++ SpyCustom/sdk/annotations.h | 64 + SpyCustom/sdk/baseclientstate.h | 118 + SpyCustom/sdk/baseentity.h | 352 +++ SpyCustom/sdk/baseentity_shared.h | 277 ++ SpyCustom/sdk/basehandle.h | 160 ++ SpyCustom/sdk/basetypes.h | 341 +++ SpyCustom/sdk/beam_flags.h | 29 + SpyCustom/sdk/bitbuf.h | 624 +++++ SpyCustom/sdk/bittools.h | 38 + SpyCustom/sdk/bitvec.h | 1239 +++++++++ SpyCustom/sdk/bone_accessor.h | 122 + SpyCustom/sdk/bone_merge_cache.h | 68 + SpyCustom/sdk/bspfile.h | 1067 +++++++ SpyCustom/sdk/bspflags.h | 101 + SpyCustom/sdk/bumpvects.h | 27 + SpyCustom/sdk/byteswap.h | 170 ++ SpyCustom/sdk/c_baseanimating.h | 696 +++++ SpyCustom/sdk/c_baseanimatingoverlay.h | 53 + SpyCustom/sdk/c_basecombatcharacter.h | 168 ++ SpyCustom/sdk/c_baseentity.h | 192 ++ SpyCustom/sdk/c_baseflex.h | 284 ++ SpyCustom/sdk/c_baseplayer.h | 619 +++++ SpyCustom/sdk/c_basetempentity.h | 98 + SpyCustom/sdk/c_input.h | 93 + SpyCustom/sdk/c_pixel_visibility.h | 48 + SpyCustom/sdk/c_playerlocaldata.h | 66 + SpyCustom/sdk/c_recipientfilter.h | 149 + SpyCustom/sdk/c_te_legacytempents.h | 178 ++ SpyCustom/sdk/cdll_client_int.h | 271 ++ SpyCustom/sdk/cdll_int.h | 632 +++++ SpyCustom/sdk/cdll_util.h | 149 + SpyCustom/sdk/checksum_crc.h | 25 + SpyCustom/sdk/checksum_md5.h | 51 + SpyCustom/sdk/client_class.h | 140 + SpyCustom/sdk/client_render_handle.h | 19 + SpyCustom/sdk/client_thinklist.h | 114 + SpyCustom/sdk/client_virtualreality.h | 123 + SpyCustom/sdk/cliententitylist.h | 252 ++ SpyCustom/sdk/clientleafsystem.h | 223 ++ SpyCustom/sdk/cmodel.h | 87 + SpyCustom/sdk/collisionproperty.h | 380 +++ SpyCustom/sdk/commonmacros.h | 85 + SpyCustom/sdk/compressed_light_cube.h | 18 + SpyCustom/sdk/compressed_vector.h | 519 ++++ SpyCustom/sdk/const.h | 364 +++ SpyCustom/sdk/convar.h | 541 ++++ SpyCustom/sdk/cs_achievementdefs.h | 261 ++ SpyCustom/sdk/cs_shareddefs.h | 391 +++ SpyCustom/sdk/cs_view_scene.h | 28 + SpyCustom/sdk/datamap.h | 397 +++ SpyCustom/sdk/dbg.h | 700 +++++ SpyCustom/sdk/dbgflag.h | 44 + SpyCustom/sdk/deformations.h | 48 + SpyCustom/sdk/dlight.h | 51 + SpyCustom/sdk/dmattributetypes.h | 329 +++ SpyCustom/sdk/dmelementhandle.h | 34 + SpyCustom/sdk/dmxattribute.h | 210 ++ SpyCustom/sdk/dmxelement.h | 472 ++++ SpyCustom/sdk/dmxloader.h | 48 + SpyCustom/sdk/dt_common.h | 191 ++ SpyCustom/sdk/dt_recv.h | 505 ++++ SpyCustom/sdk/dt_send.h | 686 +++++ SpyCustom/sdk/econ_item_constants.h | 550 ++++ SpyCustom/sdk/econ_item_interface.h | 287 ++ SpyCustom/sdk/econ_item_schema.h | 3522 ++++++++++++++++++++++++ SpyCustom/sdk/econ_item_view.h | 515 ++++ SpyCustom/sdk/edict.h | 370 +++ SpyCustom/sdk/ehandle.h | 150 + SpyCustom/sdk/eiface.h | 580 ++++ SpyCustom/sdk/enginetrace.h | 18 + SpyCustom/sdk/entitylist.h | 352 +++ SpyCustom/sdk/entitylist_base.h | 184 ++ SpyCustom/sdk/expressioncalculator.h | 65 + SpyCustom/sdk/exprevaluator.h | 66 + SpyCustom/sdk/fasttimer.h | 505 ++++ SpyCustom/sdk/filesystem.h | 747 +++++ SpyCustom/sdk/filesystem_passthru.h | 305 ++ SpyCustom/sdk/flashlighteffect.h | 319 +++ SpyCustom/sdk/fltx4.h | 93 + SpyCustom/sdk/functors.h | 798 ++++++ SpyCustom/sdk/fx.h | 156 ++ SpyCustom/sdk/game_item_schema.h | 61 + SpyCustom/sdk/gameconsole.h | 42 + SpyCustom/sdk/gamestringpool.h | 105 + 99 files changed, 27682 insertions(+) create mode 100644 SpyCustom/sdk/BuildGroup.h create mode 100644 SpyCustom/sdk/Button.h create mode 100644 SpyCustom/sdk/ButtonCode.h create mode 100644 SpyCustom/sdk/CGameUI.h create mode 100644 SpyCustom/sdk/CheckButton.h create mode 100644 SpyCustom/sdk/Color.h create mode 100644 SpyCustom/sdk/Controls.h create mode 100644 SpyCustom/sdk/Cursor.h create mode 100644 SpyCustom/sdk/Dar.h create mode 100644 SpyCustom/sdk/EditablePanel.h create mode 100644 SpyCustom/sdk/FocusNavGroup.h create mode 100644 SpyCustom/sdk/Frame.h create mode 100644 SpyCustom/sdk/GameEventListener.h create mode 100644 SpyCustom/sdk/GameEventManager.h create mode 100644 SpyCustom/sdk/animationlayer.h create mode 100644 SpyCustom/sdk/annotations.h create mode 100644 SpyCustom/sdk/baseclientstate.h create mode 100644 SpyCustom/sdk/baseentity.h create mode 100644 SpyCustom/sdk/baseentity_shared.h create mode 100644 SpyCustom/sdk/basehandle.h create mode 100644 SpyCustom/sdk/basetypes.h create mode 100644 SpyCustom/sdk/beam_flags.h create mode 100644 SpyCustom/sdk/bitbuf.h create mode 100644 SpyCustom/sdk/bittools.h create mode 100644 SpyCustom/sdk/bitvec.h create mode 100644 SpyCustom/sdk/bone_accessor.h create mode 100644 SpyCustom/sdk/bone_merge_cache.h create mode 100644 SpyCustom/sdk/bspfile.h create mode 100644 SpyCustom/sdk/bspflags.h create mode 100644 SpyCustom/sdk/bumpvects.h create mode 100644 SpyCustom/sdk/byteswap.h create mode 100644 SpyCustom/sdk/c_baseanimating.h create mode 100644 SpyCustom/sdk/c_baseanimatingoverlay.h create mode 100644 SpyCustom/sdk/c_basecombatcharacter.h create mode 100644 SpyCustom/sdk/c_baseentity.h create mode 100644 SpyCustom/sdk/c_baseflex.h create mode 100644 SpyCustom/sdk/c_baseplayer.h create mode 100644 SpyCustom/sdk/c_basetempentity.h create mode 100644 SpyCustom/sdk/c_input.h create mode 100644 SpyCustom/sdk/c_pixel_visibility.h create mode 100644 SpyCustom/sdk/c_playerlocaldata.h create mode 100644 SpyCustom/sdk/c_recipientfilter.h create mode 100644 SpyCustom/sdk/c_te_legacytempents.h create mode 100644 SpyCustom/sdk/cdll_client_int.h create mode 100644 SpyCustom/sdk/cdll_int.h create mode 100644 SpyCustom/sdk/cdll_util.h create mode 100644 SpyCustom/sdk/checksum_crc.h create mode 100644 SpyCustom/sdk/checksum_md5.h create mode 100644 SpyCustom/sdk/client_class.h create mode 100644 SpyCustom/sdk/client_render_handle.h create mode 100644 SpyCustom/sdk/client_thinklist.h create mode 100644 SpyCustom/sdk/client_virtualreality.h create mode 100644 SpyCustom/sdk/cliententitylist.h create mode 100644 SpyCustom/sdk/clientleafsystem.h create mode 100644 SpyCustom/sdk/cmodel.h create mode 100644 SpyCustom/sdk/collisionproperty.h create mode 100644 SpyCustom/sdk/commonmacros.h create mode 100644 SpyCustom/sdk/compressed_light_cube.h create mode 100644 SpyCustom/sdk/compressed_vector.h create mode 100644 SpyCustom/sdk/const.h create mode 100644 SpyCustom/sdk/convar.h create mode 100644 SpyCustom/sdk/cs_achievementdefs.h create mode 100644 SpyCustom/sdk/cs_shareddefs.h create mode 100644 SpyCustom/sdk/cs_view_scene.h create mode 100644 SpyCustom/sdk/datamap.h create mode 100644 SpyCustom/sdk/dbg.h create mode 100644 SpyCustom/sdk/dbgflag.h create mode 100644 SpyCustom/sdk/deformations.h create mode 100644 SpyCustom/sdk/dlight.h create mode 100644 SpyCustom/sdk/dmattributetypes.h create mode 100644 SpyCustom/sdk/dmelementhandle.h create mode 100644 SpyCustom/sdk/dmxattribute.h create mode 100644 SpyCustom/sdk/dmxelement.h create mode 100644 SpyCustom/sdk/dmxloader.h create mode 100644 SpyCustom/sdk/dt_common.h create mode 100644 SpyCustom/sdk/dt_recv.h create mode 100644 SpyCustom/sdk/dt_send.h create mode 100644 SpyCustom/sdk/econ_item_constants.h create mode 100644 SpyCustom/sdk/econ_item_interface.h create mode 100644 SpyCustom/sdk/econ_item_schema.h create mode 100644 SpyCustom/sdk/econ_item_view.h create mode 100644 SpyCustom/sdk/edict.h create mode 100644 SpyCustom/sdk/ehandle.h create mode 100644 SpyCustom/sdk/eiface.h create mode 100644 SpyCustom/sdk/enginetrace.h create mode 100644 SpyCustom/sdk/entitylist.h create mode 100644 SpyCustom/sdk/entitylist_base.h create mode 100644 SpyCustom/sdk/expressioncalculator.h create mode 100644 SpyCustom/sdk/exprevaluator.h create mode 100644 SpyCustom/sdk/fasttimer.h create mode 100644 SpyCustom/sdk/filesystem.h create mode 100644 SpyCustom/sdk/filesystem_passthru.h create mode 100644 SpyCustom/sdk/flashlighteffect.h create mode 100644 SpyCustom/sdk/fltx4.h create mode 100644 SpyCustom/sdk/functors.h create mode 100644 SpyCustom/sdk/fx.h create mode 100644 SpyCustom/sdk/game_item_schema.h create mode 100644 SpyCustom/sdk/gameconsole.h create mode 100644 SpyCustom/sdk/gamestringpool.h diff --git a/SpyCustom/sdk/BuildGroup.h b/SpyCustom/sdk/BuildGroup.h new file mode 100644 index 0000000..cd821eb --- /dev/null +++ b/SpyCustom/sdk/BuildGroup.h @@ -0,0 +1,143 @@ +#ifndef VGUI_BUILDGROUP_H +#define VGUI_BUILDGROUP_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "utlvector.h" +#include "utlsymbol.h" +#include "vgui.h" +#include "Dar.h" +#include "Cursor.h" +#include "IScheme.h" +#include "Controls.h" +#include "PHandle.h" +#include "utlhandletable.h" + +class KeyValues; + +namespace vgui +{ + + class BuildGroup + { + DECLARE_HANDLES(BuildGroup, 20); + + public: + BuildGroup(Panel* parentPanel, Panel* contextPanel); + ~BuildGroup(); + + virtual void SetEnabled(bool state); + + virtual bool IsEnabled(); + + virtual Panel* GetCurrentPanel(); + + virtual void LoadControlSettings(const char* controlResourceName, const char* pathID = NULL, KeyValues* pPreloadedKeyValues = NULL, KeyValues* pConditions = NULL); + + void ReloadControlSettings(); + + void ChangeControlSettingsFile(const char* controlResourceName); + + virtual bool SaveControlSettings(); + + virtual void ApplySettings(KeyValues* resourceData); + + virtual void GetSettings(KeyValues* resourceData); + + virtual void RemoveSettings(); + + void GetNewFieldName(char* newFieldName, int newFieldNameSize, Panel* newPanel); + + Panel* FieldNameTaken(const char* fieldName); + + Panel* NewControl(KeyValues* controlKeys, int x = 0, int y = 0); + Panel* NewControl(const char* name, int x = 0, int y = 0); + + virtual void SetContextPanel(Panel* contextPanel); + + virtual Panel* GetContextPanel(); + + CUtlVector* GetPanelList(); + + virtual const char* GetResourceName(void) { return m_pResourceName; } + + void PanelAdded(Panel* panel); + void PanelRemoved(Panel* panel); + + virtual bool MousePressed(MouseCode code, Panel* panel); + virtual bool MouseReleased(MouseCode code, Panel* panel); + + virtual CUtlVector* GetControlGroup(); + + virtual void ToggleRulerDisplay(); + + virtual void SetRulerLabelsVisible(bool state); + + virtual bool HasRulersOn(); + + virtual void DrawRulers(); + + void RegisterControlSettingsFile(const char* controlResourceName, const char* pathID = NULL); + + int GetRegisteredControlSettingsFileCount(); + const char* GetRegisteredControlSettingsFileByIndex(int index); + + KeyValues* GetDialogVariables(); + + void ProcessConditionalKeys(KeyValues* pDat, KeyValues* pConditions); + + protected: + virtual bool CursorMoved(int x, int y, Panel* panel); + virtual bool MouseDoublePressed(MouseCode code, Panel* panel); + virtual bool KeyCodeTyped(KeyCode code, Panel* panel); + virtual bool KeyCodeReleased(KeyCode code, Panel* panel); + virtual void ApplySchemeSettings(IScheme* pScheme); + virtual bool KeyTyped(wchar_t unichar, Panel* panel); + + virtual HCursor GetCursor(Panel* panel); + + private: + void ApplySnap(Panel* panel); + Panel* CreateBuildDialog(); + void ActivateBuildDialog(); + void DeleteAllControlsCreatedByControlSettingsFile(); + + bool _enabled; + int _snapX; + int _snapY; + HCursor _cursor_sizenwse; + HCursor _cursor_sizenesw; + HCursor _cursor_sizewe; + HCursor _cursor_sizens; + HCursor _cursor_sizeall; + bool _dragging; + MouseCode _dragMouseCode; + int _dragStartPanelPos[2]; + int _dragStartCursorPos[2]; + int _dragStartPanelSize[2]; + Panel* _currentPanel; + CUtlVector _panelDar; + char* m_pResourceName; + char* m_pResourcePathID; + PHandle m_hBuildDialog; + Panel* m_pBuildContext; + Panel* m_pParentPanel; + CUtlVector _controlGroup; + CUtlVector _groupDeltaX; + CUtlVector _groupDeltaY; + Label* _rulerNumber[4]; + bool _showRulers; + CUtlVector m_RegisteredControlSettingsFiles; + + friend class Panel; + }; + + + typedef CUtlHandle HBuildGroup; + + +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/Button.h b/SpyCustom/sdk/Button.h new file mode 100644 index 0000000..abd454d --- /dev/null +++ b/SpyCustom/sdk/Button.h @@ -0,0 +1,185 @@ +#ifndef BUTTON_H +#define BUTTON_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "VGUI.h" +#include "Dar.h" +#include "Color.h" +#include "Label.h" +#include "MouseCode.h" + +namespace vgui +{ + + class Button : public Label + { + DECLARE_CLASS_SIMPLE(Button, Label); + + public: + Button(Panel* parent, const char* panelName, const char* text, Panel* pActionSignalTarget = NULL, const char* pCmd = NULL); + Button(Panel* parent, const char* panelName, const wchar_t* text, Panel* pActionSignalTarget = NULL, const char* pCmd = NULL); + ~Button(); + private: + void Init(); + public: + virtual void SetArmed(bool state); + virtual bool IsArmed(void); + + virtual bool IsDepressed(); + virtual void ForceDepressed(bool state); + virtual void RecalculateDepressedState(void); + + virtual void SetSelected(bool state); + virtual bool IsSelected(void); + + virtual void SetBlink(bool state); + virtual bool IsBlinking(void); + + virtual void SetUseCaptureMouse(bool state); + virtual bool IsUseCaptureMouseEnabled(void); + + MESSAGE_FUNC(DoClick, "PressButton"); + MESSAGE_FUNC(OnHotkey, "Hotkey") + { + DoClick(); + } + + virtual void SetMouseClickEnabled(MouseCode code, bool state); + virtual bool IsMouseClickEnabled(MouseCode code); + enum ActivationType_t + { + ACTIVATE_ONPRESSEDANDRELEASED, + ACTIVATE_ONPRESSED, + ACTIVATE_ONRELEASED, + }; + virtual void SetButtonActivationType(ActivationType_t activationType); + + virtual void FireActionSignal(void); + virtual void PerformLayout(); + + virtual bool RequestInfo(KeyValues* data); + + virtual bool CanBeDefaultButton(void); + + MESSAGE_FUNC_INT(SetAsDefaultButton, "SetAsDefaultButton", state); + MESSAGE_FUNC_INT(SetAsCurrentDefaultButton, "SetAsCurrentDefaultButton", state); + + virtual void OnSetFocus(); + virtual void OnKillFocus(); + + virtual void SetButtonBorderEnabled(bool state); + + virtual void SetDefaultColor(Color fgColor, Color bgColor); + virtual void SetArmedColor(Color fgColor, Color bgColor); + virtual void SetSelectedColor(Color fgColor, Color bgColor); + virtual void SetDepressedColor(Color fgColor, Color bgColor); + virtual void SetBlinkColor(Color fgColor); + + virtual Color GetButtonFgColor(); + virtual Color GetButtonBgColor(); + + Color GetButtonDefaultFgColor() { return _defaultFgColor; } + Color GetButtonDefaultBgColor() { return _defaultBgColor; } + + Color GetButtonArmedFgColor() { return _armedFgColor; } + Color GetButtonArmedBgColor() { return _armedBgColor; } + + Color GetButtonSelectedFgColor() { return _selectedFgColor; } + Color GetButtonSelectedBgColor() { return _selectedBgColor; } + + Color GetButtonDepressedFgColor() { return _depressedFgColor; } + Color GetButtonDepressedBgColor() { return _depressedBgColor; } + + virtual void SetDefaultBorder(IBorder* border); + virtual void SetDepressedBorder(IBorder* border); + virtual void SetKeyFocusBorder(IBorder* border); + + virtual void SetCommand(const char* command); + virtual void SetCommand(KeyValues* message); + + void SetArmedSound(const char* sound); + void SetDepressedSound(const char* sound); + void SetReleasedSound(const char* sound); + + virtual void OnCursorEntered(); + virtual void OnCursorExited(); + virtual void SizeToContents(); + + virtual KeyValues* GetCommand(); + + bool IsDrawingFocusBox(); + void DrawFocusBox(bool bEnable); + + bool ShouldPaint() { return _paint; } + void SetShouldPaint(bool paint) { _paint = paint; } + + virtual void ApplySettings(KeyValues* inResourceData); + virtual void NavigateTo(); + virtual void NavigateFrom(); + + protected: + virtual void DrawFocusBorder(int tx0, int ty0, int tx1, int ty1); + + virtual void Paint(void); + virtual IBorder* GetBorder(bool depressed, bool armed, bool selected, bool keyfocus); + + virtual void ApplySchemeSettings(IScheme* pScheme); + MESSAGE_FUNC_INT(OnSetState, "SetState", state); + + virtual void OnMousePressed(MouseCode code); + virtual void OnMouseDoublePressed(MouseCode code); + virtual void OnMouseReleased(MouseCode code); + virtual void OnKeyCodePressed(KeyCode code); + virtual void OnKeyCodeReleased(KeyCode code); + + virtual void GetSettings(KeyValues* outResourceData); + virtual const char* GetDescription(void); + + KeyValues* GetActionMessage(); + void PlayButtonReleasedSound(); + + protected: + enum ButtonFlags_t + { + ARMED = 0x0001, + DEPRESSED = 0x0002, + FORCE_DEPRESSED = 0x0004, + BUTTON_BORDER_ENABLED = 0x0008, + USE_CAPTURE_MOUSE = 0x0010, + BUTTON_KEY_DOWN = 0x0020, + DEFAULT_BUTTON = 0x0040, + SELECTED = 0x0080, + DRAW_FOCUS_BOX = 0x0100, + BLINK = 0x0200, + ALL_FLAGS = 0xFFFF, + }; + + CUtlFlags< unsigned short > _buttonFlags; + int _mouseClickMask; + KeyValues* _actionMessage; + ActivationType_t _activationType; + + IBorder* _defaultBorder; + IBorder* _depressedBorder; + IBorder* _keyFocusBorder; + + Color _defaultFgColor, _defaultBgColor; + Color _armedFgColor, _armedBgColor; + Color _selectedFgColor, _selectedBgColor; + Color _depressedFgColor, _depressedBgColor; + Color _keyboardFocusColor; + Color _blinkFgColor; + + bool _paint; + + unsigned short m_sArmedSoundName, m_sDepressedSoundName, m_sReleasedSoundName; + bool m_bSelectionStateSaved; + bool m_bStaySelectedOnClick; + }; + +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/ButtonCode.h b/SpyCustom/sdk/ButtonCode.h new file mode 100644 index 0000000..0441a26 --- /dev/null +++ b/SpyCustom/sdk/ButtonCode.h @@ -0,0 +1,364 @@ +#ifndef BUTTONCODE_H +#define BUTTONCODE_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "InputEnums.h" +#include "mathlib.h" + +enum +{ + JOYSTICK_MAX_BUTTON_COUNT = 32, + JOYSTICK_POV_BUTTON_COUNT = 4, + JOYSTICK_AXIS_BUTTON_COUNT = MAX_JOYSTICK_AXES * 2, +}; + +#define JOYSTICK_BUTTON_INTERNAL( _joystick, _button ) ( JOYSTICK_FIRST_BUTTON + ((_joystick) * JOYSTICK_MAX_BUTTON_COUNT) + (_button) ) +#define JOYSTICK_POV_BUTTON_INTERNAL( _joystick, _button ) ( JOYSTICK_FIRST_POV_BUTTON + ((_joystick) * JOYSTICK_POV_BUTTON_COUNT) + (_button) ) +#define JOYSTICK_AXIS_BUTTON_INTERNAL( _joystick, _button ) ( JOYSTICK_FIRST_AXIS_BUTTON + ((_joystick) * JOYSTICK_AXIS_BUTTON_COUNT) + (_button) ) + +#define JOYSTICK_BUTTON( _joystick, _button ) ( (ButtonCode_t)JOYSTICK_BUTTON_INTERNAL( _joystick, _button ) ) +#define JOYSTICK_POV_BUTTON( _joystick, _button ) ( (ButtonCode_t)JOYSTICK_POV_BUTTON_INTERNAL( _joystick, _button ) ) +#define JOYSTICK_AXIS_BUTTON( _joystick, _button ) ( (ButtonCode_t)JOYSTICK_AXIS_BUTTON_INTERNAL( _joystick, _button ) ) + +enum ButtonCode_t +{ + BUTTON_CODE_INVALID = -1, + BUTTON_CODE_NONE = 0, + + KEY_FIRST = 0, + + KEY_NONE = KEY_FIRST, + KEY_0, + KEY_1, + KEY_2, + KEY_3, + KEY_4, + KEY_5, + KEY_6, + KEY_7, + KEY_8, + KEY_9, + KEY_A, + KEY_B, + KEY_C, + KEY_D, + KEY_E, + KEY_F, + KEY_G, + KEY_H, + KEY_I, + KEY_J, + KEY_K, + KEY_L, + KEY_M, + KEY_N, + KEY_O, + KEY_P, + KEY_Q, + KEY_R, + KEY_S, + KEY_T, + KEY_U, + KEY_V, + KEY_W, + KEY_X, + KEY_Y, + KEY_Z, + KEY_PAD_0, + KEY_PAD_1, + KEY_PAD_2, + KEY_PAD_3, + KEY_PAD_4, + KEY_PAD_5, + KEY_PAD_6, + KEY_PAD_7, + KEY_PAD_8, + KEY_PAD_9, + KEY_PAD_DIVIDE, + KEY_PAD_MULTIPLY, + KEY_PAD_MINUS, + KEY_PAD_PLUS, + KEY_PAD_ENTER, + KEY_PAD_DECIMAL, + KEY_LBRACKET, + KEY_RBRACKET, + KEY_SEMICOLON, + KEY_APOSTROPHE, + KEY_BACKQUOTE, + KEY_COMMA, + KEY_PERIOD, + KEY_SLASH, + KEY_BACKSLASH, + KEY_MINUS, + KEY_EQUAL, + KEY_ENTER, + KEY_SPACE, + KEY_BACKSPACE, + KEY_TAB, + KEY_CAPSLOCK, + KEY_NUMLOCK, + KEY_ESCAPE, + KEY_SCROLLLOCK, + KEY_INSERT, + KEY_DELETE, + KEY_HOME, + KEY_END, + KEY_PAGEUP, + KEY_PAGEDOWN, + KEY_BREAK, + KEY_LSHIFT, + KEY_RSHIFT, + KEY_LALT, + KEY_RALT, + KEY_LCONTROL, + KEY_RCONTROL, + KEY_LWIN, + KEY_RWIN, + KEY_APP, + KEY_UP, + KEY_LEFT, + KEY_DOWN, + KEY_RIGHT, + KEY_F1, + KEY_F2, + KEY_F3, + KEY_F4, + KEY_F5, + KEY_F6, + KEY_F7, + KEY_F8, + KEY_F9, + KEY_F10, + KEY_F11, + KEY_F12, + KEY_CAPSLOCKTOGGLE, + KEY_NUMLOCKTOGGLE, + KEY_SCROLLLOCKTOGGLE, + + KEY_LAST = KEY_SCROLLLOCKTOGGLE, + KEY_COUNT = KEY_LAST - KEY_FIRST + 1, + + MOUSE_FIRST = KEY_LAST + 1, + + MOUSE_LEFT = MOUSE_FIRST, + MOUSE_RIGHT, + MOUSE_MIDDLE, + MOUSE_4, + MOUSE_5, + MOUSE_WHEEL_UP, + MOUSE_WHEEL_DOWN, + + MOUSE_LAST = MOUSE_WHEEL_DOWN, + MOUSE_COUNT = MOUSE_LAST - MOUSE_FIRST + 1, + + JOYSTICK_FIRST = MOUSE_LAST + 1, + + JOYSTICK_FIRST_BUTTON = JOYSTICK_FIRST, + JOYSTICK_LAST_BUTTON = JOYSTICK_BUTTON_INTERNAL(MAX_JOYSTICKS - 1, JOYSTICK_MAX_BUTTON_COUNT - 1), + JOYSTICK_FIRST_POV_BUTTON, + JOYSTICK_LAST_POV_BUTTON = JOYSTICK_POV_BUTTON_INTERNAL(MAX_JOYSTICKS - 1, JOYSTICK_POV_BUTTON_COUNT - 1), + JOYSTICK_FIRST_AXIS_BUTTON, + JOYSTICK_LAST_AXIS_BUTTON = JOYSTICK_AXIS_BUTTON_INTERNAL(MAX_JOYSTICKS - 1, JOYSTICK_AXIS_BUTTON_COUNT - 1), + + JOYSTICK_LAST = JOYSTICK_LAST_AXIS_BUTTON, + +#if !defined ( _X360 ) + NOVINT_FIRST = JOYSTICK_LAST + 2, + + NOVINT_LOGO_0 = NOVINT_FIRST, + NOVINT_TRIANGLE_0, + NOVINT_BOLT_0, + NOVINT_PLUS_0, + NOVINT_LOGO_1, + NOVINT_TRIANGLE_1, + NOVINT_BOLT_1, + NOVINT_PLUS_1, + + NOVINT_LAST = NOVINT_PLUS_1, +#endif + + BUTTON_CODE_LAST, + BUTTON_CODE_COUNT = BUTTON_CODE_LAST - KEY_FIRST + 1, + + KEY_XBUTTON_UP = JOYSTICK_FIRST_POV_BUTTON, + KEY_XBUTTON_RIGHT, + KEY_XBUTTON_DOWN, + KEY_XBUTTON_LEFT, + + KEY_XBUTTON_A = JOYSTICK_FIRST_BUTTON, + KEY_XBUTTON_B, + KEY_XBUTTON_X, + KEY_XBUTTON_Y, + KEY_XBUTTON_LEFT_SHOULDER, + KEY_XBUTTON_RIGHT_SHOULDER, + KEY_XBUTTON_BACK, + KEY_XBUTTON_START, + KEY_XBUTTON_STICK1, + KEY_XBUTTON_STICK2, + + KEY_XSTICK1_RIGHT = JOYSTICK_FIRST_AXIS_BUTTON, + KEY_XSTICK1_LEFT, + KEY_XSTICK1_DOWN, + KEY_XSTICK1_UP, + KEY_XBUTTON_LTRIGGER, + KEY_XBUTTON_RTRIGGER, + KEY_XSTICK2_RIGHT, + KEY_XSTICK2_LEFT, + KEY_XSTICK2_DOWN, + KEY_XSTICK2_UP, +}; + +inline bool IsAlpha(ButtonCode_t code) +{ + return (code >= KEY_A) && (code <= KEY_Z); +} + +inline bool IsAlphaNumeric(ButtonCode_t code) +{ + return (code >= KEY_0) && (code <= KEY_Z); +} + +inline bool IsSpace(ButtonCode_t code) +{ + return (code == KEY_ENTER) || (code == KEY_TAB) || (code == KEY_SPACE); +} + +inline bool IsKeypad(ButtonCode_t code) +{ + return (code >= MOUSE_FIRST) && (code <= KEY_PAD_DECIMAL); +} + +inline bool IsPunctuation(ButtonCode_t code) +{ + return (code >= KEY_0) && (code <= KEY_SPACE) && !IsAlphaNumeric(code) && !IsSpace(code) && !IsKeypad(code); +} + +inline bool IsKeyCode(ButtonCode_t code) +{ + return (code >= KEY_FIRST) && (code <= KEY_LAST); +} + +inline bool IsMouseCode(ButtonCode_t code) +{ + return (code >= MOUSE_FIRST) && (code <= MOUSE_LAST); +} + +inline bool IsNovintCode(ButtonCode_t code) +{ +#if !defined ( _X360 ) + return ((code >= NOVINT_FIRST) && (code <= NOVINT_LAST)); +#else + return false; +#endif +} + +inline bool IsNovintButtonCode(ButtonCode_t code) +{ +#if !defined ( _X360 ) + return IsNovintCode(code); +#else + return false; +#endif +} + +inline bool IsJoystickCode(ButtonCode_t code) +{ + return (((code >= JOYSTICK_FIRST) && (code <= JOYSTICK_LAST)) || IsNovintCode(code)); +} + +inline bool IsJoystickButtonCode(ButtonCode_t code) +{ + return (((code >= JOYSTICK_FIRST_BUTTON) && (code <= JOYSTICK_LAST_BUTTON)) || IsNovintButtonCode(code)); +} + +inline bool IsJoystickPOVCode(ButtonCode_t code) +{ + return (code >= JOYSTICK_FIRST_POV_BUTTON) && (code <= JOYSTICK_LAST_POV_BUTTON); +} + +inline bool IsJoystickAxisCode(ButtonCode_t code) +{ + return (code >= JOYSTICK_FIRST_AXIS_BUTTON) && (code <= JOYSTICK_LAST_AXIS_BUTTON); +} + +inline ButtonCode_t GetBaseButtonCode(ButtonCode_t code) +{ + if (IsJoystickButtonCode(code)) + { + int offset = (code - JOYSTICK_FIRST_BUTTON) % JOYSTICK_MAX_BUTTON_COUNT; + return (ButtonCode_t)(JOYSTICK_FIRST_BUTTON + offset); + } + + if (IsJoystickPOVCode(code)) + { + int offset = (code - JOYSTICK_FIRST_POV_BUTTON) % JOYSTICK_POV_BUTTON_COUNT; + return (ButtonCode_t)(JOYSTICK_FIRST_POV_BUTTON + offset); + } + + if (IsJoystickAxisCode(code)) + { + int offset = (code - JOYSTICK_FIRST_AXIS_BUTTON) % JOYSTICK_AXIS_BUTTON_COUNT; + return (ButtonCode_t)(JOYSTICK_FIRST_AXIS_BUTTON + offset); + } + + return code; +} + +inline int GetJoystickForCode(ButtonCode_t code) +{ + if (!IsJoystickCode(code)) + return 0; + + if (IsJoystickButtonCode(code)) + { + int offset = (code - JOYSTICK_FIRST_BUTTON) / JOYSTICK_MAX_BUTTON_COUNT; + return offset; + } + if (IsJoystickPOVCode(code)) + { + int offset = (code - JOYSTICK_FIRST_POV_BUTTON) / JOYSTICK_POV_BUTTON_COUNT; + return offset; + } + if (IsJoystickAxisCode(code)) + { + int offset = (code - JOYSTICK_FIRST_AXIS_BUTTON) / JOYSTICK_AXIS_BUTTON_COUNT; + return offset; + } + + return 0; +} + +inline ButtonCode_t ButtonCodeToJoystickButtonCode(ButtonCode_t code, int nDesiredJoystick) +{ + if (!IsJoystickCode(code) || nDesiredJoystick == 0) + return code; + + nDesiredJoystick = ::clamp(nDesiredJoystick, 0, MAX_JOYSTICKS - 1); + + code = GetBaseButtonCode(code); + + if (IsJoystickButtonCode(code)) + { + int nOffset = code - JOYSTICK_FIRST_BUTTON; + return JOYSTICK_BUTTON(nDesiredJoystick, nOffset); + } + + if (IsJoystickPOVCode(code)) + { + int nOffset = code - JOYSTICK_FIRST_POV_BUTTON; + return JOYSTICK_POV_BUTTON(nDesiredJoystick, nOffset); + } + + if (IsJoystickAxisCode(code)) + { + int nOffset = code - JOYSTICK_FIRST_AXIS_BUTTON; + return JOYSTICK_AXIS_BUTTON(nDesiredJoystick, nOffset); + } + + return code; +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/CGameUI.h b/SpyCustom/sdk/CGameUI.h new file mode 100644 index 0000000..d12b2c9 --- /dev/null +++ b/SpyCustom/sdk/CGameUI.h @@ -0,0 +1,48 @@ +#pragma once + +class ECommandMsgBoxSlot; +class KeyValues; +class IPanel; + +class CGameUI { +public: + virtual void Initialize(void* (*)(char const*, int*)) = 0; + virtual void PostInit(void) = 0; + virtual void Connect(void* (*)(char const*, int*)) = 0; + virtual void Start(void) = 0; + virtual void Shutdown(void) = 0; + virtual void RunFrame(void) = 0; + virtual void OnGameUIActivated(void) = 0; + virtual void OnGameUIHidden(void) = 0; + virtual void OLD_OnConnectToServer(char const*, int, int) = 0; + virtual void OnDisconnectFromServer_OLD(unsigned char, char const*) = 0; + virtual void OnLevelLoadingStarted(char const*, bool) = 0; + virtual void OnLevelLoadingFinished(bool, char const*, char const*) = 0; + virtual void StartLoadingScreenForCommand(char const*) = 0; + virtual void StartLoadingScreenForKeyValues(KeyValues*) = 0; + virtual void UpdateProgressBar(float, char const*, bool) = 0; + virtual void SetShowProgressText(bool) = 0; + virtual void UpdateSecondaryProgressBar(float, wchar_t const*) = 0; + virtual void SetProgressLevelName(char const*) = 0; + virtual void ShowMessageDialog(unsigned int, IPanel*) = 0; + virtual void ShowMessageDialog(char const*, char const*) = 0; + virtual void CreateCommandMsgBox(char const*, char const*, bool, bool, char const*, char const*, char const*, char const*, char const*) = 0; + virtual void CreateCommandMsgBoxInSlot(ECommandMsgBoxSlot, char const*, char const*, bool, bool, char const*, char const*, char const*, char const*) = 0; + virtual void SetLoadingBackgroundDialog(unsigned long long) = 0; + virtual void OnConnectToServer2(char const*, int, int, int) = 0; + virtual void SetProgressOnStart(void) = 0; + virtual void OnDisconnectFromServer(unsigned char) = 0; + virtual void NeedConnectionProblemWaitScreen(void) = 0; + virtual void ShowPasswordUI(char const*) = 0; + virtual void LoadingProgressWantsIsolatedRender(bool) = 0; + virtual bool IsPlayingFullScreenVideo(void) = 0; + virtual bool IsTransitionEffectEnabled(void) = 0; + virtual bool IsInLevel(void) = 0; + virtual void RestoreTopLevelMenu(void) = 0; + virtual void StartProgressBar(void) = 0; + virtual void ContinueProgressBar(float, bool) = 0; + virtual void StopProgressBar(bool, char const*, char const*) = 0; + virtual void SetProgressBarStatusText(char const*, bool) = 0; + virtual void SetSecondaryProgressBar(float) = 0; + virtual void SetSecondaryProgressBarText(wchar_t const*) = 0; +}; \ No newline at end of file diff --git a/SpyCustom/sdk/CheckButton.h b/SpyCustom/sdk/CheckButton.h new file mode 100644 index 0000000..12397f1 --- /dev/null +++ b/SpyCustom/sdk/CheckButton.h @@ -0,0 +1,85 @@ +#ifndef CHECKBUTTON_H +#define CHECKBUTTON_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "VGUI.h" +#include "ToggleButton.h" +#include "TextImage.h" + +namespace vgui +{ + + class TextImage; + + class CheckImage : public TextImage + { + public: + CheckImage(CheckButton* CheckButton) : TextImage("g") + { + _CheckButton = CheckButton; + + SetSize(20, 13); + } + + virtual void Paint(); + + virtual void SetColor(Color color) + { + _borderColor1 = color; + _borderColor2 = color; + _checkColor = color; + } + + Color _borderColor1; + Color _borderColor2; + Color _checkColor; + + Color _bgColor; + + private: + CheckButton* _CheckButton; + }; + + class CheckButton : public ToggleButton + { + DECLARE_CLASS_SIMPLE(CheckButton, ToggleButton); + + public: + CheckButton(Panel* parent, const char* panelName, const char* text); + ~CheckButton(); + + virtual void SetSelected(bool state); + + virtual void SetCheckButtonCheckable(bool state); + virtual bool IsCheckButtonCheckable() const { return m_bCheckButtonCheckable; } + + Color GetDisabledFgColor() { return _disabledFgColor; } + Color GetDisabledBgColor() { return _disabledBgColor; } + + CheckImage* GetCheckImage() { return _checkBoxImage; } + + virtual void SetHighlightColor(Color fgColor); + + protected: + virtual void ApplySchemeSettings(IScheme* pScheme); + MESSAGE_FUNC_PTR(OnCheckButtonChecked, "CheckButtonChecked", panel); + virtual Color GetButtonFgColor(); + + virtual IBorder* GetBorder(bool depressed, bool armed, bool selected, bool keyfocus); + + + private: + enum { CHECK_INSET = 6 }; + bool m_bCheckButtonCheckable; + CheckImage* _checkBoxImage; + Color _disabledFgColor; + Color _disabledBgColor; + Color _highlightFgColor; + }; + +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/Color.h b/SpyCustom/sdk/Color.h new file mode 100644 index 0000000..38f0746 --- /dev/null +++ b/SpyCustom/sdk/Color.h @@ -0,0 +1,85 @@ +#ifndef COLOR_H +#define COLOR_H + +#ifdef _WIN32 +#pragma once +#endif + +class Color +{ +public: + Color() + { + *((int*)this) = 0; + } + Color(int _r, int _g, int _b) + { + SetColor(_r, _g, _b, 0); + } + Color(int _r, int _g, int _b, int _a) + { + SetColor(_r, _g, _b, _a); + } + + void SetColor(int _r, int _g, int _b, int _a = 0) + { + _color[0] = (unsigned char)_r; + _color[1] = (unsigned char)_g; + _color[2] = (unsigned char)_b; + _color[3] = (unsigned char)_a; + } + + void GetColor(int& _r, int& _g, int& _b, int& _a) const + { + _r = _color[0]; + _g = _color[1]; + _b = _color[2]; + _a = _color[3]; + } + + void SetRawColor(int color32) + { + *((int*)this) = color32; + } + + int GetRawColor() const + { + return *((int*)this); + } + + inline int r() const { return _color[0]; } + inline int g() const { return _color[1]; } + inline int b() const { return _color[2]; } + inline int a() const { return _color[3]; } + + unsigned char& operator[](int index) + { + return _color[index]; + } + + const unsigned char& operator[](int index) const + { + return _color[index]; + } + + bool operator == (const Color& rhs) const + { + return (*((int*)this) == *((int*)&rhs)); + } + + bool operator != (const Color& rhs) const + { + return !(operator==(rhs)); + } + + Color& operator=(const Color& rhs) + { + SetRawColor(rhs.GetRawColor()); + return *this; + } + + unsigned char _color[4]; +}; + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/Controls.h b/SpyCustom/sdk/Controls.h new file mode 100644 index 0000000..7998fda --- /dev/null +++ b/SpyCustom/sdk/Controls.h @@ -0,0 +1,103 @@ +#ifndef CONTROLS_H +#define CONTROLS_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "VGUI.h" +#include "IPanel.h" +#include "IKeyValuesSystem.h" + +#include "interface.h" +#include "MouseCode.h" +#include "KeyCode.h" +#include "tier3.h" + + +namespace vgui +{ + + bool VGui_InitInterfacesList(const char* moduleName, CreateInterfaceFn* factoryList, int numFactories); + + const char* GetControlsModuleName(); + + class IPanel; + class IInput; + class ISchemeManager; + class ISurface; + class ISystem; + class IVGui; + + class AnalogBar; + class AnimatingImagePanel; + class AnimationController; + class BuildModeDialog; + class Button; + class CheckButton; + class CheckButtonList; + class CircularProgressBar; + template< class T >class CvarToggleCheckButton; + class ComboBox; + class DirectorySelectDialog; + class Divider; + class EditablePanel; + class FileOpenDialog; + class Frame; + class GraphPanel; + class HTML; + class ImagePanel; + class Label; + class ListPanel; + class ListViewPanel; + class Menu; + class MenuBar; + class MenuButton; + class MenuItem; + class MessageBox; + class Panel; + class PanelListPanel; + class ProgressBar; + class ProgressBox; + class PropertyDialog; + class PropertyPage; + class PropertySheet; + class QueryBox; + class RadioButton; + class RichText; + class ScalableImagePanel; + class ScrollBar; + class ScrollBarSlider; + class SectionedListPanel; + class Slider; + class Splitter; + class TextEntry; + class ToggleButton; + class BaseTooltip; + class TextTooltip; + class TreeView; + class CTreeViewListControl; + class URLLabel; + class WizardPanel; + class WizardSubPanel; + + class BuildGroup; + class FocusNavGroup; + class IBorder; + class IImage; + class Image; + class ImageList; + class TextImage; + +} + +#define VGUI_HOTKEYS_ENABLED +#define USING_BUILD_FACTORY( className ) \ + extern className *g_##className##LinkerHack; \ + className *g_##className##PullInModule = g_##className##LinkerHack; + +#define USING_BUILD_FACTORY_ALIAS( className, factoryName ) \ + extern className *g_##factoryName##LinkerHack; \ + className *g_##factoryName##PullInModule = g_##factoryName##LinkerHack; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/Cursor.h b/SpyCustom/sdk/Cursor.h new file mode 100644 index 0000000..7244d81 --- /dev/null +++ b/SpyCustom/sdk/Cursor.h @@ -0,0 +1,40 @@ +#ifndef CURSOR_H +#define CURSOR_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "VGUI.h" + +namespace vgui +{ + + enum CursorCode + { + dc_user, + dc_none, + dc_arrow, + dc_ibeam, + dc_hourglass, + dc_waitarrow, + dc_crosshair, + dc_up, + dc_sizenwse, + dc_sizenesw, + dc_sizewe, + dc_sizens, + dc_sizeall, + dc_no, + dc_hand, + dc_blank, + dc_last, + dc_alwaysvisible_push, + dc_alwaysvisible_pop, + }; + + typedef unsigned long HCursor; + +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/Dar.h b/SpyCustom/sdk/Dar.h new file mode 100644 index 0000000..7fcbab5 --- /dev/null +++ b/SpyCustom/sdk/Dar.h @@ -0,0 +1,121 @@ +#ifndef DAR_H +#define DAR_H + +#ifdef _WIN32 +#pragma once +#endif + +#include +#include +#include "VGUI.h" +#include "utlvector.h" + +#include "memdbgon.h" + +namespace vgui +{ + + template class Dar : public CUtlVector< ELEMTYPE > + { + typedef CUtlVector< ELEMTYPE > BaseClass; + + public: + Dar() + { + } + Dar(int initialCapacity) : + BaseClass(0, initialCapacity) + { + } + + public: + void SetCount(int count) + { + this->EnsureCount(count); + } + int GetCount() + { + return this->Count(); + } + int AddElement(ELEMTYPE elem) + { + return this->AddToTail(elem); + } + void MoveElementToEnd(ELEMTYPE elem) + { + if (this->Count() == 0) + return; + + if (this->Element(this->Count() - 1) == elem) + return; + + int idx = this->GetOffset(elem); + if (idx == this->InvalidIndex()) + return; + + this->Remove(idx); + this->AddToTail(elem); + } + int FindElement(ELEMTYPE elem) + { + return this->GetOffset(elem); + } + bool HasElement(ELEMTYPE elem) + { + if (this->FindElement(elem) != this->InvalidIndex()) + { + return true; + } + return false; + } + int PutElement(ELEMTYPE elem) + { + int index = this->FindElement(elem); + if (index >= 0) + { + return index; + } + return this->AddElement(elem); + } + void InsertElementAt(ELEMTYPE elem, int index) + { + this->InsertBefore(index, elem); + } + void SetElementAt(ELEMTYPE elem, int index) + { + this->EnsureCount(index + 1); + this->Element(index) = elem; + } + void RemoveElementAt(int index) + { + this->Remove(index); + } + + void RemoveElementsBefore(int index) + { + if (index <= 0) + return; + this->RemoveMultiple(0, index - 1); + } + + void RemoveElement(ELEMTYPE elem) + { + this->FindAndRemove(elem); + } + + void* GetBaseData() + { + return this->Base(); + } + + void CopyFrom(Dar& dar) + { + this->CopyArray(dar.Base(), dar.Count()); + } + }; + +} + +#include "memdbgoff.h" + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/EditablePanel.h b/SpyCustom/sdk/EditablePanel.h new file mode 100644 index 0000000..3efd145 --- /dev/null +++ b/SpyCustom/sdk/EditablePanel.h @@ -0,0 +1,98 @@ +#ifndef EDITABLEPANEL_H +#define EDITABLEPANEL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "Panel.h" +#include "FocusNavGroup.h" + +namespace vgui +{ + + class EditablePanel : public Panel + { + DECLARE_CLASS_SIMPLE(EditablePanel, Panel); + + public: + EditablePanel(Panel* parent, const char* panelName); + EditablePanel(Panel* parent, const char* panelName, HScheme hScheme); + + virtual ~EditablePanel(); + + virtual void LoadControlSettings(const char* dialogResourceName, const char* pathID = NULL, KeyValues* pPreloadedKeyValues = NULL, KeyValues* pConditions = NULL); + virtual void ApplySettings(KeyValues* inResourceData); + + virtual void LoadUserConfig(const char* configName, int dialogID = 0); + virtual void SaveUserConfig(); + + virtual void LoadControlSettingsAndUserConfig(const char* dialogResourceName, int dialogID = 0); + + virtual void ActivateBuildMode(); + + virtual BuildGroup* GetBuildGroup(); + + virtual Panel* CreateControlByName(const char* controlName); + + virtual void SetControlString(const char* controlName, const char* string); + virtual void SetControlString(const char* controlName, const wchar_t* string); + virtual void SetControlInt(const char* controlName, int state); + virtual int GetControlInt(const char* controlName, int defaultState); + virtual const char* GetControlString(const char* controlName, const char* defaultString = ""); + virtual void GetControlString(const char* controlName, char* buf, int bufSize, const char* defaultString = ""); + virtual void SetControlEnabled(const char* controlName, bool enabled); + virtual void SetControlVisible(const char* controlName, bool visible); + + virtual void SetDialogVariable(const char* varName, const char* value); + virtual void SetDialogVariable(const char* varName, const wchar_t* value); + virtual void SetDialogVariable(const char* varName, int value); + virtual void SetDialogVariable(const char* varName, float value); + + virtual void RequestFocus(int direction = 0); + virtual bool RequestFocusNext(VPANEL panel); + virtual bool RequestFocusPrev(VPANEL panel); + virtual void OnSetFocus(); + virtual void OnRequestFocus(VPANEL subFocus, VPANEL defaultPanel); + virtual VPANEL GetCurrentKeyFocus(); + virtual Panel* HasHotkey(wchar_t key); + + virtual void OnKeyCodePressed(KeyCode code); + + virtual bool RequestInfo(KeyValues* data); + virtual void RegisterControlSettingsFile(const char* dialogResourceName, const char* pathID = NULL); + + KeyValues* GetDialogVariables(); + + protected: + virtual void PaintBackground(); + + virtual FocusNavGroup& GetFocusNavGroup(); + + MESSAGE_FUNC_HANDLE(OnDefaultButtonSet, "DefaultButtonSet", button); + MESSAGE_FUNC_HANDLE(OnCurrentDefaultButtonSet, "CurrentDefaultButtonSet", button); + MESSAGE_FUNC(OnFindDefaultButton, "FindDefaultButton"); + + virtual void OnChildAdded(VPANEL child); + virtual void OnSizeChanged(int wide, int tall); + virtual void OnClose(); + + virtual void ApplyUserConfigSettings(KeyValues* userConfig); + + virtual void GetUserConfigSettings(KeyValues* userConfig); + + private: + void ForceSubPanelsToUpdateWithNewDialogVariables(); + + BuildGroup* _buildGroup; + FocusNavGroup m_NavGroup; + KeyValues* m_pDialogVariables; + + char* m_pszConfigName; + int m_iConfigID; + bool m_bShouldSkipAutoResize; + }; + +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/FocusNavGroup.h b/SpyCustom/sdk/FocusNavGroup.h new file mode 100644 index 0000000..eb28ffc --- /dev/null +++ b/SpyCustom/sdk/FocusNavGroup.h @@ -0,0 +1,49 @@ +#ifndef FOCUSNAVGROUP_H +#define FOCUSNAVGROUP_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "VGUI.h" +#include "PHandle.h" + +namespace vgui +{ + + class Panel; + + class FocusNavGroup + { + public: + FocusNavGroup(Panel* panel); + ~FocusNavGroup(); + virtual Panel* GetDefaultPanel(); + + virtual void SetDefaultButton(Panel* panel); + virtual VPANEL GetDefaultButton(); + virtual VPANEL GetCurrentDefaultButton(); + virtual Panel* FindPanelByHotkey(wchar_t key); + virtual bool RequestFocusPrev(VPANEL panel = NULL); + virtual bool RequestFocusNext(VPANEL panel = NULL); + + virtual Panel* GetCurrentFocus(); + virtual VPANEL SetCurrentFocus(VPANEL panel, VPANEL defaultPanel); + + virtual void SetFocusTopLevel(bool state); + + virtual void SetCurrentDefaultButton(VPANEL panel, bool sendCurrentDefaultButtonMessage = true); + private: + bool CanButtonBeDefault(VPANEL panel); + + VPanelHandle _defaultButton; + VPanelHandle _currentDefaultButton; + VPanelHandle _currentFocus; + + Panel* _mainPanel; + bool _topLevelFocus; + }; + +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/Frame.h b/SpyCustom/sdk/Frame.h new file mode 100644 index 0000000..ed36079 --- /dev/null +++ b/SpyCustom/sdk/Frame.h @@ -0,0 +1,198 @@ +#ifndef VGUI_FRAME_H +#define VGUI_FRAME_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "vgui.h" +#include "Dar.h" +#include "Panel.h" +#include "EditablePanel.h" +#include "FocusNavGroup.h" + +namespace vgui +{ + + class FrameButton; + class FrameSystemButton; + + class Frame : public EditablePanel + { + DECLARE_CLASS_SIMPLE(Frame, EditablePanel); + + public: + Frame(Panel* parent, const char* panelName, bool showTaskbarIcon = true, bool bPopup = true); + virtual ~Frame(); + + virtual void SetTitle(const char* title, bool surfaceTitle); + virtual void SetTitle(const wchar_t* title, bool surfaceTitle); + + virtual void Activate(); + + virtual void ActivateMinimized(); + + MESSAGE_FUNC(Close, "Close"); + MESSAGE_FUNC(CloseModal, "CloseModal"); + + virtual void SetDeleteSelfOnClose(bool state); + + virtual void MoveToCenterOfScreen(); + + virtual void SetMoveable(bool state); + virtual bool IsMoveable(); + + virtual void SetSizeable(bool state); + virtual bool IsSizeable(); + virtual void SetMenuButtonVisible(bool state); + void SetMenuButtonResponsive(bool state); + + virtual void SetMinimizeButtonVisible(bool state); + virtual void SetMaximizeButtonVisible(bool state); + virtual void SetMinimizeToSysTrayButtonVisible(bool state); + + virtual void SetCloseButtonVisible(bool state); + + virtual bool IsMinimized(); + virtual void FlashWindow(); + virtual void FlashWindowStop(); + virtual void OnCommand(const char* command); + + virtual Menu* GetSysMenu(); + virtual void SetSysMenu(Menu* menu); + + void SetImages(const char* pEnabledImage, const char* pDisabledImage = NULL); + + virtual void SetTitleBarVisible(bool state); + + virtual void SetClipToParent(bool state); + virtual bool GetClipToParent() const; + + virtual void SetSmallCaption(bool state); + virtual bool IsSmallCaption() const; + + virtual int GetDraggerSize(); + virtual int GetCornerSize(); + virtual int GetBottomRightSize(); + virtual int GetCaptionHeight(); + + virtual void LoadControlSettings(const char* dialogResourceName, const char* pathID = NULL, KeyValues* pPreloadedKeyValues = NULL, KeyValues* pConditions = NULL); + + void SetChainKeysToParent(bool state); + bool CanChainKeysToParent() const; + + virtual void DoModal(); + + void PlaceUnderCursor(); + + void DisableFadeEffect(void); + + void SetFadeEffectDisableOverride(bool disabled); + + virtual void OnGripPanelMoved(int nNewX, int nNewY, int nNewW, int nNewH); + virtual void OnGripPanelMoveFinished() {} + + protected: + virtual void OnMousePressed(MouseCode code); + virtual void OnKeyCodeTyped(KeyCode code); + virtual void OnKeyTyped(wchar_t unichar); + virtual void OnKeyCodeReleased(KeyCode code); + virtual void OnKeyFocusTicked(); + virtual void ApplySchemeSettings(IScheme* pScheme); + virtual void PerformLayout(); + virtual void OnClose(); + virtual void OnFinishedClose(); + MESSAGE_FUNC(OnMinimize, "Minimize"); + virtual void OnMinimizeToSysTray(); + MESSAGE_FUNC(OnCloseFrameButtonPressed, "CloseFrameButtonPressed"); + virtual void OnChildAdded(VPANEL child); + virtual void ApplySettings(KeyValues* inResourceData); + virtual void GetSettings(KeyValues* outResourceData); + virtual const char* GetDescription(void); + + virtual bool GetDefaultScreenPosition(int& x, int& y, int& wide, int& tall); + + virtual void PaintBackground(); + + virtual void OnThink(); + + virtual void OnScreenSizeChanged(int iOldWide, int iOldTall); + + virtual void GetClientArea(int& x, int& y, int& wide, int& tall); + + virtual void ApplyUserConfigSettings(KeyValues* userConfig); + + virtual void GetUserConfigSettings(KeyValues* userConfig); + + virtual bool HasUserConfigSettings(); + + virtual void GetSizerClientArea(int& x, int& y, int& wide, int& tall); + + private: + MESSAGE_FUNC_CHARPTR(InternalSetTitle, "SetTitle", text); + MESSAGE_FUNC(InternalFlashWindow, "FlashWindow"); + MESSAGE_FUNC_PARAMS(OnDialogVariablesChanged, "DialogVariables", dialogVariables); + + void SetupResizeCursors(); + void LayoutProportional(FrameButton* bt); + void FinishClose(); + void OnFrameFocusChanged(bool bHasFocus); + + Color _titleBarBgColor; + Color _titleBarDisabledBgColor; + Color _titleBarFgColor; + Color _titleBarDisabledFgColor; + Color m_InFocusBgColor; + Color m_OutOfFocusBgColor; + TextImage* _title; + +#if !defined( _GAMECONSOLE ) + Panel* _topGrip; + Panel* _bottomGrip; + Panel* _leftGrip; + Panel* _rightGrip; + Panel* _topLeftGrip; + Panel* _topRightGrip; + Panel* _bottomLeftGrip; + Panel* _bottomRightGrip; + Panel* _captionGrip; + FrameButton* _minimizeButton; + FrameButton* _maximizeButton; + FrameButton* _minimizeToSysTrayButton; + FrameButton* _closeButton; + FrameSystemButton* _menuButton; + Menu* _sysMenu; +#endif + + float m_flTransitionEffectTime; + float m_flFocusTransitionEffectTime; + int m_iClientInsetX; + int m_iClientInsetY; + int m_iTitleTextInsetX; + int m_nGripperWidth; + VPANEL m_hPreviousModal; + HFont m_hCustomTitleFont; + + bool _sizeable : 1; + bool _moveable : 1; + bool m_bHasFocus : 1; + bool _flashWindow : 1; + bool _nextFlashState : 1; + bool _drawTitleBar : 1; + bool m_bPreviouslyVisible : 1; + bool m_bFadingOut : 1; + bool m_bDeleteSelfOnClose : 1; + bool m_bDisableFadeEffect : 1; + bool m_bClipToParent : 1; + bool m_bSmallCaption : 1; + bool m_bChainKeysToParent : 1; + bool m_bPrimed : 1; + bool m_iClientInsetXOverridden : 1; + + CPanelAnimationVarAliasType(int, m_iTitleTextInsetXOverride, "titletextinsetX", "0", "proportional_int"); + CPanelAnimationVarAliasType(int, m_iTitleTextInsetYOverride, "titletextinsetY", "0", "proportional_int"); + }; + +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/GameEventListener.h b/SpyCustom/sdk/GameEventListener.h new file mode 100644 index 0000000..7366d70 --- /dev/null +++ b/SpyCustom/sdk/GameEventListener.h @@ -0,0 +1,52 @@ +#ifndef GAME_EVENT_LISTENER_H +#define GAME_EVENT_LISTENER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "igameevents.h" +extern IGameEventManager2* gameeventmanager; + +class CGameEventListener : public IGameEventListener2 +{ +public: + CGameEventListener() : m_bRegisteredForEvents(false) + { + } + + ~CGameEventListener() + { + StopListeningForAllEvents(); + } + + void ListenForGameEvent(const char* name) + { + m_bRegisteredForEvents = true; + +#ifdef CLIENT_DLL + bool bServerSide = false; +#else + bool bServerSide = true; +#endif + if (gameeventmanager) + gameeventmanager->AddListener(this, name, bServerSide); + } + + void StopListeningForAllEvents() + { + if (m_bRegisteredForEvents) + { + if (gameeventmanager) + gameeventmanager->RemoveListener(this); + m_bRegisteredForEvents = false; + } + } + + virtual void FireGameEvent(IGameEvent* event) = 0; + +private: + + bool m_bRegisteredForEvents; +}; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/GameEventManager.h b/SpyCustom/sdk/GameEventManager.h new file mode 100644 index 0000000..e0a2fde --- /dev/null +++ b/SpyCustom/sdk/GameEventManager.h @@ -0,0 +1,157 @@ +#if !defined ( GAMEEVENTMANAGER_H ) +#define GAMEEVENTMANAGER_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "igameevents.h" +#include "utlvector.h" +#include "KeyValues.h" +#include "networkstringtabledefs.h" +#include "utlsymbol.h" + +#include "bitbuf.h" + +class SVC_GameEventList; +class CLC_ListenEvents; + +class CGameEventCallback +{ +public: + void* m_pCallback; + int m_nListenerType; +}; + +class CGameEventDescriptor +{ +public: + CGameEventDescriptor() + { + name[0] = 0; + eventid = -1; + keys = NULL; + local = false; + reliable = true; + } + +public: + char name[MAX_EVENT_NAME_LENGTH]; + int eventid; + KeyValues* keys; + bool local; + bool reliable; + CUtlVector listeners; +}; + +class CGameEvent : public IGameEvent +{ +public: + + CGameEvent(CGameEventDescriptor* descriptor); + virtual ~CGameEvent(); + + const char* GetName() const; + bool IsEmpty(const char* keyName = NULL); + bool IsLocal() const; + bool IsReliable() const; + + bool GetBool(const char* keyName = NULL, bool defaultValue = false); + int GetInt(const char* keyName = NULL, int defaultValue = 0); + float GetFloat(const char* keyName = NULL, float defaultValue = 0.0f); + const char* GetString(const char* keyName = NULL, const char* defaultValue = ""); + + void SetBool(const char* keyName, bool value); + void SetInt(const char* keyName, int value); + void SetFloat(const char* keyName, float value); + void SetString(const char* keyName, const char* value); + + CGameEventDescriptor* m_pDescriptor; + KeyValues* m_pDataKeys; +}; + +class CGameEventManager : public IGameEventManager2 +{ + friend class CGameEventManagerOld; + +public: + + enum + { + SERVERSIDE = 0, + CLIENTSIDE, + CLIENTSTUB, + SERVERSIDE_OLD, + CLIENTSIDE_OLD, + }; + + enum + { + TYPE_LOCAL = 0, + TYPE_STRING, + TYPE_FLOAT, + TYPE_LONG, + TYPE_SHORT, + TYPE_BYTE, + TYPE_BOOL + }; + + CGameEventManager(); + virtual ~CGameEventManager(); + + int LoadEventsFromFile(const char* filename); + void Reset(); + + bool AddListener(IGameEventListener2* listener, const char* name, bool bServerSide); + bool FindListener(IGameEventListener2* listener, const char* name); + void RemoveListener(IGameEventListener2* listener); + + IGameEvent* CreateEvent(const char* name, bool bForce = false); + IGameEvent* DuplicateEvent(IGameEvent* event); + bool FireEvent(IGameEvent* event, bool bDontBroadcast = false); + bool FireEventClientSide(IGameEvent* event); + void FreeEvent(IGameEvent* event); + + bool SerializeEvent(IGameEvent* event, bf_write* buf); + IGameEvent* UnserializeEvent(bf_read* buf); + +public: + bool Init(); + void Shutdown(); + void ReloadEventDefinitions(); + bool AddListener(void* listener, CGameEventDescriptor* descriptor, int nListenerType); + + CGameEventDescriptor* GetEventDescriptor(const char* name); + CGameEventDescriptor* GetEventDescriptor(IGameEvent* event); + CGameEventDescriptor* GetEventDescriptor(int eventid); + + void WriteEventList(SVC_GameEventList* msg); + bool ParseEventList(SVC_GameEventList* msg); + + void WriteListenEventList(CLC_ListenEvents* msg); + bool HasClientListenersChanged(bool bReset = true); + void ConPrintEvent(IGameEvent* event); + + bool AddListenerAll(void* listener, int nListenerType); + void RemoveListenerOld(void* listener); + + +protected: + + IGameEvent* CreateEvent(CGameEventDescriptor* descriptor); + bool RegisterEvent(KeyValues* keys); + void UnregisterEvent(int index); + bool FireEventIntern(IGameEvent* event, bool bServerSide, bool bClientOnly); + CGameEventCallback* FindEventListener(void* listener); + + CUtlVector m_GameEvents; + CUtlVector m_Listeners; + CUtlSymbolTable m_EventFiles; + CUtlVector m_EventFileNames; + + bool m_bClientListenersChanged; +}; + +extern CGameEventManager& g_GameEventManager; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/animationlayer.h b/SpyCustom/sdk/animationlayer.h new file mode 100644 index 0000000..e074f08 --- /dev/null +++ b/SpyCustom/sdk/animationlayer.h @@ -0,0 +1,335 @@ +#ifndef ANIMATIONLAYER_H +#define ANIMATIONLAYER_H +#ifdef _WIN32 +#pragma once +#endif + + +#include "rangecheckedvar.h" +#include "lerp_functions.h" + +#include "shareddefs.h" +#include "cs_shareddefs.h" + +#ifdef CLIENT_DLL +class C_BaseAnimatingOverlay; +#endif + +class C_AnimationLayer +{ +public: + + ALLOW_DATATABLES_PRIVATE_ACCESS(); + + C_AnimationLayer(); + void Reset(); + +#ifdef CLIENT_DLL + void SetOwner(C_BaseAnimatingOverlay* pOverlay); + C_BaseAnimatingOverlay* GetOwner() const; +#endif + + void SetOrder(int order); + bool IsActive(void); + float GetFadeout(float flCurTime); + + void SetSequence(int nSequence); + void SetCycle(float flCycle); + void SetPrevCycle(float flCycle); + void SetPlaybackRate(float flPlaybackRate); + void SetWeight(float flWeight); + void SetWeightDeltaRate(float flDelta); + + int GetOrder() const; + int GetSequence() const; + float GetCycle() const; + float GetPrevCycle() const; + float GetPlaybackRate() const; + float GetWeight() const; + float GetWeightDeltaRate() const; + +#ifdef CLIENT_DLL + int GetInvalidatePhysicsBits() const; + void SetInvalidatePhysicsBits(int iBit) { m_nInvalidatePhysicsBits = iBit; } +#endif + +public: + float m_flLayerAnimtime; + float m_flLayerFadeOuttime; + + CStudioHdr* m_pDispatchedStudioHdr; + int m_nDispatchedSrc; + int m_nDispatchedDst; + +private: + int m_nOrder; + CRangeCheckedVar m_nSequence; + CRangeCheckedVar m_flPrevCycle; + CRangeCheckedVar m_flWeight; + CRangeCheckedVar m_flWeightDeltaRate; + + CRangeCheckedVar m_flPlaybackRate; + CRangeCheckedVar m_flCycle; + +#ifdef CLIENT_DLL + C_BaseAnimatingOverlay* m_pOwner; + int m_nInvalidatePhysicsBits; +#endif + + friend class C_BaseAnimatingOverlay; + friend C_AnimationLayer LoopingLerp(float flPercent, C_AnimationLayer& from, C_AnimationLayer& to); + friend C_AnimationLayer Lerp(float flPercent, const C_AnimationLayer& from, const C_AnimationLayer& to); + friend C_AnimationLayer LoopingLerp_Hermite(const C_AnimationLayer& current, float flPercent, C_AnimationLayer& prev, C_AnimationLayer& from, C_AnimationLayer& to); + friend C_AnimationLayer Lerp_Hermite(const C_AnimationLayer& current, float flPercent, const C_AnimationLayer& prev, const C_AnimationLayer& from, const C_AnimationLayer& to); + friend void Lerp_Clamp(C_AnimationLayer& val); + friend int CheckForSequenceBoxChanges(const C_AnimationLayer& newLayer, const C_AnimationLayer& oldLayer); +}; + +#ifdef CLIENT_DLL +#define CAnimationLayer C_AnimationLayer +#endif + + +inline C_AnimationLayer::C_AnimationLayer() +{ +#ifdef CLIENT_DLL + m_pOwner = NULL; + m_nInvalidatePhysicsBits = 0; +#endif + m_pDispatchedStudioHdr = NULL; + m_nDispatchedSrc = 0; + m_nDispatchedDst = 0; + + Reset(); +} + +#ifdef GAME_DLL + +inline void C_AnimationLayer::SetSequence(int nSequence) +{ + m_nSequence = nSequence; +} + +inline void C_AnimationLayer::SetCycle(float flCycle) +{ + m_flCycle = flCycle; +} + +inline void C_AnimationLayer::SetWeight(float flWeight) +{ + m_flWeight = flWeight; +} + +#endif + +FORCEINLINE void C_AnimationLayer::SetPrevCycle(float flPrevCycle) +{ + m_flPrevCycle = flPrevCycle; +} + +FORCEINLINE void C_AnimationLayer::SetPlaybackRate(float flPlaybackRate) +{ + m_flPlaybackRate = flPlaybackRate; +} + +FORCEINLINE void C_AnimationLayer::SetWeightDeltaRate(float flDelta) +{ + m_flWeightDeltaRate = flDelta; +} + +FORCEINLINE int C_AnimationLayer::GetSequence() const +{ + return m_nSequence; +} + +FORCEINLINE float C_AnimationLayer::GetCycle() const +{ + return m_flCycle; +} + +FORCEINLINE float C_AnimationLayer::GetPrevCycle() const +{ + return m_flPrevCycle; +} + +FORCEINLINE float C_AnimationLayer::GetPlaybackRate() const +{ + return m_flPlaybackRate; +} + +FORCEINLINE float C_AnimationLayer::GetWeight() const +{ + return m_flWeight; +} + +FORCEINLINE float C_AnimationLayer::GetWeightDeltaRate() const +{ + return m_flWeightDeltaRate; +} + +FORCEINLINE int C_AnimationLayer::GetOrder() const +{ + return m_nOrder; +} + +inline float C_AnimationLayer::GetFadeout(float flCurTime) +{ + float s; + + if (m_flLayerFadeOuttime <= 0.0f) + { + s = 0; + } + else + { + s = 1.0 - (flCurTime - m_flLayerAnimtime) / m_flLayerFadeOuttime; + if (s > 0 && s <= 1.0) + { + s = 3 * s * s - 2 * s * s * s; + } + else if (s > 1.0f) + { + s = 1.0f; + } + } + return s; +} + +#ifdef CLIENT_DLL +FORCEINLINE int C_AnimationLayer::GetInvalidatePhysicsBits() const +{ + return m_nInvalidatePhysicsBits; +} +#endif + +inline C_AnimationLayer LoopingLerp(float flPercent, C_AnimationLayer& from, C_AnimationLayer& to) +{ +#ifdef CLIENT_DLL + Assert(from.GetOwner() == to.GetOwner()); +#endif + + C_AnimationLayer output; + + output.m_nSequence = to.m_nSequence; + output.m_flCycle = LoopingLerp(flPercent, (float)from.m_flCycle, (float)to.m_flCycle); + output.m_flPrevCycle = to.m_flPrevCycle; + output.m_flWeight = Lerp(flPercent, from.m_flWeight, to.m_flWeight); + output.m_nOrder = to.m_nOrder; + + output.m_flLayerAnimtime = to.m_flLayerAnimtime; + output.m_flLayerFadeOuttime = to.m_flLayerFadeOuttime; +#ifdef CLIENT_DLL + output.SetOwner(to.GetOwner()); +#endif + return output; +} + +inline C_AnimationLayer Lerp(float flPercent, const C_AnimationLayer& from, const C_AnimationLayer& to) +{ +#ifdef CLIENT_DLL + Assert(from.GetOwner() == to.GetOwner()); +#endif + + C_AnimationLayer output; + + output.m_nSequence = to.m_nSequence; + output.m_flCycle = Lerp(flPercent, from.m_flCycle, to.m_flCycle); + output.m_flPrevCycle = to.m_flPrevCycle; + output.m_flWeight = Lerp(flPercent, from.m_flWeight, to.m_flWeight); + output.m_nOrder = to.m_nOrder; + + output.m_flLayerAnimtime = to.m_flLayerAnimtime; + output.m_flLayerFadeOuttime = to.m_flLayerFadeOuttime; +#ifdef CLIENT_DLL + output.SetOwner(to.GetOwner()); +#endif + return output; +} + +inline int CheckForSequenceBoxChanges(const C_AnimationLayer& newLayer, const C_AnimationLayer& oldLayer) +{ + int nChangeFlags = 0; + + bool bOldIsZero = (oldLayer.GetWeight() == 0.0f); + bool bNewIsZero = (newLayer.GetWeight() == 0.0f); + + if ((newLayer.GetSequence() != oldLayer.GetSequence()) || + (bNewIsZero != bOldIsZero)) + { + nChangeFlags |= SEQUENCE_CHANGED | BOUNDS_CHANGED; + } + + if (newLayer.GetCycle() != oldLayer.GetCycle()) + { + nChangeFlags |= ANIMATION_CHANGED; + } + + if (newLayer.GetOrder() != oldLayer.GetOrder()) + { + nChangeFlags |= BOUNDS_CHANGED; + } + + return nChangeFlags; +} + +inline C_AnimationLayer LoopingLerp_Hermite(const C_AnimationLayer& current, float flPercent, C_AnimationLayer& prev, C_AnimationLayer& from, C_AnimationLayer& to) +{ +#ifdef CLIENT_DLL + Assert(prev.GetOwner() == from.GetOwner()); + Assert(from.GetOwner() == to.GetOwner()); +#endif + + C_AnimationLayer output; + + output.m_nSequence = to.m_nSequence; + output.m_flCycle = LoopingLerp_Hermite((float)current.m_flCycle, flPercent, (float)prev.m_flCycle, (float)from.m_flCycle, (float)to.m_flCycle); + output.m_flPrevCycle = to.m_flPrevCycle; + output.m_flWeight = Lerp(flPercent, from.m_flWeight, to.m_flWeight); + output.m_nOrder = to.m_nOrder; + + output.m_flLayerAnimtime = to.m_flLayerAnimtime; + output.m_flLayerFadeOuttime = to.m_flLayerFadeOuttime; + +#ifdef CLIENT_DLL + output.SetOwner(to.GetOwner()); + output.m_nInvalidatePhysicsBits = CheckForSequenceBoxChanges(output, current); +#endif + return output; +} + +inline C_AnimationLayer Lerp_Hermite(const C_AnimationLayer& current, float flPercent, const C_AnimationLayer& prev, const C_AnimationLayer& from, const C_AnimationLayer& to) +{ +#ifdef CLIENT_DLL + Assert(prev.GetOwner() == from.GetOwner()); + Assert(from.GetOwner() == to.GetOwner()); +#endif + + C_AnimationLayer output; + + output.m_nSequence = to.m_nSequence; + output.m_flCycle = Lerp_Hermite((float)current.m_flCycle, flPercent, (float)prev.m_flCycle, (float)from.m_flCycle, (float)to.m_flCycle); + output.m_flPrevCycle = to.m_flPrevCycle; + output.m_flWeight = Lerp(flPercent, from.m_flWeight, to.m_flWeight); + output.m_nOrder = to.m_nOrder; + + output.m_flLayerAnimtime = to.m_flLayerAnimtime; + output.m_flLayerFadeOuttime = to.m_flLayerFadeOuttime; +#ifdef CLIENT_DLL + output.SetOwner(to.GetOwner()); + output.m_nInvalidatePhysicsBits = CheckForSequenceBoxChanges(output, current); +#endif + return output; +} + +inline void Lerp_Clamp(C_AnimationLayer& val) +{ + Lerp_Clamp(val.m_nSequence); + Lerp_Clamp(val.m_flCycle); + Lerp_Clamp(val.m_flPrevCycle); + Lerp_Clamp(val.m_flWeight); + Lerp_Clamp(val.m_nOrder); + Lerp_Clamp(val.m_flLayerAnimtime); + Lerp_Clamp(val.m_flLayerFadeOuttime); +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/annotations.h b/SpyCustom/sdk/annotations.h new file mode 100644 index 0000000..c20b06e --- /dev/null +++ b/SpyCustom/sdk/annotations.h @@ -0,0 +1,64 @@ +#ifndef ANALYSIS_ANNOTATIONS_H +#define ANALYSIS_ANNOTATIONS_H + +#if _MSC_VER >= 1600 +#pragma warning(error : 4789 ) + +#ifdef _PREFAST_ +#include + +#define ANALYZE_SUPPRESS(wnum) __pragma(warning(suppress: wnum)) +#define ANALYZE_SUPPRESS2(wnum1, wnum2) __pragma(warning(supress: wnum1 wnum2)) +#define ANALYZE_SUPPRESS3(wnum1, wnum2, wnum3) __pragma(warning(suppress: wnum1 wnum2 wnum3)) +#define ANALYZE_SUPPRESS4(wnum1, wnum2, wnum3, wnum4) __pragma(warning(suppress: wnum1 wnum2 wnum3 wnum4)) + +#define PRINTF_FORMAT_STRING _Printf_format_string_ +#define SCANF_FORMAT_STRING _Scanf_format_string_impl_ +#define IN_Z _In_z_ +#define IN_CAP(x) _In_count_(x) +#define IN_BYTECAP(x) _In_bytecount_(x) +#define OUT_Z_CAP(x) _Out_z_cap_(x) +#define OUT_CAP(x) _Out_cap_(x) +#define OUT_CAP_C(x) _Out_cap_c_(x) +#define OUT_BYTECAP(x) _Out_bytecap_(x) +#define OUT_Z_BYTECAP(x) _Out_z_bytecap_(x) +#define INOUT_BYTECAP(x) _Inout_bytecap_(x) +#define INOUT_Z_CAP(x) _Inout_z_cap_(x) +#define INOUT_Z_BYTECAP(x) _Inout_z_bytecap_(x) +#if _MSC_VER >= 1700 +#define IN_Z_ARRAY _Pre_z_ +#define OUT_Z_ARRAY _Post_z_ +#define INOUT_Z_ARRAY _Prepost_z_ +#else +#define IN_Z_ARRAY _Deref_pre_z_ +#define OUT_Z_ARRAY _Deref_post_z_ +#define INOUT_Z_ARRAY _Deref_prepost_z_ +#endif +#define MUST_CHECK_RETURN _Check_return_ +#endif +#endif + +#ifndef ANALYZE_SUPPRESS +#define ANALYZE_SUPPRESS(wnum) +#define ANALYZE_SUPPRESS2(wnum1, wnum2) +#define ANALYZE_SUPPRESS3(wnum1, wnum2, wnum3) +#define ANALYZE_SUPPRESS4(wnum1, wnum2, wnum3, wnum4) +#define PRINTF_FORMAT_STRING +#define SCANF_FORMAT_STRING +#define IN_Z +#define IN_CAP(x) +#define IN_BYTECAP(x) +#define OUT_Z_CAP(x) +#define OUT_CAP(x) +#define OUT_CAP_C(x) +#define OUT_BYTECAP(x) +#define OUT_Z_BYTECAP(x) +#define INOUT_BYTECAP(x) +#define INOUT_Z_CAP(x) +#define INOUT_Z_BYTECAP(x) +#define OUT_Z_ARRAY +#define INOUT_Z_ARRAY +#define MUST_CHECK_RETURN +#endif + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/baseclientstate.h b/SpyCustom/sdk/baseclientstate.h new file mode 100644 index 0000000..cc89a78 --- /dev/null +++ b/SpyCustom/sdk/baseclientstate.h @@ -0,0 +1,118 @@ +#ifndef BASECLIENTSTATE_H +#define BASECLIENTSTATE_H +#ifdef _WIN32 +#pragma once +#endif + + + + + + + +class CBaseClientState +{ +public: + char _pad0[0x20C]; + int m_nDeltaTick; + bool m_bPaused; + char _pad1[0x3]; + int m_nViewEntity; + char _pad2[0x8]; + char m_szLevelName[260]; + char m_szLevelNameShort[40]; +}; + +class CClockDriftMgr +{ +public: + float m_ClockOffsets[16]; + uint32_t m_iCurClockOffset; + uint32_t m_nServerTick; + uint32_t m_nClientTick; +}; + +class CEventInfo +{ +public: + enum + { + EVENT_INDEX_BITS = 8, + EVENT_DATA_LEN_BITS = 11, + MAX_EVENT_DATA = 192, + }; + + inline CEventInfo() + { + classID = 0; + fire_delay = 0.0f; + flags = 0; + pSendTable = NULL; + pClientClass = NULL; + m_Packed = 0; + } + + short classID; + short pad; + float fire_delay; + const void* pSendTable; + const ClientClass* pClientClass; + int m_Packed; + int flags; + int filter[8]; + CEventInfo* next; +}; + +class CClientState +{ +public: + void ForceFullUpdate() + { + m_nDeltaTick = -1; + } + + char pad_0000[156]; + INetChannel* m_NetChannel; + int m_nChallengeNr; + char pad_00A4[100]; + int m_nSignonState; + int signon_pads[2]; + float m_flNextCmdTime; + int m_nServerCount; + int m_nCurrentSequence; + int musor_pads[2]; + CClockDriftMgr m_ClockDriftMgr; + int m_nDeltaTick; + bool m_bPaused; + char paused_align[3]; + int m_nViewEntity; + int m_nPlayerSlot; + int bruh; + char m_szLevelName[260]; + char m_szLevelNameShort[80]; + char m_szGroupName[80]; + char pad_032[92]; + int m_nMaxClients; + char pad_0314[18828]; + float m_nLastServerTickTime; + bool m_bInSimulation; + char pad_4C9D[3]; + int m_nOldTickCount; + float m_flTickReminder; + float m_flFrametime; + int m_nLastOutgoingCommand; + int m_nChokedCommands; + int m_nLastCommandAck; + int m_nPacketEndTickUpdate; + int m_nCommandAck; + int m_nSoundSequence; + char pad_4CCD[76]; + QAngle viewangles; + int pads[54]; + CEventInfo* m_pEvents; +}; + + + +#endif +#pragma once diff --git a/SpyCustom/sdk/baseentity.h b/SpyCustom/sdk/baseentity.h new file mode 100644 index 0000000..85e36c0 --- /dev/null +++ b/SpyCustom/sdk/baseentity.h @@ -0,0 +1,352 @@ +#ifndef ENTITYLIST_H +#define ENTITYLIST_H + +#ifdef _WIN32 +#pragma once +#endif + +class CBaseEntity; +class IEntityListener; + +class CBaseEntityClassList +{ +public: + CBaseEntityClassList(); + ~CBaseEntityClassList(); + virtual void LevelShutdownPostEntity() = 0; + + CBaseEntityClassList* m_pNextClassList; +}; + +template< class T > +class CEntityClassList : public CBaseEntityClassList +{ +public: + virtual void LevelShutdownPostEntity() { m_pClassList = NULL; } + + void Insert(T* pEntity) + { + pEntity->m_pNext = m_pClassList; + m_pClassList = pEntity; + } + + void Remove(T* pEntity) + { + T** pPrev = &m_pClassList; + T* pCur = *pPrev; + while (pCur) + { + if (pCur == pEntity) + { + *pPrev = pCur->m_pNext; + return; + } + pPrev = &pCur->m_pNext; + pCur = *pPrev; + } + } + + static T* m_pClassList; +}; + +abstract_class IEntityFindFilter +{ +public: + virtual bool ShouldFindEntity(CBaseEntity * pEntity) = 0; + virtual CBaseEntity* GetFilterResult(void) = 0; +}; + +class CGlobalEntityList : public CBaseEntityList +{ +public: +private: + int m_iHighestEnt; + int m_iNumEnts; + int m_iNumEdicts; + + bool m_bClearingEntities; + CUtlVector m_entityListeners; + +public: + CBaseHandle AddNetworkableEntity(IHandleEntity* pEnt, int index, int iForcedSerialNum = -1); + CBaseHandle AddNonNetworkableEntity(IHandleEntity* pEnt); + + void UpdateName(IHandleEntity* pEnt, CBaseHandle hEnt); + void UpdateName(IHandleEntity* pEnt); + + IServerNetworkable* GetServerNetworkable(CBaseHandle hEnt) const; + CBaseNetworkable* GetBaseNetworkable(CBaseHandle hEnt) const; + CBaseEntity* GetBaseEntity(CBaseHandle hEnt) const; + edict_t* GetEdict(CBaseHandle hEnt) const; + + int NumberOfEntities(void); + int NumberOfEdicts(void); + + void AddToDeleteList(IServerNetworkable* ent); + void CleanupDeleteList(void); + int ResetDeleteList(void); + + void Clear(void); + + bool IsClearingEntities() { return m_bClearingEntities; } + + void AddListenerEntity(IEntityListener* pListener); + void RemoveListenerEntity(IEntityListener* pListener); + + void ReportEntityFlagsChanged(CBaseEntity* pEntity, unsigned int flagsOld, unsigned int flagsNow); + void AddPostClientMessageEntity(CBaseEntity* pEntity); + void PostClientMessagesSent(); + + void NotifyCreateEntity(CBaseEntity* pEnt); + void NotifySpawn(CBaseEntity* pEnt); + void NotifyRemoveEntity(CBaseEntity* pEnt); + CBaseEntity* NextEnt(CBaseEntity* pCurrentEnt); + CBaseEntity* FirstEnt() { return NextEnt(NULL); } + + template< class T > + T* NextEntByClass(T* start) + { + for (CBaseEntity* x = NextEnt(start); x; x = NextEnt(x)) + { + start = dynamic_cast(x); + if (start) + return start; + } + return NULL; + } + + bool IsEntityPtr(void* pTest); + CBaseEntity* FindEntityByClassname(CBaseEntity* pStartEntity, const char* szName); + CBaseEntity* FindEntityByName(CBaseEntity* pStartEntity, const char* szName, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL, IEntityFindFilter* pFilter = NULL); + CBaseEntity* FindEntityByName(CBaseEntity* pStartEntity, string_t iszName, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL, IEntityFindFilter* pFilter = NULL) + { + return FindEntityByName(pStartEntity, STRING(iszName), pSearchingEntity, pActivator, pCaller, pFilter); + } + CBaseEntity* FindEntityInSphere(CBaseEntity* pStartEntity, const Vector& vecCenter, float flRadius); + CBaseEntity* FindEntityByTarget(CBaseEntity* pStartEntity, const char* szName); + CBaseEntity* FindEntityByModel(CBaseEntity* pStartEntity, const char* szModelName); + CBaseEntity* FindEntityByOutputTarget(CBaseEntity* pStartEntity, string_t iTarget); + + CBaseEntity* FindEntityByNameNearest(const char* szName, const Vector& vecSrc, float flRadius, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL); + CBaseEntity* FindEntityByNameWithin(CBaseEntity* pStartEntity, const char* szName, const Vector& vecSrc, float flRadius, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL); + CBaseEntity* FindEntityByClassnameNearest(const char* szName, const Vector& vecSrc, float flRadius); + CBaseEntity* FindEntityByClassnameNearest2D(const char* szName, const Vector& vecSrc, float flRadius); + CBaseEntity* FindEntityByClassnameWithin(CBaseEntity* pStartEntity, const char* szName, const Vector& vecSrc, float flRadius); + CBaseEntity* FindEntityByClassnameWithin(CBaseEntity* pStartEntity, const char* szName, const Vector& vecMins, const Vector& vecMaxs); + + CBaseEntity* FindEntityGeneric(CBaseEntity* pStartEntity, const char* szName, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL); + CBaseEntity* FindEntityGenericWithin(CBaseEntity* pStartEntity, const char* szName, const Vector& vecSrc, float flRadius, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL); + CBaseEntity* FindEntityGenericNearest(const char* szName, const Vector& vecSrc, float flRadius, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL); + + CBaseEntity* FindEntityNearestFacing(const Vector& origin, const Vector& facing, float threshold); + CBaseEntity* FindEntityClassNearestFacing(const Vector& origin, const Vector& facing, float threshold, char* classname); + CBaseEntity* FindEntityByNetname(CBaseEntity* pStartEntity, const char* szModelName); + + CBaseEntity* FindEntityProcedural(const char* szName, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL); + + CBaseEntity* FindEntityByClassnameFast(CBaseEntity* pStartEntity, string_t iszClassname); + CBaseEntity* FindEntityByClassnameNearestFast(string_t iszClassname, const Vector& vecSrc, float flRadius); + CBaseEntity* FindEntityByNameFast(CBaseEntity* pStartEntity, string_t iszName); + + CGlobalEntityList(); + +protected: + + virtual void OnAddEntity(IHandleEntity* pEnt, CBaseHandle handle); + virtual void OnRemoveEntity(IHandleEntity* pEnt, CBaseHandle handle); + +}; + +extern CGlobalEntityList gEntList; + + +inline CBaseHandle CGlobalEntityList::AddNetworkableEntity(IHandleEntity* pEnt, int index, int iForcedSerialNum) +{ + CBaseHandle h = CBaseEntityList::AddNetworkableEntity(pEnt, index, iForcedSerialNum); + UpdateName(pEnt, h); + return h; +} + +inline CBaseHandle CGlobalEntityList::AddNonNetworkableEntity(IHandleEntity* pEnt) +{ + CBaseHandle h = CBaseEntityList::AddNonNetworkableEntity(pEnt); + UpdateName(pEnt, h); + return h; +} + +inline edict_t* CGlobalEntityList::GetEdict(CBaseHandle hEnt) const +{ + IServerUnknown* pUnk = static_cast(LookupEntity(hEnt)); + if (pUnk) + return pUnk->GetNetworkable()->GetEdict(); + else + return NULL; +} + +inline CBaseNetworkable* CGlobalEntityList::GetBaseNetworkable(CBaseHandle hEnt) const +{ + IServerUnknown* pUnk = static_cast(LookupEntity(hEnt)); + if (pUnk) + return pUnk->GetNetworkable()->GetBaseNetworkable(); + else + return NULL; +} + +inline IServerNetworkable* CGlobalEntityList::GetServerNetworkable(CBaseHandle hEnt) const +{ + IServerUnknown* pUnk = static_cast(LookupEntity(hEnt)); + if (pUnk) + return pUnk->GetNetworkable(); + else + return NULL; +} + +inline CBaseEntity* CGlobalEntityList::GetBaseEntity(CBaseHandle hEnt) const +{ + IServerUnknown* pUnk = static_cast(LookupEntity(hEnt)); + if (pUnk) + return pUnk->GetBaseEntity(); + else + return NULL; +} + + +#if 0 + +template +inline bool FindEntityByName(const char* pszName, ENT_TYPE** ppResult) +{ + CBaseEntity* pBaseEntity = gEntList.FindEntityByName(NULL, pszName); + + if (pBaseEntity) + *ppResult = dynamic_cast(pBaseEntity); + else + *ppResult = NULL; + + return (*ppResult != NULL); +} + +template <> +inline bool FindEntityByName(const char* pszName, CBaseEntity** ppResult) +{ + *ppResult = gEntList.FindEntityByName(NULL, pszName); + return (*ppResult != NULL); +} + +template <> +inline bool FindEntityByName(const char* pszName, CAI_BaseNPC** ppResult) +{ + CBaseEntity* pBaseEntity = gEntList.FindEntityByName(NULL, pszName); + + if (pBaseEntity) + *ppResult = pBaseEntity->MyNPCPointer(); + else + *ppResult = NULL; + + return (*ppResult != NULL); +} +#endif +struct entitem_t +{ + EHANDLE hEnt; + struct entitem_t* pNext; + + static void* operator new(size_t stAllocateBlock); + static void* operator new(size_t stAllocateBlock, int nBlockUse, const char* pFileName, int nLine); + static void operator delete(void* pMem); + static void operator delete(void* pMem, int nBlockUse, const char* pFileName, int nLine) { operator delete(pMem); } +}; + +class CEntityList +{ +public: + CEntityList(); + ~CEntityList(); + + int m_iNumItems; + entitem_t* m_pItemList; + + void AddEntity(CBaseEntity*); + void DeleteEntity(CBaseEntity*); +}; + +enum notify_system_event_t +{ + NOTIFY_EVENT_TELEPORT = 0, + NOTIFY_EVENT_DESTROY, +}; + +struct notify_teleport_params_t +{ + Vector prevOrigin; + QAngle prevAngles; + bool physicsRotate; +}; + +struct notify_destroy_params_t +{ +}; + +struct notify_system_event_params_t +{ + union + { + const notify_teleport_params_t* pTeleport; + const notify_destroy_params_t* pDestroy; + }; + notify_system_event_params_t(const notify_teleport_params_t* pInTeleport) { pTeleport = pInTeleport; } + notify_system_event_params_t(const notify_destroy_params_t* pInDestroy) { pDestroy = pInDestroy; } +}; + + +abstract_class INotify +{ +public: + virtual void AddEntity(CBaseEntity * pNotify, CBaseEntity * pWatched) = 0; + + virtual void RemoveEntity(CBaseEntity* pNotify, CBaseEntity* pWatched) = 0; + + virtual void ReportNamedEvent(CBaseEntity* pEntity, const char* pEventName) = 0; + + virtual void ReportSystemEvent(CBaseEntity* pEntity, notify_system_event_t eventType, const notify_system_event_params_t& params) = 0; + + inline void ReportDestroyEvent(CBaseEntity* pEntity) + { + notify_destroy_params_t destroy; + ReportSystemEvent(pEntity, NOTIFY_EVENT_DESTROY, notify_system_event_params_t(&destroy)); + } + + inline void ReportTeleportEvent(CBaseEntity* pEntity, const Vector& prevOrigin, const QAngle& prevAngles, bool physicsRotate) + { + notify_teleport_params_t teleport; + teleport.prevOrigin = prevOrigin; + teleport.prevAngles = prevAngles; + teleport.physicsRotate = physicsRotate; + ReportSystemEvent(pEntity, NOTIFY_EVENT_TELEPORT, notify_system_event_params_t(&teleport)); + } + + virtual void ClearEntity(CBaseEntity* pNotify) = 0; +}; + +class IEntityListener +{ +public: + virtual void OnEntityCreated(CBaseEntity* pEntity) {}; + virtual void OnEntitySpawned(CBaseEntity* pEntity) {}; + virtual void OnEntityDeleted(CBaseEntity* pEntity) {}; +}; + +extern INotify* g_pNotify; + +void EntityTouch_Add(CBaseEntity* pEntity); +void EntityTouch_Remove(CBaseEntity* pEntity); +int AimTarget_ListCount(); +int AimTarget_ListCopy(CBaseEntity* pList[], int listMax); +CBaseEntity* AimTarget_ListElement(int iIndex); +void AimTarget_ForceRepopulateList(); + +void SimThink_EntityChanged(CBaseEntity* pEntity); +int SimThink_ListCount(); +int SimThink_ListCopy(CBaseEntity* pList[], int listMax); + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/baseentity_shared.h b/SpyCustom/sdk/baseentity_shared.h new file mode 100644 index 0000000..0519cdb --- /dev/null +++ b/SpyCustom/sdk/baseentity_shared.h @@ -0,0 +1,277 @@ +#ifndef BASEENTITY_SHARED_H +#define BASEENTITY_SHARED_H +#ifdef _WIN32 +#pragma once +#endif + + +#define FCAP_MUST_SPAWN 0x00000001 +#define FCAP_ACROSS_TRANSITION 0x00000002 +#define FCAP_FORCE_TRANSITION 0x00000004 +#define FCAP_NOTIFY_ON_TRANSITION 0x00000008 + +#define FCAP_IMPULSE_USE 0x00000010 +#define FCAP_CONTINUOUS_USE 0x00000020 +#define FCAP_ONOFF_USE 0x00000040 +#define FCAP_DIRECTIONAL_USE 0x00000080 +#define FCAP_USE_ONGROUND 0x00000100 +#define FCAP_USE_IN_RADIUS 0x00000200 +#define FCAP_SAVE_NON_NETWORKABLE 0x00000400 + +#define FCAP_MASTER 0x10000000 +#define FCAP_WCEDIT_POSITION 0x40000000 +#define FCAP_DONT_SAVE 0x80000000 + + +#define NUM_PARENTATTACHMENT_BITS 6 + +#define VPHYSICS_MAX_OBJECT_LIST_COUNT 1024 + +enum InvalidatePhysicsBits_t +{ + POSITION_CHANGED = 0x1, + ANGLES_CHANGED = 0x2, + VELOCITY_CHANGED = 0x4, + ANIMATION_CHANGED = 0x8, +}; + + +#if defined( CLIENT_DLL ) +#include "c_baseentity.h" +#include "c_baseanimating.h" +#else +#include "baseentity.h" + +#ifdef HL2_EPISODIC +#include "info_darknessmode_lightsource.h" +#endif + +#endif + +#if !defined( NO_ENTITY_PREDICTION ) +inline bool CBaseEntity::IsPlayerSimulated(void) const +{ + return m_bIsPlayerSimulated; +} + +inline CBasePlayer* CBaseEntity::GetSimulatingPlayer(void) +{ + return m_hPlayerSimulationOwner; +} +#endif + +inline MoveType_t CBaseEntity::GetMoveType() const +{ + return (MoveType_t)(unsigned char)m_MoveType; +} + +inline MoveCollide_t CBaseEntity::GetMoveCollide() const +{ + return (MoveCollide_t)(unsigned char)m_MoveCollide; +} + +inline int CBaseEntity::GetCollisionGroup() const +{ + return m_CollisionGroup; +} + +inline int CBaseEntity::GetFlags(void) const +{ + return m_fFlags; +} + +inline bool CBaseEntity::IsAlive(void) +{ + return m_lifeState == LIFE_ALIVE; +} + +inline CBaseEntity* CBaseEntity::GetOwnerEntity() const +{ + return m_hOwnerEntity.Get(); +} + +inline CBaseEntity* CBaseEntity::GetEffectEntity() const +{ + return m_hEffectEntity.Get(); +} + +inline int CBaseEntity::GetPredictionRandomSeed(void) +{ + return m_nPredictionRandomSeed; +} + +inline CBasePlayer* CBaseEntity::GetPredictionPlayer(void) +{ + return m_pPredictionPlayer; +} + +inline void CBaseEntity::SetPredictionPlayer(CBasePlayer* player) +{ + m_pPredictionPlayer = player; +} + + +inline bool CBaseEntity::IsSimulatedEveryTick() const +{ + return m_bSimulatedEveryTick; +} + +inline bool CBaseEntity::IsAnimatedEveryTick() const +{ + return m_bAnimatedEveryTick; +} + +inline void CBaseEntity::SetSimulatedEveryTick(bool sim) +{ + if (m_bSimulatedEveryTick != sim) + { + m_bSimulatedEveryTick = sim; +#ifdef CLIENT_DLL + Interp_UpdateInterpolationAmounts(GetVarMapping()); +#endif + } +} + +inline void CBaseEntity::SetAnimatedEveryTick(bool anim) +{ + if (m_bAnimatedEveryTick != anim) + { + m_bAnimatedEveryTick = anim; +#ifdef CLIENT_DLL + Interp_UpdateInterpolationAmounts(GetVarMapping()); +#endif + } +} + +inline float CBaseEntity::GetAnimTime() const +{ + return m_flAnimTime; +} + +inline float CBaseEntity::GetSimulationTime() const +{ + return m_flSimulationTime; +} + +inline void CBaseEntity::SetAnimTime(float at) +{ + m_flAnimTime = at; +} + +inline void CBaseEntity::SetSimulationTime(float st) +{ + m_flSimulationTime = st; +} + +inline int CBaseEntity::GetEffects(void) const +{ + return m_fEffects; +} + +inline void CBaseEntity::RemoveEffects(int nEffects) +{ +#if !defined( CLIENT_DLL ) +#ifdef HL2_EPISODIC + if (nEffects & (EF_BRIGHTLIGHT | EF_DIMLIGHT)) + { + if (!IsPlayer()) + { + RemoveEntityFromDarknessCheck(this); + } + } +#endif +#endif + + m_fEffects &= ~nEffects; + if (nEffects & EF_NODRAW) + { +#ifndef CLIENT_DLL + NetworkProp()->MarkPVSInformationDirty(); + DispatchUpdateTransmitState(); +#else + UpdateVisibility(); +#endif + } +} + +inline void CBaseEntity::ClearEffects(void) +{ +#if !defined( CLIENT_DLL ) +#ifdef HL2_EPISODIC + if (m_fEffects & (EF_BRIGHTLIGHT | EF_DIMLIGHT)) + { + if (!IsPlayer()) + { + RemoveEntityFromDarknessCheck(this); + } + } +#endif +#endif + + m_fEffects = 0; +#ifndef CLIENT_DLL + DispatchUpdateTransmitState(); +#else + UpdateVisibility(); +#endif +} + +inline bool CBaseEntity::IsEffectActive(int nEffects) const +{ + return (m_fEffects & nEffects) != 0; +} + +#define BASEENTITY_MSG_REMOVE_DECALS 1 + +extern float k_flMaxEntityPosCoord; +extern float k_flMaxEntityEulerAngle; +extern float k_flMaxEntitySpeed; +extern float k_flMaxEntitySpinRate; + +inline bool IsEntityCoordinateReasonable(const vec_t c) +{ + float r = k_flMaxEntityPosCoord; + return c > -r && c < r; +} + +inline bool IsEntityPositionReasonable(const Vector& v) +{ + float r = k_flMaxEntityPosCoord; + return + v.x > -r && v.x < r&& + v.y > -r && v.y < r&& + v.z > -r && v.z < r; +} + +extern int CheckEntityVelocity(Vector& v); + +inline bool IsEntityQAngleReasonable(const QAngle& q) +{ + float r = k_flMaxEntityEulerAngle; + return + q.x > -r && q.x < r&& + q.y > -r && q.y < r&& + q.z > -r && q.z < r; +} + +inline bool IsEntityAngularVelocityReasonable(const Vector& q) +{ + float r = k_flMaxEntitySpinRate; + return + q.x > -r && q.x < r&& + q.y > -r && q.y < r&& + q.z > -r && q.z < r; +} + +inline bool IsEntityQAngleVelReasonable(const QAngle& q) +{ + float r = k_flMaxEntitySpinRate; + return + q.x > -r && q.x < r&& + q.y > -r && q.y < r&& + q.z > -r && q.z < r; +} + +extern bool CheckEmitReasonablePhysicsSpew(); + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/basehandle.h b/SpyCustom/sdk/basehandle.h new file mode 100644 index 0000000..393ec83 --- /dev/null +++ b/SpyCustom/sdk/basehandle.h @@ -0,0 +1,160 @@ +#ifndef BASEHANDLE_H +#define BASEHANDLE_H +#ifdef _WIN32 +#pragma once +#endif + + +#include "const.h" +#include "dbg.h" + + +class IHandleEntity; + + +class CBaseHandle +{ + friend class CBaseEntityList; + +public: + + CBaseHandle(); + CBaseHandle(const CBaseHandle& other); + CBaseHandle(unsigned long value); + CBaseHandle(int iEntry, int iSerialNumber); + + void Init(int iEntry, int iSerialNumber); + void Term(); + + bool IsValid() const; + + int GetEntryIndex() const; + int GetSerialNumber() const; + + int ToInt() const; + bool operator !=(const CBaseHandle& other) const; + bool operator ==(const CBaseHandle& other) const; + bool operator ==(const IHandleEntity* pEnt) const; + bool operator !=(const IHandleEntity* pEnt) const; + bool operator <(const CBaseHandle& other) const; + bool operator <(const IHandleEntity* pEnt) const; + + const CBaseHandle& operator=(const IHandleEntity* pEntity); + const CBaseHandle& Set(const IHandleEntity* pEntity); + + IHandleEntity* Get() const; + + +protected: + unsigned long m_Index; +}; + + +#include "ihandleentity.h" + + +inline CBaseHandle::CBaseHandle() +{ + m_Index = INVALID_EHANDLE_INDEX; +} + +inline CBaseHandle::CBaseHandle(const CBaseHandle& other) +{ + m_Index = other.m_Index; +} + +inline CBaseHandle::CBaseHandle(unsigned long value) +{ + m_Index = value; +} + +inline CBaseHandle::CBaseHandle(int iEntry, int iSerialNumber) +{ + Init(iEntry, iSerialNumber); +} + +inline void CBaseHandle::Init(int iEntry, int iSerialNumber) +{ + Assert(iEntry >= 0 && iEntry < NUM_ENT_ENTRIES); + Assert(iSerialNumber >= 0 && iSerialNumber < (1 << NUM_SERIAL_NUM_BITS)); + + m_Index = iEntry | (iSerialNumber << NUM_ENT_ENTRY_BITS); +} + +inline void CBaseHandle::Term() +{ + m_Index = INVALID_EHANDLE_INDEX; +} + +inline bool CBaseHandle::IsValid() const +{ + return m_Index != INVALID_EHANDLE_INDEX; +} + +inline int CBaseHandle::GetEntryIndex() const +{ + return m_Index & ENT_ENTRY_MASK; +} + +inline int CBaseHandle::GetSerialNumber() const +{ + return m_Index >> NUM_ENT_ENTRY_BITS; +} + +inline int CBaseHandle::ToInt() const +{ + return (int)m_Index; +} + +inline bool CBaseHandle::operator !=(const CBaseHandle& other) const +{ + return m_Index != other.m_Index; +} + +inline bool CBaseHandle::operator ==(const CBaseHandle& other) const +{ + return m_Index == other.m_Index; +} + +inline bool CBaseHandle::operator ==(const IHandleEntity* pEnt) const +{ + return Get() == pEnt; +} + +inline bool CBaseHandle::operator !=(const IHandleEntity* pEnt) const +{ + return Get() != pEnt; +} + +inline bool CBaseHandle::operator <(const CBaseHandle& other) const +{ + return m_Index < other.m_Index; +} + +inline bool CBaseHandle::operator <(const IHandleEntity* pEntity) const +{ + unsigned long otherIndex = (pEntity) ? pEntity->GetRefEHandle().m_Index : INVALID_EHANDLE_INDEX; + return m_Index < otherIndex; +} + +inline const CBaseHandle& CBaseHandle::operator=(const IHandleEntity* pEntity) +{ + return Set(pEntity); +} + +inline const CBaseHandle& CBaseHandle::Set(const IHandleEntity* pEntity) +{ + if (pEntity) + { + *this = pEntity->GetRefEHandle(); + } + else + { + m_Index = INVALID_EHANDLE_INDEX; + } + + return *this; +} + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/basetypes.h b/SpyCustom/sdk/basetypes.h new file mode 100644 index 0000000..acbb225 --- /dev/null +++ b/SpyCustom/sdk/basetypes.h @@ -0,0 +1,341 @@ +#ifndef BASETYPES_H +#define BASETYPES_H + +#include "commonmacros.h" +#include "wchartypes.h" + +#ifdef _WIN32 +#pragma once +#endif + + + + +#define DLLExtTokenPaste(x) #x +#define DLLExtTokenPaste2(x) DLLExtTokenPaste(x) +#define DLL_EXT_STRING DLLExtTokenPaste2( _DLL_EXT ) + + + +#ifdef IN_XBOX_CODELINE +#define XBOX_CODELINE_ONLY() +#else +#define XBOX_CODELINE_ONLY() Error_Compiling_Code_Only_Valid_in_Xbox_Codeline +#endif + +#ifndef NULL +#define NULL 0 +#endif + + +#ifdef POSIX +#include +#endif + +#define ExecuteNTimes( nTimes, x ) \ + { \ + static int __executeCount=0;\ + if ( __executeCount < nTimes )\ + { \ + x; \ + ++__executeCount; \ + } \ + } + + +#define ExecuteOnce( x ) ExecuteNTimes( 1, x ) + + +template +inline T AlignValue(T val, uintptr_t alignment) +{ + return (T)(((uintptr_t)val + alignment - 1) & ~(alignment - 1)); +} + + +#define PAD_NUMBER(number, boundary) \ + ( ((number) + ((boundary)-1)) / (boundary) ) * (boundary) + +#if !defined(M_PI) && !defined(HAVE_M_PI) +#define M_PI 3.14159265358979323846 +#endif + +#define COMPILETIME_MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) +#define COMPILETIME_MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) +#ifndef MIN +#define MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) +#endif + +#ifndef MAX +#define MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) +#endif + +#ifdef __cplusplus + +template< class T > +T Clamp(T const& val, T const& minVal, T const& maxVal) +{ + if (val < minVal) + return minVal; + else if (val > maxVal) + return maxVal; + else + return val; +} + +template< class T > +T Min(T const& val1, T const& val2) +{ + return val1 < val2 ? val1 : val2; +} + +template< class T > +T Max(T const& val1, T const& val2) +{ + return val1 > val2 ? val1 : val2; +} + +#endif + +#ifndef FALSE +#define FALSE 0 +#define TRUE (!FALSE) +#endif + + +#ifndef DONT_DEFINE_BOOL +typedef int BOOL; +#endif + +typedef int qboolean; +typedef unsigned long ULONG; +typedef unsigned char BYTE; +typedef unsigned char byte; +typedef unsigned short word; +#ifdef _WIN32 +typedef wchar_t ucs2; +#else +typedef unsigned short ucs2; +#endif + +enum ThreeState_t +{ + TRS_FALSE, + TRS_TRUE, + TRS_NONE, +}; + +typedef float vec_t; + +#if defined(__GNUC__) +#define fpmin __builtin_fminf +#define fpmax __builtin_fmaxf +#elif !defined(_X360) +#define fpmin min +#define fpmax max +#endif + + + +inline unsigned long& FloatBits(vec_t& f) +{ + return *reinterpret_cast(&f); +} + +inline unsigned long const& FloatBits(vec_t const& f) +{ + return *reinterpret_cast(&f); +} + +inline vec_t BitsToFloat(unsigned long i) +{ + return *reinterpret_cast(&i); +} + +inline bool IsFinite(vec_t f) +{ + return ((FloatBits(f) & 0x7F800000) != 0x7F800000); +} + +inline unsigned long FloatAbsBits(vec_t f) +{ + return FloatBits(f) & 0x7FFFFFFF; +} + +#ifdef _MSC_VER +#ifndef _In_ +#define _In_ +#endif +extern "C" float fabsf(_In_ float); +#else +#include +#endif + +inline float FloatMakeNegative(vec_t f) +{ + return -fabsf(f); +} + +inline float FloatMakePositive(vec_t f) +{ + return fabsf(f); +} + +inline float FloatNegate(vec_t f) +{ + return -f; +} + + +#define FLOAT32_NAN_BITS (unsigned long)0x7FC00000 +#define FLOAT32_NAN BitsToFloat( FLOAT32_NAN_BITS ) + +#define VEC_T_NAN FLOAT32_NAN + + + +struct color24 +{ + byte r, g, b; +}; + +typedef struct color32_s +{ + bool operator!=(const struct color32_s& other) const; + + byte r, g, b, a; +} color32; + +inline bool color32::operator!=(const color32& other) const +{ + return r != other.r || g != other.g || b != other.b || a != other.a; +} + +struct colorVec +{ + unsigned r, g, b, a; +}; + + +#ifndef NOTE_UNUSED +#define NOTE_UNUSED(x) (void)(x) +#endif + +struct vrect_t +{ + int x, y, width, height; + vrect_t* pnext; +}; + + +struct Rect_t +{ + int x, y; + int width, height; +}; + + +struct interval_t +{ + float start; + float range; +}; + + +template< class HandleType > +class CBaseIntHandle +{ +public: + + inline bool operator==(const CBaseIntHandle& other) { return m_Handle == other.m_Handle; } + inline bool operator!=(const CBaseIntHandle& other) { return m_Handle != other.m_Handle; } + + inline HandleType GetHandleValue() { return m_Handle; } + inline void SetHandleValue(HandleType val) { m_Handle = val; } + + typedef HandleType HANDLE_TYPE; + +protected: + + HandleType m_Handle; +}; + +template< class DummyType > +class CIntHandle16 : public CBaseIntHandle< unsigned short > +{ +public: + inline CIntHandle16() {} + + static inline CIntHandle16 MakeHandle(HANDLE_TYPE val) + { + return CIntHandle16(val); + } + +protected: + inline CIntHandle16(HANDLE_TYPE val) + { + m_Handle = val; + } +}; + + +template< class DummyType > +class CIntHandle32 : public CBaseIntHandle< unsigned long > +{ +public: + inline CIntHandle32() {} + + static inline CIntHandle32 MakeHandle(HANDLE_TYPE val) + { + return CIntHandle32(val); + } + +protected: + inline CIntHandle32(HANDLE_TYPE val) + { + m_Handle = val; + } +}; + + +#define DECLARE_HANDLE_16BIT(name) typedef CIntHandle16< struct name##__handle * > name; +#define DECLARE_HANDLE_32BIT(name) typedef CIntHandle32< struct name##__handle * > name; + +#define DECLARE_POINTER_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name +#define FORWARD_DECLARE_HANDLE(name) typedef struct name##__ *name + +#if !defined(_STATIC_LINKED) && !defined(PUBLISH_DLL_SUBSYSTEM) +#define PUBLISH_DLL_SUBSYSTEM() +#endif + +#define UID_PREFIX generated_id_ +#define UID_CAT1(a,c) a ## c +#define UID_CAT2(a,c) UID_CAT1(a,c) +#define EXPAND_CONCAT(a,c) UID_CAT1(a,c) +#ifdef _MSC_VER +#define UNIQUE_ID UID_CAT2(UID_PREFIX,__COUNTER__) +#else +#define UNIQUE_ID UID_CAT2(UID_PREFIX,__LINE__) +#endif + +#define DEFINE_ENUM_BITWISE_OPERATORS( Type ) \ + inline Type operator| ( Type a, Type b ) { return Type( int( a ) | int( b ) ); } \ + inline Type operator& ( Type a, Type b ) { return Type( int( a ) & int( b ) ); } \ + inline Type operator^ ( Type a, Type b ) { return Type( int( a ) ^ int( b ) ); } \ + inline Type operator<< ( Type a, int b ) { return Type( int( a ) << b ); } \ + inline Type operator>> ( Type a, int b ) { return Type( int( a ) >> b ); } \ + inline Type &operator|= ( Type &a, Type b ) { return a = a | b; } \ + inline Type &operator&= ( Type &a, Type b ) { return a = a & b; } \ + inline Type &operator^= ( Type &a, Type b ) { return a = a ^ b; } \ + inline Type &operator<<=( Type &a, int b ) { return a = a << b; } \ + inline Type &operator>>=( Type &a, int b ) { return a = a >> b; } \ + inline Type operator~( Type a ) { return Type( ~int( a ) ); } + +#define DEFINE_ENUM_INCREMENT_OPERATORS( Type ) \ + inline Type &operator++( Type &a ) { return a = Type( int( a ) + 1 ); } \ + inline Type &operator--( Type &a ) { return a = Type( int( a ) - 1 ); } \ + inline Type operator++( Type &a, int ) { Type t = a; ++a; return t; } \ + inline Type operator--( Type &a, int ) { Type t = a; --a; return t; } + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/beam_flags.h b/SpyCustom/sdk/beam_flags.h new file mode 100644 index 0000000..e978875 --- /dev/null +++ b/SpyCustom/sdk/beam_flags.h @@ -0,0 +1,29 @@ +#if !defined( BEAM_FLAGS_H ) +#define BEAM_FLAGS_H +#ifdef _WIN32 +#pragma once +#endif + +enum +{ + FBEAM_STARTENTITY = 0x00000001, + FBEAM_ENDENTITY = 0x00000002, + FBEAM_FADEIN = 0x00000004, + FBEAM_FADEOUT = 0x00000008, + FBEAM_SINENOISE = 0x00000010, + FBEAM_SOLID = 0x00000020, + FBEAM_SHADEIN = 0x00000040, + FBEAM_SHADEOUT = 0x00000080, + FBEAM_ONLYNOISEONCE = 0x00000100, + FBEAM_NOTILE = 0x00000200, + FBEAM_USE_HITBOXES = 0x00000400, + FBEAM_STARTVISIBLE = 0x00000800, + FBEAM_ENDVISIBLE = 0x00001000, + FBEAM_ISACTIVE = 0x00002000, + FBEAM_FOREVER = 0x00004000, + FBEAM_HALOBEAM = 0x00008000, + FBEAM_REVERSED = 0x00010000, + NUM_BEAM_FLAGS = 17 +}; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/bitbuf.h b/SpyCustom/sdk/bitbuf.h new file mode 100644 index 0000000..ce8aa81 --- /dev/null +++ b/SpyCustom/sdk/bitbuf.h @@ -0,0 +1,624 @@ +#ifndef BITBUF_H +#define BITBUF_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "mathlib.h" +#include "vector.h" +#include "basetypes.h" + +#if _DEBUG +#define BITBUF_INLINE inline +#else +#define BITBUF_INLINE FORCEINLINE +#endif + +class Vector; +class QAngle; + +typedef enum +{ + BITBUFERROR_VALUE_OUT_OF_RANGE = 0, + BITBUFERROR_BUFFER_OVERRUN, + + BITBUFERROR_NUM_ERRORS +} BitBufErrorType; + + +typedef void (*BitBufErrorHandler)(BitBufErrorType errorType, const char* pDebugName); + + +#if defined( _DEBUG ) +extern void InternalBitBufErrorHandler(BitBufErrorType errorType, const char* pDebugName); +#define CallErrorHandler( errorType, pDebugName ) InternalBitBufErrorHandler( errorType, pDebugName ); +#else +#define CallErrorHandler( errorType, pDebugName ) +#endif + + +void SetBitBufErrorHandler(BitBufErrorHandler fn); + + +inline int BitByte(int bits) +{ + return (bits + 7) >> 3; +} + +namespace bitbuf +{ + inline uint32 ZigZagEncode32(int32 n) + { + return(n << 1) ^ (n >> 31); + } + + inline int32 ZigZagDecode32(uint32 n) + { + return(n >> 1) ^ -static_cast(n & 1); + } + + inline uint64 ZigZagEncode64(int64 n) + { + return(n << 1) ^ (n >> 63); + } + + inline int64 ZigZagDecode64(uint64 n) + { + return(n >> 1) ^ -static_cast(n & 1); + } + + const int kMaxVarintBytes = 10; + const int kMaxVarint32Bytes = 5; +} + +class bf_write +{ +public: + bf_write(); + + bf_write(void* pData, int nBytes, int nMaxBits = -1); + bf_write(const char* pDebugName, void* pData, int nBytes, int nMaxBits = -1); + + void StartWriting(void* pData, int nBytes, int iStartBit = 0, int nMaxBits = -1); + + void Reset(); + + unsigned char* GetBasePointer() { return (unsigned char*)m_pData; } + + void SetAssertOnOverflow(bool bAssert); + + const char* GetDebugName(); + void SetDebugName(const char* pDebugName); + + +public: + + void SeekToBit(int bitPos); + + +public: + + void WriteOneBit(int nValue); + void WriteOneBitNoCheck(int nValue); + void WriteOneBitAt(int iBit, int nValue); + + void WriteUBitLong(unsigned int data, int numbits, bool bCheckRange = true); + void WriteSBitLong(int data, int numbits); + + void WriteBitLong(unsigned int data, int numbits, bool bSigned); + + bool WriteBits(const void* pIn, int nBits); + + void WriteUBitVar(unsigned int data); + + void WriteVarInt32(uint32 data); + void WriteVarInt64(uint64 data); + void WriteSignedVarInt32(int32 data); + void WriteSignedVarInt64(int64 data); + int ByteSizeVarInt32(uint32 data); + int ByteSizeVarInt64(uint64 data); + int ByteSizeSignedVarInt32(int32 data); + int ByteSizeSignedVarInt64(int64 data); + + bool WriteBitsFromBuffer(class bf_read* pIn, int nBits); + + void WriteBitAngle(float fAngle, int numbits); + void WriteBitCoord(const float f); + void WriteBitCoordMP(const float f, bool bIntegral, bool bLowPrecision); + void WriteBitFloat(float val); + void WriteBitVec3Coord(const Vector& fa); + void WriteBitNormal(float f); + void WriteBitVec3Normal(const Vector& fa); + void WriteBitAngles(const QAngle& fa); + + +public: + + void WriteChar(int val); + void WriteByte(int val); + void WriteShort(int val); + void WriteWord(int val); + void WriteLong(long val); + void WriteLongLong(int64 val); + void WriteFloat(float val); + bool WriteBytes(const void* pBuf, int nBytes); + + bool WriteString(const char* pStr); + + +public: + + int GetNumBytesWritten() const; + int GetNumBitsWritten() const; + int GetMaxNumBits(); + int GetNumBitsLeft(); + int GetNumBytesLeft(); + unsigned char* GetData(); + const unsigned char* GetData() const; + + bool CheckForOverflow(int nBits); + inline bool IsOverflowed() const { return m_bOverflow; } + + void SetOverflowFlag(); + + +public: + unsigned long* RESTRICT m_pData; + int m_nDataBytes; + int m_nDataBits; + + int m_iCurBit; + +private: + + bool m_bOverflow; + + bool m_bAssertOnOverflow; + const char* m_pDebugName; +}; + + +inline int bf_write::GetNumBytesWritten() const +{ + return BitByte(m_iCurBit); +} + +inline int bf_write::GetNumBitsWritten() const +{ + return m_iCurBit; +} + +inline int bf_write::GetMaxNumBits() +{ + return m_nDataBits; +} + +inline int bf_write::GetNumBitsLeft() +{ + return m_nDataBits - m_iCurBit; +} + +inline int bf_write::GetNumBytesLeft() +{ + return GetNumBitsLeft() >> 3; +} + +inline unsigned char* bf_write::GetData() +{ + return (unsigned char*)m_pData; +} + +inline const unsigned char* bf_write::GetData() const +{ + return (unsigned char*)m_pData; +} + +BITBUF_INLINE bool bf_write::CheckForOverflow(int nBits) +{ + if (m_iCurBit + nBits > m_nDataBits) + { + SetOverflowFlag(); + CallErrorHandler(BITBUFERROR_BUFFER_OVERRUN, GetDebugName()); + } + + return m_bOverflow; +} + +BITBUF_INLINE void bf_write::SetOverflowFlag() +{ +#ifdef DBGFLAG_ASSERT + if (m_bAssertOnOverflow) + { + Assert(false); + } +#endif + m_bOverflow = true; +} + +BITBUF_INLINE void bf_write::WriteOneBitNoCheck(int nValue) +{ +#if __i386__ + if (nValue) + m_pData[m_iCurBit >> 5] |= 1u << (m_iCurBit & 31); + else + m_pData[m_iCurBit >> 5] &= ~(1u << (m_iCurBit & 31)); +#else + extern unsigned long g_LittleBits[32]; + if (nValue) + m_pData[m_iCurBit >> 5] |= g_LittleBits[m_iCurBit & 31]; + else + m_pData[m_iCurBit >> 5] &= ~g_LittleBits[m_iCurBit & 31]; +#endif + + ++m_iCurBit; +} + +inline void bf_write::WriteOneBit(int nValue) +{ + if (m_iCurBit >= m_nDataBits) + { + SetOverflowFlag(); + CallErrorHandler(BITBUFERROR_BUFFER_OVERRUN, GetDebugName()); + return; + } + WriteOneBitNoCheck(nValue); +} + + +inline void bf_write::WriteOneBitAt(int iBit, int nValue) +{ + if (iBit >= m_nDataBits) + { + SetOverflowFlag(); + CallErrorHandler(BITBUFERROR_BUFFER_OVERRUN, GetDebugName()); + return; + } + +#if __i386__ + if (nValue) + m_pData[iBit >> 5] |= 1u << (iBit & 31); + else + m_pData[iBit >> 5] &= ~(1u << (iBit & 31)); +#else + extern unsigned long g_LittleBits[32]; + if (nValue) + m_pData[iBit >> 5] |= g_LittleBits[iBit & 31]; + else + m_pData[iBit >> 5] &= ~g_LittleBits[iBit & 31]; +#endif +} + +BITBUF_INLINE void bf_write::WriteUBitLong(unsigned int curData, int numbits, bool bCheckRange) RESTRICT +{ +#ifdef _DEBUG + if (bCheckRange && numbits < 32) + { + if (curData >= (unsigned long)(1 << numbits)) + { + CallErrorHandler(BITBUFERROR_VALUE_OUT_OF_RANGE, GetDebugName()); + } + } + Assert(numbits >= 0 && numbits <= 32); +#endif + + if (GetNumBitsLeft() < numbits) + { + m_iCurBit = m_nDataBits; + SetOverflowFlag(); + CallErrorHandler(BITBUFERROR_BUFFER_OVERRUN, GetDebugName()); + return; + } + + int iCurBitMasked = m_iCurBit & 31; + int iDWord = m_iCurBit >> 5; + m_iCurBit += numbits; + + Assert((iDWord * 4 + sizeof(long)) <= (unsigned int)m_nDataBytes); + unsigned long* RESTRICT pOut = &m_pData[iDWord]; + + curData = (curData << iCurBitMasked) | (curData >> (32 - iCurBitMasked)); + + unsigned int temp = 1 << (numbits - 1); + unsigned int mask1 = (temp * 2 - 1) << iCurBitMasked; + unsigned int mask2 = (temp - 1) >> (31 - iCurBitMasked); + + int i = mask2 & 1; + unsigned long dword1 = LoadLittleDWord(pOut, 0); + unsigned long dword2 = LoadLittleDWord(pOut, i); + + dword1 ^= (mask1 & (curData ^ dword1)); + dword2 ^= (mask2 & (curData ^ dword2)); + + StoreLittleDWord(pOut, i, dword2); + StoreLittleDWord(pOut, 0, dword1); +} + +BITBUF_INLINE void bf_write::WriteUBitVar(unsigned int data) +{ + int n = (data < 0x10u ? -1 : 0) + (data < 0x100u ? -1 : 0) + (data < 0x1000u ? -1 : 0); + WriteUBitLong(data * 4 + n + 3, 6 + n * 4 + 12); + if (data >= 0x1000u) + { + WriteUBitLong(data >> 16, 16); + } +} + +BITBUF_INLINE void bf_write::WriteBitFloat(float val) +{ + long intVal; + + Assert(sizeof(long) == sizeof(float)); + Assert(sizeof(float) == 4); + + intVal = *((long*)&val); + WriteUBitLong(intVal, 32); +} + +template +class old_bf_write_static : public bf_write +{ +public: + inline old_bf_write_static() : bf_write(m_StaticData, SIZE) {} + + char m_StaticData[SIZE]; +}; + + + +class bf_read +{ +public: + bf_read(); + + bf_read(const void* pData, int nBytes, int nBits = -1); + bf_read(const char* pDebugName, const void* pData, int nBytes, int nBits = -1); + + void StartReading(const void* pData, int nBytes, int iStartBit = 0, int nBits = -1); + + void Reset(); + + void SetAssertOnOverflow(bool bAssert); + + const char* GetDebugName() const { return m_pDebugName; } + void SetDebugName(const char* pName); + + void ExciseBits(int startbit, int bitstoremove); + + +public: + + int ReadOneBit(); + + +protected: + + unsigned int CheckReadUBitLong(int numbits); + int ReadOneBitNoCheck(); + bool CheckForOverflow(int nBits); + + +public: + + const unsigned char* GetBasePointer() { return m_pData; } + + BITBUF_INLINE int TotalBytesAvailable(void) const + { + return m_nDataBytes; + } + + void ReadBits(void* pOut, int nBits); + int ReadBitsClamped_ptr(void* pOut, size_t outSizeBytes, size_t nBits); + template + int ReadBitsClamped(T(&pOut)[N], size_t nBits) + { + return ReadBitsClamped_ptr(pOut, N * sizeof(T), nBits); + } + + float ReadBitAngle(int numbits); + + unsigned int ReadUBitLong(int numbits) RESTRICT; + unsigned int ReadUBitLongNoInline(int numbits) RESTRICT; + unsigned int PeekUBitLong(int numbits); + int ReadSBitLong(int numbits); + + unsigned int ReadUBitVar(); + unsigned int ReadUBitVarInternal(int encodingType); + + uint32 ReadVarInt32(); + uint64 ReadVarInt64(); + int32 ReadSignedVarInt32(); + int64 ReadSignedVarInt64(); + + unsigned int ReadBitLong(int numbits, bool bSigned); + + float ReadBitCoord(); + float ReadBitCoordMP(bool bIntegral, bool bLowPrecision); + float ReadBitFloat(); + float ReadBitNormal(); + void ReadBitVec3Coord(Vector& fa); + void ReadBitVec3Normal(Vector& fa); + void ReadBitAngles(QAngle& fa); + + unsigned int ReadBitCoordBits(); + unsigned int ReadBitCoordMPBits(bool bIntegral, bool bLowPrecision); + +public: + + BITBUF_INLINE int ReadChar() { return (char)ReadUBitLong(8); } + BITBUF_INLINE int ReadByte() { return ReadUBitLong(8); } + BITBUF_INLINE int ReadShort() { return (short)ReadUBitLong(16); } + BITBUF_INLINE int ReadWord() { return ReadUBitLong(16); } + BITBUF_INLINE long ReadLong() { return ReadUBitLong(32); } + int64 ReadLongLong(); + float ReadFloat(); + bool ReadBytes(void* pOut, int nBytes); + + bool ReadString(char* pStr, int bufLen, bool bLine = false, int* pOutNumChars = NULL); + + char* ReadAndAllocateString(bool* pOverflow = 0); + + int CompareBits(bf_read* RESTRICT other, int bits) RESTRICT; + int CompareBitsAt(int offset, bf_read* RESTRICT other, int otherOffset, int bits) RESTRICT; + +public: + int GetNumBytesLeft(); + int GetNumBytesRead(); + int GetNumBitsLeft(); + int GetNumBitsRead() const; + + inline bool IsOverflowed() const { return m_bOverflow; } + + inline bool Seek(int iBit); + inline bool SeekRelative(int iBitDelta); + + void SetOverflowFlag(); + + +public: + + const unsigned char* RESTRICT m_pData; + int m_nDataBytes; + int m_nDataBits; + + int m_iCurBit; + + +private: + bool m_bOverflow; + + bool m_bAssertOnOverflow; + + const char* m_pDebugName; +}; + +inline int bf_read::GetNumBytesRead() +{ + return BitByte(m_iCurBit); +} + +inline int bf_read::GetNumBitsLeft() +{ + return m_nDataBits - m_iCurBit; +} + +inline int bf_read::GetNumBytesLeft() +{ + return GetNumBitsLeft() >> 3; +} + +inline int bf_read::GetNumBitsRead() const +{ + return m_iCurBit; +} + +inline bool bf_read::Seek(int iBit) +{ + if (iBit < 0 || iBit > m_nDataBits) + { + SetOverflowFlag(); + m_iCurBit = m_nDataBits; + return false; + } + else + { + m_iCurBit = iBit; + return true; + } +} + +inline bool bf_read::SeekRelative(int iBitDelta) +{ + return Seek(m_iCurBit + iBitDelta); +} + +inline bool bf_read::CheckForOverflow(int nBits) +{ + if (m_iCurBit + nBits > m_nDataBits) + { + SetOverflowFlag(); + CallErrorHandler(BITBUFERROR_BUFFER_OVERRUN, GetDebugName()); + } + + return m_bOverflow; +} + +inline int bf_read::ReadOneBitNoCheck() +{ +#if VALVE_LITTLE_ENDIAN + unsigned int value = ((unsigned long* RESTRICT)m_pData)[m_iCurBit >> 5] >> (m_iCurBit & 31); +#else + unsigned char value = m_pData[m_iCurBit >> 3] >> (m_iCurBit & 7); +#endif + ++m_iCurBit; + return value & 1; +} + +inline int bf_read::ReadOneBit() +{ + if (GetNumBitsLeft() <= 0) + { + SetOverflowFlag(); + CallErrorHandler(BITBUFERROR_BUFFER_OVERRUN, GetDebugName()); + return 0; + } + return ReadOneBitNoCheck(); +} + +inline float bf_read::ReadBitFloat() +{ + union { uint32 u; float f; } c = { ReadUBitLong(32) }; + return c.f; +} + +BITBUF_INLINE unsigned int bf_read::ReadUBitVar() +{ + unsigned int sixbits = ReadUBitLong(6); + unsigned int encoding = sixbits & 3; + if (encoding) + { + return ReadUBitVarInternal(encoding); + } + return sixbits >> 2; +} + +BITBUF_INLINE unsigned int bf_read::ReadUBitLong(int numbits) RESTRICT +{ + Assert(numbits > 0 && numbits <= 32); + + if (GetNumBitsLeft() < numbits) + { + m_iCurBit = m_nDataBits; + SetOverflowFlag(); + CallErrorHandler(BITBUFERROR_BUFFER_OVERRUN, GetDebugName()); + return 0; + } + + unsigned int iStartBit = m_iCurBit & 31u; + int iLastBit = m_iCurBit + numbits - 1; + unsigned int iWordOffset1 = m_iCurBit >> 5; + unsigned int iWordOffset2 = iLastBit >> 5; + m_iCurBit += numbits; + +#if __i386__ + unsigned int bitmask = (2 << (numbits - 1)) - 1; +#else + extern unsigned long g_ExtraMasks[33]; + unsigned int bitmask = g_ExtraMasks[numbits]; +#endif + + unsigned int dw1 = LoadLittleDWord((unsigned long* RESTRICT)m_pData, iWordOffset1) >> iStartBit; + unsigned int dw2 = LoadLittleDWord((unsigned long* RESTRICT)m_pData, iWordOffset2) << (32 - iStartBit); + + return (dw1 | dw2) & bitmask; +} + +BITBUF_INLINE int bf_read::CompareBits(bf_read* RESTRICT other, int numbits) RESTRICT +{ + return (ReadUBitLong(numbits) != other->ReadUBitLong(numbits)); +} + + +#endif + diff --git a/SpyCustom/sdk/bittools.h b/SpyCustom/sdk/bittools.h new file mode 100644 index 0000000..90503d5 --- /dev/null +++ b/SpyCustom/sdk/bittools.h @@ -0,0 +1,38 @@ +#ifndef BITTOOLS_H +#define BITTOOLS_H +#ifdef _WIN32 +#pragma once +#endif + +namespace bittools +{ + template + struct RecurseBit + { + enum { result = RecurseBit::result }; + }; + + template + struct RecurseBit<0, C> + { + enum { result = C }; + }; + + template + struct RecursePow2 + { + enum { result = RecursePow2::result }; + }; + + template + struct RecursePow2<0, C> + { + enum { result = C }; + }; + +} + +#define ROUND_TO_POWER_OF_2( n ) ( bittools::RecursePow2< (n) - 1 >::result ) +#define MINIMUM_BITS_NEEDED( n ) ( bittools::RecurseBit< (n) - 1 >::result ) + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/bitvec.h b/SpyCustom/sdk/bitvec.h new file mode 100644 index 0000000..46d6ed6 --- /dev/null +++ b/SpyCustom/sdk/bitvec.h @@ -0,0 +1,1239 @@ +#ifndef BITVEC_H +#define BITVEC_H +#ifdef _WIN32 +#pragma once +#endif + +#include +#include "dbg.h" +#include "basetypes.h" + + +class CBitVecAccessor +{ +public: + CBitVecAccessor(uint32* pDWords, int iBit); + + void operator=(int val); + operator uint32(); + +private: + uint32* m_pDWords; + int m_iBit; +}; + + +#define LOG2_BITS_PER_INT 5 +#define BITS_PER_INT 32 + +#if _WIN32 && !defined(_X360) +#include +#pragma intrinsic(_BitScanForward) +#endif + +inline int FirstBitInWord(unsigned int elem, int offset) +{ +#if _WIN32 + if (!elem) + return -1; +#if defined( _X360 ) + unsigned int mask = elem - 1; + unsigned int comp = ~elem; + elem = mask & comp; + return (32 - _CountLeadingZeros(elem)) + offset; +#else + unsigned long out; + _BitScanForward(&out, elem); + return out + offset; +#endif + +#else + static unsigned firstBitLUT[256] = + { + 0,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0, + 3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0, + 3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0, + 3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0, + 4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0 + }; + unsigned elemByte; + + elemByte = (elem & 0xFF); + if (elemByte) + return offset + firstBitLUT[elemByte]; + + elem >>= 8; + offset += 8; + elemByte = (elem & 0xFF); + if (elemByte) + return offset + firstBitLUT[elemByte]; + + elem >>= 8; + offset += 8; + elemByte = (elem & 0xFF); + if (elemByte) + return offset + firstBitLUT[elemByte]; + + elem >>= 8; + offset += 8; + elemByte = (elem & 0xFF); + if (elemByte) + return offset + firstBitLUT[elemByte]; + + return -1; +#endif +} + +inline unsigned GetEndMask(int numBits) +{ + static unsigned bitStringEndMasks[] = + { + 0xffffffff, + 0x00000001, + 0x00000003, + 0x00000007, + 0x0000000f, + 0x0000001f, + 0x0000003f, + 0x0000007f, + 0x000000ff, + 0x000001ff, + 0x000003ff, + 0x000007ff, + 0x00000fff, + 0x00001fff, + 0x00003fff, + 0x00007fff, + 0x0000ffff, + 0x0001ffff, + 0x0003ffff, + 0x0007ffff, + 0x000fffff, + 0x001fffff, + 0x003fffff, + 0x007fffff, + 0x00ffffff, + 0x01ffffff, + 0x03ffffff, + 0x07ffffff, + 0x0fffffff, + 0x1fffffff, + 0x3fffffff, + 0x7fffffff, + }; + + return bitStringEndMasks[numBits % BITS_PER_INT]; +} + + +inline int GetBitForBitnum(int bitNum) +{ + static int bitsForBitnum[] = + { + (1 << 0), + (1 << 1), + (1 << 2), + (1 << 3), + (1 << 4), + (1 << 5), + (1 << 6), + (1 << 7), + (1 << 8), + (1 << 9), + (1 << 10), + (1 << 11), + (1 << 12), + (1 << 13), + (1 << 14), + (1 << 15), + (1 << 16), + (1 << 17), + (1 << 18), + (1 << 19), + (1 << 20), + (1 << 21), + (1 << 22), + (1 << 23), + (1 << 24), + (1 << 25), + (1 << 26), + (1 << 27), + (1 << 28), + (1 << 29), + (1 << 30), + (1 << 31), + }; + + return bitsForBitnum[(bitNum) & (BITS_PER_INT - 1)]; +} + +inline int GetBitForBitnumByte(int bitNum) +{ + static int bitsForBitnum[] = + { + (1 << 0), + (1 << 1), + (1 << 2), + (1 << 3), + (1 << 4), + (1 << 5), + (1 << 6), + (1 << 7), + }; + + return bitsForBitnum[bitNum & 7]; +} + +inline int CalcNumIntsForBits(int numBits) { return (numBits + (BITS_PER_INT - 1)) / BITS_PER_INT; } + +#ifdef _X360 +#define BitVec_Bit( bitNum ) GetBitForBitnum( bitNum ) +#define BitVec_BitInByte( bitNum ) GetBitForBitnumByte( bitNum ) +#else +#define BitVec_Bit( bitNum ) ( 1 << ( (bitNum) & (BITS_PER_INT-1) ) ) +#define BitVec_BitInByte( bitNum ) ( 1 << ( (bitNum) & 7 ) ) +#endif +#define BitVec_Int( bitNum ) ( (bitNum) >> LOG2_BITS_PER_INT ) + + +template +class CBitVecT : public BASE_OPS +{ +public: + CBitVecT(); + CBitVecT(int numBits); + + void Init(int val = 0); + + CBitVecAccessor operator[](int i); + + void And(const CBitVecT& andStr, CBitVecT* out) const; + void Or(const CBitVecT& orStr, CBitVecT* out) const; + void Xor(const CBitVecT& orStr, CBitVecT* out) const; + + void Not(CBitVecT* out) const; + + void CopyTo(CBitVecT* out) const; + void Copy(const CBitVecT& other, int nBits = -1); + bool Compare(const CBitVecT& other, int nBits = -1) const; + + bool IsAllClear(void) const; + bool IsAllSet(void) const; + + uint32 Get(uint32 bitNum) const; + bool IsBitSet(int bitNum) const; + void Set(int bitNum); + void Set(int bitNum, bool bNewVal); + void Clear(int bitNum); + + bool TestAndSet(int bitNum); + + void Set(uint32 offset, uint32 mask); + void Clear(uint32 offset, uint32 mask); + uint32 Get(uint32 offset, uint32 mask); + + void SetAll(void); + void ClearAll(void); + + uint32 GetDWord(int i) const; + void SetDWord(int i, uint32 val); + + CBitVecT& operator=(const CBitVecT& other) { other.CopyTo(this); return *this; } + bool operator==(const CBitVecT& other) { return Compare(other); } + bool operator!=(const CBitVecT& other) { return !operator==(other); } + + static void GetOffsetMaskForBit(uint32 bitNum, uint32* pOffset, uint32* pMask) { *pOffset = BitVec_Int(bitNum); *pMask = BitVec_Bit(bitNum); } +}; + +template +class CVarBitVecBase +{ +public: + bool IsFixedSize() const { return false; } + int GetNumBits(void) const { return m_numBits; } + void Resize(int numBits, bool bClearAll = false); + + int GetNumDWords() const { return m_numInts; } + uint32* Base() { return m_pInt; } + const uint32* Base() const { return m_pInt; } + + void Attach(uint32* pBits, int numBits); + bool Detach(uint32** ppBits, int* pNumBits); + + int FindNextSetBit(int iStartBit) const; + +protected: + CVarBitVecBase(); + CVarBitVecBase(int numBits); + CVarBitVecBase(const CVarBitVecBase& from); + CVarBitVecBase& operator=(const CVarBitVecBase& from); + ~CVarBitVecBase(void); + + void ValidateOperand(const CVarBitVecBase& operand) const { Assert(GetNumBits() == operand.GetNumBits()); } + + unsigned GetEndMask() const { return ::GetEndMask(GetNumBits()); } + +private: + + BITCOUNTTYPE m_numBits; + BITCOUNTTYPE m_numInts; + uint32 m_iBitStringStorage; + uint32* m_pInt; + + void AllocInts(int numInts); + void ReallocInts(int numInts); + void FreeInts(void); +}; + +template struct BitCountToEndMask_t { }; +template <> struct BitCountToEndMask_t< 0> { enum { MASK = 0xffffffff }; }; +template <> struct BitCountToEndMask_t< 1> { enum { MASK = 0x00000001 }; }; +template <> struct BitCountToEndMask_t< 2> { enum { MASK = 0x00000003 }; }; +template <> struct BitCountToEndMask_t< 3> { enum { MASK = 0x00000007 }; }; +template <> struct BitCountToEndMask_t< 4> { enum { MASK = 0x0000000f }; }; +template <> struct BitCountToEndMask_t< 5> { enum { MASK = 0x0000001f }; }; +template <> struct BitCountToEndMask_t< 6> { enum { MASK = 0x0000003f }; }; +template <> struct BitCountToEndMask_t< 7> { enum { MASK = 0x0000007f }; }; +template <> struct BitCountToEndMask_t< 8> { enum { MASK = 0x000000ff }; }; +template <> struct BitCountToEndMask_t< 9> { enum { MASK = 0x000001ff }; }; +template <> struct BitCountToEndMask_t<10> { enum { MASK = 0x000003ff }; }; +template <> struct BitCountToEndMask_t<11> { enum { MASK = 0x000007ff }; }; +template <> struct BitCountToEndMask_t<12> { enum { MASK = 0x00000fff }; }; +template <> struct BitCountToEndMask_t<13> { enum { MASK = 0x00001fff }; }; +template <> struct BitCountToEndMask_t<14> { enum { MASK = 0x00003fff }; }; +template <> struct BitCountToEndMask_t<15> { enum { MASK = 0x00007fff }; }; +template <> struct BitCountToEndMask_t<16> { enum { MASK = 0x0000ffff }; }; +template <> struct BitCountToEndMask_t<17> { enum { MASK = 0x0001ffff }; }; +template <> struct BitCountToEndMask_t<18> { enum { MASK = 0x0003ffff }; }; +template <> struct BitCountToEndMask_t<19> { enum { MASK = 0x0007ffff }; }; +template <> struct BitCountToEndMask_t<20> { enum { MASK = 0x000fffff }; }; +template <> struct BitCountToEndMask_t<21> { enum { MASK = 0x001fffff }; }; +template <> struct BitCountToEndMask_t<22> { enum { MASK = 0x003fffff }; }; +template <> struct BitCountToEndMask_t<23> { enum { MASK = 0x007fffff }; }; +template <> struct BitCountToEndMask_t<24> { enum { MASK = 0x00ffffff }; }; +template <> struct BitCountToEndMask_t<25> { enum { MASK = 0x01ffffff }; }; +template <> struct BitCountToEndMask_t<26> { enum { MASK = 0x03ffffff }; }; +template <> struct BitCountToEndMask_t<27> { enum { MASK = 0x07ffffff }; }; +template <> struct BitCountToEndMask_t<28> { enum { MASK = 0x0fffffff }; }; +template <> struct BitCountToEndMask_t<29> { enum { MASK = 0x1fffffff }; }; +template <> struct BitCountToEndMask_t<30> { enum { MASK = 0x3fffffff }; }; +template <> struct BitCountToEndMask_t<31> { enum { MASK = 0x7fffffff }; }; + +template +class CFixedBitVecBase +{ +public: + bool IsFixedSize() const { return true; } + int GetNumBits(void) const { return NUM_BITS; } + void Resize(int numBits, bool bClearAll = false) { Assert(numBits == NUM_BITS); if (bClearAll) Plat_FastMemset(m_Ints, 0, NUM_INTS * sizeof(uint32)); } + + int GetNumDWords() const { return NUM_INTS; } + uint32* Base() { return m_Ints; } + const uint32* Base() const { return m_Ints; } + + int FindNextSetBit(int iStartBit) const; + +protected: + CFixedBitVecBase() {} + CFixedBitVecBase(int numBits) { Assert(numBits == NUM_BITS); } + + void ValidateOperand(const CFixedBitVecBase& operand) const { } + +public: + unsigned GetEndMask() const { return static_cast(BitCountToEndMask_t::MASK); } + +private: + enum + { + NUM_INTS = (NUM_BITS + (BITS_PER_INT - 1)) / BITS_PER_INT + }; + + uint32 m_Ints[(NUM_BITS + (BITS_PER_INT - 1)) / BITS_PER_INT]; +}; + +class CVarBitVec : public CBitVecT< CVarBitVecBase > +{ +public: + CVarBitVec() + { + } + + CVarBitVec(int numBits) + : CBitVecT< CVarBitVecBase >(numBits) + { + } +}; + +class CLargeVarBitVec : public CBitVecT< CVarBitVecBase > +{ +public: + CLargeVarBitVec() + { + } + + CLargeVarBitVec(int numBits) + : CBitVecT< CVarBitVecBase >(numBits) + { + } +}; + +template < int NUM_BITS > +class CBitVec : public CBitVecT< CFixedBitVecBase > +{ +public: + CBitVec() + { + } + + CBitVec(int numBits) + : CBitVecT< CFixedBitVecBase >(numBits) + { + } +}; + + +typedef CBitVec<32> CDWordBitVec; + +template +inline CVarBitVecBase::CVarBitVecBase() +{ + Plat_FastMemset(this, 0, sizeof(*this)); +} + +template +inline CVarBitVecBase::CVarBitVecBase(int numBits) +{ + Assert(numBits); + m_numBits = numBits; + + m_numInts = CalcNumIntsForBits(numBits); + m_pInt = NULL; + AllocInts(m_numInts); +} + +template +inline CVarBitVecBase::CVarBitVecBase(const CVarBitVecBase& from) +{ + if (from.m_numInts) + { + m_numBits = from.m_numBits; + m_numInts = from.m_numInts; + m_pInt = NULL; + AllocInts(m_numInts); + memcpy(m_pInt, from.m_pInt, m_numInts * sizeof(int)); + } + else + memset(this, 0, sizeof(*this)); +} + +template +inline CVarBitVecBase& CVarBitVecBase::operator=(const CVarBitVecBase& from) +{ + Resize(from.GetNumBits()); + if (m_pInt) + memcpy(m_pInt, from.m_pInt, m_numInts * sizeof(int)); + return (*this); +} + +template +inline CVarBitVecBase::~CVarBitVecBase(void) +{ + FreeInts(); +} + +template +inline void CVarBitVecBase::Attach(uint32* pBits, int numBits) +{ + FreeInts(); + m_numBits = numBits; + m_numInts = CalcNumIntsForBits(numBits); + if (m_numInts > 1) + { + m_pInt = pBits; + } + else + { + m_iBitStringStorage = *pBits; + m_pInt = &m_iBitStringStorage; + free(pBits); + } +} + +template +inline bool CVarBitVecBase::Detach(uint32** ppBits, int* pNumBits) +{ + if (!m_numBits) + { + return false; + } + + *pNumBits = m_numBits; + if (m_numInts > 1) + { + *ppBits = m_pInt; + } + else + { + *ppBits = (uint32*)malloc(sizeof(uint32)); + **ppBits = m_iBitStringStorage; + free(m_pInt); + } + + memset(this, 0, sizeof(*this)); + return true; +} + +template +inline CBitVecT::CBitVecT() +{ + COMPILE_TIME_ASSERT(sizeof(int) == 4); + + ClearAll(); +} + +template +inline CBitVecT::CBitVecT(int numBits) + : BASE_OPS(numBits) +{ + COMPILE_TIME_ASSERT(sizeof(int) == 4); + + ClearAll(); +} + +template +inline CBitVecAccessor CBitVecT::operator[](int i) +{ + Assert(i >= 0 && i < this->GetNumBits()); + return CBitVecAccessor(this->Base(), i); +} + + +template +inline void CBitVecT::Init(int val) +{ + if (this->Base()) + Plat_FastMemset(this->Base(), (val) ? 0xff : 0, this->GetNumDWords() * sizeof(int)); +} + +template +inline uint32 CBitVecT::Get(uint32 bitNum) const +{ + Assert(bitNum < (uint32)this->GetNumBits()); + const uint32* pInt = this->Base() + BitVec_Int(bitNum); + return (*pInt & BitVec_Bit(bitNum)); +} + +template +inline bool CBitVecT::IsBitSet(int bitNum) const +{ + Assert(bitNum >= 0 && bitNum < this->GetNumBits()); + const uint32* pInt = this->Base() + BitVec_Int(bitNum); + return ((*pInt & BitVec_Bit(bitNum)) != 0); +} + +template +inline void CBitVecT::Set(int bitNum) +{ + Assert(bitNum >= 0 && bitNum < this->GetNumBits()); + uint32* pInt = this->Base() + BitVec_Int(bitNum); + *pInt |= BitVec_Bit(bitNum); +} + +template +inline bool CBitVecT::TestAndSet(int bitNum) +{ + Assert(bitNum >= 0 && bitNum < this->GetNumBits()); + uint32 bitVecBit = BitVec_Bit(bitNum); + uint32* pInt = this->Base() + BitVec_Int(bitNum); + bool bResult = ((*pInt & bitVecBit) != 0); + *pInt |= bitVecBit; + return bResult; +} + +template +inline void CBitVecT::Clear(int bitNum) +{ + Assert(bitNum >= 0 && bitNum < this->GetNumBits()); + uint32* pInt = this->Base() + BitVec_Int(bitNum); + *pInt &= ~BitVec_Bit(bitNum); +} + +template +inline void CBitVecT::Set(int bitNum, bool bNewVal) +{ + uint32* pInt = this->Base() + BitVec_Int(bitNum); + uint32 bitMask = BitVec_Bit(bitNum); + if (bNewVal) + { + *pInt |= bitMask; + } + else + { + *pInt &= ~bitMask; + } +} + +template +inline void CBitVecT::Set(uint32 offset, uint32 mask) +{ + uint32* pInt = this->Base() + offset; + *pInt |= mask; +} + +template +inline void CBitVecT::Clear(uint32 offset, uint32 mask) +{ + uint32* pInt = this->Base() + offset; + *pInt &= ~mask; +} + +template +inline uint32 CBitVecT::Get(uint32 offset, uint32 mask) +{ + uint32* pInt = this->Base() + offset; + return (*pInt & mask); +} + +template +inline void CBitVecT::And(const CBitVecT& addStr, CBitVecT* out) const +{ + this->ValidateOperand(addStr); + this->ValidateOperand(*out); + + uint32* pDest = out->Base(); + const uint32* pOperand1 = this->Base(); + const uint32* pOperand2 = addStr.Base(); + + for (int i = this->GetNumDWords() - 1; i >= 0; --i) + { + pDest[i] = pOperand1[i] & pOperand2[i]; + } +} + +template +inline void CBitVecT::Or(const CBitVecT& orStr, CBitVecT* out) const +{ + this->ValidateOperand(orStr); + this->ValidateOperand(*out); + + uint32* pDest = out->Base(); + const uint32* pOperand1 = this->Base(); + const uint32* pOperand2 = orStr.Base(); + + for (int i = this->GetNumDWords() - 1; i >= 0; --i) + { + pDest[i] = pOperand1[i] | pOperand2[i]; + } +} + +template +inline void CBitVecT::Xor(const CBitVecT& xorStr, CBitVecT* out) const +{ + uint32* pDest = out->Base(); + const uint32* pOperand1 = this->Base(); + const uint32* pOperand2 = xorStr.Base(); + + for (int i = this->GetNumDWords() - 1; i >= 0; --i) + { + pDest[i] = pOperand1[i] ^ pOperand2[i]; + } +} + +template +inline void CBitVecT::Not(CBitVecT* out) const +{ + this->ValidateOperand(*out); + + uint32* pDest = out->Base(); + const uint32* pOperand = this->Base(); + + for (int i = this->GetNumDWords() - 1; i >= 0; --i) + { + pDest[i] = ~(pOperand[i]); + } +} + +template +inline void CBitVecT::CopyTo(CBitVecT* out) const +{ + out->Resize(this->GetNumBits()); + + this->ValidateOperand(*out); + Assert(out != this); + + memcpy(out->Base(), this->Base(), this->GetNumDWords() * sizeof(int)); +} + +template +inline bool CBitVecT::IsAllClear(void) const +{ + (const_cast(this))->Base()[this->GetNumDWords() - 1] &= CBitVecT::GetEndMask(); + + for (int i = this->GetNumDWords() - 1; i >= 0; --i) + { + if (this->Base()[i] != 0) + { + return false; + } + } + return true; +} + +template +inline bool CBitVecT::IsAllSet(void) const +{ + (const_cast(this))->Base()[this->GetNumDWords() - 1] |= ~CBitVecT::GetEndMask(); + + for (int i = this->GetNumDWords() - 1; i >= 0; --i) + { + if (this->Base()[i] != ~0) + { + return false; + } + } + return true; +} + +template +inline void CBitVecT::SetAll(void) +{ + if (this->Base()) + Plat_FastMemset(this->Base(), 0xff, this->GetNumDWords() * sizeof(int)); +} + +template +inline void CBitVecT::ClearAll(void) +{ + if (this->Base()) + Plat_FastMemset(this->Base(), 0, this->GetNumDWords() * sizeof(int)); +} + +template +inline void CBitVecT::Copy(const CBitVecT& other, int nBits) +{ + if (nBits == -1) + { + nBits = other.GetNumBits(); + } + + this->Resize(nBits); + + this->ValidateOperand(other); + Assert(&other != this); + + memcpy(this->Base(), other.Base(), this->GetNumDWords() * sizeof(uint32)); +} + +template +inline bool CBitVecT::Compare(const CBitVecT& other, int nBits) const +{ + if (nBits == -1) + { + if (other.GetNumBits() != this->GetNumBits()) + { + return false; + } + + nBits = other.GetNumBits(); + } + + if (nBits > other.GetNumBits() || nBits > this->GetNumBits()) + { + return false; + } + + (const_cast(this))->Base()[this->GetNumDWords() - 1] &= CBitVecT::GetEndMask(); + (const_cast(&other))->Base()[this->GetNumDWords() - 1] &= other.CBitVecT::GetEndMask(); + + int nBytes = PAD_NUMBER(nBits, 8) >> 3; + + return (memcmp(this->Base(), other.Base(), nBytes) == 0); +} + +template +inline uint32 CBitVecT::GetDWord(int i) const +{ + Assert(i >= 0 && i < this->GetNumDWords()); + return this->Base()[i]; +} + +template +inline void CBitVecT::SetDWord(int i, uint32 val) +{ + Assert(i >= 0 && i < this->GetNumDWords()); + this->Base()[i] = val; +} + +inline unsigned GetStartBitMask(int startBit) +{ + static unsigned int g_StartMask[32] = + { + 0xffffffff, + 0xfffffffe, + 0xfffffffc, + 0xfffffff8, + 0xfffffff0, + 0xffffffe0, + 0xffffffc0, + 0xffffff80, + 0xffffff00, + 0xfffffe00, + 0xfffffc00, + 0xfffff800, + 0xfffff000, + 0xffffe000, + 0xffffc000, + 0xffff8000, + 0xffff0000, + 0xfffe0000, + 0xfffc0000, + 0xfff80000, + 0xfff00000, + 0xffe00000, + 0xffc00000, + 0xff800000, + 0xff000000, + 0xfe000000, + 0xfc000000, + 0xf8000000, + 0xf0000000, + 0xe0000000, + 0xc0000000, + 0x80000000, + }; + + return g_StartMask[startBit & 31]; +} + +template +inline int CVarBitVecBase::FindNextSetBit(int startBit) const +{ + if (startBit < GetNumBits()) + { + int wordIndex = BitVec_Int(startBit); + unsigned int startMask = GetStartBitMask(startBit); + int lastWord = GetNumDWords() - 1; + + if ((GetNumBits() % BITS_PER_INT) != 0) + { + unsigned int elem = Base()[wordIndex]; + elem &= startMask; + if (wordIndex == lastWord) + { + elem &= (GetEndMask()); + if (elem) + return FirstBitInWord(elem, wordIndex << 5); + } + else + { + if (elem) + return FirstBitInWord(elem, wordIndex << 5); + + for (int i = wordIndex + 1; i < lastWord; i++) + { + elem = Base()[i]; + if (elem) + return FirstBitInWord(elem, i << 5); + } + elem = Base()[lastWord] & GetEndMask(); + if (elem) + return FirstBitInWord(elem, lastWord << 5); + } + } + else + { + const uint32* RESTRICT pCurElem = Base() + wordIndex; + unsigned int elem = *pCurElem; + elem &= startMask; + do + { + if (elem) + return FirstBitInWord(elem, wordIndex << 5); + ++pCurElem; + elem = *pCurElem; + ++wordIndex; + } while (wordIndex <= lastWord); + } + + } + + return -1; +} + +template +inline int CFixedBitVecBase::FindNextSetBit(int startBit) const +{ + if (startBit < NUM_BITS) + { + int wordIndex = BitVec_Int(startBit); + unsigned int startMask = GetStartBitMask(startBit); + + if ((NUM_BITS % BITS_PER_INT) != 0) + { + unsigned int elem = Base()[wordIndex]; + elem &= startMask; + if (wordIndex == NUM_INTS - 1) + { + elem &= (GetEndMask()); + if (elem) + return FirstBitInWord(elem, wordIndex << 5); + } + else + { + if (elem) + return FirstBitInWord(elem, wordIndex << 5); + + for (int i = wordIndex + 1; i < NUM_INTS - 1; i++) + { + elem = Base()[i]; + if (elem) + return FirstBitInWord(elem, i << 5); + } + elem = Base()[NUM_INTS - 1] & GetEndMask(); + if (elem) + return FirstBitInWord(elem, (NUM_INTS - 1) << 5); + } + } + else + { + const uint32* RESTRICT pCurElem = Base() + wordIndex; + unsigned int elem = *pCurElem; + elem &= startMask; + do + { + if (elem) + return FirstBitInWord(elem, wordIndex << 5); + ++pCurElem; + elem = *pCurElem; + ++wordIndex; + } while (wordIndex <= NUM_INTS - 1); + } + + } + + return -1; +} + +template<> +FORCEINLINE_TEMPLATE void CBitVecT< CFixedBitVecBase<256> >::And(const CBitVecT& addStr, CBitVecT* out) const +{ + uint32* pDest = out->Base(); + const uint32* pOperand1 = Base(); + const uint32* pOperand2 = addStr.Base(); + + pDest[0] = pOperand1[0] & pOperand2[0]; + pDest[1] = pOperand1[1] & pOperand2[1]; + pDest[2] = pOperand1[2] & pOperand2[2]; + pDest[3] = pOperand1[3] & pOperand2[3]; + pDest[4] = pOperand1[4] & pOperand2[4]; + pDest[5] = pOperand1[5] & pOperand2[5]; + pDest[6] = pOperand1[6] & pOperand2[6]; + pDest[7] = pOperand1[7] & pOperand2[7]; +} + +template<> +FORCEINLINE_TEMPLATE bool CBitVecT< CFixedBitVecBase<256> >::IsAllClear(void) const +{ + const uint32* pInts = Base(); + return (pInts[0] == 0 && pInts[1] == 0 && pInts[2] == 0 && pInts[3] == 0 && pInts[4] == 0 && pInts[5] == 0 && pInts[6] == 0 && pInts[7] == 0); +} + +template<> +FORCEINLINE_TEMPLATE void CBitVecT< CFixedBitVecBase<256> >::CopyTo(CBitVecT* out) const +{ + uint32* pDest = out->Base(); + const uint32* pInts = Base(); + + pDest[0] = pInts[0]; + pDest[1] = pInts[1]; + pDest[2] = pInts[2]; + pDest[3] = pInts[3]; + pDest[4] = pInts[4]; + pDest[5] = pInts[5]; + pDest[6] = pInts[6]; + pDest[7] = pInts[7]; +} + +template<> +FORCEINLINE_TEMPLATE void CBitVecT< CFixedBitVecBase<128> >::And(const CBitVecT& addStr, CBitVecT* out) const +{ + uint32* pDest = out->Base(); + const uint32* pOperand1 = Base(); + const uint32* pOperand2 = addStr.Base(); + + pDest[0] = pOperand1[0] & pOperand2[0]; + pDest[1] = pOperand1[1] & pOperand2[1]; + pDest[2] = pOperand1[2] & pOperand2[2]; + pDest[3] = pOperand1[3] & pOperand2[3]; +} + +template<> +FORCEINLINE_TEMPLATE bool CBitVecT< CFixedBitVecBase<128> >::IsAllClear(void) const +{ + const uint32* pInts = Base(); + return (pInts[0] == 0 && pInts[1] == 0 && pInts[2] == 0 && pInts[3] == 0); +} + +template<> +FORCEINLINE_TEMPLATE void CBitVecT< CFixedBitVecBase<128> >::CopyTo(CBitVecT* out) const +{ + uint32* pDest = out->Base(); + const uint32* pInts = Base(); + + pDest[0] = pInts[0]; + pDest[1] = pInts[1]; + pDest[2] = pInts[2]; + pDest[3] = pInts[3]; +} + +template<> +inline void CBitVecT< CFixedBitVecBase<96> >::And(const CBitVecT& addStr, CBitVecT* out) const +{ + uint32* pDest = out->Base(); + const uint32* pOperand1 = Base(); + const uint32* pOperand2 = addStr.Base(); + + pDest[0] = pOperand1[0] & pOperand2[0]; + pDest[1] = pOperand1[1] & pOperand2[1]; + pDest[2] = pOperand1[2] & pOperand2[2]; +} + +template<> +inline bool CBitVecT< CFixedBitVecBase<96> >::IsAllClear(void) const +{ + const uint32* pInts = Base(); + return (pInts[0] == 0 && pInts[1] == 0 && pInts[2] == 0); +} + +template<> +inline void CBitVecT< CFixedBitVecBase<96> >::CopyTo(CBitVecT* out) const +{ + uint32* pDest = out->Base(); + const uint32* pInts = Base(); + + pDest[0] = pInts[0]; + pDest[1] = pInts[1]; + pDest[2] = pInts[2]; +} + +template<> +inline void CBitVecT< CFixedBitVecBase<64> >::And(const CBitVecT& addStr, CBitVecT* out) const +{ + uint32* pDest = out->Base(); + const uint32* pOperand1 = Base(); + const uint32* pOperand2 = addStr.Base(); + + pDest[0] = pOperand1[0] & pOperand2[0]; + pDest[1] = pOperand1[1] & pOperand2[1]; +} + +template<> +inline bool CBitVecT< CFixedBitVecBase<64> >::IsAllClear(void) const +{ + const uint32* pInts = Base(); + return (pInts[0] == 0 && pInts[1] == 0); +} + +template<> +inline void CBitVecT< CFixedBitVecBase<64> >::CopyTo(CBitVecT* out) const +{ + uint32* pDest = out->Base(); + const uint32* pInts = Base(); + + pDest[0] = pInts[0]; + pDest[1] = pInts[1]; +} + +template<> +inline void CBitVecT< CFixedBitVecBase<32> >::And(const CBitVecT& addStr, CBitVecT* out) const +{ + uint32* pDest = out->Base(); + const uint32* pOperand1 = Base(); + const uint32* pOperand2 = addStr.Base(); + + pDest[0] = pOperand1[0] & pOperand2[0]; +} + +template<> +inline bool CBitVecT< CFixedBitVecBase<32> >::IsAllClear(void) const +{ + const uint32* pInts = Base(); + + return (pInts[0] == 0); +} + +template<> +inline void CBitVecT< CFixedBitVecBase<32> >::CopyTo(CBitVecT* out) const +{ + uint32* pDest = out->Base(); + const uint32* pInts = Base(); + + pDest[0] = pInts[0]; +} + +template <> +inline uint32 CBitVecT< CFixedBitVecBase<32> >::Get(uint32 bitNum) const +{ + return (*Base() & BitVec_Bit(bitNum)); +} + +template <> +inline bool CBitVecT< CFixedBitVecBase<32> >::IsBitSet(int bitNum) const +{ + return ((*Base() & BitVec_Bit(bitNum)) != 0); +} + +template <> +inline void CBitVecT< CFixedBitVecBase<32> >::Set(int bitNum) +{ + *Base() |= BitVec_Bit(bitNum); +} + +template <> +inline void CBitVecT< CFixedBitVecBase<32> >::Clear(int bitNum) +{ + *Base() &= ~BitVec_Bit(bitNum); +} + +template <> +inline void CBitVecT< CFixedBitVecBase<32> >::Set(int bitNum, bool bNewVal) +{ + uint32 bitMask = BitVec_Bit(bitNum); + if (bNewVal) + { + *Base() |= bitMask; + } + else + { + *Base() &= ~bitMask; + } +} + + +#include "memdbgon.h" + +template +inline void CVarBitVecBase::Resize(int resizeNumBits, bool bClearAll) +{ + Assert(resizeNumBits >= 0 && ((BITCOUNTTYPE)resizeNumBits == resizeNumBits)); + + int newIntCount = CalcNumIntsForBits(resizeNumBits); + if (newIntCount != GetNumDWords()) + { + if (Base()) + { + ReallocInts(newIntCount); + if (!bClearAll && resizeNumBits >= GetNumBits()) + { + Base()[GetNumDWords() - 1] &= GetEndMask(); + Plat_FastMemset(Base() + GetNumDWords(), 0, (newIntCount - GetNumDWords()) * sizeof(int)); + } + } + else + { + AllocInts(newIntCount); + bClearAll = true; + } + + m_numInts = newIntCount; + } + else if (!bClearAll && resizeNumBits >= GetNumBits() && Base()) + { + Base()[GetNumDWords() - 1] &= GetEndMask(); + } + + if (bClearAll && Base()) + { + Plat_FastMemset(Base(), 0, newIntCount * sizeof(int)); + } + + m_numBits = resizeNumBits; +} + +template +inline void CVarBitVecBase::AllocInts(int numInts) +{ + Assert(!m_pInt); + + if (numInts == 0) + return; + + if (numInts == 1) + { + m_pInt = &m_iBitStringStorage; + return; + } + + m_pInt = (uint32*)malloc(numInts * sizeof(int)); +} + + +template +inline void CVarBitVecBase::ReallocInts(int numInts) +{ + Assert(Base()); + if (numInts == 0) + { + FreeInts(); + return; + } + + if (m_pInt == &m_iBitStringStorage) + { + if (numInts != 1) + { + m_pInt = ((uint32*)malloc(numInts * sizeof(int))); + *m_pInt = m_iBitStringStorage; + } + + return; + } + + if (numInts == 1) + { + m_iBitStringStorage = *m_pInt; + free(m_pInt); + m_pInt = &m_iBitStringStorage; + return; + } + + m_pInt = (uint32*)realloc(m_pInt, numInts * sizeof(int)); +} + + +template +inline void CVarBitVecBase::FreeInts(void) +{ + if (m_numInts > 1) + { + free(m_pInt); + } + m_pInt = NULL; +} + +#include "memdbgoff.h" + +inline CBitVecAccessor::CBitVecAccessor(uint32* pDWords, int iBit) +{ + m_pDWords = pDWords; + m_iBit = iBit; +} + + +inline void CBitVecAccessor::operator=(int val) +{ + if (val) + m_pDWords[m_iBit >> 5] |= (1 << (m_iBit & 31)); + else + m_pDWords[m_iBit >> 5] &= ~(unsigned long)(1 << (m_iBit & 31)); +} + +inline CBitVecAccessor::operator uint32() +{ + return m_pDWords[m_iBit >> 5] & (1 << (m_iBit & 31)); +} + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/bone_accessor.h b/SpyCustom/sdk/bone_accessor.h new file mode 100644 index 0000000..04159e0 --- /dev/null +++ b/SpyCustom/sdk/bone_accessor.h @@ -0,0 +1,122 @@ +#ifndef BONE_ACCESSOR_H +#define BONE_ACCESSOR_H +#ifdef _WIN32 +#pragma once +#endif + + +#include "studio.h" + + +class C_BaseAnimating; + + +class CBoneAccessor +{ +public: + + CBoneAccessor(); + CBoneAccessor(matrix3x4_t* pBones); + +#if defined( CLIENT_DLL ) + void Init(const C_BaseAnimating* pAnimating, matrix3x4_t* pBones); +#endif + + int GetReadableBones(); + void SetReadableBones(int flags); + + int GetWritableBones(); + void SetWritableBones(int flags); + + const matrix3x4_t& GetBone(int iBone) const; + const matrix3x4_t& operator[](int iBone) const; + matrix3x4_t& GetBoneForWrite(int iBone); + + matrix3x4_t* GetBoneArrayForWrite() const; + +private: + +#if defined( CLIENT_DLL ) && defined( _DEBUG ) + void SanityCheckBone(int iBone, bool bReadable) const; +#endif + + const C_BaseAnimating* m_pAnimating; + + matrix3x4_t* m_pBones; + + int m_ReadableBones; + int m_WritableBones; +}; + + +inline CBoneAccessor::CBoneAccessor() +{ + m_pAnimating = NULL; + m_pBones = NULL; + m_ReadableBones = m_WritableBones = 0; +} + +inline CBoneAccessor::CBoneAccessor(matrix3x4_t* pBones) +{ + m_pAnimating = NULL; + m_pBones = pBones; +} + +#if defined( CLIENT_DLL ) +inline void CBoneAccessor::Init(const C_BaseAnimating* pAnimating, matrix3x4_t* pBones) +{ + m_pAnimating = pAnimating; + m_pBones = pBones; +} +#endif + +inline int CBoneAccessor::GetReadableBones() +{ + return m_ReadableBones; +} + +inline void CBoneAccessor::SetReadableBones(int flags) +{ + m_ReadableBones = flags; +} + +inline int CBoneAccessor::GetWritableBones() +{ + return m_WritableBones; +} + +inline void CBoneAccessor::SetWritableBones(int flags) +{ + m_WritableBones = flags; +} + +inline const matrix3x4_t& CBoneAccessor::GetBone(int iBone) const +{ +#if defined( CLIENT_DLL ) && defined( _DEBUG ) + SanityCheckBone(iBone, true); +#endif + return m_pBones[iBone]; +} + +inline const matrix3x4_t& CBoneAccessor::operator[](int iBone) const +{ +#if defined( CLIENT_DLL ) && defined( _DEBUG ) + SanityCheckBone(iBone, true); +#endif + return m_pBones[iBone]; +} + +inline matrix3x4_t& CBoneAccessor::GetBoneForWrite(int iBone) +{ +#if defined( CLIENT_DLL ) && defined( _DEBUG ) + SanityCheckBone(iBone, false); +#endif + return m_pBones[iBone]; +} + +inline matrix3x4_t* CBoneAccessor::GetBoneArrayForWrite(void) const +{ + return m_pBones; +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/bone_merge_cache.h b/SpyCustom/sdk/bone_merge_cache.h new file mode 100644 index 0000000..ada89ac --- /dev/null +++ b/SpyCustom/sdk/bone_merge_cache.h @@ -0,0 +1,68 @@ +#ifndef BONE_MERGE_CACHE_H +#define BONE_MERGE_CACHE_H +#ifdef _WIN32 +#pragma once +#endif + + +class C_BaseAnimating; +class CStudioHdr; + + +#include "vector.h" + + +class CBoneMergeCache +{ +public: + + CBoneMergeCache(); + + void Init(C_BaseAnimating* pOwner); + + void UpdateCache(); + + void MergeMatchingBones(int boneMask); + + void CopyParentToChild(const Vector parentPos[], const Quaternion parentQ[], Vector childPos[], Quaternion childQ[], int boneMask); + void CopyChildToParent(const Vector childPos[], const Quaternion childQ[], Vector parentPos[], Quaternion parentQ[], int boneMask); + + int IsBoneMerged(int iBone) const; + + bool GetAimEntOrigin(Vector* pAbsOrigin, QAngle* pAbsAngles); + + bool GetRootBone(matrix3x4_t& rootBone); + +private: + + C_BaseAnimating* m_pOwner; + + C_BaseAnimating* m_pFollow; + CStudioHdr* m_pFollowHdr; + const studiohdr_t* m_pFollowRenderHdr; + CStudioHdr* m_pOwnerHdr; + + int m_nFollowBoneSetupMask; + + class CMergedBone + { + public: + unsigned short m_iMyBone; + unsigned short m_iParentBone; + }; + + CUtlVector m_MergedBones; + CUtlVector m_BoneMergeBits; +}; + + +inline int CBoneMergeCache::IsBoneMerged(int iBone) const +{ + if (m_pOwnerHdr) + return m_BoneMergeBits[iBone >> 3] & (1 << (iBone & 7)); + else + return 0; +} + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/bspfile.h b/SpyCustom/sdk/bspfile.h new file mode 100644 index 0000000..246d2ce --- /dev/null +++ b/SpyCustom/sdk/bspfile.h @@ -0,0 +1,1067 @@ +#ifndef BSPFILE_H +#define BSPFILE_H +#pragma once + +#ifndef MATHLIB_H +#include "mathlib.h" +#endif + +#include "vector4d.h" +#include "datamap.h" +#include "bumpvects.h" +#include "compressed_light_cube.h" + +#define IDBSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'V') + +#define MINBSPVERSION 19 +#define BSPVERSION 21 + + +#define MAX_BRUSH_LIGHTMAP_DIM_WITHOUT_BORDER 32 +#define MAX_BRUSH_LIGHTMAP_DIM_INCLUDING_BORDER 35 + +#define MAX_DISP_LIGHTMAP_DIM_WITHOUT_BORDER 125 +#define MAX_DISP_LIGHTMAP_DIM_INCLUDING_BORDER 128 + + +#define MAX_LIGHTMAP_DIM_WITHOUT_BORDER MAX_DISP_LIGHTMAP_DIM_WITHOUT_BORDER +#define MAX_LIGHTMAP_DIM_INCLUDING_BORDER MAX_DISP_LIGHTMAP_DIM_INCLUDING_BORDER + +#define MAX_LIGHTSTYLES 64 + + +#define MIN_MAP_DISP_POWER 2 +#define MAX_MAP_DISP_POWER 4 + +#define MAX_DISP_CORNER_NEIGHBORS 4 + +#define NUM_DISP_POWER_VERTS(power) ( ((1 << (power)) + 1) * ((1 << (power)) + 1) ) +#define NUM_DISP_POWER_TRIS(power) ( (1 << (power)) * (1 << (power)) * 2 ) + +#if !defined( BSP_USE_LESS_MEMORY ) +#define MAX_MAP_MODELS 1024 +#define MAX_MAP_BRUSHES 8192 +#define MAX_MAP_ENTITIES 16384 +#define MAX_MAP_TEXINFO 12288 +#define MAX_MAP_TEXDATA 2048 +#define MAX_MAP_DISPINFO 2048 +#define MAX_MAP_DISP_VERTS ( MAX_MAP_DISPINFO * ((1<> (16 - OVERLAY_RENDER_ORDER_NUM_BITS)); +} + + +struct doverlayfade_t +{ + DECLARE_BYTESWAP_DATADESC(); + + float flFadeDistMinSq; + float flFadeDistMaxSq; +}; + + +struct doverlaysystemlevel_t +{ + DECLARE_BYTESWAP_DATADESC(); + + unsigned char nMinCPULevel; + unsigned char nMaxCPULevel; + unsigned char nMinGPULevel; + unsigned char nMaxGPULevel; +}; + + +#define WATEROVERLAY_BSP_FACE_COUNT 256 +#define WATEROVERLAY_RENDER_ORDER_NUM_BITS 2 +#define WATEROVERLAY_NUM_RENDER_ORDERS (1<> (16 - WATEROVERLAY_RENDER_ORDER_NUM_BITS)); +} + +#ifndef _DEF_BYTE_ +#define _DEF_BYTE_ +typedef unsigned char byte; +typedef unsigned short word; +#endif + + +#define ANGLE_UP -1 +#define ANGLE_DOWN -2 + + + +struct epair_t +{ + epair_t* next; + char* key; + char* value; +}; + +#define MAX_LIGHTMAPPAGE_WIDTH 256 +#define MAX_LIGHTMAPPAGE_HEIGHT 128 +typedef struct nameForDatadesc_dlightmappage_t +{ + DECLARE_BYTESWAP_DATADESC(); + byte data[MAX_LIGHTMAPPAGE_WIDTH * MAX_LIGHTMAPPAGE_HEIGHT]; + byte palette[256 * 4]; +} dlightmappage_t; + +typedef struct nameForDatadesc_dlightmappageinfo_t +{ + DECLARE_BYTESWAP_DATADESC(); + byte page; + byte offset[2]; + byte pad; + ColorRGBExp32 avgColor; +} dlightmappageinfo_t; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/bspflags.h b/SpyCustom/sdk/bspflags.h new file mode 100644 index 0000000..472c314 --- /dev/null +++ b/SpyCustom/sdk/bspflags.h @@ -0,0 +1,101 @@ +#ifndef BSPFLAGS_H +#define BSPFLAGS_H + +#ifdef _WIN32 +#pragma once +#endif + +#define CONTENTS_EMPTY 0 + +#define CONTENTS_SOLID 0x1 +#define CONTENTS_WINDOW 0x2 +#define CONTENTS_AUX 0x4 +#define CONTENTS_GRATE 0x8 +#define CONTENTS_SLIME 0x10 +#define CONTENTS_WATER 0x20 +#define CONTENTS_BLOCKLOS 0x40 +#define CONTENTS_OPAQUE 0x80 +#define LAST_VISIBLE_CONTENTS 0x80 + +#define ALL_VISIBLE_CONTENTS (LAST_VISIBLE_CONTENTS | (LAST_VISIBLE_CONTENTS-1)) + +#define CONTENTS_TESTFOGVOLUME 0x100 +#define CONTENTS_UNUSED 0x200 + +#define CONTENTS_UNUSED6 0x400 + +#define CONTENTS_TEAM1 0x800 +#define CONTENTS_TEAM2 0x1000 + +#define CONTENTS_IGNORE_NODRAW_OPAQUE 0x2000 + +#define CONTENTS_MOVEABLE 0x4000 + +#define CONTENTS_AREAPORTAL 0x8000 + +#define CONTENTS_PLAYERCLIP 0x10000 +#define CONTENTS_MONSTERCLIP 0x20000 + +#define CONTENTS_CURRENT_0 0x40000 +#define CONTENTS_CURRENT_90 0x80000 +#define CONTENTS_CURRENT_180 0x100000 +#define CONTENTS_CURRENT_270 0x200000 +#define CONTENTS_CURRENT_UP 0x400000 +#define CONTENTS_CURRENT_DOWN 0x800000 + +#define CONTENTS_ORIGIN 0x1000000 + +#define CONTENTS_MONSTER 0x2000000 +#define CONTENTS_DEBRIS 0x4000000 +#define CONTENTS_DETAIL 0x8000000 +#define CONTENTS_TRANSLUCENT 0x10000000 +#define CONTENTS_LADDER 0x20000000 +#define CONTENTS_HITBOX 0x40000000 + + +#define SURF_LIGHT 0x0001 +#define SURF_SKY2D 0x0002 +#define SURF_SKY 0x0004 +#define SURF_WARP 0x0008 +#define SURF_TRANS 0x0010 +#define SURF_NOPORTAL 0x0020 +#define SURF_TRIGGER 0x0040 +#define SURF_NODRAW 0x0080 + +#define SURF_HINT 0x0100 + +#define SURF_SKIP 0x0200 +#define SURF_NOLIGHT 0x0400 +#define SURF_BUMPLIGHT 0x0800 +#define SURF_NOSHADOWS 0x1000 +#define SURF_NODECALS 0x2000 +#define SURF_NOCHOP 0x4000 +#define SURF_HITBOX 0x8000 + + + +#define MASK_ALL (0xFFFFFFFF) +#define MASK_SOLID (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) +#define MASK_PLAYERSOLID (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) +#define MASK_NPCSOLID (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER|CONTENTS_GRATE) +#define MASK_WATER (CONTENTS_WATER|CONTENTS_MOVEABLE|CONTENTS_SLIME) +#define MASK_OPAQUE (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_OPAQUE) +#define MASK_OPAQUE_AND_NPCS (MASK_OPAQUE|CONTENTS_MONSTER) +#define MASK_BLOCKLOS (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_BLOCKLOS) +#define MASK_BLOCKLOS_AND_NPCS (MASK_BLOCKLOS|CONTENTS_MONSTER) +#define MASK_VISIBLE (MASK_OPAQUE|CONTENTS_IGNORE_NODRAW_OPAQUE) +#define MASK_VISIBLE_AND_NPCS (MASK_OPAQUE_AND_NPCS|CONTENTS_IGNORE_NODRAW_OPAQUE) +#define MASK_SHOT (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_HITBOX) +#define MASK_SHOT_HULL (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEBRIS|CONTENTS_GRATE) +#define MASK_SHOT_PORTAL (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTER) +#define MASK_SOLID_BRUSHONLY (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_GRATE) +#define MASK_PLAYERSOLID_BRUSHONLY (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_PLAYERCLIP|CONTENTS_GRATE) +#define MASK_NPCSOLID_BRUSHONLY (CONTENTS_SOLID|CONTENTS_MOVEABLE|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE) +#define MASK_NPCWORLDSTATIC (CONTENTS_SOLID|CONTENTS_WINDOW|CONTENTS_MONSTERCLIP|CONTENTS_GRATE) +#define MASK_SPLITAREAPORTAL (CONTENTS_WATER|CONTENTS_SLIME) + +#define MASK_CURRENT (CONTENTS_CURRENT_0|CONTENTS_CURRENT_90|CONTENTS_CURRENT_180|CONTENTS_CURRENT_270|CONTENTS_CURRENT_UP|CONTENTS_CURRENT_DOWN) + +#define MASK_DEADSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_GRATE) + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/bumpvects.h b/SpyCustom/sdk/bumpvects.h new file mode 100644 index 0000000..0dd7d9c --- /dev/null +++ b/SpyCustom/sdk/bumpvects.h @@ -0,0 +1,27 @@ +#ifndef BUMPVECTS_H +#define BUMPVECTS_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "mathlib.h" + +#define OO_SQRT_2 0.70710676908493042f +#define OO_SQRT_3 0.57735025882720947f +#define OO_SQRT_6 0.40824821591377258f +#define OO_SQRT_2_OVER_3 0.81649661064147949f + +#define NUM_BUMP_VECTS 3 + +const TableVector g_localBumpBasis[NUM_BUMP_VECTS] = +{ + { OO_SQRT_2_OVER_3, 0.0f, OO_SQRT_3 }, + { -OO_SQRT_6, OO_SQRT_2, OO_SQRT_3 }, + { -OO_SQRT_6, -OO_SQRT_2, OO_SQRT_3 } +}; + +void GetBumpNormals(const Vector& sVect, const Vector& tVect, const Vector& flatNormal, + const Vector& phongNormal, Vector bumpNormals[NUM_BUMP_VECTS]); + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/byteswap.h b/SpyCustom/sdk/byteswap.h new file mode 100644 index 0000000..c588ed1 --- /dev/null +++ b/SpyCustom/sdk/byteswap.h @@ -0,0 +1,170 @@ +#ifndef BYTESWAP_H +#define BYTESWAP_H +#if defined(_WIN32) +#pragma once +#endif + +#include "datamap.h" + +class CByteswap +{ +public: + CByteswap() + { + SetTargetBigEndian(IsMachineBigEndian()); + } + + void SwapFieldToTargetEndian(void* pOutputBuffer, void* pData, typedescription_t* pField); + + void SwapFieldsToTargetEndian(void* pOutputBuffer, void* pBaseData, datamap_t* pDataMap); + + template inline void SwapFieldsToTargetEndian(T* pOutputBuffer, void* pBaseData, unsigned int objectCount = 1) + { + for (unsigned int i = 0; i < objectCount; ++i, ++pOutputBuffer) + { + SwapFieldsToTargetEndian((void*)pOutputBuffer, pBaseData, &T::m_DataMap); + pBaseData = (byte*)pBaseData + sizeof(T); + } + } + + template inline void SwapFieldsToTargetEndian(T* pOutputBuffer, unsigned int objectCount = 1) + { + SwapFieldsToTargetEndian(pOutputBuffer, (void*)pOutputBuffer, objectCount); + } + + static bool IsMachineBigEndian() + { + short nIsBigEndian = 1; + + return (bool)(0 == *(char*)&nIsBigEndian); + } + + inline void SetTargetBigEndian(bool bigEndian) + { + m_bBigEndian = bigEndian; + m_bSwapBytes = IsMachineBigEndian() != bigEndian; + } + + inline void FlipTargetEndian(void) + { + m_bSwapBytes = !m_bSwapBytes; + m_bBigEndian = !m_bBigEndian; + } + + inline void ActivateByteSwapping(bool bActivate) + { + SetTargetBigEndian(IsMachineBigEndian() != bActivate); + } + + inline bool IsSwappingBytes(void) + { + return m_bSwapBytes; + } + + inline bool IsTargetBigEndian(void) + { + return m_bBigEndian; + } + + template inline int SourceIsNativeEndian(T input, T nativeConstant) + { + if (input == nativeConstant) + return 1; + + int output; + LowLevelByteSwap(&output, &input); + if (output == nativeConstant) + return 0; + + assert(0); + return -1; + } + + template inline void SwapBuffer(T* outputBuffer, T* inputBuffer = NULL, int count = 1) + { + assert(count >= 0); + assert(outputBuffer); + + if (count <= 0 || !outputBuffer) + return; + + if (inputBuffer == NULL) + { + inputBuffer = outputBuffer; + } + + for (int i = 0; i < count; i++) + { + LowLevelByteSwap(&outputBuffer[i], &inputBuffer[i]); + } + } + + template inline void SwapBufferToTargetEndian(T* outputBuffer, T* inputBuffer = NULL, int count = 1) + { + assert(count >= 0); + assert(outputBuffer); + + if (count <= 0 || !outputBuffer) + return; + + if (inputBuffer == NULL) + { + inputBuffer = outputBuffer; + } + + if (!m_bSwapBytes || (sizeof(T) == 1)) + { + if (!inputBuffer) + return; + + memcpy(outputBuffer, inputBuffer, count * sizeof(T)); + return; + + } + + for (int i = 0; i < count; i++) + { + LowLevelByteSwap(&outputBuffer[i], &inputBuffer[i]); + } + } + +private: + template static void LowLevelByteSwap(T* output, T* input) + { + T temp = *output; +#if defined( _X360 ) + DWORD* word = (DWORD*)input; + switch (sizeof(T)) + { + case 8: + { + __storewordbytereverse(*word, 0, &temp); + __storewordbytereverse(*(word + 1), 4, &temp); + } + break; + + case 4: + __storewordbytereverse(*word, 0, &temp); + break; + + case 2: + __storeshortbytereverse(*input, 0, &temp); + break; + + default: + Assert("Invalid size in CByteswap::LowLevelByteSwap" && 0); + } +#else + for (int i = 0; i < sizeof(T); i++) + { + ((unsigned char*)&temp)[i] = ((unsigned char*)input)[sizeof(T) - (i + 1)]; + } +#endif + Q_memcpy(output, &temp, sizeof(T)); + } + + unsigned int m_bSwapBytes : 1; + unsigned int m_bBigEndian : 1; +}; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/c_baseanimating.h b/SpyCustom/sdk/c_baseanimating.h new file mode 100644 index 0000000..f7cdc27 --- /dev/null +++ b/SpyCustom/sdk/c_baseanimating.h @@ -0,0 +1,696 @@ +#ifndef C_BASEANIMATING_H +#define C_BASEANIMATING_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "c_baseentity.h" +#include "studio.h" +#include "utlvector.h" +#include "ragdoll.h" +#include "mouthinfo.h" +#include "ai_activity.h" +#include "animationlayer.h" +#include "sequence_Transitioner.h" +#include "bone_accessor.h" +#include "bone_merge_cache.h" +#include "ragdoll_shared.h" +#include "threadtools.h" +#include "idatacache.h" + +#include "baseentity_shared.h" + +#define LIPSYNC_POSEPARAM_NAME "mouth" +#define NUM_HITBOX_FIRES 10 + +class IRagdoll; +class CIKContext; +class CIKState; +class ConVar; +class C_RopeKeyframe; +class CBoneBitList; +class CBoneList; +class KeyValues; +class CJiggleBones; +class IBoneSetup; +FORWARD_DECLARE_HANDLE(memhandle_t); +typedef unsigned short MDLHandle_t; + +extern ConVar vcollide_wireframe; + + +struct ClientModelRenderInfo_t : public ModelRenderInfo_t +{ + matrix3x4_t lightingOffset; + + matrix3x4_t modelToWorld; +}; + +struct RagdollInfo_t +{ + bool m_bActive; + float m_flSaveTime; + int m_nNumBones; + Vector m_rgBonePos[MAXSTUDIOBONES]; + Quaternion m_rgBoneQuaternion[MAXSTUDIOBONES]; +}; + + +class CAttachmentData +{ +public: + matrix3x4_t m_AttachmentToWorld; + QAngle m_angRotation; + Vector m_vOriginVelocity; + int m_nLastFramecount : 31; + int m_bAnglesComputed : 1; +}; + + +typedef unsigned int ClientSideAnimationListHandle_t; + +#define INVALID_CLIENTSIDEANIMATION_LIST_HANDLE (ClientSideAnimationListHandle_t)~0 + + +class C_BaseAnimating : public C_BaseEntity, private IModelLoadCallback +{ +public: + DECLARE_CLASS(C_BaseAnimating, C_BaseEntity); + DECLARE_CLIENTCLASS(); + DECLARE_PREDICTABLE(); + DECLARE_INTERPOLATION(); + + enum + { + NUM_POSEPAREMETERS = 24, + NUM_BONECTRLS = 4 + }; + + C_BaseAnimating(); + ~C_BaseAnimating(); + + virtual C_BaseAnimating* GetBaseAnimating() { return this; } + + bool UsesPowerOfTwoFrameBufferTexture(void); + + virtual bool Interpolate(float currentTime); + virtual void Simulate(); + virtual void Release(); + + float GetAnimTimeInterval(void) const; + + virtual unsigned char GetClientSideFade(void); + + virtual void GetBoneControllers(float controllers[MAXSTUDIOBONECTRLS]); + virtual float SetBoneController(int iController, float flValue); + + LocalFlexController_t GetNumFlexControllers(void); + const char* GetFlexDescFacs(int iFlexDesc); + const char* GetFlexControllerName(LocalFlexController_t iFlexController); + const char* GetFlexControllerType(LocalFlexController_t iFlexController); + + virtual void GetAimEntOrigin(IClientEntity* pAttachedTo, Vector* pAbsOrigin, QAngle* pAbsAngles); + + bool ComputeHitboxSurroundingBox(Vector* pVecWorldMins, Vector* pVecWorldMaxs); + bool ComputeEntitySpaceHitboxSurroundingBox(Vector* pVecWorldMins, Vector* pVecWorldMaxs); + + bool HitboxToWorldTransforms(matrix3x4_t* pHitboxToWorld[MAXSTUDIOBONES]); + + float ClampCycle(float cycle, bool isLooping); + virtual void GetPoseParameters(CStudioHdr* pStudioHdr, float poseParameter[MAXSTUDIOPOSEPARAM]); + virtual void BuildTransformations(CStudioHdr* pStudioHdr, Vector* pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList& boneComputed); + virtual void ApplyBoneMatrixTransform(matrix3x4_t& transform); + virtual int VPhysicsGetObjectList(IPhysicsObject** pList, int listMax); + + virtual bool SetupBones(matrix3x4_t* pBoneToWorldOut, int nMaxBones, int boneMask, float currentTime); + virtual void UpdateIKLocks(float currentTime); + virtual void CalculateIKLocks(float currentTime); + virtual bool ShouldDraw(); + virtual int DrawModel(int flags); + virtual int InternalDrawModel(int flags); + virtual bool OnInternalDrawModel(ClientModelRenderInfo_t* pInfo); + virtual bool OnPostInternalDrawModel(ClientModelRenderInfo_t* pInfo); + void DoInternalDrawModel(ClientModelRenderInfo_t* pInfo, DrawModelState_t* pState, matrix3x4_t* pBoneToWorldArray = NULL); + + virtual CMouthInfo* GetMouth(); + virtual void ControlMouth(CStudioHdr* pStudioHdr); + + virtual void DoAnimationEvents(CStudioHdr* pStudio); + virtual void FireEvent(const Vector& origin, const QAngle& angles, int event, const char* options); + virtual void FireObsoleteEvent(const Vector& origin, const QAngle& angles, int event, const char* options); + virtual const char* ModifyEventParticles(const char* token) { return token; } + + virtual bool DispatchMuzzleEffect(const char* options, bool isFirstPerson); + + virtual void ValidateModelIndex(void); + virtual CStudioHdr* OnNewModel(void); + CStudioHdr* GetModelPtr() const; + void InvalidateMdlCache(); + + virtual void SetPredictable(bool state); + void UseClientSideAnimation(); + + virtual void StandardBlendingRules(CStudioHdr* pStudioHdr, Vector pos[], Quaternion q[], float currentTime, int boneMask); + void UnragdollBlend(CStudioHdr* hdr, Vector pos[], Quaternion q[], float currentTime); + + void MaintainSequenceTransitions(IBoneSetup& boneSetup, float flCycle, Vector pos[], Quaternion q[]); + virtual void AccumulateLayers(IBoneSetup& boneSetup, Vector pos[], Quaternion q[], float currentTime); + + virtual void ChildLayerBlend(Vector pos[], Quaternion q[], float currentTime, int boneMask); + + int LookupAttachment(const char* pAttachmentName); + int LookupRandomAttachment(const char* pAttachmentNameSubstring); + + int LookupPoseParameter(CStudioHdr* pStudioHdr, const char* szName); + inline int LookupPoseParameter(const char* szName) { return LookupPoseParameter(GetModelPtr(), szName); } + + float SetPoseParameter(CStudioHdr* pStudioHdr, const char* szName, float flValue); + inline float SetPoseParameter(const char* szName, float flValue) { return SetPoseParameter(GetModelPtr(), szName, flValue); } + float SetPoseParameter(CStudioHdr* pStudioHdr, int iParameter, float flValue); + inline float SetPoseParameter(int iParameter, float flValue) { return SetPoseParameter(GetModelPtr(), iParameter, flValue); } + + float GetPoseParameter(int iPoseParameter); + + bool GetPoseParameterRange(int iPoseParameter, float& minValue, float& maxValue); + + int LookupBone(const char* szName); + void GetBonePosition(int iBone, Vector& origin, QAngle& angles); + void GetBoneTransform(int iBone, matrix3x4_t& pBoneToWorld); + + int GetHitboxBone(int hitboxIndex); + + virtual void AttachEntityToBone(C_BaseAnimating* attachTarget, int boneIndexAttached = -1, Vector bonePosition = Vector(0, 0, 0), QAngle boneAngles = QAngle(0, 0, 0)); + void AddBoneAttachment(C_BaseAnimating* newBoneAttachment); + void RemoveBoneAttachment(C_BaseAnimating* boneAttachment); + void RemoveBoneAttachments(); + void DestroyBoneAttachments(); + void MoveBoneAttachments(C_BaseAnimating* attachTarget); + int GetNumBoneAttachments(); + C_BaseAnimating* GetBoneAttachment(int i); + virtual void NotifyBoneAttached(C_BaseAnimating* attachTarget); + virtual void UpdateBoneAttachments(void); + + virtual void PreDataUpdate(DataUpdateType_t updateType); + virtual void PostDataUpdate(DataUpdateType_t updateType); + virtual int RestoreData(const char* context, int slot, int type); + + virtual void NotifyShouldTransmit(ShouldTransmitState_t state); + virtual void OnPreDataChanged(DataUpdateType_t updateType); + virtual void OnDataChanged(DataUpdateType_t updateType); + virtual void AddEntity(void); + + void ForceClientSideAnimationOn(); + + void AddToClientSideAnimationList(); + void RemoveFromClientSideAnimationList(); + + virtual bool IsSelfAnimating(); + virtual void ResetLatched(); + + virtual void GetRenderBounds(Vector& theMins, Vector& theMaxs); + virtual const Vector& GetRenderOrigin(void); + virtual const QAngle& GetRenderAngles(void); + + virtual bool GetSoundSpatialization(SpatializationInfo_t& info); + + bool GetAttachment(const char* szName, Vector& absOrigin); + bool GetAttachment(const char* szName, Vector& absOrigin, QAngle& absAngles); + + virtual bool GetAttachment(int number, Vector& origin); + virtual bool GetAttachment(int number, Vector& origin, QAngle& angles); + virtual bool GetAttachment(int number, matrix3x4_t& matrix); + virtual bool GetAttachmentVelocity(int number, Vector& originVel, Quaternion& angleVel); + + bool GetAttachmentLocal(int iAttachment, matrix3x4_t& attachmentToLocal); + bool GetAttachmentLocal(int iAttachment, Vector& origin, QAngle& angles); + bool GetAttachmentLocal(int iAttachment, Vector& origin); + + bool GetRootBone(matrix3x4_t& rootBone); + + virtual ShadowType_t ShadowCastType(); + + virtual CollideType_t GetCollideType(void); + + virtual bool TestCollision(const Ray_t& ray, unsigned int fContentsMask, trace_t& tr); + virtual bool TestHitboxes(const Ray_t& ray, unsigned int fContentsMask, trace_t& tr); + + bool IsRagdoll() const; + bool IsAboutToRagdoll() const; + virtual C_BaseAnimating* BecomeRagdollOnClient(); + C_BaseAnimating* CreateRagdollCopy(); + bool InitAsClientRagdoll(const matrix3x4_t* pDeltaBones0, const matrix3x4_t* pDeltaBones1, const matrix3x4_t* pCurrentBonePosition, float boneDt, bool bFixedConstraints = false); + void IgniteRagdoll(C_BaseAnimating* pSource); + void TransferDissolveFrom(C_BaseAnimating* pSource); + virtual void SaveRagdollInfo(int numbones, const matrix3x4_t& cameraTransform, CBoneAccessor& pBoneToWorld); + virtual bool RetrieveRagdollInfo(Vector* pos, Quaternion* q); + virtual void Clear(void); + void ClearRagdoll(); + void CreateUnragdollInfo(C_BaseAnimating* pRagdoll); + void ForceSetupBonesAtTime(matrix3x4_t* pBonesOut, float flTime); + virtual void GetRagdollInitBoneArrays(matrix3x4_t* pDeltaBones0, matrix3x4_t* pDeltaBones1, matrix3x4_t* pCurrentBones, float boneDt); + + virtual int GetBody() { return m_nBody; } + virtual int GetSkin() { return m_nSkin; } + + bool IsOnFire() { return ((GetFlags() & FL_ONFIRE) != 0); } + + inline float GetPlaybackRate(); + inline void SetPlaybackRate(float rate); + + void SetModelScale(float scale, float change_duration = 0.0f); + float GetModelScale() const { return m_flModelScale; } + inline bool IsModelScaleFractional() const; + inline bool IsModelScaled() const; + void UpdateModelScale(void); + virtual void RefreshCollisionBounds(void); + + int GetSequence(); + virtual void SetSequence(int nSequence); + inline void ResetSequence(int nSequence); + float GetSequenceGroundSpeed(CStudioHdr* pStudioHdr, int iSequence); + inline float GetSequenceGroundSpeed(int iSequence) { return GetSequenceGroundSpeed(GetModelPtr(), iSequence); } + bool IsSequenceLooping(CStudioHdr* pStudioHdr, int iSequence); + inline bool IsSequenceLooping(int iSequence) { return IsSequenceLooping(GetModelPtr(), iSequence); } + float GetSequenceMoveDist(CStudioHdr* pStudioHdr, int iSequence); + void GetSequenceLinearMotion(int iSequence, Vector* pVec); + void GetBlendedLinearVelocity(Vector* pVec); + int LookupSequence(const char* label); + int LookupActivity(const char* label); + char const* GetSequenceName(int iSequence); + char const* GetSequenceActivityName(int iSequence); + Activity GetSequenceActivity(int iSequence); + KeyValues* GetSequenceKeyValues(int iSequence); + virtual void StudioFrameAdvance(); + + virtual float FrameAdvance(float flInterval = 0.0f); + virtual float GetSequenceCycleRate(CStudioHdr* pStudioHdr, int iSequence); + virtual void UpdateClientSideAnimation(); + void ClientSideAnimationChanged(); + virtual unsigned int ComputeClientSideAnimationFlags(); + + virtual void ResetClientsideFrame(void) { SetCycle(0); } + + void SetCycle(float flCycle); + float GetCycle() const; + + void SetBodygroup(int iGroup, int iValue); + int GetBodygroup(int iGroup); + + const char* GetBodygroupName(int iGroup); + int FindBodygroupByName(const char* name); + int GetBodygroupCount(int iGroup); + int GetNumBodyGroups(void); + + class CBoneCache* GetBoneCache(CStudioHdr* pStudioHdr); + void SetHitboxSet(int setnum); + void SetHitboxSetByName(const char* setname); + int GetHitboxSet(void); + char const* GetHitboxSetName(void); + int GetHitboxSetCount(void); + void DrawClientHitboxes(float duration = 0.0f, bool monocolor = false); + + C_BaseAnimating* FindFollowedEntity(); + + virtual bool IsActivityFinished(void) { return m_bSequenceFinished; } + inline bool IsSequenceFinished(void); + inline bool SequenceLoops(void) { return m_bSequenceLoops; } + + virtual void UncorrectViewModelAttachment(Vector& vOrigin) {} + + void InvalidateBoneCache(); + bool IsBoneCacheValid() const; + void GetCachedBoneMatrix(int boneIndex, matrix3x4_t& out); + + const matrix3x4_t& GetBone(int iBone) const; + matrix3x4_t& GetBoneForWrite(int iBone); + + struct AutoAllowBoneAccess + { + AutoAllowBoneAccess(bool bAllowForNormalModels, bool bAllowForViewModels); + ~AutoAllowBoneAccess(void); + }; + static void PushAllowBoneAccess(bool bAllowForNormalModels, bool bAllowForViewModels, char const* tagPush); + static void PopBoneAccess(char const* tagPop); + static void ThreadedBoneSetup(); + static void InitBoneSetupThreadPool(); + static void ShutdownBoneSetupThreadPool(); + + static void InvalidateBoneCaches(); + + virtual void VPhysicsUpdate(IPhysicsObject* pPhysics); + + void DisableMuzzleFlash(); + virtual void DoMuzzleFlash(); + bool ShouldMuzzleFlash() const; + + virtual void ProcessMuzzleFlashEvent(); + + static void UpdateClientSideAnimations(); + + void InitModelEffects(void); + + virtual void SetServerIntendedCycle(float intended) { (void)intended; } + virtual float GetServerIntendedCycle(void) { return -1.0f; } + + int SelectWeightedSequence(int activity); + void ResetSequenceInfo(void); + float SequenceDuration(void); + float SequenceDuration(CStudioHdr* pStudioHdr, int iSequence); + inline float SequenceDuration(int iSequence) { return SequenceDuration(GetModelPtr(), iSequence); } + int FindTransitionSequence(int iCurrentSequence, int iGoalSequence, int* piDir); + + void RagdollMoved(void); + + virtual void GetToolRecordingState(KeyValues* msg); + virtual void CleanupToolRecordingState(KeyValues* msg); + + void SetReceivedSequence(void); + virtual bool ShouldResetSequenceOnNewModel(void); + + virtual bool IsViewModel() const; + +protected: + virtual void FormatViewModelAttachment(int nAttachment, matrix3x4_t& attachmentToWorld) {} + + bool IsBoneAccessAllowed() const; + CMouthInfo& MouthInfo(); + + virtual bool IsMenuModel() const; + + virtual int GetStudioBody(void) { return m_nBody; } + + virtual bool CalcAttachments(); + +private: + virtual float LastBoneChangedTime() { return FLT_MAX; } + + CBoneList* RecordBones(CStudioHdr* hdr, matrix3x4_t* pBoneState); + + bool PutAttachment(int number, const matrix3x4_t& attachmentToWorld); + void TermRopes(); + + void DelayedInitModelEffects(void); + + void UpdateRelevantInterpolatedVars(); + void AddBaseAnimatingInterpolatedVars(); + void RemoveBaseAnimatingInterpolatedVars(); + +public: + CRagdoll* m_pRagdoll; + + int m_nSkin; + + int m_nBody; + + int m_nHitboxSet; + + CSequenceTransitioner m_SequenceTransitioner; + +protected: + CIKContext* m_pIk; + + int m_iEyeAttachment; + + float m_flPlaybackRate; + + bool m_bStoreRagdollInfo; + RagdollInfo_t* m_pRagdollInfo; + Vector m_vecForce; + int m_nForceBone; + + unsigned long m_iMostRecentModelBoneCounter; + unsigned long m_iMostRecentBoneSetupRequest; + int m_iPrevBoneMask; + int m_iAccumulatedBoneMask; + + CBoneAccessor m_BoneAccessor; + CThreadFastMutex m_BoneSetupLock; + + ClientSideAnimationListHandle_t m_ClientSideAnimationListHandle; + + bool m_bClientSideFrameReset; + + CUtlVector > m_BoneAttachments; + int m_boneIndexAttached; + Vector m_bonePosition; + QAngle m_boneAngles; + CHandle m_pAttachedTo; + +protected: + + float m_fadeMinDist; + float m_fadeMaxDist; + float m_flFadeScale; + +private: + + float m_flGroundSpeed; + float m_flLastEventCheck; + bool m_bSequenceFinished; + bool m_bSequenceLoops; + + CMouthInfo m_mouth; + + CNetworkVar(float, m_flModelScale); + + float m_flPoseParameter[MAXSTUDIOPOSEPARAM]; + CInterpolatedVarArray< float, MAXSTUDIOPOSEPARAM > m_iv_flPoseParameter; + float m_flOldPoseParameters[MAXSTUDIOPOSEPARAM]; + + int m_nPrevSequence; + int m_nRestoreSequence; + + CUtlLinkedList m_Ropes; + + float m_flPrevEventCycle; + int m_nEventSequence; + + float m_flEncodedController[MAXSTUDIOBONECTRLS]; + CInterpolatedVarArray< float, MAXSTUDIOBONECTRLS > m_iv_flEncodedController; + float m_flOldEncodedController[MAXSTUDIOBONECTRLS]; + + bool m_bClientSideAnimation; + bool m_bLastClientSideFrameReset; + + int m_nNewSequenceParity; + int m_nResetEventsParity; + + int m_nPrevNewSequenceParity; + int m_nPrevResetEventsParity; + + bool m_builtRagdoll; + Vector m_vecPreRagdollMins; + Vector m_vecPreRagdollMaxs; + + int m_nSequence; + bool m_bReceivedSequence; + +protected: + float m_flCycle; + CInterpolatedVar< float > m_iv_flCycle; + float m_flOldCycle; + bool m_bNoModelParticles; + +private: + float m_flOldModelScale; + int m_nOldSequence; + CBoneMergeCache* m_pBoneMergeCache; + CUtlVector< matrix3x4_t > m_CachedBoneData; + memhandle_t m_hitboxBoneCacheHandle; + float m_flLastBoneSetupTime; + CJiggleBones* m_pJiggleBones; + + CUtlVector m_Attachments; + + void SetupBones_AttachmentHelper(CStudioHdr* pStudioHdr); + + EHANDLE m_hLightingOrigin; + EHANDLE m_hLightingOriginRelative; + + CNetworkVar(unsigned char, m_nMuzzleFlashParity); + unsigned char m_nOldMuzzleFlashParity; + + bool m_bInitModelEffects; + + bool m_bDynamicModelAllowed; + bool m_bDynamicModelPending; + bool m_bResetSequenceInfoOnLoad; + CRefCountedModelIndex m_AutoRefModelIndex; +public: + void EnableDynamicModels() { m_bDynamicModelAllowed = true; } + bool IsDynamicModelLoading() const { return m_bDynamicModelPending; } +private: + virtual void OnModelLoadComplete(const model_t* pModel); + +private: + void LockStudioHdr(); + void UnlockStudioHdr(); + mutable CStudioHdr* m_pStudioHdr; + mutable MDLHandle_t m_hStudioHdr; + CThreadFastMutex m_StudioHdrInitLock; +}; + +enum +{ + RAGDOLL_FRICTION_OFF = -2, + RAGDOLL_FRICTION_NONE, + RAGDOLL_FRICTION_IN, + RAGDOLL_FRICTION_HOLD, + RAGDOLL_FRICTION_OUT, +}; + +class C_ClientRagdoll : public C_BaseAnimating, public IPVSNotify +{ + +public: + C_ClientRagdoll(bool bRestoring = true); + DECLARE_CLASS(C_ClientRagdoll, C_BaseAnimating); + DECLARE_DATADESC(); + + virtual void OnPVSStatusChanged(bool bInPVS); + + virtual void Release(void); + virtual void SetupWeights(const matrix3x4_t* pBoneToWorld, int nFlexWeightCount, float* pFlexWeights, float* pFlexDelayedWeights); + virtual void ImpactTrace(trace_t* pTrace, int iDamageType, const char* pCustomImpactName); + void ClientThink(void); + void ReleaseRagdoll(void) { m_bReleaseRagdoll = true; } + bool ShouldSavePhysics(void) { return true; } + virtual void OnSave(); + virtual void OnRestore(); + virtual int ObjectCaps(void) { return BaseClass::ObjectCaps() | FCAP_SAVE_NON_NETWORKABLE; } + virtual IPVSNotify* GetPVSNotifyInterface() { return this; } + + void HandleAnimatedFriction(void); + virtual void SUB_Remove(void); + + void FadeOut(void); + virtual float LastBoneChangedTime(); + + bool m_bFadeOut; + bool m_bImportant; + float m_flEffectTime; + +private: + int m_iCurrentFriction; + int m_iMinFriction; + int m_iMaxFriction; + float m_flFrictionModTime; + float m_flFrictionTime; + + int m_iFrictionAnimState; + bool m_bReleaseRagdoll; + + bool m_bFadingOut; + + float m_flScaleEnd[NUM_HITBOX_FIRES]; + float m_flScaleTimeStart[NUM_HITBOX_FIRES]; + float m_flScaleTimeEnd[NUM_HITBOX_FIRES]; +}; + +inline void C_BaseAnimating::ResetSequence(int nSequence) +{ + SetSequence(nSequence); + ResetSequenceInfo(); +} + +inline float C_BaseAnimating::GetPlaybackRate() +{ + return m_flPlaybackRate; +} + +inline void C_BaseAnimating::SetPlaybackRate(float rate) +{ + m_flPlaybackRate = rate; +} + +inline const matrix3x4_t& C_BaseAnimating::GetBone(int iBone) const +{ + return m_BoneAccessor.GetBone(iBone); +} + +inline matrix3x4_t& C_BaseAnimating::GetBoneForWrite(int iBone) +{ + return m_BoneAccessor.GetBoneForWrite(iBone); +} + + +inline bool C_BaseAnimating::ShouldMuzzleFlash() const +{ + return m_nOldMuzzleFlashParity != m_nMuzzleFlashParity; +} + +inline float C_BaseAnimating::GetCycle() const +{ + return m_flCycle; +} + +inline CStudioHdr* C_BaseAnimating::GetModelPtr() const +{ + if (IsDynamicModelLoading()) + return NULL; + +#ifdef _DEBUG +#endif + if (!m_pStudioHdr) + { + const_cast(this)->LockStudioHdr(); + } + Assert(m_pStudioHdr ? m_pStudioHdr->GetRenderHdr() == mdlcache->GetStudioHdr(m_hStudioHdr) : m_hStudioHdr == MDLHANDLE_INVALID); + return m_pStudioHdr; +} + + +inline void C_BaseAnimating::InvalidateMdlCache() +{ + if (m_pStudioHdr) + { + UnlockStudioHdr(); + delete m_pStudioHdr; + m_pStudioHdr = NULL; + } +} + + +inline bool C_BaseAnimating::IsModelScaleFractional() const +{ + COMPILE_TIME_ASSERT(sizeof(m_flModelScale) == sizeof(int)); + return *((const int*)&m_flModelScale) < 0x3f800000; +} + +inline bool C_BaseAnimating::IsModelScaled() const +{ + return (m_flModelScale > 1.0f + FLT_EPSILON || m_flModelScale < 1.0f - FLT_EPSILON); +} + +inline int C_BaseAnimating::GetSequence() +{ + return m_nSequence; +} + +inline bool C_BaseAnimating::IsSequenceFinished(void) +{ + return m_bSequenceFinished; +} + +inline float C_BaseAnimating::SequenceDuration(void) +{ + return SequenceDuration(GetSequence()); +} + + +inline CMouthInfo& C_BaseAnimating::MouthInfo() +{ + return m_mouth; +} + + +void GetColumn(matrix3x4_t& src, int column, Vector& dest); +void SetColumn(Vector& src, int column, matrix3x4_t& dest); + +EXTERN_RECV_TABLE(DT_BaseAnimating); + + +extern void DevMsgRT(PRINTF_FORMAT_STRING char const* pMsg, ...); + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/c_baseanimatingoverlay.h b/SpyCustom/sdk/c_baseanimatingoverlay.h new file mode 100644 index 0000000..9681dc1 --- /dev/null +++ b/SpyCustom/sdk/c_baseanimatingoverlay.h @@ -0,0 +1,53 @@ +#ifndef C_BASEANIMATINGOVERLAY_H +#define C_BASEANIMATINGOVERLAY_H +#pragma once + +#include "c_baseanimating.h" + +#define CBaseAnimatingOverlay C_BaseAnimatingOverlay + + +class C_BaseAnimatingOverlay : public C_BaseAnimating +{ +public: + DECLARE_CLASS(C_BaseAnimatingOverlay, C_BaseAnimating); + DECLARE_CLIENTCLASS(); + DECLARE_PREDICTABLE(); + DECLARE_INTERPOLATION(); + + + C_BaseAnimatingOverlay(); + + virtual CStudioHdr* OnNewModel(); + + C_AnimationLayer* GetAnimOverlay(int i); + void SetNumAnimOverlays(int num); + int GetNumAnimOverlays() const; + + virtual void GetRenderBounds(Vector& theMins, Vector& theMaxs); + + void CheckForLayerChanges(CStudioHdr* hdr, float currentTime); + + virtual void AccumulateLayers(IBoneSetup& boneSetup, Vector pos[], Quaternion q[], float currentTime); + virtual void DoAnimationEvents(CStudioHdr* pStudioHdr); + + enum + { + MAX_OVERLAYS = 15, + }; + + CUtlVector < C_AnimationLayer > m_AnimOverlay; + + CUtlVector < CInterpolatedVar< C_AnimationLayer > > m_iv_AnimOverlay; + + float m_flOverlayPrevEventCycle[MAX_OVERLAYS]; + +private: + C_BaseAnimatingOverlay(const C_BaseAnimatingOverlay&); +}; + + +EXTERN_RECV_TABLE(DT_BaseAnimatingOverlay); + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/c_basecombatcharacter.h b/SpyCustom/sdk/c_basecombatcharacter.h new file mode 100644 index 0000000..56f3b8d --- /dev/null +++ b/SpyCustom/sdk/c_basecombatcharacter.h @@ -0,0 +1,168 @@ +#ifndef C_BASECOMBATCHARACTER_H +#define C_BASECOMBATCHARACTER_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "shareddefs.h" +#include "c_baseflex.h" +#ifdef GLOWS_ENABLE +#include "glow_outline_effect.h" +#endif + +class C_BaseCombatWeapon; +class C_WeaponCombatShield; + +#define BCC_DEFAULT_LOOK_TOWARDS_TOLERANCE 0.9f + +class C_BaseCombatCharacter : public C_BaseFlex +{ + DECLARE_CLASS(C_BaseCombatCharacter, C_BaseFlex); +public: + DECLARE_CLIENTCLASS(); + DECLARE_PREDICTABLE(); + + C_BaseCombatCharacter(void); + virtual ~C_BaseCombatCharacter(void); + + virtual void OnPreDataChanged(DataUpdateType_t updateType); + virtual void OnDataChanged(DataUpdateType_t updateType); + + virtual bool IsBaseCombatCharacter(void) { return true; }; + virtual C_BaseCombatCharacter* MyCombatCharacterPointer(void) { return this; } + + enum FieldOfViewCheckType { USE_FOV, DISREGARD_FOV }; + bool IsAbleToSee(const CBaseEntity* entity, FieldOfViewCheckType checkFOV); + bool IsAbleToSee(C_BaseCombatCharacter* pBCC, FieldOfViewCheckType checkFOV); + + virtual bool IsLookingTowards(const CBaseEntity* target, float cosTolerance = BCC_DEFAULT_LOOK_TOWARDS_TOLERANCE) const; + virtual bool IsLookingTowards(const Vector& target, float cosTolerance = BCC_DEFAULT_LOOK_TOWARDS_TOLERANCE) const; + + virtual bool IsInFieldOfView(CBaseEntity* entity) const; + virtual bool IsInFieldOfView(const Vector& pos) const; + + enum LineOfSightCheckType + { + IGNORE_NOTHING, + IGNORE_ACTORS + }; + virtual bool IsLineOfSightClear(CBaseEntity* entity, LineOfSightCheckType checkType = IGNORE_NOTHING) const; + virtual bool IsLineOfSightClear(const Vector& pos, LineOfSightCheckType checkType = IGNORE_NOTHING, CBaseEntity* entityToIgnore = NULL) const; + + + void RemoveAmmo(int iCount, int iAmmoIndex); + void RemoveAmmo(int iCount, const char* szName); + void RemoveAllAmmo(); + int GetAmmoCount(int iAmmoIndex) const; + int GetAmmoCount(char* szName) const; + + C_BaseCombatWeapon* Weapon_OwnsThisType(const char* pszWeapon, int iSubType = 0) const; + virtual bool Weapon_Switch(C_BaseCombatWeapon* pWeapon, int viewmodelindex = 0); + virtual bool Weapon_CanSwitchTo(C_BaseCombatWeapon* pWeapon); + + bool SwitchToNextBestWeapon(C_BaseCombatWeapon* pCurrent); + + virtual C_BaseCombatWeapon* GetActiveWeapon(void) const; + int WeaponCount() const; + C_BaseCombatWeapon* GetWeapon(int i) const; + + void SetAmmoCount(int iCount, int iAmmoIndex); + + float GetNextAttack() const { return m_flNextAttack; } + void SetNextAttack(float flWait) { m_flNextAttack = flWait; } + + virtual int BloodColor(); + + void SetBloodColor(int nBloodColor); + + virtual void DoMuzzleFlash(); + +#ifdef GLOWS_ENABLE + CGlowObject* GetGlowObject(void) { return m_pGlowEffect; } + virtual void GetGlowEffectColor(float* r, float* g, float* b); +#endif + +public: + + float m_flNextAttack; + +protected: + +#ifdef GLOWS_ENABLE + virtual void UpdateGlowEffect(void); + virtual void DestroyGlowEffect(void); +#endif + + int m_bloodColor; + +private: + bool ComputeLOS(const Vector& vecEyePosition, const Vector& vecTarget) const; + + CNetworkArray(int, m_iAmmo, MAX_AMMO_TYPES); + + CHandle m_hMyWeapons[MAX_WEAPONS]; + CHandle< C_BaseCombatWeapon > m_hActiveWeapon; + +#ifdef GLOWS_ENABLE + bool m_bGlowEnabled; + bool m_bOldGlowEnabled; + CGlowObject* m_pGlowEffect; +#endif + +private: + C_BaseCombatCharacter(const C_BaseCombatCharacter&); + + +#ifdef INVASION_CLIENT_DLL +public: + virtual void Release(void); + virtual void SetDormant(bool bDormant); + virtual void OnPreDataChanged(DataUpdateType_t updateType); + virtual void OnDataChanged(DataUpdateType_t updateType); + virtual void ClientThink(void); + + virtual bool CanBePoweredUp(void) { return true; } + bool HasPowerup(int iPowerup) { return (m_iPowerups & (1 << iPowerup)) != 0; }; + virtual void PowerupStart(int iPowerup, bool bInitial); + virtual void PowerupEnd(int iPowerup); + void RemoveAllPowerups(void); + + void AddEMPEffect(float flSize); + void AddBuffEffect(float flSize); + + C_WeaponCombatShield* GetShield(void); + +public: + int m_iPowerups; + int m_iPrevPowerups; +#endif + +}; + +inline C_BaseCombatCharacter* ToBaseCombatCharacter(C_BaseEntity* pEntity) +{ + if (!pEntity || !pEntity->IsBaseCombatCharacter()) + return NULL; + +#if _DEBUG + return dynamic_cast(pEntity); +#else + return static_cast(pEntity); +#endif +} + +inline int C_BaseCombatCharacter::WeaponCount() const +{ + return MAX_WEAPONS; +} + +inline C_BaseCombatWeapon* C_BaseCombatCharacter::GetWeapon(int i) const +{ + Assert((i >= 0) && (i < MAX_WEAPONS)); + return m_hMyWeapons[i].Get(); +} + +EXTERN_RECV_TABLE(DT_BaseCombatCharacter); + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/c_baseentity.h b/SpyCustom/sdk/c_baseentity.h new file mode 100644 index 0000000..b80b767 --- /dev/null +++ b/SpyCustom/sdk/c_baseentity.h @@ -0,0 +1,192 @@ +#ifndef CBASEENT +#define CBASEENT + +#pragma once + +#include "icliententity.h" +#include "NetVarManager.hpp" +#include "PatternScan.hpp" +#include "netvars.hpp" + + +namespace VirtualMethod +{ + template + constexpr T call(void* classBase, Args... args) noexcept + { + return (*reinterpret_cast(classBase))[Idx](classBase, args...); + } +} + +#define VIRTUAL_METHOD(returnType, name, idx, args, argsRaw) \ +returnType name args noexcept \ +{ \ + return VirtualMethod::callargsRaw; \ +} + +#define CONCAT(a, b) a##b +#define PAD_NAME(n) CONCAT(pad, n) +#define PAD(size) \ +private: \ + std::byte PAD_NAME(__COUNTER__) [size]; \ +public: + + + class C_BaseEntity : public IClientEntity + { + public: + + NETVAR_OFFSET(GetIndex, "CBaseEntity", "m_bIsAutoaimTarget", +0x4, int); + NETVAR(GetModelIndex, "CBaseEntity", "m_nModelIndex", unsigned); + + NETVAR(Ragdoll, "CCSPlayer", "m_hRagdoll", int); + + NETVAR2(GetViewmodelArmConfig, "DT_CSPlayer", "m_pViewmodelArmConfig", PlayerViewmodelArmConfig*); + NETVAR2(GetArmsModel, "DT_CSPlayer", "m_szArmsModel", char*); + + + + void SetModelIndex(const int index) + { + getvfunc(this, 75)(this, index); + } + + NETVAR_OFFSET(m_dwBoneMatrix, "CBaseAnimating", "m_nForceBone", +0x1C, uintptr_t); + + Vector GetBonePosition(int iBone) { + uintptr_t bm = m_dwBoneMatrix(); + matrix3x4_t boneMatrix = *(matrix3x4_t*) (bm +iBone * sizeof(matrix3x4_t)) ; + return Vector(boneMatrix[0][3], boneMatrix[1][3], boneMatrix[2][3]); + } + + NETVAR(body, "CBaseAnimating", "m_nBody", int); + NETVAR(GetModelScale, "CBaseAnimating", "m_flModelScale", float); + NETVAR(GetScaleType, "CBaseAnimating", "m_ScaleType", float); + NETVAR(GetFrozen, "CBaseAnimating", "m_flFrozen", float); + + NETVAR(GetMins, "CBaseEntity", "m_vecMins", Vector); + NETVAR(GetMaxs, "CBaseEntity", "m_vecMaxs", Vector); + + int GetSequenceActivity(int sequence, studiohdr_t* hdr) + { + static auto getSequenceActivity = (DWORD)(FindPatternV2("client.dll", "55 8B EC 53 8B 5D 08 56 8B F1 83")); + static auto GetSequenceActivity = reinterpret_cast(getSequenceActivity); + return GetSequenceActivity(this, hdr, sequence); + } + + char* GetSequenceActivity(int sequence) + { + static auto getSequenceActivity = (DWORD)(FindPatternV2("client.dll", "55 8B EC 83 7D 08 FF 56 8B F1")); + static auto GetSequenceActivity = reinterpret_cast(getSequenceActivity); + return GetSequenceActivity(this, 0, sequence); + } + + void SendViewModelMatchingSequence(int sequence) + { + printf("Set new sequence %d\n",sequence); + typedef void(__thiscall* OriginalFn)(void*, int); + return getvfunc(this, 246)(this, sequence); + } + + }; + + class C_BaseCombatCharacter : public C_BaseEntity + { + public: + NETVAR(GetWeapons, "CBaseCombatCharacter", "m_hMyWeapons", std::array); + PNETVAR(GetWearables, "CBaseCombatCharacter", "m_hMyWearables", CBaseHandle); + }; + + class C_BasePlayer : public C_BaseCombatCharacter + { + public: + NETVAR(GetLifeState, "CBasePlayer", "m_lifeState", int); + NETVAR(GetViewModel, "CBasePlayer", "m_hViewModel[0]", CBaseHandle); + + NETVAR(GetOrigin, "CBaseEntity", "m_vecOrigin", Vector); + NETVAR(GetAngles, "CBaseEntity", "m_angRotation", Vector); + NETVAR(GetHealth, "CBasePlayer", "m_iHealth", int); + NETVAR(GetViewOffset, "CBasePlayer", "m_vecViewOffset[0]", Vector); + NETVAR(GetTeam, "CBaseEntity", "m_iTeamNum", int); + + NETVAR2(GetNightvision, "DT_CSPlayer", "m_bNightVisionOn", bool); + NETVAR2(GetNightvisionAlpha, "DT_CSPlayer", "m_flNightVisionAlpha", float); + }; + + class C_BaseCombatWeapon : public C_BaseEntity + { + public: + NETVAR(GetViewModelIndex, "CBaseCombatWeapon", "m_iViewModelIndex", int); + NETVAR(GetWorldModelIndex, "CBaseCombatWeapon", "m_iWorldModelIndex", int); + NETVAR(GetWorldDroppedModelIndex, "CBaseCombatWeapon", "m_iWorldDroppedModelIndex", int); + NETVAR(GetWeaponWorldModel, "CBaseCombatWeapon", "m_hWeaponWorldModel", CBaseHandle); + }; + + class C_BaseAttributableItem : public C_BaseCombatWeapon + { + public: + NETVAR(GetAccountID, "CBaseAttributableItem", "m_iAccountID", int); + NETVAR(GetItemDefinitionIndex, "CBaseAttributableItem", "m_iItemDefinitionIndex", short); + NETVAR(GetItemIDHigh, "CBaseAttributableItem", "m_iItemIDHigh", int); + NETVAR(GetEntityQuality, "CBaseAttributableItem", "m_iEntityQuality", int); + NETVAR(GetCustomName, "CBaseAttributableItem", "m_szCustomName", char[32]); + NETVAR(GetFallbackPaintKit, "CBaseAttributableItem", "m_nFallbackPaintKit", unsigned); + NETVAR(GetFallbackSeed, "CBaseAttributableItem", "m_nFallbackSeed", unsigned); + NETVAR(GetFallbackWear, "CBaseAttributableItem", "m_flFallbackWear", float); + NETVAR(GetFallbackStatTrak, "CBaseAttributableItem", "m_nFallbackStatTrak", unsigned); + NETVAR(initialized, "CBaseAttributableItem", "m_bInitialized", bool) + }; + + class C_BaseViewModel : public C_BaseEntity + { + public: + NETVAR(GetOwner, "CBaseViewModel", "m_hOwner", CBaseHandle); + NETVAR(GetWeapon, "CBaseViewModel", "m_hWeapon", CBaseHandle); + NETPROP(GetSequenceProp, "CBaseViewModel", "m_nSequence"); + + NETVAR(GetSequence, "CBaseViewModel", "m_nSequence", int); + }; + + class C_PlayerResource + { + public: + NETPROP(GetTeamProp, "CPlayerResource", "m_iTeam"); + }; + + class C_CS_PlayerResource : public C_PlayerResource + { + public: + NETVAR(GetRanks, "CCSPlayerResource", "m_iCompetitiveRanking", int[MAX_PLAYERS]); + NETVAR(GetRankType, "CCSPlayerResource", "m_iCompetitiveRankType", int[MAX_PLAYERS]); + NETVAR(GetWins, "CCSPlayerResource", "m_iCompetitiveWins", int[MAX_PLAYERS]); + NETVAR(GetLevel, "CCSPlayerResource", "m_nPersonaDataPublicLevel", int[MAX_PLAYERS]); + NETVAR(GetComLeader, "CCSPlayerResource", "m_nPersonaDataPublicCommendsLeader", int[MAX_PLAYERS]); + NETVAR(GetComTeacher, "CCSPlayerResource", "m_nPersonaDataPublicCommendsTeacher", int[MAX_PLAYERS]); + NETVAR(GetComFriendly, "CCSPlayerResource", "m_nPersonaDataPublicCommendsFriendly", int[MAX_PLAYERS]); + + NETVAR(GetClanTags, "CCSPlayerResource", "m_szClan", char[MAX_PLAYERS][32]); + NETVAR(GetCoins, "CCSPlayerResource", "m_nActiveCoinRank", unsigned[MAX_PLAYERS]); + NETVAR(GetMusicKits, "CCSPlayerResource", "m_nMusicID", unsigned[MAX_PLAYERS]); + + NETVAR2(GetKills, "DT_CSPlayerResource", "m_iKills", unsigned[MAX_PLAYERS]); + NETVAR2(GetAssists, "DT_CSPlayerResource", "m_iAssists", unsigned[MAX_PLAYERS]); + NETVAR2(GetDeaths, "DT_CSPlayerResource", "m_iDeaths", unsigned[MAX_PLAYERS]); + + NETVAR(GetMVPs, "CCSPlayerResource", "m_iMVPs", int[MAX_PLAYERS]); + NETVAR(GetScore, "CCSPlayerResource", "m_iScore", int[MAX_PLAYERS]); + + NETVAR(IsVIP, "CCSPlayerResource", "m_iPlayerVIP", int[MAX_PLAYERS]); + + }; + + class CBaseWeaponWorldModel : public C_BaseEntity + { + }; + + class C_Precipitation : public C_BaseEntity + { + public: + NETVAR2(GetPrecipitationType, "DT_Precipitation", "m_nPrecipType", PrecipitationType_t); + }; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/c_baseflex.h b/SpyCustom/sdk/c_baseflex.h new file mode 100644 index 0000000..086b719 --- /dev/null +++ b/SpyCustom/sdk/c_baseflex.h @@ -0,0 +1,284 @@ +#ifndef C_STUDIOFLEX_H +#define C_STUDIOFLEX_H +#pragma once + + +#include "c_baseanimating.h" +#include "c_baseanimatingoverlay.h" +#include "sceneentity_shared.h" + +#include "utlvector.h" + +class CFlexSceneFile +{ +public: + enum + { + MAX_FLEX_FILENAME = 128, + }; + + char filename[MAX_FLEX_FILENAME]; + void* buffer; +}; + +struct Emphasized_Phoneme; +class CSentence; + +enum +{ + PHONEME_CLASS_WEAK = 0, + PHONEME_CLASS_NORMAL, + PHONEME_CLASS_STRONG, + + NUM_PHONEME_CLASSES +}; + +struct FS_LocalToGlobal_t +{ + explicit FS_LocalToGlobal_t() : + m_Key(0), + m_nCount(0), + m_Mapping(0) + { + } + + explicit FS_LocalToGlobal_t(const flexsettinghdr_t* key) : + m_Key(key), + m_nCount(0), + m_Mapping(0) + { + } + + void SetCount(int count) + { + Assert(!m_Mapping); + Assert(count > 0); + m_nCount = count; + m_Mapping = new int[m_nCount]; + Q_memset(m_Mapping, 0, m_nCount * sizeof(int)); + } + + FS_LocalToGlobal_t(const FS_LocalToGlobal_t& src) + { + m_Key = src.m_Key; + delete m_Mapping; + m_Mapping = new int[src.m_nCount]; + Q_memcpy(m_Mapping, src.m_Mapping, src.m_nCount * sizeof(int)); + + m_nCount = src.m_nCount; + } + + ~FS_LocalToGlobal_t() + { + delete m_Mapping; + m_nCount = 0; + m_Mapping = 0; + } + + const flexsettinghdr_t* m_Key; + int m_nCount; + int* m_Mapping; +}; + +bool FlexSettingLessFunc(const FS_LocalToGlobal_t& lhs, const FS_LocalToGlobal_t& rhs); + +class IHasLocalToGlobalFlexSettings +{ +public: + virtual void EnsureTranslations(const flexsettinghdr_t* pSettinghdr) = 0; +}; + +struct Emphasized_Phoneme +{ + char classname[64]; + bool required; + bool basechecked; + const flexsettinghdr_t* base; + const flexsetting_t* exp; + + bool valid; + float amount; +}; + +class C_BaseFlex : public C_BaseAnimatingOverlay, public IHasLocalToGlobalFlexSettings +{ + DECLARE_CLASS(C_BaseFlex, C_BaseAnimatingOverlay); +public: + DECLARE_CLIENTCLASS(); + DECLARE_PREDICTABLE(); + DECLARE_INTERPOLATION(); + + C_BaseFlex(); + virtual ~C_BaseFlex(); + + virtual void Spawn(); + + virtual void InitPhonemeMappings(); + + void SetupMappings(char const* pchFileRoot); + + virtual CStudioHdr* OnNewModel(void); + + virtual void StandardBlendingRules(CStudioHdr* hdr, Vector pos[], Quaternion q[], float currentTime, int boneMask); + + virtual void OnThreadedDrawSetup(); + + virtual void BuildTransformations(CStudioHdr* pStudioHdr, Vector* pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList& boneComputed); + static void LinkToGlobalFlexControllers(CStudioHdr* hdr); + virtual void SetupWeights(const matrix3x4_t* pBoneToWorld, int nFlexWeightCount, float* pFlexWeights, float* pFlexDelayedWeights); + virtual bool SetupGlobalWeights(const matrix3x4_t* pBoneToWorld, int nFlexWeightCount, float* pFlexWeights, float* pFlexDelayedWeights); + static void RunFlexDelay(int nFlexWeightCount, float* pFlexWeights, float* pFlexDelayedWeights, float& flFlexDelayTime); + virtual void SetupLocalWeights(const matrix3x4_t* pBoneToWorld, int nFlexWeightCount, float* pFlexWeights, float* pFlexDelayedWeights); + virtual bool UsesFlexDelayedWeights(); + + static void RunFlexRules(CStudioHdr* pStudioHdr, float* dest); + + virtual Vector SetViewTarget(CStudioHdr* pStudioHdr); + + virtual bool GetSoundSpatialization(SpatializationInfo_t& info); + + virtual void GetToolRecordingState(KeyValues* msg); + + void AddFlexAnimation(CSceneEventInfo* info); + + void SetFlexWeight(LocalFlexController_t index, float value); + float GetFlexWeight(LocalFlexController_t index); + + LocalFlexController_t FindFlexController(const char* szName); + +public: + Vector m_viewtarget; + CInterpolatedVar< Vector > m_iv_viewtarget; + float m_flexWeight[MAXSTUDIOFLEXCTRL]; + CInterpolatedVarArray< float, MAXSTUDIOFLEXCTRL > m_iv_flexWeight; + + int m_blinktoggle; + + static int AddGlobalFlexController(const char* szName); + static char const* GetGlobalFlexControllerName(int idx); + +public: + + void StartChoreoScene(CChoreoScene* scene); + void RemoveChoreoScene(CChoreoScene* scene); + + virtual bool StartSceneEvent(CSceneEventInfo* info, CChoreoScene* scene, CChoreoEvent* event, CChoreoActor* actor, C_BaseEntity* pTarget); + + virtual void ProcessSceneEvents(bool bFlexEvents); + + virtual bool ProcessSceneEvent(bool bFlexEvents, CSceneEventInfo* info, CChoreoScene* scene, CChoreoEvent* event); + + virtual bool ProcessSequenceSceneEvent(CSceneEventInfo* info, CChoreoScene* scene, CChoreoEvent* event); + + void ClearSceneEvents(CChoreoScene* scene, bool canceled); + + virtual bool ClearSceneEvent(CSceneEventInfo* info, bool fastKill, bool canceled); + + void AddSceneEvent(CChoreoScene* scene, CChoreoEvent* event, C_BaseEntity* pTarget = NULL, bool bClientSide = false); + + void RemoveSceneEvent(CChoreoScene* scene, CChoreoEvent* event, bool fastKill); + + bool CheckSceneEvent(float currenttime, CChoreoScene* scene, CChoreoEvent* event); + + virtual bool CheckSceneEventCompletion(CSceneEventInfo* info, float currenttime, CChoreoScene* scene, CChoreoEvent* event); + + int FlexControllerLocalToGlobal(const flexsettinghdr_t* pSettinghdr, int key); + + virtual void EnsureTranslations(const flexsettinghdr_t* pSettinghdr); + + void* FindSceneFile(const char* filename); + +private: + + bool RequestStartSequenceSceneEvent(CSceneEventInfo* info, CChoreoScene* scene, CChoreoEvent* event, CChoreoActor* actor, CBaseEntity* pTarget); + + bool ProcessFlexAnimationSceneEvent(CSceneEventInfo* info, CChoreoScene* scene, CChoreoEvent* event); + bool ProcessFlexSettingSceneEvent(CSceneEventInfo* info, CChoreoScene* scene, CChoreoEvent* event); + void AddFlexSetting(const char* expr, float scale, + const flexsettinghdr_t* pSettinghdr, bool newexpression); + + CUtlVector < CSceneEventInfo > m_SceneEvents; + CUtlVector < CChoreoScene* > m_ActiveChoreoScenes; + + bool HasSceneEvents() const; + +private: + CUtlRBTree< FS_LocalToGlobal_t, unsigned short > m_LocalToGlobal; + + float m_blinktime; + int m_prevblinktoggle; + + int m_iBlink; + LocalFlexController_t m_iEyeUpdown; + LocalFlexController_t m_iEyeRightleft; + bool m_bSearchedForEyeFlexes; + int m_iMouthAttachment; + + float m_flFlexDelayTime; + float* m_flFlexDelayedWeight; + int m_cFlexDelayedWeight; + + static int g_numflexcontrollers; + static char* g_flexcontroller[MAXSTUDIOFLEXCTRL * 4]; + static float g_flexweight[MAXSTUDIOFLEXDESC]; + +protected: + + Emphasized_Phoneme m_PhonemeClasses[NUM_PHONEME_CLASSES]; + +private: + + C_BaseFlex(const C_BaseFlex&); + + const flexsetting_t* FindNamedSetting(const flexsettinghdr_t* pSettinghdr, const char* expr); + + void ProcessVisemes(Emphasized_Phoneme* classes); + void AddVisemesForSentence(Emphasized_Phoneme* classes, float emphasis_intensity, CSentence* sentence, float t, float dt, bool juststarted); + void AddViseme(Emphasized_Phoneme* classes, float emphasis_intensity, int phoneme, float scale, bool newexpression); + bool SetupEmphasisBlend(Emphasized_Phoneme* classes, int phoneme); + void ComputeBlendedSetting(Emphasized_Phoneme* classes, float emphasis_intensity); + +#ifdef HL2_CLIENT_DLL +public: + + Vector m_vecLean; + CInterpolatedVar< Vector > m_iv_vecLean; + Vector m_vecShift; + CInterpolatedVar< Vector > m_iv_vecShift; +#endif +}; + + +class CFlexSceneFileManager : CAutoGameSystem +{ +public: + + CFlexSceneFileManager() : CAutoGameSystem("CFlexSceneFileManager") + { + } + + virtual bool Init(); + virtual void Shutdown(); + + void EnsureTranslations(IHasLocalToGlobalFlexSettings* instance, const flexsettinghdr_t* pSettinghdr); + void* FindSceneFile(IHasLocalToGlobalFlexSettings* instance, const char* filename, bool allowBlockingIO); + +private: + void DeleteSceneFiles(); + + CUtlVector< CFlexSceneFile* > m_FileList; +}; + + +inline bool C_BaseFlex::HasSceneEvents() const +{ + return m_SceneEvents.Count() != 0; +} + + +EXTERN_RECV_TABLE(DT_BaseFlex); + +float* GetVisemeWeights(int phoneme); + + +#endif diff --git a/SpyCustom/sdk/c_baseplayer.h b/SpyCustom/sdk/c_baseplayer.h new file mode 100644 index 0000000..5e0c111 --- /dev/null +++ b/SpyCustom/sdk/c_baseplayer.h @@ -0,0 +1,619 @@ +#ifndef C_BASEPLAYER_H +#define C_BASEPLAYER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "c_playerlocaldata.h" +#include "c_basecombatcharacter.h" + +#include "usercmd.h" +#include "shareddefs.h" +#include "timedevent.h" +#include "smartptr.h" + +#include "igameevents.h" +#include "GameEventListener.h" + +#if defined USES_ECON_ITEMS +#include "econ_item.h" +#include "game_item_schema.h" +#include "econ_item_view.h" +#endif + +class C_BaseCombatWeapon; +class C_BaseViewModel; +class C_FuncLadder; +class CFlashlightEffect; +class C_EconWearable; + +extern int g_nKillCamMode; +extern int g_nKillCamTarget1; +extern int g_nKillCamTarget2; + +class C_CommandContext +{ +public: + bool needsprocessing; + + CUserCmd cmd; + int command_number; +}; + +class C_PredictionError +{ +public: + float time; + Vector error; +}; + +#define CHASE_CAM_DISTANCE_MIN 16.0f +#define CHASE_CAM_DISTANCE_MAX 96.0f +#define WALL_OFFSET 6.0f + + +bool IsInFreezeCam(void); + +class C_BasePlayer : public C_BaseCombatCharacter, public CGameEventListener +{ +public: + DECLARE_CLASS(C_BasePlayer, C_BaseCombatCharacter); + DECLARE_CLIENTCLASS(); + DECLARE_PREDICTABLE(); + DECLARE_INTERPOLATION(); + + C_BasePlayer(); + virtual ~C_BasePlayer(); + + virtual void Spawn(void); + virtual void SharedSpawn(); + virtual bool GetSteamID(CSteamID* pID); + + virtual void OnPreDataChanged(DataUpdateType_t updateType); + virtual void OnDataChanged(DataUpdateType_t updateType); + + virtual void PreDataUpdate(DataUpdateType_t updateType); + virtual void PostDataUpdate(DataUpdateType_t updateType); + + virtual void ReceiveMessage(int classID, bf_read& msg); + + virtual void OnRestore(); + + virtual void AddEntity(void); + + virtual void MakeTracer(const Vector& vecTracerSrc, const trace_t& tr, int iTracerType); + + virtual void GetToolRecordingState(KeyValues* msg); + + virtual float GetPlayerMaxSpeed(); + + void SetAnimationExtension(const char* pExtension); + + C_BaseViewModel* GetViewModel(int viewmodelindex = 0, bool bObserverOK = true); + C_BaseCombatWeapon* GetActiveWeapon(void) const; + const char* GetTracerType(void); + + virtual void CalcView(Vector& eyeOrigin, QAngle& eyeAngles, float& zNear, float& zFar, float& fov); + virtual void CalcViewModelView(const Vector& eyeOrigin, const QAngle& eyeAngles); + + + void SmoothViewOnStairs(Vector& eyeOrigin); + virtual float CalcRoll(const QAngle& angles, const Vector& velocity, float rollangle, float rollspeed); + void CalcViewRoll(QAngle& eyeAngles); + void CreateWaterEffects(void); + + virtual void SetPlayerUnderwater(bool state); + void UpdateUnderwaterState(void); + bool IsPlayerUnderwater(void) { return m_bPlayerUnderwater; } + + virtual Vector Weapon_ShootPosition(); + virtual void Weapon_DropPrimary(void) {} + + virtual Vector GetAutoaimVector(float flScale); + void SetSuitUpdate(const char* name, int fgroup, int iNoRepeat); + + virtual bool CreateMove(float flInputSampleTime, CUserCmd* pCmd); + virtual void AvoidPhysicsProps(CUserCmd* pCmd); + + virtual void PlayerUse(void); + CBaseEntity* FindUseEntity(void); + virtual bool IsUseableEntity(CBaseEntity* pEntity, unsigned int requiredCaps); + + virtual bool IsPlayer(void) const { return true; } + virtual int GetHealth() const { return m_iHealth; } + + int GetBonusProgress() const { return m_iBonusProgress; } + int GetBonusChallenge() const { return m_iBonusChallenge; } + + virtual int GetObserverMode() const; + void SetObserverMode(int iNewMode); + virtual CBaseEntity* GetObserverTarget() const; + void SetObserverTarget(EHANDLE hObserverTarget); + + bool AudioStateIsUnderwater(Vector vecMainViewOrigin); + + bool IsObserver() const; + bool IsHLTV() const; + bool IsReplay() const; + void ResetObserverMode(); + bool IsBot(void) const { return false; } + + virtual Vector EyePosition(); + virtual const QAngle& EyeAngles(); + void EyePositionAndVectors(Vector* pPosition, Vector* pForward, Vector* pRight, Vector* pUp); + virtual const QAngle& LocalEyeAngles(); + + virtual IRagdoll* GetRepresentativeRagdoll() const; + + virtual void GetRagdollInitBoneArrays(matrix3x4_t* pDeltaBones0, matrix3x4_t* pDeltaBones1, matrix3x4_t* pCurrentBones, float boneDt); + + void EyeVectors(Vector* pForward, Vector* pRight = NULL, Vector* pUp = NULL); + void CacheVehicleView(void); + + + bool IsSuitEquipped(void) { return m_Local.m_bWearingSuit; }; + + virtual void TeamChange(int iNewTeam); + + void Flashlight(void); + void UpdateFlashlight(void); + + virtual bool IsAllowedToSwitchWeapons(void) { return !IsObserver(); } + virtual C_BaseCombatWeapon* GetActiveWeaponForSelection(void); + + virtual C_BaseAnimating* GetRenderedWeaponModel(); + + virtual bool IsOverridingViewmodel(void) { return false; }; + virtual int DrawOverriddenViewmodel(C_BaseViewModel* pViewmodel, int flags) { return 0; }; + + virtual float GetDefaultAnimSpeed(void) { return 1.0; } + + void SetMaxSpeed(float flMaxSpeed) { m_flMaxspeed = flMaxSpeed; } + float MaxSpeed() const { return m_flMaxspeed; } + + virtual ShadowType_t ShadowCastType() { return SHADOWS_NONE; } + + virtual bool ShouldReceiveProjectedTextures(int flags) + { + return false; + } + + + bool IsLocalPlayer(void) const; + + virtual void ThirdPersonSwitch(bool bThirdperson); + static bool LocalPlayerInFirstPersonView(); + static bool ShouldDrawLocalPlayer(); + static C_BasePlayer* GetLocalPlayer(void); + int GetUserID(void); + virtual bool CanSetSoundMixer(void); + virtual int GetVisionFilterFlags(bool bWeaponsCheck = false) { return 0x00; } + bool HasVisionFilterFlags(int nFlags, bool bWeaponsCheck = false) { return (GetVisionFilterFlags(bWeaponsCheck) & nFlags) == nFlags; } + virtual void CalculateVisionUsingCurrentFlags(void) {} + void BuildFirstPersonMeathookTransformations(CStudioHdr* hdr, Vector* pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList& boneComputed, const char* pchHeadBoneName); + + bool InFirstPersonView(); + bool ShouldDrawThisPlayer(); + + virtual bool ViewModel_IsTransparent(void); + virtual bool ViewModel_IsUsingFBTexture(void); + +#if !defined( NO_ENTITY_PREDICTION ) + void AddToPlayerSimulationList(C_BaseEntity* other); + void SimulatePlayerSimulatedEntities(void); + void RemoveFromPlayerSimulationList(C_BaseEntity* ent); + void ClearPlayerSimulationList(void); +#endif + + virtual void PhysicsSimulate(void); + virtual unsigned int PhysicsSolidMaskForEntity(void) const { return MASK_PLAYERSOLID; } + + virtual bool ShouldPredict(void); + + virtual void PreThink(void); + virtual void PostThink(void); + + virtual void ItemPreFrame(void); + virtual void ItemPostFrame(void); + virtual void AbortReload(void); + + virtual void SelectLastItem(void); + virtual void Weapon_SetLast(C_BaseCombatWeapon* pWeapon); + virtual bool Weapon_ShouldSetLast(C_BaseCombatWeapon* pOldWeapon, C_BaseCombatWeapon* pNewWeapon) { return true; } + virtual bool Weapon_ShouldSelectItem(C_BaseCombatWeapon* pWeapon); + virtual bool Weapon_Switch(C_BaseCombatWeapon* pWeapon, int viewmodelindex = 0); + virtual C_BaseCombatWeapon* GetLastWeapon(void) { return m_hLastWeapon.Get(); } + void ResetAutoaim(void); + virtual void SelectItem(const char* pstr, int iSubType = 0); + + virtual void UpdateClientData(void); + + virtual float GetFOV(void); + int GetDefaultFOV(void) const; + virtual bool IsZoomed(void) { return false; } + bool SetFOV(CBaseEntity* pRequester, int FOV, float zoomRate = 0.0f, int iZoomStart = 0); + void ClearZoomOwner(void); + + float GetFOVDistanceAdjustFactor(); + + virtual void ViewPunch(const QAngle& angleOffset); + void ViewPunchReset(float tolerance = 0); + + void UpdateButtonState(int nUserCmdButtonMask); + int GetImpulse(void) const; + + virtual void Simulate(); + + virtual bool ShouldInterpolate(); + + virtual bool ShouldDraw(); + virtual int DrawModel(int flags); + + virtual void OverrideView(CViewSetup* pSetup); + + const char* GetPlayerName(); + virtual const Vector GetPlayerMins(void) const; + virtual const Vector GetPlayerMaxs(void) const; + + bool IsPlayerDead(); + bool IsPoisoned(void) { return m_Local.m_bPoisoned; } + + C_BaseEntity* GetUseEntity(); + + IClientVehicle* GetVehicle(); + + bool IsInAVehicle() const { return (NULL != m_hVehicle.Get()) ? true : false; } + virtual void SetVehicleRole(int nRole); + void LeaveVehicle(void); + + bool UsingStandardWeaponsInVehicle(void); + + virtual void SetAnimation(PLAYER_ANIM playerAnim); + + float GetTimeBase(void) const; + float GetFinalPredictedTime() const; + + bool IsInVGuiInputMode() const; + bool IsInViewModelVGuiInputMode() const; + + C_CommandContext* GetCommandContext(); + + int CurrentCommandNumber() const; + const CUserCmd* GetCurrentUserCommand() const; + + const QAngle& GetPunchAngle(); + void SetPunchAngle(const QAngle& angle); + + float GetWaterJumpTime() const; + void SetWaterJumpTime(float flWaterJumpTime); + float GetSwimSoundTime(void) const; + void SetSwimSoundTime(float flSwimSoundTime); + + float GetDeathTime(void) { return m_flDeathTime; } + + void SetPreviouslyPredictedOrigin(const Vector& vecAbsOrigin); + const Vector& GetPreviouslyPredictedOrigin() const; + + virtual float GetMinFOV() const; + + virtual void DoMuzzleFlash(); + virtual void PlayPlayerJingle(); + + virtual void UpdateStepSound(surfacedata_t* psurface, const Vector& vecOrigin, const Vector& vecVelocity); + virtual void PlayStepSound(Vector& vecOrigin, surfacedata_t* psurface, float fvol, bool force); + virtual surfacedata_t* GetFootstepSurface(const Vector& origin, const char* surfaceName); + virtual void GetStepSoundVelocities(float* velwalk, float* velrun); + virtual void SetStepSoundTime(stepsoundtimes_t iStepSoundTime, bool bWalking); + virtual const char* GetOverrideStepSound(const char* pszBaseStepSoundName) { return pszBaseStepSoundName; } + + virtual void OnEmitFootstepSound(const CSoundParameters& params, const Vector& vecOrigin, float fVolume) {} + + void NotePredictionError(const Vector& vDelta); + + void GetPredictionErrorSmoothingVector(Vector& vOffset); + + virtual void ExitLadder() {} + surfacedata_t* GetLadderSurface(const Vector& origin); + + surfacedata_t* GetSurfaceData(void) { return m_pSurfaceData; } + + void SetLadderNormal(Vector vecLadderNormal) { m_vecLadderNormal = vecLadderNormal; } + + virtual CHintSystem* Hints(void) { return NULL; } + bool ShouldShowHints(void) { return Hints() ? Hints()->ShouldShowHints() : false; } + bool HintMessage(int hint, bool bForce = false, bool bOnlyIfClear = false) { return Hints() ? Hints()->HintMessage(hint, bForce, bOnlyIfClear) : false; } + void HintMessage(const char* pMessage) { if (Hints()) Hints()->HintMessage(pMessage); } + + virtual IMaterial* GetHeadLabelMaterial(void); + + fogparams_t* GetFogParams(void) { return &m_CurrentFog; } + void FogControllerChanged(bool bSnap); + void UpdateFogController(void); + void UpdateFogBlend(void); + + float GetFOVTime(void) { return m_flFOVTime; } + + virtual void OnAchievementAchieved(int iAchievement) {} + + bool ShouldAnnounceAchievement(void) { return m_flNextAchievementAnnounceTime < gpGlobals->curtime; } + void SetNextAchievementAnnounceTime(float flTime) { m_flNextAchievementAnnounceTime = flTime; } + +#if defined USES_ECON_ITEMS + void UpdateWearables(); + C_EconWearable* GetWearable(int i) { return m_hMyWearables[i]; } + int GetNumWearables(void) { return m_hMyWearables.Count(); } +#endif + + bool HasFiredWeapon(void) { return m_bFiredWeapon; } + void SetFiredWeapon(bool bFlag) { m_bFiredWeapon = bFlag; } + + virtual bool CanUseFirstPersonCommand(void) { return true; } + +protected: + fogparams_t m_CurrentFog; + EHANDLE m_hOldFogController; + +public: + int m_StuckLast; + + CNetworkVarEmbedded(CPlayerLocalData, m_Local); + +#if defined USES_ECON_ITEMS + CNetworkVarEmbedded(CAttributeList, m_AttributeList); +#endif + + CPlayerState pl; + + int m_iFOV; + int m_iFOVStart; + float m_flFOVTime; + int m_iDefaultFOV; + EHANDLE m_hZoomOwner; + bool m_fOnTarget; + + char m_szAnimExtension[32]; + + int m_afButtonLast; + int m_afButtonPressed; + int m_afButtonReleased; + + int m_nButtons; + + CUserCmd* m_pCurrentCommand; + + EHANDLE m_hConstraintEntity; + Vector m_vecConstraintCenter; + float m_flConstraintRadius; + float m_flConstraintWidth; + float m_flConstraintSpeedFactor; + +protected: + + void CalcPlayerView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov); + void CalcVehicleView(IClientVehicle* pVehicle, Vector& eyeOrigin, QAngle& eyeAngles, + float& zNear, float& zFar, float& fov); + virtual void CalcObserverView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov); + virtual Vector GetChaseCamViewOffset(CBaseEntity* target); + void CalcChaseCamView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov); + virtual void CalcInEyeCamView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov); + + virtual float GetDeathCamInterpolationTime(); + + virtual void CalcDeathCamView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov); + void CalcRoamingView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov); + virtual void CalcFreezeCamView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov); + + void DetermineVguiInputMode(CUserCmd* pCmd); + + virtual void SetLocalViewAngles(const QAngle& viewAngles); + virtual void SetViewAngles(const QAngle& ang); + + surfacedata_t* GetGroundSurface(); + + virtual void FireGameEvent(IGameEvent* event); + +protected: + bool JustEnteredVehicle(); + + int m_iObserverMode; + EHANDLE m_hObserverTarget; + float m_flObserverChaseDistance; + Vector m_vecFreezeFrameStart; + float m_flFreezeFrameStartTime; + float m_flFreezeFrameDistance; + bool m_bWasFreezeFraming; + float m_flDeathTime; + + float m_flStepSoundTime; + bool m_IsFootprintOnLeft; + +private: + C_BasePlayer& operator=(const C_BasePlayer& src); + C_BasePlayer(const C_BasePlayer&); + + EHANDLE m_hVehicle; + EHANDLE m_hOldVehicle; + EHANDLE m_hUseEntity; + + float m_flMaxspeed; + + int m_iBonusProgress; + int m_iBonusChallenge; + + CInterpolatedVar< Vector > m_iv_vecViewOffset; + + Vector m_vecWaterJumpVel; + float m_flWaterJumpTime; + int m_nImpulse; + + float m_flSwimSoundTime; + Vector m_vecLadderNormal; + + QAngle m_vecOldViewAngles; + + bool m_bWasFrozen; + int m_flPhysics; + + int m_nTickBase; + int m_nFinalPredictedTick; + + EHANDLE m_pCurrentVguiScreen; + + bool m_bFiredWeapon; + + + CFlashlightEffect* m_pFlashlight; + + typedef CHandle CBaseCombatWeaponHandle; + CNetworkVar(CBaseCombatWeaponHandle, m_hLastWeapon); + +#if !defined( NO_ENTITY_PREDICTION ) + CUtlVector< CHandle< C_BaseEntity > > m_SimulatedByThisPlayer; +#endif + + CHandle< C_BaseViewModel > m_hViewModel[MAX_VIEWMODELS]; + + float m_flOldPlayerZ; + float m_flOldPlayerViewOffsetZ; + + Vector m_vecVehicleViewOrigin; + QAngle m_vecVehicleViewAngles; + float m_flVehicleViewFOV; + int m_nVehicleViewSavedFrame; + + int m_iOldAmmo[MAX_AMMO_TYPES]; + + C_CommandContext m_CommandContext; + + float m_flWaterSurfaceZ; + bool m_bResampleWaterSurface; + TimedEvent m_tWaterParticleTimer; + CSmartPtr m_pWaterEmitter; + + bool m_bPlayerUnderwater; + + friend class CPrediction; + + friend class CTFGameMovementRecon; + friend class CGameMovement; + friend class CTFGameMovement; + friend class CHL1GameMovement; + friend class CCSGameMovement; + friend class CHL2GameMovement; + friend class CDODGameMovement; + friend class CPortalGameMovement; + + float GetStepSize(void) const { return m_Local.m_flStepSize; } + + float m_flNextAvoidanceTime; + float m_flAvoidanceRight; + float m_flAvoidanceForward; + float m_flAvoidanceDotForward; + float m_flAvoidanceDotRight; + +protected: + virtual bool IsDucked(void) const { return m_Local.m_bDucked; } + virtual bool IsDucking(void) const { return m_Local.m_bDucking; } + virtual float GetFallVelocity(void) { return m_Local.m_flFallVelocity; } + void ForceSetupBonesAtTimeFakeInterpolation(matrix3x4_t* pBonesOut, float curtimeOffset); + + float m_flLaggedMovementValue; + + Vector m_vecPredictionError; + float m_flPredictionErrorTime; + + Vector m_vecPreviouslyPredictedOrigin; + + char m_szLastPlaceName[MAX_PLACE_NAME_LENGTH]; + + int m_surfaceProps; + surfacedata_t* m_pSurfaceData; + float m_surfaceFriction; + char m_chTextureType; + + bool m_bSentFreezeFrame; + float m_flFreezeZOffset; + + float m_flNextAchievementAnnounceTime; + + int m_nForceVisionFilterFlags; + +#if defined USES_ECON_ITEMS + CUtlVector > m_hMyWearables; +#endif + +private: + + struct StepSoundCache_t + { + StepSoundCache_t() : m_usSoundNameIndex(0) {} + CSoundParameters m_SoundParameters; + unsigned short m_usSoundNameIndex; + }; + StepSoundCache_t m_StepSoundCache[2]; + +public: + + const char* GetLastKnownPlaceName(void) const { return m_szLastPlaceName; } + + float GetLaggedMovementValue(void) { return m_flLaggedMovementValue; } + bool ShouldGoSouth(Vector vNPCForward, Vector vNPCRight); + + void SetOldPlayerZ(float flOld) { m_flOldPlayerZ = flOld; } +}; + +EXTERN_RECV_TABLE(DT_BasePlayer); + +inline C_BasePlayer* ToBasePlayer(C_BaseEntity* pEntity) +{ + if (!pEntity || !pEntity->IsPlayer()) + return NULL; + +#if _DEBUG + Assert(dynamic_cast(pEntity) != NULL); +#endif + + return static_cast(pEntity); +} + +inline C_BaseEntity* C_BasePlayer::GetUseEntity() +{ + return m_hUseEntity; +} + + +inline IClientVehicle* C_BasePlayer::GetVehicle() +{ + C_BaseEntity* pVehicleEnt = m_hVehicle.Get(); + return pVehicleEnt ? pVehicleEnt->GetClientVehicle() : NULL; +} + +inline bool C_BasePlayer::IsObserver() const +{ + return (GetObserverMode() != OBS_MODE_NONE); +} + +inline int C_BasePlayer::GetImpulse(void) const +{ + return m_nImpulse; +} + + +inline C_CommandContext* C_BasePlayer::GetCommandContext() +{ + return &m_CommandContext; +} + +inline int CBasePlayer::CurrentCommandNumber() const +{ + Assert(m_pCurrentCommand); + return m_pCurrentCommand->command_number; +} + +inline const CUserCmd* CBasePlayer::GetCurrentUserCommand() const +{ + Assert(m_pCurrentCommand); + return m_pCurrentCommand; +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/c_basetempentity.h b/SpyCustom/sdk/c_basetempentity.h new file mode 100644 index 0000000..bc0a6b5 --- /dev/null +++ b/SpyCustom/sdk/c_basetempentity.h @@ -0,0 +1,98 @@ +#ifndef C_BASETEMPENTITY_H +#define C_BASETEMPENTITY_H +#ifdef _WIN32 +#pragma once +#endif + + +#include "client_class.h" +#include "iclientnetworkable.h" +#include "c_recipientfilter.h" + + +class C_BaseTempEntity : public IClientUnknown, public IClientNetworkable + +{ +public: + DECLARE_CLASS_NOBASE(C_BaseTempEntity); + DECLARE_CLIENTCLASS(); + + C_BaseTempEntity(void); + virtual ~C_BaseTempEntity(void); + + +public: + + virtual void SetRefEHandle(const CBaseHandle& handle) { Assert(false); } + virtual const CBaseHandle& GetRefEHandle() const { return *((CBaseHandle*)0); } + + virtual IClientUnknown* GetIClientUnknown() { return this; } + virtual ICollideable* GetCollideable() { return 0; } + virtual IClientNetworkable* GetClientNetworkable() { return this; } + virtual IClientRenderable* GetClientRenderable() { return 0; } + virtual IClientEntity* GetIClientEntity() { return 0; } + virtual C_BaseEntity* GetBaseEntity() { return 0; } + virtual IClientThinkable* GetClientThinkable() { return 0; } + virtual IClientModelRenderable* GetClientModelRenderable() { return 0; } + virtual IClientAlphaProperty* GetClientAlphaProperty() { return 0; } + +public: + + virtual void Release(); + virtual void NotifyShouldTransmit(ShouldTransmitState_t state); + virtual void PreDataUpdate(DataUpdateType_t updateType); + virtual void PostDataUpdate(DataUpdateType_t updateType); + virtual void OnPreDataChanged(DataUpdateType_t updateType); + virtual void OnDataChanged(DataUpdateType_t updateType); + virtual void SetDormant(bool bDormant); + virtual bool IsDormant(void); + virtual int entindex(void) const; + virtual void ReceiveMessage(int classID, bf_read& msg); + virtual void* GetDataTableBasePtr(); + virtual void SetDestroyedOnRecreateEntities(void); + +public: + + void NetworkStateChanged() {} + void NetworkStateChanged(void* pVar) {} + + virtual bool Init(int entnum, int iSerialNum); + + virtual void Precache(void); + + virtual bool ShouldDestroy(void) { return false; }; + + C_BaseTempEntity* GetNext(void); + + static C_BaseTempEntity* GetList(void); + + C_BaseTempEntity* GetNextDynamic(void); + + void GetColorModulation(float* color) + { + assert(color); + color[0] = color[1] = color[2] = 1.0f; + } + + virtual bool ShouldReceiveProjectedTextures(int flags) { return false; } + +public: + static C_BaseTempEntity* GetDynamicList(); + + static void PrecacheTempEnts(void); + + static void ClearDynamicTempEnts(void); + + static void CheckDynamicTempEnts(void); + +private: + + C_BaseTempEntity* m_pNext; + C_BaseTempEntity* m_pNextDynamic; + + static C_BaseTempEntity* s_pTempEntities; + static C_BaseTempEntity* s_pDynamicEntities; +}; + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/c_input.h b/SpyCustom/sdk/c_input.h new file mode 100644 index 0000000..27d05ea --- /dev/null +++ b/SpyCustom/sdk/c_input.h @@ -0,0 +1,93 @@ +#pragma once + +#include "usercmd.h" +#define MULTIPLAYER_BACKUP 150 + +class bf_write; +class bf_read; + +class CVerifiedUserCmd +{ +public: + CUserCmd m_cmd; + CRC32_t m_crc; +}; + +class CInput +{ +public: + virtual void Init_All(void); + virtual void Shutdown_All(void); + virtual int GetButtonBits(int); + virtual void CreateMove(int sequence_number, float input_sample_frametime, bool active); + virtual void ExtraMouseSample(float frametime, bool active); + virtual bool WriteUsercmdDeltaToBuffer(bf_write* buf, int from, int to, bool isnewcommand); + virtual void EncodeUserCmdToBuffer(bf_write& buf, int slot); + virtual void DecodeUserCmdFromBuffer(bf_read& buf, int slot); + + + inline CUserCmd* GetUserCmd(int sequence_number); + inline CVerifiedUserCmd* GetVerifiedCmd(int sequence_number); + + bool m_fTrackIRAvailable; + bool m_fMouseInitialized; + bool m_fMouseActive; + bool m_fJoystickAdvancedInit; + char pad_0x08[0x2C]; + void* m_pKeys; + char pad_0x38[0x6C]; + bool m_fCameraInterceptingMouse; + bool m_fCameraInThirdPerson; + bool m_fCameraMovingWithMouse; + Vector m_vecCameraOffset; + bool m_fCameraDistanceMove; + int m_nCameraOldX; + int m_nCameraOldY; + int m_nCameraX; + int m_nCameraY; + bool m_CameraIsOrthographic; + QAngle m_angPreviousViewAngles; + QAngle m_angPreviousViewAnglesTilt; + float m_flLastForwardMove; + int m_nClearInputState; + CUserCmd* m_pCommands; + CVerifiedUserCmd* m_pVerifiedCommands; +}; + +CUserCmd* CInput::GetUserCmd(int sequence_number) +{ + return &m_pCommands[sequence_number % MULTIPLAYER_BACKUP]; +} + +CVerifiedUserCmd* CInput::GetVerifiedCmd(int sequence_number) +{ + return &m_pVerifiedCommands[sequence_number % MULTIPLAYER_BACKUP]; +} + + +#define IN_ATTACK (1 << 0) +#define IN_JUMP (1 << 1) +#define IN_DUCK (1 << 2) +#define IN_FORWARD (1 << 3) +#define IN_BACK (1 << 4) +#define IN_USE (1 << 5) +#define IN_CANCEL (1 << 6) +#define IN_LEFT (1 << 7) +#define IN_RIGHT (1 << 8) +#define IN_MOVELEFT (1 << 9) +#define IN_MOVERIGHT (1 << 10) +#define IN_ATTACK2 (1 << 11) +#define IN_RUN (1 << 12) +#define IN_RELOAD (1 << 13) +#define IN_ALT1 (1 << 14) +#define IN_ALT2 (1 << 15) +#define IN_SCORE (1 << 16) +#define IN_SPEED (1 << 17) +#define IN_WALK (1 << 18) +#define IN_ZOOM (1 << 19) +#define IN_WEAPON1 (1 << 20) +#define IN_WEAPON2 (1 << 21) +#define IN_BULLRUSH (1 << 22) +#define IN_GRENADE1 (1 << 23) +#define IN_GRENADE2 (1 << 24) +#define IN_LOOKSPIN (1 << 25) \ No newline at end of file diff --git a/SpyCustom/sdk/c_pixel_visibility.h b/SpyCustom/sdk/c_pixel_visibility.h new file mode 100644 index 0000000..be835ac --- /dev/null +++ b/SpyCustom/sdk/c_pixel_visibility.h @@ -0,0 +1,48 @@ +#ifndef C_PIXEL_VISIBILITY_H +#define C_PIXEL_VISIBILITY_H +#ifdef _WIN32 +#pragma once +#endif + + +const float PIXELVIS_DEFAULT_PROXY_SIZE = 2.0f; +const float PIXELVIS_DEFAULT_FADE_TIME = 0.0625f; + +typedef int pixelvis_handle_t; +struct pixelvis_queryparams_t +{ + pixelvis_queryparams_t() + { + bSetup = false; + } + + void Init(const Vector& origin, float proxySizeIn = PIXELVIS_DEFAULT_PROXY_SIZE, float proxyAspectIn = 1.0f, float fadeTimeIn = PIXELVIS_DEFAULT_FADE_TIME) + { + position = origin; + proxySize = proxySizeIn; + proxyAspect = proxyAspectIn; + fadeTime = fadeTimeIn; + bSetup = true; + bSizeInScreenspace = false; + } + + Vector position; + float proxySize; + float proxyAspect; + float fadeTime; + bool bSetup; + bool bSizeInScreenspace; +}; + +float PixelVisibility_FractionVisible(const pixelvis_queryparams_t& params, pixelvis_handle_t* queryHandle); +float StandardGlowBlend(const pixelvis_queryparams_t& params, pixelvis_handle_t* queryHandle, int rendermode, int renderfx, int alpha, float* pscale); + +void PixelVisibility_ShiftVisibilityViews(int iSourceViewID, int iDestViewID); + +void PixelVisibility_EndCurrentView(); +void PixelVisibility_EndScene(); +float GlowSightDistance(const Vector& glowOrigin, bool bShouldTrace); + +bool PixelVisibility_IsAvailable(); + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/c_playerlocaldata.h b/SpyCustom/sdk/c_playerlocaldata.h new file mode 100644 index 0000000..8108efa --- /dev/null +++ b/SpyCustom/sdk/c_playerlocaldata.h @@ -0,0 +1,66 @@ +#ifndef C_PLAYERLOCALDATA_H +#define C_PLAYERLOCALDATA_H +#ifdef _WIN32 +#pragma once +#endif + +#include "basetypes.h" +#include "vector.h" +#include "playernet_vars.h" +#include "interpolatedvar.h" +#include "predictable_entity.h" + +class CPlayerLocalData +{ +public: + DECLARE_PREDICTABLE(); + DECLARE_CLASS_NOBASE(CPlayerLocalData); + DECLARE_EMBEDDED_NETWORKVAR(); + + CPlayerLocalData() : + m_iv_vecPunchAngle("CPlayerLocalData::m_iv_vecPunchAngle"), + m_iv_vecPunchAngleVel("CPlayerLocalData::m_iv_vecPunchAngleVel") + { + m_iv_vecPunchAngle.Setup(&m_vecPunchAngle.m_Value, LATCH_SIMULATION_VAR); + m_iv_vecPunchAngleVel.Setup(&m_vecPunchAngleVel.m_Value, LATCH_SIMULATION_VAR); + m_flFOVRate = 0; + } + + unsigned char m_chAreaBits[MAX_AREA_STATE_BYTES]; + unsigned char m_chAreaPortalBits[MAX_AREA_PORTAL_STATE_BYTES]; + + int m_iHideHUD; + + float m_flFOVRate; + + + bool m_bDucked; + bool m_bDucking; + bool m_bInDuckJump; + float m_flDucktime; + float m_flDuckJumpTime; + float m_flJumpTime; + int m_nStepside; + float m_flFallVelocity; + int m_nOldButtons; + Vector m_vecClientBaseVelocity; + CNetworkQAngle(m_vecPunchAngle); + CInterpolatedVar< QAngle > m_iv_vecPunchAngle; + + CNetworkQAngle(m_vecPunchAngleVel); + CInterpolatedVar< QAngle > m_iv_vecPunchAngleVel; + bool m_bDrawViewmodel; + bool m_bWearingSuit; + bool m_bPoisoned; + float m_flStepSize; + bool m_bAllowAutoMovement; + + sky3dparams_t m_skybox3d; + fogplayerparams_t m_PlayerFog; + audioparams_t m_audio; + + bool m_bSlowMovement; + +}; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/c_recipientfilter.h b/SpyCustom/sdk/c_recipientfilter.h new file mode 100644 index 0000000..44d30c6 --- /dev/null +++ b/SpyCustom/sdk/c_recipientfilter.h @@ -0,0 +1,149 @@ +#ifndef C_RECIPIENTFILTER_H +#define C_RECIPIENTFILTER_H +#ifdef _WIN32 +#pragma once +#endif + +#include "irecipientfilter.h" +#include "utlvector.h" +#include "c_baseentity.h" +#include "soundflags.h" +#include "bitvec.h" + +class C_BasePlayer; +class C_Team; + +class C_RecipientFilter : public IRecipientFilter +{ +public: + C_RecipientFilter(); + virtual ~C_RecipientFilter(); + + virtual bool IsReliable(void) const; + + virtual int GetRecipientCount(void) const; + virtual int GetRecipientIndex(int slot) const; + + virtual bool IsInitMessage(void) const { return false; }; + +public: + + void CopyFrom(const C_RecipientFilter& src); + + void Reset(void); + + void MakeReliable(void); + + void AddAllPlayers(void); + void AddRecipientsByPVS(const Vector& origin); + void AddRecipientsByPAS(const Vector& origin); + void AddRecipient(C_BasePlayer* player); + void RemoveRecipient(C_BasePlayer* player); + void AddRecipientsByTeam(C_Team* team); + void RemoveRecipientsByTeam(C_Team* team); + + void UsePredictionRules(void); + bool IsUsingPredictionRules(void) const; + + bool IgnorePredictionCull(void) const; + void SetIgnorePredictionCull(bool ignore); + + void AddPlayersFromBitMask(CPlayerBitVec& playerbits); + + void RemoveSplitScreenPlayers(); + +private: + + bool m_bReliable; + bool m_bInitMessage; + CUtlVector< int > m_Recipients; + bool m_bUsingPredictionRules; + bool m_bIgnorePredictionCull; +}; + +class CSingleUserRecipientFilter : public C_RecipientFilter +{ +public: + CSingleUserRecipientFilter(C_BasePlayer* player) + { + AddRecipient(player); + } +}; + +class CBroadcastRecipientFilter : public C_RecipientFilter +{ +public: + CBroadcastRecipientFilter(void) + { + AddAllPlayers(); + } +}; + +class CReliableBroadcastRecipientFilter : public CBroadcastRecipientFilter +{ +public: + CReliableBroadcastRecipientFilter(void) + { + MakeReliable(); + } +}; + +class CPASFilter : public C_RecipientFilter +{ +public: + CPASFilter(const Vector& origin) + { + AddRecipientsByPAS(origin); + } +}; + +class CPASAttenuationFilter : public CPASFilter +{ +public: + CPASAttenuationFilter(C_BaseEntity* entity, float attenuation = ATTN_NORM) : + CPASFilter(entity->GetAbsOrigin()) + { + } + + CPASAttenuationFilter(const Vector& origin, float attenuation = ATTN_NORM) : + CPASFilter(origin) + { + } + + CPASAttenuationFilter(C_BaseEntity* entity, const char* lookupSound) : + CPASFilter(entity->GetAbsOrigin()) + { + } + + CPASAttenuationFilter(const Vector& origin, const char* lookupSound) : + CPASFilter(origin) + { + } + + CPASAttenuationFilter(C_BaseEntity* entity, const char* lookupSound, HSOUNDSCRIPTHANDLE& handle) : + CPASFilter(entity->GetAbsOrigin()) + { + } + + CPASAttenuationFilter(const Vector& origin, const char* lookupSound, HSOUNDSCRIPTHANDLE& handle) : + CPASFilter(origin) + { + } +}; + +class CPVSFilter : public C_RecipientFilter +{ +public: + CPVSFilter(const Vector& origin) + { + AddRecipientsByPVS(origin); + } +}; + +class CLocalPlayerFilter : public C_RecipientFilter +{ +public: + CLocalPlayerFilter(void); +}; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/c_te_legacytempents.h b/SpyCustom/sdk/c_te_legacytempents.h new file mode 100644 index 0000000..aa755a2 --- /dev/null +++ b/SpyCustom/sdk/c_te_legacytempents.h @@ -0,0 +1,178 @@ +#if !defined( C_TE_LEGACYTEMPENTS_H ) +#define C_TE_LEGACYTEMPENTS_H +#ifdef _WIN32 +#pragma once +#endif + +class C_BaseEntity; +class C_LocalTempEntity; +struct model_t; + +#include "mempool.h" +#include "UtlLinkedList.h" + +#include "particlemgr.h" +typedef CParticleSubTexture* PMaterialHandle; +#include "cliententitylist.h" + +#if defined( SDK_DLL ) +enum +{ + CS_SHELL_9MM = 0, + CS_SHELL_57, + CS_SHELL_12GAUGE, + CS_SHELL_556, + CS_SHELL_762NATO, + CS_SHELL_338MAG, +}; +#endif + +abstract_class ITempEnts +{ +public: + virtual ~ITempEnts() {} + + virtual void Init(void) = 0; + virtual void Shutdown(void) = 0; + virtual void LevelInit() = 0; + virtual void LevelShutdown() = 0; + + virtual void Update(void) = 0; + virtual void Clear(void) = 0; + + virtual void BloodSprite(const Vector& org, int r, int g, int b, int a, int modelIndex, int modelIndex2, float size) = 0; + virtual void RicochetSprite(const Vector& pos, model_t* pmodel, float duration, float scale) = 0; + virtual void MuzzleFlash(int type, ClientEntityHandle_t hEntity, int attachmentIndex, bool firstPerson) = 0; + virtual void MuzzleFlash(const Vector& pos1, const QAngle& angles, int type, ClientEntityHandle_t hEntity, bool firstPerson) = 0; + virtual C_LocalTempEntity* SpawnTempModel(model_t* pModel, const Vector& vecOrigin, const QAngle& vecAngles, const Vector& vecVelocity, float flLifeTime, int iFlags) = 0; + virtual void BreakModel(const Vector& pos, const QAngle& angles, const Vector& size, const Vector& dir, float random, float life, int count, int modelIndex, char flags) = 0; + virtual void Bubbles(const Vector& mins, const Vector& maxs, float height, int modelIndex, int count, float speed) = 0; + virtual void BubbleTrail(const Vector& start, const Vector& end, float flWaterZ, int modelIndex, int count, float speed) = 0; + virtual void Sprite_Explode(C_LocalTempEntity* pTemp, float scale, int flags) = 0; + virtual void FizzEffect(C_BaseEntity* pent, int modelIndex, int density, int current) = 0; + virtual C_LocalTempEntity* DefaultSprite(const Vector& pos, int spriteIndex, float framerate) = 0; + virtual void Sprite_Smoke(C_LocalTempEntity* pTemp, float scale) = 0; + virtual C_LocalTempEntity* TempSprite(const Vector& pos, const Vector& dir, float scale, int modelIndex, int rendermode, int renderfx, float a, float life, int flags, const Vector& normal = vec3_origin) = 0; + virtual void AttachTentToPlayer(int client, int modelIndex, float zoffset, float life) = 0; + virtual void KillAttachedTents(int client) = 0; + virtual void Sprite_Spray(const Vector& pos, const Vector& dir, int modelIndex, int count, int speed, int iRand) = 0; + virtual void Sprite_Trail(const Vector& vecStart, const Vector& vecEnd, int modelIndex, int nCount, float flLife, float flSize, float flAmplitude, int nRenderamt, float flSpeed) = 0; + virtual void RocketFlare(const Vector& pos) = 0; + virtual void PlaySound(C_LocalTempEntity* pTemp, float damp) = 0; + virtual void PhysicsProp(int modelindex, int skin, const Vector& pos, const QAngle& angles, const Vector& vel, int flags, int effects = 0) = 0; + virtual C_LocalTempEntity* ClientProjectile(const Vector& vecOrigin, const Vector& vecVelocity, const Vector& vecAccel, int modelindex, int lifetime, CBaseEntity* pOwner, const char* pszImpactEffect = NULL, const char* pszParticleEffect = NULL) = 0; +}; + + +class CTempEnts : public ITempEnts +{ +public: + CTempEnts(void); + virtual ~CTempEnts(void); +public: + virtual void Init(void); + virtual void Shutdown(void); + + virtual void LevelInit(); + + virtual void LevelShutdown(); + + virtual void Update(void); + virtual void Clear(void); + + virtual void BloodSprite(const Vector& org, int r, int g, int b, int a, int modelIndex, int modelIndex2, float size); + virtual void RicochetSprite(const Vector& pos, model_t* pmodel, float duration, float scale); + + virtual void MuzzleFlash(int type, ClientEntityHandle_t hEntity, int attachmentIndex, bool firstPerson); + virtual void MuzzleFlash(const Vector& pos1, const QAngle& angles, int type, ClientEntityHandle_t hEntity, bool firstPerson = false); + + virtual void BreakModel(const Vector& pos, const QAngle& angles, const Vector& size, const Vector& dir, float random, float life, int count, int modelIndex, char flags); + virtual void Bubbles(const Vector& mins, const Vector& maxs, float height, int modelIndex, int count, float speed); + virtual void BubbleTrail(const Vector& start, const Vector& end, float height, int modelIndex, int count, float speed); + virtual void Sprite_Explode(C_LocalTempEntity* pTemp, float scale, int flags); + virtual void FizzEffect(C_BaseEntity* pent, int modelIndex, int density, int current); + virtual C_LocalTempEntity* DefaultSprite(const Vector& pos, int spriteIndex, float framerate); + virtual void Sprite_Smoke(C_LocalTempEntity* pTemp, float scale); + virtual C_LocalTempEntity* TempSprite(const Vector& pos, const Vector& dir, float scale, int modelIndex, int rendermode, int renderfx, float a, float life, int flags, const Vector& normal = vec3_origin); + virtual void AttachTentToPlayer(int client, int modelIndex, float zoffset, float life); + virtual void KillAttachedTents(int client); + virtual void Sprite_Spray(const Vector& pos, const Vector& dir, int modelIndex, int count, int speed, int iRand); + void Sprite_Trail(const Vector& vecStart, const Vector& vecEnd, int modelIndex, int nCount, float flLife, float flSize, float flAmplitude, int nRenderamt, float flSpeed); + + virtual void PlaySound(C_LocalTempEntity* pTemp, float damp); + virtual C_LocalTempEntity* SpawnTempModel(model_t* pModel, const Vector& vecOrigin, const QAngle& vecAngles, const Vector& vecVelocity, float flLifeTime, int iFlags); + void RocketFlare(const Vector& pos); + void PhysicsProp(int modelindex, int skin, const Vector& pos, const QAngle& angles, const Vector& vel, int flags, int effects = 0); + C_LocalTempEntity* ClientProjectile(const Vector& vecOrigin, const Vector& vecVelocity, const Vector& vecAcceleration, int modelindex, int lifetime, CBaseEntity* pOwner, const char* pszImpactEffect = NULL, const char* pszParticleEffect = NULL); + +private: + enum + { + MAX_TEMP_ENTITIES = 500, + MAX_TEMP_ENTITY_SPRITES = 200, + MAX_TEMP_ENTITY_STUDIOMODEL = 50, + }; + + CClassMemoryPool< C_LocalTempEntity > m_TempEntsPool; + CUtlLinkedList< C_LocalTempEntity*, unsigned short > m_TempEnts; + + struct model_t* m_pSpriteMuzzleFlash[10]; + struct model_t* m_pSpriteAR2Flash[4]; + struct model_t* m_pShells[3]; + struct model_t* m_pSpriteCombineFlash[2]; + +#if defined ( SDK_DLL ) + struct model_t* m_pCS_9MMShell; + struct model_t* m_pCS_57Shell; + struct model_t* m_pCS_12GaugeShell; + struct model_t* m_pCS_556Shell; + struct model_t* m_pCS_762NATOShell; + struct model_t* m_pCS_338MAGShell; +#endif + +protected: + C_LocalTempEntity* TempEntAlloc(const Vector& org, model_t* model); + C_LocalTempEntity* TempEntAllocHigh(const Vector& org, model_t* model); + +private: + + inline void CacheMuzzleFlashes(void); + PMaterialHandle m_Material_MuzzleFlash_Player[4]; + PMaterialHandle m_Material_MuzzleFlash_NPC[4]; + PMaterialHandle m_Material_Combine_MuzzleFlash_Player[2]; + PMaterialHandle m_Material_Combine_MuzzleFlash_NPC[2]; + +private: + CTempEnts(const CTempEnts&); + + void TempEntFree(int index); + C_LocalTempEntity* TempEntAlloc(); + bool FreeLowPriorityTempEnt(); + + int AddVisibleTempEntity(C_LocalTempEntity* pEntity); + + void MuzzleFlash_AR2_Player(const Vector& origin, const QAngle& angles, ClientEntityHandle_t hEntity); + void MuzzleFlash_AR2_NPC(const Vector& origin, const QAngle& angles, ClientEntityHandle_t hEntity); + + void MuzzleFlash_SMG1_Player(ClientEntityHandle_t hEntity, int attachmentIndex); + void MuzzleFlash_SMG1_NPC(ClientEntityHandle_t hEntity, int attachmentIndex); + + void MuzzleFlash_Shotgun_Player(ClientEntityHandle_t hEntity, int attachmentIndex); + void MuzzleFlash_Shotgun_NPC(ClientEntityHandle_t hEntity, int attachmentIndex); + + void MuzzleFlash_Pistol_Player(ClientEntityHandle_t hEntity, int attachmentIndex); + void MuzzleFlash_Pistol_NPC(ClientEntityHandle_t hEntity, int attachmentIndex); + + void MuzzleFlash_Combine_Player(ClientEntityHandle_t hEntity, int attachmentIndex); + void MuzzleFlash_Combine_NPC(ClientEntityHandle_t hEntity, int attachmentIndex); + + void MuzzleFlash_357_Player(ClientEntityHandle_t hEntity, int attachmentIndex); + + void MuzzleFlash_RPG_NPC(ClientEntityHandle_t hEntity, int attachmentIndex); +}; + + +extern ITempEnts* tempents; + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/cdll_client_int.h b/SpyCustom/sdk/cdll_client_int.h new file mode 100644 index 0000000..c697a01 --- /dev/null +++ b/SpyCustom/sdk/cdll_client_int.h @@ -0,0 +1,271 @@ +#ifndef CDLL_CLIENT_INT_H +#define CDLL_CLIENT_INT_H +#ifdef _WIN32 +#pragma once +#endif + +#include "iclientnetworkable.h" +#include "utllinkedlist.h" +#include "cdll_int.h" +#include "shareddefs.h" +#include "eiface.h" +#include "tier3.h" +#include "tier2_logging.h" + +#include "shareddefs.h" + + +class IVModelRender; +class IVEngineClient; +class IVModelRender; +class IVEfx; +class IVRenderView; +class IVDebugOverlay; +class IMaterialSystem; +class IMaterialSystemStub; +class IDataCache; +class IMDLCache; +class IVModelInfoClient; +class IEngineVGui; +class ISpatialPartition; +class IBaseClientDLL; +class ISpatialPartition; +class IFileSystem; +class IStaticPropMgrClient; +class IShadowMgr; +class IEngineSound; +class IMatSystemSurface; +class IMaterialSystemHardwareConfig; +class ISharedGameRules; +class IEngineTrace; +class IGameUIFuncs; +class IGameEventManager2; +class IPhysicsGameTrace; +class CGlobalVarsBase; +class IClientTools; +class C_BaseAnimating; +class IColorCorrectionSystem; +class IInputSystem; +class ISceneFileCache; +class IXboxSystem; +class IAvi; +class IBik; +class CSteamAPIContext; +class IReplayHistoryManager; +class ISoundEmitterSystemBase; +enum CPULevel_t; +enum GPULevel_t; + +extern IVModelRender* modelrender; +extern IVEngineClient* engine; +extern IVModelRender* modelrender; +extern IVEfx* effects; +extern IVRenderView* render; +extern IVDebugOverlay* debugoverlay; +extern IMaterialSystemStub* materials_stub; +extern IVModelInfoClient* modelinfo; +extern IEngineVGui* enginevgui; +extern ISpatialPartition* partition; +extern IBaseClientDLL* clientdll; +extern IFileSystem* filesystem; +extern IStaticPropMgrClient* staticpropmgr; +extern IShadowMgr* shadowmgr; +extern IEngineSound* enginesound; +extern IEngineTrace* enginetrace; +extern IFileLoggingListener* filelogginglistener; +extern IGameUIFuncs* gameuifuncs; +extern IGameEventManager2* gameeventmanager; +extern IPhysicsGameTrace* physgametrace; +extern CGlobalVarsBase* gpGlobals; +extern IClientTools* clienttools; +extern IInputSystem* inputsystem; +extern ISceneFileCache* scenefilecache; +extern IXboxSystem* xboxsystem; +extern IAvi* avi; +extern IBik* bik; +extern IUploadGameStats* gamestatsuploader; +extern CSteamAPIContext* steamapicontext; +extern ISoundEmitterSystemBase* soundemitterbase; + +#ifdef INFESTED_DLL +class IASW_Mission_Chooser; +extern IASW_Mission_Chooser* missionchooser; +#endif +#if defined( REPLAY_ENABLED ) +extern IReplayHistoryManager* g_pReplayHistoryManager; +#endif + +CPULevel_t GetCPULevel(); +CPULevel_t GetActualCPULevel(); +GPULevel_t GetGPULevel(); +void ConfigureCurrentSystemLevel(); + +extern bool g_bLevelInitialized; +extern bool g_bTextMode; +extern bool g_bEngineIsHLTV; + +bool AddDataChangeEvent(IClientNetworkable* ent, DataUpdateType_t updateType, int* pStoredEvent); + +void ClearDataChangedEvent(int iStoredEvent); + +void PrecacheMaterial(const char* pMaterialName); + +int GetMaterialIndex(const char* pMaterialName); + +const char* GetMaterialNameFromIndex(int nIndex); + +int PrecacheParticleSystem(const char* pParticleSystemName); +int GetParticleSystemIndex(const char* pParticleSystemName); +const char* GetParticleSystemNameFromIndex(int nIndex); + + +void PrecacheEffect(const char* pEffectName); + + +void TrackBoneSetupEnt(C_BaseAnimating* pEnt); + +bool IsEngineThreaded(); + +class CVGuiScreenSizeSplitScreenPlayerGuard +{ +public: + CVGuiScreenSizeSplitScreenPlayerGuard(bool bActive, int slot, int nOldSlot); + CVGuiScreenSizeSplitScreenPlayerGuard(bool bActive, C_BaseEntity* pEntity, int nOldSlot); + ~CVGuiScreenSizeSplitScreenPlayerGuard(); +private: + + bool m_bNoRestore; + bool m_bOldSetting; + int m_nOldSize[2]; +}; + +class CSetActiveSplitScreenPlayerGuard : public CVGuiScreenSizeSplitScreenPlayerGuard +{ +public: + CSetActiveSplitScreenPlayerGuard(char const* pchContext, int nLine, int slot, int nOldSlot, bool bSetVguiScreenSize); + CSetActiveSplitScreenPlayerGuard(char const* pchContext, int nLine, C_BaseEntity* pEntity, int nOldSlot, bool bSetVguiScreenSize); + ~CSetActiveSplitScreenPlayerGuard(); +private: + bool m_bChanged; + char const* m_pchContext; + int m_nLine; + int m_nSaveSlot; + bool m_bSaveGetLocalPlayerAllowed; +}; + +class CHackForGetLocalPlayerAccessAllowedGuard +{ +public: + CHackForGetLocalPlayerAccessAllowedGuard(char const* pszContext, bool bOldSlot); + ~CHackForGetLocalPlayerAccessAllowedGuard(); +private: + bool m_bChanged; + char const* m_pszContext; + bool m_bSaveGetLocalPlayerAllowed; +}; + +class CVGuiAbsPosSplitScreenPlayerGuard +{ +public: + CVGuiAbsPosSplitScreenPlayerGuard(int slot, int nOldSlot, bool bInvert = false); + ~CVGuiAbsPosSplitScreenPlayerGuard(); +private: + bool m_bNoRestore; +}; + +int FirstValidSplitScreenSlot(); +int NextValidSplitScreenSlot(int i); +bool IsValidSplitScreenSlot(int i); +void IterateRemoteSplitScreenViewSlots_Push(bool bSet); +void IterateRemoteSplitScreenViewSlots_Pop(void); +class C_BasePlayer; +void AddRemoteSplitScreenViewPlayer(C_BasePlayer* pPlayer); +void RemoveRemoteSplitScreenViewPlayer(C_BasePlayer* pPlayer); +C_BasePlayer* GetSplitScreenViewPlayer(int nSlot); +bool IsLocalSplitScreenPlayer(int nSlot); + +#if defined( SPLIT_SCREEN_STUBS ) + +#define VGUI_SCREENSIZE_SPLITSCREEN_GUARD( slot ) +#define ACTIVE_SPLITSCREEN_PLAYER_GUARD( slot ) +#define ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( entity ) + +#define ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( slot ) +#define ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT_VGUI( entity ) + +#define HACK_GETLOCALPLAYER_GUARD( desc ) +#define VGUI_ABSPOS_SPLITSCREEN_GUARD( slot ) +#define VGUI_ABSPOS_SPLITSCREEN_GUARD_INVERT( slot ) + +#define FOR_EACH_VALID_SPLITSCREEN_PLAYER( iteratorName ) for ( int iteratorName = 0; iteratorName == 0; ++iteratorName ) + +#define ASSERT_LOCAL_PLAYER_RESOLVABLE() +#define ASSERT_LOCAL_PLAYER_NOT_RESOLVABLE() +#define GET_ACTIVE_SPLITSCREEN_SLOT() ( 0 ) + +FORCEINLINE uint32 ComputeSplitscreenRenderingFlags(IClientRenderable* pRenderable) +{ + return 0xFFFFFFFF; +} + +#else + +#define VGUI_SCREENSIZE_SPLITSCREEN_GUARD( slot ) CVGuiScreenSizeSplitScreenPlayerGuard s_VGuiSSGuard( slot, engine->GetActiveSplitScreenPlayerSlot() ); +#define ACTIVE_SPLITSCREEN_PLAYER_GUARD( slot ) CSetActiveSplitScreenPlayerGuard g_SSGuard( __FILE__, __LINE__, slot, engine->GetActiveSplitScreenPlayerSlot(), false ); +#define ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( entity ) CSetActiveSplitScreenPlayerGuard g_SSEGuard( __FILE__, __LINE__, entity, engine->GetActiveSplitScreenPlayerSlot(), false ); + +#define ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( slot ) CSetActiveSplitScreenPlayerGuard g_SSGuardNoVgui( __FILE__, __LINE__, slot, engine->GetActiveSplitScreenPlayerSlot(), true ); +#define ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT_VGUI( entity ) CSetActiveSplitScreenPlayerGuard g_SSEGuardNoVgui( __FILE__, __LINE__, entity, engine->GetActiveSplitScreenPlayerSlot(), true ); + + +#define HACK_GETLOCALPLAYER_GUARD( desc ) CHackForGetLocalPlayerAccessAllowedGuard g_HackGLPGuard( desc, engine->IsLocalPlayerResolvable() ); +#define VGUI_ABSPOS_SPLITSCREEN_GUARD( slot ) CVGuiAbsPosSplitScreenPlayerGuard s_VGuiAbsPosGuard( slot, engine->GetActiveSplitScreenPlayerSlot() ); +#define VGUI_ABSPOS_SPLITSCREEN_GUARD_INVERT( slot ) CVGuiAbsPosSplitScreenPlayerGuard s_VGuiAbsPosGuard( slot, engine->GetActiveSplitScreenPlayerSlot(), true ); + +#define FOR_EACH_VALID_SPLITSCREEN_PLAYER( iteratorName ) \ + for ( int iteratorName = FirstValidSplitScreenSlot(); \ + iteratorName != -1; \ + iteratorName = NextValidSplitScreenSlot( iteratorName ) ) + +#if defined( SS_SHIPPING_ASSERTS ) +#define ASSERT_LOCAL_PLAYER_RESOLVABLE() _AssertMsg( engine->IsLocalPlayerResolvable(), _T("Assertion Failed: ") _T("engine->IsLocalPlayerResolvable()"), ((void)0), false ) +#else +#define ASSERT_LOCAL_PLAYER_RESOLVABLE() Assert( engine->IsLocalPlayerResolvable() ); +#endif + +#if defined( SS_SHIPPING_ASSERTS ) +#define ASSERT_LOCAL_PLAYER_NOT_RESOLVABLE() _AssertMsg( !engine->IsLocalPlayerResolvable(), _T("Assertion Failed: ") _T("!engine->IsLocalPlayerResolvable()"), ((void)0), false ) +#else +#define ASSERT_LOCAL_PLAYER_NOT_RESOLVABLE() Assert( !engine->IsLocalPlayerResolvable() ); +#endif + +#define GET_ACTIVE_SPLITSCREEN_SLOT() engine->GetActiveSplitScreenPlayerSlot() + +FORCEINLINE uint32 ComputeSplitscreenRenderingFlags(IClientRenderable* pRenderable) +{ + if (IsSplitScreenSupported()) + { + int nFlags = 0; + for (int i = 0; i < MAX_SPLITSCREEN_PLAYERS; ++i) + { + if (pRenderable->ShouldDrawForSplitScreenUser(i)) + { + nFlags |= 1 << i; + } + } + return nFlags; + } + + return 0xFFFFFFFF; +} + +#endif + +inline C_BasePlayer* GetSplitScreenViewPlayer(void) { return GetSplitScreenViewPlayer(GET_ACTIVE_SPLITSCREEN_SLOT()); }; +inline bool IsLocalSplitScreenPlayer(void) { return IsLocalSplitScreenPlayer(GET_ACTIVE_SPLITSCREEN_SLOT()); }; + +int XBX_GetActiveUserId(); + +#define XBX_GetPrimaryUserId() _Use_XBX_GetActiveUserId_Instead + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/cdll_int.h b/SpyCustom/sdk/cdll_int.h new file mode 100644 index 0000000..4f86c22 --- /dev/null +++ b/SpyCustom/sdk/cdll_int.h @@ -0,0 +1,632 @@ +#ifndef CDLL_INT_H +#define CDLL_INT_H +#ifdef _WIN32 +#pragma once +#endif + +#include "sdk/basetypes.h" +#include "sdk/interface.h" +#include "sdk/mathlib.h" +#include "sdk/const.h" +#include "sdk/checksum_crc.h" +#include "sdk/datamap.h" +#include "sdk/bitbuf.h" +#include "sdk/ButtonCode.h" +#include "sdk/modes.h" + +#if !defined( _X360 ) +#include "sdk/xboxstubs.h" +#endif + +#include "sdk/jobthread.h" +#include "sdk/VGUI.h" + +struct SpatializationInfo_t; +class IClientEntity; + +class ClientClass; +struct model_t; +class CSentence; +struct vrect_t; +struct cmodel_t; +class IMaterial; +class CAudioSource; +class CMeasureSection; +class SurfInfo; +class ISpatialQuery; +struct cache_user_t; +class IMaterialSystem; +class VMatrix; +struct ScreenFade_t; +struct ScreenShake_t; +class CViewSetup; +class CEngineSprite; +class CGlobalVarsBase; +class CPhysCollide; +class CSaveRestoreData; +class INetChannelInfo; +struct datamap_t; +struct typedescription_t; +class CStandardRecvProxies; +struct client_textmessage_t; +class IAchievementMgr; +class CGamestatsData; +class KeyValues; +class IFileList; +class CRenamedRecvTableInfo; +class CMouthInfo; +class IConVar; + +struct player_info_t +{ +public: + char __pad0[0x8]; + union { + long long xuid; + struct { + int xuidlow; + int xuidhigh; + }; + }; + char name[128]; + int userid; + char guid[33]; + unsigned int friendsid; + char friendsname[128]; + bool fakeplayer; + bool ishltv; + unsigned int customfiles[4]; + unsigned char filesdownloaded; +}; + +struct AudioState_t +{ + Vector m_Origin; + QAngle m_Angles; + bool m_bIsUnderwater; +}; + + +enum SkyboxVisibility_t +{ + SKYBOX_NOT_VISIBLE = 0, + SKYBOX_3DSKYBOX_VISIBLE, + SKYBOX_2DSKYBOX_VISIBLE, +}; + +struct SkyBoxMaterials_t +{ + IMaterial* material[6]; +}; + +enum ClientFrameStage_t +{ + FRAME_UNDEFINED = -1, + FRAME_START, + + FRAME_NET_UPDATE_START, + FRAME_NET_UPDATE_POSTDATAUPDATE_START, + FRAME_NET_UPDATE_POSTDATAUPDATE_END, + FRAME_NET_UPDATE_END, + + FRAME_RENDER_START, + FRAME_RENDER_END +}; + +enum RenderViewInfo_t +{ + RENDERVIEW_UNSPECIFIED = 0, + RENDERVIEW_DRAWVIEWMODEL = (1 << 0), + RENDERVIEW_DRAWHUD = (1 << 1), + RENDERVIEW_SUPPRESSMONITORRENDERING = (1 << 2), +}; + +DECLARE_POINTER_HANDLE(LightCacheHandle_t); + + +struct OcclusionParams_t +{ + float m_flMaxOccludeeArea; + float m_flMinOccluderArea; +}; + + +#define VENGINE_CLIENT_RANDOM_INTERFACE_VERSION "VEngineRandom001" + +#define VENGINE_CLIENT_INTERFACE_VERSION "VEngineClient014" +#define VENGINE_CLIENT_INTERFACE_VERSION_13 "VEngineClient013" + +abstract_class IVEngineClient013 +{ +public: + virtual int GetIntersectingSurfaces( + const model_t * model, + const Vector & vCenter, + const float radius, + const bool bOnlyVisibleSurfaces, + SurfInfo * pInfos, + const int nMaxInfos) = 0; + + virtual Vector GetLightForPoint(const Vector& pos, bool bClamp) = 0; + + virtual IMaterial* TraceLineMaterialAndLighting(const Vector& start, const Vector& end, + Vector& diffuseLightColor, Vector& baseColor) = 0; + + virtual const char* ParseFile(const char* data, char* token, int maxlen) = 0; + virtual bool CopyLocalFile(const char* source, const char* destination) = 0; + + virtual void GetScreenSize(int& width, int& height) = 0; + + virtual void ServerCmd(const char* szCmdString, bool bReliable = true) = 0; + virtual void ClientCmd(const char* szCmdString) = 0; + + virtual bool GetPlayerInfo(int ent_num, player_info_t* pinfo) = 0; + + virtual int GetPlayerForUserID(int userID) = 0; + + virtual client_textmessage_t* TextMessageGet(const char* pName) = 0; + + virtual bool Con_IsVisible(void) = 0; + + virtual int GetLocalPlayer(void) = 0; + + virtual const model_t* LoadModel(const char* pName, bool bProp = false) = 0; + + virtual float GetLastTimeStamp(void) = 0; + + virtual CSentence* GetSentence(CAudioSource* pAudioSource) = 0; + virtual float GetSentenceLength(CAudioSource* pAudioSource) = 0; + virtual bool IsStreaming(CAudioSource* pAudioSource) const = 0; + + virtual void GetViewAngles(Vector& va) = 0; + virtual void SetViewAngles(QAngle& va) = 0; + + virtual int GetMaxClients(void) = 0; + + virtual const char* Key_LookupBinding(const char* pBinding) = 0; + + virtual const char* Key_BindingForKey(ButtonCode_t code) = 0; + + virtual void Key_SetBinding(ButtonCode_t code, const char* pBinding) = 0; + + virtual void StartKeyTrapMode(void) = 0; + virtual bool CheckDoneKeyTrapping(ButtonCode_t& code) = 0; + + virtual bool IsInGame(void) = 0; + virtual bool IsConnected(void) = 0; + virtual bool IsDrawingLoadingImage(void) = 0; + + virtual void HideLoadingPlaque(void) = 0; + + virtual void Con_NPrintf(int pos, PRINTF_FORMAT_STRING const char* fmt, ...) = 0; + virtual void Con_NXPrintf(const struct con_nprint_s* info, PRINTF_FORMAT_STRING const char* fmt, ...) = 0; + + virtual int IsBoxVisible(const Vector& mins, const Vector& maxs) = 0; + + virtual int IsBoxInViewCluster(const Vector& mins, const Vector& maxs) = 0; + + virtual bool CullBox(const Vector& mins, const Vector& maxs) = 0; + + virtual void Sound_ExtraUpdate(void) = 0; + +#if defined(_PS3) + virtual void Sound_ServerUpdateSoundsPS3(void) = 0; +#endif + + virtual const char* GetGameDirectory(void) = 0; + + virtual const VMatrix& WorldToScreenMatrix() = 0; + + virtual const VMatrix& WorldToViewMatrix() = 0; + + virtual int GameLumpVersion(int lumpId) const = 0; + virtual int GameLumpSize(int lumpId) const = 0; + virtual bool LoadGameLump(int lumpId, void* pBuffer, int size) = 0; + + virtual int LevelLeafCount() const = 0; + + virtual ISpatialQuery* GetBSPTreeQuery() = 0; + + virtual void LinearToGamma(float* linear, float* gamma) = 0; + + virtual float LightStyleValue(int style) = 0; + + virtual void ComputeDynamicLighting(const Vector& pt, const Vector* pNormal, Vector& color) = 0; + + virtual void GetAmbientLightColor(Vector& color) = 0; + + virtual int GetDXSupportLevel() = 0; + + virtual bool SupportsHDR() = 0; + + virtual void Mat_Stub(IMaterialSystem* pMatSys) = 0; + + virtual void GetChapterName(char* pchBuff, int iMaxLength) = 0; + virtual char const* GetLevelName(void) = 0; + virtual char const* GetLevelNameShort(void) = 0; + virtual char const* GetMapGroupName(void) = 0; +#if !defined( NO_VOICE ) + virtual struct IVoiceTweak_s* GetVoiceTweakAPI(void) = 0; + virtual void SetVoiceCasterID(uint32 casterID) = 0; +#endif + virtual void EngineStats_BeginFrame(void) = 0; + virtual void EngineStats_EndFrame(void) = 0; + + virtual void FireEvents() = 0; + + virtual int GetLeavesArea(int* pLeaves, int nLeaves) = 0; + + virtual bool DoesBoxTouchAreaFrustum(const Vector& mins, const Vector& maxs, int iArea) = 0; + virtual int GetFrustumList(Frustum_t** pList, int listMax) = 0; + virtual bool ShouldUseAreaFrustum(int area) = 0; + + virtual void SetAudioState(const AudioState_t& state) = 0; + + virtual int SentenceGroupPick(int groupIndex, char* name, int nameBufLen) = 0; + virtual int SentenceGroupPickSequential(int groupIndex, char* name, int nameBufLen, int sentenceIndex, int reset) = 0; + virtual int SentenceIndexFromName(const char* pSentenceName) = 0; + virtual const char* SentenceNameFromIndex(int sentenceIndex) = 0; + virtual int SentenceGroupIndexFromName(const char* pGroupName) = 0; + virtual const char* SentenceGroupNameFromIndex(int groupIndex) = 0; + virtual float SentenceLength(int sentenceIndex) = 0; + + virtual void ComputeLighting(const Vector& pt, const Vector* pNormal, bool bClamp, Vector& color, Vector* pBoxColors = NULL) = 0; + + virtual void ActivateOccluder(int nOccluderIndex, bool bActive) = 0; + virtual bool IsOccluded(const Vector& vecAbsMins, const Vector& vecAbsMaxs) = 0; + virtual int GetOcclusionViewId() const = 0; + + virtual void* SaveAllocMemory(size_t num, size_t size) = 0; + virtual void SaveFreeMemory(void* pSaveMem) = 0; + + virtual INetChannelInfo* GetNetChannelInfo(void) = 0; + + virtual void DebugDrawPhysCollide(const CPhysCollide* pCollide, IMaterial* pMaterial, matrix3x4_t& transform, const color32& color) = 0; + virtual void CheckPoint(const char* pName) = 0; + virtual void DrawPortals() = 0; + virtual bool IsPlayingDemo(void) = 0; + virtual bool IsRecordingDemo(void) = 0; + virtual bool IsPlayingTimeDemo(void) = 0; + virtual int GetDemoRecordingTick(void) = 0; + virtual int GetDemoPlaybackTick(void) = 0; + virtual int GetDemoPlaybackStartTick(void) = 0; + virtual float GetDemoPlaybackTimeScale(void) = 0; + virtual int GetDemoPlaybackTotalTicks(void) = 0; + virtual bool IsPaused(void) = 0; + virtual float GetTimescale(void) const = 0; + virtual bool IsTakingScreenshot(void) = 0; + virtual bool IsHLTV(void) = 0; + virtual bool IsLevelMainMenuBackground(void) = 0; + virtual void GetMainMenuBackgroundName(char* dest, int destlen) = 0; + + virtual void SetOcclusionParameters(const OcclusionParams_t& params) = 0; + + virtual void GetUILanguage(char* dest, int destlen) = 0; + + virtual SkyboxVisibility_t IsSkyboxVisibleFromPoint(const Vector& vecPoint) = 0; + + virtual const char* GetMapEntitiesString() = 0; + + virtual bool IsInEditMode(void) = 0; + + virtual float GetScreenAspectRatio() = 0; + + virtual bool REMOVED_SteamRefreshLogin(const char* password, bool isSecure) = 0; + virtual bool REMOVED_SteamProcessCall(bool& finished) = 0; + + virtual unsigned int GetEngineBuildNumber() = 0; + virtual const char* GetProductVersionString() = 0; + + virtual void GrabPreColorCorrectedFrame(int x, int y, int width, int height) = 0; + + virtual bool IsHammerRunning() const = 0; + + virtual void ExecuteClientCmd(const char* szCmdString) = 0; + + virtual bool MapHasHDRLighting(void) = 0; + virtual bool MapHasLightMapAlphaData(void) = 0; + + virtual int GetAppID() = 0; + + virtual Vector GetLightForPointFast(const Vector& pos, bool bClamp) = 0; + + virtual void ClientCmd_Unrestricted(const char* szCmdString, bool fromConsoleOrKeybind = false) = 0; + virtual void ClientCmd_Unrestricted(const char* szCmdString, bool fromConsoleOrKeybind, int nUserSlot, bool bCheckValidSlot = true) = 0; + + virtual void SetRestrictServerCommands(bool bRestrict) = 0; + + virtual void SetRestrictClientCommands(bool bRestrict) = 0; + + virtual void SetOverlayBindProxy(int iOverlayID, void* pBindProxy) = 0; + + virtual bool CopyFrameBufferToMaterial(const char* pMaterialName) = 0; + + virtual void ChangeTeam(const char* pTeamName) = 0; + + virtual void ReadConfiguration(const bool readDefault = false) = 0; + + virtual void SetAchievementMgr(IAchievementMgr* pAchievementMgr) = 0; + virtual IAchievementMgr* GetAchievementMgr() = 0; + + virtual bool MapLoadFailed(void) = 0; + virtual void SetMapLoadFailed(bool bState) = 0; + + virtual bool IsLowViolence() = 0; + virtual const char* GetMostRecentSaveGame(void) = 0; + virtual void SetMostRecentSaveGame(const char* lpszFilename) = 0; + + virtual void StartXboxExitingProcess() = 0; + virtual bool IsSaveInProgress() = 0; + virtual uint OnStorageDeviceAttached(void) = 0; + virtual void OnStorageDeviceDetached(void) = 0; + + virtual void ResetDemoInterpolation(void) = 0; + + virtual void SetGamestatsData(CGamestatsData* pGamestatsData) = 0; + virtual CGamestatsData* GetGamestatsData() = 0; + +#if defined( USE_SDL ) + virtual void GetMouseDelta(int& x, int& y, bool bIgnoreNextMouseDelta = false) = 0; +#endif + + virtual void ServerCmdKeyValues(KeyValues* pKeyValues) = 0; + + virtual bool IsSkippingPlayback(void) = 0; + virtual bool IsLoadingDemo(void) = 0; + + virtual bool IsPlayingDemoALocallyRecordedDemo() = 0; + + virtual const char* Key_LookupBindingExact(const char* pBinding) = 0; + + virtual void AddPhonemeFile(const char* pszPhonemeFile) = 0; + +}; + +abstract_class IVEngineClient : public IVEngineClient013 +{ +public: + virtual uint GetProtocolVersion() = 0; + virtual bool IsWindowedMode() = 0; + + virtual void FlashWindow() = 0; + + virtual int GetClientVersion() const = 0; + + virtual bool IsActiveApp() = 0; + + virtual void DisconnectInternal() = 0; + + virtual int GetInstancesRunningCount() = 0; +}; + + +abstract_class IBaseClientDLL +{ +public: + virtual int Connect(CreateInterfaceFn appSystemFactory, CGlobalVarsBase * pGlobals) = 0; + virtual void Disconnect() = 0; + + virtual int Init(CreateInterfaceFn appSystemFactory, CGlobalVarsBase* pGlobals) = 0; + + virtual void PostInit() = 0; + + virtual void Shutdown(void) = 0; + + virtual void LevelInitPreEntity(char const* pMapName) = 0; + virtual void LevelInitPostEntity() = 0; + virtual void LevelShutdown(void) = 0; + + virtual ClientClass* GetAllClasses(void) = 0; + + virtual int HudVidInit(void) = 0; + virtual void HudProcessInput(bool bActive) = 0; + virtual void HudUpdate(bool bActive) = 0; + virtual void HudReset(void) = 0; + virtual void HudText(const char* message) = 0; + + virtual bool ShouldDrawDropdownConsole() = 0; + + virtual void IN_ActivateMouse(void) = 0; + virtual void IN_DeactivateMouse(void) = 0; + virtual void IN_Accumulate(void) = 0; + virtual void IN_ClearStates(void) = 0; + virtual bool IN_IsKeyDown(const char* name, bool& isdown) = 0; + virtual int IN_KeyEvent(int eventcode, ButtonCode_t keynum, const char* pszCurrentBinding) = 0; + + virtual void CreateMove( + int sequence_number, + float input_sample_frametime, + bool active) = 0; + + virtual void ExtraMouseSample(float frametime, bool active) = 0; + + virtual bool WriteUsercmdDeltaToBuffer(int nSlot, bf_write* buf, int from, int to, bool isnewcommand) = 0; + virtual void EncodeUserCmdToBuffer(int nSlot, bf_write& buf, int slot) = 0; + virtual void DecodeUserCmdFromBuffer(int nSlot, bf_read& buf, int slot) = 0; + + virtual void View_Render(vrect_t* rect) = 0; + + virtual void RenderView(const CViewSetup& view, int nClearFlags, int whatToDraw) = 0; + + virtual void View_Fade(ScreenFade_t* pSF) = 0; + + virtual void SetCrosshairAngle(const QAngle& angle) = 0; + + virtual void InitSprite(CEngineSprite* pSprite, const char* loadname) = 0; + virtual void ShutdownSprite(CEngineSprite* pSprite) = 0; + virtual int GetSpriteSize(void) const = 0; + + virtual void VoiceStatus(int entindex, int iSsSlot, qboolean bTalking) = 0; + + virtual bool PlayerAudible(int iPlayerIndex) = 0; + + virtual void InstallStringTableCallback(char const* tableName) = 0; + + virtual void FrameStageNotify(ClientFrameStage_t curStage) = 0; + + virtual bool DispatchUserMessage(int msg_type, int32 nFlags, int size, const void* msg) = 0; + + virtual CSaveRestoreData* SaveInit(int size) = 0; + virtual void SaveWriteFields(CSaveRestoreData*, const char*, void*, datamap_t*, typedescription_t*, int) = 0; + virtual void SaveReadFields(CSaveRestoreData*, const char*, void*, datamap_t*, typedescription_t*, int) = 0; + virtual void PreSave(CSaveRestoreData*) = 0; + virtual void Save(CSaveRestoreData*) = 0; + virtual void WriteSaveHeaders(CSaveRestoreData*) = 0; + virtual void ReadRestoreHeaders(CSaveRestoreData*) = 0; + virtual void Restore(CSaveRestoreData*, bool) = 0; + virtual void DispatchOnRestore() = 0; + + virtual CStandardRecvProxies* GetStandardRecvProxies() = 0; + + virtual void WriteSaveGameScreenshot(const char* pFilename) = 0; + + virtual void EmitSentenceCloseCaption(char const* tokenstream) = 0; + virtual void EmitCloseCaption(char const* captionname, float duration) = 0; + + virtual bool CanRecordDemo(char* errorMsg, int length) const = 0; + + virtual void OnDemoRecordStart(char const* pDemoBaseName) = 0; + virtual void OnDemoRecordStop() = 0; + virtual void OnDemoPlaybackStart(char const* pDemoBaseName) = 0; + virtual void OnDemoPlaybackRestart() = 0; + virtual void OnDemoPlaybackStop() = 0; + virtual void SetDemoPlaybackHighlightXuid(uint64 xuid, bool bLowlights) = 0; + virtual void ShowHighlightSkippingMessage(bool bState, int nCurrentTick = 0, int nTickStart = 0, int nTickStop = 0) = 0; + + virtual void RecordDemoPolishUserInput(int nCmdIndex) = 0; + + virtual bool CacheReplayRagdolls(const char* pFilename, int nStartTick) = 0; + + virtual void ReplayUI_SendMessage(KeyValues* pMsg) = 0; + + virtual void* GetReplayFactory() = 0; + + virtual void ClearLocalPlayerReplayPtr() = 0; + + virtual void unk(); + + virtual int GetScreenWidth() = 0; + virtual int GetScreenHeight() = 0; + + virtual void WriteSaveGameScreenshotOfSize(const char* pFilename, int width, int height, bool bCreatePowerOf2Padded = false, bool bWriteVTF = false) = 0; + + virtual void WriteReplayScreenshot(void* params) = 0; + + virtual void UpdateReplayScreenshotCache() = 0; + + virtual bool GetPlayerView(CViewSetup& playerView) = 0; + + virtual bool ShouldHideLoadingPlaque(void) = 0; + + virtual void InvalidateMdlCache() = 0; + + virtual void IN_SetSampleTime(float frametime) = 0; + + virtual void OnActiveSplitscreenPlayerChanged(int nNewSlot) = 0; + virtual void OnSplitScreenStateChanged() = 0; + + virtual int GetSpectatorTarget(void* pObserverMode) = 0; + + virtual void CenterStringOff() = 0; + + virtual void OnScreenSizeChanged(int nOldWidth, int nOldHeight) = 0; + + virtual void* InstantiateMaterialProxy(const char* proxyName) = 0; + + virtual vgui::VPANEL GetFullscreenClientDLLVPanel(void) = 0; + + virtual void MarkEntitiesAsTouching(IClientEntity* e1, IClientEntity* e2) = 0; + + virtual void OnKeyBindingChanged(ButtonCode_t buttonCode, char const* pchKeyName, char const* pchNewBinding) = 0; + + virtual void SetBlurFade(float scale) = 0; + + virtual void ResetHudCloseCaption() = 0; + + virtual bool HandleGameUIEvent(const InputEvent_t& event) = 0; + + virtual bool GetSoundSpatialization(SpatializationInfo_t& info) = 0; + + virtual void Hud_SaveStarted() = 0; + + virtual void ShutdownMovies() = 0; + + virtual void GetStatus(char* buffer, int bufsize) = 0; + +#if defined ( CSTRIKE15 ) + virtual bool IsChatRaised(void) = 0; + virtual bool IsRadioPanelRaised(void) = 0; + virtual bool IsBindMenuRaised(void) = 0; + virtual bool IsTeamMenuRaised(void) = 0; + virtual bool IsLoadingScreenRaised(void) = 0; + +#endif + +#if defined(_PS3) + virtual int GetDrawFlags(void) = 0; + virtual int GetBuildViewID(void) = 0; + virtual bool IsSPUBuildWRJobsOn(void) = 0; + virtual void CacheFrustumData(Frustum_t* pFrustum, Frustum_t* pAreaFrustum, void* pRenderAreaBits, int numArea, bool bViewerInSolidSpace) = 0; + virtual void* GetBuildViewVolumeCuller(void) = 0; + virtual Frustum_t* GetBuildViewFrustum(void) = 0; + virtual Frustum_t* GetBuildViewAreaFrustum(void) = 0; + virtual unsigned char* GetBuildViewRenderAreaBits(void) = 0; +#else + virtual bool IsBuildWRThreaded(void) = 0; + virtual void QueueBuildWorldListJob(CJob* pJob) = 0; + virtual void CacheFrustumData(const Frustum_t& frustum, const CUtlVector< Frustum_t, CUtlMemoryAligned< Frustum_t,16 > >& aeraFrustums) = 0; + virtual const Frustum_t* GetBuildViewFrustum(void) const = 0; + virtual const CUtlVector< Frustum_t, CUtlMemoryAligned< Frustum_t,16 > >* GetBuildViewAeraFrustums(void) const = 0; +#endif + + virtual bool IsSubscribedMap(const char* pchMapName, bool bOnlyOnDisk) = 0; + virtual bool IsFeaturedMap(const char* pchMapName, bool bOnlyOnDisk) = 0; + + virtual void DownloadCommunityMapFile(int id) = 0; + + virtual float GetUGCFileDownloadProgress(int id) = 0; + + virtual void RecordUIEvent(const char* szEvent) = 0; + + virtual float FindInventoryItemWithMaxAttributeValue(char const* szItemType, char const* szAttrClass) = 0; + + virtual void DetermineSubscriptionKvToAdvertise(KeyValues* kvLocalPlayer) = 0; + + virtual bool ValidateSignedEvidenceHeader(char const* szKey, void const* pvHeader, void* pPlaybackParameters) = 0; + virtual void PrepareSignedEvidenceData(void* pvData, int numBytes, int const* pPlaybackParameters) = 0; + virtual bool ShouldSkipEvidencePlayback(int const* pPlaybackParameters) = 0; + + virtual void* GetScaleformSlotInitController() = 0; + + virtual bool IsConnectedUserInfoChangeAllowed(IConVar* pCvar) = 0; + + virtual char const* GetRichPresenceStatusString() = 0; + + virtual bool CanStopRecordDemo(char* errorMsg, int length) const = 0; + + virtual void OnHltvReplay(const int& msg) = 0; + virtual void OnHltvReplayTick() = 0; + virtual int GetHltvReplayDelay() = 0; + + virtual void OnDemoPlaybackTimeJump() = 0; + virtual void OnCommandDuringPlayback(char const* cmd) = 0; + + virtual void RetireAllPlayerDecals(bool bRenderContextValid) = 0; + virtual void EngineGotvSyncPacket(const void* pPkt) = 0; + virtual int GetInEyeEntity() const = 0; + virtual void OnTickPre(int tickcount) = 0; +}; + +#define CLIENT_DLL_INTERFACE_VERSION "VClient018" + +abstract_class IClientDLLSharedAppSystems +{ +public: + virtual int Count() = 0; + virtual char const* GetDllName(int idx) = 0; + virtual char const* GetInterfaceName(int idx) = 0; +}; + +#define CLIENT_DLL_SHARED_APPSYSTEMS "VClientDllSharedAppSystems001" + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/cdll_util.h b/SpyCustom/sdk/cdll_util.h new file mode 100644 index 0000000..d943a41 --- /dev/null +++ b/SpyCustom/sdk/cdll_util.h @@ -0,0 +1,149 @@ +#if !defined( UTIL_H ) +#define UTIL_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "soundflags.h" +#include "vector.h" +#include "shareddefs.h" + +#include "shake.h" +#include "imageformat.h" +#include "ispatialpartition.h" +#include "MaterialSystemUtil.h" + +class Vector; +class QAngle; +class IMaterial; +class ITexture; +class IClientEntity; +class CHudTexture; +class CGameTrace; +class C_BaseEntity; + +struct Ray_t; +struct client_textmessage_t; +typedef CGameTrace trace_t; + +namespace vgui +{ + typedef unsigned long HFont; +}; + + + +extern bool g_MakingDevShots; + +int ScreenHeight(void); +int ScreenWidth(void); + +#define XRES(x) ( x * ( ( float )ScreenWidth() / 640.0 ) ) +#define YRES(y) ( y * ( ( float )ScreenHeight() / 480.0 ) ) + +int UTIL_ComputeStringWidth(vgui::HFont& font, const char* str); +int UTIL_ComputeStringWidth(vgui::HFont& font, const wchar_t* str); +float UTIL_AngleDiff(float destAngle, float srcAngle); +void UTIL_Bubbles(const Vector& mins, const Vector& maxs, int count); +void UTIL_Smoke(const Vector& origin, const float scale, const float framerate); +void UTIL_ImpactTrace(trace_t* pTrace, int iDamageType, const char* pCustomImpactName = NULL); +int UTIL_PrecacheDecal(const char* name, bool preload = false); +void UTIL_EmitAmbientSound(C_BaseEntity* entity, const Vector& vecOrigin, const char* samp, float vol, soundlevel_t soundlevel, int fFlags, int pitch); +void UTIL_SetOrigin(C_BaseEntity* entity, const Vector& vecOrigin); +void UTIL_ScreenShake(const Vector& center, float amplitude, float frequency, float duration, float radius, ShakeCommand_t eCommand, bool bAirShake = false); +byte* UTIL_LoadFileForMe(const char* filename, int* pLength); +void UTIL_FreeFile(byte* buffer); +void UTIL_MakeSafeName(const char* oldName, OUT_Z_CAP(newNameBufSize) char* newName, int newNameBufSize); +const char* UTIL_SafeName(const char* oldName); +void UTIL_ReplaceKeyBindings(const wchar_t* inbuf, int inbufsizebytes, OUT_Z_BYTECAP(outbufsizebytes) wchar_t* outbuf, int outbufsizebytes); + +unsigned char UTIL_ComputeEntityFade(C_BaseEntity* pEntity, float flMinDist, float flMaxDist, float flFadeScale); + +client_textmessage_t* TextMessageGet(const char* pName); + +char* VarArgs(PRINTF_FORMAT_STRING const char* format, ...); + + +int GetSpectatorTarget(); +int GetSpectatorMode(void); +bool IsPlayerIndex(int index); +int GetLocalPlayerIndex(void); +int GetLocalPlayerVisionFilterFlags(bool bWeaponsCheck = false); +bool IsLocalPlayerUsingVisionFilterFlags(int nFlags, bool bWeaponsCheck = false); +int GetLocalPlayerTeam(void); +bool IsLocalPlayerSpectator(void); +void NormalizeAngles(QAngle& angles); +void InterpolateAngles(const QAngle& start, const QAngle& end, QAngle& output, float frac); +void InterpolateVector(float frac, const Vector& src, const Vector& dest, Vector& output); + +const char* nexttoken(char* token, const char* str, char sep); + +enum +{ + LIGHT_INDEX_TE_DYNAMIC = 0x10000000, + LIGHT_INDEX_PLAYER_BRIGHT = 0x20000000, + LIGHT_INDEX_MUZZLEFLASH = 0x40000000, +}; + +void UTIL_PrecacheOther(const char* szClassname); + +void UTIL_SetTrace(trace_t& tr, const Ray_t& ray, C_BaseEntity* edict, float fraction, int hitgroup, unsigned int contents, const Vector& normal, float intercept); + +bool GetVectorInScreenSpace(Vector pos, int& iX, int& iY, Vector* vecOffset = NULL); +bool GetVectorInHudSpace(Vector pos, int& iX, int& iY, Vector* vecOffset = NULL); +bool GetTargetInScreenSpace(C_BaseEntity* pTargetEntity, int& iX, int& iY, Vector* vecOffset = NULL); +bool GetTargetInHudSpace(C_BaseEntity* pTargetEntity, int& iX, int& iY, Vector* vecOffset = NULL); + +class C_BasePlayer; +void ClientPrint(C_BasePlayer* player, int msg_dest, const char* msg_name, const char* param1 = NULL, const char* param2 = NULL, const char* param3 = NULL, const char* param4 = NULL); + +int UTIL_EntitiesInBox(C_BaseEntity** pList, int listMax, const Vector& mins, const Vector& maxs, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS); +int UTIL_EntitiesInSphere(C_BaseEntity** pList, int listMax, const Vector& center, float radius, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS); +int UTIL_EntitiesAlongRay(C_BaseEntity** pList, int listMax, const Ray_t& ray, int flagMask, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS); + +#define MAX_SPHERE_QUERY 256 +class CEntitySphereQuery +{ +public: + CEntitySphereQuery(const Vector& center, float radius, int flagMask = 0, int partitionMask = PARTITION_CLIENT_NON_STATIC_EDICTS); + C_BaseEntity* GetCurrentEntity(); + inline void NextEntity() { m_listIndex++; } + +private: + int m_listIndex; + int m_listCount; + C_BaseEntity* m_pList[MAX_SPHERE_QUERY]; +}; + +C_BaseEntity* CreateEntityByName(const char* className); +template< class T > +T* _CreateEntity(T* newClass, const char* className) +{ + T* newEnt = dynamic_cast(CreateEntityByName(className)); + if (!newEnt) + { + Warning("classname %s used to create wrong class type\n", className); + Assert(0); + } + + return newEnt; +} + +#define CREATE_ENTITY( newClass, className ) _CreateEntity( (newClass*)NULL, className ) +#define CREATE_UNSAVED_ENTITY( newClass, className ) _CreateEntityTemplate( (newClass*)NULL, className ) + +inline bool FStrEq(const char* sz1, const char* sz2) +{ + return (sz1 == sz2 || V_stricmp(sz1, sz2) == 0); +} + +void UTIL_BoundToWorldSize(Vector* pVecPos); + +void UTIL_IncrementMapKey(const char* pszCustomKey); + +int UTIL_GetMapKeyCount(const char* pszCustomKey); + +bool UTIL_HasLoadedAnyMap(); + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/checksum_crc.h b/SpyCustom/sdk/checksum_crc.h new file mode 100644 index 0000000..b4875c3 --- /dev/null +++ b/SpyCustom/sdk/checksum_crc.h @@ -0,0 +1,25 @@ +#ifndef CHECKSUM_CRC_H +#define CHECKSUM_CRC_H +#ifdef _WIN32 +#pragma once +#endif + +typedef unsigned int CRC32_t; + +void CRC32_Init(CRC32_t* pulCRC); +void CRC32_ProcessBuffer(CRC32_t* pulCRC, const void* p, int len); +void CRC32_Final(CRC32_t* pulCRC); +CRC32_t CRC32_GetTableEntry(unsigned int slot); + +inline CRC32_t CRC32_ProcessSingleBuffer(const void* p, int len) +{ + CRC32_t crc; + + CRC32_Init(&crc); + CRC32_ProcessBuffer(&crc, p, len); + CRC32_Final(&crc); + + return crc; +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/checksum_md5.h b/SpyCustom/sdk/checksum_md5.h new file mode 100644 index 0000000..1179656 --- /dev/null +++ b/SpyCustom/sdk/checksum_md5.h @@ -0,0 +1,51 @@ +#ifndef CHECKSUM_MD5_H +#define CHECKSUM_MD5_H + +#ifdef _WIN32 +#pragma once +#endif + +#define MD5_DIGEST_LENGTH 16 +#define MD5_BIT_LENGTH ( MD5_DIGEST_LENGTH * sizeof(unsigned char) ) +struct MD5Value_t +{ + unsigned char bits[MD5_DIGEST_LENGTH]; + + void Zero(); + bool IsZero() const; + + bool operator==(const MD5Value_t& src) const; + bool operator!=(const MD5Value_t& src) const; + +}; + +typedef struct +{ + unsigned int buf[4]; + unsigned int bits[2]; + unsigned char in[64]; +} MD5Context_t; + +void MD5Init(MD5Context_t* context); +void MD5Update(MD5Context_t* context, unsigned char const* buf, unsigned int len); +void MD5Final(unsigned char digest[MD5_DIGEST_LENGTH], MD5Context_t* context); + +char* MD5_Print(unsigned char* digest, int hashlen); + +void MD5_ProcessSingleBuffer(const void* p, int len, MD5Value_t& md5Result); + +unsigned int MD5_PseudoRandom(unsigned int nSeed); + +bool MD5_Compare(const MD5Value_t& data, const MD5Value_t& compare); + +inline bool MD5Value_t::operator==(const MD5Value_t& src) const +{ + return MD5_Compare(*this, src); +} + +inline bool MD5Value_t::operator!=(const MD5Value_t& src) const +{ + return !MD5_Compare(*this, src); +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/client_class.h b/SpyCustom/sdk/client_class.h new file mode 100644 index 0000000..7d84b69 --- /dev/null +++ b/SpyCustom/sdk/client_class.h @@ -0,0 +1,140 @@ +#if !defined( CLIENT_CLASS_H ) +#define CLIENT_CLASS_H +#ifdef _WIN32 +#pragma once +#endif + +#include "interface.h" +#include "dt_recv.h" + +class Vector; +class CMouthInfo; + + +#include "iclientrenderable.h" +#include "iclientnetworkable.h" + + +class ClientClass; +extern ClientClass* g_pClientClassHead; + +typedef IClientNetworkable* (*CreateClientClassFn)(int entnum, int serialNum); +typedef IClientNetworkable* (*CreateEventFn)(); + +class ClientClass +{ +public: + ClientClass(const char* pNetworkName, CreateClientClassFn createFn, CreateEventFn createEventFn, RecvTable* pRecvTable) + { + m_pNetworkName = pNetworkName; + m_pCreateFn = createFn; + m_pCreateEventFn = createEventFn; + m_pRecvTable = pRecvTable; + + m_pNext = g_pClientClassHead; + g_pClientClassHead = this; + } + + const char* GetName() + { + return m_pNetworkName; + } + +public: + CreateClientClassFn m_pCreateFn; + CreateEventFn m_pCreateEventFn; + const char* m_pNetworkName; + RecvTable* m_pRecvTable; + ClientClass* m_pNext; + int m_ClassID; +}; + +#define DECLARE_CLIENTCLASS() \ + virtual int YouForgotToImplementOrDeclareClientClass();\ + virtual ClientClass* GetClientClass();\ + static RecvTable *m_pClassRecvTable; \ + DECLARE_CLIENTCLASS_NOBASE() + + +#define ALLOW_DATATABLES_PRIVATE_ACCESS() \ + template friend int ClientClassInit(T *); + + +#define DECLARE_CLIENTCLASS_NOBASE ALLOW_DATATABLES_PRIVATE_ACCESS + +#define IMPLEMENT_CLIENTCLASS(clientClassName, dataTable, serverClassName) \ + INTERNAL_IMPLEMENT_CLIENTCLASS_PROLOGUE(clientClassName, dataTable, serverClassName) \ + static IClientNetworkable* _##clientClassName##_CreateObject( int entnum, int serialNum ) \ + { \ + clientClassName *pRet = new clientClassName; \ + if ( !pRet ) \ + return 0; \ + pRet->Init( entnum, serialNum ); \ + return pRet; \ + } \ + ClientClass __g_##clientClassName##ClientClass(#serverClassName, \ + _##clientClassName##_CreateObject, \ + NULL,\ + &dataTable::g_RecvTable); + +#define IMPLEMENT_CLIENTCLASS_FACTORY(clientClassName, dataTable, serverClassName, factory) \ + INTERNAL_IMPLEMENT_CLIENTCLASS_PROLOGUE(clientClassName, dataTable, serverClassName) \ + ClientClass __g_##clientClassName##ClientClass(#serverClassName, \ + factory, \ + NULL,\ + &dataTable::g_RecvTable); + +#define IMPLEMENT_CLIENTCLASS_DT(clientClassName, dataTable, serverClassName)\ + IMPLEMENT_CLIENTCLASS(clientClassName, dataTable, serverClassName)\ + BEGIN_RECV_TABLE(clientClassName, dataTable) + +#define IMPLEMENT_CLIENTCLASS_DT_NOBASE(clientClassName, dataTable, serverClassName)\ + IMPLEMENT_CLIENTCLASS(clientClassName, dataTable, serverClassName)\ + BEGIN_RECV_TABLE_NOBASE(clientClassName, dataTable) + + +#define IMPLEMENT_CLIENTCLASS_EVENT(clientClassName, dataTable, serverClassName)\ + INTERNAL_IMPLEMENT_CLIENTCLASS_PROLOGUE(clientClassName, dataTable, serverClassName)\ + static clientClassName __g_##clientClassName; \ + static IClientNetworkable* _##clientClassName##_CreateObject() {return &__g_##clientClassName;}\ + ClientClass __g_##clientClassName##ClientClass(#serverClassName, \ + NULL,\ + _##clientClassName##_CreateObject, \ + &dataTable::g_RecvTable); + +#define IMPLEMENT_CLIENTCLASS_EVENT_DT(clientClassName, dataTable, serverClassName)\ + namespace dataTable {extern RecvTable g_RecvTable;}\ + IMPLEMENT_CLIENTCLASS_EVENT(clientClassName, dataTable, serverClassName)\ + BEGIN_RECV_TABLE(clientClassName, dataTable) + + +#define IMPLEMENT_CLIENTCLASS_EVENT_POINTER(clientClassName, dataTable, serverClassName, ptr)\ + INTERNAL_IMPLEMENT_CLIENTCLASS_PROLOGUE(clientClassName, dataTable, serverClassName)\ + static IClientNetworkable* _##clientClassName##_CreateObject() {return ptr;}\ + ClientClass __g_##clientClassName##ClientClass(#serverClassName, \ + NULL,\ + _##clientClassName##_CreateObject, \ + &dataTable::g_RecvTable); + +#define IMPLEMENT_CLIENTCLASS_EVENT_NONSINGLETON(clientClassName, dataTable, serverClassName)\ + static IClientNetworkable* _##clientClassName##_CreateObject() \ + { \ + clientClassName *p = new clientClassName; \ + if ( p ) \ + p->Init( -1, 0 ); \ + return p; \ + } \ + ClientClass __g_##clientClassName##ClientClass(#serverClassName, \ + NULL,\ + _##clientClassName##_CreateObject, \ + &dataTable::g_RecvTable); + + +#define INTERNAL_IMPLEMENT_CLIENTCLASS_PROLOGUE(clientClassName, dataTable, serverClassName) \ + namespace dataTable {extern RecvTable g_RecvTable;}\ + extern ClientClass __g_##clientClassName##ClientClass;\ + RecvTable* clientClassName::m_pClassRecvTable = &dataTable::g_RecvTable;\ + int clientClassName::YouForgotToImplementOrDeclareClientClass() {return 0;}\ + ClientClass* clientClassName::GetClientClass() {return &__g_##clientClassName##ClientClass;} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/client_render_handle.h b/SpyCustom/sdk/client_render_handle.h new file mode 100644 index 0000000..f2c0970 --- /dev/null +++ b/SpyCustom/sdk/client_render_handle.h @@ -0,0 +1,19 @@ +#ifndef CLIENT_RENDER_HANDLE_H +#define CLIENT_RENDER_HANDLE_H +#ifdef _WIN32 +#pragma once +#endif + + +class IClientRenderable; + + +typedef unsigned short ClientRenderHandle_t; + +enum +{ + INVALID_CLIENT_RENDER_HANDLE = (ClientRenderHandle_t)0xffff, +}; + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/client_thinklist.h b/SpyCustom/sdk/client_thinklist.h new file mode 100644 index 0000000..542be13 --- /dev/null +++ b/SpyCustom/sdk/client_thinklist.h @@ -0,0 +1,114 @@ +#ifndef CLIENT_THINKLIST_H +#define CLIENT_THINKLIST_H +#ifdef _WIN32 +#pragma once +#endif + + +#include "igamesystem.h" +#include "utllinkedlist.h" +#include "cliententitylist.h" +#include "iclientthinkable.h" +#include "utlrbtree.h" + + +#define CLIENT_THINK_ALWAYS -1293 +#define CLIENT_THINK_NEVER -1 + + +#define INVALID_THINK_HANDLE ClientThinkList()->GetInvalidThinkHandle() + + +class CClientThinkList : public IGameSystemPerFrame +{ +public: + + CClientThinkList(); + virtual ~CClientThinkList(); + + virtual char const* Name() { return "CClientThinkList"; } + virtual bool IsPerFrame() { return true; } + + void SetNextClientThink(ClientEntityHandle_t hEnt, float nextTime); + + void RemoveThinkable(ClientEntityHandle_t hEnt); + + ClientThinkHandle_t GetInvalidThinkHandle(); + + void PerformThinkFunctions(); + + void AddToDeleteList(ClientEntityHandle_t hEnt); + void RemoveFromDeleteList(ClientEntityHandle_t hEnt); + +public: + + virtual bool Init(); + virtual void PostInit() {}; + virtual void Shutdown(); + virtual void LevelInitPreEntity(); + virtual void LevelInitPostEntity() {} + virtual void LevelShutdownPreEntity(); + virtual void LevelShutdownPostEntity(); + virtual void PreRender(); + virtual void PostRender() { } + virtual void Update(float frametime); + virtual void OnSave() {} + virtual void OnRestore() {} + virtual void SafeRemoveIfDesired() {} + +private: + struct ThinkEntry_t + { + ClientEntityHandle_t m_hEnt; + float m_flNextClientThink; + float m_flLastClientThink; + int m_nIterEnum; + }; + + struct ThinkListChanges_t + { + ClientEntityHandle_t m_hEnt; + ClientThinkHandle_t m_hThink; + float m_flNextTime; + }; + +private: + void SetNextClientThink(ClientThinkHandle_t hThink, float nextTime); + void RemoveThinkable(ClientThinkHandle_t hThink); + void PerformThinkFunction(ThinkEntry_t* pEntry, float curtime); + ThinkEntry_t* GetThinkEntry(ClientThinkHandle_t hThink); + void CleanUpDeleteList(); + + void AddEntityToFrameThinkList(ThinkEntry_t* pEntry, bool bAlwaysChain, int& nCount, ThinkEntry_t** ppFrameThinkList); + +private: + CUtlLinkedList m_ThinkEntries; + + CUtlVector m_aDeleteList; + CUtlVector m_aChangeList; + + int m_nIterEnum; + bool m_bInThinkLoop; +}; + + +inline ClientThinkHandle_t CClientThinkList::GetInvalidThinkHandle() +{ + return (ClientThinkHandle_t)(uintp)m_ThinkEntries.InvalidIndex(); +} + + +inline CClientThinkList::ThinkEntry_t* CClientThinkList::GetThinkEntry(ClientThinkHandle_t hThink) +{ + return &m_ThinkEntries[(unsigned long)hThink]; +} + + +inline CClientThinkList* ClientThinkList() +{ + extern CClientThinkList g_ClientThinkList; + return &g_ClientThinkList; +} + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/client_virtualreality.h b/SpyCustom/sdk/client_virtualreality.h new file mode 100644 index 0000000..3df62be --- /dev/null +++ b/SpyCustom/sdk/client_virtualreality.h @@ -0,0 +1,123 @@ +#ifndef CLIENTVIRTUALREALITY_H +#define CLIENTVIRTUALREALITY_H +#if defined( _WIN32 ) +#pragma once +#endif + +#include "tier3.h" +#include "iclientvirtualreality.h" +#include "view_shared.h" + +enum HeadtrackMovementMode_t +{ + HMM_SHOOTFACE_MOVEFACE = 0, + HMM_SHOOTFACE_MOVETORSO, + HMM_SHOOTMOUSE_MOVEFACE, + HMM_SHOOTBOUNDEDMOUSE_LOOKFACE_MOVEFACE, + HMM_SHOOTBOUNDEDMOUSE_LOOKFACE_MOVEMOUSE, + + HMM_SHOOTMOVELOOKMOUSEFACE, + HMM_SHOOTMOVEMOUSE_LOOKFACE, + HMM_SHOOTMOVELOOKMOUSE, + + HMM_LAST, + + HMM_NOOVERRIDE = HMM_LAST +}; + + + +class CClientVirtualReality : public CTier3AppSystem< IClientVirtualReality > +{ + typedef CTier3AppSystem< IClientVirtualReality > BaseClass; + +public: + + CClientVirtualReality(); + ~CClientVirtualReality(); + + virtual bool Connect(CreateInterfaceFn factory); + virtual void Disconnect(); + virtual void* QueryInterface(const char* pInterfaceName); + + virtual InitReturnVal_t Init(); + virtual void Shutdown(); + + void StartupComplete(); + + virtual void DrawMainMenu() OVERRIDE; + + + bool OverrideView(CViewSetup* pViewMiddle, Vector* pViewModelOrigin, QAngle* pViewModelAngles, HeadtrackMovementMode_t hmmMovementOverride); + bool OverrideStereoView(CViewSetup* pViewMiddle, CViewSetup* pViewLeft, CViewSetup* pViewRight); + bool OverridePlayerMotion(float flInputSampleFrametime, const QAngle& oldAngles, const QAngle& curAngles, const Vector& curMotion, QAngle* pNewAngles, Vector* pNewMotion); + bool OverrideWeaponHudAimVectors(Vector* pAimOrigin, Vector* pAimDirection); + bool CurrentlyZoomed(); + void OverrideTorsoTransform(const Vector& position, const QAngle& angles); + void CancelTorsoTransformOverride(); + bool CanOverlayHudQuad(); + void GetHUDBounds(Vector* pViewer, Vector* pUL, Vector* pUR, Vector* pLL, Vector* pLR); + void RenderHUDQuad(bool bBlackout, bool bTranslucent); + float GetZoomedModeMagnification(); + bool ProcessCurrentTrackingState(float fGameFOV); + const VMatrix& GetHudProjectionFromWorld(); + void GetTorsoRelativeAim(Vector* pPosition, QAngle* pAngles); + float GetHUDDistance(); + bool ShouldRenderHUDInWorld(); + const VMatrix& GetWorldFromMidEye() const { return m_WorldFromMidEyeNoDebugCam; } + void OverrideViewModelTransform(Vector& vmorigin, QAngle& vmangles, bool bUseLargeOverride); + void AlignTorsoAndViewToWeapon(); + void PostProcessFrame(StereoEye_t eEye); + void OverlayHUDQuadWithUndistort(const CViewSetup& view, bool bDoUndistort, bool bBlackout, bool bTranslucent); + + void Activate(); + void Deactivate(); + +private: + HeadtrackMovementMode_t m_hmmMovementActual; + + VMatrix m_WorldFromMidEye; + + float m_fHudHorizontalFov; + VMatrix m_WorldFromHud; + VMatrix m_HudProjectionFromWorld; + float m_fHudHalfWidth; + float m_fHudHalfHeight; + + VMatrix m_TorsoFromMideye; + + VMatrix m_WorldFromMidEyeNoDebugCam; + + VMatrix m_WorldFromWeapon; + + QAngle m_PlayerTorsoAngle; + Vector m_PlayerTorsoOrigin; + Vector m_PlayerLastMovement; + + QAngle m_PlayerViewAngle; + Vector m_PlayerViewOrigin; + + float m_WorldZoomScale; + + QAngle m_OverrideTorsoAngle; + QAngle m_OverrideTorsoOffset; + bool m_bOverrideTorsoAngle; + + int m_iAlignTorsoAndViewToWeaponCountdown; + + bool m_bMotionUpdated; + + RTime32 m_rtLastMotionSample; + + bool m_bNonVRWindowed; + int m_nNonVRWidth; + int m_nNonVRHeight; +#if defined( USE_SDL ) + int m_nNonVRSDLDisplayIndex; +#endif + bool m_bNonVRRawInput; +}; + +extern CClientVirtualReality g_ClientVirtualReality; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/cliententitylist.h b/SpyCustom/sdk/cliententitylist.h new file mode 100644 index 0000000..2e448c6 --- /dev/null +++ b/SpyCustom/sdk/cliententitylist.h @@ -0,0 +1,252 @@ +#if !defined( CLIENTENTITYLIST_H ) +#define CLIENTENTITYLIST_H +#ifdef _WIN32 +#pragma once +#endif + +#include "dbg.h" +#include "icliententitylist.h" +#include "iclientunknown.h" +#include "utllinkedlist.h" +#include "utlvector.h" +#include "icliententityinternal.h" +#include "ispatialpartition.h" +#include "cdll_util.h" +#include "entitylist_base.h" +#include "utlmap.h" + +class C_Beam; +class C_BaseViewModel; +class C_BaseEntity; + + +#define INPVS_YES 0x0001 +#define INPVS_THISFRAME 0x0002 +#define INPVS_NEEDSNOTIFY 0x0004 + +class IClientEntityListener; + +abstract_class C_BaseEntityClassList +{ +public: + C_BaseEntityClassList(); + ~C_BaseEntityClassList(); + virtual void LevelShutdown() = 0; + + C_BaseEntityClassList* m_pNextClassList; +}; + +template< class T > +class C_EntityClassList : public C_BaseEntityClassList +{ +public: + virtual void LevelShutdown() { m_pClassList = NULL; } + + void Insert(T* pEntity) + { + pEntity->m_pNext = m_pClassList; + m_pClassList = pEntity; + } + + void Remove(T* pEntity) + { + T** pPrev = &m_pClassList; + T* pCur = *pPrev; + while (pCur) + { + if (pCur == pEntity) + { + *pPrev = pCur->m_pNext; + return; + } + pPrev = &pCur->m_pNext; + pCur = *pPrev; + } + } + + static T* m_pClassList; +}; + + +#define INVALID_CLIENTENTITY_HANDLE CBaseHandle( INVALID_EHANDLE_INDEX ) + + +class CClientEntityList : public CBaseEntityList, public IClientEntityList +{ + friend class C_BaseEntityIterator; + friend class C_AllBaseEntityIterator; + +public: + CClientEntityList(void); + virtual ~CClientEntityList(void); + + void Release(); + + +public: + + virtual IClientNetworkable* GetClientNetworkable(int entnum); + virtual IClientEntity* GetClientEntity(int entnum); + + virtual int NumberOfEntities(bool bIncludeNonNetworkable = false); + + virtual IClientUnknown* GetClientUnknownFromHandle(ClientEntityHandle_t hEnt); + virtual IClientNetworkable* GetClientNetworkableFromHandle(ClientEntityHandle_t hEnt); + virtual IClientEntity* GetClientEntityFromHandle(ClientEntityHandle_t hEnt); + + virtual int GetHighestEntityIndex(void); + + virtual void SetMaxEntities(int maxents); + virtual int GetMaxEntities(); + + +protected: + + virtual void OnAddEntity(IHandleEntity* pEnt, CBaseHandle handle); + virtual void OnRemoveEntity(IHandleEntity* pEnt, CBaseHandle handle); + + +public: + + IClientUnknown* GetListedEntity(int entnum); + + C_BaseEntity* GetBaseEntity(int entnum); + ICollideable* GetCollideable(int entnum); + + IClientRenderable* GetClientRenderableFromHandle(ClientEntityHandle_t hEnt); + C_BaseEntity* GetBaseEntityFromHandle(ClientEntityHandle_t hEnt); + ICollideable* GetCollideableFromHandle(ClientEntityHandle_t hEnt); + IClientThinkable* GetClientThinkableFromHandle(ClientEntityHandle_t hEnt); + + ClientEntityHandle_t EntIndexToHandle(int entnum); + int HandleToEntIndex(ClientEntityHandle_t handle); + + bool IsHandleValid(ClientEntityHandle_t handle) const; + + C_BaseEntity* GetEnt(int entnum) { return GetBaseEntity(entnum); } + + void RecomputeHighestEntityUsed(void); + + + C_BaseEntity* FirstBaseEntity() const; + C_BaseEntity* NextBaseEntity(C_BaseEntity* pEnt) const; + + class CPVSNotifyInfo + { + public: + IPVSNotify* m_pNotify; + IClientRenderable* m_pRenderable; + unsigned char m_InPVSStatus; + unsigned short m_PVSNotifiersLink; + }; + + CUtlLinkedList& GetPVSNotifiers(); + + CUtlVector m_entityListeners; + + void AddListenerEntity(IClientEntityListener* pListener); + void RemoveListenerEntity(IClientEntityListener* pListener); + + void NotifyCreateEntity(C_BaseEntity* pEnt); + void NotifyRemoveEntity(C_BaseEntity* pEnt); + +private: + + struct EntityCacheInfo_t + { + IClientNetworkable* m_pNetworkable; + unsigned short m_BaseEntitiesIndex; + }; + + int m_iNumServerEnts; + int m_iMaxServerEnts; + + int m_iNumClientNonNetworkable; + + int m_iMaxUsedServerIndex; + + EntityCacheInfo_t m_EntityCacheInfo[NUM_ENT_ENTRIES]; + + CUtlLinkedList m_BaseEntities; + + +private: + + void AddPVSNotifier(IClientUnknown* pUnknown); + void RemovePVSNotifier(IClientUnknown* pUnknown); + + CUtlLinkedList m_PVSNotifyInfos; + CUtlMap m_PVSNotifierMap; +}; + + +class C_AllBaseEntityIterator +{ +public: + C_AllBaseEntityIterator(); + + void Restart(); + C_BaseEntity* Next(); + +private: + unsigned short m_CurBaseEntity; +}; + +class C_BaseEntityIterator +{ +public: + C_BaseEntityIterator(); + + void Restart(); + C_BaseEntity* Next(); + +private: + unsigned short m_CurBaseEntity; +}; + +inline bool CClientEntityList::IsHandleValid(ClientEntityHandle_t handle) const +{ + return handle.Get() != 0; +} + +inline IClientUnknown* CClientEntityList::GetListedEntity(int entnum) +{ + return (IClientUnknown*)LookupEntityByNetworkIndex(entnum); +} + +inline IClientUnknown* CClientEntityList::GetClientUnknownFromHandle(ClientEntityHandle_t hEnt) +{ + return (IClientUnknown*)LookupEntity(hEnt); +} + +inline CUtlLinkedList& CClientEntityList::GetPVSNotifiers() +{ + return m_PVSNotifyInfos; +} + + +inline ClientEntityHandle_t CClientEntityList::EntIndexToHandle(int entnum) +{ + if (entnum < -1) + return INVALID_EHANDLE_INDEX; + IClientUnknown* pUnk = GetListedEntity(entnum); + return pUnk ? pUnk->GetRefEHandle() : INVALID_EHANDLE_INDEX; +} + + +extern CClientEntityList* cl_entitylist; + +inline CClientEntityList& ClientEntityList() +{ + return *cl_entitylist; +} + +class IClientEntityListener +{ +public: + virtual void OnEntityCreated(C_BaseEntity* pEntity) {}; + virtual void OnEntityDeleted(C_BaseEntity* pEntity) {}; +}; + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/clientleafsystem.h b/SpyCustom/sdk/clientleafsystem.h new file mode 100644 index 0000000..998bef1 --- /dev/null +++ b/SpyCustom/sdk/clientleafsystem.h @@ -0,0 +1,223 @@ +#if !defined( CLIENTLEAFSYSTEM_H ) +#define CLIENTLEAFSYSTEM_H +#ifdef _WIN32 +#pragma once +#endif + +#include "IGameSystem.h" +#include "IClientLeafSystem.h" +#include "IVRenderView.h" +#include "mempool.h" +#include "refcount.h" + +#include "ivrenderview.h" + +struct WorldListInfo_t; +class IClientRenderable; +class Vector; +class CGameTrace; +typedef CGameTrace trace_t; +struct Ray_t; +class Vector2D; +class CStaticProp; + + + + + +enum +{ + DETAIL_PROP_RENDER_HANDLE = (ClientRenderHandle_t)0xfffe +}; + + +struct DistanceFadeInfo_t +{ + float m_flMaxDistSqr; + float m_flMinDistSqr; + float m_flFalloffFactor; +}; + + +class CClientRenderablesList : public CRefCounted<> +{ + DECLARE_FIXEDSIZE_ALLOCATOR(CClientRenderablesList); + +public: + enum + { + MAX_GROUP_ENTITIES = 4096, + MAX_BONE_SETUP_DEPENDENCY = 64, + }; + + struct CEntry + { + IClientRenderable* m_pRenderable; + unsigned short m_iWorldListInfoLeaf; + RenderableInstance_t m_InstanceData; + uint8 m_nModelType : 7; + uint8 m_TwoPass : 1; + }; + + DistanceFadeInfo_t m_DetailFade; + CEntry m_RenderGroups[RENDER_GROUP_COUNT][MAX_GROUP_ENTITIES]; + int m_RenderGroupCounts[RENDER_GROUP_COUNT]; + int m_nBoneSetupDependencyCount; + IClientRenderable* m_pBoneSetupDependency[MAX_BONE_SETUP_DEPENDENCY]; +}; + + +class CViewModelRenderablesList +{ +public: + enum + { + VM_GROUP_OPAQUE = 0, + VM_GROUP_TRANSLUCENT, + VM_GROUP_COUNT, + }; + + struct CEntry + { + IClientRenderable* m_pRenderable; + RenderableInstance_t m_InstanceData; + }; + + typedef CUtlVectorFixedGrowable< CEntry, 32 > RenderGroups_t; + + RenderGroups_t m_RenderGroups[VM_GROUP_COUNT]; +}; + + +struct SetupRenderInfo_t +{ + WorldListInfo_t* m_pWorldListInfo; + CClientRenderablesList* m_pRenderList; + Vector m_vecRenderOrigin; + Vector m_vecRenderForward; + int m_nRenderFrame; + int m_nDetailBuildFrame; + float m_flRenderDistSq; + int m_nViewID; + bool m_bDrawDetailObjects : 1; + bool m_bDrawTranslucentObjects : 1; + + SetupRenderInfo_t() + { + m_bDrawDetailObjects = true; + m_bDrawTranslucentObjects = true; + } +}; + + +struct ScreenSizeComputeInfo_t +{ + VMatrix m_matViewProj; + Vector m_vecViewUp; + int m_nViewportHeight; +}; + +void ComputeScreenSizeInfo(ScreenSizeComputeInfo_t* pInfo); +float ComputeScreenSize(const Vector& vecOrigin, float flRadius, const ScreenSizeComputeInfo_t& info); + + +typedef unsigned short ClientLeafShadowHandle_t; +enum +{ + CLIENT_LEAF_SHADOW_INVALID_HANDLE = (ClientLeafShadowHandle_t)~0 +}; + + +abstract_class IClientLeafShadowEnum +{ +public: + virtual void EnumShadow(ClientShadowHandle_t userId) = 0; +}; + + +class CClientLeafSubSystemData +{ +public: + virtual ~CClientLeafSubSystemData(void) + { + } +}; + + +#define CLSUBSYSTEM_DETAILOBJECTS 0 +#define N_CLSUBSYSTEMS 1 + + + +abstract_class IClientLeafSystem : public IClientLeafSystemEngine, public IGameSystemPerFrame +{ +public: + virtual void AddRenderable(IClientRenderable * pRenderable, bool bRenderWithViewModels, RenderableTranslucencyType_t nType, RenderableModelType_t nModelType, uint32 nSplitscreenEnabled = 0xFFFFFFFF) = 0; + + virtual bool IsRenderableInPVS(IClientRenderable* pRenderable) = 0; + + virtual void SetSubSystemDataInLeaf(int leaf, int nSubSystemIdx, CClientLeafSubSystemData* pData) = 0; + virtual CClientLeafSubSystemData* GetSubSystemDataInLeaf(int leaf, int nSubSystemIdx) = 0; + + virtual void SetDetailObjectsInLeaf(int leaf, int firstDetailObject, int detailObjectCount) = 0; + virtual void GetDetailObjectsInLeaf(int leaf, int& firstDetailObject, int& detailObjectCount) = 0; + + virtual void DrawDetailObjectsInLeaf(int leaf, int frameNumber, int& firstDetailObject, int& detailObjectCount) = 0; + + virtual bool ShouldDrawDetailObjectsInLeaf(int leaf, int frameNumber) = 0; + + virtual void RenderableChanged(ClientRenderHandle_t handle) = 0; + + virtual void BuildRenderablesList(const SetupRenderInfo_t& info) = 0; + + virtual void CollateViewModelRenderables(CViewModelRenderablesList* pList) = 0; + + virtual void DrawStaticProps(bool enable) = 0; + + virtual void DrawSmallEntities(bool enable) = 0; + + virtual ClientLeafShadowHandle_t AddShadow(ClientShadowHandle_t userId, unsigned short flags) = 0; + virtual void RemoveShadow(ClientLeafShadowHandle_t h) = 0; + + virtual void ProjectShadow(ClientLeafShadowHandle_t handle, int nLeafCount, const int* pLeafList) = 0; + + virtual void ProjectFlashlight(ClientLeafShadowHandle_t handle, int nLeafCount, const int* pLeafList) = 0; + + virtual void EnumerateShadowsInLeaves(int leafCount, WorldListLeafData_t* pLeaves, IClientLeafShadowEnum* pEnum) = 0; + + virtual int GetRenderableLeaves(ClientRenderHandle_t handle, int leaves[128]) = 0; + + virtual bool GetRenderableLeaf(ClientRenderHandle_t handle, int* pOutLeaf, const int* pInIterator = 0, int* pOutIterator = 0) = 0; + + virtual void EnableAlternateSorting(ClientRenderHandle_t handle, bool bEnable) = 0; + + virtual void RenderWithViewModels(ClientRenderHandle_t handle, bool bEnable) = 0; + virtual bool IsRenderingWithViewModels(ClientRenderHandle_t handle) const = 0; + + virtual void SetTranslucencyType(ClientRenderHandle_t handle, RenderableTranslucencyType_t nType) = 0; + virtual RenderableTranslucencyType_t GetTranslucencyType(ClientRenderHandle_t handle) const = 0; + virtual void SetModelType(ClientRenderHandle_t handle, RenderableModelType_t nType = RENDERABLE_MODEL_UNKNOWN_TYPE) = 0; + virtual void EnableSplitscreenRendering(ClientRenderHandle_t handle, uint32 nFlags) = 0; + + virtual void EnableRendering(ClientRenderHandle_t handle, bool bEnable) = 0; + + virtual void EnableBloatedBounds(ClientRenderHandle_t handle, bool bEnable) = 0; + + virtual void DisableCachedRenderBounds(ClientRenderHandle_t handle, bool bDisable) = 0; + + virtual void RecomputeRenderableLeaves() = 0; + + virtual void DisableLeafReinsertion(bool bDisable) = 0; + + virtual RenderGroup_t GenerateRenderListEntry(IClientRenderable* pRenderable, CClientRenderablesList::CEntry& entryOut) = 0; +}; + + +extern IClientLeafSystem* g_pClientLeafSystem; +inline IClientLeafSystem* ClientLeafSystem() +{ + return g_pClientLeafSystem; +} + + +#endif diff --git a/SpyCustom/sdk/cmodel.h b/SpyCustom/sdk/cmodel.h new file mode 100644 index 0000000..564da94 --- /dev/null +++ b/SpyCustom/sdk/cmodel.h @@ -0,0 +1,87 @@ +#ifndef CMODEL_H +#define CMODEL_H +#ifdef _WIN32 +#pragma once +#endif + +#include "trace.h" +#include "dbg.h" +#include "basehandle.h" + +struct edict_t; +struct model_t; + +#include "bspflags.h" +#define AREA_SOLID 1 +#define AREA_TRIGGERS 2 + +#include "vcollide.h" + +struct cmodel_t +{ + Vector mins, maxs; + Vector origin; + int headnode; + + vcollide_t vcollisionData; +}; + +struct csurface_t +{ + const char* name; + short surfaceProps; + unsigned short flags; +}; + +struct Ray_t +{ + VectorAligned m_Start; + VectorAligned m_Delta; + VectorAligned m_StartOffset; + VectorAligned m_Extents; + const matrix3x4_t* m_pWorldAxisTransform; + bool m_IsRay; + bool m_IsSwept; + + Ray_t() : m_pWorldAxisTransform(NULL) {} + + void Init(Vector const& start, Vector const& end) + { + m_Delta = end - start; + + m_IsSwept = (m_Delta.LengthSqr() != 0); + + m_Extents.Init(); + + m_pWorldAxisTransform = NULL; + m_IsRay = true; + + m_StartOffset.Init(); + m_Start = start; + } + + Vector InvDelta() const + { + Vector vecInvDelta; + for (int iAxis = 0; iAxis < 3; ++iAxis) + { + if (m_Delta[iAxis] != 0.0f) + { + vecInvDelta[iAxis] = 1.0f / m_Delta[iAxis]; + } + else + { + vecInvDelta[iAxis] = FLT_MAX; + } + } + return vecInvDelta; + } + +private: +}; + + +#endif + + +#include "gametrace.h" \ No newline at end of file diff --git a/SpyCustom/sdk/collisionproperty.h b/SpyCustom/sdk/collisionproperty.h new file mode 100644 index 0000000..0f92d26 --- /dev/null +++ b/SpyCustom/sdk/collisionproperty.h @@ -0,0 +1,380 @@ +#ifndef COLLISIONPROPERTY_H +#define COLLISIONPROPERTY_H +#ifdef _WIN32 +#pragma once +#endif + +#include "networkvar.h" +#include "ICollideable.h" +#include "vector.h" +#include "ispatialpartition.h" + + +class CBaseEntity; +class IHandleEntity; +class QAngle; +class Vector; +struct Ray_t; +class IPhysicsObject; + + +void UpdateDirtySpatialPartitionEntities(); + + +enum SurroundingBoundsType_t +{ + USE_OBB_COLLISION_BOUNDS = 0, + USE_BEST_COLLISION_BOUNDS, + USE_HITBOXES, + USE_SPECIFIED_BOUNDS, + USE_GAME_CODE, + USE_ROTATION_EXPANDED_BOUNDS, + USE_COLLISION_BOUNDS_NEVER_VPHYSICS, + + SURROUNDING_TYPE_BIT_COUNT = 3 +}; + + +class CCollisionProperty : public ICollideable +{ + DECLARE_CLASS_NOBASE(CCollisionProperty); + DECLARE_EMBEDDED_NETWORKVAR(); + DECLARE_PREDICTABLE(); + +#ifdef GAME_DLL + DECLARE_DATADESC(); +#endif + +public: + CCollisionProperty(); + ~CCollisionProperty(); + + void Init(CBaseEntity* pEntity); + + virtual IHandleEntity* GetEntityHandle(); + virtual const Vector& OBBMinsPreScaled() const { return m_vecMinsPreScaled.Get(); } + virtual const Vector& OBBMaxsPreScaled() const { return m_vecMaxsPreScaled.Get(); } + virtual const Vector& OBBMins() const { return m_vecMins.Get(); } + virtual const Vector& OBBMaxs() const { return m_vecMaxs.Get(); } + virtual void WorldSpaceTriggerBounds(Vector* pVecWorldMins, Vector* pVecWorldMaxs) const; + virtual bool TestCollision(const Ray_t& ray, unsigned int fContentsMask, trace_t& tr); + virtual bool TestHitboxes(const Ray_t& ray, unsigned int fContentsMask, trace_t& tr); + virtual int GetCollisionModelIndex(); + virtual const model_t* GetCollisionModel(); + virtual const Vector& GetCollisionOrigin() const; + virtual const QAngle& GetCollisionAngles() const; + virtual const matrix3x4_t& CollisionToWorldTransform() const; + virtual SolidType_t GetSolid() const; + virtual int GetSolidFlags() const; + virtual IClientUnknown* GetIClientUnknown(); + virtual int GetCollisionGroup() const; + virtual void WorldSpaceSurroundingBounds(Vector* pVecMins, Vector* pVecMaxs); + virtual bool ShouldTouchTrigger(int triggerSolidFlags) const; + virtual const matrix3x4_t* GetRootParentToWorldTransform() const; + +public: + void CreatePartitionHandle(); + void DestroyPartitionHandle(); + unsigned short GetPartitionHandle() const; + + void MarkPartitionHandleDirty(); + + void SetCollisionBounds(const Vector& mins, const Vector& maxs); + + void RefreshScaledCollisionBounds(void); + + void UseTriggerBounds(bool bEnable, float flBloat = 0.0f); + + void SetSurroundingBoundsType(SurroundingBoundsType_t type, const Vector* pMins = NULL, const Vector* pMaxs = NULL); + + void SetSolid(SolidType_t val); + + const Vector& OBBSize() const; + + float BoundingRadius() const; + float BoundingRadius2D() const; + + const Vector& OBBCenter() const; + + const Vector& WorldSpaceCenter() const; + + void ClearSolidFlags(void); + void RemoveSolidFlags(int flags); + void AddSolidFlags(int flags); + bool IsSolidFlagSet(int flagMask) const; + void SetSolidFlags(int flags); + bool IsSolid() const; + + void UpdatePartition(); + + bool IsBoundsDefinedInEntitySpace() const; + + const Vector& CollisionToWorldSpace(const Vector& in, Vector* pResult) const; + + const Vector& WorldToCollisionSpace(const Vector& in, Vector* pResult) const; + + const Vector& WorldDirectionToCollisionSpace(const Vector& in, Vector* pResult) const; + + void RandomPointInBounds(const Vector& vecNormalizedMins, const Vector& vecNormalizedMaxs, Vector* pPoint) const; + + bool IsPointInBounds(const Vector& vecWorldPt) const; + + void WorldSpaceAABB(Vector* pWorldMins, Vector* pWorldMaxs) const; + + const Vector& CollisionSpaceMins(void) const; + + const Vector& CollisionSpaceMaxs(void) const; + + const Vector& NormalizedToCollisionSpace(const Vector& in, Vector* pResult) const; + + const Vector& NormalizedToWorldSpace(const Vector& in, Vector* pResult) const; + + const Vector& WorldToNormalizedSpace(const Vector& in, Vector* pResult) const; + + const Vector& CollisionToNormalizedSpace(const Vector& in, Vector* pResult) const; + + void CalcNearestPoint(const Vector& vecWorldPt, Vector* pVecNearestWorldPt) const; + + float CalcDistanceFromPoint(const Vector& vecWorldPt) const; + + bool DoesRotationInvalidateSurroundingBox() const; + + bool DoesVPhysicsInvalidateSurroundingBox() const; + + void MarkSurroundingBoundsDirty(); + + float ComputeSupportMap(const Vector& vecDirection) const; + +private: + void CollisionAABBToWorldAABB(const Vector& entityMins, const Vector& entityMaxs, Vector* pWorldMins, Vector* pWorldMaxs) const; + + void ComputeVPhysicsSurroundingBox(Vector* pVecWorldMins, Vector* pVecWorldMaxs); + + bool ComputeHitboxSurroundingBox(Vector* pVecWorldMins, Vector* pVecWorldMaxs); + bool ComputeEntitySpaceHitboxSurroundingBox(Vector* pVecWorldMins, Vector* pVecWorldMaxs); + + void ComputeCollisionSurroundingBox(bool bUseVPhysics, Vector* pVecWorldMins, Vector* pVecWorldMaxs); + + void ComputeRotationExpandedBounds(Vector* pVecWorldMins, Vector* pVecWorldMaxs); + + void ComputeSurroundingBox(Vector* pVecWorldMins, Vector* pVecWorldMaxs); + + void CheckForUntouch(); + + void UpdateServerPartitionMask(); + + CBaseEntity* GetOuter(); + const CBaseEntity* GetOuter() const; + +private: + CBaseEntity* m_pOuter; + + CNetworkVector(m_vecMinsPreScaled); + CNetworkVector(m_vecMaxsPreScaled); + CNetworkVector(m_vecMins); + CNetworkVector(m_vecMaxs); + float m_flRadius; + + CNetworkVar(unsigned short, m_usSolidFlags); + + SpatialPartitionHandle_t m_Partition; + CNetworkVar(unsigned char, m_nSurroundType); + + CNetworkVar(unsigned char, m_nSolidType); + CNetworkVar(unsigned char, m_triggerBloat); + + CNetworkVector(m_vecSpecifiedSurroundingMinsPreScaled); + CNetworkVector(m_vecSpecifiedSurroundingMaxsPreScaled); + CNetworkVector(m_vecSpecifiedSurroundingMins); + CNetworkVector(m_vecSpecifiedSurroundingMaxs); + +#if 0 + short m_surroundingMins[3]; + short m_surroundingMaxs[3]; +#else + Vector m_vecSurroundingMins; + Vector m_vecSurroundingMaxs; +#endif + + friend class CBaseEntity; +}; + + +#ifdef CLIENT_DLL +EXTERN_RECV_TABLE(DT_CollisionProperty); +#else +EXTERN_SEND_TABLE(DT_CollisionProperty); +#endif + + +inline CBaseEntity* CCollisionProperty::GetOuter() +{ + return m_pOuter; +} + +inline const CBaseEntity* CCollisionProperty::GetOuter() const +{ + return m_pOuter; +} + + +inline unsigned short CCollisionProperty::GetPartitionHandle() const +{ + return m_Partition; +} + + +inline const Vector& CCollisionProperty::OBBSize() const +{ + Vector& temp = AllocTempVector(); + VectorSubtract(m_vecMaxs, m_vecMins, temp); + return temp; +} + + +inline float CCollisionProperty::BoundingRadius() const +{ + return m_flRadius; +} + + +inline bool CCollisionProperty::IsBoundsDefinedInEntitySpace() const +{ + return ((m_usSolidFlags & FSOLID_FORCE_WORLD_ALIGNED) == 0) && + (m_nSolidType != SOLID_BBOX) && (m_nSolidType != SOLID_NONE); +} + +inline void CCollisionProperty::ClearSolidFlags(void) +{ + SetSolidFlags(0); +} + +inline void CCollisionProperty::RemoveSolidFlags(int flags) +{ + SetSolidFlags(m_usSolidFlags & ~flags); +} + +inline void CCollisionProperty::AddSolidFlags(int flags) +{ + SetSolidFlags(m_usSolidFlags | flags); +} + +inline int CCollisionProperty::GetSolidFlags(void) const +{ + return m_usSolidFlags; +} + +inline bool CCollisionProperty::IsSolidFlagSet(int flagMask) const +{ + return (m_usSolidFlags & flagMask) != 0; +} + +inline bool CCollisionProperty::IsSolid() const +{ + return ::IsSolid((SolidType_t)(unsigned char)m_nSolidType, m_usSolidFlags); +} + + +inline const Vector& CCollisionProperty::OBBCenter() const +{ + Vector& vecResult = AllocTempVector(); + VectorLerp(m_vecMins, m_vecMaxs, 0.5f, vecResult); + return vecResult; +} + + +inline const Vector& CCollisionProperty::WorldSpaceCenter() const +{ + Vector& vecResult = AllocTempVector(); + CollisionToWorldSpace(OBBCenter(), &vecResult); + return vecResult; +} + + +inline const Vector& CCollisionProperty::CollisionToWorldSpace(const Vector& in, Vector* pResult) const +{ + if (!IsBoundsDefinedInEntitySpace() || (GetCollisionAngles() == vec3_angle)) + { + VectorAdd(in, GetCollisionOrigin(), *pResult); + } + else + { + VectorTransform(in, CollisionToWorldTransform(), *pResult); + } + return *pResult; +} + + +inline const Vector& CCollisionProperty::WorldToCollisionSpace(const Vector& in, Vector* pResult) const +{ + if (!IsBoundsDefinedInEntitySpace() || (GetCollisionAngles() == vec3_angle)) + { + VectorSubtract(in, GetCollisionOrigin(), *pResult); + } + else + { + VectorITransform(in, CollisionToWorldTransform(), *pResult); + } + return *pResult; +} + + +inline const Vector& CCollisionProperty::WorldDirectionToCollisionSpace(const Vector& in, Vector* pResult) const +{ + if (!IsBoundsDefinedInEntitySpace() || (GetCollisionAngles() == vec3_angle)) + { + *pResult = in; + } + else + { + VectorIRotate(in, CollisionToWorldTransform(), *pResult); + } + return *pResult; +} + + +inline void CCollisionProperty::WorldSpaceAABB(Vector* pWorldMins, Vector* pWorldMaxs) const +{ + CollisionAABBToWorldAABB(m_vecMins, m_vecMaxs, pWorldMins, pWorldMaxs); +} + + +inline const Vector& CCollisionProperty::CollisionSpaceMins(void) const +{ + return m_vecMins; +} + +inline const Vector& CCollisionProperty::CollisionSpaceMaxs(void) const +{ + return m_vecMaxs; +} + + +inline bool CCollisionProperty::DoesRotationInvalidateSurroundingBox() const +{ + if (IsSolidFlagSet(FSOLID_ROOT_PARENT_ALIGNED)) + return true; + + switch (m_nSurroundType) + { + case USE_COLLISION_BOUNDS_NEVER_VPHYSICS: + case USE_OBB_COLLISION_BOUNDS: + case USE_BEST_COLLISION_BOUNDS: + return IsBoundsDefinedInEntitySpace(); + + case USE_HITBOXES: + case USE_GAME_CODE: + return true; + + case USE_ROTATION_EXPANDED_BOUNDS: + case USE_SPECIFIED_BOUNDS: + return false; + + default: + Assert(0); + return true; + } +} + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/commonmacros.h b/SpyCustom/sdk/commonmacros.h new file mode 100644 index 0000000..73ade7a --- /dev/null +++ b/SpyCustom/sdk/commonmacros.h @@ -0,0 +1,85 @@ +#ifndef COMMONMACROS_H +#define COMMONMACROS_H + +#ifdef _WIN32 +#pragma once +#endif + +#define MAKEID(d,c,b,a) ( ((int)(a) << 24) | ((int)(b) << 16) | ((int)(c) << 8) | ((int)(d)) ) + +#define STRING_MATCHES_ID( p, id ) ( (*((int *)(p)) == (id) ) ? true : false ) +#define ID_TO_STRING( id, p ) ( (p)[3] = (((id)>>24) & 0xFF), (p)[2] = (((id)>>16) & 0xFF), (p)[1] = (((id)>>8) & 0xFF), (p)[0] = (((id)>>0) & 0xFF) ) + +#define SETBITS(iBitVector, bits) ((iBitVector) |= (bits)) +#define CLEARBITS(iBitVector, bits) ((iBitVector) &= ~(bits)) +#define FBitSet(iBitVector, bits) ((iBitVector) & (bits)) + +template +inline bool IsPowerOfTwo(T value) +{ + return (value & (value - (T)1)) == (T)0; +} + +#ifndef REFERENCE +#define REFERENCE(arg) ((void)arg) +#endif + +#define CONST_INTEGER_AS_STRING(x) #x +#define __HACK_LINE_AS_STRING__(x) CONST_INTEGER_AS_STRING(x) +#define __LINE__AS_STRING __HACK_LINE_AS_STRING__(__LINE__) + +#ifdef ARRAYSIZE +#undef ARRAYSIZE +#endif + +#define RTL_NUMBER_OF_V1(A) (sizeof(A)/sizeof((A)[0])) + +#if defined(__cplusplus) && \ + !defined(MIDL_PASS) && \ + !defined(RC_INVOKED) && \ + (_MSC_FULL_VER >= 13009466) && \ + !defined(SORTPP_PASS) + +#if !defined(UNALIGNED) +#if defined(_M_IA64) || defined(_M_AMD64) +#define UNALIGNED __unaligned +#else +#define UNALIGNED +#endif +#endif + +extern "C++" +template +char(*RtlpNumberOf(UNALIGNED T(&)[N]))[N]; + +#ifdef _PREFAST_ +#define RTL_NUMBER_OF_V2(A) (sizeof(*RtlpNumberOf(A))+0) +#else +#define RTL_NUMBER_OF_V2(A) (sizeof(*RtlpNumberOf(A))) +#endif + +#else +#define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A) +#endif + +#define ARRAYSIZE(A) RTL_NUMBER_OF_V2(A) +#define _ARRAYSIZE(A) RTL_NUMBER_OF_V1(A) + +#define Q_ARRAYSIZE(p) ARRAYSIZE(p) + +template< typename IndexType, typename T, unsigned int N > +IndexType ClampedArrayIndex(const T(&buffer)[N], IndexType index) +{ + NOTE_UNUSED(buffer); + return clamp(index, 0, (IndexType)N - 1); +} + +template< typename T, unsigned int N > +T ClampedArrayElement(const T(&buffer)[N], unsigned int uIndex) +{ + if (uIndex >= N) + uIndex = N - 1; + return buffer[uIndex]; +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/compressed_light_cube.h b/SpyCustom/sdk/compressed_light_cube.h new file mode 100644 index 0000000..ef4f269 --- /dev/null +++ b/SpyCustom/sdk/compressed_light_cube.h @@ -0,0 +1,18 @@ +#ifndef COMPRESSED_LIGHT_CUBE_H +#define COMPRESSED_LIGHT_CUBE_H +#ifdef _WIN32 +#pragma once +#endif + + +#include "mathlib.h" + + +struct CompressedLightCube +{ + DECLARE_BYTESWAP_DATADESC(); + ColorRGBExp32 m_Color[6]; +}; + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/compressed_vector.h b/SpyCustom/sdk/compressed_vector.h new file mode 100644 index 0000000..5823ba3 --- /dev/null +++ b/SpyCustom/sdk/compressed_vector.h @@ -0,0 +1,519 @@ +#ifndef COMPRESSED_VECTOR_H +#define COMPRESSED_VECTOR_H + +#ifdef _WIN32 +#pragma once +#endif + +#include +#include + +#include "basetypes.h" + +#include + +#include "dbg.h" +#include "vector.h" + +#include "mathlib.h" + +#if defined( _X360 ) +#pragma bitfield_order( push, lsb_to_msb ) +#endif +class Vector32 +{ +public: + Vector32(void); + Vector32(vec_t X, vec_t Y, vec_t Z); + + Vector32& operator=(const Vector& vOther); + operator Vector (); + +private: + unsigned short x : 10; + unsigned short y : 10; + unsigned short z : 10; + unsigned short exp : 2; +}; + +inline Vector32& Vector32::operator=(const Vector& vOther) +{ + CHECK_VALID(vOther); + + static float expScale[4] = { 4.0f, 16.0f, 32.f, 64.f }; + + float fmax = Max(fabs(vOther.x), fabs(vOther.y)); + fmax = Max(fmax, (float)fabs(vOther.z)); + + for (exp = 0; exp < 3; exp++) + { + if (fmax < expScale[exp]) + break; + } + Assert(fmax < expScale[exp]); + + float fexp = 512.0f / expScale[exp]; + + x = Clamp((int)(vOther.x * fexp) + 512, 0, 1023); + y = Clamp((int)(vOther.y * fexp) + 512, 0, 1023); + z = Clamp((int)(vOther.z * fexp) + 512, 0, 1023); + return *this; +} + + +inline Vector32::operator Vector () +{ + Vector tmp; + + static float expScale[4] = { 4.0f, 16.0f, 32.f, 64.f }; + + float fexp = expScale[exp] / 512.0f; + + tmp.x = (((int)x) - 512) * fexp; + tmp.y = (((int)y) - 512) * fexp; + tmp.z = (((int)z) - 512) * fexp; + return tmp; +} + + +class Normal32 +{ +public: + Normal32(void); + Normal32(vec_t X, vec_t Y, vec_t Z); + + Normal32& operator=(const Vector& vOther); + operator Vector (); + +private: + unsigned short x : 15; + unsigned short y : 15; + unsigned short zneg : 1; +}; + + +inline Normal32& Normal32::operator=(const Vector& vOther) +{ + CHECK_VALID(vOther); + + x = Clamp((int)(vOther.x * 16384) + 16384, 0, 32767); + y = Clamp((int)(vOther.y * 16384) + 16384, 0, 32767); + zneg = (vOther.z < 0); + return *this; +} + + +inline Normal32::operator Vector () +{ + Vector tmp; + + tmp.x = ((int)x - 16384) * (1 / 16384.0); + tmp.y = ((int)y - 16384) * (1 / 16384.0); + tmp.z = sqrt(1 - tmp.x * tmp.x - tmp.y * tmp.y); + if (zneg) + tmp.z = -tmp.z; + return tmp; +} + + +class Quaternion64 +{ +public: + Quaternion64(void); + Quaternion64(vec_t X, vec_t Y, vec_t Z); + + Quaternion64& operator=(const Quaternion& vOther); + operator Quaternion (); +private: + uint64 x : 21; + uint64 y : 21; + uint64 z : 21; + uint64 wneg : 1; +}; + + +inline Quaternion64::operator Quaternion () +{ + Quaternion tmp; + + tmp.x = ((int)x - 1048576) * (1 / 1048576.5f); + tmp.y = ((int)y - 1048576) * (1 / 1048576.5f); + tmp.z = ((int)z - 1048576) * (1 / 1048576.5f); + tmp.w = sqrt(1 - tmp.x * tmp.x - tmp.y * tmp.y - tmp.z * tmp.z); + if (wneg) + tmp.w = -tmp.w; + return tmp; +} + +inline Quaternion64& Quaternion64::operator=(const Quaternion& vOther) +{ + CHECK_VALID(vOther); + + x = Clamp((int)(vOther.x * 1048576) + 1048576, 0, 2097151); + y = Clamp((int)(vOther.y * 1048576) + 1048576, 0, 2097151); + z = Clamp((int)(vOther.z * 1048576) + 1048576, 0, 2097151); + wneg = (vOther.w < 0); + return *this; +} + +class Quaternion48 +{ +public: + Quaternion48(void); + Quaternion48(vec_t X, vec_t Y, vec_t Z); + + Quaternion48& operator=(const Quaternion& vOther); + operator Quaternion (); +private: + unsigned short x : 16; + unsigned short y : 16; + unsigned short z : 15; + unsigned short wneg : 1; +}; + + +inline Quaternion48::operator Quaternion () +{ + Quaternion tmp; + + tmp.x = ((int)x - 32768) * (1 / 32768.0); + tmp.y = ((int)y - 32768) * (1 / 32768.0); + tmp.z = ((int)z - 16384) * (1 / 16384.0); + tmp.w = sqrt(1 - tmp.x * tmp.x - tmp.y * tmp.y - tmp.z * tmp.z); + if (wneg) + tmp.w = -tmp.w; + return tmp; +} + +inline Quaternion48& Quaternion48::operator=(const Quaternion& vOther) +{ + CHECK_VALID(vOther); + + x = Clamp((int)(vOther.x * 32768) + 32768, 0, 65535); + y = Clamp((int)(vOther.y * 32768) + 32768, 0, 65535); + z = Clamp((int)(vOther.z * 16384) + 16384, 0, 32767); + wneg = (vOther.w < 0); + return *this; +} + +class Quaternion32 +{ +public: + Quaternion32(void); + Quaternion32(vec_t X, vec_t Y, vec_t Z); + + Quaternion32& operator=(const Quaternion& vOther); + operator Quaternion (); +private: + unsigned int x : 11; + unsigned int y : 10; + unsigned int z : 10; + unsigned int wneg : 1; +}; + + +inline Quaternion32::operator Quaternion () +{ + Quaternion tmp; + + tmp.x = ((int)x - 1024) * (1 / 1024.0); + tmp.y = ((int)y - 512) * (1 / 512.0); + tmp.z = ((int)z - 512) * (1 / 512.0); + tmp.w = sqrt(1 - tmp.x * tmp.x - tmp.y * tmp.y - tmp.z * tmp.z); + if (wneg) + tmp.w = -tmp.w; + return tmp; +} + +inline Quaternion32& Quaternion32::operator=(const Quaternion& vOther) +{ + CHECK_VALID(vOther); + + x = Clamp((int)(vOther.x * 1024) + 1024, 0, 2047); + y = Clamp((int)(vOther.y * 512) + 512, 0, 1023); + z = Clamp((int)(vOther.z * 512) + 512, 0, 1023); + wneg = (vOther.w < 0); + return *this; +} + + +const int float32bias = 127; +const int float16bias = 15; + +const float maxfloat16bits = 65504.0f; + +class float16 +{ +public: + void Init() { m_storage.rawWord = 0; } + unsigned short GetBits() const + { + return m_storage.rawWord; + } + float GetFloat() const + { + return Convert16bitFloatTo32bits(m_storage.rawWord); + } + void SetFloat(float in) + { + m_storage.rawWord = ConvertFloatTo16bits(in); + } + + bool IsInfinity() const + { + return m_storage.bits.biased_exponent == 31 && m_storage.bits.mantissa == 0; + } + bool IsNaN() const + { + return m_storage.bits.biased_exponent == 31 && m_storage.bits.mantissa != 0; + } + + bool operator==(const float16 other) const { return m_storage.rawWord == other.m_storage.rawWord; } + bool operator!=(const float16 other) const { return m_storage.rawWord != other.m_storage.rawWord; } + +protected: + union float32bits + { + float rawFloat; + struct + { + unsigned int mantissa : 23; + unsigned int biased_exponent : 8; + unsigned int sign : 1; + } bits; + }; + + union float16bits + { + unsigned short rawWord; + struct + { + unsigned short mantissa : 10; + unsigned short biased_exponent : 5; + unsigned short sign : 1; + } bits; + }; + + static bool IsNaN(float16bits in) + { + return in.bits.biased_exponent == 31 && in.bits.mantissa != 0; + } + static bool IsInfinity(float16bits in) + { + return in.bits.biased_exponent == 31 && in.bits.mantissa == 0; + } + + static unsigned short ConvertFloatTo16bits(float input) + { + if (input > maxfloat16bits) + input = maxfloat16bits; + else if (input < -maxfloat16bits) + input = -maxfloat16bits; + + float16bits output; + float32bits inFloat; + + inFloat.rawFloat = input; + + output.bits.sign = inFloat.bits.sign; + + if ((inFloat.bits.biased_exponent == 0) && (inFloat.bits.mantissa == 0)) + { + output.bits.mantissa = 0; + output.bits.biased_exponent = 0; + } + else if ((inFloat.bits.biased_exponent == 0) && (inFloat.bits.mantissa != 0)) + { + output.bits.mantissa = 0; + output.bits.biased_exponent = 0; + } + else if ((inFloat.bits.biased_exponent == 0xff) && (inFloat.bits.mantissa == 0)) + { +#if 0 + output.bits.mantissa = 0; + output.bits.biased_exponent = 31; +#else + output.bits.mantissa = 0x3ff; + output.bits.biased_exponent = 0x1e; +#endif + } + else if ((inFloat.bits.biased_exponent == 0xff) && (inFloat.bits.mantissa != 0)) + { +#if 0 + output.bits.mantissa = 1; + output.bits.biased_exponent = 31; +#else + output.bits.mantissa = 0; + output.bits.biased_exponent = 0; +#endif + } + else + { + int new_exp = inFloat.bits.biased_exponent - 127; + + if (new_exp < -24) + { + output.bits.mantissa = 0; + output.bits.biased_exponent = 0; + } + + if (new_exp < -14) + { + output.bits.biased_exponent = 0; + unsigned int exp_val = (unsigned int)(-14 - (inFloat.bits.biased_exponent - float32bias)); + if (exp_val > 0 && exp_val < 11) + { + output.bits.mantissa = (1 << (10 - exp_val)) + (inFloat.bits.mantissa >> (13 + exp_val)); + } + } + else if (new_exp > 15) + { +#if 0 + output.bits.mantissa = 0; + output.bits.biased_exponent = 31; +#else + output.bits.mantissa = 0x3ff; + output.bits.biased_exponent = 0x1e; +#endif + } + else + { + output.bits.biased_exponent = new_exp + 15; + output.bits.mantissa = (inFloat.bits.mantissa >> 13); + } + } + return output.rawWord; + } + + static float Convert16bitFloatTo32bits(unsigned short input) + { + float32bits output; + const float16bits& inFloat = *((float16bits*)&input); + + if (IsInfinity(inFloat)) + { + return maxfloat16bits * ((inFloat.bits.sign == 1) ? -1.0f : 1.0f); + } + if (IsNaN(inFloat)) + { + return 0.0; + } + if (inFloat.bits.biased_exponent == 0 && inFloat.bits.mantissa != 0) + { + const float half_denorm = (1.0f / 16384.0f); + float mantissa = ((float)(inFloat.bits.mantissa)) / 1024.0f; + float sgn = (inFloat.bits.sign) ? -1.0f : 1.0f; + output.rawFloat = sgn * mantissa * half_denorm; + } + else + { + unsigned mantissa = inFloat.bits.mantissa; + unsigned biased_exponent = inFloat.bits.biased_exponent; + unsigned sign = ((unsigned)inFloat.bits.sign) << 31; + biased_exponent = ((biased_exponent - float16bias + float32bias) * (biased_exponent != 0)) << 23; + mantissa <<= (23 - 10); + + *((unsigned*)&output) = (mantissa | biased_exponent | sign); + } + + return output.rawFloat; + } + + + float16bits m_storage; +}; + +class float16_with_assign : public float16 +{ +public: + float16_with_assign() {} + float16_with_assign(float f) { m_storage.rawWord = ConvertFloatTo16bits(f); } + + float16& operator=(const float16& other) { m_storage.rawWord = ((float16_with_assign&)other).m_storage.rawWord; return *this; } + float16& operator=(const float& other) { m_storage.rawWord = ConvertFloatTo16bits(other); return *this; } + operator float() const { return Convert16bitFloatTo32bits(m_storage.rawWord); } +}; + +class Vector48 +{ +public: + Vector48(void) {} + Vector48(vec_t X, vec_t Y, vec_t Z) { x.SetFloat(X); y.SetFloat(Y); z.SetFloat(Z); } + + Vector48& operator=(const Vector& vOther); + operator Vector (); + + const float operator[](int i) const { return (((float16*)this)[i]).GetFloat(); } + + float16 x; + float16 y; + float16 z; +}; + +inline Vector48& Vector48::operator=(const Vector& vOther) +{ + CHECK_VALID(vOther); + + x.SetFloat(vOther.x); + y.SetFloat(vOther.y); + z.SetFloat(vOther.z); + return *this; +} + + +inline Vector48::operator Vector () +{ + Vector tmp; + + tmp.x = x.GetFloat(); + tmp.y = y.GetFloat(); + tmp.z = z.GetFloat(); + + return tmp; +} + +class Vector2d32 +{ +public: + Vector2d32(void) {} + Vector2d32(vec_t X, vec_t Y) { x.SetFloat(X); y.SetFloat(Y); } + + Vector2d32& operator=(const Vector& vOther); + Vector2d32& operator=(const Vector2D& vOther); + + operator Vector2D (); + + void Init(vec_t ix = 0.f, vec_t iy = 0.f); + + float16_with_assign x; + float16_with_assign y; +}; + +inline Vector2d32& Vector2d32::operator=(const Vector2D& vOther) +{ + x.SetFloat(vOther.x); + y.SetFloat(vOther.y); + return *this; +} + +inline Vector2d32::operator Vector2D () +{ + Vector2D tmp; + + tmp.x = x.GetFloat(); + tmp.y = y.GetFloat(); + + return tmp; +} + +inline void Vector2d32::Init(vec_t ix, vec_t iy) +{ + x.SetFloat(ix); + y.SetFloat(iy); +} + +#if defined( _X360 ) +#pragma bitfield_order( pop ) +#endif + +#endif diff --git a/SpyCustom/sdk/const.h b/SpyCustom/sdk/const.h new file mode 100644 index 0000000..80cb384 --- /dev/null +++ b/SpyCustom/sdk/const.h @@ -0,0 +1,364 @@ +#ifndef CONST_H +#define CONST_H + +#ifdef _WIN32 +#pragma once +#endif + +#define STEAM_PARM "-steam" +#define AUTO_RESTART "-autoupdate" + +#define INVALID_STEAM_TICKET "Invalid STEAM UserID Ticket\n" +#define INVALID_STEAM_VACBANSTATE "VAC banned from secure server\n" +#define INVALID_STEAM_LOGGED_IN_ELSEWHERE "This Steam account is being used in another location\n" +#define INVALID_STEAM_LOGON_NOT_CONNECTED "Client not connected to Steam\n" +#define INVALID_STEAM_LOGON_TICKET_CANCELED "Client left game (Steam auth ticket has been canceled)\n" + +#define CLIENTNAME_TIMED_OUT "%s timed out" + +#define DEFAULT_TICK_INTERVAL (0.015) +#define MINIMUM_TICK_INTERVAL (0.001) +#define MAXIMUM_TICK_INTERVAL (0.1) + +#define ABSOLUTE_PLAYER_LIMIT 255 +#define ABSOLUTE_PLAYER_LIMIT_DW ( (ABSOLUTE_PLAYER_LIMIT/32) + 1 ) + +#define MAX_PLAYER_NAME_LENGTH 32 + +#ifdef _X360 +#define MAX_PLAYERS_PER_CLIENT XUSER_MAX_COUNT +#else +#define MAX_PLAYERS_PER_CLIENT 1 +#endif + +#define MAX_MAP_NAME 96 + +#define MAX_MAP_NAME_SAVE 32 + +#define MAX_DISPLAY_MAP_NAME 32 + +#define MAX_NETWORKID_LENGTH 64 + +#define SP_MODEL_INDEX_BITS 13 + +#define MAX_EDICT_BITS 11 +#define MAX_EDICTS (1<& commands) = 0; +}; + +class ConCommandBase +{ + friend class CCvar; + friend class ConVar; + friend class ConCommand; + friend void ConVar_Register(int nCVarFlag, IConCommandBaseAccessor* pAccessor); + 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; + + virtual bool IsFlagSet(int flag) const; + virtual void AddFlags(int flags); + virtual void RemoveFlags(int flags); + virtual int GetFlags() const; + virtual const char* GetName(void) const; + + virtual const char* GetHelpText(void) const; + + const ConCommandBase* GetNext(void) const; + ConCommandBase* GetNext(void); + + virtual bool IsRegistered(void) const; + + virtual CVarDLLIdentifier_t GetDLLIdentifier() const; + + virtual void Create(const char* pName, const char* pHelpString = 0, + int flags = 0); + + virtual void Init(); + void Shutdown(); + + char* CopyString(const char* from); + + ConCommandBase* m_pNext; + + bool m_bRegistered; + + const char* m_pszName; + const char* m_pszHelpString; + + int m_nFlags; + +protected: + static ConCommandBase* s_pConCommandBases; + + static IConCommandBaseAccessor* s_pAccessor; +}; + + +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; + const char* GetCommandString() const; + const char* operator[](int nIndex) const; + const char* Arg(int nIndex) const; + + 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 +{ + if (nIndex < 0 || nIndex >= m_nArgc) + return ""; + return m_ppArgv[nIndex]; +} + +inline const char* CCommand::operator[](int nIndex) const +{ + return Arg(nIndex); +} + + +class ConCommand : public ConCommandBase +{ + friend class CCvar; + +public: + typedef ConCommandBase BaseClass; + + ConCommand(const char* pName, FnCommandCallbackVoid_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); + + virtual void Dispatch(const CCommand& command); + +private: + union + { + FnCommandCallbackVoid_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; +}; + + +class ConVar : public ConCommandBase, public IConVar +{ + friend class CCvar; + friend class ConVarRef; + +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; + virtual const char* GetBaseName(void) const; + virtual int GetSplitScreenPlayerSlot() const; + virtual void AddFlags(int flags); + virtual int GetFlags() const; + virtual bool IsCommand(void) const; + + 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]; } + + + FORCEINLINE_CVAR float GetFloat(void) const; + FORCEINLINE_CVAR int GetInt(void) const; + FORCEINLINE_CVAR Color GetColor(void) const; + FORCEINLINE_CVAR bool GetBool() const { return !!GetInt(); } + FORCEINLINE_CVAR char const* GetString(void) const; + + template T Get(void) const; + template T Get(T*) const; + + virtual void SetValue(const char* value); + virtual void SetValue(float value); + virtual void SetValue(int value); + virtual void SetValue(Color value); + + void Revert(void); + bool HasMin() const; + bool HasMax() const; + + struct CVValue_t + { + char* m_pszString; + int m_StringLength; + float m_fValue; + int m_nValue; + }; + + bool GetMin(float& minVal) const; + bool GetMax(float& maxVal) const; + float GetMinValue() const; + float GetMaxValue() const; + const char* GetDefault(void) const; + FORCEINLINE_CVAR CVValue_t& GetRawValue() + { + return m_Value; + } + FORCEINLINE_CVAR const CVValue_t& GetRawValue() const + { + return m_Value; + } + + bool InternalSetColorFromString(const char* value); + virtual void InternalSetValue(const char* value); + 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); + + virtual void Init(); + int GetFlags() { return m_pParent->m_nFlags; } +public: + + ConVar* m_pParent; + + const char* m_pszDefaultValue; + + CVValue_t m_Value; + bool m_bHasMin; + float m_fMinVal; + bool m_bHasMax; + float m_fMaxVal; + + CUtlVector m_fnChangeCallbacks; +}; + + +FORCEINLINE_CVAR float ConVar::GetFloat(void) const +{ + uint32_t xored = *(uint32_t*)&m_pParent->m_Value.m_fValue ^ (uint32_t)this; + return *(float*)&xored; +} + +FORCEINLINE_CVAR int ConVar::GetInt(void) const +{ + return (int)(m_pParent->m_Value.m_nValue ^ (int)this); +} + + +FORCEINLINE_CVAR const char* ConVar::GetString(void) const +{ + 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 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(); + + float GetFloat(void) const; + int GetInt(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(bool bValue); + + const char* GetName() const; + + const char* GetDefault() const; + +private: + IConVar* m_pConVar; + ConVar* m_pConVarState; +}; + + +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 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(bool bValue) +{ + m_pConVar->SetValue(bValue ? 1 : 0); +} + +FORCEINLINE_CVAR const char* ConVarRef::GetDefault() const +{ + return m_pConVarState->m_pszDefaultValue; +} + + +void ConVar_Register(int nCVarFlag = 0, IConCommandBaseAccessor* pAccessor = NULL); +void ConVar_Unregister(); + + +void ConVar_PrintFlags(const ConCommandBase* var); +void ConVar_PrintDescription(const ConCommandBase* pVar); + + +#pragma warning (disable : 4355 ) + +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; +}; + +#pragma warning ( default : 4355 ) + + +#define CON_COMMAND( name, description ) \ + static void name( const CCommand &args ); \ + static ConCommand name##_command( #name, name, description ); \ + static void name( const CCommand &args ) + +#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 ) + +#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 ) + +#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 \ No newline at end of file diff --git a/SpyCustom/sdk/cs_achievementdefs.h b/SpyCustom/sdk/cs_achievementdefs.h new file mode 100644 index 0000000..dd8ab1b --- /dev/null +++ b/SpyCustom/sdk/cs_achievementdefs.h @@ -0,0 +1,261 @@ +#ifndef CS_ACHIEVEMENTDEFS_H +#define CS_ACHIEVEMENTDEFS_H +#ifdef _WIN32 +#pragma once +#endif + + + +#define ALL_WEARING_SAME_UNIFORM_ACHIEVEMENT 0 + +typedef enum +{ + CSInvalidAchievement = -1, + + CSBombAchievementsStart = 1000, + + CSWinBombPlant, + CSWinBombDefuse, + CSDefuseAndNeededKit, + CSBombDefuseCloseCall, + CSKilledDefuser, + CSPlantBombWithin25Seconds, + CSKillBombPickup, + CSBombMultikill, + CSGooseChase, + CSWinBombPlantAfterRecovery, + CSDefuseDefense, + CSPlantBombsLow, + CSDefuseBombsLow, + CSPlantBombsTRLow, + CSDefuseBombsTRLow, + + CSBombAchievementsEnd, + + + CSHostageAchievementsStart = 2000, + + CSRescueAllHostagesInARound, + CSKilledRescuer, + CSFastHostageRescue, + CSRescueHostagesLow, + CSRescueHostagesMid, + + CSHostageAchievmentEnd, + + CSKillAchievementsStart = 3000, + + CSEnemyKillsLow, + CSEnemyKillsMed, + CSEnemyKillsHigh, + CSSurvivedHeadshotDueToHelmet, + CSKillEnemyReloading, + CSKillingSpree, + CSKillsWithMultipleGuns, + CSHeadshots, + CSAvengeFriend, + CSSurviveGrenade, + CSDominationsLow, + CSDominationsHigh, + CSRevengesLow, + CSRevengesHigh, + CSDominationOverkillsLow, + CSDominationOverkillsHigh, + CSDominationOverkillsMatch, + CSExtendedDomination, + CSConcurrentDominations, + CSKillEnemyBlinded, + CSKillEnemiesWhileBlind, + CSKillEnemiesWhileBlindHard, + CSKillsEnemyWeapon, + CSKillWithEveryWeapon, + CSWinKnifeFightsLow, + CSWinKnifeFightsHigh, + CSKilledDefuserWithGrenade, + CSKillSniperWithSniper, + CSKillSniperWithKnife, + CSHipShot, + CSKillSnipers, + CSKillWhenAtLowHealth, + CSPistolRoundKnifeKill, + CSWinDualDuel, + CSGrenadeMultikill, + CSKillWhileInAir, + CSKillEnemyInAir, + CSKillerAndEnemyInAir, + CSKillEnemyWithFormerGun, + CSKillTwoWithOneShot, + CSProgressiveGameKills, + CSSelectGameKills, + CSBombGameKills, + CSGunGameKillKnifer, + CSGunGameKnifeSuicide, + CSGunGameKnifeKillKnifer, + CSGunGameSMGKillKnifer, + CSFirstBulletKills, + CSSpawnCamper, + CSBornReady, + + CSKillAchievementEnd, + + CSWeaponAchievementsStart = 4000, + + CSEnemyKillsDeagle, + CSEnemyKillsUSP, + CSEnemyKillsGlock, + CSEnemyKillsP228, + CSEnemyKillsElite, + CSEnemyKillsFiveSeven, + CSEnemyKillsBizon, + CSEnemyKillsTec9, + CSEnemyKillsTaser, + CSEnemyKillsHKP2000, + CSEnemyKillsP250, + CSEnemyKillsAWP, + CSEnemyKillsAK47, + CSEnemyKillsM4A1, + CSEnemyKillsAUG, + CSEnemyKillsSG552, + CSEnemyKillsSG550, + CSEnemyKillsGALIL, + CSEnemyKillsGALILAR, + CSEnemyKillsFAMAS, + CSEnemyKillsScout, + CSEnemyKillsG3SG1, + CSEnemyKillsSCAR17, + CSEnemyKillsSCAR20, + CSEnemyKillsSG556, + CSEnemyKillsSSG08, + CSEnemyKillsP90, + CSEnemyKillsMP5NAVY, + CSEnemyKillsTMP, + CSEnemyKillsMAC10, + CSEnemyKillsUMP45, + CSEnemyKillsMP7, + CSEnemyKillsMP9, + CSEnemyKillsM3, + CSEnemyKillsXM1014, + CSEnemyKillsMag7, + CSEnemyKillsSawedoff, + CSEnemyKillsNova, + CSEnemyKillsM249, + CSEnemyKillsNegev, + CSEnemyKillsKnife, + CSEnemyKillsHEGrenade, + CSEnemyKillsMolotov, + CSMetaPistol, + CSMetaRifle, + CSMetaSMG, + CSMetaShotgun, + CSMetaWeaponMaster, + + CSWeaponAchievementsEnd, + + CSGeneralAchievementsStart = 5000, + + CSWinRoundsLow, + CSWinRoundsMed, + CSWinRoundsHigh, + CSGGWinRoundsLow, + CSGGWinRoundsMed, + CSGGWinRoundsHigh, + CSGGWinRoundsExtreme, + CSGGWinRoundsUltimate, + CSGGRoundsLow, + CSGGRoundsMed, + CSGGRoundsHigh, + CSMoneyEarnedLow, + CSMoneyEarnedMed, + CSMoneyEarnedHigh, + CSGiveDamageLow, + CSGiveDamageMed, + CSGiveDamageHigh, + CSPosthumousGrenadeKill, + CSKillEnemyTeam, + CSLastPlayerAlive, + CSKillEnemyLastBullet, + CSKillingSpreeEnder, + CSDamageNoKill, + CSKillLowDamage, + CSSurviveManyAttacks, + CSLosslessExtermination, + CSFlawlessVictory, + CSDecalSprays, + CSBreakWindows, + CSBreakProps, + CSUnstoppableForce, + CSImmovableObject, + CSHeadshotsInRound, + CSWinPistolRoundsLow, + CSWinPistolRoundsMed, + CSWinPistolRoundsHigh, + CSFastRoundWin, + CSNightvisionDamage, + CSSilentWin, + CSBloodlessVictory, + CSDonateWeapons, + CSWinRoundsWithoutBuying, +#if(ALL_WEARING_SAME_UNIFORM_ACHIEVEMENT) + CSSameUniform, +#endif + CSFriendsSameUniform, + CSCauseFriendlyFireWithFlashbang, + + CSGeneralAchievementsEnd, + + CSWinMapAchievementsStart = 6000, + + CSWinMapCS_ASSAULT, + CSWinMapCS_COMPOUND, + CSWinMapCS_HAVANA, + CSWinMapCS_ITALY, + CSWinMapCS_MILITIA, + CSWinMapCS_OFFICE, + CSWinMapDE_AZTEC, + CSWinMapDE_CBBLE, + CSWinMapDE_CHATEAU, + CSWinMapDE_DUST, + CSWinMapDE_DUST2, + CSWinMapDE_INFERNO, + CSWinMapDE_NUKE, + CSWinMapDE_PIRANESI, + CSWinMapDE_PORT, + CSWinMapDE_PRODIGY, + CSWinMapDE_TIDES, + CSWinMapDE_TRAIN, + + CSWinMatchDE_SHORTTRAIN, + CSWinMatchDE_LAKE, + CSWinMatchDE_SAFEHOUSE, + CSWinMatchDE_SUGARCANE, + CSWinMatchDE_STMARC, + CSWinMatchDE_BANK, + CSWinMatchDE_EMBASSY, + CSWinMatchDE_DEPOT, + CSWinMatchDE_VERTIGO, + CSWinMatchDE_BALKAN, + CSWinMatchAR_MONASTERY, + CSWinMatchAR_SHOOTS, + CSWinMatchAR_BAGGAGE, + CSWinEveryGGMap, + CSPlayEveryGGMap, + CSGunGameProgressiveRampage, + CSGunGameFirstKill, + CSKillEnemyTerrTeamBeforeBombPlant, + CSKillEnemyCTTeamBeforeBombPlant, + CSGunGameConservationist, + CSStillAlive, + CSMedalist, + + CSWinMapAchievementsEnd, + + CSSeason1_Start = 6200, + CSSeason1_Bronze, + CSSeason1_Silver, + CSSeason1_Gold, + CSSeason1_End + +} eCSAchievementType; + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/cs_shareddefs.h b/SpyCustom/sdk/cs_shareddefs.h new file mode 100644 index 0000000..7674dba --- /dev/null +++ b/SpyCustom/sdk/cs_shareddefs.h @@ -0,0 +1,391 @@ +#ifndef CS_SHAREDDEFS_H +#define CS_SHAREDDEFS_H +#ifdef _WIN32 +#pragma once +#endif + +#if !defined (_GAMECONSOLE) && !defined( GC_DLL ) +#endif + +#include "cs_achievementdefs.h" + +#define PANEL_CHOOSE_CLASS "choose_class" + +#define CSTRIKE_VISUALS_DATA_BYTES 96 + +#define MAX_HOSTAGES 12 +#define MAX_HOSTAGE_RESCUES 4 +#define HOSTAGE_RULE_CAN_PICKUP 1 + +#define MAX_MATCH_STATS_ROUNDS 30 +#define MATCH_STATS_TEAM_SWAP_ROUND 15 + +#define IRONSIGHT +#define GRENADE_UNDERHAND_FEATURE_ENABLED +#define GRENADE_DEFAULT_SIZE 2.0 + +#define CS_CONTROLLABLE_BOTS_ENABLED 1 + +#if !defined( CSTRIKE_DEMO_PRESSBUILD ) +#define CSTRIKE_DEMO_PRESSBUILD 0 +#endif + +#if !defined( CSTRIKE_E3_BUILD ) +#define CSTRIKE_E3_BUILD 0 +#endif + +#define CSTRIKE_DEFAULT_AVATAR "avatar_default_64" +#define CSTRIKE_DEFAULT_T_AVATAR "avatar_default-t_64" +#define CSTRIKE_DEFAULT_CT_AVATAR "avatar_default_64" +extern const float CS_PLAYER_SPEED_RUN; +extern const float CS_PLAYER_SPEED_VIP; +extern const float CS_PLAYER_SPEED_SHIELD; +extern const float CS_PLAYER_SPEED_STOPPED; +extern const float CS_PLAYER_SPEED_HAS_HOSTAGE; +extern const float CS_PLAYER_SPEED_OBSERVER; + +extern const float CS_PLAYER_SPEED_DUCK_MODIFIER; +extern const float CS_PLAYER_SPEED_WALK_MODIFIER; +extern const float CS_PLAYER_SPEED_CLIMB_MODIFIER; +extern const float CS_PLAYER_HEAVYARMOR_FLINCH_MODIFIER; + +extern const float CS_PLAYER_DUCK_SPEED_IDEAL; + +#ifdef CSTRIKE15 +#ifdef CLIENT_DLL +#define OLD_CROUCH_PROTOCOL_INDEX 13546 +inline bool IsPreCrouchUpdateDemo(void) { return (engine->IsHLTV() || engine->IsPlayingDemo()) && engine->GetConnectionDataProtocol() <= OLD_CROUCH_PROTOCOL_INDEX; } +#endif +#endif + +template< class T > +class CUtlVectorInitialized : public CUtlVector< T > +{ +public: + CUtlVectorInitialized(T* pMemory, int numElements) : CUtlVector< T >(pMemory, numElements) + { + CUtlVector< T >::SetSize(numElements); + } +}; + +namespace TeamJoinFailedReason +{ + enum Type + { + CHANGED_TOO_OFTEN, + BOTH_TEAMS_FULL, + TERRORISTS_FULL, + CTS_FULL, + CANT_JOIN_SPECTATOR, + HUMANS_CAN_ONLY_JOIN_TS, + HUMANS_CAN_ONLY_JOIN_CTS, + TOO_MANY_TS, + TOO_MANY_CTS, + }; +}; + +#define CS_HOSTAGE_TRANSTIME_PICKUP 0.1 +#define CS_HOSTAGE_TRANSTIME_DROP 0.25 +#define CS_HOSTAGE_TRANSTIME_RESCUE 4.0 + +enum EHostageStates_t +{ + k_EHostageStates_Idle = 0, + k_EHostageStates_BeingUntied, + k_EHostageStates_GettingPickedUp, + k_EHostageStates_BeingCarried, + k_EHostageStates_FollowingPlayer, + k_EHostageStates_GettingDropped, + k_EHostageStates_Rescued, + k_EHostageStates_Dead, +}; + +#define CONSTANT_UNITS_SMOKEGRENADERADIUS 166 +#define CONSTANT_UNITS_GENERICGRENADERADIUS 115 + +const float SmokeGrenadeRadius = CONSTANT_UNITS_SMOKEGRENADERADIUS; +const float FlashbangGrenadeRadius = CONSTANT_UNITS_GENERICGRENADERADIUS; +const float HEGrenadeRadius = CONSTANT_UNITS_GENERICGRENADERADIUS; +const float MolotovGrenadeRadius = CONSTANT_UNITS_GENERICGRENADERADIUS; +const float DecoyGrenadeRadius = CONSTANT_UNITS_GENERICGRENADERADIUS; + + +#define ADDON_FLASHBANG_1 0x0001 +#define ADDON_FLASHBANG_2 0x0002 +#define ADDON_HE_GRENADE 0x0004 +#define ADDON_SMOKE_GRENADE 0x0008 +#define ADDON_C4 0x0010 +#define ADDON_DEFUSEKIT 0x0020 +#define ADDON_PRIMARY 0x0040 +#define ADDON_PISTOL 0x0080 +#define ADDON_PISTOL2 0x0100 +#define ADDON_DECOY 0x0200 +#define ADDON_KNIFE 0x0400 +#define ADDON_MASK 0x0800 +#define ADDON_TAGRENADE 0x1000 +#define NUM_ADDON_BITS 13 + +#define ADDON_CLIENTSIDE_HOLIDAY_HAT ( 0x1 << NUM_ADDON_BITS ) +#define ADDON_CLIENTSIDE_GHOST ( 0x2 << NUM_ADDON_BITS ) +#define ADDON_CLIENTSIDE_ASSASSINATION_TARGET ( 0x4 << NUM_ADDON_BITS ) +#define NUM_CLIENTSIDE_ADDON_BITS 3 + + +#define WEAPON_SLOT_RIFLE 0 +#define WEAPON_SLOT_PISTOL 1 +#define WEAPON_SLOT_KNIFE 2 +#define WEAPON_SLOT_GRENADES 3 +#define WEAPON_SLOT_C4 4 + +#define WEAPON_SLOT_FIRST 0 +#define WEAPON_SLOT_LAST 4 + + +#define TEAM_TERRORIST 2 +#define TEAM_CT 3 +#define TEAM_MAXCOUNT 4 + +#define TEAM_TERRORIST_BASE0 TEAM_TERRORIST - 2 +#define TEAM_CT_BASE0 TEAM_CT - 2 + +#define CS_DEATH_ANIMATION_TIME 0.5 + +#define CS_KILLS_FOR_DOMINATION 4 + +#define CS_DEATH_DOMINATION 0x0001 +#define CS_DEATH_REVENGE 0x0002 + + +#define DMG_HEADSHOT (DMG_LASTGENERICFLAG<<1) + + +struct PlayerViewmodelArmConfig +{ + const char* szPlayerModelSearchSubStr; + const char* szSkintoneIndex; + const char* szAssociatedGloveModel; + const char* szAssociatedSleeveModel; + const char* szAssociatedSleeveModelEconOverride; +}; + +enum CSPlayerState +{ + STATE_ACTIVE = 0, + + STATE_WELCOME, + + STATE_PICKINGTEAM, + STATE_PICKINGCLASS, + + STATE_DEATH_ANIM, + STATE_DEATH_WAIT_FOR_KEY, + STATE_OBSERVER_MODE, + + STATE_GUNGAME_RESPAWN, + STATE_DORMANT, + + NUM_PLAYER_STATES +}; + + +enum e_RoundEndReason +{ + Invalid_Round_End_Reason = -1, + RoundEndReason_StillInProgress = 0, + Target_Bombed = 1, + VIP_Escaped = 2, + VIP_Assassinated = 3, + Terrorists_Escaped = 4, + CTs_PreventEscape = 5, + Escaping_Terrorists_Neutralized = 6, + Bomb_Defused = 7, + CTs_Win = 8, + Terrorists_Win = 9, + Round_Draw = 10, + All_Hostages_Rescued = 11, + Target_Saved = 12, + Hostages_Not_Rescued = 13, + Terrorists_Not_Escaped = 14, + VIP_Not_Escaped = 15, + Game_Commencing = 16, + Terrorists_Surrender = 17, + CTs_Surrender = 18, + Terrorists_Planted = 19, + CTs_ReachedHostage = 20, + RoundEndReason_Count = 21, +}; + +enum GamePhase +{ + GAMEPHASE_WARMUP_ROUND, + GAMEPHASE_PLAYING_STANDARD, + GAMEPHASE_PLAYING_FIRST_HALF, + GAMEPHASE_PLAYING_SECOND_HALF, + GAMEPHASE_HALFTIME, + GAMEPHASE_MATCH_ENDED, + GAMEPHASE_MAX +}; + +enum GrenadeType_t +{ + GRENADE_TYPE_EXPLOSIVE, + GRENADE_TYPE_FLASH, + GRENADE_TYPE_FIRE, + GRENADE_TYPE_DECOY, + GRENADE_TYPE_SMOKE, + GRENADE_TYPE_SENSOR, + + GRENADE_TYPE_TOTAL, +}; + +#define PUSHAWAY_THINK_INTERVAL (1.0f / 20.0f) +#define GLOWUPDATE_DEFAULT_THINK_INTERVAL 0.2f + +#define CS_MAX_PLAYER_MODELS 10 +#define MAX_MODEL_STRING_SIZE 256 + +#define CS_CLASS_NONE 0 + +#define MAX_ENDMATCH_VOTE_PANELS 10 +const PlayerViewmodelArmConfig* GetPlayerViewmodelArmConfigForPlayerModel(const char* szPlayerModel); + +class PlayerModelInfo +{ +public: + PlayerModelInfo(); + +#if !defined( CLIENT_DLL ) + + bool IsTClass(int classID); + bool IsCTClass(int classID); + + int GetFirstTClass(void) const { return 1; } + int GetFirstCTClass(void) const { return m_NumTModels + 1; } + int GetFirstClass(void) const { return GetFirstTClass(); } + + int GetLastTClass(void) const { return m_NumTModels; } + int GetLastCTClass(void) const { return m_NumTModels + m_NumCTModels; } + int GetLastClass(void) const { return GetLastCTClass(); } + + int GetNextClassForTeam(int team); + + const char* GetClassName(int classID); + const char* GetClassModelPath(int classID); + + int GetNumTModels(void) const { return m_NumTModels; } + int GetNumCTModels(void) const { return m_NumCTModels; } + + void InitializeForCurrentMap(void); + +private: + void AddModel(const char* modelName); + void SetTViewModelArms(const char* modelName); + void SetCTViewModelArms(const char* modelName); + +#endif + +public: + static const char* g_customizationModelCT; + static const char* g_customizationModelT; + static const char* g_defaultTModel; + static const char* g_defaultCTModel; + + static PlayerModelInfo* GetPtr(void) { return &s_PlayerModelInfo; } + +private: + static PlayerModelInfo s_PlayerModelInfo; + +#if !defined( CLIENT_DLL ) + char m_ClassModelPaths[CS_MAX_PLAYER_MODELS][MAX_MODEL_STRING_SIZE]; + char m_ClassNames[CS_MAX_PLAYER_MODELS][MAX_MODEL_STRING_SIZE]; + char m_mapName[MAX_MODEL_STRING_SIZE]; + + int m_NumTModels; + int m_NumCTModels; + int m_NumModels; + int m_nNextClassT; + int m_nNextClassCT; +#endif +}; + +enum CSMvpReason_t +{ + CSMVP_UNDEFINED = 0, + CSMVP_ELIMINATION, + CSMVP_BOMBPLANT, + CSMVP_BOMBDEFUSE, + CSMVP_HOSTAGERESCUE, + + CSMVP_GUNGAMEWINNER, +}; + +#define CS_MUZZLEFLASH_NONE -1 +#define CS_MUZZLEFLASH_NORM 0 +#define CS_MUZZLEFLASH_X 1 + +extern const char* pszWinPanelCategoryHeaders[]; + +namespace AcquireResult +{ + enum Type + { + Allowed, + InvalidItem, + AlreadyOwned, + AlreadyPurchased, + ReachedGrenadeTypeLimit, + ReachedGrenadeTotalLimit, + NotAllowedByTeam, + NotAllowedByMap, + NotAllowedByMode, + NotAllowedForPurchase, + NotAllowedByProhibition, + }; +} + +namespace AcquireMethod +{ + enum Type + { + PickUp, + Buy, + }; +} + +namespace QuestProgress +{ + enum Reason + { + QUEST_NONINITIALIZED, + + QUEST_OK, + + QUEST_NOT_ENOUGH_PLAYERS, + + QUEST_WARMUP, + + QUEST_NOT_CONNECTED_TO_STEAM, + + QUEST_NONOFFICIAL_SERVER, + + QUEST_NO_ENTITLEMENT, + + QUEST_NO_QUEST, + + QUEST_PLAYER_IS_BOT, + + QUEST_WRONG_MAP, + QUEST_WRONG_MODE, + + QUEST_NOT_SYNCED_WITH_SERVER, + + QUEST_REASON_MAX, + }; + + const int QuestReasonBits = 4; + COMPILE_TIME_ASSERT(QUEST_REASON_MAX <= (1 << QuestReasonBits)); + + const char* ReasonString(Reason reason); +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/cs_view_scene.h b/SpyCustom/sdk/cs_view_scene.h new file mode 100644 index 0000000..42c6661 --- /dev/null +++ b/SpyCustom/sdk/cs_view_scene.h @@ -0,0 +1,28 @@ +#ifndef CS_VIEW_SCENE_H +#define CS_VIEW_SCENE_H +#ifdef _WIN32 +#pragma once +#endif + +#include "viewrender.h" + +class CCSViewRender : public CViewRender +{ +public: + CCSViewRender(); + + virtual void Init(void); + + virtual void GetScreenFadeDistances(float* min, float* max); + + virtual void Render2DEffectsPreHUD(const CViewSetup& view); + virtual void Render2DEffectsPostHUD(const CViewSetup& view); + virtual void RenderPlayerSprites(void); + + void PerformFlashbangEffect(const CViewSetup& view); + void PerformNightVisionEffect(const CViewSetup& view); + + ITexture* m_pFlashTexture; +}; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/datamap.h b/SpyCustom/sdk/datamap.h new file mode 100644 index 0000000..582b094 --- /dev/null +++ b/SpyCustom/sdk/datamap.h @@ -0,0 +1,397 @@ +#ifndef DATAMAP_H +#define DATAMAP_H +#ifdef _WIN32 +#pragma once +#endif + +#ifndef VECTOR_H +#include "vector.h" +#endif + +#include "utlvector.h" + +#include "memdbgon.h" + +class SINGLE_INHERITANCE CBaseEntity; +struct inputdata_t; + +#define INVALID_TIME (FLT_MAX * -1.0) + +typedef enum _fieldtypes +{ + FIELD_VOID = 0, + FIELD_FLOAT, + FIELD_STRING, + FIELD_VECTOR, + FIELD_QUATERNION, + FIELD_INTEGER, + FIELD_BOOLEAN, + FIELD_SHORT, + FIELD_CHARACTER, + FIELD_COLOR32, + FIELD_EMBEDDED, + FIELD_CUSTOM, + + FIELD_CLASSPTR, + FIELD_EHANDLE, + FIELD_EDICT, + + FIELD_POSITION_VECTOR, + FIELD_TIME, + FIELD_TICK, + FIELD_MODELNAME, + FIELD_SOUNDNAME, + + FIELD_INPUT, + FIELD_FUNCTION, + + FIELD_VMATRIX, + + FIELD_VMATRIX_WORLDSPACE, + FIELD_MATRIX3X4_WORLDSPACE, + + FIELD_INTERVAL, + FIELD_MODELINDEX, + FIELD_MATERIALINDEX, + + FIELD_VECTOR2D, + + FIELD_TYPECOUNT, +} fieldtype_t; + + +template +class CDatamapFieldSizeDeducer +{ +public: + enum + { + SIZE = 0 + }; + + static int FieldSize() + { + return 0; + } +}; + +#define DECLARE_FIELD_SIZE( _fieldType, _fieldSize ) \ + template< > class CDatamapFieldSizeDeducer<_fieldType> { public: enum { SIZE = _fieldSize }; static int FieldSize() { return _fieldSize; } }; +#define FIELD_SIZE( _fieldType ) CDatamapFieldSizeDeducer<_fieldType>::SIZE +#define FIELD_BITS( _fieldType ) (FIELD_SIZE( _fieldType ) * 8) + +DECLARE_FIELD_SIZE(FIELD_FLOAT, sizeof(float)) +DECLARE_FIELD_SIZE(FIELD_STRING, sizeof(int)) +DECLARE_FIELD_SIZE(FIELD_VECTOR, 3 * sizeof(float)) +DECLARE_FIELD_SIZE(FIELD_VECTOR2D, 2 * sizeof(float)) +DECLARE_FIELD_SIZE(FIELD_QUATERNION, 4 * sizeof(float)) +DECLARE_FIELD_SIZE(FIELD_INTEGER, sizeof(int)) +DECLARE_FIELD_SIZE(FIELD_BOOLEAN, sizeof(char)) +DECLARE_FIELD_SIZE(FIELD_SHORT, sizeof(short)) +DECLARE_FIELD_SIZE(FIELD_CHARACTER, sizeof(char)) +DECLARE_FIELD_SIZE(FIELD_COLOR32, sizeof(int)) +DECLARE_FIELD_SIZE(FIELD_CLASSPTR, sizeof(int)) +DECLARE_FIELD_SIZE(FIELD_EHANDLE, sizeof(int)) +DECLARE_FIELD_SIZE(FIELD_EDICT, sizeof(int)) +DECLARE_FIELD_SIZE(FIELD_POSITION_VECTOR, 3 * sizeof(float)) +DECLARE_FIELD_SIZE(FIELD_TIME, sizeof(float)) +DECLARE_FIELD_SIZE(FIELD_TICK, sizeof(int)) +DECLARE_FIELD_SIZE(FIELD_MODELNAME, sizeof(int)) +DECLARE_FIELD_SIZE(FIELD_SOUNDNAME, sizeof(int)) +DECLARE_FIELD_SIZE(FIELD_INPUT, sizeof(int)) +#ifdef POSIX +DECLARE_FIELD_SIZE(FIELD_FUNCTION, sizeof(uint64)) +#else +DECLARE_FIELD_SIZE(FIELD_FUNCTION, sizeof(int*)) +#endif +DECLARE_FIELD_SIZE(FIELD_VMATRIX, 16 * sizeof(float)) +DECLARE_FIELD_SIZE(FIELD_VMATRIX_WORLDSPACE, 16 * sizeof(float)) +DECLARE_FIELD_SIZE(FIELD_MATRIX3X4_WORLDSPACE, 12 * sizeof(float)) +DECLARE_FIELD_SIZE(FIELD_INTERVAL, 2 * sizeof(float)) +DECLARE_FIELD_SIZE(FIELD_MODELINDEX, sizeof(int)) +DECLARE_FIELD_SIZE(FIELD_MATERIALINDEX, sizeof(int)) + + +#define ARRAYSIZE2D(p) (sizeof(p)/sizeof(p[0][0])) +#define SIZE_OF_ARRAY(p) _ARRAYSIZE(p) + +#define _FIELD(name,fieldtype,count,flags,mapname,tolerance) { fieldtype, #name, { offsetof(classNameTypedef, name), 0 }, count, flags, mapname, NULL, NULL, NULL, sizeof( ((classNameTypedef *)0)->name ), NULL, 0, tolerance } +#define DEFINE_FIELD_NULL { FIELD_VOID,0, {0,0},0,0,0,0,0,0} +#define DEFINE_FIELD(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_SAVE, NULL, 0 ) +#define DEFINE_KEYFIELD(name,fieldtype, mapname) _FIELD(name, fieldtype, 1, FTYPEDESC_KEY | FTYPEDESC_SAVE, mapname, 0 ) +#define DEFINE_KEYFIELD_NOT_SAVED(name,fieldtype, mapname)_FIELD(name, fieldtype, 1, FTYPEDESC_KEY, mapname, 0 ) +#define DEFINE_AUTO_ARRAY(name,fieldtype) _FIELD(name, fieldtype, SIZE_OF_ARRAY(((classNameTypedef *)0)->name), FTYPEDESC_SAVE, NULL, 0 ) +#define DEFINE_AUTO_ARRAY_KEYFIELD(name,fieldtype,mapname) _FIELD(name, fieldtype, SIZE_OF_ARRAY(((classNameTypedef *)0)->name), FTYPEDESC_SAVE, mapname, 0 ) +#define DEFINE_ARRAY(name,fieldtype, count) _FIELD(name, fieldtype, count, FTYPEDESC_SAVE, NULL, 0 ) +#define DEFINE_ENTITY_FIELD(name,fieldtype) _FIELD(edict_t, name, fieldtype, 1, FTYPEDESC_KEY | FTYPEDESC_SAVE, #name, 0 ) +#define DEFINE_ENTITY_GLOBAL_FIELD(name,fieldtype) _FIELD(edict_t, name, fieldtype, 1, FTYPEDESC_KEY | FTYPEDESC_SAVE | FTYPEDESC_GLOBAL, #name, 0 ) +#define DEFINE_GLOBAL_FIELD(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_GLOBAL | FTYPEDESC_SAVE, NULL, 0 ) +#define DEFINE_GLOBAL_KEYFIELD(name,fieldtype, mapname) _FIELD(name, fieldtype, 1, FTYPEDESC_GLOBAL | FTYPEDESC_KEY | FTYPEDESC_SAVE, mapname, 0 ) +#define DEFINE_CUSTOM_FIELD(name,datafuncs) { FIELD_CUSTOM, #name, { offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, datafuncs, NULL } +#define DEFINE_CUSTOM_KEYFIELD(name,datafuncs,mapname) { FIELD_CUSTOM, #name, { offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_KEY, mapname, datafuncs, NULL } +#define DEFINE_AUTO_ARRAY2D(name,fieldtype) _FIELD(name, fieldtype, ARRAYSIZE2D(((classNameTypedef *)0)->name), FTYPEDESC_SAVE, NULL, 0 ) +#define DEFINE_BITFIELD(name,fieldtype,bitcount) DEFINE_ARRAY(name,fieldtype,((bitcount+FIELD_BITS(fieldtype)-1)&~(FIELD_BITS(fieldtype)-1)) / FIELD_BITS(fieldtype) ) +#define DEFINE_INDEX(name,fieldtype) _FIELD(name, fieldtype, 1, FTYPEDESC_INDEX, NULL, 0 ) + +#define DEFINE_EMBEDDED( name ) \ + { FIELD_EMBEDDED, #name, { offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, NULL, NULL, &(((classNameTypedef *)0)->name.m_DataMap), sizeof( ((classNameTypedef *)0)->name ), NULL, 0, 0.0f } + +#define DEFINE_EMBEDDED_OVERRIDE( name, overridetype ) \ + { FIELD_EMBEDDED, #name, { offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, NULL, NULL, &((overridetype *)0)->m_DataMap, sizeof( ((classNameTypedef *)0)->name ), NULL, 0, 0.0f } + +#define DEFINE_EMBEDDEDBYREF( name ) \ + { FIELD_EMBEDDED, #name, { offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_PTR, NULL, NULL, NULL, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( *(((classNameTypedef *)0)->name) ), NULL, 0, 0.0f } + +#define DEFINE_EMBEDDED_ARRAY( name, count ) \ + { FIELD_EMBEDDED, #name, { offsetof(classNameTypedef, name), 0 }, count, FTYPEDESC_SAVE, NULL, NULL, NULL, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( ((classNameTypedef *)0)->name[0] ), NULL, 0, 0.0f } + +#define DEFINE_EMBEDDED_AUTO_ARRAY( name ) \ + { FIELD_EMBEDDED, #name, { offsetof(classNameTypedef, name), 0 }, SIZE_OF_ARRAY( ((classNameTypedef *)0)->name ), FTYPEDESC_SAVE, NULL, NULL, NULL, &(((classNameTypedef *)0)->name->m_DataMap), sizeof( ((classNameTypedef *)0)->name[0] ), NULL, 0, 0.0f } + +#ifndef NO_ENTITY_PREDICTION + +#define DEFINE_PRED_TYPEDESCRIPTION( name, fieldtype ) \ + { FIELD_EMBEDDED, #name, { offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE, NULL, NULL, NULL, &fieldtype::m_PredMap } + +#define DEFINE_PRED_TYPEDESCRIPTION_PTR( name, fieldtype ) \ + { FIELD_EMBEDDED, #name, { offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_SAVE | FTYPEDESC_PTR, NULL, NULL, NULL, &fieldtype::m_PredMap } + +#else + +#define DEFINE_PRED_TYPEDESCRIPTION( name, fieldtype ) DEFINE_FIELD_NULL +#define DEFINE_PRED_TYPEDESCRIPTION_PTR( name, fieldtype ) DEFINE_FIELD_NULL + +#endif + +#define DEFINE_PRED_FIELD(name,fieldtype, flags) _FIELD(name, fieldtype, 1, flags, NULL, 0.0f ) +#define DEFINE_PRED_ARRAY(name,fieldtype, count,flags) _FIELD(name, fieldtype, count, flags, NULL, 0.0f ) +#define DEFINE_FIELD_NAME(localname,netname,fieldtype) _FIELD(localname, fieldtype, 1, 0, #netname, 0.0f ) +#define DEFINE_PRED_FIELD_TOL(name,fieldtype, flags,tolerance) _FIELD(name, fieldtype, 1, flags, NULL, tolerance ) +#define DEFINE_PRED_ARRAY_TOL(name,fieldtype, count,flags,tolerance) _FIELD(name, fieldtype, count, flags, NULL, tolerance) +#define DEFINE_FIELD_NAME_TOL(localname,netname,fieldtolerance) _FIELD(localname, fieldtype, 1, 0, #netname, tolerance ) + +#define DEFINE_INPUT( name, fieldtype, inputname ) { fieldtype, #name, { offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_INPUT | FTYPEDESC_SAVE | FTYPEDESC_KEY, inputname, NULL, NULL, NULL, sizeof( ((classNameTypedef *)0)->name ) } +#define DEFINE_INPUTFUNC( fieldtype, inputname, inputfunc ) { fieldtype, #inputfunc, { NULL, NULL }, 1, FTYPEDESC_INPUT, inputname, NULL, static_cast (&classNameTypedef::inputfunc) } + +class ISaveRestoreOps; +extern ISaveRestoreOps* eventFuncs; +#define DEFINE_OUTPUT( name, outputname ) { FIELD_CUSTOM, #name, { offsetof(classNameTypedef, name), 0 }, 1, FTYPEDESC_OUTPUT | FTYPEDESC_SAVE | FTYPEDESC_KEY, outputname, eventFuncs } + +#define DEFINE_FUNCTION_RAW( function, func_type ) { FIELD_VOID, nameHolder.GenerateName(#function), { NULL, NULL }, 1, FTYPEDESC_FUNCTIONTABLE, NULL, NULL, (inputfunc_t)((func_type)(&classNameTypedef::function)) } +#define DEFINE_FUNCTION( function ) DEFINE_FUNCTION_RAW( function, inputfunc_t ) + + +#define FTYPEDESC_GLOBAL 0x0001 +#define FTYPEDESC_SAVE 0x0002 +#define FTYPEDESC_KEY 0x0004 +#define FTYPEDESC_INPUT 0x0008 +#define FTYPEDESC_OUTPUT 0x0010 +#define FTYPEDESC_FUNCTIONTABLE 0x0020 +#define FTYPEDESC_PTR 0x0040 +#define FTYPEDESC_OVERRIDE 0x0080 + +#define FTYPEDESC_INSENDTABLE 0x0100 +#define FTYPEDESC_PRIVATE 0x0200 +#define FTYPEDESC_NOERRORCHECK 0x0400 + +#define FTYPEDESC_MODELINDEX 0x0800 + +#define FTYPEDESC_INDEX 0x1000 + +#define FTYPEDESC_VIEW_OTHER_PLAYER 0x2000 +#define FTYPEDESC_VIEW_OWN_TEAM 0x4000 +#define FTYPEDESC_VIEW_NEVER 0x8000 + +#define TD_MSECTOLERANCE 0.001f + +struct typedescription_t; + + +class ISaveRestoreOps; + +typedef void (CBaseEntity::* inputfunc_t)(inputdata_t& data); + +struct datamap_t; +struct typedescription_t; + +enum +{ + TD_OFFSET_NORMAL = 0, + TD_OFFSET_PACKED = 1, + + TD_OFFSET_COUNT, +}; + +struct typedescription_t +{ + fieldtype_t fieldType; + const char* fieldName; + int fieldOffset[TD_OFFSET_COUNT]; + unsigned short fieldSize; + short flags; + const char* externalName; + ISaveRestoreOps* pSaveRestoreOps; + inputfunc_t inputFunc; + datamap_t* td; + + int fieldSizeInBytes; + + struct typedescription_t* override_field; + + int override_count; + + float fieldTolerance; +}; + + +struct datamap_t +{ + typedescription_t* dataDesc; + int dataNumFields; + char const* dataClassName; + datamap_t* baseMap; + + bool chains_validated; + bool packed_offsets_computed; + int packed_size; + +#if defined( _DEBUG ) + bool bValidityChecked; +#endif +}; + + +#define DECLARE_SIMPLE_DATADESC() \ + static datamap_t m_DataMap; \ + static datamap_t *GetBaseMap(); \ + template friend void DataMapAccess(T *, datamap_t **p); \ + template friend datamap_t *DataMapInit(T *); + +#define DECLARE_DATADESC() \ + DECLARE_SIMPLE_DATADESC() \ + virtual datamap_t *GetDataDescMap( void ); + +#define BEGIN_DATADESC( className ) \ + datamap_t className::m_DataMap = { 0, 0, #className, NULL }; \ + datamap_t *className::GetDataDescMap( void ) { return &m_DataMap; } \ + datamap_t *className::GetBaseMap() { datamap_t *pResult; DataMapAccess((BaseClass *)NULL, &pResult); return pResult; } \ + BEGIN_DATADESC_GUTS( className ) + +#define BEGIN_DATADESC_NO_BASE( className ) \ + datamap_t className::m_DataMap = { 0, 0, #className, NULL }; \ + datamap_t *className::GetDataDescMap( void ) { return &m_DataMap; } \ + datamap_t *className::GetBaseMap() { return NULL; } \ + BEGIN_DATADESC_GUTS( className ) + +#define BEGIN_SIMPLE_DATADESC( className ) \ + datamap_t className::m_DataMap = { 0, 0, #className, NULL }; \ + datamap_t *className::GetBaseMap() { return NULL; } \ + BEGIN_DATADESC_GUTS( className ) + +#define BEGIN_SIMPLE_DATADESC_( className, BaseClass ) \ + datamap_t className::m_DataMap = { 0, 0, #className, NULL }; \ + datamap_t *className::GetBaseMap() { datamap_t *pResult; DataMapAccess((BaseClass *)NULL, &pResult); return pResult; } \ + BEGIN_DATADESC_GUTS( className ) + +#define BEGIN_DATADESC_GUTS( className ) \ + template datamap_t *DataMapInit(T *); \ + template <> datamap_t *DataMapInit( className * ); \ + namespace className##_DataDescInit \ + { \ + datamap_t *g_DataMapHolder = DataMapInit( (className *)NULL ); \ + } \ + \ + template <> datamap_t *DataMapInit( className * ) \ + { \ + typedef className classNameTypedef; \ + static CDatadescGeneratedNameHolder nameHolder(#className); \ + className::m_DataMap.baseMap = className::GetBaseMap(); \ + static typedescription_t dataDesc[] = \ + { \ + { FIELD_VOID,0, {0,0},0,0,0,0,0,0}, + +#define END_DATADESC() \ + }; \ + \ + if ( sizeof( dataDesc ) > sizeof( dataDesc[0] ) ) \ + { \ + classNameTypedef::m_DataMap.dataNumFields = SIZE_OF_ARRAY( dataDesc ) - 1; \ + classNameTypedef::m_DataMap.dataDesc = &dataDesc[1]; \ + } \ + else \ + { \ + classNameTypedef::m_DataMap.dataNumFields = 1; \ + classNameTypedef::m_DataMap.dataDesc = dataDesc; \ + } \ + return &classNameTypedef::m_DataMap; \ + } + +#define IMPLEMENT_NULL_SIMPLE_DATADESC( derivedClass ) \ + BEGIN_SIMPLE_DATADESC( derivedClass ) \ + END_DATADESC() + +#define IMPLEMENT_NULL_SIMPLE_DATADESC_( derivedClass, baseClass ) \ + BEGIN_SIMPLE_DATADESC_( derivedClass, baseClass ) \ + END_DATADESC() + +#define IMPLEMENT_NULL_DATADESC( derivedClass ) \ + BEGIN_DATADESC( derivedClass ) \ + END_DATADESC() + +#define BEGIN_BITFIELD( name ) \ + union \ + { \ + char name; \ + struct \ + { + +#define END_BITFIELD() \ + }; \ + }; + +#define DECLARE_BYTESWAP_DATADESC() DECLARE_SIMPLE_DATADESC() +#define BEGIN_BYTESWAP_DATADESC(name) BEGIN_SIMPLE_DATADESC(name) +#define BEGIN_BYTESWAP_DATADESC_(name,base) BEGIN_SIMPLE_DATADESC_(name,base) +#define END_BYTESWAP_DATADESC() END_DATADESC() + +template +inline void DataMapAccess(T* ignored, datamap_t** p) +{ + *p = &T::m_DataMap; +} + +class CDatadescGeneratedNameHolder +{ +public: + CDatadescGeneratedNameHolder(const char* pszBase) + : m_pszBase(pszBase) + { + m_nLenBase = strlen(m_pszBase); + } + + ~CDatadescGeneratedNameHolder() + { + for (int i = 0; i < m_Names.Count(); i++) + { + delete m_Names[i]; + } + } + + const char* GenerateName(const char* pszIdentifier) + { + char* pBuf = new char[m_nLenBase + strlen(pszIdentifier) + 1]; + strcpy(pBuf, m_pszBase); + strcat(pBuf, pszIdentifier); + m_Names.AddToTail(pBuf); + return pBuf; + } + +private: + const char* m_pszBase; + size_t m_nLenBase; + CUtlVector m_Names; +}; + +#include "memdbgoff.h" + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/dbg.h b/SpyCustom/sdk/dbg.h new file mode 100644 index 0000000..35f2911 --- /dev/null +++ b/SpyCustom/sdk/dbg.h @@ -0,0 +1,700 @@ +#ifndef DBG_H +#define DBG_H + +#if !defined(__SPU__) + + +#ifdef _WIN32 +#pragma once +#endif + +#include "platform.h" +#include "basetypes.h" +#include "dbgflag.h" +#include "logging.h" +#include +#include +#include + +#ifdef TIER0_DLL_EXPORT +#define DBG_INTERFACE DLL_EXPORT +#define DBG_OVERLOAD DLL_GLOBAL_EXPORT +#define DBG_CLASS DLL_CLASS_EXPORT +#else +#define DBG_INTERFACE DLL_IMPORT +#define DBG_OVERLOAD DLL_GLOBAL_IMPORT +#define DBG_CLASS DLL_CLASS_IMPORT +#endif + +class Color; + + +PLATFORM_INTERFACE void _ExitOnFatalAssert(const tchar* pFile, int line); + +#if defined( DBGFLAG_STRINGS_STRIP ) +#define DbgFlagMacro_ExitOnFatalAssert( pFile, line ) _ExitOnFatalAssert( "", 0 ) +#else +#define DbgFlagMacro_ExitOnFatalAssert( pFile, line ) _ExitOnFatalAssert( pFile, line ) +#endif + +PLATFORM_INTERFACE bool ShouldUseNewAssertDialog(); + +PLATFORM_INTERFACE bool SetupWin32ConsoleIO(); + +PLATFORM_INTERFACE bool DoNewAssertDialog(const tchar* pFile, int line, const tchar* pExpression); + +#if defined( DBGFLAG_STRINGS_STRIP ) +#define DbgFlagMacro_DoNewAssertDialog( pFile, line, pExpression ) DoNewAssertDialog( "", 0, "" ) +#else +#define DbgFlagMacro_DoNewAssertDialog( pFile, line, pExpression ) DoNewAssertDialog( pFile, line, pExpression ) +#endif + +PLATFORM_INTERFACE bool AreAllAssertsDisabled(); +PLATFORM_INTERFACE void SetAllAssertsDisabled(bool bAssertsEnabled); + +PLATFORM_INTERFACE bool IsAssertDialogDisabled(); +PLATFORM_INTERFACE void SetAssertDialogDisabled(bool bAssertDialogDisabled); + +typedef void (*AssertFailedNotifyFunc_t)(const char* pchFile, int nLine, const char* pchMessage); +PLATFORM_INTERFACE void SetAssertFailedNotifyFunc(AssertFailedNotifyFunc_t func); +PLATFORM_INTERFACE void CallAssertFailedNotifyFunc(const char* pchFile, int nLine, const char* pchMessage); + +#if defined( LINUX ) +PLATFORM_INTERFACE void SetAssertDialogParent(struct SDL_Window* window); +PLATFORM_INTERFACE struct SDL_Window* GetAssertDialogParent(); +#endif + +#ifdef _PREFAST_ +#define _AssertMsg( _exp, _msg, _executeExp, _bFatal ) do { __analysis_assume( !!(_exp) ); _msg; } while (0) +#define _AssertMsgOnce( _exp, _msg, _bFatal ) do { __analysis_assume( !!(_exp) ); _msg; } while (0) +#define DBGFLAG_ASSERT +#define DBGFLAG_ASSERTFATAL +#define DBGFLAG_ASSERTDEBUG + +#define Q_ASSERT( _exp ) _AssertMsg( _exp, _T("Assertion Failed: ") _T(#_exp), ((void)0), false ) +#else +#define _AssertMsg( _exp, _msg, _executeExp, _bFatal ) \ + do { \ + if (!(_exp)) \ + { \ + LoggingResponse_t ret = Log_Assert( "%s (%d) : %s\n", __TFILE__, __LINE__, static_cast( _msg ) ); \ + CallAssertFailedNotifyFunc( __TFILE__, __LINE__, _msg ); \ + _executeExp; \ + if ( ret == LR_DEBUGGER ) \ + { \ + if ( ShouldUseNewAssertDialog() ) \ + { \ + if ( DbgFlagMacro_DoNewAssertDialog( __TFILE__, __LINE__, _msg ) ) \ + DebuggerBreak(); \ + } \ + if ( _bFatal ) \ + DbgFlagMacro_ExitOnFatalAssert( __TFILE__, __LINE__ ); \ + } \ + } \ + } while (0) + +#define _AssertMsgOnce( _exp, _msg, _bFatal ) \ + do { \ + static bool fAsserted; \ + if (!fAsserted ) \ + { \ + _AssertMsg( _exp, _msg, (fAsserted = true), _bFatal ); \ + } \ + } while (0) +#endif + +#ifdef DBGFLAG_ASSERTFATAL + +#define AssertFatal( _exp ) _AssertMsg( _exp, _T("Assertion Failed: ") _T(#_exp), ((void)0), true ) +#define AssertFatalOnce( _exp ) _AssertMsgOnce( _exp, _T("Assertion Failed: ") _T(#_exp), true ) +#define AssertFatalMsg( _exp, _msg ) _AssertMsg( _exp, _msg, ((void)0), true ) +#define AssertFatalMsgOnce( _exp, _msg ) _AssertMsgOnce( _exp, _msg, true ) +#define AssertFatalFunc( _exp, _f ) _AssertMsg( _exp, _T("Assertion Failed: " _T(#_exp), _f, true ) +#define AssertFatalEquals( _exp, _expectedValue ) AssertFatalMsg2( (_exp) == (_expectedValue), _T("Expected %d but got %d!"), (_expectedValue), (_exp) ) +#define AssertFatalFloatEquals( _exp, _expectedValue, _tol ) AssertFatalMsg2( fabs((_exp) - (_expectedValue)) <= (_tol), _T("Expected %f but got %f!"), (_expectedValue), (_exp) ) +#define VerifyFatal( _exp ) AssertFatal( _exp ) +#define VerifyEqualsFatal( _exp, _expectedValue ) AssertFatalEquals( _exp, _expectedValue ) +#define DbgVerifyFatal( _exp ) AssertFatal( _exp ) + +#define AssertFatalMsg1( _exp, _msg, a1 ) AssertFatalMsg( _exp, (const tchar *)(CDbgFmtMsg( _msg, a1 ))) +#define AssertFatalMsg2( _exp, _msg, a1, a2 ) AssertFatalMsg( _exp, (const tchar *)(CDbgFmtMsg( _msg, a1, a2 ))) +#define AssertFatalMsg3( _exp, _msg, a1, a2, a3 ) AssertFatalMsg( _exp, (const tchar *)(CDbgFmtMsg( _msg, a1, a2, a3 ))) +#define AssertFatalMsg4( _exp, _msg, a1, a2, a3, a4 ) AssertFatalMsg( _exp, (const tchar *)(CDbgFmtMsg( _msg, a1, a2, a3, a4 ))) +#define AssertFatalMsg5( _exp, _msg, a1, a2, a3, a4, a5 ) AssertFatalMsg( _exp, (const tchar *)(CDbgFmtMsg( _msg, a1, a2, a3, a4, a5 ))) +#define AssertFatalMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) AssertFatalMsg( _exp, (const tchar *)(CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6 ))) +#define AssertFatalMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) AssertFatalMsg( _exp, (const tchar *)(CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6 ))) +#define AssertFatalMsg7( _exp, _msg, a1, a2, a3, a4, a5, a6, a7 ) AssertFatalMsg( _exp, (const tchar *)(CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6, a7 ))) +#define AssertFatalMsg8( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) AssertFatalMsg( _exp, (const tchar *)(CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6, a7, a8 ))) +#define AssertFatalMsg9( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) AssertFatalMsg( _exp, (const tchar *)(CDbgFmtMsg( _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ))) + +#else + +#define AssertFatal( _exp ) ((void)0) +#define AssertFatalOnce( _exp ) ((void)0) +#define AssertFatalMsg( _exp, _msg ) ((void)0) +#define AssertFatalMsgOnce( _exp, _msg ) ((void)0) +#define AssertFatalFunc( _exp, _f ) ((void)0) +#define AssertFatalEquals( _exp, _expectedValue ) ((void)0) +#define AssertFatalFloatEquals( _exp, _expectedValue, _tol ) ((void)0) +#define VerifyFatal( _exp ) (_exp) +#define VerifyEqualsFatal( _exp, _expectedValue ) (_exp) +#define DbgVerifyFatal( _exp ) (_exp) + +#define AssertFatalMsg1( _exp, _msg, a1 ) ((void)0) +#define AssertFatalMsg2( _exp, _msg, a1, a2 ) ((void)0) +#define AssertFatalMsg3( _exp, _msg, a1, a2, a3 ) ((void)0) +#define AssertFatalMsg4( _exp, _msg, a1, a2, a3, a4 ) ((void)0) +#define AssertFatalMsg5( _exp, _msg, a1, a2, a3, a4, a5 ) ((void)0) +#define AssertFatalMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0) +#define AssertFatalMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0) +#define AssertFatalMsg7( _exp, _msg, a1, a2, a3, a4, a5, a6, a7 ) ((void)0) +#define AssertFatalMsg8( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) ((void)0) +#define AssertFatalMsg9( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) ((void)0) + +#endif + +#if defined(_CERT) || defined(_RETAIL) +#define AssertAligned(PTR) +#define AssertAlignedWidth(PTR, width) +#define AssertAlignedConsole(PTR) +#else +# if defined( _X360 ) +# define AssertAlignedWidth( PTR, width ) __twnei( intp(PTR) & ( width - 1 ), 0 ) +# define AssertAligned( PTR ) AssertAlignedWidth( PTR, 16 ) +# define AssertAlignedConsole( PTR ) AssertAlignedWidth( PTR, 4 ) +# elif defined( DBGFLAG_ASSERT ) +# define AssertAlignedWidth( adr, width ) Assert( ( ( ( intp ) ( adr ) ) & ( width - 1 ) ) == 0 ) +# define AssertAligned( adr ) AssertAlignedWidth( adr, 16 ) +# define AssertAlignedConsole(adr) +# else +# define AssertAlignedWidth(PTR, width) +# define AssertAligned(PTR) +# define AssertAlignedConsole(PTR) +# endif +#endif + +#ifdef DBGFLAG_ASSERT + +#define Assert( _exp ) _AssertMsg( _exp, _T("Assertion Failed: ") _T(#_exp), ((void)0), false ) +#define AssertMsg_( _exp, _msg ) _AssertMsg( _exp, _msg, ((void)0), false ) +#define AssertOnce( _exp ) _AssertMsgOnce( _exp, _T("Assertion Failed: ") _T(#_exp), false ) +#define AssertMsgOnce( _exp, _msg ) _AssertMsgOnce( _exp, _msg, false ) +#define AssertFunc( _exp, _f ) _AssertMsg( _exp, _T("Assertion Failed: ") _T(#_exp), _f, false ) +#define AssertEquals( _exp, _expectedValue ) AssertMsg2( (_exp) == (_expectedValue), _T("Expected %d but got %d!"), (_expectedValue), (_exp) ) +#define AssertFloatEquals( _exp, _expectedValue, _tol ) AssertMsg2( fabs((_exp) - (_expectedValue)) <= (_tol), _T("Expected %f but got %f!"), (_expectedValue), (_exp) ) +#define Verify( _exp ) ( _exp ) +#define VerifyEquals( _exp, _expectedValue ) AssertEquals( _exp, _expectedValue ) +#ifndef DbgVerify +#define DbgVerify( _exp ) Assert( _exp ) +#endif + +#ifdef _DEBUG +#define DbgAssert( _exp ) Assert( _exp ) +#else +#define DbgAssert( _exp ) ((void)0) +#endif + +#ifdef _DEBUG +#define DbgAssert( _exp ) Assert( _exp ) +#else +#define DbgAssert( _exp ) ((void)0) +#endif + +#define AssertMsg( _exp, _msg ) AssertMsg_( _exp, _T( _msg ) ) +#define AssertMsg1( _exp, _msg, a1 ) AssertMsg_( _exp, (const tchar *)(CDbgFmtMsg( _T( _msg ), a1 )) ) +#define AssertMsg2( _exp, _msg, a1, a2 ) AssertMsg_( _exp, (const tchar *)(CDbgFmtMsg( _T( _msg ), a1, a2 )) ) +#define AssertMsg3( _exp, _msg, a1, a2, a3 ) AssertMsg_( _exp, (const tchar *)(CDbgFmtMsg( _T( _msg ), a1, a2, a3 )) ) +#define AssertMsg4( _exp, _msg, a1, a2, a3, a4 ) AssertMsg_( _exp, (const tchar *)(CDbgFmtMsg( _T( _msg ), a1, a2, a3, a4 )) ) +#define AssertMsg5( _exp, _msg, a1, a2, a3, a4, a5 ) AssertMsg_( _exp, (const tchar *)(CDbgFmtMsg( _T( _msg ), a1, a2, a3, a4, a5 )) ) +#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) AssertMsg_( _exp, (const tchar *)(CDbgFmtMsg( _T( _msg ), a1, a2, a3, a4, a5, a6 )) ) +#define AssertMsg7( _exp, _msg, a1, a2, a3, a4, a5, a6, a7 ) AssertMsg_( _exp, (const tchar *)(CDbgFmtMsg( _T( _msg ), a1, a2, a3, a4, a5, a6, a7 )) ) +#define AssertMsg8( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) AssertMsg_( _exp, (const tchar *)(CDbgFmtMsg( _T( _msg ), a1, a2, a3, a4, a5, a6, a7, a8 )) ) +#define AssertMsg9( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) AssertMsg_( _exp, (const tchar *)(CDbgFmtMsg( _T( _msg ), a1, a2, a3, a4, a5, a6, a7, a8, a9 )) ) + +#else + +#define Assert( _exp ) ((void)0) +#define AssertOnce( _exp ) ((void)0) +#define AssertMsg( _exp, _msg ) ((void)0) +#define AssertMsgOnce( _exp, _msg ) ((void)0) +#define AssertFunc( _exp, _f ) ((void)0) +#define AssertEquals( _exp, _expectedValue ) ((void)0) +#define AssertFloatEquals( _exp, _expectedValue, _tol ) ((void)0) +#define Verify( _exp ) (_exp) +#define VerifyEquals( _exp, _expectedValue ) (_exp) +#ifndef DbgVerify +#define DbgVerify( _exp ) (_exp) +#endif +#define DbgAssert( _exp ) ((void)0) + +#define AssertMsg1( _exp, _msg, a1 ) ((void)0) +#define AssertMsg2( _exp, _msg, a1, a2 ) ((void)0) +#define AssertMsg3( _exp, _msg, a1, a2, a3 ) ((void)0) +#define AssertMsg4( _exp, _msg, a1, a2, a3, a4 ) ((void)0) +#define AssertMsg5( _exp, _msg, a1, a2, a3, a4, a5 ) ((void)0) +#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0) +#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0) +#define AssertMsg7( _exp, _msg, a1, a2, a3, a4, a5, a6, a7 ) ((void)0) +#define AssertMsg8( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) ((void)0) +#define AssertMsg9( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) ((void)0) + +#endif + +#define AssertDbg( X ) DbgAssert( X ) + + +#define AssertAnalyze( _exp ) Assert( _exp ) +#define STRINGIFY_INTERNAL(x) #x +#define STRINGIFY(x) STRINGIFY_INTERNAL(x) + +#define AssertAlways( _exp ) _AssertMsg( _exp, _T("Assertion Failed: ") _T(#_exp), ((void)0), false ) +#define AssertMsgAlways( _exp, _msg ) _AssertMsg( _exp, _msg, ((void)0), false ) + + +#define FILE_LINE_FUNCTION_STRING __FILE__ "(" STRINGIFY(__LINE__) "):" __FUNCTION__ ":" +#define FILE_LINE_STRING __FILE__ "(" STRINGIFY(__LINE__) "):" +#define FUNCTION_LINE_STRING __FUNCTION__ "(" STRINGIFY(__LINE__) "): " + + +#define MESSAGE(msg) message(__FILE__ "(" FUNCTION_LINE_TOSTRING(__LINE__) "): " msg) + +PLATFORM_INTERFACE LoggingChannelID_t LOG_GENERAL; + +DECLARE_LOGGING_CHANNEL(LOG_ASSERT); +DECLARE_LOGGING_CHANNEL(LOG_CONSOLE); +DECLARE_LOGGING_CHANNEL(LOG_DEVELOPER); +DECLARE_LOGGING_CHANNEL(LOG_DEVELOPER_CONSOLE); +DECLARE_LOGGING_CHANNEL(LOG_DEVELOPER_VERBOSE); + +PLATFORM_INTERFACE void Error(PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(1, 2); +PLATFORM_INTERFACE void Error_SpewCallStack(int iMaxCallStackLength, PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(2, 3); +#define Plat_FatalError( ... ) do { Log_Error( LOG_GENERAL, ##__VA_ARGS__ ); Plat_ExitProcess( EXIT_FAILURE ); } while( 0 ) + +#if defined( DBGFLAG_STRINGS_STRIP ) + +#define Msg( ... ) ((void)0) +#define Warning( ... ) ((void)0) +#define Warning_SpewCallStack( ... ) ((void)0) +#define DevMsg( ... ) ((void)0) +#define DevWarning( ... ) ((void)0) +#define ConColorMsg( ... ) ((void)0) +#define ConMsg( ... ) ((void)0) +#define ConDMsg( ... ) ((void)0) +#define COM_TimestampedLog( ... ) ((void)0) + +#else + +PLATFORM_INTERFACE void Msg(PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(1, 2); +PLATFORM_INTERFACE void Warning(PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(1, 2); +PLATFORM_INTERFACE void Warning_SpewCallStack(int iMaxCallStackLength, PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(2, 3); + +#ifdef _PS3 + +PLATFORM_OVERLOAD void DevMsg(int level, PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(2, 3); +PLATFORM_OVERLOAD void DevWarning(int level, PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(2, 3); + +PLATFORM_INTERFACE void DevMsg(PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(1, 2); +PLATFORM_INTERFACE void DevWarning(PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(1, 2); + +PLATFORM_INTERFACE void ConColorMsg(const Color& clr, PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(2, 3); +PLATFORM_INTERFACE void ConMsg(PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(1, 2); + +#else + +PLATFORM_INTERFACE void DevMsg(int level, PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(2, 3); +PLATFORM_INTERFACE void DevWarning(int level, PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(2, 3); + +PLATFORM_OVERLOAD void DevMsg(PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(1, 2); +PLATFORM_OVERLOAD void DevWarning(PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(1, 2); + +PLATFORM_OVERLOAD void ConColorMsg(const Color& clr, PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(2, 3); +PLATFORM_OVERLOAD void ConMsg(PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(1, 2); + +#endif + +PLATFORM_INTERFACE void ConDMsg(PRINTF_FORMAT_STRING const tchar* pMsg, ...) FMTFUNCTION(1, 2); + +PLATFORM_INTERFACE void COM_TimestampedLog(PRINTF_FORMAT_STRING char const* fmt, ...) FMTFUNCTION(1, 2); + +#endif + +#define ErrorIfNot( condition, msg ) \ + if ( (condition) ) \ + ; \ + else \ + { \ + Error msg; \ + } + +#ifdef _DEBUG +#define DebugMsg(...) DevMsg(__VA_ARGS__) +#else +#define DebugMsg(...) +#endif + +PLATFORM_INTERFACE void _Warning_AlwaysSpewCallStack_Enable(bool bEnable); +PLATFORM_INTERFACE void _Warning_AlwaysSpewCallStack_Length(int iMaxCallStackLength); + +PLATFORM_INTERFACE void _Error_AlwaysSpewCallStack_Enable(bool bEnable); +PLATFORM_INTERFACE void _Error_AlwaysSpewCallStack_Length(int iMaxCallStackLength); + + +#ifdef _DEBUG + +#define DBG_CODE( _code ) if (0) ; else { _code } +#define DBG_CODE_NOSCOPE( _code ) _code +#define DBG_DCODE( _g, _l, _code ) if (IsSpewActive( _g, _l )) { _code } else {} +#define DBG_BREAK() DebuggerBreak() + +#else + +#define DBG_CODE( _code ) ((void)0) +#define DBG_CODE_NOSCOPE( _code ) +#define DBG_DCODE( _g, _l, _code ) ((void)0) +#define DBG_BREAK() ((void)0) + +#endif + + +#ifdef _DEBUG +template +inline DEST_POINTER_TYPE assert_cast(SOURCE_POINTER_TYPE* pSource) +{ + Assert(static_cast(pSource) == dynamic_cast(pSource)); + return static_cast(pSource); +} +#else +#define assert_cast static_cast +#endif + +PLATFORM_INTERFACE void _AssertValidReadPtr(void* ptr, int count = 1); +PLATFORM_INTERFACE void _AssertValidWritePtr(void* ptr, int count = 1); +PLATFORM_INTERFACE void _AssertValidReadWritePtr(void* ptr, int count = 1); +PLATFORM_INTERFACE void _AssertValidStringPtr(const tchar* ptr, int maxchar); + +#ifdef DBGFLAG_ASSERT +inline void AssertValidStringPtr(const tchar* ptr, int maxchar = 0xFFFFFF) { _AssertValidStringPtr(ptr, maxchar); } +template inline void AssertValidReadPtr(T* ptr, int count = 1) { _AssertValidReadPtr((void*)ptr, count); } +template inline void AssertValidWritePtr(T* ptr, int count = 1) { _AssertValidWritePtr((void*)ptr, count); } +template inline void AssertValidReadWritePtr(T* ptr, int count = 1) { _AssertValidReadWritePtr((void*)ptr, count); } +#define AssertValidThis() AssertValidReadWritePtr(this,sizeof(*this)) + +#else + +inline void AssertValidStringPtr(const tchar* ptr, int maxchar = 0xFFFFFF) { } +template inline void AssertValidReadPtr(T* ptr, int count = 1) { } +template inline void AssertValidWritePtr(T* ptr, int count = 1) { } +template inline void AssertValidReadWritePtr(T* ptr, int count = 1) { } +#define AssertValidThis() +#endif + +#ifdef _DEBUG +class CReentryGuard +{ +public: + CReentryGuard(int* pSemaphore) + : m_pSemaphore(pSemaphore) + { + ++(*m_pSemaphore); + } + + ~CReentryGuard() + { + --(*m_pSemaphore); + } + +private: + int* m_pSemaphore; +}; + +#define ASSERT_NO_REENTRY() \ + static int fSemaphore##__LINE__; \ + Assert( !fSemaphore##__LINE__ ); \ + CReentryGuard ReentryGuard##__LINE__( &fSemaphore##__LINE__ ) +#else +#define ASSERT_NO_REENTRY() +#endif + +#ifdef POSIX +#define Tier0Internal_sntprintf snprintf +#define Tier0Internal_vsntprintf vsnprintf +#define Tier0Internal_vsnprintf vsnprintf +#else +#define Tier0Internal_sntprintf _sntprintf +#define Tier0Internal_vsntprintf _vsntprintf +#define Tier0Internal_vsnprintf _vsnprintf +#endif + +#include "valve_off.h" +class CDbgFmtMsg +{ +public: + CDbgFmtMsg(PRINTF_FORMAT_STRING const tchar* pszFormat, ...) + { + va_list arg_ptr; + + va_start(arg_ptr, pszFormat); + Tier0Internal_vsntprintf(m_szBuf, sizeof(m_szBuf) - 1, pszFormat, arg_ptr); + va_end(arg_ptr); + + m_szBuf[sizeof(m_szBuf) - 1] = 0; + } + + operator const tchar* () const + { + return m_szBuf; + } + +private: + tchar m_szBuf[256]; +}; +#include "valve_on.h" + +#if defined( _WIN32 ) && !defined( _X360 ) + +#ifdef _DEBUG +#pragma comment(compiler) +#endif + +#endif + +#ifdef _DEBUG + +template< class Type > +class CDataWatcher +{ +public: + const Type& operator=(const Type& val) + { + return Set(val); + } + + const Type& operator=(const CDataWatcher& val) + { + return Set(val.m_Value); + } + + const Type& Set(const Type& val) + { + m_Value = val; + return m_Value; + } + + Type& GetForModify() + { + return m_Value; + } + + const Type& operator+=(const Type& val) + { + return Set(m_Value + val); + } + + const Type& operator-=(const Type& val) + { + return Set(m_Value - val); + } + + const Type& operator/=(const Type& val) + { + return Set(m_Value / val); + } + + const Type& operator*=(const Type& val) + { + return Set(m_Value * val); + } + + const Type& operator^=(const Type& val) + { + return Set(m_Value ^ val); + } + + const Type& operator|=(const Type& val) + { + return Set(m_Value | val); + } + + const Type& operator++() + { + return (*this += 1); + } + + Type operator--() + { + return (*this -= 1); + } + + Type operator++(int) + { + Type val = m_Value; + (*this += 1); + return val; + } + + Type operator--(int) + { + Type val = m_Value; + (*this -= 1); + return val; + } + + template< class C > + const Type& operator&=(C val) + { + return Set(m_Value & val); + } + + operator const Type& () const + { + return m_Value; + } + + const Type& Get() const + { + return m_Value; + } + + const Type* operator->() const + { + return &m_Value; + } + + Type m_Value; + +}; + +#else + +template< class Type > +class CDataWatcher +{ +private: + CDataWatcher(); +}; + +#endif + +#ifdef IS_WINDOWS_PC + +typedef void* HardwareBreakpointHandle_t; + +enum EHardwareBreakpointType +{ + BREAKPOINT_EXECUTE = 0, + BREAKPOINT_WRITE, + BREAKPOINT_READWRITE, +}; + +enum EHardwareBreakpointSize +{ + BREAKPOINT_SIZE_1 = 1, + BREAKPOINT_SIZE_2 = 2, + BREAKPOINT_SIZE_4 = 4, + BREAKPOINT_SIZE_8 = 8, +}; + +PLATFORM_INTERFACE HardwareBreakpointHandle_t SetHardwareBreakpoint(EHardwareBreakpointType eType, EHardwareBreakpointSize eSize, const void* pvLocation); +PLATFORM_INTERFACE bool ClearHardwareBreakpoint(HardwareBreakpointHandle_t handle); + +class CHardwareBreakPointScopeGuard +{ +public: + CHardwareBreakPointScopeGuard(const void* pvLocation, size_t nLocationSize, EHardwareBreakpointType eType = BREAKPOINT_WRITE) + { + EHardwareBreakpointSize eSize = BREAKPOINT_SIZE_4; + switch (nLocationSize) + { + case 1: + eSize = BREAKPOINT_SIZE_1; + break; + case 2: + eSize = BREAKPOINT_SIZE_2; + break; + case 4: + eSize = BREAKPOINT_SIZE_4; + break; + case 8: + eSize = BREAKPOINT_SIZE_8; + break; + default: + Warning(_T("SetHardwareBreakpoint can only work with 1, 2, 4 or 8 byte data fields.")); + break; + } + + m_hBreakPoint = SetHardwareBreakpoint(eType, eSize, pvLocation); + m_bActive = m_hBreakPoint != (HardwareBreakpointHandle_t)0; + } + + ~CHardwareBreakPointScopeGuard() + { + Release(); + } + + void Release() + { + if (!m_bActive) + return; + ClearHardwareBreakpoint(m_hBreakPoint); + } + +private: + bool m_bActive; + HardwareBreakpointHandle_t m_hBreakPoint; +}; + +#endif + +#else + +#define Assert( _exp ) ((void)0) +#define AssertOnce( _exp ) ((void)0) +#define AssertMsg( _exp, _msg ) ((void)0) +#define AssertMsgOnce( _exp, _msg ) ((void)0) +#define AssertFunc( _exp, _f ) ((void)0) +#define AssertEquals( _exp, _expectedValue ) ((void)0) +#define AssertFloatEquals( _exp, _expectedValue, _tol ) ((void)0) +#define Verify( _exp ) (_exp) +#define VerifyEquals( _exp, _expectedValue ) (_exp) + +#define AssertMsg1( _exp, _msg, a1 ) ((void)0) +#define AssertMsg2( _exp, _msg, a1, a2 ) ((void)0) +#define AssertMsg3( _exp, _msg, a1, a2, a3 ) ((void)0) +#define AssertMsg4( _exp, _msg, a1, a2, a3, a4 ) ((void)0) +#define AssertMsg5( _exp, _msg, a1, a2, a3, a4, a5 ) ((void)0) +#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0) +#define AssertMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0) +#define AssertMsg7( _exp, _msg, a1, a2, a3, a4, a5, a6, a7 ) ((void)0) +#define AssertMsg8( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) ((void)0) +#define AssertMsg9( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) ((void)0) + +#define COMPILE_TIME_ASSERT( pred ) +#define ASSERT_INVARIANT( pred ) + +#define AssertFatal( _exp ) ((void)0) +#define AssertFatalOnce( _exp ) ((void)0) +#define AssertFatalMsg( _exp, _msg ) ((void)0) +#define AssertFatalMsgOnce( _exp, _msg ) ((void)0) +#define AssertFatalFunc( _exp, _f ) ((void)0) +#define AssertFatalEquals( _exp, _expectedValue ) ((void)0) +#define AssertFatalFloatEquals( _exp, _expectedValue, _tol ) ((void)0) +#define VerifyFatal( _exp ) (_exp) +#define VerifyEqualsFatal( _exp, _expectedValue ) (_exp) + +#define AssertFatalMsg1( _exp, _msg, a1 ) ((void)0) +#define AssertFatalMsg2( _exp, _msg, a1, a2 ) ((void)0) +#define AssertFatalMsg3( _exp, _msg, a1, a2, a3 ) ((void)0) +#define AssertFatalMsg4( _exp, _msg, a1, a2, a3, a4 ) ((void)0) +#define AssertFatalMsg5( _exp, _msg, a1, a2, a3, a4, a5 ) ((void)0) +#define AssertFatalMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0) +#define AssertFatalMsg6( _exp, _msg, a1, a2, a3, a4, a5, a6 ) ((void)0) +#define AssertFatalMsg7( _exp, _msg, a1, a2, a3, a4, a5, a6, a7 ) ((void)0) +#define AssertFatalMsg8( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8 ) ((void)0) +#define AssertFatalMsg9( _exp, _msg, a1, a2, a3, a4, a5, a6, a7, a8, a9 ) ((void)0) + +#define AssertAligned(PTR) + +#endif + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/dbgflag.h b/SpyCustom/sdk/dbgflag.h new file mode 100644 index 0000000..97df078 --- /dev/null +++ b/SpyCustom/sdk/dbgflag.h @@ -0,0 +1,44 @@ +#ifndef DBGFLAG_H +#define DBGFLAG_H +#ifdef _WIN32 +#pragma once +#endif + + +#undef DBGFLAG_MEMORY +#undef DBGFLAG_MEMORY_NEWDEL +#undef DBGFLAG_VALIDATE +#undef DBGFLAG_ASSERT +#undef DBGFLAG_ASSERTFATAL +#undef DBGFLAG_ASSERTDLG +#undef DBGFLAG_STRINGS + +#if defined( _DEBUG ) && !defined( PS3MEMOVERRIDEWRAP ) + +#define DBGFLAG_MEMORY +#ifdef _SERVER +#define DBGFLAG_MEMORY_NEWDEL +#endif +#ifdef STEAM +#define DBGFLAG_VALIDATE +#endif +#define DBGFLAG_ASSERT +#define DBGFLAG_ASSERTFATAL +#define DBGFLAG_ASSERTDLG +#define DBGFLAG_STRINGS + + +#else +#ifdef STEAM +#define DBGFLAG_ASSERT +#endif +#define DBGFLAG_ASSERTFATAL +#define DBGFLAG_ASSERTDLG + +#endif + +#if defined( _CERT ) +#define DBGFLAG_STRINGS_STRIP +#endif + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/deformations.h b/SpyCustom/sdk/deformations.h new file mode 100644 index 0000000..65598e8 --- /dev/null +++ b/SpyCustom/sdk/deformations.h @@ -0,0 +1,48 @@ +#ifndef DEFORMATIONS_H +#define DEFORMATIONS_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "platform.h" + +enum DeformationType_t +{ + DEFORMATION_CLAMP_TO_BOX_IN_WORLDSPACE = 1, +}; + + +struct DeformationBase_t +{ + DeformationType_t m_eType; +}; + + +struct BoxDeformation_t : DeformationBase_t +{ + Vector m_SourceMins; + float m_flPad0; + Vector m_SourceMaxes; + float m_flPad1; + + Vector m_ClampMins; + float m_flPad2; + Vector m_ClampMaxes; + float m_flPad3; + + FORCEINLINE BoxDeformation_t(void) + { + m_eType = DEFORMATION_CLAMP_TO_BOX_IN_WORLDSPACE; + m_SourceMins.Init(0, 0, 0); + m_SourceMaxes.Init(-1, -1, -1); + + m_ClampMins.Init(-FLT_MAX, -FLT_MAX, -FLT_MAX); + m_ClampMaxes.Init(FLT_MAX, FLT_MAX, FLT_MAX); + } + +}; + + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/dlight.h b/SpyCustom/sdk/dlight.h new file mode 100644 index 0000000..6f9127e --- /dev/null +++ b/SpyCustom/sdk/dlight.h @@ -0,0 +1,51 @@ +#if !defined ( DLIGHTH ) +#define DLIGHTH +#ifdef _WIN32 +#pragma once +#endif + +#include "vector.h" + +enum +{ + DLIGHT_NO_WORLD_ILLUMINATION = 0x1, + DLIGHT_NO_MODEL_ILLUMINATION = 0x2, + + DLIGHT_ADD_DISPLACEMENT_ALPHA = 0x4, + DLIGHT_SUBTRACT_DISPLACEMENT_ALPHA = 0x8, + DLIGHT_DISPLACEMENT_MASK = (DLIGHT_ADD_DISPLACEMENT_ALPHA | DLIGHT_SUBTRACT_DISPLACEMENT_ALPHA), +}; + +struct dlight_t +{ + int flags; + Vector origin; + float radius; + ColorRGBExp32 color; + float die; + float decay; + float minlight; + int key; + int style; + + Vector m_Direction; + float m_InnerAngle; + float m_OuterAngle; + + float GetRadius() const + { + return radius; + } + + float GetRadiusSquared() const + { + return radius * radius; + } + + float IsRadiusGreaterThanZero() const + { + return radius > 0.0f; + } +}; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/dmattributetypes.h b/SpyCustom/sdk/dmattributetypes.h new file mode 100644 index 0000000..fb89808 --- /dev/null +++ b/SpyCustom/sdk/dmattributetypes.h @@ -0,0 +1,329 @@ +#ifndef DMATTRIBUTETYPES_H +#define DMATTRIBUTETYPES_H +#ifdef _WIN32 +#pragma once +#endif + +#include "utlvector.h" +#include "utlstring.h" +#include "uniqueid.h" +#include "color.h" +#include "vector2d.h" +#include "vector.h" +#include "vector4d.h" +#include "vmatrix.h" +#include "dmelementhandle.h" +#include "utlsymbollarge.h" +#include "timeutils.h" + + +typedef UniqueId_t DmObjectId_t; + + +struct DmUnknownAttribute_t +{ + bool operator==(const DmUnknownAttribute_t& src) const { return true; } +}; + + +struct DmElementAttribute_t +{ + DmElementAttribute_t() : m_ElementType(UTL_INVAL_SYMBOL_LARGE) {} + + operator DmElementHandle_t& () { return m_Handle; } + operator const DmElementHandle_t& () const { return m_Handle; } + + DmElementHandle_t m_Handle; + CUtlSymbolLarge m_ElementType; +}; + +struct DmElementArray_t : public CUtlVector< DmElementHandle_t > +{ + DmElementArray_t() : m_ElementType(UTL_INVAL_SYMBOL_LARGE) {} + + CUtlSymbolLarge m_ElementType; +}; + + +enum DmAttributeType_t +{ + AT_UNKNOWN = 0, + + AT_FIRST_VALUE_TYPE, + + AT_ELEMENT = AT_FIRST_VALUE_TYPE, + AT_INT, + AT_FLOAT, + AT_BOOL, + AT_STRING, + AT_VOID, + AT_TIME, + AT_COLOR, + AT_VECTOR2, + AT_VECTOR3, + AT_VECTOR4, + AT_QANGLE, + AT_QUATERNION, + AT_VMATRIX, + + AT_FIRST_ARRAY_TYPE, + + AT_ELEMENT_ARRAY = AT_FIRST_ARRAY_TYPE, + AT_INT_ARRAY, + AT_FLOAT_ARRAY, + AT_BOOL_ARRAY, + AT_STRING_ARRAY, + AT_VOID_ARRAY, + AT_TIME_ARRAY, + AT_COLOR_ARRAY, + AT_VECTOR2_ARRAY, + AT_VECTOR3_ARRAY, + AT_VECTOR4_ARRAY, + AT_QANGLE_ARRAY, + AT_QUATERNION_ARRAY, + AT_VMATRIX_ARRAY, + AT_TYPE_COUNT, + + AT_TYPE_INVALID, +}; + +const char* GetTypeString(DmAttributeType_t type); + +inline bool IsValueType(DmAttributeType_t type) +{ + return type >= AT_FIRST_VALUE_TYPE && type < AT_FIRST_ARRAY_TYPE; +} + +inline bool IsArrayType(DmAttributeType_t type) +{ + return type >= AT_FIRST_ARRAY_TYPE && type < AT_TYPE_COUNT; +} + +inline bool IsTopological(DmAttributeType_t type) +{ + return type == AT_ELEMENT || type == AT_ELEMENT_ARRAY; +} + +inline DmAttributeType_t ValueTypeToArrayType(DmAttributeType_t type) +{ + Assert(IsValueType(type)); + return (DmAttributeType_t)((type - AT_FIRST_VALUE_TYPE) + AT_FIRST_ARRAY_TYPE); +} + +inline DmAttributeType_t ArrayTypeToValueType(DmAttributeType_t type) +{ + Assert(IsArrayType(type)); + return (DmAttributeType_t)((type - AT_FIRST_ARRAY_TYPE) + AT_FIRST_VALUE_TYPE); +} + +inline int NumComponents(DmAttributeType_t type) +{ + switch (type) + { + case AT_BOOL: + case AT_INT: + case AT_FLOAT: + case AT_TIME: + return 1; + + case AT_VECTOR2: + return 2; + + case AT_VECTOR3: + case AT_QANGLE: + return 3; + + case AT_COLOR: + case AT_VECTOR4: + case AT_QUATERNION: + return 4; + + case AT_VMATRIX: + return 16; + + case AT_ELEMENT: + case AT_STRING: + case AT_VOID: + default: + return 0; + } +} + +template< typename T > +inline float GetComponent(const T& value, int i) +{ + Assert(0); + return 0.0f; +} + +template <> inline float GetComponent(const bool& value, int i) +{ + Assert(i == 0); + return value ? 1.0f : 0.0f; +} + +template <> inline float GetComponent(const int& value, int i) +{ + Assert(i == 0); + return float(value); +} + +template <> inline float GetComponent(const float& value, int i) +{ + Assert(i == 0); + return value; +} + +template <> inline float GetComponent(const DmeTime_t& value, int i) +{ + Assert(i == 0); + return value.GetSeconds(); +} + +template <> inline float GetComponent(const Vector2D& value, int i) +{ + return value[i]; +} + +template <> inline float GetComponent(const Vector& value, int i) +{ + return value[i]; +} + +template <> inline float GetComponent(const QAngle& value, int i) +{ + return value[i]; +} + +template <> inline float GetComponent(const Color& value, int i) +{ + return value[i]; +} + +template <> inline float GetComponent(const Vector4D& value, int i) +{ + return value[i]; +} + +template <> inline float GetComponent(const Quaternion& value, int i) +{ + return value[i]; +} + +template <> inline float GetComponent(const VMatrix& value, int i) +{ + return value.Base()[i]; +} + + +template +class CDmAttributeInfo +{ +private: + enum { ATTRIBUTE_TYPE = AT_TYPE_INVALID }; + + typedef T StorageType_t; + friend class CDmxAttribute; + + static DmAttributeType_t AttributeType() + { + return AT_TYPE_INVALID; + } + + static const char* AttributeTypeName() + { + return "invalid"; + } + + static void SetDefaultValue(T& value) + { + Assert(0); + } +}; + + +template <> +class CDmAttributeInfo< DmUnknownAttribute_t > +{ +public: + enum { ATTRIBUTE_TYPE = AT_UNKNOWN }; + + typedef DmUnknownAttribute_t StorageType_t; + + static DmAttributeType_t AttributeType() + { + return AT_UNKNOWN; + } + + static const char* AttributeTypeName() + { + return "unknown"; + } + + static void SetDefaultValue(DmUnknownAttribute_t& value) + { + Assert(0); + } +}; + + +#define DECLARE_ATTRIBUTE_TYPE_INTERNAL( _className, _storageType, _attributeType, _attributeName, _defaultSetStatement ) \ + template< > class CDmAttributeInfo< _className > \ + { \ + public: \ + enum { ATTRIBUTE_TYPE = _attributeType }; \ + typedef _storageType StorageType_t; \ + static DmAttributeType_t AttributeType() { return _attributeType; } \ + static const char *AttributeTypeName() { return _attributeName; } \ + static void SetDefaultValue( _className& value ) { _defaultSetStatement } \ + }; \ + +#define DECLARE_ATTRIBUTE_ARRAY_TYPE_INTERNAL( _className, _storageType, _attributeType, _attributeName ) \ + template< > class CDmAttributeInfo< CUtlVector<_className> > \ + { \ + public: \ + enum { ATTRIBUTE_TYPE = _attributeType }; \ + typedef _storageType StorageType_t; \ + static DmAttributeType_t AttributeType() { return _attributeType; } \ + static const char *AttributeTypeName() { return _attributeName; } \ + static void SetDefaultValue( CUtlVector< _className >& value ) { value.RemoveAll(); } \ + }; \ + +#define DECLARE_ATTRIBUTE_TYPE( _className, _attributeType, _attributeName, _defaultSetStatement ) \ + DECLARE_ATTRIBUTE_TYPE_INTERNAL( _className, _className, _attributeType, _attributeName, _defaultSetStatement ) + +#define DECLARE_ATTRIBUTE_ARRAY_TYPE( _className, _attributeType, _attributeName )\ + DECLARE_ATTRIBUTE_ARRAY_TYPE_INTERNAL( _className, CUtlVector< _className >, _attributeType, _attributeName ) + +DECLARE_ATTRIBUTE_TYPE(int, AT_INT, "int", value = 0; ) +DECLARE_ATTRIBUTE_TYPE(float, AT_FLOAT, "float", value = 0.0f; ) +DECLARE_ATTRIBUTE_TYPE(bool, AT_BOOL, "bool", value = false; ) +DECLARE_ATTRIBUTE_TYPE(Color, AT_COLOR, "color", value.SetColor(0, 0, 0, 255); ) +DECLARE_ATTRIBUTE_TYPE(Vector2D, AT_VECTOR2, "vector2", value.Init(0.0f, 0.0f); ) +DECLARE_ATTRIBUTE_TYPE(Vector, AT_VECTOR3, "vector3", value.Init(0.0f, 0.0f, 0.0f); ) +DECLARE_ATTRIBUTE_TYPE(Vector4D, AT_VECTOR4, "vector4", value.Init(0.0f, 0.0f, 0.0f, 0.0f); ) +DECLARE_ATTRIBUTE_TYPE(QAngle, AT_QANGLE, "qangle", value.Init(0.0f, 0.0f, 0.0f); ) +DECLARE_ATTRIBUTE_TYPE(Quaternion, AT_QUATERNION, "quaternion", value.Init(0.0f, 0.0f, 0.0f, 1.0f); ) +DECLARE_ATTRIBUTE_TYPE(VMatrix, AT_VMATRIX, "matrix", MatrixSetIdentity(value); ) +DECLARE_ATTRIBUTE_TYPE(CUtlSymbolLarge, AT_STRING, "string", value = UTL_INVAL_SYMBOL_LARGE; ) +DECLARE_ATTRIBUTE_TYPE(CUtlBinaryBlock, AT_VOID, "binary", value.Set(NULL, 0); ) +DECLARE_ATTRIBUTE_TYPE(DmeTime_t, AT_TIME, "time", value.SetTenthsOfMS(0); ) +DECLARE_ATTRIBUTE_TYPE_INTERNAL(DmElementHandle_t, DmElementAttribute_t, AT_ELEMENT, "element", value = DMELEMENT_HANDLE_INVALID; ) + +DECLARE_ATTRIBUTE_ARRAY_TYPE(int, AT_INT_ARRAY, "int_array") +DECLARE_ATTRIBUTE_ARRAY_TYPE(float, AT_FLOAT_ARRAY, "float_array") +DECLARE_ATTRIBUTE_ARRAY_TYPE(bool, AT_BOOL_ARRAY, "bool_array") +DECLARE_ATTRIBUTE_ARRAY_TYPE(Color, AT_COLOR_ARRAY, "color_array") +DECLARE_ATTRIBUTE_ARRAY_TYPE(Vector2D, AT_VECTOR2_ARRAY, "vector2_array") +DECLARE_ATTRIBUTE_ARRAY_TYPE(Vector, AT_VECTOR3_ARRAY, "vector3_array") +DECLARE_ATTRIBUTE_ARRAY_TYPE(Vector4D, AT_VECTOR4_ARRAY, "vector4_array") +DECLARE_ATTRIBUTE_ARRAY_TYPE(QAngle, AT_QANGLE_ARRAY, "qangle_array") +DECLARE_ATTRIBUTE_ARRAY_TYPE(Quaternion, AT_QUATERNION_ARRAY, "quaternion_array") +DECLARE_ATTRIBUTE_ARRAY_TYPE(VMatrix, AT_VMATRIX_ARRAY, "matrix_array") +DECLARE_ATTRIBUTE_ARRAY_TYPE(CUtlSymbolLarge, AT_STRING_ARRAY, "string_array") +DECLARE_ATTRIBUTE_ARRAY_TYPE(CUtlBinaryBlock, AT_VOID_ARRAY, "binary_array") +DECLARE_ATTRIBUTE_ARRAY_TYPE(DmeTime_t, AT_TIME_ARRAY, "time_array") +DECLARE_ATTRIBUTE_ARRAY_TYPE_INTERNAL(DmElementHandle_t, DmElementArray_t, AT_ELEMENT_ARRAY, "element_array") + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/dmelementhandle.h b/SpyCustom/sdk/dmelementhandle.h new file mode 100644 index 0000000..78b8844 --- /dev/null +++ b/SpyCustom/sdk/dmelementhandle.h @@ -0,0 +1,34 @@ +#ifndef DMELEMENTHANDLE_H +#define DMELEMENTHANDLE_H + +#ifdef _WIN32 +#pragma once +#endif + + +#define PERFORM_HANDLE_TYPECHECKING 0 +#if PERFORM_HANDLE_TYPECHECKING + +struct DmElementHandle_t +{ + DmElementHandle_t() : handle(0xffffffff) {} + explicit DmElementHandle_t(int h) : handle(h) {} + inline bool operator==(const DmElementHandle_t& h) const { return handle == h.handle; } + inline bool operator!=(const DmElementHandle_t& h) const { return handle != h.handle; } + inline bool operator<(const DmElementHandle_t& h) const { return handle < h.handle; } + int handle; +}; +const DmElementHandle_t DMELEMENT_HANDLE_INVALID; + +#else + +enum DmElementHandle_t +{ + DMELEMENT_HANDLE_INVALID = 0xffffffff +}; + +#endif + + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/dmxattribute.h b/SpyCustom/sdk/dmxattribute.h new file mode 100644 index 0000000..c946bb1 --- /dev/null +++ b/SpyCustom/sdk/dmxattribute.h @@ -0,0 +1,210 @@ +#ifndef DMXATTRIBUTE_H +#define DMXATTRIBUTE_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "dmattributetypes.h" +#include "utlvector.h" +#include "utlrbtree.h" +#include "utlsymbol.h" +#include "mempool.h" +#include "dmxloader.h" + + +class CDmxElement; + + + + + +#define DECLARE_DMX_ATTRIBUTE_TYPE_INTERNAL( _className, _storageType, _attributeType, _attributeName, _defaultSetStatement ) \ + template< > class CDmAttributeInfo< _className > \ + { \ + private: \ + enum { ATTRIBUTE_TYPE = _attributeType }; \ + typedef _storageType StorageType_t; \ + static DmAttributeType_t AttributeType() { return _attributeType; } \ + static const char *AttributeTypeName() { return _attributeName; } \ + static void SetDefaultValue( _className& value ) { _defaultSetStatement } \ + friend class CDmxAttribute; \ + friend class CDmxElement; \ + }; \ + +#define DECLARE_DMX_ATTRIBUTE_ARRAY_TYPE_INTERNAL( _className, _storageType, _attributeType, _attributeName ) \ + template< > class CDmAttributeInfo< CUtlVector<_className> > \ + { \ + private: \ + enum { ATTRIBUTE_TYPE = _attributeType }; \ + typedef _storageType StorageType_t; \ + static DmAttributeType_t AttributeType() { return _attributeType; } \ + static const char *AttributeTypeName() { return _attributeName; } \ + static void SetDefaultValue( CUtlVector< _className >& value ) { value.RemoveAll(); } \ + friend class CDmxAttribute; \ + friend class CDmxElement; \ + }; \ + +#define DECLARE_DMX_ATTRIBUTE_TYPE( _className, _attributeType, _attributeName, _defaultSetStatement ) \ + DECLARE_DMX_ATTRIBUTE_TYPE_INTERNAL( _className, _className, _attributeType, _attributeName, _defaultSetStatement ) + +#define DECLARE_DMX_ATTRIBUTE_ARRAY_TYPE( _className, _attributeType, _attributeName )\ + DECLARE_DMX_ATTRIBUTE_ARRAY_TYPE_INTERNAL( _className, CUtlVector< _className >, _attributeType, _attributeName ) + + + +DECLARE_DMX_ATTRIBUTE_TYPE(CDmxElement*, AT_ELEMENT, "element", value = 0; ) +DECLARE_DMX_ATTRIBUTE_ARRAY_TYPE(CDmxElement*, AT_ELEMENT_ARRAY, "element_array") + +DECLARE_DMX_ATTRIBUTE_TYPE(CUtlString, AT_STRING, "string", value.Set(NULL); ) +DECLARE_DMX_ATTRIBUTE_ARRAY_TYPE(CUtlString, AT_STRING_ARRAY, "string_array") + + +class CDmxAttribute +{ + DECLARE_DMX_ALLOCATOR(); + +public: + DmAttributeType_t GetType() const; + const char* GetTypeString() const; + template< class T > bool IsA() const; + + const char* GetName() const; + CUtlSymbolLarge GetNameSymbol() const; + void SetName(const char* pName); + + template< class T > const T& GetValue() const; + template< class T > const CUtlVector< T >& GetArray() const; + const char* GetValueString() const; + + template< class T > void SetValue(const T& value); + void SetValue(const char* pString); + void SetValue(char* pString); + void SetValue(const void* pBuffer, size_t nLen); + void SetValue(const CDmxAttribute* pAttribute); + + template< class T > CUtlVector< T >& GetArrayForEdit(); + + void SetToDefaultValue(); + + void SetValueFromString(const char* pValue); + const char* GetValueAsString(char* pBuffer, size_t nBufLen) const; + + int GetArrayCount() const; + + bool Unserialize(DmAttributeType_t type, CUtlBuffer& buf); + bool UnserializeElement(DmAttributeType_t type, CUtlBuffer& buf); + bool Serialize(CUtlBuffer& buf) const; + bool SerializeElement(int nIndex, CUtlBuffer& buf) const; + bool SerializesOnMultipleLines() const; + + static int AttributeDataSize(DmAttributeType_t type); + static DmAttributeType_t ArrayAttributeBasicType(DmAttributeType_t type); + +private: + CDmxAttribute(const char* pAttributeName); + CDmxAttribute(CUtlSymbolLarge attributeName); + ~CDmxAttribute(); + + void AllocateDataMemory(DmAttributeType_t type); + void AllocateDataMemory_AndConstruct(DmAttributeType_t type); + void FreeDataMemory(); + + + void SetValue(DmAttributeType_t type, const void* pSrc, int nLen); + void SetArrayValue(DmAttributeType_t type, const void* pSrc, int nDataTypeSize, int nArrayLength, int nSrcStride); + void GetArrayValue(DmAttributeType_t type, void* pDest, int nDataTypeSize, int nArrayLength, const char* pDefaultString = NULL) const; + void SetArrayCount(int nArrayCount); + const void* GetArrayBase(void) const; + + template < class VT, class T > void ConstructDataMemory(void); + template < class VT, class T > void DestructDataMemory(void); + template < class VT, class T > void SetArrayCount(int nArrayCount); + template < class VT, class T > void GetArrayCount(int& nArrayCount) const; + template < class VT, class T > void GetArrayBase(const void*& pBasePtr) const; + template < class VT, class T > void SerializesOnMultipleLines(bool& bResult) const; + template < class VT, class T > void SerializeType(bool& bSuccess, CUtlBuffer& buf) const; + template < class VT, class T > void SerializeTypedElement(bool& bSuccess, int nIndex, CUtlBuffer& buf) const; + template < class VT, class T > void UnserializeType(bool& bSuccess, CUtlBuffer& buf); + template < class VT, class T > void UnserializeTypedElement(bool& bSuccess, CUtlBuffer& buf); + template < class VT, class T > void SetDefaultValue(void); + + + DmAttributeType_t m_Type; + CUtlSymbolLarge m_Name; + void* m_pData; + + static CUtlSymbolTableLargeMT s_AttributeNameSymbols; + + friend class CDmxElement; + +public: + + static const char* s_pAttributeTypeName[AT_TYPE_COUNT]; + +}; + + +inline DmAttributeType_t CDmxAttribute::GetType() const +{ + return m_Type; +} + +template< class T > inline bool CDmxAttribute::IsA() const +{ + return GetType() == CDmAttributeInfo< T >::ATTRIBUTE_TYPE; +} + +inline CUtlSymbolLarge CDmxAttribute::GetNameSymbol() const +{ + return m_Name; +} + + +template< class T > void CDmxAttribute::SetValue(const T& value) +{ + AllocateDataMemory(CDmAttributeInfo::AttributeType()); + CopyConstruct((T*)m_pData, value); +} + + +inline const char* CDmxAttribute::GetValueString() const +{ + if (m_Type == AT_STRING) + return *(CUtlString*)m_pData; + return ""; +} + +template< class T > +inline const T& CDmxAttribute::GetValue() const +{ + if (CDmAttributeInfo::AttributeType() == m_Type) + return *(T*)m_pData; + + static T defaultValue; + CDmAttributeInfo::SetDefaultValue(defaultValue); + return defaultValue; +} + +template< class T > +inline const CUtlVector< T >& CDmxAttribute::GetArray() const +{ + if (CDmAttributeInfo< CUtlVector< T > >::AttributeType() == m_Type) + return *(CUtlVector< T >*)m_pData; + + static CUtlVector defaultArray; + return defaultArray; +} + +template< class T > +inline CUtlVector< T >& CDmxAttribute::GetArrayForEdit() +{ + if (CDmAttributeInfo< CUtlVector< T > >::AttributeType() == m_Type) + return *(CUtlVector< T >*)m_pData; + + AllocateDataMemory(CDmAttributeInfo< CUtlVector< T > >::AttributeType()); + Construct((CUtlVector*)m_pData); + return *(CUtlVector< T >*)m_pData; +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/dmxelement.h b/SpyCustom/sdk/dmxelement.h new file mode 100644 index 0000000..7f40432 --- /dev/null +++ b/SpyCustom/sdk/dmxelement.h @@ -0,0 +1,472 @@ +#ifndef DMXELEMENT_H +#define DMXELEMENT_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "dmattributetypes.h" +#include "utlvector.h" +#include "utlrbtree.h" +#include "utlsymbol.h" +#include "mempool.h" +#include "utlsortvector.h" +#include "dmxattribute.h" + + +class CDmxAttributeLess +{ +public: + bool Less(const CDmxAttribute* pAttribute1, const CDmxAttribute* pAttribute2, void* pContext) + { + return (pAttribute1 ? pAttribute1->GetNameSymbol() : CUtlSymbolLarge(UTL_INVAL_SYMBOL_LARGE)) < (pAttribute2 ? pAttribute2->GetNameSymbol() : CUtlSymbolLarge(UTL_INVAL_SYMBOL_LARGE)); + } +}; + + +enum BitfieldType_t +{ + BITFIELD_TYPE_NONE, + BITFIELD_TYPE_BOOL, + BITFIELD_TYPE_CHAR, + BITFIELD_TYPE_UNSIGNED_CHAR, + BITFIELD_TYPE_BYTE = BITFIELD_TYPE_UNSIGNED_CHAR, + BITFIELD_TYPE_SHORT, + BITFIELD_TYPE_UNSIGNED_SHORT, + BITFIELD_TYPE_INT, + BITFIELD_TYPE_UNSIGNED_INT, +}; + +struct DmxElementUnpackStructure_t +{ + const char* m_pAttributeName; + const char* m_pDefaultString; + DmAttributeType_t m_AttributeType; + int m_nOffset; + int m_nSize; + int m_nBitOffset; + BitfieldType_t m_BitfieldType; + const void* m_pUserData; + + const char* m_pTypeName; + const DmxElementUnpackStructure_t* m_pSub; + + int m_nArrayLength; +}; + +#define NO_BIT_OFFSET -1 +#define UTL_STRING_SIZE -1 +#define NO_USER_DATA NULL +#define NO_EMBEDDED_TYPENAME NULL +#define NO_EMBEDDED_STRUCT_PTR NULL +#define NOT_A_BITFIELD BITFIELD_TYPE_NONE +#define NOT_AN_ARRAY 0 + +#define DECLARE_DMXELEMENT_UNPACK() \ + template friend DmxElementUnpackStructure_t *DmxElementUnpackInit(T *); + +#define BEGIN_DMXELEMENT_UNPACK( _structName ) \ + template DmxElementUnpackStructure_t *DmxElementUnpackInit(T *); \ + template <> DmxElementUnpackStructure_t *DmxElementUnpackInit<_structName>( _structName * ); \ + namespace _structName##_UnpackInit \ + { \ + static DmxElementUnpackStructure_t *s_pUnpack = DmxElementUnpackInit( (_structName *)NULL ); \ + } \ + \ + template <> DmxElementUnpackStructure_t *DmxElementUnpackInit<_structName>( _structName * ) \ + { \ + typedef _structName DestStructType_t; \ + static DmxElementUnpackStructure_t unpack[] = \ + { \ + +#define DMXELEMENT_UNPACK_FLTX4( _attributeName, _defaultString, _varName ) \ + { _attributeName, _defaultString, CDmAttributeInfo::AttributeType(), offsetof( DestStructType_t, _varName ), sizeof( fltx4 ), NO_BIT_OFFSET, NOT_A_BITFIELD, NO_USER_DATA, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR, NOT_AN_ARRAY }, + +#define DMXELEMENT_UNPACK_EMBEDDED( _typeName, _attributeName, _varName, _embeddedUnpackStructure ) \ + { _attributeName, "", AT_TYPE_COUNT, offsetof( DestStructType_t, _varName ), sizeof( ((DestStructType_t *)0)->_varName), NO_BIT_OFFSET, NOT_A_BITFIELD, NO_USER_DATA, _typeName, _embeddedUnpackStructure, NOT_AN_ARRAY }, + +#define DMXELEMENT_UNPACK_BASECLASS( _structName, _baseClass ) \ + { "Baseclass unpack", "", AT_TYPE_COUNT, size_cast< int >((intp) static_cast< _baseClass * >( (_structName*)0)), 0, NO_BIT_OFFSET, NOT_A_BITFIELD, NO_USER_DATA, #_baseClass, DmxElementUnpackInit<_baseClass>( (_baseClass *)0 ), NOT_AN_ARRAY }, + +#define DMXELEMENT_UNPACK_BASECLASS_NAMESPACE( _namespace, _structName, _baseClass ) \ + { "Baseclass unpack", "", AT_TYPE_COUNT, size_cast< int >((intp) static_cast< _baseClass * >( (_structName*)0)), 0, NO_BIT_OFFSET, NOT_A_BITFIELD, NO_USER_DATA, #_baseClass, DmxElementUnpackInit##_namespace<_baseClass>( (_baseClass *)0 ), NOT_AN_ARRAY }, + +#define VGUI_UNPACK_BASEPANEL() \ + DMXELEMENT_UNPACK_BASECLASS_NAMESPACE( vgui, DestStructType_t, DestStructType_t::BaseClass ) \ + +#define DMXELEMENT_UNPACK_FIELD( _attributeName, _defaultString, _type, _varName ) \ + { _attributeName, _defaultString, CDmAttributeInfo<_type>::AttributeType(), offsetof( DestStructType_t, _varName ), sizeof( ((DestStructType_t *)0)->_varName), NO_BIT_OFFSET, NOT_A_BITFIELD, NO_USER_DATA, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR, NOT_AN_ARRAY }, +#define DMXELEMENT_UNPACK_FIELD_STRING( _attributeName, _defaultString, _varName ) \ + { _attributeName, _defaultString, AT_STRING, offsetof( DestStructType_t, _varName ), sizeof( ((DestStructType_t *)0)->_varName), NO_BIT_OFFSET, NOT_A_BITFIELD, NO_USER_DATA, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR, NOT_AN_ARRAY }, +#define DMXELEMENT_UNPACK_FIELD_UTLSTRING( _attributeName, _defaultString, _varName ) \ + { _attributeName, _defaultString, AT_STRING, offsetof( DestStructType_t, _varName ), UTL_STRING_SIZE, NO_BIT_OFFSET, NOT_A_BITFIELD, NO_USER_DATA, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR, NOT_AN_ARRAY }, +#define DMXELEMENT_UNPACK_SHORT( _attributeName, _defaultString, _varName ) \ + { _attributeName, _defaultString, AT_INT, offsetof( DestStructType_t, _varName ), sizeof( short ), NO_BIT_OFFSET, NOT_A_BITFIELD, NO_USER_DATA, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR, NOT_AN_ARRAY }, +#define DMXELEMENT_UNPACK_CHAR( _attributeName, _defaultString, _varName ) \ + { _attributeName, _defaultString, AT_INT, offsetof( DestStructType_t, _varName ), sizeof( char ), NO_BIT_OFFSET, NOT_A_BITFIELD, NO_USER_DATA, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR, NOT_AN_ARRAY }, +#define DMXELEMENT_UNPACK_BITFIELD( _attributeName, _defaultString, _bitfieldType, _varName ) \ + { _attributeName, _defaultString, CDmAttributeInfo::AttributeType(), DestStructType_t::Get##_varName##ByteOffset(), DestStructType_t::Get##_varName##BitCount(), DestStructType_t::Get##_varName##BitOffset(), _bitfieldType, NO_USER_DATA, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR, NOT_AN_ARRAY }, + +#define DMXELEMENT_UNPACK_FIELD_ARRAY( _attributeName, _defaultString, _type, _varName ) \ + { _attributeName, _defaultString, CDmAttributeInfo< CUtlVector< _type > >::AttributeType(), offsetof( DestStructType_t, _varName ), sizeof( ((DestStructType_t *)0)->_varName[0]), NO_BIT_OFFSET, NOT_A_BITFIELD, NO_USER_DATA, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR, ARRAYSIZE( ((DestStructType_t *)0)->_varName ) }, + + +#define DMXELEMENT_UNPACK_FIELD_USERDATA( _attributeName, _defaultString, _type, _varName, _userData ) \ + { _attributeName, _defaultString, CDmAttributeInfo<_type>::AttributeType(), offsetof( DestStructType_t, _varName ), sizeof( ((DestStructType_t *)0)->_varName), NO_BIT_OFFSET, NOT_A_BITFIELD, _userData, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR, NOT_AN_ARRAY }, +#define DMXELEMENT_UNPACK_FIELD_STRING_USERDATA( _attributeName, _defaultString, _varName, _userData ) \ + { _attributeName, _defaultString, AT_STRING, offsetof( DestStructType_t, _varName ), sizeof( ((DestStructType_t *)0)->_varName), NO_BIT_OFFSET, NOT_A_BITFIELD, _userData, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR, NOT_AN_ARRAY }, +#define DMXELEMENT_UNPACK_FIELD_UTLSTRING_USERDATA( _attributeName, _defaultString, _varName, _userData ) \ + { _attributeName, _defaultString, AT_STRING, offsetof( DestStructType_t, _varName ), UTL_STRING_SIZE, NO_BIT_OFFSET, NOT_A_BITFIELD, _userData, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR, NOT_AN_ARRAY }, + +#define END_DMXELEMENT_UNPACK( _structName, _varName ) \ + { NULL, NULL, AT_UNKNOWN, 0, 0, NO_BIT_OFFSET, NOT_A_BITFIELD, NO_USER_DATA, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR } \ + }; \ + return unpack; \ + } \ + DmxElementUnpackStructure_t *_varName = _structName##_UnpackInit::s_pUnpack; + +#define END_DMXELEMENT_UNPACK_TEMPLATE( _structName, _varName ) \ + { NULL, NULL, AT_UNKNOWN, 0, 0, NO_BIT_OFFSET, NOT_A_BITFIELD, NO_USER_DATA, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR } \ + }; \ + return unpack; \ + } \ + template<> DmxElementUnpackStructure_t *_varName = _structName##_UnpackInit::s_pUnpack; + +#define BEGIN_DMXELEMENT_NAMESPACE_UNPACK( _nameSpace, _structName ) \ + template DmxElementUnpackStructure_t *DmxElementUnpackInit(T *); \ + template <> DmxElementUnpackStructure_t *_nameSpace::DmxElementUnpackInit<_nameSpace::_structName>( _nameSpace::_structName * ); \ + namespace _structName##_UnpackInit \ + { \ + static DmxElementUnpackStructure_t *s_pUnpack = _nameSpace::DmxElementUnpackInit( (_nameSpace::_structName *)NULL ); \ + } \ + \ + template <> DmxElementUnpackStructure_t *_nameSpace::DmxElementUnpackInit<_nameSpace::_structName>( _nameSpace::_structName * ) \ + { \ + typedef _nameSpace::_structName DestStructType_t; \ + static DmxElementUnpackStructure_t unpack[] = \ + { \ + +#if defined( _PS3 ) && defined( __GCC__ ) +#define DECLARE_DMXELEMENT_UNPACK_NAMESPACE( _namespace ) \ + template friend DmxElementUnpackStructure_t *_namespace::DmxElementUnpackInit##_namespace(T *); \ + private: \ + static DmxElementUnpackStructure_t *s_pUnpackParams; \ + public: \ + virtual const DmxElementUnpackStructure_t* GetUnpackStructure() const { return s_pUnpackParams; } +#else +#define DECLARE_DMXELEMENT_UNPACK_NAMESPACE( _namespace ) \ + template friend DmxElementUnpackStructure_t *DmxElementUnpackInit##_namespace(T *); \ + private: \ + static DmxElementUnpackStructure_t *s_pUnpackParams; \ + public: \ + virtual const DmxElementUnpackStructure_t* GetUnpackStructure() const { return s_pUnpackParams; } +#endif + +#define BEGIN_DMXELEMENT_UNPACK_NAMESPACE_SIMPLE( _namespace, _structName ) \ + BEGIN_DMXELEMENT_UNPACK_NAMESPACE( _namespace, _structName ) \ + VGUI_UNPACK_BASEPANEL() \ + +#define BEGIN_DMXELEMENT_UNPACK_NAMESPACE_SIMPLE_NO_BASE( _namespace, _structName ) \ + BEGIN_DMXELEMENT_UNPACK_NAMESPACE( _namespace, _structName ) \ + +#define BEGIN_DMXELEMENT_UNPACK_NAMESPACE( _namespace, _structName ) \ + namespace _namespace { \ + template DmxElementUnpackStructure_t *DmxElementUnpackInit##_namespace(T *); \ + template <> DmxElementUnpackStructure_t *DmxElementUnpackInit##_namespace<_structName>( _namespace::_structName * ); \ + namespace _namespace##_structName##_UnpackInit \ + { \ + static DmxElementUnpackStructure_t *s_pUnpack = _namespace::DmxElementUnpackInit##_namespace( (_namespace::_structName *)NULL ); \ + } \ + \ + template <> DmxElementUnpackStructure_t *DmxElementUnpackInit##_namespace<_structName>( _namespace::_structName * ) \ + { \ + typedef _structName DestStructType_t; \ + static DmxElementUnpackStructure_t unpack[] = \ + { \ + +#define END_DMXELEMENT_UNPACK_NAMESPACE( _namespace, _structName, _varName ) \ + { NULL, NULL, AT_UNKNOWN, 0, 0, NO_BIT_OFFSET, NOT_A_BITFIELD, NO_USER_DATA, NO_EMBEDDED_TYPENAME, NO_EMBEDDED_STRUCT_PTR } \ + }; \ + return unpack; \ + } \ + DmxElementUnpackStructure_t *_structName::_varName = _namespace##_structName##_UnpackInit::s_pUnpack; \ + } \ + +template inline T GetAllOnesNumber() +{ + T temp = 0; + return (T)~temp; +} + +template <> inline bool GetAllOnesNumber() +{ + return true; +} + +#define DECLARE_DMXELEMENT_BITFIELD( _fieldName, _type, _structName ) \ + class CBitFieldInfo_##_fieldName \ + { \ + public: \ + CBitFieldInfo_##_fieldName () \ + { \ + const int nSize = ( sizeof(_structName) + 3 ) & ~0x3; \ + unsigned char pBuf[nSize] = {}; \ + (( _structName * )pBuf)->_fieldName = GetAllOnesNumber<_type>(); \ + _type *pTest = (_type *)pBuf; \ + for ( int i = 0; i < sizeof(_structName); ++i ) \ + { \ + if ( pTest[i] == 0 ) \ + continue; \ + \ + for ( int j = 0; j < 8*sizeof(_type); ++j ) \ + { \ + unsigned int temp = ((unsigned int)pTest[i]) & ( 1 << j ) ; \ + if ( temp == 0 ) \ + continue; \ + \ + m_nByteOffset = i*sizeof(_type) + j / 8; \ + m_nBitOffset = j & 0x7; \ + \ + int k; \ + for ( k = j+1; k < 8*sizeof(_type); ++k ) \ + { \ + unsigned int temp = ((unsigned int)pTest[i]) & ( 1 << k ) ; \ + if ( temp != 0 ) \ + continue; \ + break; \ + } \ + m_nBitCount = k - j; \ + break; \ + } \ + break; \ + } \ + } \ + \ + int GetByteOffset() const \ + { \ + return m_nByteOffset; \ + } \ + \ + int GetBitCount() const \ + { \ + return m_nBitCount; \ + } \ + \ + int GetBitOffset() const \ + { \ + return m_nBitOffset; \ + } \ + \ + private: \ + int m_nByteOffset; \ + int m_nBitCount; \ + int m_nBitOffset; \ + }; \ + \ + static int Get##_fieldName##BitCount() \ + { \ + CBitFieldInfo_##_fieldName info; \ + return info.GetBitCount(); \ + } \ + \ + static int Get##_fieldName##ByteOffset() \ + { \ + CBitFieldInfo_##_fieldName info; \ + return info.GetByteOffset(); \ + } \ + \ + static int Get##_fieldName##BitOffset() \ + { \ + CBitFieldInfo_##_fieldName info; \ + return info.GetBitOffset(); \ + } \ + friend class CBitFieldInfo_##_fieldName; \ + + +extern CUtlSymbolTableLargeMT g_DmxAttributeStrings; + +class CDmxElement +{ + DECLARE_DMX_ALLOCATOR(); + +public: + bool HasAttribute(const char* pAttributeName) const; + CDmxAttribute* GetAttribute(const char* pAttributeName); + const CDmxAttribute* GetAttribute(const char* pAttributeName) const; + int AttributeCount() const; + CDmxAttribute* GetAttribute(int nIndex); + const CDmxAttribute* GetAttribute(int nIndex) const; + CUtlSymbolLarge GetType() const; + const char* GetTypeString() const; + const char* GetName() const; + const DmObjectId_t& GetId() const; + + void LockForChanges(bool bLock); + CDmxAttribute* AddAttribute(const char* pAttributeName); + void RemoveAttribute(const char* pAttributeName); + void RemoveAttributeByPtr(CDmxAttribute* pAttribute); + void RemoveAllAttributes(); + void RenameAttribute(const char* pAttributeName, const char* pNewName); + + const char* GetValueString(const char* pAttributeName) const; + template< class T > const T& GetValue(const char* pAttributeName) const; + template< class T > const T& GetValue(const char* pAttributeName, const T& defaultValue) const; + + template< class T > const CUtlVector& GetArray(const char* pAttributeName) const; + template< class T > const CUtlVector& GetArray(const char* pAttributeName, const CUtlVector& defaultValue) const; + + void SetName(const char* pName); + CDmxAttribute* SetValue(const char* pAttributeName, const char* pString); + CDmxAttribute* SetValue(const char* pAttributeName, void* pBuffer, int nLen); + template< class T > CDmxAttribute* SetValue(const char* pAttributeName, const T& value); + + void UnpackIntoStructure(void* pData, const DmxElementUnpackStructure_t* pUnpack) const; + + void AddAttributesFromStructure(const void* pData, const DmxElementUnpackStructure_t* pUnpack); + +private: + typedef CUtlSortVector< CDmxAttribute*, CDmxAttributeLess > AttributeList_t; + + CDmxElement(const char* pType); + ~CDmxElement(); + + void RemoveAllElementsRecursive(); + + void AddElementsToDelete(CUtlVector< CDmxElement* >& elementsToDelete); + + void Resort() const; + + int FindAttribute(const char* pAttributeName) const; + int FindAttribute(CUtlSymbolLarge attributeName) const; + + void SetId(const DmObjectId_t& id); + + bool IsLocked() const; + + template void UnpackBitfield(T* pDest2, const DmxElementUnpackStructure_t* pUnpack, const CDmxAttribute* pAttribute) const; + + AttributeList_t m_Attributes; + DmObjectId_t m_Id; + CUtlSymbolLarge m_Type; + char m_nLockCount; + mutable bool m_bResortNeeded : 1; + bool m_bIsMarkedForDeletion : 1; + + static CUtlSymbolTableLargeMT s_TypeSymbols; + + friend class CDmxSerializer; + friend class CDmxSerializerKeyValues2; + friend void CleanupDMX(CDmxElement* pElement); + friend CDmxElement* CreateDmxElement(const char* pType); +}; + + +inline bool CDmxElement::IsLocked() const +{ + return m_nLockCount > 0; +} + +inline const char* CDmxElement::GetValueString(const char* pAttributeName) const +{ + const CDmxAttribute* pAttribute = GetAttribute(pAttributeName); + if (pAttribute) + return pAttribute->GetValueString(); + return ""; +} + +template< class T > +inline const T& CDmxElement::GetValue(const char* pAttributeName) const +{ + const CDmxAttribute* pAttribute = GetAttribute(pAttributeName); + if (pAttribute) + return pAttribute->GetValue(); + + static T defaultValue; + CDmAttributeInfo::SetDefaultValue(defaultValue); + return defaultValue; +} + +template< class T > +inline const T& CDmxElement::GetValue(const char* pAttributeName, const T& defaultValue) const +{ + const CDmxAttribute* pAttribute = GetAttribute(pAttributeName); + if (pAttribute) + return pAttribute->GetValue(); + return defaultValue; +} + +template< class T > +inline const CUtlVector& CDmxElement::GetArray(const char* pAttributeName) const +{ + const CDmxAttribute* pAttribute = GetAttribute(pAttributeName); + if (pAttribute) + return pAttribute->GetArray(); + + static CUtlVector defaultValue; + return defaultValue; +} + +template< class T > +inline const CUtlVector& CDmxElement::GetArray(const char* pAttributeName, const CUtlVector& defaultValue) const +{ + const CDmxAttribute* pAttribute = GetAttribute(pAttributeName); + if (pAttribute) + return pAttribute->GetArray(); + return defaultValue; +} + + +CDmxElement* CreateDmxElement(const char* pType); + + +class CDmxElementModifyScope +{ +public: + CDmxElementModifyScope(CDmxElement* pElement) : m_pElement(pElement) + { + m_pElement->LockForChanges(true); + } + ~CDmxElementModifyScope() + { + Release(); + } + void Release() + { + if (m_pElement) + { + m_pElement->LockForChanges(false); + m_pElement = NULL; + } + } +private: + CDmxElement* m_pElement; +}; + + +inline CDmxAttribute* CDmxElement::SetValue(const char* pAttributeName, const char* pString) +{ + CDmxElementModifyScope modify(this); + CDmxAttribute* pAttribute = AddAttribute(pAttributeName); + pAttribute->SetValue(pString); + return pAttribute; +} + +inline CDmxAttribute* CDmxElement::SetValue(const char* pAttributeName, void* pBuffer, int nLen) +{ + CDmxElementModifyScope modify(this); + CDmxAttribute* pAttribute = AddAttribute(pAttributeName); + pAttribute->SetValue(pBuffer, nLen); + return pAttribute; +} + +template< class T > +inline CDmxAttribute* CDmxElement::SetValue(const char* pAttributeName, const T& value) +{ + CDmxElementModifyScope modify(this); + CDmxAttribute* pAttribute = AddAttribute(pAttributeName); + pAttribute->SetValue(value); + return pAttribute; +} + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/dmxloader.h b/SpyCustom/sdk/dmxloader.h new file mode 100644 index 0000000..293723d --- /dev/null +++ b/SpyCustom/sdk/dmxloader.h @@ -0,0 +1,48 @@ +#ifndef DMXLOADER_H +#define DMXLOADER_H + +#ifdef _WIN32 +#pragma once +#endif + +class CUtlBuffer; +class CDmxElement; + + +bool SerializeDMX(CUtlBuffer& buf, CDmxElement* pRoot, const char* pFileName = NULL); +bool SerializeDMX(const char* pFileName, const char* pPathID, bool bTextMode, CDmxElement* pRoot); + +bool UnserializeDMX(CUtlBuffer& buf, CDmxElement** ppRoot, const char* pFileName = NULL); +bool UnserializeDMX(const char* pFileName, const char* pPathID, bool bTextMode, CDmxElement** ppRoot); + +void BeginDMXContext(); +void EndDMXContext(bool bDecommitMemory); +void DecommitDMXMemory(); + + +class CDMXContextHelper +{ +public: + CDMXContextHelper(bool bDecommitMemory) { m_bDecommitMemory = bDecommitMemory; BeginDMXContext(); } + ~CDMXContextHelper() { EndDMXContext(m_bDecommitMemory); } + +private: + bool m_bDecommitMemory; +}; + +#define DECLARE_DMX_CONTEXT( ) CDMXContextHelper __dmxContextHelper( true ); +#define DECLARE_DMX_CONTEXT_NODECOMMIT( ) CDMXContextHelper __dmxContextHelper( false ); +#define DECLARE_DMX_CONTEXT_DECOMMIT( _decommit ) CDMXContextHelper __dmxContextHelper( _decommit ); + + +void* DMXAlloc(size_t size); + + +#define DECLARE_DMX_ALLOCATOR( ) \ + public: \ + inline void* operator new( size_t size ) { MEM_ALLOC_CREDIT_( "DMXAlloc" ); return DMXAlloc(size); } \ + inline void* operator new( size_t size, int nBlockUse, const char *pFileName, int nLine ) { MEM_ALLOC_CREDIT_( "DMXAlloc" ); return DMXAlloc(size); } \ + inline void operator delete( void* p ) { } \ + inline void operator delete( void* p, int nBlockUse, const char *pFileName, int nLine ) { } \ + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/dt_common.h b/SpyCustom/sdk/dt_common.h new file mode 100644 index 0000000..277fba5 --- /dev/null +++ b/SpyCustom/sdk/dt_common.h @@ -0,0 +1,191 @@ +#ifndef DATATABLE_COMMON_H +#define DATATABLE_COMMON_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "basetypes.h" +#include "dbg.h" +#include "strtools.h" +#include + +#ifdef LINUX +#undef offsetof +#define offsetof(s,m) (size_t)&(((s *)0)->m) +#endif + +#define MAX_DATATABLES 1024 +#define MAX_DATATABLE_PROPS 4096 + +#define MAX_ARRAY_ELEMENTS 2048 + +#define HIGH_DEFAULT -121121.121121f + +#define BITS_FULLRES -1 +#define BITS_WORLDCOORD -2 + +#define DT_MAX_STRING_BITS 9 +#define DT_MAX_STRING_BUFFERSIZE (1<varName ) + +#define PROPSIZEOF(className, varName) sizeof(((className*)0)->varName) + + +#define SPROP_UNSIGNED (1<<0) + +#define SPROP_COORD (1<<1) +#define SPROP_NOSCALE (1<<2) + +#define SPROP_ROUNDDOWN (1<<3) + +#define SPROP_ROUNDUP (1<<4) + +#define SPROP_NORMAL (1<<5) + +#define SPROP_EXCLUDE (1<<6) + +#define SPROP_XYZE (1<<7) + +#define SPROP_INSIDEARRAY (1<<8) +#define SPROP_PROXY_ALWAYS_YES (1<<9) +#define SPROP_CHANGES_OFTEN (1<<10) + +#define SPROP_IS_A_VECTOR_ELEM (1<<11) + +#define SPROP_COLLAPSIBLE (1<<12) +#define SPROP_COORD_MP (1<<13) +#define SPROP_COORD_MP_LOWPRECISION (1<<14) +#define SPROP_COORD_MP_INTEGRAL (1<<15) + +#define SPROP_VARINT SPROP_NORMAL + +#define SPROP_NUMFLAGBITS_NETWORKED 16 + +#define SPROP_ENCODED_AGAINST_TICKCOUNT (1<<16) + +#define SPROP_NUMFLAGBITS 17 + +#define SIZEOF_IGNORE -1 + + +#define EXTERN_SEND_TABLE(tableName) namespace tableName {extern SendTable g_SendTable;} +#define EXTERN_RECV_TABLE(tableName) namespace tableName {extern RecvTable g_RecvTable;} + +#define REFERENCE_SEND_TABLE(tableName) tableName::g_SendTable +#define REFERENCE_RECV_TABLE(tableName) tableName::g_RecvTable + + +class SendProp; + +typedef enum +{ + DPT_Int = 0, + DPT_Float, + DPT_Vector, + DPT_VectorXY, + DPT_String, + DPT_Array, + DPT_DataTable, +#if 0 + DPT_Quaternion, +#endif + +#ifdef SUPPORTS_INT64 + DPT_Int64, +#endif + + DPT_NUMSendPropTypes + +} SendPropType; + + +class DVariant +{ +public: + DVariant() { m_Type = DPT_Float; } + DVariant(float val) { m_Type = DPT_Float; m_Float = val; } + + const char* ToString() + { + static char text[128]; + + switch (m_Type) + { + case DPT_Int: + Q_snprintf(text, sizeof(text), "%i", m_Int); + break; + case DPT_Float: + Q_snprintf(text, sizeof(text), "%.3f", m_Float); + break; + case DPT_Vector: + Q_snprintf(text, sizeof(text), "(%.3f,%.3f,%.3f)", + m_Vector[0], m_Vector[1], m_Vector[2]); + break; + case DPT_VectorXY: + Q_snprintf(text, sizeof(text), "(%.3f,%.3f)", + m_Vector[0], m_Vector[1]); + break; +#if 0 + case DPT_Quaternion: + Q_snprintf(text, sizeof(text), "(%.3f,%.3f,%.3f %.3f)", + m_Vector[0], m_Vector[1], m_Vector[2], m_Vector[3]); + break; +#endif + case DPT_String: + if (m_pString) + return m_pString; + else + return "NULL"; + break; + case DPT_Array: + Q_snprintf(text, sizeof(text), "Array"); + break; + case DPT_DataTable: + Q_snprintf(text, sizeof(text), "DataTable"); + break; +#ifdef SUPPORTS_INT64 + case DPT_Int64: + Q_snprintf(text, sizeof(text), "%I64d", m_Int64); + break; +#endif + default: + Q_snprintf(text, sizeof(text), "DVariant type %i unknown", m_Type); + break; + } + + return text; + } + + union + { + float m_Float; + int m_Int; + const char* m_pString; + void* m_pData; +#if 0 + float m_Vector[4]; +#else + float m_Vector[3]; +#endif + + int64 m_Int64; + }; + SendPropType m_Type; +}; + + +inline int NumBitsForCount(int nMaxElements) +{ + int nBits = 0; + while (nMaxElements > 0) + { + ++nBits; + nMaxElements >>= 1; + } + return nBits; +} + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/dt_recv.h b/SpyCustom/sdk/dt_recv.h new file mode 100644 index 0000000..d5f3f46 --- /dev/null +++ b/SpyCustom/sdk/dt_recv.h @@ -0,0 +1,505 @@ +#ifndef DATATABLE_RECV_H +#define DATATABLE_RECV_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "dt_common.h" +#include "dbg.h" + + +#define ADDRESSPROXY_NONE -1 + + +class RecvTable; +class RecvProp; + + +class CRecvProxyData +{ +public: + const RecvProp* m_pRecvProp; + + DVariant m_Value; + + int m_iElement; + + int m_ObjectID; +}; + + +typedef void (*RecvVarProxyFn)(const CRecvProxyData* pData, void* pStruct, void* pOut); + +typedef void (*ArrayLengthRecvProxyFn)(void* pStruct, int objectID, int currentArrayLength); + + +typedef void (*DataTableRecvVarProxyFn)(const RecvProp* pProp, void** pOut, void* pData, int objectID); + + +class CStandardRecvProxies +{ +public: + CStandardRecvProxies(); + + RecvVarProxyFn m_Int32ToInt8; + RecvVarProxyFn m_Int32ToInt16; + RecvVarProxyFn m_Int32ToInt32; + RecvVarProxyFn m_FloatToFloat; + RecvVarProxyFn m_VectorToVector; +#ifdef SUPPORTS_INT64 + RecvVarProxyFn m_Int64ToInt64; +#endif +}; +extern CStandardRecvProxies g_StandardRecvProxies; + + +class CRecvDecoder; + + +class RecvProp +{ +public: + RecvProp(); + + void InitArray(int nElements, int elementStride); + + int GetNumElements() const; + void SetNumElements(int nElements); + + int GetElementStride() const; + void SetElementStride(int stride); + + int GetFlags() const; + + const char* GetName() const; + SendPropType GetType() const; + + RecvTable* GetDataTable() const; + void SetDataTable(RecvTable* pTable); + + RecvVarProxyFn GetProxyFn() const; + void SetProxyFn(RecvVarProxyFn fn); + + DataTableRecvVarProxyFn GetDataTableProxyFn() const; + void SetDataTableProxyFn(DataTableRecvVarProxyFn fn); + + int GetOffset() const; + void SetOffset(int o); + + RecvProp* GetArrayProp() const; + void SetArrayProp(RecvProp* pProp); + + void SetArrayLengthProxy(ArrayLengthRecvProxyFn proxy); + ArrayLengthRecvProxyFn GetArrayLengthProxy() const; + + bool IsInsideArray() const; + void SetInsideArray(); + + const void* GetExtraData() const; + void SetExtraData(const void* pData); + + const char* GetParentArrayPropName(); + void SetParentArrayPropName(const char* pArrayPropName); + +public: + + const char* m_pVarName; + SendPropType m_RecvType; + int m_Flags; + int m_StringBufferSize; + + + bool m_bInsideArray; + + const void* m_pExtraData; + + RecvProp* m_pArrayProp; + ArrayLengthRecvProxyFn m_ArrayLengthProxy; + + RecvVarProxyFn m_ProxyFn; + DataTableRecvVarProxyFn m_DataTableProxyFn; + + RecvTable* m_pDataTable; + int m_Offset; + + int m_ElementStride; + int m_nElements; + + const char* m_pParentArrayPropName; +}; + + +class RecvTable +{ +public: + + typedef RecvProp PropType; + + RecvTable(); + RecvTable(RecvProp* pProps, int nProps, const char* pNetTableName); + ~RecvTable(); + + void Construct(RecvProp* pProps, int nProps, const char* pNetTableName); + + int GetNumProps(); + RecvProp* GetProp(int i); + + const char* GetName(); + + void SetInitialized(bool bInitialized); + bool IsInitialized() const; + + void SetInMainList(bool bInList); + bool IsInMainList() const; + + +public: + + RecvProp* m_pProps; + int m_nProps; + + CRecvDecoder* m_pDecoder; + + const char* m_pNetTableName; + + + bool m_bInitialized; + bool m_bInMainList; +}; + + +inline int RecvTable::GetNumProps() +{ + return m_nProps; +} + +inline RecvProp* RecvTable::GetProp(int i) +{ + Assert(i >= 0 && i < m_nProps); + return &m_pProps[i]; +} + +inline const char* RecvTable::GetName() +{ + return m_pNetTableName; +} + +inline void RecvTable::SetInitialized(bool bInitialized) +{ + m_bInitialized = bInitialized; +} + +inline bool RecvTable::IsInitialized() const +{ + return m_bInitialized; +} + +inline void RecvTable::SetInMainList(bool bInList) +{ + m_bInMainList = bInList; +} + +inline bool RecvTable::IsInMainList() const +{ + return m_bInMainList; +} + + +#define BEGIN_RECV_TABLE(className, tableName) \ + BEGIN_RECV_TABLE_NOBASE(className, tableName) \ + RecvPropDataTable("baseclass", 0, 0, className::BaseClass::m_pClassRecvTable, DataTableRecvProxy_StaticDataTable), + +#define BEGIN_RECV_TABLE_NOBASE(className, tableName) \ + template int ClientClassInit(T *); \ + namespace tableName { \ + struct ignored; \ + } \ + template <> int ClientClassInit(tableName::ignored *); \ + namespace tableName { \ + RecvTable g_RecvTable; \ + int g_RecvTableInit = ClientClassInit((tableName::ignored *)NULL); \ + } \ + template <> int ClientClassInit(tableName::ignored *) \ + { \ + typedef className currentRecvDTClass; \ + const char *pRecvTableName = #tableName; \ + RecvTable &RecvTable = tableName::g_RecvTable; \ + static RecvProp RecvProps[] = { \ + RecvPropInt("should_never_see_this", 0, sizeof(int)), + +#define END_RECV_TABLE() \ + }; \ + RecvTable.Construct(RecvProps+1, sizeof(RecvProps) / sizeof(RecvProp) - 1, pRecvTableName); \ + return 1; \ + } + + +#define RECVINFO(varName) #varName, offsetof(currentRecvDTClass, varName), sizeof(((currentRecvDTClass*)0)->varName) +#define RECVINFO_NAME(varName, remoteVarName) #remoteVarName, offsetof(currentRecvDTClass, varName), sizeof(((currentRecvDTClass*)0)->varName) +#define RECVINFO_STRING(varName) #varName, offsetof(currentRecvDTClass, varName), STRINGBUFSIZE(currentRecvDTClass, varName) +#define RECVINFO_BASECLASS(tableName) RecvPropDataTable("this", 0, 0, &REFERENCE_RECV_TABLE(tableName)) +#define RECVINFO_ARRAY(varName) #varName, offsetof(currentRecvDTClass, varName), sizeof(((currentRecvDTClass*)0)->varName[0]), sizeof(((currentRecvDTClass*)0)->varName)/sizeof(((currentRecvDTClass*)0)->varName[0]) + +#define RECVINFO_NOSIZE(varName) #varName, offsetof(currentRecvDTClass, varName) +#define RECVINFO_DT(varName) RECVINFO_NOSIZE(varName) +#define RECVINFO_DTNAME(varName,remoteVarName) #remoteVarName, offsetof(currentRecvDTClass, varName) + + +void RecvProxy_FloatToFloat(const CRecvProxyData* pData, void* pStruct, void* pOut); +void RecvProxy_VectorToVector(const CRecvProxyData* pData, void* pStruct, void* pOut); +void RecvProxy_VectorXYToVectorXY(const CRecvProxyData* pData, void* pStruct, void* pOut); +void RecvProxy_QuaternionToQuaternion(const CRecvProxyData* pData, void* pStruct, void* pOut); +void RecvProxy_Int32ToInt8(const CRecvProxyData* pData, void* pStruct, void* pOut); +void RecvProxy_Int32ToInt16(const CRecvProxyData* pData, void* pStruct, void* pOut); +void RecvProxy_StringToString(const CRecvProxyData* pData, void* pStruct, void* pOut); +void RecvProxy_Int32ToInt32(const CRecvProxyData* pData, void* pStruct, void* pOut); +#ifdef SUPPORTS_INT64 +void RecvProxy_Int64ToInt64(const CRecvProxyData* pData, void* pStruct, void* pOut); +#endif + +void DataTableRecvProxy_StaticDataTable(const RecvProp* pProp, void** pOut, void* pData, int objectID); + +void DataTableRecvProxy_PointerDataTable(const RecvProp* pProp, void** pOut, void* pData, int objectID); + + +RecvProp RecvPropFloat( + const char* pVarName, + int offset, + int sizeofVar = SIZEOF_IGNORE, + int flags = 0, + RecvVarProxyFn varProxy = RecvProxy_FloatToFloat +); + +RecvProp RecvPropVector( + const char* pVarName, + int offset, + int sizeofVar = SIZEOF_IGNORE, + int flags = 0, + RecvVarProxyFn varProxy = RecvProxy_VectorToVector +); + +RecvProp RecvPropVectorXY( + const char* pVarName, + int offset, + int sizeofVar = SIZEOF_IGNORE, + int flags = 0, + RecvVarProxyFn varProxy = RecvProxy_VectorXYToVectorXY +); + +#define RecvPropQAngles RecvPropVector + +#if 0 + +RecvProp RecvPropQuaternion( + const char* pVarName, + int offset, + int sizeofVar = SIZEOF_IGNORE, + int flags = 0, + RecvVarProxyFn varProxy = RecvProxy_QuaternionToQuaternion +); +#endif + +RecvProp RecvPropInt( + const char* pVarName, + int offset, + int sizeofVar = SIZEOF_IGNORE, + int flags = 0, + RecvVarProxyFn varProxy = 0 +); + +RecvProp RecvPropString( + const char* pVarName, + int offset, + int bufferSize, + int flags = 0, + RecvVarProxyFn varProxy = RecvProxy_StringToString +); + +RecvProp RecvPropDataTable( + const char* pVarName, + int offset, + int flags, + RecvTable* pTable, + DataTableRecvVarProxyFn varProxy = DataTableRecvProxy_StaticDataTable +); + +RecvProp RecvPropArray3( + const char* pVarName, + int offset, + int sizeofVar, + int elements, + RecvProp pArrayProp, + DataTableRecvVarProxyFn varProxy = DataTableRecvProxy_StaticDataTable +); + +RecvProp InternalRecvPropArray( + const int elementCount, + const int elementStride, + const char* pName, + ArrayLengthRecvProxyFn proxy +); + + +#define RecvPropVirtualArray( arrayLengthProxy, maxArrayLength, varTemplate, propertyName ) \ + varTemplate, \ + InternalRecvPropArray( \ + maxArrayLength, \ + 0, \ + #propertyName, \ + arrayLengthProxy \ + ) + + +#define RecvPropVariableLengthArray( arrayLengthProxy, varTemplate, arrayName ) \ + varTemplate, \ + InternalRecvPropArray( \ + sizeof(((currentRecvDTClass*)0)->arrayName) / PROPSIZEOF(currentRecvDTClass, arrayName[0]), \ + PROPSIZEOF(currentRecvDTClass, arrayName[0]), \ + #arrayName, \ + arrayLengthProxy \ + ) + + +#define RecvPropArray( varTemplate, arrayName ) \ + RecvPropVariableLengthArray( 0, varTemplate, arrayName ) + + +#define RecvPropArray2( arrayLengthProxy, varTemplate, elementCount, elementStride, arrayName ) \ + varTemplate, \ + InternalRecvPropArray( elementCount, elementStride, #arrayName, arrayLengthProxy ) + + +inline void RecvProp::InitArray(int nElements, int elementStride) +{ + m_RecvType = DPT_Array; + m_nElements = nElements; + m_ElementStride = elementStride; +} + +inline int RecvProp::GetNumElements() const +{ + return m_nElements; +} + +inline void RecvProp::SetNumElements(int nElements) +{ + m_nElements = nElements; +} + +inline int RecvProp::GetElementStride() const +{ + return m_ElementStride; +} + +inline void RecvProp::SetElementStride(int stride) +{ + m_ElementStride = stride; +} + +inline int RecvProp::GetFlags() const +{ + return m_Flags; +} + +inline const char* RecvProp::GetName() const +{ + return m_pVarName; +} + +inline SendPropType RecvProp::GetType() const +{ + return m_RecvType; +} + +inline RecvTable* RecvProp::GetDataTable() const +{ + return m_pDataTable; +} + +inline void RecvProp::SetDataTable(RecvTable* pTable) +{ + m_pDataTable = pTable; +} + +inline RecvVarProxyFn RecvProp::GetProxyFn() const +{ + return m_ProxyFn; +} + +inline void RecvProp::SetProxyFn(RecvVarProxyFn fn) +{ + m_ProxyFn = fn; +} + +inline DataTableRecvVarProxyFn RecvProp::GetDataTableProxyFn() const +{ + return m_DataTableProxyFn; +} + +inline void RecvProp::SetDataTableProxyFn(DataTableRecvVarProxyFn fn) +{ + m_DataTableProxyFn = fn; +} + +inline int RecvProp::GetOffset() const +{ + return m_Offset; +} + +inline void RecvProp::SetOffset(int o) +{ + m_Offset = o; +} + +inline RecvProp* RecvProp::GetArrayProp() const +{ + return m_pArrayProp; +} + +inline void RecvProp::SetArrayProp(RecvProp* pProp) +{ + m_pArrayProp = pProp; +} + +inline void RecvProp::SetArrayLengthProxy(ArrayLengthRecvProxyFn proxy) +{ + m_ArrayLengthProxy = proxy; +} + +inline ArrayLengthRecvProxyFn RecvProp::GetArrayLengthProxy() const +{ + return m_ArrayLengthProxy; +} + +inline bool RecvProp::IsInsideArray() const +{ + return m_bInsideArray; +} + +inline void RecvProp::SetInsideArray() +{ + m_bInsideArray = true; +} + +inline const void* RecvProp::GetExtraData() const +{ + return m_pExtraData; +} + +inline void RecvProp::SetExtraData(const void* pData) +{ + m_pExtraData = pData; +} + +inline const char* RecvProp::GetParentArrayPropName() +{ + return m_pParentArrayPropName; +} + +inline void RecvProp::SetParentArrayPropName(const char* pArrayPropName) +{ + m_pParentArrayPropName = pArrayPropName; +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/dt_send.h b/SpyCustom/sdk/dt_send.h new file mode 100644 index 0000000..6bd148e --- /dev/null +++ b/SpyCustom/sdk/dt_send.h @@ -0,0 +1,686 @@ +#ifndef DATATABLE_SEND_H +#define DATATABLE_SEND_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "dt_common.h" +#include "dbg.h" +#include "const.h" +#include "bitvec.h" + + +typedef void (*SendVarProxyFn)(const SendProp* pProp, const void* pStructBase, const void* pData, DVariant* pOut, int iElement, int objectID); + +class CSendProxyRecipients; + +typedef void* (*SendTableProxyFn)( + const SendProp* pProp, + const void* pStructBase, + const void* pData, + CSendProxyRecipients* pRecipients, + int objectID); + + +class CNonModifiedPointerProxy +{ +public: + CNonModifiedPointerProxy(SendTableProxyFn fn); + +public: + + SendTableProxyFn m_Fn; + CNonModifiedPointerProxy* m_pNext; +}; + + +#define REGISTER_SEND_PROXY_NON_MODIFIED_POINTER( sendProxyFn ) static CNonModifiedPointerProxy __proxy_##sendProxyFn( sendProxyFn ); + + +class CStandardSendProxiesV1 +{ +public: + CStandardSendProxiesV1(); + + SendVarProxyFn m_Int8ToInt32; + SendVarProxyFn m_Int16ToInt32; + SendVarProxyFn m_Int32ToInt32; + + SendVarProxyFn m_UInt8ToInt32; + SendVarProxyFn m_UInt16ToInt32; + SendVarProxyFn m_UInt32ToInt32; + + SendVarProxyFn m_FloatToFloat; + SendVarProxyFn m_VectorToVector; + +#ifdef SUPPORTS_INT64 + SendVarProxyFn m_Int64ToInt64; + SendVarProxyFn m_UInt64ToInt64; +#endif +}; + +class CStandardSendProxies : public CStandardSendProxiesV1 +{ +public: + CStandardSendProxies(); + + SendTableProxyFn m_DataTableToDataTable; + SendTableProxyFn m_SendLocalDataTable; + CNonModifiedPointerProxy** m_ppNonModifiedPointerProxies; +}; + +extern CStandardSendProxies g_StandardSendProxies; + + +#define MAX_DATATABLE_PROXIES 32 + +class CSendProxyRecipients +{ +public: + void SetAllRecipients(); + void ClearAllRecipients(); + + void SetRecipient(int iClient); + void ClearRecipient(int iClient); + + void SetOnly(int iClient); + +public: + CBitVec< ABSOLUTE_PLAYER_LIMIT > m_Bits; +}; + +inline void CSendProxyRecipients::SetAllRecipients() +{ + m_Bits.SetAll(); +} + +inline void CSendProxyRecipients::ClearAllRecipients() +{ + m_Bits.ClearAll(); +} + +inline void CSendProxyRecipients::SetRecipient(int iClient) +{ + m_Bits.Set(iClient); +} + +inline void CSendProxyRecipients::ClearRecipient(int iClient) +{ + m_Bits.Clear(iClient); +} + +inline void CSendProxyRecipients::SetOnly(int iClient) +{ + m_Bits.ClearAll(); + m_Bits.Set(iClient); +} + + + +typedef int (*ArrayLengthSendProxyFn)(const void* pStruct, int objectID); + + + +class RecvProp; +class SendTable; +class CSendTablePrecalc; + + +#define DATATABLE_PROXY_INDEX_NOPROXY 255 +#define DATATABLE_PROXY_INDEX_INVALID 254 + +class SendProp +{ +public: + SendProp(); + virtual ~SendProp(); + + void Clear(); + + int GetOffset() const; + void SetOffset(int i); + + SendVarProxyFn GetProxyFn() const; + void SetProxyFn(SendVarProxyFn f); + + SendTableProxyFn GetDataTableProxyFn() const; + void SetDataTableProxyFn(SendTableProxyFn f); + + SendTable* GetDataTable() const; + void SetDataTable(SendTable* pTable); + + char const* GetExcludeDTName() const; + + const char* GetParentArrayPropName() const; + void SetParentArrayPropName(char* pArrayPropName); + + const char* GetName() const; + + bool IsSigned() const; + + bool IsExcludeProp() const; + + bool IsInsideArray() const; + void SetInsideArray(); + + void SetArrayProp(SendProp* pProp); + SendProp* GetArrayProp() const; + + void SetArrayLengthProxy(ArrayLengthSendProxyFn fn); + ArrayLengthSendProxyFn GetArrayLengthProxy() const; + + int GetNumElements() const; + void SetNumElements(int nElements); + + int GetNumArrayLengthBits() const; + + int GetElementStride() const; + + SendPropType GetType() const; + + int GetFlags() const; + void SetFlags(int flags); + + const void* GetExtraData() const; + void SetExtraData(const void* pData); + +public: + + RecvProp* m_pMatchingRecvProp; + SendPropType m_Type; + int m_nBits; + float m_fLowValue; + float m_fHighValue; + + SendProp* m_pArrayProp; + ArrayLengthSendProxyFn m_ArrayLengthProxy; + + int m_nElements; + int m_ElementStride; + + const char* m_pExcludeDTName; + const char* m_pParentArrayPropName; + + const char* m_pVarName; + float m_fHighLowMul; + +private: + + int m_Flags; + + SendVarProxyFn m_ProxyFn; + SendTableProxyFn m_DataTableProxyFn; + + SendTable* m_pDataTable; + + int m_Offset; + + const void* m_pExtraData; +}; + + +inline int SendProp::GetOffset() const +{ + return m_Offset; +} + +inline void SendProp::SetOffset(int i) +{ + m_Offset = i; +} + +inline SendVarProxyFn SendProp::GetProxyFn() const +{ + Assert(m_Type != DPT_DataTable); + return m_ProxyFn; +} + +inline void SendProp::SetProxyFn(SendVarProxyFn f) +{ + m_ProxyFn = f; +} + +inline SendTableProxyFn SendProp::GetDataTableProxyFn() const +{ + Assert(m_Type == DPT_DataTable); + return m_DataTableProxyFn; +} + +inline void SendProp::SetDataTableProxyFn(SendTableProxyFn f) +{ + m_DataTableProxyFn = f; +} + +inline SendTable* SendProp::GetDataTable() const +{ + return m_pDataTable; +} + +inline void SendProp::SetDataTable(SendTable* pTable) +{ + m_pDataTable = pTable; +} + +inline char const* SendProp::GetExcludeDTName() const +{ + return m_pExcludeDTName; +} + +inline const char* SendProp::GetParentArrayPropName() const +{ + return m_pParentArrayPropName; +} + +inline void SendProp::SetParentArrayPropName(char* pArrayPropName) +{ + Assert(!m_pParentArrayPropName); + m_pParentArrayPropName = pArrayPropName; +} + +inline const char* SendProp::GetName() const +{ + return m_pVarName; +} + + +inline bool SendProp::IsSigned() const +{ + return !(m_Flags & SPROP_UNSIGNED); +} + +inline bool SendProp::IsExcludeProp() const +{ + return (m_Flags & SPROP_EXCLUDE) != 0; +} + +inline bool SendProp::IsInsideArray() const +{ + return (m_Flags & SPROP_INSIDEARRAY) != 0; +} + +inline void SendProp::SetInsideArray() +{ + m_Flags |= SPROP_INSIDEARRAY; +} + +inline void SendProp::SetArrayProp(SendProp* pProp) +{ + m_pArrayProp = pProp; +} + +inline SendProp* SendProp::GetArrayProp() const +{ + return m_pArrayProp; +} + +inline void SendProp::SetArrayLengthProxy(ArrayLengthSendProxyFn fn) +{ + m_ArrayLengthProxy = fn; +} + +inline ArrayLengthSendProxyFn SendProp::GetArrayLengthProxy() const +{ + return m_ArrayLengthProxy; +} + +inline int SendProp::GetNumElements() const +{ + return m_nElements; +} + +inline void SendProp::SetNumElements(int nElements) +{ + m_nElements = nElements; +} + +inline int SendProp::GetElementStride() const +{ + return m_ElementStride; +} + +inline SendPropType SendProp::GetType() const +{ + return m_Type; +} + +inline int SendProp::GetFlags() const +{ + return m_Flags; +} + +inline void SendProp::SetFlags(int flags) +{ + Assert(!(flags & ~((1 << SPROP_NUMFLAGBITS) - 1))); + m_Flags = flags; +} + +inline const void* SendProp::GetExtraData() const +{ + return m_pExtraData; +} + +inline void SendProp::SetExtraData(const void* pData) +{ + m_pExtraData = pData; +} + + +class SendTable +{ +public: + + typedef SendProp PropType; + + SendTable(); + SendTable(SendProp* pProps, int nProps, const char* pNetTableName); + ~SendTable(); + + void Construct(SendProp* pProps, int nProps, const char* pNetTableName); + + const char* GetName() const; + + int GetNumProps() const; + SendProp* GetProp(int i); + + bool IsInitialized() const; + void SetInitialized(bool bInitialized); + + void SetWriteFlag(bool bHasBeenWritten); + bool GetWriteFlag() const; + + bool HasPropsEncodedAgainstTickCount() const; + void SetHasPropsEncodedAgainstTickcount(bool bState); + +public: + + SendProp* m_pProps; + int m_nProps; + + const char* m_pNetTableName; + + CSendTablePrecalc* m_pPrecalc; + + +protected: + bool m_bInitialized : 1; + bool m_bHasBeenWritten : 1; + bool m_bHasPropsEncodedAgainstCurrentTickCount : 1; +}; + + +inline const char* SendTable::GetName() const +{ + return m_pNetTableName; +} + + +inline int SendTable::GetNumProps() const +{ + return m_nProps; +} + + +inline SendProp* SendTable::GetProp(int i) +{ + Assert(i >= 0 && i < m_nProps); + return &m_pProps[i]; +} + + +inline bool SendTable::IsInitialized() const +{ + return m_bInitialized; +} + + +inline void SendTable::SetInitialized(bool bInitialized) +{ + m_bInitialized = bInitialized; +} + + +inline bool SendTable::GetWriteFlag() const +{ + return m_bHasBeenWritten; +} + + +inline void SendTable::SetWriteFlag(bool bHasBeenWritten) +{ + m_bHasBeenWritten = bHasBeenWritten; +} + +inline bool SendTable::HasPropsEncodedAgainstTickCount() const +{ + return m_bHasPropsEncodedAgainstCurrentTickCount; +} + +inline void SendTable::SetHasPropsEncodedAgainstTickcount(bool bState) +{ + m_bHasPropsEncodedAgainstCurrentTickCount = bState; +} + +#define BEGIN_SEND_TABLE(className, tableName) \ + BEGIN_SEND_TABLE_NOBASE(className, tableName) \ + SendPropDataTable("baseclass", 0, className::BaseClass::m_pClassSendTable, SendProxy_DataTableToDataTable), + +#define BEGIN_SEND_TABLE_NOBASE(className, tableName) \ + template int ServerClassInit(T *); \ + namespace tableName { \ + struct ignored; \ + } \ + template <> int ServerClassInit(tableName::ignored *); \ + namespace tableName { \ + SendTable g_SendTable;\ + int g_SendTableInit = ServerClassInit((tableName::ignored *)NULL); \ + } \ + template <> int ServerClassInit(tableName::ignored *) \ + { \ + typedef className currentSendDTClass; \ + static const char *g_pSendTableName = #tableName; \ + SendTable &sendTable = tableName::g_SendTable; \ + static SendProp g_SendProps[] = { \ + SendPropInt("should_never_see_this", 0, sizeof(int)), + +#define END_SEND_TABLE() \ + };\ + sendTable.Construct(g_SendProps+1, sizeof(g_SendProps) / sizeof(SendProp) - 1, g_pSendTableName);\ + return 1; \ + } + + +#define SENDINFO(varName) #varName, offsetof(currentSendDTClass::MakeANetworkVar_##varName, varName), sizeof(((currentSendDTClass*)0)->varName) +#define SENDINFO_ARRAY(varName) #varName, offsetof(currentSendDTClass::MakeANetworkVar_##varName, varName), sizeof(((currentSendDTClass*)0)->varName[0]) +#define SENDINFO_ARRAY3(varName) #varName, offsetof(currentSendDTClass::MakeANetworkVar_##varName, varName), sizeof(((currentSendDTClass*)0)->varName[0]), sizeof(((currentSendDTClass*)0)->varName)/sizeof(((currentSendDTClass*)0)->varName[0]) +#define SENDINFO_ARRAYELEM(varName, i) #varName "[" #i "]", offsetof(currentSendDTClass::MakeANetworkVar_##varName, varName[i]), sizeof(((currentSendDTClass*)0)->varName[0]) +#define SENDINFO_NETWORKARRAYELEM(varName, i)#varName "[" #i "]", offsetof(currentSendDTClass::MakeANetworkVar_##varName, varName.m_Value[i]), sizeof(((currentSendDTClass*)0)->varName.m_Value[0]) + +#define SENDINFO_VECTORELEM(varName, i) #varName "[" #i "]", -(int)offsetof(currentSendDTClass::MakeANetworkVar_##varName, varName.m_Value[i]), sizeof(((currentSendDTClass*)0)->varName.m_Value[0]) + +#define SENDINFO_STRUCTELEM(varName) #varName, offsetof(currentSendDTClass, varName), sizeof(((currentSendDTClass*)0)->varName.m_Value) +#define SENDINFO_STRUCTARRAYELEM(varName, i)#varName "[" #i "]", offsetof(currentSendDTClass, varName.m_Value[i]), sizeof(((currentSendDTClass*)0)->varName.m_Value[0]) + +#define SENDINFO_NOCHECK(varName) #varName, offsetof(currentSendDTClass, varName), sizeof(((currentSendDTClass*)0)->varName) +#define SENDINFO_STRING_NOCHECK(varName) #varName, offsetof(currentSendDTClass, varName) +#define SENDINFO_DT(varName) #varName, offsetof(currentSendDTClass, varName) +#define SENDINFO_DT_NAME(varName, remoteVarName) #remoteVarName, offsetof(currentSendDTClass, varName) +#define SENDINFO_NAME(varName,remoteVarName) #remoteVarName, offsetof(currentSendDTClass, varName), sizeof(((currentSendDTClass*)0)->varName) + + + + +void SendProxy_QAngles(const SendProp* pProp, const void* pStruct, const void* pData, DVariant* pOut, int iElement, int objectID); +void SendProxy_AngleToFloat(const SendProp* pProp, const void* pStruct, const void* pData, DVariant* pOut, int iElement, int objectID); +void SendProxy_FloatToFloat(const SendProp* pProp, const void* pStruct, const void* pData, DVariant* pOut, int iElement, int objectID); +void SendProxy_VectorToVector(const SendProp* pProp, const void* pStruct, const void* pData, DVariant* pOut, int iElement, int objectID); +void SendProxy_VectorXYToVectorXY(const SendProp* pProp, const void* pStruct, const void* pData, DVariant* pOut, int iElement, int objectID); +#if 0 +void SendProxy_QuaternionToQuaternion(const SendProp* pProp, const void* pStruct, const void* pData, DVariant* pOut, int iElement, int objectID); +#endif + +void SendProxy_Int8ToInt32(const SendProp* pProp, const void* pStruct, const void* pData, DVariant* pOut, int iElement, int objectID); +void SendProxy_Int16ToInt32(const SendProp* pProp, const void* pStruct, const void* pData, DVariant* pOut, int iElement, int objectID); +void SendProxy_Int32ToInt32(const SendProp* pProp, const void* pStruct, const void* pData, DVariant* pOut, int iElement, int objectID); +#ifdef SUPPORTS_INT64 +void SendProxy_Int64ToInt64(const SendProp* pProp, const void* pStruct, const void* pData, DVariant* pOut, int iElement, int objectID); +#endif +void SendProxy_StringToString(const SendProp* pProp, const void* pStruct, const void* pData, DVariant* pOut, int iElement, int objectID); + +void* SendProxy_DataTableToDataTable(const SendProp* pProp, const void* pStructBase, const void* pData, CSendProxyRecipients* pRecipients, int objectID); + +void* SendProxy_DataTablePtrToDataTable(const SendProp* pProp, const void* pStructBase, const void* pData, CSendProxyRecipients* pRecipients, int objectID); + +void* SendProxy_SendLocalDataTable(const SendProp* pProp, const void* pStruct, const void* pVarData, CSendProxyRecipients* pRecipients, int objectID); + + +SendProp SendPropFloat( + const char* pVarName, + int offset, + int sizeofVar = SIZEOF_IGNORE, + int nBits = 32, + int flags = 0, + float fLowValue = 0.0f, + float fHighValue = HIGH_DEFAULT, + SendVarProxyFn varProxy = SendProxy_FloatToFloat +); + +SendProp SendPropVector( + const char* pVarName, + int offset, + int sizeofVar = SIZEOF_IGNORE, + int nBits = 32, + int flags = SPROP_NOSCALE, + float fLowValue = 0.0f, + float fHighValue = HIGH_DEFAULT, + SendVarProxyFn varProxy = SendProxy_VectorToVector +); + +SendProp SendPropVectorXY( + const char* pVarName, + int offset, + int sizeofVar = SIZEOF_IGNORE, + int nBits = 32, + int flags = SPROP_NOSCALE, + float fLowValue = 0.0f, + float fHighValue = HIGH_DEFAULT, + SendVarProxyFn varProxy = SendProxy_VectorXYToVectorXY +); + +#if 0 +SendProp SendPropQuaternion( + const char* pVarName, + int offset, + int sizeofVar = SIZEOF_IGNORE, + int nBits = 32, + int flags = SPROP_NOSCALE, + float fLowValue = 0.0f, + float fHighValue = HIGH_DEFAULT, + SendVarProxyFn varProxy = SendProxy_QuaternionToQuaternion +); +#endif + +SendProp SendPropAngle( + const char* pVarName, + int offset, + int sizeofVar = SIZEOF_IGNORE, + int nBits = 32, + int flags = 0, + SendVarProxyFn varProxy = SendProxy_AngleToFloat +); + +SendProp SendPropQAngles( + const char* pVarName, + int offset, + int sizeofVar = SIZEOF_IGNORE, + int nBits = 32, + int flags = 0, + SendVarProxyFn varProxy = SendProxy_QAngles +); + +SendProp SendPropInt( + const char* pVarName, + int offset, + int sizeofVar = SIZEOF_IGNORE, + int nBits = -1, + int flags = 0, + SendVarProxyFn varProxy = 0 +); + +inline SendProp SendPropModelIndex(const char* pVarName, int offset, int sizeofVar = SIZEOF_IGNORE) +{ + return SendPropInt(pVarName, offset, sizeofVar, SP_MODEL_INDEX_BITS, 0); +} + +SendProp SendPropString( + const char* pVarName, + int offset, + int bufferLen, + int flags = 0, + SendVarProxyFn varProxy = SendProxy_StringToString); + +SendProp SendPropDataTable( + const char* pVarName, + int offset, + SendTable* pTable, + SendTableProxyFn varProxy = SendProxy_DataTableToDataTable +); + +SendProp SendPropArray3( + const char* pVarName, + int offset, + int sizeofVar, + int elements, + SendProp pArrayProp, + SendTableProxyFn varProxy = SendProxy_DataTableToDataTable +); + + + +SendProp InternalSendPropArray( + const int elementCount, + const int elementStride, + const char* pName, + ArrayLengthSendProxyFn proxy +); + + +#define SendPropArray( varTemplate, arrayName ) \ + SendPropVariableLengthArray( \ + 0, \ + varTemplate, \ + arrayName ) + +#define SendPropVirtualArray( arrayLengthSendProxy, maxArrayLength, varTemplate, propertyName ) \ + varTemplate, \ + InternalSendPropArray( \ + maxArrayLength, \ + 0, \ + #propertyName, \ + arrayLengthSendProxy \ + ) + + +#define SendPropVariableLengthArray( arrayLengthSendProxy, varTemplate, arrayName ) \ + varTemplate, \ + InternalSendPropArray( \ + sizeof(((currentSendDTClass*)0)->arrayName) / PROPSIZEOF(currentSendDTClass, arrayName[0]), \ + PROPSIZEOF(currentSendDTClass, arrayName[0]), \ + #arrayName, \ + arrayLengthSendProxy \ + ) + +#define SendPropArray2( arrayLengthSendProxy, varTemplate, elementCount, elementStride, arrayName ) \ + varTemplate, \ + InternalSendPropArray( elementCount, elementStride, #arrayName, arrayLengthSendProxy ) + + + + +SendProp SendPropExclude( + const char* pDataTableName, + const char* pPropName +); + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/econ_item_constants.h b/SpyCustom/sdk/econ_item_constants.h new file mode 100644 index 0000000..030c897 --- /dev/null +++ b/SpyCustom/sdk/econ_item_constants.h @@ -0,0 +1,550 @@ +#ifndef ACTUAL_ECON_ITEM_CONSTANTS_H +#define ACTUAL_ECON_ITEM_CONSTANTS_H +#ifdef _WIN32 +#pragma once +#endif + +typedef uint32 item_price_t; +typedef uint8 item_transaction_quantity_t; + +class CLocalizationProvider; + +#define TESTITEM_DEFINITIONS_BEGIN_AT 32000 +#define TESTITEM_DEFINITIONS_COUNT 16 + +enum EEconTypeID +{ + k_EEconTypeItem = 1, + k_EEconTypePersonaDataPublic = 2, + k_EEconTypeGameAccountClient = 7, + k_EEconTypeGameAccount = 8, + k_EEconTypeEquipInstance = 31, + k_EEconTypeDefaultEquippedDefinitionInstance = 42, + k_EEconTypeDefaultEquippedDefinitionInstanceClient = 43, + k_EEconTypeCoupon = 45, + k_EEconTypeQuest = 46, +}; + +enum EItemAction +{ + k_EItemActionInvalid = -1, + k_EItemActionGSCreate = 0, + k_EItemActionUnpurchase = 1, + k_EItemActionDelete = 2, + k_EItemActionAwardAchievement = 3, + k_EItemActionBanned = 4, + k_EItemActionQuantityChanged = 5, + k_EItemActionRestored = 6, + k_EItemActionAwardTime = 7, + k_EItemActionManualCreate = 8, + k_EItemActionDrop = 9, + k_EItemActionPickUp = 10, + k_EItemActionCraftDestroy = 11, + k_EItemActionCraftCreate = 12, + k_EItemActionLimitExceeded = 13, + k_EItemActionPurchase = 14, + k_EItemActionNameChanged_Add = 15, + k_EItemActionUnlockCrate_Add = 16, + k_EItemActionPaintItem_Add = 17, + k_EItemActionAutoGrantItem = 18, + k_EItemActionCrossGameAchievement = 19, + k_EItemActionAddItemToSocket_Add = 20, + k_EItemActionAddSocketToItem_Add = 21, + k_EItemActionRemoveSocketItem_Add = 22, + k_EItemActionCustomizeItemTexture_Add = 23, + k_EItemActionItemTraded_Add = 24, + k_EItemActionUseItem = 25, + k_EItemActionAwardGift_Receiver = 26, + k_EItemActionNameChanged_Remove = 27, + k_EItemActionUnlockCrate_Remove = 28, + k_EItemActionPaintItem_Remove = 29, + k_EItemActionAddItemToSocket_Remove = 30, + k_EItemActionAddSocketToItem_Remove = 31, + k_EItemActionRemoveSocketItem_Remove = 32, + k_EItemActionCustomizeItemTexture_Remove = 33, + k_EItemActionItemTraded_Remove = 34, + k_EItemActionUnpackItemBundle = 35, + k_EItemActionCreateItemFromBundle = 36, + k_EItemActionAwardStorePromotionItem = 37, + k_EItemActionConvertItem = 38, + k_EItemActionEarnedItem = 39, + k_EItemActionAwardGift_Giver = 40, + k_EItemActionRefundedItem = 41, + k_EItemActionAwardThirdPartyPromo = 42, + k_EItemActionRemoveItemName_Remove = 43, + k_EItemActionRemoveItemName_Add = 44, + k_EItemActionRemoveItemPaint_Remove = 45, + k_EItemActionRemoveItemPaint_Add = 46, + k_EItemActionHalloweenDrop = 47, + k_EItemActionSteamWorkshopContributor = 48, + + k_EItemActionSupportDelete = 50, + k_EItemActionSupportCreatedByUndo = 51, + k_EItemActionSupportDeletedByUndo = 52, + k_EItemActionSupportQuantityChangedByUndo = 53, + k_EItemActionSupportRename_Add = 54, + k_EItemActionSupportRename_Remove = 55, + k_EItemActionSupportDescribe_Add = 56, + k_EItemActionSupportDescribe_Remove = 57, + + k_EItemActionPeriodicScoreReward_Add = 58, + k_EItemActionPeriodicScoreReward_Remove = 59, + k_EItemActionStrangePartApply_Add = 60, + k_EItemActionStrangePartApply_Remove = 61, + + k_EItemActionPennantUpgradeApply_Add = 62, + k_EItemActionPennantUpgradeApply_Remove = 63, + + k_EItemActionPaintKitItem_Add = 64, + k_EItemActionPaintKitItem_Remove = 65, + + k_EItemActionUpgradeChallengeCoin_Add = 66, + k_EItemActionUpgradeChallengeCoin_Remove = 67, + + k_EItemActionStickerApply_Add = 68, + k_EItemActionStickerApply_Remove = 69, + k_EItemActionStickerRemove_Add = 70, + k_EItemActionStickerRemove_Remove = 71, + + k_EItemActionGrantQuestReward_Add = 72, + k_EItemActionGrantQuestReward_Remove = 73, + k_EItemActionApplyQuestProgress_Add = 74, + k_EItemActionApplyQuestProgress_Remove = 75, + + k_EItemActionPurchaseUnlockCrate_Add = 76, + k_EItemActionPurchaseUnlockCrate_Remove = 77, + + k_EItemActionSwapStatTrak_Add = 78, + k_EItemActionSwapStatTrak_Remove = 79, + + k_EItemActionPurchaseConsumedAsNonItem = 80, + + k_EItemActionDev_ClientLootListRoll = 90, + + k_EItemActionGiftWrap_Add = 100, + k_EItemActionGiftWrap_Remove = 101, + k_EItemActionGiftDelivery_Add = 102, + k_EItemActionGiftDelivery_Remove = 103, + k_EItemActionGiftUnwrap_Add = 104, + k_EItemActionGiftUnwrap_Remove = 105, + k_EItemActionPackageItem = 106, + k_EItemActionPackageItem_Revoked = 107, + k_EItemActionHandleMapToken = 108, + k_EItemActionCafeOrSchoolItem_Remove = 109, + k_EItemActionVACBanned_Remove = 110, + k_EItemActionUpgradeThirdPartyPromo = 111, + k_EItemActionExpired = 112, + k_EItemActionTradeRollback_Add = 113, + k_EItemActionTradeRollback_Remove = 114, + k_EItemActionCDKeyGrant = 115, + k_EItemActionCDKeyRevoke = 116, + k_EItemActionWeddingRing_Add = 117, + k_EItemActionWeddingRing_Remove = 118, + k_EItemActionWeddingRing_AddPartner = 119, + k_EItemActionEconSetUnowned = 120, + k_EItemActionEconSetOwned = 121, + + k_EItemActionRemoveItemCraftIndex_Remove = 150, + k_EItemActionRemoveItemCraftIndex_Add = 151, + k_EItemActionRemoveItemMakersMark_Remove = 152, + k_EItemActionRemoveItemMakersMark_Add = 153, + + k_EItemActionCollectItem_CollectedItem = 154, + k_EItemActionCollectItem_UpdateCollection = 155, + k_EItemActionCollectItem_RemoveCollection = 156, + k_EItemActionCollectItem_RedeemCollectionReward = 157, + + k_EItemActionPreviewItem_BeginPreviewPeriod = 158, + k_EItemActionPreviewItem_EndPreviewPeriodExpired = 159, + k_EItemActionPreviewItem_EndPreviewPeriodItemBought = 160, + + k_EItemActionRecycling = 161, + k_EItemActionAwardXP = 162, + k_EItemActionTournamentDrop = 163, + k_EItemDiretideReward = 164, + + + k_EItemDiretideEggAddOnModify = 165, + k_EItemDiretideEssenceRemove = 166, + k_EItemDiretideEggRemoveOnModify = 167, + + k_EItemActionUnpackItems = 168, + + k_EItemActionUnlockStyle = 169, + k_EItemActionUnlockStyle_Remove = 170, + + k_EItemActionTutorialDrop = 171, + + k_EItemActionAutographAdd = 172, + k_EItemActionAutographRemove = 173, + + k_EItemActionApplyIntermediateStickerWear = 174, + k_EItemActionTemplateItemGrant = 175, + + k_EItemActionCoinCampaignProgress = 176, + + k_EItemActionMarket_Add = 177, + k_EItemActionMarket_Remove = 178, +}; +extern const char* PchNameFromEItemAction(EItemAction eAction); +extern const char* PchNameFromEItemActionUnsafe(EItemAction eAction); + +extern bool BIsActionCreative(EItemAction); +extern bool BIsActionDestructive(EItemAction); + +enum EItemActionMissingBehavior { kEItemAction_FriendlyNameLookup_ReturnNULLIfMissing, kEItemAction_FriendlyNameLookup_ReturnDummyStringIfMissing }; +extern const char* PchFriendlyNameFromEItemAction(EItemAction eAction, EItemActionMissingBehavior eMissingBehavior); +extern const char* PchLocalizedNameFromEItemAction(EItemAction eAction, CLocalizationProvider& localizationProvider); + + +enum EEconOwnershipAction +{ + k_EEconOwnershipAction_Invalid = 0, + + k_EEconOwnershipAction_TradeBase = 100, + k_EEconOwnershipAction_TradeCommit = 101, + k_EEconOwnershipAction_TradeRollback = 102, +}; + +enum eEconItemFlags_Deprecated +{ + kDeprecated_EconItemFlag_AchievementGrantedItem = 1 << 0, + kDeprecated_EconItemFlag_CannotTrade = 1 << 1, + kDeprecated_EconItemFlag_Purchased = 1 << 2, + kDeprecated_EconItemFlag_CannotBeUsedInCrafting = 1 << 3, + kDeprecated_EconItemFlag_Promotion = 1 << 4, +}; + +enum eEconItemFlags +{ + kEconItemFlag_CannotTrade = 1 << 0, + kEconItemFlag_CannotBeUsedInCrafting = 1 << 1, + kEconItemFlag_CanBeTradedByFreeAccounts = 1 << 2, + kEconItemFlag_NonEconomy = 1 << 3, + +#ifdef CLIENT_DLL +#ifdef TF_CLIENT_DLL + kEconItemFlagClient_ForceBlueTeam = 1 << 5, +#endif + kEconItemFlagClient_StoreItem = 1 << 6, + kEconItemFlagClient_Preview = 1 << 7, +#endif + + kEconItemFlags_CheckFlags_CannotTrade = kEconItemFlag_CannotTrade, + kEconItemFlags_CheckFlags_NotUsableInCrafting = kEconItemFlag_CannotBeUsedInCrafting, + + kEconItemFlags_CheckFlags_AllGCFlags = kEconItemFlags_CheckFlags_CannotTrade | kEconItemFlags_CheckFlags_NotUsableInCrafting, +}; + +enum eEconItemOrigin +{ + kEconItemOrigin_Invalid = -1, + + kEconItemOrigin_Drop = 0, + kEconItemOrigin_Achievement, + kEconItemOrigin_Purchased, + kEconItemOrigin_Traded, + kEconItemOrigin_Crafted, + kEconItemOrigin_StorePromotion, + kEconItemOrigin_Gifted, + kEconItemOrigin_SupportGranted, + kEconItemOrigin_FoundInCrate, + kEconItemOrigin_Earned, + kEconItemOrigin_ThirdPartyPromotion, + kEconItemOrigin_GiftWrapped, + kEconItemOrigin_HalloweenDrop, + kEconItemOrigin_PackageItem, + kEconItemOrigin_Foreign, + kEconItemOrigin_CDKey, + kEconItemOrigin_CollectionReward, + kEconItemOrigin_PreviewItem, + kEconItemOrigin_SteamWorkshopContribution, + kEconItemOrigin_PeriodicScoreReward, + kEconItemOrigin_Recycling, + kEconItemOrigin_TournamentDrop, + kEconItemOrigin_StockItem, + KEconItemOrigin_QuestReward, + KEconItemOrigin_LevelUpReward, + + kEconItemOrigin_Max, +}; +extern const char* PchNameFromeEconItemOrigin(eEconItemOrigin eOrigin); + +typedef uint64 itemid_t; +typedef uint16 item_definition_index_t; +typedef uint16 attrib_definition_index_t; +typedef uint32 attrib_value_t; + +typedef uint32 equip_region_mask_t; +typedef uint8 style_index_t; + +const uint64 INVALID_ITEM_ID = (itemid_t)-1; +const item_definition_index_t INVALID_ITEM_DEF_INDEX = ((item_definition_index_t)-1); +const attrib_definition_index_t INVALID_ATTRIB_DEF_INDEX = ((attrib_definition_index_t)-1); + +#define DEFAULT_NUM_BACKPACK_SLOTS_PER_PAGE 100 +#define DEFAULT_NUM_BACKPACK_SLOTS 1000 +#define DEFAULT_NUM_BACKPACK_SLOTS_FREE_TRIAL_ACCOUNT 100 +#define MAX_NUM_BACKPACK_SLOTS 2000 + +#define MIN_ITEM_LEVEL 0 +#define MAX_ITEM_LEVEL 100 + +#define MAX_ATTRIBUTES_PER_ITEM 32 +#define MAX_ATTRIBUTE_DESCRIPTION_LENGTH ( 256 / sizeof( locchar_t ) ) + +#define MAX_ITEM_NAME_LENGTH 128 +#define MAX_ITEM_DESC_LENGTH 256 +#define MAX_ITEM_LONG_DESC_LENGTH 2048 +#define MAX_ITEM_CUSTOM_NAME_LENGTH 40 +#define MAX_ITEM_CUSTOM_NAME_DATABASE_SIZE ((4 * MAX_ITEM_CUSTOM_NAME_LENGTH) + 1) +#define MAX_ITEM_CUSTOM_DESC_LENGTH 80 +#define MAX_ITEM_CUSTOM_DESC_DATABASE_SIZE ((4 * MAX_ITEM_CUSTOM_DESC_LENGTH) + 1) + +#define MAX_CLAIM_CODE_LENGTH 128 + +#define MAX_ITEMS_BEFORE_YIELD 50 + +#define RGB_INT_RED 12073019 +#define RGB_INT_BLUE 5801378 + +const int k_nCustomImageSize = 256; +const int k_nMaxCustomImageFileSize = k_nCustomImageSize * k_nCustomImageSize * 4 + 4 * 1024; + +typedef int32 entityquality_t; +enum EEconItemQuality +{ + AE_UNDEFINED = -1, + + AE_NORMAL = 0, + AE_GENUINE = 1, + AE_VINTAGE, + AE_UNUSUAL, + AE_UNIQUE, + AE_COMMUNITY, + AE_DEVELOPER, + AE_SELFMADE, + AE_CUSTOMIZED, + AE_STRANGE, + AE_COMPLETED, + AE_HAUNTED, + AE_TOURNAMENT, + AE_FAVORED, + + AE_MAX_TYPES, +}; + + +enum attrib_colors_t +{ + ATTRIB_COL_LEVEL = 0, + ATTRIB_COL_NEUTRAL, + ATTRIB_COL_POSITIVE, + ATTRIB_COL_NEGATIVE, + ATTRIB_COL_ITEMSET_NAME, + ATTRIB_COL_ITEMSET_EQUIPPED, + ATTRIB_COL_ITEMSET_MISSING, + ATTRIB_COL_BUNDLE_ITEM, + ATTRIB_COL_LIMITED_USE, + ATTRIB_COL_ITEM_FLAGS, + ATTRIB_COL_RARITY_DEFAULT, + ATTRIB_COL_RARITY_COMMON, + ATTRIB_COL_RARITY_UNCOMMON, + ATTRIB_COL_RARITY_RARE, + ATTRIB_COL_RARITY_MYTHICAL, + ATTRIB_COL_RARITY_LEGENDARY, + ATTRIB_COL_RARITY_ANCIENT, + ATTRIB_COL_RARITY_IMMORTAL, + ATTRIB_COL_RARITY_ARCANA, + ATTRIB_COL_STRANGE, + ATTRIB_COL_UNUSUAL, + + NUM_ATTRIB_COLORS, +}; + + +#define AE_USE_SCRIPT_VALUE 9999 + +const char* EconQuality_GetQualityString(EEconItemQuality eQuality); +const char* EconQuality_GetColorString(EEconItemQuality eQuality); +const char* EconQuality_GetLocalizationString(EEconItemQuality eQuality); + +int EconQuality_GetRarityScore(EEconItemQuality eQuality); + +int EconRarity_CombinedItemAndPaintRarity(int nItemDefRarity, int nPaintRarity); + +int EconWear_ToIntCategory(float flWear); +float EconWear_FromIntCategory(int nWearCategory); + +int EconMinutes_ToRoundMinHrsCategory(float flMinutes); +float EconMinutes_FromRoundMinHrsCategory(int nRoundMinHrsCategory); + +int EconTintID_ToRoundCategory(uint32 unTintID); +uint32 EconTintID_FromRoundCategory(int nRoundCategory); + +extern attrib_colors_t GetAttribColorIndexForName(const char* pszName); + +extern const char* GetColorNameForAttribColor(attrib_colors_t unAttribColor); +extern const char* GetHexColorForAttribColor(attrib_colors_t unAttribColor); + +entityquality_t GetItemQualityFromString(const char* sQuality); + +enum recipecategories_t +{ + RECIPE_CATEGORY_CRAFTINGITEMS = 0, + RECIPE_CATEGORY_COMMONITEMS, + RECIPE_CATEGORY_RAREITEMS, + RECIPE_CATEGORY_SPECIAL, + + NUM_RECIPE_CATEGORIES +}; +extern const char* g_szRecipeCategoryStrings[NUM_RECIPE_CATEGORIES]; + +enum kill_eater_event_t +{ + kKillEaterEvent_PlayerKill = 0, + kKillEaterEvent_MVPs, + + +}; + +bool EventRequiresVictim(kill_eater_event_t ke_event); + +#define KILL_EATER_RANK_LEVEL_BLOCK_NAME "KillEaterRank" + +int GetKillEaterAttrPairCount(); +const class CEconItemAttributeDefinition* GetKillEaterAttrPair_Score(int i); +const class CEconItemAttributeDefinition* GetKillEaterAttrPair_Type(int i); +bool GetKillEaterAttrPair_IsUserCustomizable(int i); + + +enum unacknowledged_item_inventory_positions_t +{ + UNACK_ITEM_DROPPED = 1, + UNACK_ITEM_CRAFTED, + UNACK_ITEM_TRADED, + UNACK_ITEM_PURCHASED, + UNACK_ITEM_FOUND_IN_CRATE, + UNACK_ITEM_GIFTED, + UNACK_ITEM_SUPPORT, + UNACK_ITEM_PROMOTION, + UNACK_ITEM_EARNED, + UNACK_ITEM_REFUNDED, + UNACK_ITEM_GIFT_WRAPPED, + UNACK_ITEM_FOREIGN, + UNACK_ITEM_COLLECTION_REWARD, + UNACK_ITEM_PREVIEW_ITEM, + UNACK_ITEM_PREVIEW_ITEM_PURCHASED, + UNACK_ITEM_PERIODIC_SCORE_REWARD, + UNACK_ITEM_RECYCLING, + UNACK_ITEM_TOURNAMENT_DROP, + UNACK_ITEM_QUEST_REWARD, + UNACK_ITEM_LEVEL_UP_REWARD, +#ifdef ENABLE_STORE_RENTAL_BACKEND + UNACK_ITEM_RENTAL_PURCHASE, +#endif + + UNACK_NUM_METHODS, +}; + +extern const char* g_pszItemPickupMethodStrings[UNACK_NUM_METHODS]; +extern const char* g_pszItemPickupMethodStringsUnloc[UNACK_NUM_METHODS]; +extern const char* g_pszItemFoundMethodStrings[UNACK_NUM_METHODS]; + +enum +{ + kGCItemSort_NoSort = 0, + + kGCItemSort_SortByName = 1, + kGCItemSort_SortByDefIndex = 2, + kGCItemSort_SortByRarity = 3, + kGCItemSort_SortByType = 4, + kGCItemSort_SortByQuality = 5, + + kGCItemSort_GameSpecificBase = 100, +}; + +enum +{ + kTFGCItemSort_SortByClass = kGCItemSort_GameSpecificBase + 1, + kTFGCItemSort_SortBySlot = kGCItemSort_GameSpecificBase + 2, + kDOTAGCItemSort_SortByHero = kGCItemSort_GameSpecificBase + 3, +}; + +enum +{ + kBackendPosition_Unacked = 1 << 30, + kBackendPosition_Reserved = 1 << 31, + + kBackendPositionMask_Position = 0x0000ffff, + kBackendPositionMask_FormatFlags = (kBackendPosition_Unacked | kBackendPosition_Reserved), +}; + +inline void SetBackpackPosition(uint32* pPosition, uint32 iPackPosition) +{ + (*pPosition) = iPackPosition; + + (*pPosition) &= ~kBackendPosition_Unacked; +} + +inline bool IsUnacknowledged(uint32 iBackendPosition) +{ + return (iBackendPosition == 0 || (iBackendPosition & kBackendPosition_Unacked) != 0); +} + +inline int ExtractBackpackPositionFromBackend(uint32 iBackendPosition) +{ + if (IsUnacknowledged(iBackendPosition)) + return 0; + + return iBackendPosition & kBackendPositionMask_Position; +} + +inline unacknowledged_item_inventory_positions_t GetUnacknowledgedReason(uint32 iBackendPosition) +{ + return (unacknowledged_item_inventory_positions_t)(iBackendPosition &= ~kBackendPositionMask_FormatFlags); +} + +inline uint32 GetUnacknowledgedPositionFor(unacknowledged_item_inventory_positions_t iMethod) +{ + return (iMethod | kBackendPosition_Unacked | kBackendPosition_Reserved); +} + +enum EEconItemPreviewEventIDs +{ + k_EEconItemPreview_Start = 1, + k_EEconItemPreview_Expired = 2, + k_EEconItemPreview_ItemPurchased = 3, +}; + +enum EHoliday +{ + kHoliday_None = 0, + kHoliday_Halloween, + kHoliday_Christmas, + kHoliday_FullMoon, + kHoliday_HalloweenOrFullMoon, + kHoliday_Easter, + + kHolidayCount, +}; + +enum ECartItemType +{ + kCartItem_Purchase, + kCartItem_TryOutUpgrade, + kCartItem_Rental_1Day, + kCartItem_Rental_3Day, + kCartItem_Rental_7Day, +}; + +void GetHexStringFromPaintColor(float flPaint, char* pszRGB); +inline bool IsRentalCartItemType(ECartItemType eCartType) +{ + return eCartType == kCartItem_Rental_1Day + || eCartType == kCartItem_Rental_3Day + || eCartType == kCartItem_Rental_7Day; +} + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/econ_item_interface.h b/SpyCustom/sdk/econ_item_interface.h new file mode 100644 index 0000000..98143ec --- /dev/null +++ b/SpyCustom/sdk/econ_item_interface.h @@ -0,0 +1,287 @@ +#ifndef ECONITEMINTERFACE_H +#define ECONITEMINTERFACE_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "game_item_schema.h" + +class CAttribute_String; + +template < typename T > +struct StripConstIfPresent { typedef T ResultType; }; + +template < typename T > struct StripConstIfPresent { typedef T ResultType; }; + +template < typename T, typename U > +struct AreTypesIdentical { enum { kValue = false }; }; + +template < typename T > struct AreTypesIdentical { enum { kValue = true }; }; + +template < typename T> +struct IsValidAttributeValueTypeImpl { enum { kValue = false }; }; + +template < > struct IsValidAttributeValueTypeImpl { enum { kValue = true }; }; +template < > struct IsValidAttributeValueTypeImpl { enum { kValue = true }; }; +template < > struct IsValidAttributeValueTypeImpl { enum { kValue = true }; }; +template < > struct IsValidAttributeValueTypeImpl { enum { kValue = true }; }; + +template < typename T > +struct IsValidAttributeValueType : public IsValidAttributeValueTypeImpl< typename StripConstIfPresent::ResultType > { }; + +class IEconItemAttributeIterator +{ +public: + virtual ~IEconItemAttributeIterator() { } + + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, attrib_value_t value) = 0; + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, float value) = 0; + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, const CAttribute_String& value) = 0; + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, const Vector& value) = 0; +}; + +class CEconItemSpecificAttributeIterator : public IEconItemAttributeIterator +{ + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, attrib_value_t value) { return true; } + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, const CAttribute_String& value) { return true; } + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, const Vector& value) { return true; } +}; + + +class IEconItemUntypedAttributeIterator : public IEconItemAttributeIterator +{ +public: + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, attrib_value_t) OVERRIDE + { + return OnIterateAttributeValueUntyped(pAttrDef); + } + + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, float) OVERRIDE + { + return OnIterateAttributeValueUntyped(pAttrDef); + } + + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, const CAttribute_String&) OVERRIDE + { + return OnIterateAttributeValueUntyped(pAttrDef); + } + + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, const Vector&) OVERRIDE + { + return OnIterateAttributeValueUntyped(pAttrDef); + } + +private: + virtual bool OnIterateAttributeValueUntyped(const CEconItemAttributeDefinition* pAttrDef) = 0; +}; + +class CAttributeIterator_HasAttribute : public IEconItemUntypedAttributeIterator +{ +public: + CAttributeIterator_HasAttribute(const CEconItemAttributeDefinition* pAttrDef) + : m_pAttrDef(pAttrDef) + , m_bFound(false) + { + Assert(m_pAttrDef); + } + + bool WasFound() const + { + return m_bFound; + } + +private: + bool OnIterateAttributeValueUntyped(const CEconItemAttributeDefinition* pAttrDef) OVERRIDE + { + if (m_pAttrDef == pAttrDef) + { + m_bFound = true; + } + + return !m_bFound; + } + +private: + const CEconItemAttributeDefinition* m_pAttrDef; + bool m_bFound; +}; + +template < typename TActualTypeInMemory, typename TTreatAsThisType = TActualTypeInMemory > +class CAttributeIterator_GetTypedAttributeValue : public IEconItemAttributeIterator +{ +public: + CAttributeIterator_GetTypedAttributeValue(const CEconItemAttributeDefinition* pAttrDef, TTreatAsThisType* outpValue) + : m_pAttrDef(pAttrDef) + , m_outpValue(outpValue) + , m_bFound(false) + { + COMPILE_TIME_ASSERT(IsValidAttributeValueType::kValue); + + COMPILE_TIME_ASSERT(((AreTypesIdentical::kValue && AreTypesIdentical::kValue) || + (AreTypesIdentical::kValue && AreTypesIdentical::kValue) || + AreTypesIdentical::kValue)); + + Assert(m_pAttrDef); + Assert(outpValue); + } + + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, attrib_value_t value) OVERRIDE + { + return OnIterateAttributeValueTyped(pAttrDef, value); + } + + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, float value) OVERRIDE + { + return OnIterateAttributeValueTyped(pAttrDef, value); + } + + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, const CAttribute_String& value) OVERRIDE + { + return OnIterateAttributeValueTyped(pAttrDef, value); + } + + virtual bool OnIterateAttributeValue(const CEconItemAttributeDefinition* pAttrDef, const Vector& value) OVERRIDE + { + return OnIterateAttributeValueTyped(pAttrDef, value); + } + + bool WasFound() const + { + return m_bFound; + } + +private: + template < typename TAnyOtherType > + bool OnIterateAttributeValueTyped(const CEconItemAttributeDefinition* pAttrDef, const TAnyOtherType& value) + { + COMPILE_TIME_ASSERT(IsValidAttributeValueType::kValue); + + AssertMsg(m_pAttrDef != pAttrDef, "Incorrect type found for attribute during iteration."); + + return true; + } + + bool OnIterateAttributeValueTyped(const CEconItemAttributeDefinition* pAttrDef, const TActualTypeInMemory& value) + { + if (m_pAttrDef == pAttrDef) + { + m_bFound = true; + CopyAttributeValueToOutput(&value, reinterpret_cast(m_outpValue)); + } + + return !m_bFound; + } + +private: + static void CopyAttributeValueToOutput(const TActualTypeInMemory* pValue, TTreatAsThisType* out_pValue) + { + COMPILE_TIME_ASSERT(sizeof(TActualTypeInMemory) == sizeof(TTreatAsThisType)); + + Assert(pValue); + Assert(out_pValue); + + *out_pValue = *reinterpret_cast(pValue); + } + +private: + const CEconItemAttributeDefinition* m_pAttrDef; + TTreatAsThisType* m_outpValue; + bool m_bFound; +}; + +void CopyStringAttributeValueToCharPointerOutput(const CAttribute_String* pValue, const char** out_pValue); + +template < > +inline void CAttributeIterator_GetTypedAttributeValue::CopyAttributeValueToOutput(const CAttribute_String* pValue, const char** out_pValue) +{ + CopyStringAttributeValueToCharPointerOutput(pValue, out_pValue); +} + +template < typename TAttributeContainerType > +bool FindAttribute(const TAttributeContainerType* pSomethingThatHasAnIterateAttributesFunction, const CEconItemAttributeDefinition* pAttrDef) +{ + if (!pAttrDef) + return false; + + CAttributeIterator_HasAttribute it(pAttrDef); + pSomethingThatHasAnIterateAttributesFunction->IterateAttributes(&it); + return it.WasFound(); +} + +template < typename TActualTypeInMemory, typename TTreatAsThisType, typename TAttributeContainerType > +bool FindAttribute_UnsafeBitwiseCast(const TAttributeContainerType* pSomethingThatHasAnIterateAttributesFunction, const CEconItemAttributeDefinition* pAttrDef, TTreatAsThisType* out_pValue) +{ + if (!pAttrDef) + return false; + + CAttributeIterator_GetTypedAttributeValue it(pAttrDef, out_pValue); + pSomethingThatHasAnIterateAttributesFunction->IterateAttributes(&it); + return it.WasFound(); +} + +template < typename TAttributeContainerType, typename T > +bool FindAttribute(const TAttributeContainerType* pSomethingThatHasAnIterateAttributesFunction, const CEconItemAttributeDefinition* pAttrDef, T* out_pValue) +{ + return FindAttribute_UnsafeBitwiseCast(pSomethingThatHasAnIterateAttributesFunction, pAttrDef, out_pValue); +} + +class IEconItemInterface +{ +public: + virtual ~IEconItemInterface() { } + + bool FindAttribute(const CEconItemAttributeDefinition* pAttrDef) const + { + return ::FindAttribute(this, pAttrDef); + } + + template < typename T > + bool FindAttribute(const CEconItemAttributeDefinition* pAttrDef, T* out_pValue) const + { + return ::FindAttribute(this, pAttrDef, out_pValue); + } + + virtual int GetCustomPaintKitIndex(void) const; + virtual int GetCustomPaintKitSeed(void) const; + virtual float GetCustomPaintKitWear(float flWearDefault = 0.0f) const; + + virtual float GetStickerAttributeBySlotIndexFloat(int nSlotIndex, EStickerAttributeType type, float flDefault) const; + virtual uint32 GetStickerAttributeBySlotIndexInt(int nSlotIndex, EStickerAttributeType type, uint32 uiDefault) const; + + virtual bool IsTradable() const; + virtual bool IsMarketable() const; + virtual bool IsCommodity() const; + virtual bool IsUsableInCrafting() const; + virtual bool IsHiddenFromDropList() const; + + virtual RTime32 GetExpirationDate() const; + + virtual const GameItemDefinition_t* GetItemDefinition() const = 0; + + virtual uint32 GetAccountID() const = 0; + virtual uint64 GetItemID() const = 0; + virtual int32 GetQuality() const = 0; + virtual int32 GetRarity() const = 0; + virtual uint8 GetFlags() const = 0; + virtual eEconItemOrigin GetOrigin() const = 0; + virtual uint16 GetQuantity() const = 0; + virtual uint32 GetItemLevel() const = 0; + virtual bool GetInUse() const = 0; + + virtual const char* GetCustomName() const = 0; + virtual const char* GetCustomDesc() const = 0; + + virtual int GetItemSetIndex() const = 0; + + virtual void IterateAttributes(IEconItemAttributeIterator* pIterator) const = 0; + + bool IsPotentiallyTradable() const; + + RTime32 GetCacheRefreshDateTime() const; + + RTime32 GetTradableAfterDateTime() const; + RTime32 GetUseAfterDateTime() const; +}; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/econ_item_schema.h b/SpyCustom/sdk/econ_item_schema.h new file mode 100644 index 0000000..972c919 --- /dev/null +++ b/SpyCustom/sdk/econ_item_schema.h @@ -0,0 +1,3522 @@ +#ifndef ECONITEMSCHEMA_H +#define ECONITEMSCHEMA_H +#ifdef _WIN32 +#pragma once +#endif + +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif + +#include +#include "steamtypes.h" +#include "keyvalues.h" +#include "utldict.h" +#include "econ_item_constants.h" +#include "UtlStringMap.h" + +#include "item_selection_criteria.h" +#include "bitvec.h" +#include "smartptr.h" +#include "random.h" +#include "imaterialsystem.h" + +#include "expressioncalculator.h" + +#if defined(CLIENT_DLL) || defined(GAME_DLL) +#include "weapon_parse.h" +#include "ivmodelinfo.h" +#include "ivmodelrender.h" +#endif + +class CEconItem; +#ifdef SOURCE1 +#include "gamestringpool.h" +#endif + +class CEconItemSchema; +class CEconSharedObjectCache; +class CSOItemRecipe; +class CStickerList; + +class CTimedItemRewardDefinition; +void Helper_TemporaryBuildCopyOfLootlistForQuestDrop(CTimedItemRewardDefinition& build, const CTimedItemRewardDefinition* pDescReward, char const* szGameModeExclude); + +#define MAX_PAINT_DATA_NAME 128 + +#define MAX_STICKER_DATA_PATH 128 + +#define DEFAULT_EMBROIDER_NCOLORS 10 +#define DEFAULT_EMBROIDER_GAMMA 0.8 + +enum CraftFilter_t +{ + CRAFT_FILTER_TRADEUP = -3, + CRAFT_FILTER_COLLECT = -2, +}; + +enum EQuestVar_t +{ + k_EQuestVar_First, + k_EQuestVar_Last +}; + +class CEconItemRarityDefinition +{ +public: + CEconItemRarityDefinition(void); + CEconItemRarityDefinition(const CEconItemRarityDefinition& that); + CEconItemRarityDefinition& operator=(const CEconItemRarityDefinition& rhs); + + ~CEconItemRarityDefinition(void) { } + + bool BInitFromKV(KeyValues* pKVItem, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + int32 GetDBValue(void) const { return m_nValue; } + const char* GetName(void) const { return !m_strName.IsEmpty() ? m_strName.String() : "unknown"; } + const char* GetLocKey(void) const { return m_strLocKey.String(); } + const char* GetWepLocKey(void) const { return m_strWepLocKey.String(); } + const char* GetLootList(void) const { return m_strLootList.String(); } + const char* GetRecycleLootList(void) const { return m_strRecycleLootList.String(); } + const char* GetDropSound(void) const { return m_strDropSound.String(); } + attrib_colors_t GetAttribColor(void) const { return m_iAttribColor; } + const char* GetNextRarity(void) const { return m_strNextRarity.String(); } + int GetWhiteCount(void) const { return m_iWhiteCount; } + int GetBlackCount(void) const { return m_iBlackCount; } + float GetWeight(void) const { return m_flWeight; } + +private: + + int32 m_nValue; + + attrib_colors_t m_iAttribColor; + + CUtlString m_strName; + + CUtlString m_strLocKey; + CUtlString m_strWepLocKey; + + CUtlString m_strLootList; + CUtlString m_strRecycleLootList; + CUtlString m_strDropSound; + + CUtlString m_strNextRarity; + + int m_iWhiteCount; + int m_iBlackCount; + + float m_flWeight; +}; + +typedef int econ_tag_handle_t; +typedef uint16 equipped_class_t; +typedef uint16 equipped_slot_t; +typedef uint8 equipped_preset_t; + +#define INVALID_ECON_TAG_HANDLE ((econ_tag_handle_t)-1) +#define INVALID_EQUIPPED_SLOT ((equipped_slot_t)-1) +#define INVALID_EQUIPPED_SLOT_BITPACKED 0x3F +#define INVALID_STYLE_INDEX ((style_index_t)-1) +#define INVALID_PRESET_INDEX ((equipped_preset_t)-1) + +union attribute_data_union_t +{ + float asFloat; + uint32 asUint32; + byte* asBlobPointer; +}; + +struct static_attrib_t +{ + static_attrib_t() + { + iDefIndex = 0; + m_value.asBlobPointer = NULL; + m_bForceGCToGenerate = false; + + } + + attrib_definition_index_t iDefIndex; + attribute_data_union_t m_value; + bool m_bForceGCToGenerate; + + bool BInitFromKV_MultiLine(const char* pszContext, KeyValues* pKVAttribute, CUtlVector* pVecErrors); + + bool BInitFromKV_SingleLine(const char* pszContext, KeyValues* pKVAttribute, CUtlVector* pVecErrors); + + const class CEconItemAttributeDefinition* GetAttributeDefinition() const; +}; + +enum EWebResourceStatus +{ + kWebResource_InvalidName, + kWebResource_NotLoaded, + kWebResource_Loading, + kWebResource_Loaded, +}; + +struct WeaponPaintableMaterial_t +{ + char m_szName[MAX_PAINT_DATA_NAME]; + char m_szOriginalMaterialName[MAX_PAINT_DATA_NAME]; + char m_szFolderName[MAX_PAINT_DATA_NAME]; + int m_nViewModelSize; + int m_nWorldModelSize; + float m_flWeaponLength; + float m_flUVScale; + bool m_bBaseTextureOverride; + bool m_bMirrorPattern; +}; + +struct InventoryImageData_t +{ + QAngle* m_pCameraAngles; + Vector* m_pCameraOffset; + float m_cameraFOV; + LightDesc_t* m_pLightDesc[MATERIAL_MAX_LIGHT_COUNT]; + bool m_bOverrideDefaultLight; +}; + +struct StickerData_t +{ + char m_szStickerModelPath[MAX_STICKER_DATA_PATH]; + char m_szStickerMaterialPath[MAX_STICKER_DATA_PATH]; + Vector m_vWorldModelProjectionStart; + Vector m_vWorldModelProjectionEnd; + char m_szStickerBoneParentName[32]; +}; + +class CEconItemQualityDefinition +{ +public: + CEconItemQualityDefinition(void); + CEconItemQualityDefinition(const CEconItemQualityDefinition& that); + CEconItemQualityDefinition& operator=(const CEconItemQualityDefinition& rhs); + + ~CEconItemQualityDefinition(void) { } + + bool BInitFromKV(KeyValues* pKVItem, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + + int32 GetDBValue(void) const { return m_nValue; } + const char* GetName(void) const { return !m_strName.IsEmpty() ? m_strName.Get() : "unknown"; } + uint32 GetWeight(void) const { return m_unWeight; } + bool GetRequiresExplicitMatches(void) const { return m_bExplicitMatchesOnly; } + bool CanSupportSet(void) const { return m_bCanSupportSet; } + const char* GetHexColor(void) const { return !m_strHexColor.IsEmpty() ? m_strHexColor.Get() : "B2B2B2"; } + +private: + + int32 m_nValue; + + CUtlConstString m_strName; + + uint32 m_unWeight; + + bool m_bExplicitMatchesOnly; + + bool m_bCanSupportSet; + + CUtlConstString m_strHexColor; +}; + +class CEconColorDefinition +{ +public: + bool BInitFromKV(KeyValues* pKVColor, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + const char* GetName(void) const { return m_strName.Get(); } + const char* GetColorName(void) const { return m_strColorName.Get(); } + const char* GetHexColor(void) const { return m_strHexColor.Get(); } + +private: + CUtlConstString m_strName; + + CUtlConstString m_strColorName; + + CUtlConstString m_strHexColor; +}; + +class CEconGraffitiTintDefinition +{ +public: + bool BInitFromKV(KeyValues* pKVColor, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + int GetID(void) const { return m_nID; } + const char* GetColorName(void) const { return m_strColorName.Get(); } + const char* GetHexColor(void) const { return m_strHexColor.Get(); } + uint32 GetHexColorRGB(void) const { return m_unHexColorRGB; } + +private: + int m_nID; + + CUtlConstString m_strColorName; + + CUtlConstString m_strHexColor; + uint32 m_unHexColorRGB; +}; + +class CEconMusicDefinition +{ +public: + bool BInitFromKV(KeyValues* pKVMusicDef, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + uint32 GetID(void) const { return nID; } + const char* GetName(void) const { return m_strName.Get(); } + const char* GetNameLocToken(void) const { return m_strNameLocToken.Get(); } + const char* GetDescription(void) const { return m_strLocDescription.Get(); } + const char* GetInventoryImage(void) const { return m_strInventoryImage.Get(); } + const char* GetPedestalDisplayModel(void) const { return m_strPedestalDisplayModel.Get(); } + + const char* GetIconURLSmall() const { return m_sIconURLSmall; } + const char* GetIconURLLarge() const { return m_sIconURLLarge; } + void SetIconURLSmall(const char* szURL) { m_sIconURLSmall = szURL; } + void SetIconURLLarge(const char* szURL) { m_sIconURLLarge = szURL; } + +private: + + int nID; + CUtlConstString m_strName; + CUtlConstString m_strNameLocToken; + CUtlConstString m_strLocDescription; + CUtlConstString m_strPedestalDisplayModel; + CUtlConstString m_strInventoryImage; + + CUtlConstString m_sIconURLSmall; + CUtlConstString m_sIconURLLarge; +}; + + +class CEconQuestDefinition; + +struct quest_event_t +{ + quest_event_t(int nStartDay, const char* pchHHMM, int nDurationInMinutes, const char* strTimeZone, CEconQuestDefinition* pQuestDef, RTime32 start, RTime32 end) : m_strHHMM(pchHHMM), + m_rtEventStart(start), + m_rtEventEnd(end), + m_nStartDay(nStartDay), + m_nDurationInMinutes(nDurationInMinutes), + m_pQuestDef(pQuestDef), + m_strTimeZone(strTimeZone) {} + RTime32 m_rtEventStart; + RTime32 m_rtEventEnd; + int m_nDurationInMinutes; + int m_nStartDay; + CEconQuestDefinition* m_pQuestDef; + CUtlConstString m_strHHMM; + CUtlConstString m_strTimeZone; + + +}; + +typedef CUtlVector QuestEvents_t; +typedef CUtlMap< RTime32, quest_event_t*, int, CDefLess< RTime32 > > QuestEventsSchedule_t; + + +class CEconQuestDefinition +{ +public: + bool BInitFromKV(KeyValues* pKVQuestDef, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + uint32 GetID(void) const { return nID; } + const char* GetName(void) const { return m_strName.Get(); } + + const char* GetGameMode(void) const { return m_strGameMode.Get(); } + const char* GetMapGroup(void) const { return m_strMapGroup.Get(); } + const char* GetMap(void) const { return m_strMap.Get(); } + const char* GetRewardLootList(void) const { return m_strRewardLootList.Get(); } + + const char* GetQuestExpression(void) const { return m_strExpr; } + const char* GetQuestBonusExpression(void) const { return m_strBonusExpr; } + + const uint32 GetDifficulty(void) const { return m_nDifficulty; } + const uint32 GetOperationalPoints(void) const { return m_nOperationalPoints; } + const uint32 GetXPReward(void) const { return m_nXPReward; } + const uint32 GetTargetTeam(void) const { return m_nTargetTeam; } + + const uint32 GetXPBonusPercent(void) const { return m_nXPBonusPercent; } + + const CCopyableUtlVector< uint32 >& GetQuestPoints(void) const { return m_vecQuestPoints; } + + const char* GetQuestConVars(void) const { return m_strQuestConVars.Get(); } + const bool IsAnEvent(void) const { return m_bIsAnEvent; } + + static void TokenizeQuestExpression(const char* szExpression, KeyValues* pKVExpressionTokens); + static bool IsQuestExpressionValid(const char* pszQuestExpr); + static void ZeroOutQuestExpressionVariables(CExpressionCalculator& expQuest); + static void SetQuestExpressionVariable(CExpressionCalculator& expQuest, EQuestVar_t questVar, float flValue); + +private: + + int nID; + CUtlConstString m_strName; + + CUtlConstString m_strMapGroup; + CUtlConstString m_strMap; + CUtlConstString m_strGameMode; + CUtlConstString m_strRewardLootList; + + CUtlConstString m_strExpr; + CUtlConstString m_strBonusExpr; + + CCopyableUtlVector< uint32 > m_vecQuestPoints; + bool m_bIsAnEvent; + + uint32 m_nDifficulty; + uint32 m_nOperationalPoints; + uint32 m_nXPReward; + + uint32 m_nXPBonusPercent; + uint32 m_nTargetTeam; + + CUtlConstString m_strQuestConVars; + +#ifdef CLIENT_DLL + +public: + const char* GetNameLocToken(void) const { return m_strNameLocToken.Get(); } + const char* GetShortNameLocToken(void) const { return m_strShortNameLocToken.Get(); } + const char* GetDescriptionLocToken(void) const { return m_strDescriptionLocToken.Get(); } + const char* GetHudDesscriptionLocToken(void) const { return m_strHudDescriptionLocToken.Get(); } + const char* GetBonusLocToken(void) const { return m_strLocBonus.Get(); } + KeyValues* GetStringTokens(void) const { return m_kvStringTokens; } + const char* GetIcon(void) const { return m_strIcon; } + + static void PopulateQuestStringTokens(CEconQuestDefinition& questDef, KeyValues& kvExpressionTokens, KeyValues& kvStringTokens, bool bBonus = false); + +private: + CUtlConstString m_strNameLocToken; + CUtlConstString m_strShortNameLocToken; + CUtlConstString m_strDescriptionLocToken; + CUtlConstString m_strHudDescriptionLocToken; + KeyValues* m_kvStringTokens; + CUtlConstString m_strLocBonus; + CUtlConstString m_strIcon; + +#endif + +}; + + + +class CEconCampaignDefinition +{ +public: + + class CEconCampaignNodeDefinition + { + public: + +#ifdef CLIENT_DLL + class CEconCampaignNodeStoryBlockDefinition + { + public: + bool BInitFromKV(int nCampaignIndex, int nNodeID, KeyValues* pKVCampaignNodeStoryBlockDef, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + const char* GetContentFile(void) const { return m_strContentFile.Get(); } + const char* GetCharacterName(void) const { return m_strCharacterName.Get(); } + const char* GetStoryBlockExpression(void) const { return m_strExpr.Get(); } + const char* GetDescription(void) const { return m_strDescription.Get(); } + + float EvaluateStoryBlockExpression(CEconItemView* pCampaignCoin) const; + + private: + CUtlConstString m_strContentFile; + CUtlConstString m_strCharacterName; + CUtlConstString m_strExpr; + CUtlConstString m_strDescription; + }; + + const CUtlVector< CEconCampaignNodeStoryBlockDefinition* >& GetStoryBlocks(void) const { return m_vecStoryBlocks; } + + CEconCampaignNodeStoryBlockDefinition* GetBestScoringStoryBlock(CEconItemView* pCampaignCoin) const; + + private: + CUtlVector< CEconCampaignNodeStoryBlockDefinition* > m_vecStoryBlocks; + public: +#endif + + bool BInitFromKV(int nCampaignIndex, KeyValues* pKVCampaignNodeDef, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + const uint32 GetID(void) const { return m_nID; } + const uint32 GetQuestIndex(void) const { return m_nQuestIndex; } + const CUtlVector< uint32 >& GetNextNodes(void) const { return m_vecNextNodes; } + const uint32 GetCampaignID(void) const { return m_CampaignID; } + + + + private: + + uint32 m_nID; + uint32 m_nQuestIndex; + uint32 m_CampaignID; + CUtlVector< uint32 > m_vecNextNodes; + + + + }; + + typedef CUtlMap > CampaignNodeDefinitionsList_t; + + bool BInitFromKV(KeyValues* pKVCampaignDef, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + const uint32 GetID(void) const { return m_nID; } + const char* GetNameLocToken(void) const { return m_strNameLocToken.Get(); } + const char* GetDescription(void) const { return m_strLocDescription.Get(); } + const CampaignNodeDefinitionsList_t& GetStartNodes(void) const { return m_mapStartNodes; } + const CampaignNodeDefinitionsList_t& GetCampaignNodes(void) const { return m_mapCampaignNodes; } + uint32 GetSeasonNumber() const { return m_nSeasonNumber; } + + void GetAccessibleCampaignNodes(const uint32 unCampaignCompletionBitfield, CUtlVector< CEconCampaignNodeDefinition* >& vecAccessibleNodes); + void Helper_RecursiveGetAccessibleCampaignNodes(const uint32 unCampaignCompletionBitfield, const CEconCampaignNodeDefinition* pNode, CUtlVector< CEconCampaignNodeDefinition* >& vecAccessibleNodes); + + +private: + + int m_nID; + CUtlConstString m_strName; + CUtlConstString m_strNameLocToken; + CUtlConstString m_strLocDescription; + CampaignNodeDefinitionsList_t m_mapCampaignNodes; + CampaignNodeDefinitionsList_t m_mapStartNodes; + uint32 m_nSeasonNumber; + +}; + +bool ResolveQuestIdToCampaignAndIndex(uint16 unQuestID, uint32& unCampaignID, uint32& unCamapaignNodeID); +void TokenizeCalculatorExpression(const char* szExpression, KeyValues* pKVExpressionTokens); + +struct item_list_entry_t +{ + item_list_entry_t() + { + memset(this, 0, sizeof(*this)); + m_nPaintKitSeed = -2; + m_flPaintKitWear = -2; + } + + bool operator==(const item_list_entry_t other) const + { + return ( + (m_nItemDef == other.m_nItemDef) && + (m_nPaintKit == other.m_nPaintKit) && + (m_nPaintKitSeed == other.m_nPaintKitSeed) && + (m_flPaintKitWear == other.m_flPaintKitWear) && + (m_nStickerKit == other.m_nStickerKit) && + (m_nMusicKit == other.m_nMusicKit) && + (m_bIsNestedList == other.m_bIsNestedList) && + (m_bIsUnusualList == other.m_bIsUnusualList) && + (m_bAlreadyUsedInRecursiveCreation == m_bAlreadyUsedInRecursiveCreation) + ); + } + + bool InitFromName(const char* pchName); + + int m_nItemDef; + + int m_nPaintKit; + int m_nPaintKitSeed; + float m_flPaintKitWear; + + uint32 m_nStickerKit; + + uint32 m_nMusicKit; + + bool m_bIsNestedList; + bool m_bIsUnusualList; + mutable bool m_bAlreadyUsedInRecursiveCreation; +}; + +class CEconItemSetDefinition : public IEconItemSetDefinition +{ +public: + CEconItemSetDefinition(void); + CEconItemSetDefinition(const CEconItemSetDefinition& that); + CEconItemSetDefinition& operator=(const CEconItemSetDefinition& rhs); + + ~CEconItemSetDefinition(void) {} + + virtual bool BInitFromKV(KeyValues* pKVItemSet, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + virtual const char* GetName(void) const { return m_pszName; } + virtual const char* GetLocKey(void) const { return m_pszLocalizedName; } + virtual const char* GetUnlocalizedName(void) const { return m_pszUnlocalizedName; } + virtual int GetBundle(void) const { return m_iBundleItemDef; } + virtual int GetItemCount(void) const { return m_ItemEntries.Count(); } + virtual int GetItemDef(int iIndex) const { return m_ItemEntries[iIndex].m_nItemDef; } + virtual int GetItemPaintKit(int iIndex) const { return m_ItemEntries[iIndex].m_nPaintKit; } + virtual int GetItemRarity(int iIndex) const; + virtual int GetHighestItemRarityValue(void) const; + virtual item_definition_index_t GetCraftReward(void) const { return m_nCraftReward; } + +public: + + const char* m_pszName; + const char* m_pszLocalizedName; + const char* m_pszUnlocalizedName; + const char* m_pszLocalizedDescription; + CUtlVector m_ItemEntries; + int m_iBundleItemDef; + bool m_bIsCollection; + bool m_bIsHiddenSet; + item_definition_index_t m_nCraftReward; + + struct itemset_attrib_t + { + int m_iAttribDefIndex; + attrib_value_t m_valValue; + }; + CUtlVector m_iAttributes; +}; + +struct favored_lootlist_t +{ + favored_lootlist_t() + { + iHeroID = 0; + iBonus = 0; + } + + favored_lootlist_t& operator=(const favored_lootlist_t& rhs) + { + iHeroID = rhs.iHeroID; + iBonus = rhs.iBonus; + return *this; + } + + uint iHeroID; + uint iBonus; +}; + +class CEconLootListDefinition : public IEconLootListDefinition +{ +public: + CEconLootListDefinition(void); + CEconLootListDefinition(const CEconLootListDefinition& that); + CEconLootListDefinition& operator=(const CEconLootListDefinition& rhs); + + ~CEconLootListDefinition(void); + + bool AddRandomAtrributes(KeyValues* pRandomAttributesKV, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + bool BInitFromKV(KeyValues* pKVLootList, KeyValues* pKVRandomAttributeTemplates, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL, bool bServerList = false); + virtual const char* GetName() const { return m_pszName; } + const CUtlVector& GetLootListContents() const { return m_ItemEntries; } + virtual float GetWeight(int iIdx) const { return m_flWeights[iIdx]; } + virtual KeyValues* GenerateKeyValues() const; + virtual bool IsServerList() const { return m_bServerList; } + virtual bool HasUnusualLoot() const; + virtual int GetAdditionalDropCount(void) const { return m_AdditionalDrops.Count(); } + virtual bool GetAdditionalDrop(int iIndex, CUtlString& strLootList, float& flChance) const; + + virtual int GetRandomAttributeGroupCount(void) const { return m_RandomAttribs.Count(); } + virtual bool GetRandomAttributeGroup(int iIndex, float& flChance, float& flTotalWeight) const; + virtual int GetRandomAttributeCount(int iGroup) const; + virtual bool GetRandomAttribute(int iGroup, int iIndex, float& flWeight, int& iValue, int& iDefIndex) const; + + virtual void PurgeItems(void); + + bool GetPublicListContents() const + { + return true; + } + + struct loot_list_additional_drop_t + { + float m_fChance; + bool m_bPremiumOnly; + const char* m_pszLootListDefName; + }; + CUtlVector m_AdditionalDrops; + +protected: + const char* m_pszName; + + CUtlVector m_ItemEntries; + uint32 m_unHeroID; + + bool m_bPublicListContents; +#ifndef GC_DLL + bool m_bWillProduceStatTrak; +#endif + float m_flTotalWeight; + CUtlVector m_flWeights; + + struct lootlist_attrib_t + { + static_attrib_t m_staticAttrib; + float m_flWeight; + float m_flRangeMin; + float m_flRangeMax; + + CCopyableUtlVector< uint32 > m_vecValues; + + bool BInitFromKV(const char* pszContext, KeyValues* pKVKey, CEconItemSchema& pschema, CUtlVector* pVecErrors); + }; + + struct random_attrib_t + { + float m_flChanceOfRandomAttribute; + float m_flTotalAttributeWeight; + bool m_bPickAllAttributes; + CUtlVector m_RandomAttributes; + }; + + CUtlVector m_RandomAttribs; + bool m_bServerList; +}; + +class CEconCraftingRecipeDefinition +{ +public: + CEconCraftingRecipeDefinition(void); + virtual ~CEconCraftingRecipeDefinition(void) { } + + bool BInitFromKV(KeyValues* pKVItem, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + bool BInitFromSet(const IEconItemSetDefinition* pSet, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + virtual void CopyPolymorphic(const CEconCraftingRecipeDefinition* pSourceDef) { *this = *pSourceDef; } + + void SetDefinitionIndex(uint32 iIndex) { m_nDefIndex = iIndex; } + int32 GetDefinitionIndex(void) const { return m_nDefIndex; } + const char* GetName(void) const { return !m_strName.IsEmpty() ? m_strName.String() : "unknown"; } + const char* GetName_A(void) const { return !m_strN_A.IsEmpty() ? m_strN_A.String() : "unknown"; } + const char* GetDescInputs(void) const { return !m_strDescInputs.IsEmpty() ? m_strDescInputs.String() : "unknown"; } + const char* GetDescOutputs(void) const { return !m_strDescOutputs.IsEmpty() ? m_strDescOutputs.String() : "unknown"; } + + const char* GetDescI_A(void) const { return !m_strDI_A.IsEmpty() ? m_strDI_A.String() : "unknown"; } + const char* GetDescI_B(void) const { return !m_strDI_B.IsEmpty() ? m_strDI_B.String() : "unknown"; } + const char* GetDescI_C(void) const { return !m_strDI_C.IsEmpty() ? m_strDI_C.String() : "unknown"; } + const char* GetDescO_A(void) const { return !m_strDO_A.IsEmpty() ? m_strDO_A.String() : "unknown"; } + const char* GetDescO_B(void) const { return !m_strDO_B.IsEmpty() ? m_strDO_B.String() : "unknown"; } + const char* GetDescO_C(void) const { return !m_strDO_C.IsEmpty() ? m_strDO_C.String() : "unknown"; } + + const wchar_t* GetLocName(void) const { return m_wszName; } + const wchar_t* GetLocDescription(void) const { return m_wszDesc; } + + void SetDisabled(bool bDisabled) { m_bDisabled = bDisabled; } + bool IsDisabled(void) const { return m_bDisabled; } + bool RequiresAllSameClass(void) { return m_bRequiresAllSameClass; } + bool RequiresAllSameSlot(void) { return m_bRequiresAllSameSlot; } + bool IsAlwaysKnown(void) const { return m_bAlwaysKnown; } + bool IsPremiumAccountOnly(void) const { return m_bPremiumAccountOnly; } + recipecategories_t GetCategory(void) const { return m_iCategory; } + int GetFilter(void) const { return m_iFilter; } + void SetFilter(int nFilter) { m_iFilter = nFilter; } + int GetTotalInputItemsRequired(void) const; + int GetTotalOutputItems(void) const { return m_OutputItemsCriteria.Count(); } + + virtual bool ItemListMatchesInputs(const CUtlVector< CEconItem* >& vecCraftingItems, bool bAllowPartialMatch = false) const; + + const CUtlVector* GetInputItems(void) const { return &m_InputItemsCriteria; } + const CUtlVector& GetInputItemDupeCounts(void) const { return m_InputItemDupeCounts; } + const CUtlVector& GetOutputItems(void) const { return m_OutputItemsCriteria; } + + bool BSerializeToMsg(CSOItemRecipe& msg) const; + bool BDeserializeFromMsg(const CSOItemRecipe& msg); + +private: + void GenerateLocStrings(void); + +protected: + int32 m_nDefIndex; + + CUtlString m_strName; + CUtlString m_strN_A; + CUtlString m_strDescInputs; + CUtlString m_strDescOutputs; + CUtlString m_strDI_A; + CUtlString m_strDI_B; + CUtlString m_strDI_C; + CUtlString m_strDO_A; + CUtlString m_strDO_B; + CUtlString m_strDO_C; + + wchar_t m_wszName[64]; + wchar_t m_wszDesc[512]; + + bool m_bDisabled; + bool m_bRequiresAllSameClass; + bool m_bRequiresAllSameSlot; + int m_iCacheClassUsageForOutputFromItem; + int m_iCacheSlotUsageForOutputFromItem; + int m_iCacheSetForOutputFromItem; + bool m_bAlwaysKnown; + bool m_bPremiumAccountOnly; + recipecategories_t m_iCategory; + int m_iFilter; + + CUtlVector m_InputItemsCriteria; + CUtlVector m_InputItemDupeCounts; + + CUtlVector m_OutputItemsCriteria; +}; + +enum +{ + ATTDESCFORM_VALUE_IS_PERCENTAGE, + ATTDESCFORM_VALUE_IS_INVERTED_PERCENTAGE, + ATTDESCFORM_VALUE_IS_ADDITIVE, + ATTDESCFORM_VALUE_IS_ADDITIVE_PERCENTAGE, + ATTDESCFORM_VALUE_IS_OR, + ATTDESCFORM_VALUE_IS_DATE, + ATTDESCFORM_VALUE_IS_ACCOUNT_ID, + ATTDESCFORM_VALUE_IS_PARTICLE_INDEX, + ATTDESCFORM_VALUE_IS_ITEM_DEF, + ATTDESCFORM_VALUE_IS_COLOR, + ATTDESCFORM_VALUE_IS_GAME_TIME, + ATTDESCFORM_VALUE_IS_MINS_AS_HOURS, + ATTDESCFORM_VALUE_IS_REPLACE, +}; + +enum attrib_effect_types_t +{ + ATTRIB_EFFECT_NEUTRAL = 0, + ATTRIB_EFFECT_POSITIVE, + ATTRIB_EFFECT_NEGATIVE, + + NUM_EFFECT_TYPES, +}; + +enum EAssetClassAttrExportRule_t +{ + k_EAssetClassAttrExportRule_Default = 0, + k_EAssetClassAttrExportRule_Bucketed = (1 << 0), + k_EAssetClassAttrExportRule_Skip = (1 << 1), + k_EAssetClassAttrExportRule_GCOnly = (1 << 2), +}; + +class CEconItemAttributeDefinition : public IEconItemAttributeDefinition +{ +public: + CEconItemAttributeDefinition(void); + CEconItemAttributeDefinition(const CEconItemAttributeDefinition& that); + CEconItemAttributeDefinition& operator=(const CEconItemAttributeDefinition& rhs); + + ~CEconItemAttributeDefinition(void); + + bool BInitFromKV(KeyValues* pKVAttribute, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + virtual attrib_definition_index_t GetDefinitionIndex(void) const { return m_nDefIndex; } + virtual const char* GetDefinitionName(void) const { return m_pszDefinitionName; } + + virtual KeyValues* GetRawDefinition(void) const { return m_pKVAttribute; } + + bool IsHidden(void) const { return m_bHidden; } + bool BForceWebSchemaOutput(void) const { return m_bWebSchemaOutputForced; } + bool IsStoredAsInteger(void) const { return m_bStoredAsInteger; } + bool IsStoredAsFloat(void) const { return !m_bStoredAsInteger; } + bool IsInstanceData() const { return m_bInstanceData; } + EAssetClassAttrExportRule_t GetAssetClassAttrExportRule() const { return m_eAssetClassAttrExportRule; } + uint32 GetAssetClassBucket() const { return m_unAssetClassBucket; } + int GetDescriptionFormat(void) const { return m_iDescriptionFormat; } + int GetScore(void) const { return m_iScore; } + virtual const char* GetDescriptionString(void) const { return m_pszDescriptionString; } + const char* GetArmoryDescString(void) const { return m_pszArmoryDesc; } + virtual const char* GetAttributeClass(void) const { return m_pszAttributeClass; } + attrib_effect_types_t GetEffectType(void) const { return m_iEffectType; } + + const class ISchemaAttributeType* GetAttributeType(void) const { return m_pAttrType; } + +#ifndef GC_DLL + void ClearStringCache(void) const { m_iszAttributeClass = NULL_STRING; } + string_t GetCachedClass(void) const + { + if (m_iszAttributeClass == NULL_STRING && m_pszAttributeClass) + { + m_iszAttributeClass = AllocPooledString(m_pszAttributeClass); + } + return m_iszAttributeClass; + } +#endif + +private: + KeyValues* m_pKVAttribute; + + attrib_definition_index_t m_nDefIndex; + + const class ISchemaAttributeType* m_pAttrType; + + bool m_bHidden; + + bool m_bWebSchemaOutputForced; + + bool m_bStoredAsInteger; + + bool m_bInstanceData; + EAssetClassAttrExportRule_t m_eAssetClassAttrExportRule; + uint32 m_unAssetClassBucket; + + attrib_effect_types_t m_iEffectType; + + int m_iDescriptionFormat; + const char* m_pszDescriptionString; + + const char* m_pszDescriptionTag; + + const char* m_pszArmoryDesc; + int m_iScore; + + const char* m_pszDefinitionName; + + const char* m_pszAttributeClass; + +#if defined(CLIENT_DLL) || defined(GAME_DLL) || defined(GC) + mutable string_t m_iszAttributeClass; +#endif + +}; + +class CEconSoundMaterialDefinition +{ +public: + CEconSoundMaterialDefinition(void); + CEconSoundMaterialDefinition(const CEconSoundMaterialDefinition& that); + CEconSoundMaterialDefinition& operator=(const CEconSoundMaterialDefinition& rhs); + + ~CEconSoundMaterialDefinition(void) { } + + bool BInitFromKV(KeyValues* pKVItem, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + int32 GetID(void) const { return m_nID; } + const char* GetName(void) const { return !m_strName.IsEmpty() ? m_strName.String() : "unknown"; } + + const char* GetStartDragSound(void) const { return m_strStartDragSound.Get(); } + const char* GetEndDragSound(void) const { return m_strEndDragSound.Get(); } + const char* GetEquipSound(void) const { return m_strEquipSound.Get(); } + +private: + + int32 m_nID; + + CUtlString m_strName; + + CUtlString m_strStartDragSound; + CUtlString m_strEndDragSound; + + CUtlString m_strEquipSound; +}; + + +#define MAX_VISUALS_CUSTOM_SOUNDS 10 + + +#if defined(CLIENT_DLL) || defined(GAME_DLL) +enum +{ + kAttachedModelDisplayFlag_WorldModel = 0x01, + kAttachedModelDisplayFlag_ViewModel = 0x02, + + kAttachedModelDisplayFlag_MaskAll = kAttachedModelDisplayFlag_WorldModel | kAttachedModelDisplayFlag_ViewModel, +}; + +struct attachedmodel_t +{ + const char* m_pszModelName; + int m_iModelDisplayFlags; +}; + +struct attachedparticle_t +{ + int m_iParticleIndex; + int m_nStyle; +}; + +enum wearableanimplayback_t +{ + WAP_ON_SPAWN, + WAP_START_BUILDING, + WAP_STOP_BUILDING, + + NUM_WAP_TYPES, +}; + +struct animation_on_wearable_t +{ + int iActivity; + const char* pszActivity; + wearableanimplayback_t iPlayback; + const char* pszReplacement; + int iReplacement; + const char* pszSequence; + const char* pszRequiredItem; + const char* pszScene; + float flFrequency; +}; + +struct sound_on_wearable_t +{ + const char* pszSound; + const char* pszReplacement; +}; + +struct particle_on_wearable_t +{ + const char* pszParticle; + const char* pszReplacement; + bool bFlyingCourierEffect; +}; + +struct particlesnapshot_on_wearable_t +{ + const char* pszParticleSnapshot; + const char* pszReplacement; +}; + +struct particle_control_point_on_wearable_t +{ + const char* pszParticle; + int nParticleControlPoint; + Vector vecCPValue; +}; + +struct codecontrolledbodygroupdata_t +{ + const char* pFuncName; + void* pFunc; +}; + +#endif + +struct style_unlock_info +{ + const char* pszItemName; + int iPrice; + int iStylePreReq; + const char* pszAttrib; + uint32 iAttribValue; + + bool IsLockable() const + { + return pszItemName || pszAttrib; + } + + bool HasUnlockPrice() const + { + return iPrice && pszItemName; + } + + bool HasUnlockAttrib() const + { + return iAttribValue && pszAttrib; + } +}; + +class CEconStyleInfo +{ +public: + CEconStyleInfo() + { + m_iIndex = 0; + m_iSkin = 0; + m_iIcon = 0; + m_pszName = NULL; + m_pszBasePlayerModel = NULL; + m_UnlockInfo.pszItemName = NULL; + m_UnlockInfo.iPrice = 0; + m_UnlockInfo.iStylePreReq = 0; + m_UnlockInfo.pszAttrib = NULL; + m_UnlockInfo.iAttribValue = 0; + } + + virtual ~CEconStyleInfo() + { + } + + virtual void BInitFromKV(KeyValues* pKVItem, CEconItemSchema& pschema, CUtlVector* pVecErrors); + +#if defined(CLIENT_DLL) || defined(GAME_DLL) + virtual void GeneratePrecacheModelStringsForStyle(CUtlVector* out_pVecModelStrings) const; +#endif + + int GetSkin() const + { + return m_iSkin; + } + + int GetIndex() const { return m_iIndex; } + const char* GetName() const { return m_pszName; } + const char* GetBasePlayerDisplayModel() const { return m_pszBasePlayerModel; } + const CUtlVector& GetAdditionalHideBodygroups() const { return m_vecAdditionalHideBodygroups; } + int GetIcon() const { return m_iIcon; } + const style_unlock_info* GetUnlockInfo() const { return &m_UnlockInfo; } + +protected: + int m_iIndex; + int m_iSkin; + int m_iIcon; + const char* m_pszName; + const char* m_pszBasePlayerModel; + CUtlVector m_vecAdditionalHideBodygroups; + style_unlock_info m_UnlockInfo; +}; + +struct courier_t +{ + const char* m_pszModelName; + int m_iTeam; +}; + +struct announcer_preview_t +{ + CUtlString m_strFileName; + CUtlString m_strCaption; +}; + +struct ability_icon_replacement_t +{ + CUtlString m_strAbilityName; + CUtlString m_strReplacement; +}; + +enum EAssetModifier +{ + AM_Invalid = -1, + AM_Activity, + AM_Announcer, + AM_AnnouncerPreview, + AM_HudSkin, + AM_AbilityName, + AM_Sound, + AM_Speech, + AM_Particle, + AM_ParticleSnapshot, + AM_ParticleControlPoint, + AM_EntityModel, + AM_ViewModel, + AM_EntityScale, + AM_Icon, + AM_AbilityIcon, + AM_Courier, + AM_CourierFlying, + AM_HeroModelChange, + AM_MAX +}; + +struct AssetModifier +{ + EAssetModifier m_Type; + CUtlString m_strAsset; + CUtlString m_strModifier; + float m_flModifier; + float m_flFrequency; + int m_iStyle; +}; + +struct AssetInfo +{ + AssetInfo() + { +#if defined(CLIENT_DLL) || defined(GAME_DLL) + iHideParentBodyGroup = -1; + + m_ModifiedBodyGroupNames.SetLessFunc(StringLessThan); + m_CodeControlledBodyGroupNames.SetLessFunc(StringLessThan); + + iSkin = 0; + bUsePerClassBodygroups = false; + m_pszMaterialOverride = NULL; + m_pszParticleEffect = NULL; + m_pszParticleSnapshot = NULL; + for (int i = 0; i < MAX_VISUALS_CUSTOM_SOUNDS; i++) + { + m_pszCustomSounds[i] = NULL; + } + + for (int i = 0; i < NUM_SHOOT_SOUND_TYPES; i++) + { + m_pszWeaponSoundReplacements[i] = NULL; + } + + m_iViewModelBodyGroupOverride = -1; + m_iViewModelBodyGroupStateOverride = -1; + m_iWorldModelBodyGroupOverride = -1; + m_iWorldModelBodyGroupStateOverride = -1; + + m_pszSpeechConcept = NULL; + m_pszChatMessage = NULL; + m_pszAnnouncerName.Clear(); + m_pszAnnouncerResource.Clear(); + m_pszEntityModel = NULL; + m_pszViewModel = NULL; + m_pszEntityClass = NULL; + m_flScaleSize = 1.f; + m_pszScaleClass = NULL; + m_bSkipModelCombine = false; + + m_pszPrimaryAmmo = NULL; + m_pszWeaponTypeString = NULL; + m_pszAddonLocation = NULL; + m_pszEjectBrassEffect = NULL; + m_pszTracerEffect = NULL; + m_pszMuzzleFlashEffect1stPerson = NULL; + m_pszMuzzleFlashEffect1stPersonAlt = NULL; + m_pszMuzzleFlashEffect3rdPerson = NULL; + m_pszMuzzleFlashEffect3rdPersonAlt = NULL; + m_pszHeatEffect = NULL; + m_pszPlayerAnimationExtension = NULL; + + m_pszOriginalIcon = NULL; + m_pszNewIcon = NULL; + + m_mapAssetModifiers.SetLessFunc(DefLessFunc(int)); + + +#endif + } + + ~AssetInfo() + { + m_Styles.PurgeAndDeleteElements(); + } + + void AddAssetModifier(AssetModifier* newMod); + CUtlVector* GetAssetModifiers(EAssetModifier type); + const char* GetModifierByAsset(EAssetModifier type, const char* pszAsset, int iStyle = -1); + const char* GetAssetByModifier(EAssetModifier type, const char* pszModifier, int iStyle = -1); + + CUtlMap< int, CUtlVector* > m_mapAssetModifiers; + +#if defined(CLIENT_DLL) || defined(GAME_DLL) + int iHideParentBodyGroup; + CUtlMap m_ModifiedBodyGroupNames; + CUtlMap m_CodeControlledBodyGroupNames; + int iSkin; + bool bUsePerClassBodygroups; + CUtlVector m_AttachedModels; + CUtlVector m_AttachedParticles; + CUtlVector m_Animations; + CUtlVector m_Sounds; + CUtlVector m_Particles; + CUtlVector m_ParticleSnapshots; + CUtlVector m_ParticleControlPoints; + const char* m_pszCustomSounds[MAX_VISUALS_CUSTOM_SOUNDS]; + const char* m_pszMaterialOverride; + const char* m_pszMuzzleFlash; + const char* m_pszTracerEffect; + const char* m_pszParticleEffect; + const char* m_pszParticleSnapshot; + const char* m_pszWeaponSoundReplacements[NUM_SHOOT_SOUND_TYPES]; + + const char* m_pszPrimaryAmmo; + const char* m_pszWeaponTypeString; + const char* m_pszAddonLocation; + const char* m_pszEjectBrassEffect; + const char* m_pszMuzzleFlashEffect1stPerson; + const char* m_pszMuzzleFlashEffect1stPersonAlt; + const char* m_pszMuzzleFlashEffect3rdPerson; + const char* m_pszMuzzleFlashEffect3rdPersonAlt; + const char* m_pszHeatEffect; + const char* m_pszPlayerAnimationExtension; + + int m_iViewModelBodyGroupOverride; + int m_iViewModelBodyGroupStateOverride; + int m_iWorldModelBodyGroupOverride; + int m_iWorldModelBodyGroupStateOverride; + bool m_bSkipModelCombine; + CUtlVector m_vecAnimationModifiers; + + const char* m_pszSpeechConcept; + const char* m_pszChatMessage; + + CUtlString m_pszAnnouncerName; + CUtlString m_pszAnnouncerResource; + CUtlVector< announcer_preview_t > m_vecAnnouncerPreview; + + CUtlString m_pszHudSkinName; + + CUtlString m_pszAbilityName; + + const char* m_pszEntityModel; + const char* m_pszViewModel; + const char* m_pszEntityClass; + + float m_flScaleSize; + const char* m_pszScaleClass; + + const char* m_pszOriginalIcon; + const char* m_pszNewIcon; + + CUtlVector< ability_icon_replacement_t > m_vecAbilityIconReplacements; + + +#endif + + CUtlVector m_Styles; +}; + +enum item_capabilities_t +{ + ITEM_CAP_NONE = 0, + ITEM_CAP_PAINTABLE = 1 << 0, + ITEM_CAP_NAMEABLE = 1 << 1, + ITEM_CAP_DECODABLE = 1 << 2, + ITEM_CAP_CAN_DELETE = 1 << 3, + ITEM_CAP_CAN_CUSTOMIZE_TEXTURE = 1 << 4, + ITEM_CAP_USABLE = 1 << 5, + ITEM_CAP_USABLE_GC = 1 << 6, + ITEM_CAP_CAN_GIFT_WRAP = 1 << 7, + ITEM_CAP_USABLE_OUT_OF_GAME = 1 << 8, + ITEM_CAP_CAN_COLLECT = 1 << 9, + ITEM_CAP_CAN_CRAFT_COUNT = 1 << 10, + ITEM_CAP_CAN_CRAFT_MARK = 1 << 11, + ITEM_CAP_PAINTABLE_TEAM_COLORS = 1 << 12, + ITEM_CAP_CAN_BE_RESTORED = 1 << 13, + ITEM_CAP_CAN_USE_STRANGE_PARTS = 1 << 14, + ITEM_CAP_PAINTABLE_UNUSUAL = 1 << 15, + ITEM_CAP_CAN_INCREMENT = 1 << 16, + ITEM_CAP_USES_ESSENCE = 1 << 17, + ITEM_CAP_AUTOGRAPH = 1 << 18, + ITEM_CAP_RECIPE = 1 << 19, + ITEM_CAP_CAN_STICKER = 1 << 20, + ITEM_CAP_STATTRACK_SWAP = 1 << 21, + NUM_ITEM_CAPS = 22, +}; + +enum { ITEM_CAP_DEFAULT = ITEM_CAP_NONE }; +enum { ITEM_CAP_TOOL_DEFAULT = ITEM_CAP_NONE }; + +struct bundleinfo_t +{ + CUtlVector vecItemEntries; +}; + +#ifdef CLIENT_DLL +namespace vgui +{ + class Panel; +} +#endif + +class IEconConsumable +{ + +}; + +class IEconItemInterface; + +class IEconTool +{ + friend class CEconSharedToolSupport; + +public: + IEconTool(const char* pszTypeName, const char* pszUseString, const char* pszUsageRestriction, item_capabilities_t unCapabilities, KeyValues* pUsageKV) + : m_pszTypeName(pszTypeName) + , m_pszUseString(pszUseString) + , m_pszUsageRestriction(pszUsageRestriction) + , m_unCapabilities(unCapabilities) + { + if (pUsageKV) + { + KeyValues* pBonusItemDefs = pUsageKV->FindKey("bonus_itemdefs"); + if (pBonusItemDefs) + { + FOR_EACH_SUBKEY(pBonusItemDefs, pBonusItemDef) + { + m_vecBonusItemDef.AddToTail(atoi(pBonusItemDef->GetName())); + } + } + } + } + + virtual ~IEconTool() { } + + const char* GetUsageRestriction() const { return m_pszUsageRestriction; } + item_capabilities_t GetCapabilities() const { return m_unCapabilities; } + + virtual bool CanApplyTo(const IEconItemInterface* pTool, const IEconItemInterface* pToolSubject) const { Assert(pTool); Assert(pToolSubject); return true; } + virtual bool ShouldDisplayQuantity(const IEconItemInterface* pTool) const; + virtual bool RequiresToolEscrowPeriod() const { return false; } + + virtual bool IsValid() const { return true; } + + const char* GetTypeName() const { return m_pszTypeName; } + const char* GetUseString() const { return m_pszUseString; } + + int GetBonusItemDefCount(void) const { return m_vecBonusItemDef.Count(); } + int GetBonusItemDef(int i) const { return m_vecBonusItemDef[i]; } + + virtual IEconConsumable* CreateEconConsumable() const + { + Assert(!"IEconTool::CreateEconConsumable(): unimplemented call!"); + return NULL; + } + +#ifdef CLIENT_DLL + virtual bool ShouldShowContainedItemPanel(const IEconItemInterface* pItem) const { Assert(!"IEconTool::ShouldShowContainedItemPanel(): we don't expect this to be called on anything besides gifts!"); return false; } + virtual const char* GetUseCommandLocalizationToken(const IEconItemInterface* pItem, const char* pszDefault = "#ApplyOnItem") const; + + virtual void OnClientUseConsumable(class C_EconItemView* pItem) const + { + Assert(!"IEconTool::OnClientUseConsumable(): unimplemented call!"); + } + + virtual void OnClientApplyTool(class C_EconItemView* pTool, class C_EconItemView* pSubject) const + { + Assert(!"IEconTool::OnClientApplyTool(): unimplemented call!"); + } + virtual void OnClientApplyCommit(class C_EconItemView* pTool, class C_EconItemView* pSubject) const + { + Assert(!"IEconTool::OnClientApplyCommit(): unimplemented call!"); + } +#endif + +private: + const char* m_pszTypeName; + const char* m_pszUseString; + const char* m_pszUsageRestriction; + item_capabilities_t m_unCapabilities; + CUtlVector m_vecBonusItemDef; +}; + +enum EItemType +{ + k_EItemTypeNone, + k_EItemTypeCoupon, + k_EItemTypeCampaign, + k_EItemTypeSelfOpeningPurchase, + k_EItemTypeOperationCoin, + k_EItemTypePrestigeCoin, + k_EItemTypeTool, +}; +const char* PchNameFromEItemType(EItemType eType); + +enum EItemSlot +{ + k_EItemSlotNone, + k_EItemSlotMelee, + k_EItemSlotSecondary, + k_EItemSlotSMG, + k_EItemSlotRifle, + k_EItemSlotHeavy, + k_EItemSlotFlair, + k_EItemSlotMusicKit, +}; +const char* PchNameFromEItemSlot(EItemSlot eSlot); +EItemSlot EItemSlotFromName(const char* pchName); + +class CEconItemDefinition : public IEconItemDefinition +{ +public: + CEconItemDefinition(void); + virtual ~CEconItemDefinition(void); + + void PurgeStaticAttributes(void); + +public: + virtual bool BInitFromKV(KeyValues* pKVItem, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); +#if defined(CLIENT_DLL) || defined(GAME_DLL) + virtual bool BInitFromTestItemKVs(int iNewDefIndex, KeyValues* pKVItem, CEconItemSchema& pschema); + virtual void GeneratePrecacheModelStrings(bool bDynamicLoad, CUtlVector* out_pVecModelStrings) const; + virtual void GeneratePrecacheSoundStrings(CUtlVector* out_pVecSoundStrings) const; + virtual void GeneratePrecacheEffectStrings(CUtlVector* out_pVecEffectStrings) const; +#endif + virtual void CopyPolymorphic(const CEconItemDefinition* pSourceDef) { *this = *pSourceDef; } + + bool BInitItemMappings(CEconItemSchema& pschema, CUtlVector* pVecErrors); + + virtual void BInitVisualBlockFromKV(KeyValues* pKVItem, IEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + void BInitStylesBlockFromKV(KeyValues* pKVStyles, CEconItemSchema& pschema, AssetInfo* pAssetInfo, CUtlVector* pVecErrors); + bool BInitAlternateIconsFromKV(KeyValues* pKVAlternateIcons, CEconItemSchema& pschema, AssetInfo* pAssetInfo, CUtlVector* pVecErrors); + + virtual item_definition_index_t GetDefinitionIndex(void) const { return m_nDefIndex; } + const CUtlVector& GetAssociatedItemsDefIndexes() const { return m_nAssociatedItemsDefIndexes; } + virtual const char* GetPrefabName(void) const { return m_szPrefab; } + bool BEnabled(void) const { return m_bEnabled; } + bool BLoadOnDemand(void) const { return m_bLoadOnDemand; } + bool BHasBeenLoaded(void) const { return m_bHasBeenLoaded; } + const char* GetDefinitionName(void) const { return m_pszDefinitionName; } + const char* GetItemClass(void) const { return m_pszItemClassname; } + virtual const char* GetItemBaseName(void) const { return m_pszItemBaseName; } + const char* GetBrassModelOverride(void) const { return m_pszBrassModelOverride; } + virtual const char* GetItemTypeName(void) const { return m_pszItemTypeName; } + virtual uint32 GetItemTypeID(void) const { return m_unItemTypeID; } + uint8 GetMinLevel(void) const { return m_unMinItemLevel; } + uint8 GetMaxLevel(void) const { return m_unMaxItemLevel; } + virtual uint8 GetRarity(void) const { return m_nItemRarity; } + uint8 GetQuality(void) const { return m_nItemQuality; } + uint8 GetForcedQuality(void) const { return m_nForcedItemQuality; } + uint8 GetDefaultDropQuality(void) const { return m_nDefaultDropItemQuality; } + uint8 GetDefaultDropQuantity(void) const { return m_nDefaultDropQuantity; } + KeyValues* GetRawDefinition(void) const { return m_pKVItem; } + const CUtlVector& GetStaticAttributes(void) const { return m_vecStaticAttributes; } + uint32 GetNumConcreteItems() const { return m_unNumConcreteItems; } + int GetSoundMaterialID() const { return m_nSoundMaterialID; } + + bool IsHidden(void) const { return m_bHidden; } + bool IsImported(void) const { return m_bImported; } + bool IsOnePerAccountCDKEY(void) const { return m_bOnePerAccountCDKEY; } + bool IsAllowedInMatch(void) const { return m_bAllowedInThisMatch; } + virtual bool IsBaseItem(void) const { return m_bBaseItem; } + virtual bool IsDefaultSlotItem(void) const { return m_bDefaultSlotItem; } + virtual bool IsBundle(void) const { return m_BundleInfo != NULL; } + bool HasProperName(void) const { return m_bProperName; } + const char* GetClassToken(void) const { return m_pszClassToken; } + const char* GetSlotToken(void) const { return m_pszSlotToken; } + bool ShouldAttachToHands(void) const { return m_bAttachToHands; } + bool ShouldAttachToHandsVMOnly(void) const { return m_bAttachToHandsVMOnly; } + bool ShouldFlipViewmodels(void) const { return m_bFlipViewModel; } + int GetInventoryImagePosition(int iIndex) const { Assert(iIndex >= 0 && iIndex < 2); return m_iInventoryImagePosition[iIndex]; } + int GetInventoryImageSize(int iIndex) const { Assert(iIndex >= 0 && iIndex < 2); return m_iInventoryImageSize[iIndex]; } + int GetDropType(void) const { return m_iDropType; } + const char* GetHolidayRestriction(void) const { return m_pszHolidayRestriction; } + int GetSubType(void) const { return m_iSubType; } + item_capabilities_t GetCapabilities(void) const { return m_iCapabilities; } + void AddItemSet(int nIndex); + const CUtlVector< int >& GetItemSets(void) const; + int GetArmoryRemap(void) const { return m_iArmoryRemap; } + int GetStoreRemap(void) const { return m_iStoreRemap; } + virtual int GetLoadoutSlot(void) const { return 0; } + virtual int GetHeroID(void) const { return 0; } + KeyValues* GetPortraitsKV(void) const { return m_pPortraitsKV; } + KeyValues* GetPortraitKVForModel(const char* pszModelName) const; + + AssetInfo* GetAssetInfo() const { return m_pAssetInfo; } + + bool IsTool() const { return m_pTool != NULL; } + bool IsToolAndNotACrate() const { return (IsTool() && GetEconTool() && V_strcmp(GetEconTool()->GetTypeName(), "supply_crate") != 0); } + const IEconTool* GetEconTool() const { return m_pTool; } + template < class T > + const T* GetTypedEconTool() const { return dynamic_cast(GetEconTool()); } + + virtual bool IsPreviewableInStore() const { return true; } + + const bundleinfo_t* GetBundleInfo(void) const { return m_BundleInfo; } + virtual int GetBundleItemCount(void) const { return m_BundleInfo ? m_BundleInfo->vecItemEntries.Count() : 0; } + virtual int GetBundleItem(int iIndex) const { return m_BundleInfo ? m_BundleInfo->vecItemEntries[iIndex].m_nItemDef : -1; } + virtual int GetBundleItemPaintKitID(int iIndex) const { return m_BundleInfo ? m_BundleInfo->vecItemEntries[iIndex].m_nPaintKit : -1; } + + const CUtlVector< const CEconItemDefinition* >& GetContainingBundles() const { return m_vecContainingBundleItemDefs; } + uint32 GetContainingBundleCount() const { return m_vecContainingBundleItemDefs.Count(); } + + typedef CUtlVector< uint32 > WorkshopContributorList_t; + + void AddSteamWorkshopContributor(uint32 unAccountID) { if (m_vecSteamWorkshopContributors.InvalidIndex() == m_vecSteamWorkshopContributors.Find(unAccountID)) { m_vecSteamWorkshopContributors.AddToTail(unAccountID); } } + const WorkshopContributorList_t& GetSteamWorkshopContributors() const { return m_vecSteamWorkshopContributors; } + bool BIsSteamWorkshopItem() const { return m_vecSteamWorkshopContributors.Count() > 0; } + + const char* GetIconClassname(void) const { return m_pszItemIconClassname; } + const char* GetLogClassname(void) const { return m_pszItemLogClassname; } + const char* GetInventoryModel(void) const { return m_pszInventoryModel; } + virtual const char* GetInventoryImage(void) const { return m_pszInventoryImage; } + const char* GetInventoryOverlayImage(int idx) const { if (m_pszInventoryOverlayImages.IsValidIndex(idx)) return m_pszInventoryOverlayImages[idx]; else return NULL; } + int GetInventoryOverlayImageCount(void) const { return m_pszInventoryOverlayImages.Count(); } + const char* GetIconURLSmall() const { return m_sIconURLSmall; } + const char* GetIconURLLarge() const { return m_sIconURLLarge; } + void SetIconURLSmall(const char* szURL) { m_sIconURLSmall = szURL; } + void SetIconURLLarge(const char* szURL) { m_sIconURLLarge = szURL; } + virtual const char* GetBasePlayerDisplayModel() const { return m_pszBaseDisplayModel; } + virtual const char* GetWorldDisplayModel() const { return m_pszWorldDisplayModel; } + virtual const char* GetWorldDroppedModel() const { return m_pszWorldDroppedModel; } + + virtual const char* GetIconDisplayModel() const; + virtual const char* GetBuyMenuDisplayModel() const; + virtual const char* GetPedestalDisplayModel() const; + virtual const char* GetMagazineModel() const; + virtual const char* GetScopeLensMaskModel() const; + virtual const char* GetUidModel() const; + virtual const char* GetStatTrakModelByType(uint32 nType) const; + + virtual const int GetNumSupportedStickerSlots() const; + virtual const char* GetStickerSlotModelBySlotIndex(uint32 nIndex) const; + virtual const Vector& GetStickerSlotWorldProjectionStartBySlotIndex(uint32 nIndex) const; + virtual const Vector& GetStickerSlotWorldProjectionEndBySlotIndex(uint32 nIndex) const; + virtual const char* GetStickerWorldModelBoneParentNameBySlotIndex(uint32 nIndex) const; + virtual const char* GetStickerSlotMaterialBySlotIndex(uint32 nIndex) const; + virtual const char* GetIconDefaultImage() const { return m_pszIconDefaultImage; } + virtual const char* GetExtraWearableModel(void) const { return m_pszWorldExtraWearableModel; } + virtual const char* GetParticleFile(void) const { return m_pszParticleFile; } + virtual const char* GetParticleSnapshotFile(void) const { return m_pszParticleSnapshotFile; } + const CUtlVector< WeaponPaintableMaterial_t >* GetPaintData(void) const { return &m_PaintData; } + const InventoryImageData_t* GetInventoryImageData(void) const { return m_pInventoryImageData; } + virtual const char* GetItemDesc(void) const { return m_pszItemDesc; } + const char* GetArmoryDescString(void) const { return m_pszArmoryDesc; } + RTime32 GetExpirationDate(void) const { return m_rtExpiration; } + RTime32 GetDefCreationDate(void) const { return m_rtDefCreation; } + bool ShouldShowInArmory(void) const { return m_bShouldShowInArmory; } + bool IsActingAsAWearable(void) const { return m_bActAsWearable; } + bool GetHideBodyGroupsDeployedOnly(void) const { return m_bHideBodyGroupsDeployedOnly; } + virtual bool IsPackBundle(void) const { return m_bIsPackBundle; } + virtual bool IsPackItem(void) const { return NULL != m_pOwningPackBundle; } + CEconItemDefinition* GetOwningPackBundle() { return m_pOwningPackBundle; } + const CEconItemDefinition* GetOwningPackBundle() const { return m_pOwningPackBundle; } +#if ECONITEM_DATABASE_AUDIT_TABLES_FEATURE + const char* GetDatabaseAuditTableName(void) const { return m_pszDatabaseAuditTable; } +#endif + const char* GetAlternateIcon(int iAlternateIcon) const; + + equip_region_mask_t GetEquipRegionMask(void) const { return m_unEquipRegionMask; } + equip_region_mask_t GetEquipRegionConflictMask(void) const { return m_unEquipRegionConflictMask; } + + void SetAllowedInMatch(bool bAllowed) { m_bAllowedInThisMatch = bAllowed; } + void SetHasBeenLoaded(bool bLoaded) { m_bHasBeenLoaded = bLoaded; } + + bool BRandomProxy(void) const { return NULL != m_pProxyCriteria; } + CItemSelectionCriteria* PProxyCriteria(void) const { return m_pProxyCriteria; } + + uint32 RollItemLevel(void) const; + + const char* GetFirstSaleDate(void) const; + + virtual bool IsRecent(void) const { return false; } + + void IterateAttributes(class IEconItemAttributeIterator* pIterator) const; + +#if defined(CLIENT_DLL) || defined(GAME_DLL) + int GetNumAttachedModels() const; + attachedmodel_t* GetAttachedModelData(int iIdx) const; + int GetNumAttachedParticles() const; + attachedparticlesystem_t* GetAttachedParticleData(int iIdx) const; + bool IsAttachedParticleDataValidForStyle(int iIdx, int nStyle) const; + int GetNumAnimations() const; + animation_on_wearable_t* GetAnimationData(int iIdx) const; + int GetNumAnimationModifiers() const; + const char* GetAnimationModifier(int iIdx) const; + + Activity GetActivityOverride(Activity baseAct) const; + const char* GetReplacementForActivityOverride(Activity baseAct) const; + int GetNumSounds() const; + sound_on_wearable_t* GetSoundData(int iIdx) const; + const char* GetReplacementSound(const char* pszSoundName) const; + int GetNumParticles() const; + particle_on_wearable_t* GetParticleData(int iIdx) const; + const char* GetReplacementParticleEffect(const char* pszParticleName) const; + int GetNumParticleSnapshots() const; + particlesnapshot_on_wearable_t* GetParticleSnapshotData(int iIdx) const; + const char* GetReplacementParticleSnapshot(const char* pszParticleSnapshotName) const; + + int GetNumParticleControlPoints() const; + particle_control_point_on_wearable_t* GetParticleControlPointData(int iIdx) const; + + bool GetReplacementControlPoint(int nIndex, const char* pszParticleName, int& nOutputCP, Vector& nCPValue) const; + + virtual bool IsContentStreamable() const; + + const char* GetAnnouncerName() const; + const char* GetAnnouncerResource() const; + + const char* GetEntityOverrideModel() const; + const char* GetViewOverrideModel() const; + const char* GetEntityOverrideClass() const; + + const char* GetHeroModelChangeModel() const; + + const char* GetUIOverrideIcon() const; + const char* GetUIOverrideOriginalIcon() const; + + const char* GetUIOverrideAbilityIcon(const char* pszAbilityName) const; + + const char* GetScaleOverrideClass() const; + float GetScaleOverrideSize() const; + + bool SkipModelCombine(void) const; + + const char* GetMuzzleFlash() const; + const char* GetTracerEffect() const; + const char* GetParticleEffect() const; + const char* GetParticleSnapshot() const; + const char* GetMaterialOverride() const; + const char* GetCustomSound(int iSound) const; + const char* GetWeaponReplacementSound( int iSound) const; + + const char* GetPrimaryAmmo(void) const; + const char* GetWeaponTypeString(void) const; + const char* GetAddonLocation(void) const; + const char* GetEjectBrassEffect(void) const; + const char* GetMuzzleFlashEffect1stPerson(void) const; + const char* GetMuzzleFlashEffect1stPersonAlt(void) const; + const char* GetMuzzleFlashEffect3rdPerson(void) const; + const char* GetMuzzleFlashEffect3rdPersonAlt(void) const; + const char* GetHeatEffect(void) const; + const char* GetPlayerAnimationExtension(void) const; + + int GetHiddenParentBodygroup() const; + int GetNumModifiedBodyGroups() const; + const char* GetModifiedBodyGroup(int i, int& body) const; + bool UsesPerClassBodygroups() const; + int GetNumCodeControlledBodyGroups() const; + const char* GetCodeControlledBodyGroup(int i, struct codecontrolledbodygroupdata_t& ccbgd) const; + + int GetViewmodelBodygroupOverride() const; + int GetViewmodelBodygroupStateOverride() const; + int GetWorldmodelBodygroupOverride() const; + int GetWorldmodelBodygroupStateOverride() const; + +#endif + + style_index_t GetNumStyles() const; + const CEconStyleInfo* GetStyleInfo(style_index_t unStyle) const; + + + int GetPopularitySeed() const { return m_nPopularitySeed; } + + bool HasEconTag(econ_tag_handle_t tag) const { return m_vecTags.IsValidIndex(m_vecTags.Find(tag)); } + + bool ShoulDisableStyleSelector(void) const { return m_bDisableStyleSelection; } + +#if defined(CLIENT_DLL) || defined(GAME_DLL) + int GetStyleSkin(style_index_t unStyle) const; +#endif + + virtual bool IsPublicItem(void) const { return m_bPublicItem; } + virtual bool IgnoreInCollectionView(void) const { return m_bIgnoreInCollectionView; } + + const char* GetLootListName(void) const { return m_pszLootListName; } + + + EItemType GetItemType() const { return m_eItemType; } + bool GetAllowPurchaseStandalone() const { return m_bAllowPurchaseStandalone; } + +private: + KeyValues* m_pKVItem; + + item_definition_index_t m_nDefIndex; + + CUtlVector< item_definition_index_t > m_nAssociatedItemsDefIndexes; + + bool m_bEnabled; + + const char* m_szPrefab; + + uint8 m_unMinItemLevel; + uint8 m_unMaxItemLevel; + + uint8 m_nItemRarity; + + uint8 m_nItemQuality; + uint8 m_nForcedItemQuality; + uint8 m_nDefaultDropItemQuality; + + uint8 m_nDefaultDropQuantity; + + CUtlVector m_vecStaticAttributes; + + uint8 m_nPopularitySeed; + + KeyValues* m_pPortraitsKV; + + const char* m_pszItemBaseName; + bool m_bProperName; + const char* m_pszItemTypeName; + + uint32 m_unItemTypeID; + + const char* m_pszItemDesc; + + RTime32 m_rtExpiration; + + RTime32 m_rtDefCreation; + + const char* m_pszInventoryModel; + const char* m_pszInventoryImage; + CUtlVector m_pszInventoryOverlayImages; + int m_iInventoryImagePosition[2]; + int m_iInventoryImageSize[2]; + + const char* m_pszBaseDisplayModel; + bool m_bLoadOnDemand; + bool m_bHasBeenLoaded; + + bool m_bHideBodyGroupsDeployedOnly; + + const char* m_pszWorldDisplayModel; + const char* m_pszWorldExtraWearableModel; + + const char* m_pszWorldDroppedModel; + char m_szWorldDroppedModel[80]; + + CUtlVector m_vStickerModels; + + const char* m_pszIconDefaultImage; + + bool m_bAttachToHands; + bool m_bAttachToHandsVMOnly; + + bool m_bFlipViewModel; + + bool m_bActAsWearable; + + mutable CUtlVector< int > m_iItemSets; + + AssetInfo* m_pAssetInfo; + + EItemType m_eItemType; + bool m_bAllowPurchaseStandalone; + + const char* m_pszBrassModelOverride; + + IEconTool* m_pTool; + bundleinfo_t* m_BundleInfo; + item_capabilities_t m_iCapabilities; + + uint32 m_unNumConcreteItems; + + int m_nSoundMaterialID; + + bool m_bDisableStyleSelection; + + CUtlString m_sIconURLSmall; + CUtlString m_sIconURLLarge; + + const char* m_pszParticleFile; + const char* m_pszParticleSnapshotFile; + + const char* m_pszLootListName; + + CUtlVector m_nCharacterPaintKitIndices; + +protected: + CUtlVector< WeaponPaintableMaterial_t > m_PaintData; + InventoryImageData_t* m_pInventoryImageData; + +private: + + const char* m_pszItemClassname; + + const char* m_pszItemLogClassname; + + const char* m_pszItemIconClassname; + + const char* m_pszDefinitionName; + +#if ECONITEM_DATABASE_AUDIT_TABLES_FEATURE + const char* m_pszDatabaseAuditTable; +#endif + + bool m_bHidden; + bool m_bShouldShowInArmory; + bool m_bBaseItem; + bool m_bDefaultSlotItem; + bool m_bImported; + bool m_bOnePerAccountCDKEY; + + bool m_bIsPackBundle; + + CEconItemDefinition* m_pOwningPackBundle; + + const char* m_pszArmoryDesc; + + int m_iArmoryRemap; + int m_iStoreRemap; + const char* m_pszArmoryRemap; + const char* m_pszStoreRemap; + + const char* m_pszClassToken; + const char* m_pszSlotToken; + + int m_iDropType; + + const char* m_pszHolidayRestriction; + + int m_iSubType; + + bool m_bAllowedInThisMatch; + + CItemSelectionCriteria* m_pProxyCriteria; + + equip_region_mask_t m_unEquipRegionMask; + equip_region_mask_t m_unEquipRegionConflictMask; + + CUtlMap* m_pMapAlternateIcons; + + CUtlVector m_vecTags; + CUtlVector m_vecContainingBundleItemDefs; + WorkshopContributorList_t m_vecSteamWorkshopContributors; + + friend class CEconItemSchema; + bool m_bPublicItem; + bool m_bIgnoreInCollectionView; +}; + +inline style_index_t CEconItemDefinition::GetNumStyles() const +{ + const AssetInfo* pAssetInfo = GetAssetInfo(); + + if (!pAssetInfo) + return 0; + + return pAssetInfo->m_Styles.Count(); +} + +inline const CEconStyleInfo* CEconItemDefinition::GetStyleInfo(style_index_t unStyle) const +{ + const AssetInfo* pAssetInfo = GetAssetInfo(); + if (!pAssetInfo || !pAssetInfo->m_Styles.IsValidIndex(unStyle)) + return NULL; + + return pAssetInfo->m_Styles[unStyle]; +} + +#if defined(CLIENT_DLL) || defined(GAME_DLL) +inline int CEconItemDefinition::GetNumAttachedModels() const +{ + if (!GetAssetInfo()) + return 0; + + return GetAssetInfo()->m_AttachedModels.Count(); +} + +inline attachedmodel_t* CEconItemDefinition::GetAttachedModelData(int iIdx) const +{ + if (!GetAssetInfo()) + return NULL; + + Assert(iIdx < GetAssetInfo()->m_AttachedModels.Count()); + if (iIdx >= GetAssetInfo()->m_AttachedModels.Count()) + return NULL; + + return &GetAssetInfo()->m_AttachedModels[iIdx]; +} + +inline int CEconItemDefinition::GetNumAnimations() const +{ + if (!GetAssetInfo()) + return 0; + + return GetAssetInfo()->m_Animations.Count(); +} + +inline animation_on_wearable_t* CEconItemDefinition::GetAnimationData(int iIdx) const +{ + if (!GetAssetInfo()) + return NULL; + + Assert(iIdx < GetAssetInfo()->m_Animations.Count()); + if (iIdx < 0 || iIdx >= GetAssetInfo()->m_Animations.Count()) + return NULL; + + return &GetAssetInfo()->m_Animations[iIdx]; +} + +inline int CEconItemDefinition::GetNumAnimationModifiers() const +{ + if (!GetAssetInfo()) + return 0; + + return GetAssetInfo()->m_vecAnimationModifiers.Count(); +} + +inline const char* CEconItemDefinition::GetAnimationModifier(int iIdx) const +{ + if (!GetAssetInfo()) + return NULL; + + if (iIdx < 0 || iIdx >= GetAssetInfo()->m_vecAnimationModifiers.Count()) + return NULL; + + return GetAssetInfo()->m_vecAnimationModifiers[iIdx]; +} + +inline const char* CEconItemDefinition::GetAnnouncerName() const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszAnnouncerName; +} + +inline const char* CEconItemDefinition::GetAnnouncerResource() const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszAnnouncerResource; +} + +inline const char* CEconItemDefinition::GetUIOverrideIcon() const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszNewIcon; +} + +inline const char* CEconItemDefinition::GetUIOverrideOriginalIcon() const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszOriginalIcon; +} + +inline const char* CEconItemDefinition::GetUIOverrideAbilityIcon(const char* pszAbilityName) const +{ + if (!pszAbilityName) + return NULL; + + if (!GetAssetInfo()) + return NULL; + + FOR_EACH_VEC(GetAssetInfo()->m_vecAbilityIconReplacements, i) + { + ability_icon_replacement_t* pszAbilityReplacement = &GetAssetInfo()->m_vecAbilityIconReplacements.Element(i); + if (pszAbilityReplacement) + { + if (!Q_strcmp(pszAbilityName, pszAbilityReplacement->m_strAbilityName)) + { + return pszAbilityReplacement->m_strReplacement; + } + } + } + + return NULL; +} + +inline const char* CEconItemDefinition::GetEntityOverrideModel() const +{ + if (!GetAssetInfo()) + return NULL; + + CUtlVector* pAssetModifierList = GetAssetInfo()->GetAssetModifiers(AM_EntityModel); + if (pAssetModifierList && pAssetModifierList->Count() > 0) + return pAssetModifierList->Element(0)->m_strModifier.String(); + + return NULL; +} + +inline const char* CEconItemDefinition::GetViewOverrideModel() const +{ + if (!GetAssetInfo()) + return NULL; + + CUtlVector* pAssetModifierList = GetAssetInfo()->GetAssetModifiers(AM_ViewModel); + if (pAssetModifierList && pAssetModifierList->Count() > 0) + return pAssetModifierList->Element(0)->m_strModifier.String(); + + return NULL; +} + +inline const char* CEconItemDefinition::GetEntityOverrideClass() const +{ + if (!GetAssetInfo()) + return NULL; + + CUtlVector* pAssetModifierList = GetAssetInfo()->GetAssetModifiers(AM_EntityModel); + if (pAssetModifierList && pAssetModifierList->Count() > 0) + return pAssetModifierList->Element(0)->m_strAsset.String(); + + return NULL; +} + +inline const char* CEconItemDefinition::GetScaleOverrideClass() const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszScaleClass; +} + +inline const char* CEconItemDefinition::GetHeroModelChangeModel() const +{ + if (!GetAssetInfo()) + return NULL; + + CUtlVector* pAssetModifierList = GetAssetInfo()->GetAssetModifiers(AM_HeroModelChange); + if (pAssetModifierList && pAssetModifierList->Count() > 0) + return pAssetModifierList->Element(0)->m_strModifier.String(); + + return NULL; +} + +inline float CEconItemDefinition::GetScaleOverrideSize() const +{ + if (!GetAssetInfo()) + return 0.0f; + + return GetAssetInfo()->m_flScaleSize; +} + +inline bool CEconItemDefinition::SkipModelCombine(void) const +{ + if (!GetAssetInfo()) + return false; + + return GetAssetInfo()->m_bSkipModelCombine; +} + +inline int CEconItemDefinition::GetNumSounds() const +{ + if (!GetAssetInfo()) + return 0; + + return GetAssetInfo()->m_Sounds.Count(); +} + +inline sound_on_wearable_t* CEconItemDefinition::GetSoundData(int iIdx) const +{ + if (!GetAssetInfo()) + return NULL; + + Assert(iIdx < GetAssetInfo()->m_Sounds.Count()); + if (iIdx >= GetAssetInfo()->m_Sounds.Count()) + return NULL; + + return &GetAssetInfo()->m_Sounds[iIdx]; +} + +inline int CEconItemDefinition::GetNumParticles() const +{ + if (!GetAssetInfo()) + return 0; + + return GetAssetInfo()->m_Particles.Count(); +} + +inline particle_on_wearable_t* CEconItemDefinition::GetParticleData(int iIdx) const +{ + if (!GetAssetInfo()) + return NULL; + + Assert(iIdx < GetAssetInfo()->m_Particles.Count()); + if (iIdx >= GetAssetInfo()->m_Particles.Count()) + return NULL; + + return &GetAssetInfo()->m_Particles[iIdx]; +} + +inline int CEconItemDefinition::GetNumParticleSnapshots() const +{ + if (!GetAssetInfo()) + return 0; + + return GetAssetInfo()->m_ParticleSnapshots.Count(); +} + +inline particlesnapshot_on_wearable_t* CEconItemDefinition::GetParticleSnapshotData(int iIdx) const +{ + if (!GetAssetInfo()) + return NULL; + + Assert(iIdx < GetAssetInfo()->m_ParticleSnapshots.Count()); + if (iIdx >= GetAssetInfo()->m_ParticleSnapshots.Count()) + return NULL; + + return &GetAssetInfo()->m_ParticleSnapshots[iIdx]; +} + +inline int CEconItemDefinition::GetNumParticleControlPoints() const +{ + if (!GetAssetInfo()) + return 0; + + return GetAssetInfo()->m_ParticleControlPoints.Count(); +} + +inline particle_control_point_on_wearable_t* CEconItemDefinition::GetParticleControlPointData(int iIdx) const +{ + if (!GetAssetInfo()) + return NULL; + + Assert(iIdx < GetAssetInfo()->m_ParticleControlPoints.Count()); + if (iIdx >= GetAssetInfo()->m_ParticleControlPoints.Count()) + return NULL; + + return &GetAssetInfo()->m_ParticleControlPoints[iIdx]; +} + +inline int CEconItemDefinition::GetNumAttachedParticles() const +{ + if (!GetAssetInfo()) + return 0; + + return GetAssetInfo()->m_AttachedParticles.Count(); +} + +inline const char* CEconItemDefinition::GetMaterialOverride() const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszMaterialOverride; +} + + +inline const char* CEconItemDefinition::GetMuzzleFlash() const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszMuzzleFlash; +} + +inline const char* CEconItemDefinition::GetTracerEffect() const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszTracerEffect; +} + +inline const char* CEconItemDefinition::GetParticleEffect() const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszParticleEffect; +} + +inline const char* CEconItemDefinition::GetParticleSnapshot() const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszParticleSnapshot; +} + +inline int CEconItemDefinition::GetHiddenParentBodygroup() const +{ + if (!GetAssetInfo()) + return -1; + + return GetAssetInfo()->iHideParentBodyGroup; +} + +inline int CEconItemDefinition::GetNumModifiedBodyGroups() const +{ + if (!GetAssetInfo()) + return -1; + + return GetAssetInfo()->m_ModifiedBodyGroupNames.Count(); +} + +inline const char* CEconItemDefinition::GetModifiedBodyGroup(int i, int& body) const +{ + if (!GetAssetInfo()) + return NULL; + + body = GetAssetInfo()->m_ModifiedBodyGroupNames[i]; + return GetAssetInfo()->m_ModifiedBodyGroupNames.Key(i); +} + +inline int CEconItemDefinition::GetNumCodeControlledBodyGroups() const +{ + if (!GetAssetInfo()) + return -1; + + return GetAssetInfo()->m_CodeControlledBodyGroupNames.Count(); +} + +inline const char* CEconItemDefinition::GetCodeControlledBodyGroup(int i, codecontrolledbodygroupdata_t& ccbgd) const +{ + if (!GetAssetInfo()) + return NULL; + + ccbgd = GetAssetInfo()->m_CodeControlledBodyGroupNames[i]; + return GetAssetInfo()->m_CodeControlledBodyGroupNames.Key(i); +} + +#if defined(CLIENT_DLL) || defined(GAME_DLL) +inline int CEconItemDefinition::GetStyleSkin(style_index_t unStyle) const +{ + const CEconStyleInfo* pStyle = GetStyleInfo(unStyle); + + return pStyle + ? pStyle->GetSkin() + : -1; +} +#endif + +inline int CEconItemDefinition::GetViewmodelBodygroupOverride() const +{ + if (!GetAssetInfo()) + return 0; + + return GetAssetInfo()->m_iViewModelBodyGroupOverride; +} + +inline int CEconItemDefinition::GetViewmodelBodygroupStateOverride() const +{ + if (!GetAssetInfo()) + return 0; + + return GetAssetInfo()->m_iViewModelBodyGroupStateOverride; +} + +inline int CEconItemDefinition::GetWorldmodelBodygroupOverride() const +{ + if (!GetAssetInfo()) + return 0; + + return GetAssetInfo()->m_iWorldModelBodyGroupOverride; +} + +inline int CEconItemDefinition::GetWorldmodelBodygroupStateOverride() const +{ + if (!GetAssetInfo()) + return 0; + + return GetAssetInfo()->m_iWorldModelBodyGroupStateOverride; +} + +inline bool CEconItemDefinition::UsesPerClassBodygroups() const +{ + if (!GetAssetInfo()) + return false; + + return GetAssetInfo()->bUsePerClassBodygroups; +} + +inline const char* CEconItemDefinition::GetCustomSound(int iSound) const +{ + if (!GetAssetInfo()) + return NULL; + if (iSound < 0 || iSound >= MAX_VISUALS_CUSTOM_SOUNDS) + return NULL; + return GetAssetInfo()->m_pszCustomSounds[iSound]; +} + +inline const char* CEconItemDefinition::GetWeaponReplacementSound( int iSound) const +{ + if (!GetAssetInfo()) + return NULL; + if (iSound < 0 || iSound >= NUM_SHOOT_SOUND_TYPES) + return NULL; + return GetAssetInfo()->m_pszWeaponSoundReplacements[iSound]; +} + +inline const char* CEconItemDefinition::GetPrimaryAmmo(void) const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszPrimaryAmmo; +} + +inline const char* CEconItemDefinition::GetWeaponTypeString(void) const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszWeaponTypeString; +} + +inline const char* CEconItemDefinition::GetAddonLocation(void) const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszAddonLocation; +} + +inline const char* CEconItemDefinition::GetEjectBrassEffect(void) const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszEjectBrassEffect; +} + +inline const char* CEconItemDefinition::GetMuzzleFlashEffect1stPerson(void) const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszMuzzleFlashEffect1stPerson; +} + +inline const char* CEconItemDefinition::GetMuzzleFlashEffect1stPersonAlt(void) const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszMuzzleFlashEffect1stPersonAlt; +} + +inline const char* CEconItemDefinition::GetMuzzleFlashEffect3rdPerson(void) const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszMuzzleFlashEffect3rdPerson; +} + +inline const char* CEconItemDefinition::GetMuzzleFlashEffect3rdPersonAlt(void) const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszMuzzleFlashEffect3rdPersonAlt; +} + +inline const char* CEconItemDefinition::GetHeatEffect(void) const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszHeatEffect; +} + +inline const char* CEconItemDefinition::GetPlayerAnimationExtension(void) const +{ + if (!GetAssetInfo()) + return NULL; + + return GetAssetInfo()->m_pszPlayerAnimationExtension; +} + +#endif + +class CTimedItemRewardDefinition +{ +public: + CTimedItemRewardDefinition(void); + CTimedItemRewardDefinition(const CTimedItemRewardDefinition& that); + CTimedItemRewardDefinition& operator=(const CTimedItemRewardDefinition& rhs); + + ~CTimedItemRewardDefinition(void); + + bool BInitFromKV(KeyValues* pKVTimedReward, CEconItemSchema& pschema, CUtlVector* pVecErrors = NULL); + + uint32 GetRandomFrequency(void) const { return RandomFloat(m_unMinFreq, m_unMaxFreq); } + uint32 GetMinFrequency(void) const { return m_unMinFreq; } + uint32 GetMaxFrequency(void) const { return m_unMaxFreq; } + + float GetChance(void) const; + RTime32 GetForcedBaselineAdjustmentTime(void) const { return m_rtForcedBaselineAdjustment; } + RTime32 GetForcedLastDropAdjustmentTime(void) const { return m_rtForcedLastDropTimeAdjustment; } + uint32 GetHoursInRewardPeriod(void) const { return m_unHoursInRewardPeriod; } + uint32 GetHoursBetweenDropsRealtime(void) const { return m_unHoursBetweenDropsRealtime; } + uint32 GetTotalPointsForPeriod(float flHoursOfPlaytimeInPeriod) const + { + float flHours = flHoursOfPlaytimeInPeriod; + if (flHours <= 0.0f) + return 0; + + uint32 unPoints = 0; + uint32 numPointsToProrate = 0; + uint32 nHoursPlayed = (uint32)flHours; + if (!nHoursPlayed) + { + numPointsToProrate = (m_arrTotalPointsBasedOnHoursPlayed.Count()) ? m_arrTotalPointsBasedOnHoursPlayed.Head() : m_unPointsPerHourOverplayed; + } + else if (uint32 numHoursToCreditFromTable = MIN(nHoursPlayed, (uint32)m_arrTotalPointsBasedOnHoursPlayed.Count())) + { + nHoursPlayed -= numHoursToCreditFromTable; + flHours -= numHoursToCreditFromTable; + unPoints += m_arrTotalPointsBasedOnHoursPlayed[numHoursToCreditFromTable - 1]; + numPointsToProrate = (numHoursToCreditFromTable < (uint32)m_arrTotalPointsBasedOnHoursPlayed.Count()) + ? (m_arrTotalPointsBasedOnHoursPlayed[numHoursToCreditFromTable] - m_arrTotalPointsBasedOnHoursPlayed[numHoursToCreditFromTable - 1]) + : m_unPointsPerHourOverplayed; + } + + if (nHoursPlayed) + { + unPoints += nHoursPlayed * m_unPointsPerHourOverplayed; + numPointsToProrate = m_unPointsPerHourOverplayed; + flHours -= nHoursPlayed; + } + + unPoints += flHours * numPointsToProrate; + return unPoints; + } + uint32 GetPointsPerPeriodRollover(void) const { return m_unPointsPerPeriodRollover; } + + const CItemSelectionCriteria& GetCriteria(void) const { return m_criteria; } + int GetLootListCount(void) const { return m_arrLootLists.Count(); } + const CEconLootListDefinition* GetLootList(int iLootListIdx = 0) const { return m_arrLootLists.IsValidIndex(iLootListIdx) ? m_arrLootLists[iLootListIdx] : NULL; } +private: + uint32 m_unMinFreq; + uint32 m_unMaxFreq; + + RTime32 m_rtForcedBaselineAdjustment; + RTime32 m_rtForcedLastDropTimeAdjustment; + uint32 m_unHoursInRewardPeriod; + uint32 m_unHoursBetweenDropsRealtime; + CUtlVector< uint32 > m_arrTotalPointsBasedOnHoursPlayed; + uint32 m_unPointsPerHourOverplayed; + uint32 m_unPointsPerPeriodRollover; + + float m_flChance; + + + CItemSelectionCriteria m_criteria; + CUtlVector< const CEconLootListDefinition* > m_arrLootLists; + + CUtlVector< const CEconLootListDefinition* > m_arrDynamicLootLists; +}; + +class CItemLevelingDefinition +{ +public: + CItemLevelingDefinition(void); + CItemLevelingDefinition(const CItemLevelingDefinition& that); + CItemLevelingDefinition& operator=(const CItemLevelingDefinition& rhs); + + ~CItemLevelingDefinition(void); + + bool BInitFromKV(KeyValues* pKVItemLevel, CEconItemSchema& pschema, const char* pszLevelBlockName, CUtlVector* pVecErrors = NULL); + + uint32 GetLevel(void) const { return m_unLevel; } + uint32 GetRequiredScore(void) const { return m_unRequiredScore; } + const char* GetNameLocalizationKey(void) const { return m_pszLocalizedName_LocalStorage; } + +private: + uint32 m_unLevel; + uint32 m_unRequiredScore; + char* m_pszLocalizedName_LocalStorage; +}; + +struct AchievementAward_t +{ + AchievementAward_t(const AchievementAward_t& rhs) + : m_sNativeName(rhs.m_sNativeName), + m_unSourceAppId(rhs.m_unSourceAppId), + m_unAuditData(rhs.m_unAuditData) + { + m_vecDefIndex.CopyArray(rhs.m_vecDefIndex.Base(), rhs.m_vecDefIndex.Count()); + } + AchievementAward_t() {} + + CUtlString m_sNativeName; + AppId_t m_unSourceAppId; + uint32 m_unAuditData; + CUtlVector m_vecDefIndex; +}; + +enum eTimedRewardType +{ + kTimedRewards_Reward, + kTimedRewards_PremiumTimedDrop, + kTimedRewards_Crate, + kTimedRewards_Operation, + kTimedRewards_Capsule, + kTimedRewards_Quest, + kTimedRewards_FreeSprayDropsOct2016, + kNumTimedRewards +}; + +struct kill_eater_score_type_t +{ + int32 m_nValue; + const char* m_pszTypeString; + const char* m_pszModelAttributeString; + const char* m_pszLevelBlockName; + bool m_bUseLevelBlock; +}; + +class CWebResource +{ +public: + CWebResource() : m_bOnDemand(false), m_pKeyValues(NULL), m_fnLoadCallback(NULL) {} + CWebResource(const CWebResource& other) + { + m_strName = other.m_strName; + m_strURL = other.m_strURL; + m_bOnDemand = other.m_bOnDemand; + m_pKeyValues = other.m_pKeyValues->MakeCopy(); + m_fnLoadCallback = other.m_fnLoadCallback; + } + ~CWebResource() { m_pKeyValues->deleteThis(); } + + CUtlString m_strName; + CUtlString m_strURL; + bool m_bOnDemand; + KeyValues* m_pKeyValues; + void (*m_fnLoadCallback)(const char*, KeyValues*); + + static bool s_Initialized; +}; + +class CForeignAppImports +{ +public: + CForeignAppImports() : m_mapDefinitions(DefLessFunc(uint16)) {} + + void AddMapping(uint16 unForeignDefIndex, const CEconItemDefinition* pDefn); + const CEconItemDefinition* FindMapping(uint16 unForeignDefIndex) const; + +private: + CUtlMap< uint16, const CEconItemDefinition*> m_mapDefinitions; +}; + +class ISchemaAttributeType +{ +public: + virtual ~ISchemaAttributeType() { } + + virtual unsigned int GetTypeUniqueIdentifier() const = 0; + + virtual void LoadEconAttributeValue(CEconItem* pTargetItem, const CEconItemAttributeDefinition* pAttrDef, const union attribute_data_union_t& value) const = 0; + + virtual void ConvertEconAttributeValueToByteStream(const union attribute_data_union_t& value, std::string* out_psBytes) const = 0; + + virtual bool BConvertStringToEconAttributeValue(const CEconItemAttributeDefinition* pAttrDef, const char* pszValue, union attribute_data_union_t* out_pValue) const = 0; + + virtual void ConvertEconAttributeValueToString(const CEconItemAttributeDefinition* pAttrDef, const attribute_data_union_t& value, std::string* out_ps) const = 0; + + virtual void LoadByteStreamToEconAttributeValue(CEconItem* pTargetItem, const CEconItemAttributeDefinition* pAttrDef, const std::string& sBytes) const = 0; + + virtual void InitializeNewEconAttributeValue(attribute_data_union_t* out_pValue) const = 0; + + virtual void UnloadEconAttributeValue(union attribute_data_union_t* out_pValue) const = 0; + + virtual bool OnIterateAttributeValue(class IEconItemAttributeIterator* pIterator, const CEconItemAttributeDefinition* pAttrDef, const attribute_data_union_t& value) const = 0; + + virtual bool BSupportsGameplayModificationAndNetworking() const { return false; } +}; + + + + +struct CAppliedStickerInfo_t +{ + int nID; + float flWearMin; + float flWearMax; + float flScale; + float flRotate; +}; + +class CStickerKit +{ +public: + + CStickerKit(const CStickerKit& rhs) + : sName(rhs.sName), + sDescriptionString(rhs.sDescriptionString), + sItemName(rhs.sItemName), + sMaterialPath(rhs.sMaterialPath), + m_strInventoryImage(rhs.m_strInventoryImage) + { + nID = rhs.nID; + nRarity = rhs.nRarity; + flRotateStart = rhs.flRotateStart; + flRotateEnd = rhs.flRotateEnd; + flScaleMin = rhs.flScaleMin; + flScaleMax = rhs.flScaleMax; + flWearMin = rhs.flWearMin; + flWearMax = rhs.flWearMax; + bMaterialPathIsAbsolute = rhs.bMaterialPathIsAbsolute; + + m_nEventID = rhs.m_nEventID; + m_nEventTeamID = rhs.m_nEventTeamID; + m_nPlayerID = rhs.m_nPlayerID; + + m_pKVItem = rhs.m_pKVItem ? rhs.m_pKVItem->MakeCopy() : NULL; + } + + CStickerKit(void) + { + nID = 0; + nRarity = 1; + flRotateStart = 0.0f; + flRotateEnd = 0.0f; + flScaleMax = flScaleMin = 1.0f; + flWearMin = 0.0f; + flWearMax = 1.0f; + bMaterialPathIsAbsolute = false; + + m_nEventID = 0; + m_nEventTeamID = 0; + m_nPlayerID = 0; + + m_pKVItem = NULL; + } + + ~CStickerKit() + { + if (m_pKVItem) + m_pKVItem->deleteThis(); + m_pKVItem = NULL; + } + + bool InitFromKeyValues(KeyValues* pKVEntry, const CStickerKit* pDefault, CUtlVector* pVecErrors = NULL); + bool GenerateStickerApplicationInfo(CAppliedStickerInfo_t* pInfo) const; + + int nID; + int nRarity; + CUtlString sName; + CUtlString sDescriptionString; + CUtlString sItemName; + CUtlString sMaterialPath; + CUtlString sMaterialPathNoDrips; + CUtlString m_strInventoryImage; + + int m_nEventID; + int m_nEventTeamID; + int m_nPlayerID; + + bool bMaterialPathIsAbsolute; + + float flRotateStart; + float flRotateEnd; + + float flScaleMin; + float flScaleMax; + + float flWearMin; + float flWearMax; + + const char* GetInventoryImage(void) const { return m_strInventoryImage; } + + const char* GetIconURLSmall() const { return m_sIconURLSmall; } + const char* GetIconURLLarge() const { return m_sIconURLLarge; } + void SetIconURLSmall(const char* szURL) { m_sIconURLSmall = szURL; } + void SetIconURLLarge(const char* szURL) { m_sIconURLLarge = szURL; } + + KeyValues* GetRawDefinition(void) const { return m_pKVItem; } + +private: + CUtlString m_sIconURLSmall; + CUtlString m_sIconURLLarge; + KeyValues* m_pKVItem; +}; + +class CStickerList +{ +public: + CStickerList(const CStickerList& rhs) + { + flWearMin = rhs.flWearMin; + flWearMax = rhs.flWearMax; + + flTotalWeight = rhs.flTotalWeight; + arrElements.AddMultipleToTail(rhs.arrElements.Count(), rhs.arrElements.Base()); + } + CStickerList() + { + flWearMin = 0.0f; + flWearMax = 1.0f; + + flTotalWeight = 0.0f; + } + + bool InitFromKeyValues(KeyValues* pKVEntry, CUtlVector* pVecErrors = NULL); + + bool GenerateStickerApplicationInfo(CAppliedStickerInfo_t* pInfo) const; + + struct sticker_list_entry_t + { + const CStickerList* pList; + const CStickerKit* pKit; + float flWeight; + }; + CUtlVector< sticker_list_entry_t > arrElements; + float flTotalWeight; + + float flWearMin; + float flWearMax; +}; + +class CPaintKit +{ +public: + enum { NUM_COLORS = 4 }; + + CPaintKit(const CPaintKit& rhs) + : sName(rhs.sName), + sDescriptionString(rhs.sDescriptionString), + sDescriptionTag(rhs.sDescriptionTag), + sVmtPath(rhs.sVmtPath), + sPattern(rhs.sPattern), + sLogoMaterial(rhs.sLogoMaterial) + { + nID = rhs.nID; + + kvVmtOverrides = rhs.kvVmtOverrides->MakeCopy(); + + bBaseDiffuseOverride = rhs.bBaseDiffuseOverride; + nRarity = rhs.nRarity; + nStyle = rhs.nStyle; + flWearDefault = rhs.flWearDefault; + flWearRemapMin = rhs.flWearRemapMin; + flWearRemapMax = rhs.flWearRemapMax; + nFixedSeed = rhs.nFixedSeed; + uchPhongExponent = rhs.uchPhongExponent; + uchPhongAlbedoBoost = rhs.uchPhongAlbedoBoost; + uchPhongIntensity = rhs.uchPhongIntensity; + flPatternScale = rhs.flPatternScale; + flPatternOffsetXStart = rhs.flPatternOffsetXStart; + flPatternOffsetXEnd = rhs.flPatternOffsetXEnd; + flPatternOffsetYStart = rhs.flPatternOffsetYStart; + flPatternOffsetYEnd = rhs.flPatternOffsetYEnd; + flPatternRotateStart = rhs.flPatternRotateStart; + flPatternRotateEnd = rhs.flPatternRotateEnd; + flLogoScale = rhs.flLogoScale; + flLogoOffsetX = rhs.flLogoOffsetX; + flLogoOffsetY = rhs.flLogoOffsetY; + flLogoRotation = rhs.flLogoRotation; + bIgnoreWeaponSizeScale = rhs.bIgnoreWeaponSizeScale; + nViewModelExponentOverrideSize = rhs.nViewModelExponentOverrideSize; + bOnlyFirstMaterial = rhs.bOnlyFirstMaterial; + + memcpy(rgbaLogoColor, rhs.rgbaLogoColor, sizeof(rgbaLogoColor)); + memcpy(rgbaLogoColor, rhs.rgbaLogoColor, sizeof(rgbaLogoColor)); + } + + CPaintKit(void) + { + nID = 0; + + kvVmtOverrides = nullptr; + + bBaseDiffuseOverride = false; + nRarity = 1; + nStyle = 0; + flWearDefault = 0.5f; + flWearRemapMin = 0.0f; + flWearRemapMax = 1.0f; + nFixedSeed = 0; + uchPhongExponent = 16; + uchPhongAlbedoBoost = 0; + uchPhongIntensity = 255; + flPatternScale = 0.5f; + flPatternOffsetXStart = 0.0f; + flPatternOffsetXEnd = 0.0f; + flPatternOffsetYStart = 0.0f; + flPatternOffsetYEnd = 0.0f; + flPatternRotateStart = 0.0f; + flPatternRotateEnd = 0.0f; + flLogoScale = 1.8f; + flLogoOffsetX = 1.0f; + flLogoOffsetY = 2.0f; + flLogoRotation = 0.0f; + bIgnoreWeaponSizeScale = false; + nViewModelExponentOverrideSize = 256; + bOnlyFirstMaterial = false; + + memset(rgbaColor, 128, sizeof(rgbaColor)); + memset(rgbaLogoColor, 128, sizeof(rgbaLogoColor)); + } + + ~CPaintKit() + { + if (kvVmtOverrides) + { + kvVmtOverrides->deleteThis(); + kvVmtOverrides = nullptr; + } + } + + bool InitFromKeyValues(KeyValues* pKVEntry, const CPaintKit* pDefault, bool bHandleAbsolutePaths = false); + void FillKeyValuesForWorkshop(KeyValues* pKVToFill) const; + + int nID; + CUtlString sName; + CUtlString sDescriptionString; + CUtlString sDescriptionTag; + + CUtlString sPattern; + CUtlString sLogoMaterial; + bool bBaseDiffuseOverride; + int nRarity; + int nStyle; + Color rgbaColor[NUM_COLORS]; + Color rgbaLogoColor[NUM_COLORS]; + float flWearDefault; + float flWearRemapMin; + float flWearRemapMax; + unsigned char nFixedSeed; + unsigned char uchPhongExponent; + unsigned char uchPhongAlbedoBoost; + unsigned char uchPhongIntensity; + float flPatternScale; + float flPatternOffsetXStart; + float flPatternOffsetXEnd; + float flPatternOffsetYStart; + float flPatternOffsetYEnd; + float flPatternRotateStart; + float flPatternRotateEnd; + float flLogoScale; + float flLogoOffsetX; + float flLogoOffsetY; + float flLogoRotation; + bool bIgnoreWeaponSizeScale; + int nViewModelExponentOverrideSize; + bool bOnlyFirstMaterial; + + CUtlString sVmtPath; + KeyValues* kvVmtOverrides; +}; + +class AlternateIconData_t +{ +public: + AlternateIconData_t() + { + } + + const char* GetInventoryImage(void) const { return sSimpleName; } + + const char* GetIconURLSmall() const { return m_sIconURLSmall; } + const char* GetIconURLLarge() const { return m_sIconURLLarge; } + void SetIconURLSmall(const char* szURL) { m_sIconURLSmall = szURL; } + void SetIconURLLarge(const char* szURL) { m_sIconURLLarge = szURL; } + + CUtlString sSimpleName; + CUtlString sLargeSimpleName; + +private: + CUtlString m_sIconURLSmall; + CUtlString m_sIconURLLarge; +}; + +class CProPlayerData +{ +public: + + CProPlayerData(const CProPlayerData& rhs) + { + m_nAccountID = rhs.m_nAccountID; + m_sName = rhs.m_sName; + m_sCode = rhs.m_sCode; + m_rtDOB = rhs.m_rtDOB; + m_sGeo = rhs.m_sGeo; + + m_pKVItem = rhs.m_pKVItem ? rhs.m_pKVItem->MakeCopy() : NULL; + } + + CProPlayerData(void) + { + m_nAccountID = 0; + m_rtDOB = 0; + m_pKVItem = NULL; + } + + ~CProPlayerData() + { + if (m_pKVItem) + m_pKVItem->deleteThis(); + m_pKVItem = NULL; + } + + bool BInitFromKeyValues(KeyValues* pDef, CUtlVector* pVecErrors = NULL); + + KeyValues* GetRawDefinition(void) const { return m_pKVItem; } + uint32 GetAccountID() const { return m_nAccountID; } + char const* GetName() const { return m_sName; } + char const* GetCode() const { return m_sCode; } + RTime32 GetDOB() const { return m_rtDOB; } + char const* GetGeo() const { return m_sGeo; } + +private: + KeyValues* m_pKVItem; + uint32 m_nAccountID; + CUtlString m_sName; + CUtlString m_sCode; + RTime32 m_rtDOB; + CUtlString m_sGeo; +}; + +typedef CUtlDict ArmoryStringDict_t; +typedef CUtlDict< CUtlVector* > LevelBlockDict_t; +typedef CUtlMap KillEaterScoreMap_t; + +struct attr_type_t +{ + CUtlConstString m_sName; + const ISchemaAttributeType* m_pAttrType; + + attr_type_t(const char* pszName, const ISchemaAttributeType* pAttrType) + : m_sName(pszName) + , m_pAttrType(pAttrType) + { + } +}; + +#if defined(CLIENT_DLL) || defined(GAME_DLL) +class IDelayedSchemaData +{ +public: + virtual ~IDelayedSchemaData() {} + virtual bool InitializeSchema(CEconItemSchema* pItemSchema) = 0; + +protected: + bool InitializeSchemaInternal(CEconItemSchema* pItemSchema, CUtlBuffer& bufRawData, bool bInitAsBinary, uint32 nExpectedVersion); +}; +#endif + +class CEconStorePriceSheet; + +class CEconItemSchema : public IEconItemSchema +{ +public: + CEconItemSchema(); + +private: + CEconItemSchema(const CEconItemSchema& rhs); + CEconItemSchema& operator=(CEconItemSchema& rhs); + +public: + virtual ~CEconItemSchema(void) { Reset(); }; + + virtual bool BInit(const char* fileName, const char* pathID, CUtlVector* pVecErrors = NULL); + bool BInitBinaryBuffer(CUtlBuffer& buffer, CUtlVector* pVecErrors = NULL); + bool BInitTextBuffer(CUtlBuffer& buffer, CUtlVector* pVecErrors = NULL); + + uint32 GetVersion() const { return m_unVersion; } + uint32 GetResetCount() const { return m_unResetCount; } + + static CUniformRandomStream& GetRandomStream() { return m_RandomStream; } + + static uint32 CalculateKeyValuesVersion(KeyValues* pKV); + +#if defined(CLIENT_DLL) || defined(GAME_DLL) + void MaybeInitFromBuffer(IDelayedSchemaData* pDelayedSchemaData); + + bool BInitFromDelayedBuffer(); +#endif + + equipped_class_t GetFirstValidClass() const { return m_unFirstValidClass; } + equipped_class_t GetLastValidClass() const { return m_unLastValidClass; } + bool IsValidClass(equipped_class_t unClass) { return unClass >= m_unFirstValidClass && unClass <= m_unLastValidClass; } + equipped_slot_t GetFirstValidItemSlot() const { return m_unFirstValidItemSlot; } + equipped_slot_t GetLastValidItemSlot() const { return m_unLastValidItemSlot; } + bool IsValidItemSlot(equipped_slot_t unSlot) { return unSlot >= m_unFirstValidItemSlot && unSlot <= m_unLastValidItemSlot; } + uint32 GetNumAllowedItemPresets() const { return m_unNumItemPresets; } + bool IsValidPreset(equipped_preset_t unPreset) const { return unPreset <= m_unNumItemPresets; } + uint32 GetMinLevel() const { return m_unMinLevel; } + uint32 GetMaxLevel() const { return m_unMaxLevel; } + uint32 GetSumQualityWeights() const { return m_unSumQualityWeights; } + + typedef CUtlHashMapLarge ItemDefinitionMap_t; + const ItemDefinitionMap_t& GetItemDefinitionMap() const { return m_mapItems; } + + typedef CUtlMap > SortedItemDefinitionMap_t; + const SortedItemDefinitionMap_t& GetSortedItemDefinitionMap() const { return m_mapItemsSorted; } + + typedef CUtlDict LootListDefinitionDict_t; + const LootListDefinitionDict_t& GetLootLists() const { return m_dictLootLists; } + + typedef CUtlMap > RevolvingLootListDefinitionMap_t; + const RevolvingLootListDefinitionMap_t& GetRevolvingLootLists() const { return m_mapRevolvingLootLists; } + const RevolvingLootListDefinitionMap_t& GetQuestRewardLootLists() const { return m_mapQuestRewardLootLists; } + + typedef CUtlMap BodygroupStateMap_t; + const BodygroupStateMap_t& GetDefaultBodygroupStateMap() const { return m_mapDefaultBodygroupState; } + + typedef CUtlVector ColorDefinitionsList_t; + + typedef CUtlMap > MusicDefinitionsList_t; + typedef CUtlMap > QuestDefinitionsList_t; + typedef CUtlMap > CampaignDefinitionsList_t; + + + const MusicDefinitionsList_t& GetMusicDefinitionMap() const { return m_mapMusicDefs; } + + const CEconItemDefinition* GetDefaultItemDefinition() const { return m_pDefaultItemDefinition; } + IEconItemDefinition* GetDefaultItemDefinitionInterface() { return m_pDefaultItemDefinition; } + + const CUtlMap >& GetQualityDefinitionMap() const { return m_mapQualities; } + + typedef CUtlVector< CEconItemAttributeDefinition* > EconAttrDefsContainer_t; + EconAttrDefsContainer_t& GetAttributeDefinitionContainer() { return m_mapAttributesContainer; } + const EconAttrDefsContainer_t& GetAttributeDefinitionContainer() const { return m_mapAttributesContainer; } + + typedef CUtlMap > RecipeDefinitionMap_t; + const RecipeDefinitionMap_t& GetRecipeDefinitionMap() const { return m_mapRecipes; } + const CUtlMap& GetItemSets() const { return m_mapItemSets; } + +#if defined(CLIENT_DLL) || defined(GAME_DLL) + const ArmoryStringDict_t& GetArmoryDataItemClasses() const { return m_dictArmoryItemClassesDataStrings; } + const ArmoryStringDict_t& GetArmoryDataItemTypes() const { return m_dictArmoryItemTypesDataStrings; } + const ArmoryStringDict_t& GetArmoryDataItems() const { return m_dictArmoryItemDataStrings; } + const ArmoryStringDict_t& GetArmoryDataAttributes() const { return m_dictArmoryAttributeDataStrings; } +#endif + + const CTimedItemRewardDefinition* GetTimedReward(eTimedRewardType type) const; + + const CEconLootListDefinition* GetLootListByName(const char* pListName, int* out_piIndex = NULL) const; + const CEconLootListDefinition* GetLootListByIndex(int iIdx) const { return m_dictLootLists.IsValidIndex(iIdx) ? &(m_dictLootLists[iIdx]) : NULL; } + + virtual void PurgeLootLists(void) { m_dictLootLists.Purge(); } + virtual const IEconLootListDefinition* GetLootListInterfaceByName(const char* pListName, int* out_piIndex = NULL) { return GetLootListByName(pListName, out_piIndex); } + virtual const IEconLootListDefinition* GetLootListInterfaceByIndex(int iIdx) const { return GetLootListByIndex(iIdx); } + virtual const int GetLootListIndex(const char* pListName) { return m_dictLootLists.Find(pListName); } + virtual const int GetLootListInterfaceCount(void) const { return m_dictLootLists.Count(); } + + const CEconItemSetDefinition* GetItemSet(const char* pSetName, int* piIndex = NULL) const; + const CEconItemSetDefinition* GetItemSetByIndex(int iIdx) const { return m_mapItemSets.IsValidIndex(iIdx) ? &(m_mapItemSets[iIdx]) : NULL; } + + uint8 GetDefaultQuality() const { return AE_UNIQUE; } + + virtual int GetItemSetCount(void) const { return m_mapItemSets.Count(); } + virtual const IEconItemSetDefinition* GetItemSet(int iIndex) const; + + void AssignDefaultBodygroupState(const char* pszBodygroupName, int iValue); + + equip_region_mask_t GetEquipRegionMaskByName(const char* pRegionName) const; + + struct EquipRegion + { + CUtlConstString m_sName; + unsigned int m_unBitIndex; + equip_region_mask_t m_unMask; + }; + + typedef CUtlVector EquipRegionsList_t; + const EquipRegionsList_t& GetEquipRegionsList() const { return m_vecEquipRegionsList; } + + virtual KeyValues* FindDefinitionPrefabByName(const char* pszPrefabName) const; + + equip_region_mask_t GetEquipRegionBitMaskByName(const char* pRegionName) const; + + CUtlVector< CEconItemDefinition* >& GetBundles() { return m_vecBundles; } + +private: + void SetEquipRegionConflict(int iRegion, unsigned int unBit); + int GetEquipRegionIndexByName(const char* pRegionName) const; + +public: + bool BGetItemQualityFromName(const char* pchName, uint8* nQuality) const; + const CEconItemQualityDefinition* GetQualityDefinition(int nQuality) const; + const CEconItemQualityDefinition* GetQualityDefinitionByName(const char* pszDefName) const; + virtual int GetQualityDefinitionCount(void) { return m_mapQualities.Count(); } + virtual const char* GetQualityName(uint8 iQuality); + virtual int GetQualityIndex(const char* pszQuality); + bool BGetItemRarityFromName(const char* pchName, uint8* nRarity) const; + const CEconItemRarityDefinition* GetRarityDefinitionByMapIndex(int nRarityIndex) const; + const CEconItemRarityDefinition* GetRarityDefinition(int nRarity) const; + const CEconItemRarityDefinition* GetRarityDefinitionByName(const char* pszDefName) const; + virtual int GetRarityDefinitionCount(void) const { return m_mapRarities.Count(); } + virtual const char* GetRarityName(uint8 iRarity); + virtual const char* GetRarityLocKey(uint8 iRarity); + virtual const char* GetRarityColor(uint8 iRarity); + virtual const char* GetRarityLootList(uint8 iRarity); + virtual int GetRarityIndex(const char* pszRarity); + CEconItemDefinition* GetItemDefinitionMutable(int iItemIndex, bool bNoDefault = false); + const CEconItemDefinition* GetItemDefinition(int iItemIndex, bool bNoDefault = false) const; + const CEconItemDefinition* GetItemDefinitionByMapIndex(int iMapIndex) const; + const CEconItemAttributeDefinition* GetAttributeDefinition(int iAttribIndex) const; + virtual const IEconItemAttributeDefinition* GetAttributeDefinitionInterface(int iAttribIndex) const { return GetAttributeDefinition(iAttribIndex); } + const CEconItemAttributeDefinition* GetAttributeDefinitionByName(const char* pszDefName) const; + const CEconCraftingRecipeDefinition* GetRecipeDefinition(int iRecipeIndex) const; + int GetPaintKitDefinitionCount(void) const { return m_mapPaintKits.Count(); } + void AddPaintKitDefinition(int iPaintKitID, CPaintKit* pPaintKit); + void RemovePaintKitDefinition(int iPaintKitID); + const unsigned int GetPaintKitCount() const; + const CPaintKit* GetPaintKitDefinition(int iPaintKitID) const; + const CPaintKit* GetPaintKitDefinitionByMapIndex(int iMapIndex); + const CPaintKit* GetPaintKitDefinitionByName(const char* pchName) const; + + int GetStickerKitDefinitionCount(void) const { return m_mapStickerKits.Count(); } + void AddStickerKitDefinition(int iStickerKitID, CStickerKit* pStickerKit); + void RemoveStickerKitDefinition(int iStickerKitID); + const CStickerKit* GetStickerKitDefinition(int iStickerKitID) const; + const CStickerKit* GetStickerKitDefinitionByMapIndex(int iMapIndex); + const CStickerKit* GetStickerKitDefinitionByName(const char* pchName) const; + const CStickerList* GetStickerListDefinitionByName(const char* pchName) const; + const CEconMusicDefinition* GetMusicKitDefinitionByName(const char* pchName) const; + + const CEconColorDefinition* GetColorDefinitionByName(const char* pszDefName) const; + + int GetGraffitiTintMaxValidDefID() const { return m_nMaxValidGraffitiTintDefID; } + const CEconGraffitiTintDefinition* GetGraffitiTintDefinitionByID(int nID) const; + const CEconGraffitiTintDefinition* GetGraffitiTintDefinitionByName(const char* pszDefName) const; + + const CEconMusicDefinition* GetMusicDefinition(uint32 unMusicID) const; + + CEconQuestDefinition* GetQuestDefinition(uint32 unQuestID) const; + const QuestDefinitionsList_t& GetQuestDefinitionMap(void) const { return m_mapQuestDefs; } + + const QuestEventsSchedule_t& GetAndUpdateQuestEventsSchedule(void); + const QuestEvents_t& GetQuestEvents(void) const { return m_vecQuestEvents; } + + CEconCampaignDefinition* GetCampaignDefinition(uint32 unCampaignID) const; + const CampaignDefinitionsList_t& GetCampaignDefinitionMap(void) const { return m_mapCampaignDefs; } + + virtual int GetToolType(const char* pszToolType) const { return -1; } + virtual int GetNumPrefabs(void) { return m_mapDefinitionPrefabs.Count(); } + virtual const char* GetPrefabName(int idx) { return m_mapDefinitionPrefabs.Key(idx); } + + const CEconSoundMaterialDefinition* GetSoundMaterialDefinitionByID(int nSoundMaterialID) const; + const CEconSoundMaterialDefinition* GetSoundMaterialDefinitionByName(const char* pszSoundMaterialName) const; + virtual const char* GetSoundMaterialNameByID(int nSoundMaterialID); + virtual int GetSoundMaterialID(const char* pszSoundMaterial); + + virtual int GetSoundMaterialCount(void) { return m_mapSoundMaterials.Count(); } + virtual int GetSoundMaterialIDByIndex(int nIndex); + +#ifdef CLIENT_DLL + EWebResourceStatus LoadWebResource(CUtlString pszName, void (*fnCallback)(const char*, KeyValues*), bool bForceReload = false); + void SetWebResource(CUtlString strName, KeyValues* pResourceKV); +#endif + + const CProPlayerData* GetProPlayerDataByAccountID(uint32 unAccountID) const; + const CUtlVector< const CProPlayerData* >* GetProPlayersDataForEventIDTeamID(int nEventID, int nTeamID) const; + + virtual uint32 GetHeroID(const char* pszHeroName) { return 0; } + + bool BCanGSCreateItems(uint32 unIP) const; + const AchievementAward_t* GetAchievementRewardByDefIndex(uint16 usDefIndex) const; + bool BHasAchievementRewards(void) const { return (m_dictAchievementRewards.Count() > 0); } + + static CUtlString ComputeAchievementName(AppId_t unAppID, const char* pchNativeAchievementName); + + CEconItemDefinition* GetItemDefinitionByName(const char* pszDefName); + const CEconItemDefinition* GetItemDefinitionByName(const char* pszDefName) const; + + attachedparticlesystem_t* GetAttributeControlledParticleSystem(int id); + attachedparticlesystem_t* GetAttributeControlledParticleSystemByIndex(int id); + attachedparticlesystem_t* FindAttributeControlledParticleSystem(const char* pchSystemName, int* outID = NULL); + typedef CUtlMap > ParticleDefinitionMap_t; + const ParticleDefinitionMap_t& GetAttributeControlledParticleSystems() const { return m_mapAttributeControlledParticleSystems; } + virtual int GetNumAttributeControlledParticleSystems() const { return GetAttributeControlledParticleSystems().Count(); } + + const KillEaterScoreMap_t& GetKillEaterScoreTypes() const { return m_mapKillEaterScoreTypes; } + + const kill_eater_score_type_t* FindKillEaterScoreType(uint32 unScoreType) const; + + const CUtlVector& GetAttributeTypes() const { return m_vecAttributeTypes; } + const ISchemaAttributeType* GetAttributeType(const char* pszAttrTypeName) const; + + const LevelBlockDict_t& GetItemLevelingDataDict() const { return m_vecItemLevelingData; } + + const CUtlVector* GetItemLevelingData(const char* pszLevelBlockName) const + { + LevelBlockDict_t::IndexType_t i = m_vecItemLevelingData.Find(pszLevelBlockName); + if (i == LevelBlockDict_t::InvalidIndex()) + return NULL; + + return m_vecItemLevelingData[i]; + } + + const CItemLevelingDefinition* GetItemLevelForScore(const char* pszLevelBlockName, uint32 unScore) const; + const char* GetKillEaterScoreTypeLocString(uint32 unScoreType) const; + bool GetKillEaterScoreTypeUseLevelData(uint32 unScoreType) const; + const char* GetKillEaterScoreTypeLevelingDataName(uint32 unScoreType) const; +#if defined(CLIENT_DLL) || defined(GAME_DLL) + virtual void ItemTesting_CreateTestDefinition(int iCloneFromItemDef, int iNewDef, KeyValues* pNewKV); + virtual void ItemTesting_DiscardTestDefinition(int iDef); +#endif + + econ_tag_handle_t GetHandleForTag(const char* pszTagName); + + typedef CUtlDict EconTagDict_t; + +public: + virtual CEconItemDefinition* CreateEconItemDefinition() { return new CEconItemDefinition; } + virtual CEconCraftingRecipeDefinition* CreateCraftingRecipeDefinition() { return new CEconCraftingRecipeDefinition; } + virtual CEconStyleInfo* CreateEconStyleInfo() { return new CEconStyleInfo; } + + virtual IEconTool* CreateEconToolImpl(const char* pszToolType, const char* pszUseString, const char* pszUsageRestriction, item_capabilities_t unCapabilities, KeyValues* pUsageKV); + virtual int GetItemDefinitionCount() { return m_mapItems.Count(); } + + AlternateIconData_t* GetAlternateIcon(uint64 ullAlternateIcon); + + typedef CUtlMap< uint64, AlternateIconData_t, int, CDefLess > AlternateIconsMap_t; + AlternateIconsMap_t& GetAlternateIconsMap() { return m_mapAlternateIcons; } + + +protected: + virtual void Reset(void); + + virtual KeyValues* GetRawDefinition(void) const { return m_pKVRawDefinition; } + virtual IEconItemDefinition* GetItemDefinitionInterface(int iDefIndex) { return GetItemDefinitionMutable(iDefIndex, true); } + virtual int GetLoadoutSlotCount() { return 0; } + virtual const char* GetLoadoutSlotName(int iSlot) { return NULL; } + virtual int GetLoadoutSlot(const char* pszSlotName) { return 0; } + virtual int GetCharacterSlotType(int iCharacter, int iSlot) { return 0; } + virtual int GetCharacterID(const char* pszCharacterName) { return 0; } + virtual bool DeleteItemDefinition(int iDefIndex); + virtual int GetCharacterCount(void) { return 0; } + virtual const char* GetCharacterName(int iCharacter) { return NULL; } + virtual const char* GetCharacterModel(int iCharacter) { return NULL; } + + virtual int CalculateNumberOfConcreteItems(const CEconItemDefinition* pItemDef); + + virtual bool BInitItems(KeyValues* pKVItems, CUtlVector* pVecErrors); + virtual bool BInitItemMappings(CUtlVector* pVecErrors); + virtual bool BInitBundles(CUtlVector* pVecErrors); + virtual bool BInitPaymentRules(CUtlVector* pVecErrors); + virtual bool BInitItemSets(KeyValues* pKVItemSets, CUtlVector* pVecErrors); + +private: + bool BInitGameInfo(KeyValues* pKVGameInfo, CUtlVector* pVecErrors); + bool BInitAttributeTypes(CUtlVector* pVecErrors); + bool BInitDefinitionPrefabs(KeyValues* pKVPrefabs, CUtlVector* pVecErrors); + bool BInitRarities(KeyValues* pKVRarities, CUtlVector* pVecErrors); + bool BInitQualities(KeyValues* pKVAttributes, CUtlVector* pVecErrors); + bool BInitColors(KeyValues* pKVColors, CUtlVector* pVecErrors); + bool BInitGraffitiTints(KeyValues* pKVColors, CUtlVector* pVecErrors); + bool BInitAttributes(KeyValues* pKVAttributes, CUtlVector* pVecErrors); + bool BInitEquipRegions(KeyValues* pKVEquipRegions, CUtlVector* pVecErrors); + bool BInitEquipRegionConflicts(KeyValues* pKVEquipRegions, CUtlVector* pVecErrors); + bool BInitTimedRewards(KeyValues* pKVTimeRewards, CUtlVector* pVecErrors); + bool BInitAchievementRewards(KeyValues* pKVTimeRewards, CUtlVector* pVecErrors); + bool BInitRecipes(KeyValues* pKVRecipes, CUtlVector* pVecErrors); + virtual bool BInitLootLists(KeyValues* pKVLootLists, KeyValues* pKVRandomAttributeTemplates, CUtlVector* pVecErrors, bool bServerLists); + bool BInitRevolvingLootLists(KeyValues* pKVRevolvingLootLists, CUtlVector* pVecErrors); + bool BInitQuestRewardLootLists(KeyValues* pKVQuestRewardLootLists, CUtlVector* pVecErrors); +#ifdef TF_CLIENT_DLL + bool BInitConcreteItemCounts(CUtlVector* pVecErrors); +#endif + bool BInitItemLevels(KeyValues* pKVItemLevels, CUtlVector* pVecErrors); + bool BInitKillEaterScoreTypes(KeyValues* pKVItemLevels, CUtlVector* pVecErrors); + bool BInitAlternateIcons(KeyValues* pKVAlternateIcons, CUtlVector* pVecErrors); + bool BInitAlternateIcon(uint64 ullAltIconKey, char const* szSimpleName, KeyValues* pKVAlternateIcon, CUtlVector* pVecErrors); + bool BInitStickerKits(KeyValues* pKVStickerKits, CUtlVector* pVecErrors); + bool BInitSoundMaterials(KeyValues* pKVSoundMaterials, CUtlVector* pVecErrors); + bool BInitStickerLists(KeyValues* pKVStickerKits, CUtlVector* pVecErrors); + + bool BInitPaintKits(KeyValues* pKVPaintKits, CUtlVector* pVecErrors); + bool BInitPaintKitsRarity(KeyValues* pKVPaintKitsRarity, CUtlVector* pVecErrors); + + bool BInitMusicDefs(KeyValues* pKVMusicDefs, CUtlVector* pVecErrors); + + bool BInitQuestDefs(KeyValues* pKVQuestDefs, CUtlVector* pVecErrors); + + bool BInitQuestEvents(KeyValues* pKVQuestEvents, CUtlVector* pVecErrors); + + bool BInitCampaignDefs(KeyValues* pKVCampaignDefs, CUtlVector* pVecErrors); + + bool BInitProPlayers(KeyValues* pKVData, CUtlVector* pVecErrors); + +#ifdef CLIENT_DLL + bool BInitWebResources(KeyValues* pKVWebResources, CUtlVector* pVecErrors); +#endif + + bool BPostSchemaInitStartupChecks(CUtlVector* pVecErrors); + + virtual attachedparticlesystem_t GetAttachedParticleSystemInfo(KeyValues* pParticleSystemKV, int32 nItemIndex) const; + virtual bool BInitAttributeControlledParticleSystems(KeyValues* pKVParticleSystems, CUtlVector* pVecErrors); +#if defined(CLIENT_DLL) || defined(GAME_DLL) + bool BInitArmoryData(KeyValues* pKVArmoryData, CUtlVector* pVecErrors); +#else + bool BInitExperiements(KeyValues* pKVExperiments, CUtlVector* pVecErrors); + bool BInitForeignImports(CUtlVector* pVecErrors); + + CForeignAppImports* FindOrAddAppImports(AppId_t unAppID); +#endif + +protected: + virtual bool BInitSchema(KeyValues* pKVRawDefinition, CUtlVector* pVecErrors = NULL); +private: + bool m_bSchemaUpdatesEnabled; + + uint32 m_unResetCount; + + KeyValues* m_pKVRawDefinition; + uint32 m_unVersion; + + equipped_class_t m_unFirstValidClass; + equipped_class_t m_unLastValidClass; + + equipped_slot_t m_unFirstValidItemSlot; + equipped_slot_t m_unLastValidItemSlot; + + uint32 m_unNumItemPresets; + + uint32 m_unMinLevel; + uint32 m_unMaxLevel; + + uint32 m_unSumQualityWeights; + + CUtlVector m_vecAttributeTypes; + + CUtlMap > m_mapRarities; + + CUtlMap > m_mapQualities; + + ItemDefinitionMap_t m_mapItems; + + SortedItemDefinitionMap_t m_mapItemsSorted; + + CEconItemDefinition* m_pDefaultItemDefinition; + + EconAttrDefsContainer_t m_mapAttributesContainer; + + RecipeDefinitionMap_t m_mapRecipes; + + CUtlMap m_mapItemSets; + + CUtlMap > m_mapRevolvingLootLists; + + CUtlMap > m_mapQuestRewardLootLists; + + LootListDefinitionDict_t m_dictLootLists; + + CUtlVector m_vecTimedRewards; + + CUtlDict m_dictWebResources; + + AlternateIconsMap_t m_mapAlternateIcons; + + CUtlDict< AchievementAward_t*, int > m_dictAchievementRewards; + CUtlMap< uint32, AchievementAward_t*, int, CDefLess > m_mapAchievementRewardsByData; + + CUtlMap > m_mapPaintKits; + + CUtlMap > m_mapStickerKits; + CUtlDict< CStickerKit*, int > m_dictStickerKits; + + CUtlDict< CStickerList*, int > m_dictStickerLists; + + CUtlMap > m_mapAttributeControlledParticleSystems; + + EquipRegionsList_t m_vecEquipRegionsList; + + CUtlMap m_mapDefinitionPrefabs; + + ColorDefinitionsList_t m_vecColorDefs; + CUtlVector< CEconGraffitiTintDefinition* > m_vecGraffitiTintDefs; + CUtlStringMap< CEconGraffitiTintDefinition* > m_mapGraffitiTintByName; + int m_nMaxValidGraffitiTintDefID; + + MusicDefinitionsList_t m_mapMusicDefs; + + QuestDefinitionsList_t m_mapQuestDefs; + + CampaignDefinitionsList_t m_mapCampaignDefs; + + QuestEvents_t m_vecQuestEvents; + QuestEventsSchedule_t m_mapQuestEventsSchedule; + + typedef CUtlMap< uint32, CProPlayerData*, int, CDefLess< uint32 > > MapProPlayersByAccountID_t; + typedef CUtlStringMap< CProPlayerData* > MapProPlayersByName_t; + typedef CUtlMap< uint64, CUtlVector< const CProPlayerData* >*, int, CDefLess< uint64 > > MapProPlayersByEventIDTeamID_t; + MapProPlayersByAccountID_t m_mapProPlayersByAccountID; + MapProPlayersByName_t m_mapProPlayersByCode; + MapProPlayersByEventIDTeamID_t m_mapProPlayersByEventIDTeamID; + + CUtlMap > m_mapSoundMaterials; + + BodygroupStateMap_t m_mapDefaultBodygroupState; + + EconTagDict_t m_dictTags; + + KillEaterScoreMap_t m_mapKillEaterScoreTypes; + + LevelBlockDict_t m_vecItemLevelingData; + +#if defined(CLIENT_DLL) || defined(GAME_DLL) + ArmoryStringDict_t m_dictArmoryItemTypesDataStrings; + ArmoryStringDict_t m_dictArmoryItemClassesDataStrings; + ArmoryStringDict_t m_dictArmoryAttributeDataStrings; + ArmoryStringDict_t m_dictArmoryItemDataStrings; + + IDelayedSchemaData* m_pDelayedSchemaData; +#endif + + CUtlVector< CEconItemDefinition* > m_vecBundles; + + static CUniformRandomStream m_RandomStream; + + bool m_bSchemaParsingItems; +}; + +extern CEconItemSchema& GEconItemSchema(); + +template < class T > +class CSchemaFieldHandle +{ +public: + explicit CSchemaFieldHandle(const char* szName) + : m_szName(szName) + { + m_pRef = GetTypedRef(); + m_unSchemaGeneration = GEconItemSchema().GetResetCount(); +#if _DEBUG + m_unVersion_Debug = GEconItemSchema().GetVersion(); +#endif + } + + operator const T* (void) const + { + uint32 unSchemaGeneration = GEconItemSchema().GetResetCount(); + if (m_unSchemaGeneration != unSchemaGeneration) + { + m_pRef = GetTypedRef(); + m_unSchemaGeneration = unSchemaGeneration; +#if _DEBUG + m_unVersion_Debug = GEconItemSchema().GetVersion(); +#endif + } + +#if _DEBUG + Assert(m_unVersion_Debug == GEconItemSchema().GetVersion()); +#endif + return m_pRef; + } + + const T* operator->(void) const + { + return static_cast(*this); + } + + const char* GetName(void) const + { + return m_szName; + } + +private: + const T* GetTypedRef() const; + +private: + const char* m_szName; + + mutable const T* m_pRef; + mutable uint32 m_unSchemaGeneration; +#if _DEBUG + mutable uint32 m_unVersion_Debug; +#endif +}; + +template < > +inline const CEconColorDefinition* CSchemaFieldHandle::GetTypedRef(void) const +{ + return GEconItemSchema().GetColorDefinitionByName(m_szName); +} + +template < > +inline const CEconItemAttributeDefinition* CSchemaFieldHandle::GetTypedRef(void) const +{ + return GEconItemSchema().GetAttributeDefinitionByName(m_szName); +} + +template < > +inline const CEconItemDefinition* CSchemaFieldHandle::GetTypedRef(void) const +{ + return GEconItemSchema().GetItemDefinitionByName(m_szName); +} + +template < > +inline const CEconLootListDefinition* CSchemaFieldHandle::GetTypedRef(void) const +{ + return GEconItemSchema().GetLootListByName(m_szName); +} + +typedef CSchemaFieldHandle CSchemaColorDefHandle; +typedef CSchemaFieldHandle CSchemaMusicDefHandle; +typedef CSchemaFieldHandle CSchemaAttributeDefHandle; +typedef CSchemaFieldHandle CSchemaItemDefHandle; +typedef CSchemaFieldHandle CSchemaLootListDefHandle; + +inline const CEconItemAttributeDefinition* static_attrib_t::GetAttributeDefinition() const +{ + return GEconItemSchema().GetAttributeDefinition(iDefIndex); +} + +int StringFieldToInt(const char* szValue, const char** pValueStrings, int iNumStrings, bool bDontAssert = false); +int StringFieldToInt(const char* szValue, const CUtlVector& vecValueStrings, bool bDontAssert = false); + +enum EStickerAttributeType +{ + k_EStickerAttribute_ID, + k_EStickerAttribute_Wear, + k_EStickerAttribute_Scale, + k_EStickerAttribute_Rotation, + k_EStickerAttribute_Count, +}; +const int g_nNumStickerAttrs = 6; +const CSchemaAttributeDefHandle& GetStickerAttributeDefHandle(int attrNum, EStickerAttributeType type); + +enum ECampaignAttributeType +{ + k_ECampaignAttribute_CompletionBitfield, + k_ECampaignAttribute_LastCompletedQuest, + +}; +const int g_nNumCampaigns = 8; +const CSchemaAttributeDefHandle& GetCampaignAttributeDefHandle(int nCampaignID, ECampaignAttributeType type); + +extern const uint32 g_unNumWearBuckets; +uint64 Helper_GetAlternateIconKeyForWeaponPaintWearItem(item_definition_index_t nDefIdx, uint32 nPaintId, uint32 nWear); + +uint64 Helper_GetAlternateIconKeyForTintedStickerItem(uint32 nStickerKitID, uint32 unTintID); + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/econ_item_view.h b/SpyCustom/sdk/econ_item_view.h new file mode 100644 index 0000000..fa8074c --- /dev/null +++ b/SpyCustom/sdk/econ_item_view.h @@ -0,0 +1,515 @@ +#ifndef ECON_ITEM_CONSTANTS_H +#define ECON_ITEM_CONSTANTS_H +#ifdef _WIN32 +#pragma once +#endif + +#include "game_item_schema.h" +#include "econ_item_constants.h" +#include "localization_provider.h" +#include "econ_item_interface.h" +#include "econ_item.h" +#include "utlhashtable.h" + +#if defined(CLIENT_DLL) +#include "iclientrenderable.h" + +#if defined(CSTRIKE15) +#include "custommaterialowner.h" +#endif + +#include "icompositetexturegenerator.h" + +#endif + +#include "MaterialSystemUtil.h" + +#if defined(TF_DLL) +#include "tf_item_schema.h" +#endif + +#if defined(CLIENT_DLL) +#define CEconItemView C_EconItemView + +#if defined(CSTRIKE15) +typedef void (*ImageReadyCallback_t)(const CEconItemView* pItemView, CUtlBuffer& rawImageRgba, int nWidth, int nHeight, uint64 nItemID); +struct RenderToRTData_t; +class CMergedMDL; +#endif + +#endif + +#include "econ_item_view_helpers.h" + +#define RGB_INT_RED 12073019 +#define RGB_INT_BLUE 5801378 +#define ECON_ITEM_GENERATED_ICON_WIDTH 512 +#define ECON_ITEM_GENERATED_ICON_HEIGHT 384 +#define ECON_ITEM_GENERATED_PINBOARD_ICON_WIDTH 512 +#define ECON_ITEM_GENERATED_PINBOARD_ICON_HEIGHT 384 +#define ECON_ITEM_GENERATED_ICON_DIR "resource/Flash/econ/weapons/cached/" + +#define SCHEMA_BASE_ITEM_MAX 499 + +class CEconItemAttribute; +class CAttributeManager; + +#if defined(CSTRIKE_CLIENT_DLL) +class IVisualsDataProcessor; +#endif + +struct stickerMaterialReference_t +{ + CMaterialReference m_pMaterialReferenceFirstPerson; + CMaterialReference m_pMaterialReferenceThirdPerson; + int m_nSlotIndex; +}; + +class CAttributeList +{ + friend class CEconItemView; + friend class CTFPlayer; + + DECLARE_CLASS_NOBASE(CAttributeList); +public: + DECLARE_EMBEDDED_NETWORKVAR(); + DECLARE_DATADESC(); + + CAttributeList(); + CAttributeList& operator=(const CAttributeList& src); + + void Init(); + void SetManager(CAttributeManager* pManager); + + void IterateAttributes(class IEconItemAttributeIterator* pIterator); + + void DestroyAllAttributes(void); + +private: + void AddAttribute(CEconItemAttribute* pAttribute); + void SetOrAddAttributeValueByName(const char* pszAttribDefName, float flValue); + + void RemoveAttribute(const char* pszAttribDefName); + void RemoveAttributeByIndex(int iIndex); + +public: + CEconItemAttribute* GetAttributeByName(const char* pszAttribDefName); + const CEconItemAttribute* GetAttributeByName(const char* pszAttribDefName) const; + + CEconItemAttribute* GetAttributeByClass(const char* szAttribClass); + const CEconItemAttribute* GetAttributeByClass(const char* szAttribClass) const; + + CEconItemAttribute* GetAttributeByDefIndex(uint16 unAttrDefIndex); + const CEconItemAttribute* GetAttributeByDefIndex(uint16 unAttrDefIndex) const; + + + void SetValue(CEconItemAttribute* pAttrib, float flValue); + + void UpdateManagerCache(void); + +private: + int GetNumAttributes(void) const { return m_Attributes.Count(); } + CEconItemAttribute* GetAttribute(int iIndex) { Assert(iIndex >= 0 && iIndex < m_Attributes.Count()); return &m_Attributes[iIndex]; } + const CEconItemAttribute* GetAttribute(int iIndex) const { Assert(iIndex >= 0 && iIndex < m_Attributes.Count()); return &m_Attributes[iIndex]; } + + CUtlVector m_Attributes; + + CAttributeManager* m_pManager; +}; + +class CEconItemAttribute +{ + DECLARE_CLASS_NOBASE(CEconItemAttribute); +public: + DECLARE_EMBEDDED_NETWORKVAR(); + + CEconItemAttribute(const attrib_definition_index_t iAttributeIndex, float flValue); + CEconItemAttribute(const attrib_definition_index_t iAttributeIndex, uint32 unValue); + + CEconItemAttribute& operator=(const CEconItemAttribute& val); + attrib_definition_index_t GetAttribIndex(void) const { return m_iAttributeDefinitionIndex; } + void SetAttribIndex(attrib_definition_index_t iIndex) { m_iAttributeDefinitionIndex = iIndex; } + + const CEconItemAttributeDefinition* GetStaticData(void) const; + + float GetValue(void) const; + + uint32 GetIntValue(void) const; + + float GetInitialValue(void) const { return m_flInitialValue; } + int GetRefundableCurrency(void) const { return m_nRefundableCurrency; } + void AddRefundableCurrency(int nAdd) { m_nRefundableCurrency += nAdd; } + void RemovedRefundableCurrency(int nSubtract) { m_nRefundableCurrency -= nSubtract; } + + bool GetSetBonus(void) { return m_bSetBonus; } + void SetSetBonus(bool bBonus) { m_bSetBonus = bBonus; } + +private: + void SetValue(float flValue); + + void SetIntValue(uint32 unValue); + + friend class CAttributeList; + friend class CEconItemSystem; + + void Init(void); + +private: + CNetworkVar(attrib_definition_index_t, m_iAttributeDefinitionIndex); + + CNetworkVar(float, m_flValue); + + CNetworkVar(float, m_flInitialValue); + CNetworkVar(int, m_nRefundableCurrency); + + CNetworkVar(bool, m_bSetBonus); + +public: + CEconItemAttribute(void); +}; + +#if defined(CLIENT_DLL) +class CEconItemView : public CDefaultClientRenderable, public IEconItemInterface, public CCustomMaterialOwner +#else +class CEconItemView : public IEconItemInterface +#endif +{ +#if defined(CLIENT_DLL) || defined(GAME_DLL) + DECLARE_CLASS_NOBASE(CEconItemView); +public: + DECLARE_EMBEDDED_NETWORKVAR(); + DECLARE_DATADESC(); +#endif + +public: + CEconItemView(); + CEconItemView(const CEconItemView& src); + virtual ~CEconItemView(); + CEconItemView& operator=(const CEconItemView& src); + bool operator==(const CEconItemView& other) const; + bool operator!=(const CEconItemView& other) const { return !operator==(other); } + + virtual const GameItemDefinition_t* GetItemDefinition() const + { + return GetStaticData(); + } + +public: + + virtual int32 GetQuality() const; + virtual int32 GetRarity() const; + virtual style_index_t GetStyle() const; + virtual uint8 GetFlags() const; + virtual eEconItemOrigin GetOrigin() const; + virtual uint16 GetQuantity() const; + + virtual const char* GetCustomName() const; + virtual const char* GetCustomDesc() const; + + virtual int GetItemSetIndex() const; + + virtual bool GetInUse() const { return GetSOCData() ? GetSOCData()->GetInUse() : false; } + + virtual void IterateAttributes(class IEconItemAttributeIterator* pIterator) const OVERRIDE; + + bool IsValid(void) const { return m_bInitialized; } + void Invalidate(void); + + void Init(int iDefIndex, int iQuality, int iLevel, uint32 iAccountID = 0); + void SetInitialized(bool bInit) { m_bInitialized = bInit; } + bool Init(CEconItem* pItem); + + const GameItemDefinition_t* GetStaticData(void) const; + + void SetNonSOEconItem(CEconItem* pItem) { m_pNonSOEconItem = pItem; } + + void MarkDescriptionDirty(void); + + virtual bool IsStyleUnlocked(int iStyle) const; + +private: + void EnsureDescriptionIsBuilt(void) const; +public: + void SetGrayedOutReason(const char* pszGrayedOutReason); + + void SetItemIndex(item_definition_index_t iIndex) { m_iItemDefinitionIndex = iIndex; MarkDescriptionDirty(); } + item_definition_index_t GetItemIndex(void) const { return m_iItemDefinitionIndex; } + + void SetItemQuality(int iQuality) { m_iEntityQuality = iQuality; MarkDescriptionDirty(); } + int GetItemQuality(void) const { return m_iEntityQuality; } + void SetItemLevel(uint32 unLevel) { m_iEntityLevel = unLevel; MarkDescriptionDirty(); } + uint32 GetItemLevel(void) const { return m_iEntityLevel; } + + int GetItemQuantity() const; +#ifdef CLIENT_DLL + void SetIsStoreItem(bool bIsStoreItem) { m_bIsStoreItem = bIsStoreItem; MarkDescriptionDirty(); } + void SetIsTradeItem(bool bIsTradeItem) { m_bIsTradeItem = bIsTradeItem; MarkDescriptionDirty(); } + void SetItemQuantity(int iQuantity) { m_iEntityQuantity = iQuantity; MarkDescriptionDirty(); } + void SetClientItemFlags(uint8 unFlags); + void SetItemRarityOverride(int iRarity) { m_iRarityOverride = iRarity; MarkDescriptionDirty(); } + void SetItemQualityOverride(int iQuality) { m_iQualityOverride = iQuality; MarkDescriptionDirty(); } + void SetItemStyleOverride(style_index_t unNewStyleOverride); +#endif + style_index_t GetItemStyle() const; + + void SetItemID(itemid_t iIdx) { m_iItemID = iIdx; m_iItemIDHigh = (m_iItemID >> 32); m_iItemIDLow = (m_iItemID & 0xFFFFFFFF); } +#ifdef CLIENT_DLL + virtual itemid_t GetItemID(void) const { uint64 iTmp = ((((int64)m_iItemIDHigh) << 32) | m_iItemIDLow); return (itemid_t)iTmp; } +#else + itemid_t GetItemID(void) const { return m_iItemID; } +#endif + uint32 GetItemIDHigh(void) const { return m_iItemIDHigh; } + uint32 GetItemIDLow(void) const { return m_iItemIDLow; } + + itemid_t GetFauxItemIDFromDefinitionIndex(void) const; + + uint32 GetAccountID(void) const { return m_iAccountID; } + + void SetInventoryPosition(uint32 iPosition) { m_iInventoryPosition = iPosition; } + const uint32 GetInventoryPosition(void) const { return m_iInventoryPosition; } + + const char* GetInventoryModel(void); + const char* GetInventoryImage(void) const; + bool HasGeneratedInventoryImage(void) const; + bool GetInventoryImageData(int* iPosition, int* iSize); + const char* GetInventoryOverlayImage(int idx); + int GetInventoryOverlayImageCount(void); + + IMaterial* GetToolStickerMaterial(void); + bool IsStickerTool(void); + + const char* GetPlayerDisplayModel(int iClass = 0) const; + + const char* GetWorldDisplayModel(); + const char* GetExtraWearableModel(); + const char* GetIconDisplayModel(); + const char* GetBuyMenuDisplayModel(); + const char* GetWorldDroppedModel(); + const char* GetPedestalDisplayModel(); + const char* GetMagazineModel(); + + const char* GetScopeLensMaskModel(); + + const char* GetStatTrakModelByType(int nStatTrakType); + + const char* GetUidModel(); + + int GetAnimationSlot(void); + + int GetDropType(void); + + void DestroyAllAttributes(void); + + void AddAttribute(CEconItemAttribute* pAttribute); + + void SetOrAddAttributeValueByName(const char* pszAttribDefName, float flValue); + + void InitNetworkedDynamicAttributesForDemos(void); + void UpdateNetworkedDynamicAttributesForDemos(attrib_definition_index_t nDef, float flNewValue); + +#if defined(CSTRIKE_CLIENT_DLL) + void UpdateGeneratedMaterial(bool bIgnorePicMip = false, CompositeTextureSize_t diffuseTextureSize = COMPOSITE_TEXTURE_SIZE_512); +#endif + + const char* GetStickerSlotModelBySlotIndex(int nIndex); + int GetNumSupportedStickerSlots(void); + Vector GetStickerSlotWorldProjectionStartBySlotIndex(int nIndex); + Vector GetStickerSlotWorldProjectionEndBySlotIndex(int nIndex); + const char* GetStickerWorldModelBoneParentNameBySlotIndex(int nIndex); + const char* GetStickerSlotMaterialBySlotIndex(int nIndex); + IMaterial* GetStickerIMaterialBySlotIndex(int nIndex, bool bThirdPerson = false); + void GenerateStickerMaterials(void); + bool ItemHasAnyStickersApplied(void); + bool ItemHasAnyFreeStickerSlots(void); + int GetStickerSlotFirstFreeFromIndex(int nIndex = 0); + + + void SetCustomNameOverride(const char* pszCustomName); + + virtual void GenerateKillEaterTypeVector(void); + virtual void GetKillEaterTypes(CUtlSortVector& types); + virtual int32 GetKillEaterValueByType(uint32 uKillEaterType); + + + bool m_bKillEaterTypesCached; + CUtlSortVector m_vCachedKillEaterTypes; + int m_nKillEaterValuesCacheFrame; + CUtlHashtable m_vCachedKillEaterValues; + +private: + void Cleanup(void); + +#if defined(CSTRIKE_CLIENT_DLL) + void CreateCustomWeaponMaterials(int nWeaponId, bool bIgnorePicMip, CompositeTextureSize_t diffuseTextureSize = COMPOSITE_TEXTURE_SIZE_512); + void CreateCustomClothingMaterials(const char* pchSkinIdent, int nSlotId, int nTeam, bool bIgnorePicMip, CompositeTextureSize_t diffuseTextureSize = COMPOSITE_TEXTURE_SIZE_512); + +public: + void Update(void); + void SaveInventoryImageAsPNG(int nWidth, int nHeight); + const CUtlBuffer* GetInventoryImageRgba(int nWidth, int nHeight, ImageReadyCallback_t pImageReadyCallback); + bool CanGenerateInventoryImageRgba(void); + void ClearInventoryImageRgba(void); + bool LoadCachedInventoryImage(void); + void SaveInventoryImage(CUtlBuffer& rawImageRgba); + void GenerateCachedInventoryImageName(); + + static void CleanInventoryImageCacheDir(void); + + void FinishLoadCachedInventoryImage(void* pData, int numReadBytes, FSAsyncStatus_t asyncStatus); + + enum AsyncFixupState_t + { + AFS_Init, + AFS_LoadingInProgress, + AFS_LoadingDone, + AFS_FixupDone, + } m_asyncFixupState; + + int m_nNumAsyncReadBytes; + FSAsyncStatus_t m_asyncStatus; + CUtlBuffer m_inventoryImageRgba; + +private: + static bool m_sbHasCleanedInventoryImageCacheDir; + + bool m_bInventoryImageRgbaRequested; + bool m_bInventoryImageTriedCache; + ImageReadyCallback_t m_pImageReadyCallback; + int m_nInventoryImageRgbaWidth; + int m_nInventoryImageRgbaHeight; + + FSAsyncControl_t m_hAsyncControl; + + char m_szCurrentLoadCachedFileName[MAX_PATH]; + + RenderToRTData_t* m_pRenderToRTData; + IVTFTexture* m_pScratchVTF; + CMergedMDL* m_pRenderToRTMDL; +#endif + + CUtlVector< stickerMaterialReference_t > m_pStickerMaterials; + + + + + void RemoveAttribute(const char* pszAttribDefName); + +public: + + const bool GetCombinedAttributeClassValue(float& flValue, string_t iszAttribClass) const; + + CEconItemAttribute* GetAttributeByClass(const char* szAttribClass); + const CEconItemAttribute* GetAttributeByClass(const char* szAttribClass) const; + CEconItemAttribute* GetAttributeByDefIndex(int iAttributeDefIndex); + const CEconItemAttribute* GetAttributeByDefIndex(int iAttributeDefIndex) const; + CEconItemAttribute* GetAttributeByName(const char* pszAttribDefName); + const CEconItemAttribute* GetAttributeByName(const char* pszAttribDefName) const; + + int GetNumAttributes(void) const { return m_AttributeList.GetNumAttributes(); } + CEconItemAttribute* GetAttribute(int iIndex) { return m_AttributeList.GetAttribute(iIndex); } + const CEconItemAttribute* GetAttribute(int iIndex) const { return m_AttributeList.GetAttribute(iIndex); } + CAttributeList* GetAttributeList(void) { return m_AttributeList.Get(); } + const CAttributeList* GetAttributeList(void) const { return m_AttributeList.Get(); } + + int GetModifiedRGBValue(bool bAltColor = false); + int GetCustomPaintKitIndex(void) const; + + const char* GetCustomPaintKitDbgName(void) const; + + bool CanCollect(CEconItemView& subject); + + uint64 GetCustomUserTextureID(); + const CPaintKit* GetCustomPaintKit(void) const; + + CEconItem* GetSOCData(void) const; + + bool IsEquipped(void) const { return GetSOCData() && GetSOCData()->IsEquipped(); } + bool IsEquippedForClass(equipped_class_t unClass) const { return GetSOCData() && GetSOCData()->IsEquippedForClass(unClass); } + void UpdateEquippedState(equipped_class_t unClass, equipped_slot_t unSlot) { if (GetSOCData()) { GetSOCData()->UpdateEquippedState(unClass, unSlot); } } + equipped_slot_t GetEquippedPositionForClass(equipped_class_t unClass) const { return GetSOCData() ? GetSOCData()->GetEquippedPositionForClass(unClass) : INVALID_EQUIPPED_SLOT; } + + EItemSlot GetSlot(void) const { return EItemSlotFromName(GetItemDefinition()->GetRawDefinition()->GetString("item_slot")); } + + int GetQualityParticleType(); + + int GetSkin() const; + +#if defined(CSTRIKE_CLIENT_DLL) + IVisualsDataProcessor* GetVisualsDataProcessor(int nIndex) { return (nIndex < m_ppVisualsDataProcessors.Count()) ? m_ppVisualsDataProcessors[nIndex] : NULL; } + IVisualsDataProcessor* GetVisualsDataProcessorByName(const char* szName) const; + + static CEconItemView* FindOrCreateEconItemViewForItemID(uint64 uiItemId); +#else + typedef CUtlMap< itemid_t, uint64, int, CDefLess< itemid_t > > UtlMapLookupByID_t; + static UtlMapLookupByID_t s_mapLookupByID; +#endif + +#if defined ( GAME_DLL ) + void UpdateNetworkedCustomName(); +#endif + +protected: + CNetworkVar(item_definition_index_t, m_iItemDefinitionIndex); + + CNetworkVar(int, m_iEntityQuality); + + CNetworkVar(uint32, m_iEntityLevel); + + itemid_t m_iItemID; + CNetworkVar(uint32, m_iItemIDHigh); + CNetworkVar(uint32, m_iItemIDLow); + + CNetworkVar(uint32, m_iAccountID); + + CNetworkVar(uint32, m_iInventoryPosition); + + CEconItem* m_pNonSOEconItem; + + CNetworkVar(bool, m_bInitialized); + +#if defined( CLIENT_DLL ) + bool m_bIsStoreItem; + bool m_bIsTradeItem; + int m_iEntityQuantity; + int m_iRarityOverride; + int m_iQualityOverride; + uint8 m_unClientFlags; + + style_index_t m_unOverrideStyle; + +public: + const wchar_t* GetItemName(bool bUncustomized = false) const; + + const class CEconItemDescription* GetDescription() const { EnsureDescriptionIsBuilt(); return m_pDescription; } + +private: + mutable class CEconItemDescription* m_pDescription; + mutable char* m_pszGrayedOutReason; + +#endif +#if defined(CSTRIKE_CLIENT_DLL) + CUtlVector< IVisualsDataProcessor* > m_ppVisualsDataProcessors; +#endif + +protected: + +#if defined(CLIENT_DLL) + virtual const Vector& GetRenderOrigin(void) { return vec3_origin; } + virtual const QAngle& GetRenderAngles(void) { return vec3_angle; } + virtual bool ShouldDraw(void) { return false; } + virtual bool IsTransparent(void) { return false; } + virtual const matrix3x4_t& RenderableToWorldTransform() { static matrix3x4_t mat; SetIdentityMatrix(mat); return mat; } + virtual void GetRenderBounds(Vector& mins, Vector& maxs) { return; } +#endif + +private: + CNetworkVarEmbedded(CAttributeList, m_AttributeList); + CNetworkVarEmbedded(CAttributeList, m_NetworkedDynamicAttributesForDemos); + + CNetworkString(m_szCustomName, MAX_ITEM_CUSTOM_NAME_DATABASE_SIZE); + + char m_szCustomNameOverride[MAX_ITEM_CUSTOM_NAME_DATABASE_SIZE]; + GCSDK::CAutoPtr< char > m_autoptrInventoryImageGeneratedPath; +}; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/edict.h b/SpyCustom/sdk/edict.h new file mode 100644 index 0000000..6f7d014 --- /dev/null +++ b/SpyCustom/sdk/edict.h @@ -0,0 +1,370 @@ +#ifndef EDICT_H +#define EDICT_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "vector.h" +#include "cmodel.h" +#include "const.h" +#include "iserverentity.h" +#include "globalvars_base.h" +#include "ICollideable.h" +#include "iservernetworkable.h" +#include "bitvec.h" +#include "convar.h" + +struct edict_t; + + +enum MapLoadType_t +{ + MapLoad_NewGame = 0, + MapLoad_LoadGame, + MapLoad_Transition, + MapLoad_Background, +}; + + +class CGlobalVars : public CGlobalVarsBase +{ +public: + + CGlobalVars(bool bIsClient); + +public: + + string_t mapname; + string_t mapGroupName; + int mapversion; + string_t startspot; + MapLoadType_t eLoadType; + bool bMapLoadFailed; + + bool deathmatch; + bool coop; + bool teamplay; + int maxEntities; + + int serverCount; + edict_t* pEdicts; +}; + +inline CGlobalVars::CGlobalVars(bool bIsClient) : + CGlobalVarsBase(bIsClient) +{ + serverCount = 0; +} + + +class CPlayerState; +class IServerNetworkable; +class IServerEntity; + + +#define FL_EDICT_CHANGED (1<<0) +#define FL_EDICT_FREE (1<<1) +#define FL_EDICT_FULL (1<<2) + +#define FL_EDICT_FULLCHECK (0<<0) +#define FL_EDICT_ALWAYS (1<<3) +#define FL_EDICT_DONTSEND (1<<4) +#define FL_EDICT_PVSCHECK (1<<5) + +#define FL_EDICT_PENDING_DORMANT_CHECK (1<<6) + +#define FL_EDICT_DIRTY_PVS_INFORMATION (1<<7) + +#define FL_FULL_EDICT_CHANGED (1<<8) + + +#define MAX_CHANGE_OFFSETS 19 +#define MAX_EDICT_CHANGE_INFOS 100 + + +class CEdictChangeInfo +{ +public: + unsigned short m_ChangeOffsets[MAX_CHANGE_OFFSETS]; + unsigned short m_nChangeOffsets; +}; + +class CSharedEdictChangeInfo +{ +public: + CSharedEdictChangeInfo() + { + m_iSerialNumber = 1; + } + + unsigned short m_iSerialNumber; + +#ifdef NETWORK_VARS_ENABLED + CEdictChangeInfo m_ChangeInfos[MAX_EDICT_CHANGE_INFOS]; + unsigned short m_nChangeInfos; +#endif +}; +extern CSharedEdictChangeInfo* g_pSharedChangeInfo; + +class IChangeInfoAccessor +{ +public: + inline void SetChangeInfo(unsigned short info) + { + m_iChangeInfo = info; + } + + inline void SetChangeInfoSerialNumber(unsigned short sn) + { + m_iChangeInfoSerialNumber = sn; + } + + inline unsigned short GetChangeInfo() const + { + return m_iChangeInfo; + } + + inline unsigned short GetChangeInfoSerialNumber() const + { + return m_iChangeInfoSerialNumber; + } + +private: + unsigned short m_iChangeInfo; + unsigned short m_iChangeInfoSerialNumber; +}; + +class CBaseEdict +{ +public: + + IServerEntity* GetIServerEntity(); + const IServerEntity* GetIServerEntity() const; + + IServerNetworkable* GetNetworkable(); + IServerUnknown* GetUnknown(); + + void SetEdict(IServerUnknown* pUnk, bool bFullEdict); + + int AreaNum() const; + const char* GetClassName() const; + + bool IsFree() const; + void SetFree(); + void ClearFree(); + + bool HasStateChanged() const; + void ClearStateChanged(); + void StateChanged(); + void StateChanged(unsigned short offset); + + void ClearTransmitState(); + + void SetChangeInfo(unsigned short info); + void SetChangeInfoSerialNumber(unsigned short sn); + unsigned short GetChangeInfo() const; + unsigned short GetChangeInfoSerialNumber() const; + +public: + +#ifdef _XBOX + unsigned short m_fStateFlags; +#else + int m_fStateFlags; +#endif + + int m_NetworkSerialNumber; + + IServerNetworkable* m_pNetworkable; + +protected: + IServerUnknown* m_pUnk; + + +public: + + IChangeInfoAccessor* GetChangeAccessor(); + const IChangeInfoAccessor* GetChangeAccessor() const; + friend void InitializeEntityDLLFields(edict_t* pEdict); +}; + + +inline IServerEntity* CBaseEdict::GetIServerEntity() +{ + if (m_fStateFlags & FL_EDICT_FULL) + return (IServerEntity*)m_pUnk; + else + return 0; +} + +inline bool CBaseEdict::IsFree() const +{ + return (m_fStateFlags & FL_EDICT_FREE) != 0; +} + + + +inline bool CBaseEdict::HasStateChanged() const +{ + return (m_fStateFlags & FL_EDICT_CHANGED) != 0; +} + +inline void CBaseEdict::ClearStateChanged() +{ + m_fStateFlags &= ~(FL_EDICT_CHANGED | FL_FULL_EDICT_CHANGED); + SetChangeInfoSerialNumber(0); +} + +inline void CBaseEdict::StateChanged() +{ + m_fStateFlags |= (FL_EDICT_CHANGED | FL_FULL_EDICT_CHANGED); +} + +inline void CBaseEdict::StateChanged(unsigned short offset) +{ +#ifdef NETWORK_VARS_ENABLED + if (m_fStateFlags & FL_FULL_EDICT_CHANGED) + return; + + m_fStateFlags |= FL_EDICT_CHANGED; + + IChangeInfoAccessor* accessor = GetChangeAccessor(); + + if (accessor->GetChangeInfoSerialNumber() == g_pSharedChangeInfo->m_iSerialNumber) + { + CEdictChangeInfo* p = &g_pSharedChangeInfo->m_ChangeInfos[accessor->GetChangeInfo()]; + + for (unsigned short i = 0; i < p->m_nChangeOffsets; i++) + if (p->m_ChangeOffsets[i] == offset) + return; + + if (p->m_nChangeOffsets == MAX_CHANGE_OFFSETS) + { + accessor->SetChangeInfoSerialNumber(0); + m_fStateFlags |= FL_FULL_EDICT_CHANGED; + } + else + { + p->m_ChangeOffsets[p->m_nChangeOffsets++] = offset; + } + } + else + { + if (g_pSharedChangeInfo->m_nChangeInfos == MAX_EDICT_CHANGE_INFOS) + { + accessor->SetChangeInfoSerialNumber(0); + m_fStateFlags |= FL_FULL_EDICT_CHANGED; + } + else + { + accessor->SetChangeInfo(g_pSharedChangeInfo->m_nChangeInfos); + g_pSharedChangeInfo->m_nChangeInfos++; + + accessor->SetChangeInfoSerialNumber(g_pSharedChangeInfo->m_iSerialNumber); + + CEdictChangeInfo* p = &g_pSharedChangeInfo->m_ChangeInfos[accessor->GetChangeInfo()]; + p->m_ChangeOffsets[0] = offset; + p->m_nChangeOffsets = 1; + } + } +#else + StateChanged(); +#endif +} + + + +inline void CBaseEdict::SetFree() +{ + m_fStateFlags |= FL_EDICT_FREE; +} + +inline void CBaseEdict::ClearFree() +{ + m_fStateFlags &= ~FL_EDICT_FREE; +} + +inline void CBaseEdict::ClearTransmitState() +{ + m_fStateFlags &= ~(FL_EDICT_ALWAYS | FL_EDICT_PVSCHECK | FL_EDICT_DONTSEND); +} + +inline const IServerEntity* CBaseEdict::GetIServerEntity() const +{ + if (m_fStateFlags & FL_EDICT_FULL) + return (IServerEntity*)m_pUnk; + else + return 0; +} + +inline IServerUnknown* CBaseEdict::GetUnknown() +{ + return m_pUnk; +} + +inline IServerNetworkable* CBaseEdict::GetNetworkable() +{ + return m_pNetworkable; +} + +inline void CBaseEdict::SetEdict(IServerUnknown* pUnk, bool bFullEdict) +{ + m_pUnk = pUnk; + if ((pUnk != NULL) && bFullEdict) + { + m_fStateFlags = FL_EDICT_FULL; + } + else + { + m_fStateFlags = 0; + } +} + +inline int CBaseEdict::AreaNum() const +{ + if (!m_pUnk) + return 0; + + return m_pNetworkable->AreaNum(); +} + +inline const char* CBaseEdict::GetClassName() const +{ + if (!m_pUnk) + return ""; + return m_pNetworkable->GetClassName(); +} + +inline void CBaseEdict::SetChangeInfo(unsigned short info) +{ + GetChangeAccessor()->SetChangeInfo(info); +} + +inline unsigned short CBaseEdict::GetChangeInfo() const +{ + return GetChangeAccessor()->GetChangeInfo(); +} + +inline unsigned short CBaseEdict::GetChangeInfoSerialNumber() const +{ + return GetChangeAccessor()->GetChangeInfoSerialNumber(); +} + +struct edict_t : public CBaseEdict +{ +public: + ICollideable* GetCollideable(); +}; + +inline ICollideable* edict_t::GetCollideable() +{ + IServerEntity* pEnt = GetIServerEntity(); + if (pEnt) + return pEnt->GetCollideable(); + else + return NULL; +} + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/ehandle.h b/SpyCustom/sdk/ehandle.h new file mode 100644 index 0000000..0b504c5 --- /dev/null +++ b/SpyCustom/sdk/ehandle.h @@ -0,0 +1,150 @@ +#ifndef EHANDLE_H +#define EHANDLE_H +#ifdef _WIN32 +#pragma once +#endif + +#if defined( _DEBUG ) && defined( GAME_DLL ) +#include "tier0/dbg.h" +#include "cbase.h" +#endif + + +#include "const.h" +#include "basehandle.h" +#include "entitylist_base.h" + +#include "icliententitylist.h" +class IHandleEntity; + + +inline IHandleEntity* CBaseHandle::Get() const +{ + extern IClientEntityList* g_pEntityList; + return ((CBaseEntityList*)g_pEntityList)->LookupEntity(*this); +} + + +template< class T > +class CHandle : public CBaseHandle +{ +public: + + CHandle(); + CHandle(int iEntry, int iSerialNumber); + CHandle(const CBaseHandle& handle); + CHandle(T* pVal); + + static CHandle FromIndex(int index); + + T* Get() const; + void Set(const T* pVal); + + operator T* (); + operator T* () const; + + bool operator !() const; + bool operator==(T* val) const; + bool operator!=(T* val) const; + const CBaseHandle& operator=(const T* val); + + T* operator->() const; +}; + + +template +CHandle::CHandle() +{ +} + + +template +CHandle::CHandle(int iEntry, int iSerialNumber) +{ + Init(iEntry, iSerialNumber); +} + + +template +CHandle::CHandle(const CBaseHandle& handle) + : CBaseHandle(handle) +{ +} + + +template +CHandle::CHandle(T* pObj) +{ + Term(); + Set(pObj); +} + + +template +inline CHandle CHandle::FromIndex(int index) +{ + CHandle ret; + ret.m_Index = index; + return ret; +} + + +template +inline T* CHandle::Get() const +{ + return (T*)CBaseHandle::Get(); +} + + +template +inline CHandle::operator T* () +{ + return Get(); +} + +template +inline CHandle::operator T* () const +{ + return Get(); +} + + +template +inline bool CHandle::operator !() const +{ + return !Get(); +} + +template +inline bool CHandle::operator==(T* val) const +{ + return Get() == val; +} + +template +inline bool CHandle::operator!=(T* val) const +{ + return Get() != val; +} + +template +void CHandle::Set(const T* pVal) +{ + CBaseHandle::Set(reinterpret_cast(pVal)); +} + +template +inline const CBaseHandle& CHandle::operator=(const T* val) +{ + Set(val); + return *this; +} + +template +T* CHandle::operator -> () const +{ + return Get(); +} + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/eiface.h b/SpyCustom/sdk/eiface.h new file mode 100644 index 0000000..201290a --- /dev/null +++ b/SpyCustom/sdk/eiface.h @@ -0,0 +1,580 @@ +#ifndef EIFACE_H +#define EIFACE_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "convar.h" +#include "icvar.h" +#include "edict.h" +#include "vplane.h" +#include "iserverentity.h" +#include "ivmodelinfo.h" +#include "soundflags.h" +#include "bitvec.h" +#include "iserverplugin.h" +#include "bitbuf.h" +#include "checksum_crc.h" +#include "iclient.h" + +class SendTable; +class ServerClass; +class IMoveHelper; +struct Ray_t; +class CGameTrace; +typedef CGameTrace trace_t; +struct typedescription_t; +class CSaveRestoreData; +struct datamap_t; +class SendTable; +class ServerClass; +class IMoveHelper; +struct Ray_t; +struct studiohdr_t; +class CBaseEntity; +class CRestore; +class CSave; +class variant_t; +struct vcollide_t; +class IRecipientFilter; +class CBaseEntity; +class ITraceFilter; +struct client_textmessage_t; +class INetChannelInfo; +class ISpatialPartition; +class IScratchPad3D; +class CStandardSendProxies; +class IAchievementMgr; +class CGamestatsData; +class CSteamID; +class ISPSharedMemory; +class CGamestatsData; +class CEngineHltvInfo_t; +class INetMessage; +class HltvReplayParams_t; + +namespace google +{ + namespace protobuf + { + class Message; + } +} + +typedef struct player_info_s player_info_t; + +typedef uint64 PublishedFileId_t; + +#ifdef _WIN32 +#define DLLEXPORT __stdcall +#else +#define DLLEXPORT +#endif + +#define INTERFACEVERSION_VENGINESERVER "VEngineServer023" + +struct bbox_t +{ + Vector mins; + Vector maxs; +}; + +abstract_class IVEngineServer +{ +public: + virtual void ChangeLevel(const char* s1, const char* s2) = 0; + + virtual int IsMapValid(const char* filename) = 0; + + virtual bool IsDedicatedServer(void) = 0; + + virtual int IsInEditMode(void) = 0; + + virtual KeyValues* GetLaunchOptions(void) = 0; + + virtual int PrecacheModel(const char* s, bool preload = false) = 0; + virtual int PrecacheSentenceFile(const char* s, bool preload = false) = 0; + virtual int PrecacheDecal(const char* name, bool preload = false) = 0; + virtual int PrecacheGeneric(const char* s, bool preload = false) = 0; + + virtual bool IsModelPrecached(char const* s) const = 0; + virtual bool IsDecalPrecached(char const* s) const = 0; + virtual bool IsGenericPrecached(char const* s) const = 0; + + virtual int GetClusterForOrigin(const Vector& org) = 0; + virtual int GetPVSForCluster(int cluster, int outputpvslength, unsigned char* outputpvs) = 0; + virtual bool CheckOriginInPVS(const Vector& org, const unsigned char* checkpvs, int checkpvssize) = 0; + virtual bool CheckBoxInPVS(const Vector& mins, const Vector& maxs, const unsigned char* checkpvs, int checkpvssize) = 0; + + virtual int GetPlayerUserId(const edict_t* e) = 0; + virtual const char* GetPlayerNetworkIDString(const edict_t* e) = 0; + virtual bool IsUserIDInUse(int userID) = 0; + virtual int GetLoadingProgressForUserID(int userID) = 0; + + virtual int GetEntityCount(void) = 0; + + virtual INetChannelInfo* GetPlayerNetInfo(int playerIndex) = 0; + + virtual edict_t* CreateEdict(int iForceEdictIndex = -1) = 0; + virtual void RemoveEdict(edict_t* e) = 0; + + virtual void* PvAllocEntPrivateData(long cb) = 0; + virtual void FreeEntPrivateData(void* pEntity) = 0; + + virtual void* SaveAllocMemory(size_t num, size_t size) = 0; + virtual void SaveFreeMemory(void* pSaveMem) = 0; + + virtual void EmitAmbientSound(int entindex, const Vector& pos, const char* samp, float vol, soundlevel_t soundlevel, int fFlags, int pitch, float delay = 0.0f) = 0; + + virtual void FadeClientVolume(const edict_t* pEdict, float fadePercent, float fadeOutSeconds, float holdTime, float fadeInSeconds) = 0; + + virtual int SentenceGroupPick(int groupIndex, char* name, int nameBufLen) = 0; + virtual int SentenceGroupPickSequential(int groupIndex, char* name, int nameBufLen, int sentenceIndex, int reset) = 0; + virtual int SentenceIndexFromName(const char* pSentenceName) = 0; + virtual const char* SentenceNameFromIndex(int sentenceIndex) = 0; + virtual int SentenceGroupIndexFromName(const char* pGroupName) = 0; + virtual const char* SentenceGroupNameFromIndex(int groupIndex) = 0; + virtual float SentenceLength(int sentenceIndex) = 0; + + virtual void ServerCommand(const char* str) = 0; + virtual void ServerExecute(void) = 0; + virtual void ClientCommand(edict_t* pEdict, const char* szFmt, ...) FMTFUNCTION(3, 4) = 0; + + virtual void LightStyle(int style, const char* val) = 0; + + virtual void StaticDecal(const Vector& originInEntitySpace, int decalIndex, int entityIndex, int modelIndex, bool lowpriority) = 0; + + virtual void Message_DetermineMulticastRecipients(bool usepas, const Vector& origin, CPlayerBitVec& playerbits) = 0; + + virtual bf_write* EntityMessageBegin(int ent_index, ServerClass* ent_class, bool reliable) = 0; + + virtual void MessageEnd(void) = 0; + + virtual void SendUserMessage(IRecipientFilter& filter, int message, const google::protobuf::Message& msg) = 0; + + virtual void ClientPrintf(edict_t* pEdict, const char* szMsg) = 0; + + virtual void Con_NPrintf(int pos, const char* fmt, ...) = 0; + virtual void Con_NXPrintf(const struct con_nprint_s* info, const char* fmt, ...) = 0; + + virtual void SetView(const edict_t* pClient, const edict_t* pViewent) = 0; + + virtual void CrosshairAngle(const edict_t* pClient, float pitch, float yaw) = 0; + + virtual void GetGameDir(char* szGetGameDir, int maxlength) = 0; + + virtual int CompareFileTime(const char* filename1, const char* filename2, int* iCompare) = 0; + + virtual bool LockNetworkStringTables(bool lock) = 0; + + virtual edict_t* CreateFakeClient(const char* netname) = 0; + + virtual const char* GetClientConVarValue(int clientIndex, const char* name) = 0; + + virtual const char* ParseFile(const char* data, char* token, int maxlen) = 0; + virtual bool CopyFile(const char* source, const char* destination) = 0; + + virtual void ResetPVS(byte* pvs, int pvssize) = 0; + virtual void AddOriginToPVS(const Vector& origin) = 0; + + virtual void SetAreaPortalState(int portalNumber, int isOpen) = 0; + + virtual void PlaybackTempEntity(IRecipientFilter& filter, float delay, const void* pSender, const SendTable* pST, int classID) = 0; + virtual int CheckHeadnodeVisible(int nodenum, const byte* pvs, int vissize) = 0; + virtual int CheckAreasConnected(int area1, int area2) = 0; + virtual int GetArea(const Vector& origin) = 0; + virtual void GetAreaBits(int area, unsigned char* bits, int buflen) = 0; + virtual bool GetAreaPortalPlane(Vector const& vViewOrigin, int portalKey, VPlane* pPlane) = 0; + + virtual bool LoadGameState(char const* pMapName, bool createPlayers) = 0; + virtual void LoadAdjacentEnts(const char* pOldLevel, const char* pLandmarkName) = 0; + virtual void ClearSaveDir() = 0; + + virtual const char* GetMapEntitiesString() = 0; + + virtual client_textmessage_t* TextMessageGet(const char* pName) = 0; + + virtual void LogPrint(const char* msg) = 0; + virtual bool IsLogEnabled() = 0; + virtual void BuildEntityClusterList(edict_t* pEdict, PVSInfo_t* pPVSInfo) = 0; + + virtual void SolidMoved(edict_t* pSolidEnt, ICollideable* pSolidCollide, const Vector* pPrevAbsOrigin, bool testSurroundingBoundsOnly) = 0; + virtual void TriggerMoved(edict_t* pTriggerEnt, bool testSurroundingBoundsOnly) = 0; + + virtual ISpatialPartition* CreateSpatialPartition(const Vector& worldmin, const Vector& worldmax) = 0; + virtual void DestroySpatialPartition(ISpatialPartition*) = 0; + + virtual void DrawMapToScratchPad(IScratchPad3D* pPad, unsigned long iFlags) = 0; + + virtual const CBitVec* GetEntityTransmitBitsForClient(int iClientIndex) = 0; + + virtual bool IsPaused() = 0; + + virtual float GetTimescale(void) const = 0; + + virtual void ForceExactFile(const char* s) = 0; + virtual void ForceModelBounds(const char* s, const Vector& mins, const Vector& maxs) = 0; + virtual void ClearSaveDirAfterClientLoad() = 0; + + virtual void SetFakeClientConVarValue(edict_t* pEntity, const char* cvar, const char* value) = 0; + + virtual void ForceSimpleMaterial(const char* s) = 0; + + virtual int IsInCommentaryMode(void) = 0; + + virtual bool IsLevelMainMenuBackground(void) = 0; + + virtual void SetAreaPortalStates(const int* portalNumbers, const int* isOpen, int nPortals) = 0; + + virtual void NotifyEdictFlagsChange(int iEdict) = 0; + + virtual const CCheckTransmitInfo* GetPrevCheckTransmitInfo(edict_t* pPlayerEdict) = 0; + + virtual CSharedEdictChangeInfo* GetSharedEdictChangeInfo() = 0; + + virtual void AllowImmediateEdictReuse() = 0; + + virtual bool IsInternalBuild(void) = 0; + + virtual IChangeInfoAccessor* GetChangeAccessor(const edict_t* pEdict) = 0; + + virtual char const* GetMostRecentlyLoadedFileName() = 0; + virtual char const* GetSaveFileName() = 0; + + virtual void CleanUpEntityClusterList(PVSInfo_t* pPVSInfo) = 0; + + virtual void SetAchievementMgr(IAchievementMgr*) = 0; + virtual IAchievementMgr* GetAchievementMgr() = 0; + + virtual int GetAppID() = 0; + + virtual bool IsLowViolence() = 0; + + virtual bool IsAnyClientLowViolence() = 0; + + virtual QueryCvarCookie_t StartQueryCvarValue(edict_t* pPlayerEntity, const char* pName) = 0; + + virtual void InsertServerCommand(const char* str) = 0; + + virtual bool GetPlayerInfo(int ent_num, player_info_t* pinfo) = 0; + + virtual bool IsClientFullyAuthenticated(edict_t* pEdict) = 0; + + virtual void SetDedicatedServerBenchmarkMode(bool bBenchmarkMode) = 0; + + virtual bool IsSplitScreenPlayer(int ent_num) = 0; + virtual edict_t* GetSplitScreenPlayerAttachToEdict(int ent_num) = 0; + virtual int GetNumSplitScreenUsersAttachedToEdict(int ent_num) = 0; + virtual edict_t* GetSplitScreenPlayerForEdict(int ent_num, int nSlot) = 0; + + virtual bool IsOverrideLoadGameEntsOn() = 0; + + virtual void ForceFlushEntity(int iEntity) = 0; + + virtual ISPSharedMemory* GetSinglePlayerSharedMemorySpace(const char* szName, int ent_num = MAX_EDICTS) = 0; + + virtual void* AllocLevelStaticData(size_t bytes) = 0; + + virtual int GetClusterCount() = 0; + virtual int GetAllClusterBounds(bbox_t* pBBoxList, int maxBBox) = 0; + + virtual bool IsCreatingReslist() = 0; + virtual bool IsCreatingXboxReslist() = 0; + virtual bool IsDedicatedServerForXbox() = 0; + virtual bool IsDedicatedServerForPS3() = 0; + + virtual void Pause(bool bPause, bool bForce = false) = 0; + + virtual void SetTimescale(float flTimescale) = 0; + + virtual void SetGamestatsData(CGamestatsData* pGamestatsData) = 0; + virtual CGamestatsData* GetGamestatsData() = 0; + + virtual const CSteamID* GetClientSteamID(const edict_t* pPlayerEdict, bool bValidatedIDOnly = false) = 0; + + virtual const CSteamID* GetGameServerSteamID() = 0; + + virtual void HostValidateSession() = 0; + + virtual void RefreshScreenIfNecessary() = 0; + + virtual bool HasPaintmap() = 0; + + virtual bool SpherePaintSurface(const model_t* pModel, const Vector&, unsigned char, float, float) = 0; + + virtual void SphereTracePaintSurface(const model_t* pModel, const Vector&, const Vector&, float, CUtlVector&) = 0; + + virtual void RemoveAllPaint() = 0; + + virtual void PaintAllSurfaces(unsigned char) = 0; + virtual void RemovePaint(const model_t* pModel) = 0; + + virtual void ClientCommandKeyValues(edict_t* pEdict, KeyValues* pCommand) = 0; + + virtual uint64 GetClientXUID(edict_t* pPlayerEdict) = 0; + virtual bool IsActiveApp() = 0; + + virtual void SetNoClipEnabled(bool bEnabled) = 0; + + virtual void GetPaintmapDataRLE(CUtlVector& mapdata) = 0; + virtual void LoadPaintmapDataRLE(CUtlVector& mapdata) = 0; + virtual void SendPaintmapDataToClient(edict_t* pEdict) = 0; + + virtual float GetLatencyForChoreoSounds() = 0; + + virtual CrossPlayPlatform_t GetClientCrossPlayPlatform(int ent_num) = 0; + + virtual void EnsureInstanceBaseline(int ent_num) = 0; + + virtual bool ReserveServerForQueuedGame(const char* szReservationPayload) = 0; + + virtual bool GetEngineHltvInfo(CEngineHltvInfo_t& out) = 0; + + virtual void AddHltvRelayProxyWhitelist(uint32 octet1, uint32 octet2, uint32 octet3, uint32 octet4, uint32 prefix) = 0; + + virtual int GetServerVersion() const = 0; + + virtual void UpdateHltvExternalViewers(uint32 totalSpectators, uint32 spectatorsLinkedToSteam) = 0; + + virtual bool WasShutDownRequested(void) const = 0; + virtual void* StartClientHltvReplay(int client , const HltvReplayParams_t&) = 0; + virtual void* StopClientHltvReplay(int client) = 0; + virtual int GetClientHltvReplayDelay(int client) = 0; + virtual bool HasHltvReplay(void) = 0; + virtual bool ClientCanStartHltvReplay(int client) = 0; + virtual int ClientResetReplayRequestTime(int client) = 0; + virtual bool AnyClientsInHltvReplayMode(void) = 0; +}; + +#define INTERFACEVERSION_SERVERGAMEDLL "ServerGameDLL005" + +abstract_class IServerGameDLL +{ +public: + virtual bool DLLInit(CreateInterfaceFn engineFactory, + CreateInterfaceFn physicsFactory, + CreateInterfaceFn fileSystemFactory, + CGlobalVars * pGlobals) = 0; + + virtual bool GameInit(void) = 0; + + virtual bool LevelInit(char const* pMapName, + char const* pMapEntities, char const* pOldLevel, + char const* pLandmarkName, bool loadGame, bool background) = 0; + + virtual void ServerActivate(edict_t* pEdictList, int edictCount, int clientMax) = 0; + + virtual void GameFrame(bool simulating) = 0; + + virtual void PreClientUpdate(bool simulating) = 0; + + virtual void LevelShutdown(void) = 0; + virtual void GameShutdown(void) = 0; + + virtual void DLLShutdown(void) = 0; + + virtual float GetTickInterval(void) const = 0; + + virtual ServerClass* GetAllServerClasses(void) = 0; + + virtual const char* GetGameDescription(void) = 0; + + virtual void CreateNetworkStringTables(void) = 0; + + virtual CSaveRestoreData* SaveInit(int size) = 0; + virtual void SaveWriteFields(CSaveRestoreData*, const char*, void*, datamap_t*, typedescription_t*, int) = 0; + virtual void SaveReadFields(CSaveRestoreData*, const char*, void*, datamap_t*, typedescription_t*, int) = 0; + virtual void SaveGlobalState(CSaveRestoreData*) = 0; + virtual void RestoreGlobalState(CSaveRestoreData*) = 0; + virtual void PreSave(CSaveRestoreData*) = 0; + virtual void Save(CSaveRestoreData*) = 0; + virtual void GetSaveComment(char* comment, int maxlength, float flMinutes, float flSeconds, bool bNoTime = false) = 0; + virtual void WriteSaveHeaders(CSaveRestoreData*) = 0; + virtual void ReadRestoreHeaders(CSaveRestoreData*) = 0; + virtual void Restore(CSaveRestoreData*, bool) = 0; + virtual bool IsRestoring() = 0; + virtual bool SupportsSaveRestore() = 0; + + virtual int CreateEntityTransitionList(CSaveRestoreData*, int) = 0; + virtual void BuildAdjacentMapList(void) = 0; + + virtual CStandardSendProxies* GetStandardSendProxies() = 0; + + virtual void PostInit() = 0; + virtual void Think(bool finalTick) = 0; + +#ifdef _XBOX + virtual void GetTitleName(const char* pMapName, char* pTitleBuff, int titleBuffSize) = 0; +#endif + + virtual void PreSaveGameLoaded(char const* pSaveName, bool bCurrentlyInGame) = 0; + + virtual bool ShouldHideServer(void) = 0; + + virtual void InvalidateMdlCache() = 0; + + virtual void OnQueryCvarValueFinished(QueryCvarCookie_t iCookie, edict_t* pPlayerEntity, EQueryCvarValueStatus eStatus, const char* pCvarName, const char* pCvarValue) = 0; + + virtual void PostToolsInit() = 0; + + virtual void GameServerSteamAPIActivated(bool bActivated) = 0; + + virtual void ApplyGameSettings(KeyValues* pKV) = 0; + + virtual void GetMatchmakingTags(char* buf, size_t bufSize) = 0; + + virtual void ServerHibernationUpdate(bool bHibernating) = 0; + + virtual bool ShouldPreferSteamAuth() = 0; + + virtual bool ShouldAllowDirectConnect() = 0; + virtual bool FriendsReqdForDirectConnect() = 0; + virtual bool IsLoadTestServer() = 0; + virtual bool IsValveDS() = 0; + virtual KeyValues* GetExtendedServerInfoForNewClient() = 0; + virtual void UpdateGCInformation() = 0; + virtual void ReportGCQueuedMatchStart(int32 iReservationStage, uint32* puiConfirmedAccounts, int numConfirmedAccounts) = 0; + + virtual PublishedFileId_t GetUGCMapFileID(const char* mapName) = 0; + virtual void GetMatchmakingGameData(char* buf, size_t bufSize) = 0; + virtual bool HasPendingMapDownloads() const = 0; + virtual void UpdateUGCMap(PublishedFileId_t file) = 0; + virtual int GetMessageEncryptionKey(INetMessage* msg) = 0; + virtual bool ShouldHoldGameServerReservation(float flTime) = 0; + virtual bool OnPureServerFileValidationFailure(edict_t* pPlayer, const char* pszPathID, const char* pszFileName, + CRC32_t crcIOSequence, int eFileHashType, int cbFileLen, int nPackFileNumber, int nPackFileID) = 0; + virtual void PrecacheParticleSystemFile(const char* pszFilename) = 0; + virtual void ClientConnectionValidatePreNetChan(bool, const char*, int, unsigned long long) = 0; + virtual void OnEngineClientNetworkEvent(edict_t*, unsigned long long, int, void*) = 0; + virtual void GetNewestSubscribedFiles() = 0; + virtual bool ValidateAndAddActiveCaster(const CSteamID&) = 0; +}; + +#define VENGINE_SERVER_RANDOM_INTERFACE_VERSION "VEngineRandom001" + +#define INTERFACEVERSION_SERVERGAMEENTS "ServerGameEnts001" +abstract_class IServerGameEnts +{ +public: + virtual ~IServerGameEnts() {} + + virtual void MarkEntitiesAsTouching(edict_t * e1, edict_t * e2) = 0; + + virtual void FreeContainingEntity(edict_t*) = 0; + + virtual edict_t* BaseEntityToEdict(CBaseEntity* pEnt) = 0; + virtual CBaseEntity* EdictToBaseEntity(edict_t* pEdict) = 0; + + virtual void CheckTransmit(CCheckTransmitInfo* pInfo, const unsigned short* pEdictIndices, int nEdicts) = 0; + + virtual void PrepareForFullUpdate(edict_t* pEdict) = 0; +}; + +#define INTERFACEVERSION_SERVERGAMECLIENTS "ServerGameClients004" + +abstract_class IServerGameClients +{ +public: + virtual void GetPlayerLimits(int& minplayers, int& maxplayers, int& defaultMaxPlayers) const = 0; + + virtual bool ClientConnect(edict_t* pEntity, const char* pszName, const char* pszAddress, char* reject, int maxrejectlen) = 0; + + virtual void ClientActive(edict_t* pEntity, bool bLoadGame) = 0; + + virtual void ClientFullyConnect(edict_t* pEntity) = 0; + + virtual void ClientDisconnect(edict_t* pEntity) = 0; + + virtual void ClientPutInServer(edict_t* pEntity, char const* playername) = 0; + + virtual void ClientCommand(edict_t* pEntity, const CCommand& args) = 0; + + virtual void SetCommandClient(int index) = 0; + + virtual void ClientSettingsChanged(edict_t* pEdict) = 0; + + virtual void ClientSetupVisibility(edict_t* pViewEntity, edict_t* pClient, unsigned char* pvs, int pvssize) = 0; + + virtual float ProcessUsercmds(edict_t* player, bf_read* buf, int numcmds, int totalcmds, + int dropped_packets, bool ignore, bool paused) = 0; + + virtual void PostClientMessagesSent(void) = 0; + + virtual CPlayerState* GetPlayerState(edict_t* player) = 0; + + virtual void ClientEarPosition(edict_t* pEntity, Vector* pEarOrigin) = 0; + + virtual bool ClientReplayEvent(edict_t* player, void* event ) = 0; + + virtual int GetReplayDelay(edict_t* player, int& entity) = 0; + + virtual void GetBugReportInfo(char* buf, int buflen) = 0; + + virtual void ClientVoice(edict_t* pEdict) = 0; + + virtual void NetworkIDValidated(const char* pszUserName, const char* pszNetworkID, CSteamID steamID) = 0; + + virtual int GetMaxSplitscreenPlayers() = 0; + + virtual int GetMaxHumanPlayers() = 0; + + virtual void ClientCommandKeyValues(edict_t* pEntity, KeyValues* pKeyValues) = 0; + + virtual void ClientNameHandler(unsigned long long steamid, const char* name) = 0; +}; + +#define INTERFACEVERSION_UPLOADGAMESTATS "ServerUploadGameStats001" + +abstract_class IUploadGameStats +{ +public: + virtual bool UploadGameStats( + char const* mapname, + unsigned int blobversion, + unsigned int blobsize, + const void* pvBlobData) = 0; + + virtual void InitConnection(void) = 0; + + virtual void UpdateConnection(void) = 0; + + virtual bool IsGameStatsLoggingEnabled() = 0; + + virtual void GetPseudoUniqueId(char* buf, size_t bufsize) = 0; + + virtual bool IsCyberCafeUser(void) = 0; + + virtual bool IsHDREnabled(void) = 0; +}; + +#define INTERFACEVERSION_PLUGINHELPERSCHECK "PluginHelpersCheck001" + +abstract_class IPluginHelpersCheck +{ +public: + virtual bool CreateMessage(const char* plugin, edict_t * pEntity, DIALOG_TYPE type, KeyValues * data) = 0; +}; + +abstract_class IServerDLLSharedAppSystems +{ +public: + virtual int Count() = 0; + virtual char const* GetDllName(int idx) = 0; + virtual char const* GetInterfaceName(int idx) = 0; +}; + +#define SERVER_DLL_SHARED_APPSYSTEMS "VServerDllSharedAppSystems001" + +#define INTERFACEVERSION_SERVERGAMETAGS "ServerGameTags001" + +abstract_class IServerGameTags +{ +public: + virtual void GetTaggedConVarList(KeyValues * pCvarTagList) = 0; +}; + +extern IVEngineServer* g_pEngineServer; +extern IServerGameDLL* g_pServerGameDLL; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/enginetrace.h b/SpyCustom/sdk/enginetrace.h new file mode 100644 index 0000000..3d9e9f5 --- /dev/null +++ b/SpyCustom/sdk/enginetrace.h @@ -0,0 +1,18 @@ +#ifndef ENGINETRACE_H +#define ENGINETRACE_H + +#ifdef _WIN32 +#pragma once +#endif + + +#include "IEngineTrace.h" + +extern IEngineTrace* g_pEngineTraceServer; +extern IEngineTrace* g_pEngineTraceClient; + + +void EngineTraceRenderRayCasts(); + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/entitylist.h b/SpyCustom/sdk/entitylist.h new file mode 100644 index 0000000..85e36c0 --- /dev/null +++ b/SpyCustom/sdk/entitylist.h @@ -0,0 +1,352 @@ +#ifndef ENTITYLIST_H +#define ENTITYLIST_H + +#ifdef _WIN32 +#pragma once +#endif + +class CBaseEntity; +class IEntityListener; + +class CBaseEntityClassList +{ +public: + CBaseEntityClassList(); + ~CBaseEntityClassList(); + virtual void LevelShutdownPostEntity() = 0; + + CBaseEntityClassList* m_pNextClassList; +}; + +template< class T > +class CEntityClassList : public CBaseEntityClassList +{ +public: + virtual void LevelShutdownPostEntity() { m_pClassList = NULL; } + + void Insert(T* pEntity) + { + pEntity->m_pNext = m_pClassList; + m_pClassList = pEntity; + } + + void Remove(T* pEntity) + { + T** pPrev = &m_pClassList; + T* pCur = *pPrev; + while (pCur) + { + if (pCur == pEntity) + { + *pPrev = pCur->m_pNext; + return; + } + pPrev = &pCur->m_pNext; + pCur = *pPrev; + } + } + + static T* m_pClassList; +}; + +abstract_class IEntityFindFilter +{ +public: + virtual bool ShouldFindEntity(CBaseEntity * pEntity) = 0; + virtual CBaseEntity* GetFilterResult(void) = 0; +}; + +class CGlobalEntityList : public CBaseEntityList +{ +public: +private: + int m_iHighestEnt; + int m_iNumEnts; + int m_iNumEdicts; + + bool m_bClearingEntities; + CUtlVector m_entityListeners; + +public: + CBaseHandle AddNetworkableEntity(IHandleEntity* pEnt, int index, int iForcedSerialNum = -1); + CBaseHandle AddNonNetworkableEntity(IHandleEntity* pEnt); + + void UpdateName(IHandleEntity* pEnt, CBaseHandle hEnt); + void UpdateName(IHandleEntity* pEnt); + + IServerNetworkable* GetServerNetworkable(CBaseHandle hEnt) const; + CBaseNetworkable* GetBaseNetworkable(CBaseHandle hEnt) const; + CBaseEntity* GetBaseEntity(CBaseHandle hEnt) const; + edict_t* GetEdict(CBaseHandle hEnt) const; + + int NumberOfEntities(void); + int NumberOfEdicts(void); + + void AddToDeleteList(IServerNetworkable* ent); + void CleanupDeleteList(void); + int ResetDeleteList(void); + + void Clear(void); + + bool IsClearingEntities() { return m_bClearingEntities; } + + void AddListenerEntity(IEntityListener* pListener); + void RemoveListenerEntity(IEntityListener* pListener); + + void ReportEntityFlagsChanged(CBaseEntity* pEntity, unsigned int flagsOld, unsigned int flagsNow); + void AddPostClientMessageEntity(CBaseEntity* pEntity); + void PostClientMessagesSent(); + + void NotifyCreateEntity(CBaseEntity* pEnt); + void NotifySpawn(CBaseEntity* pEnt); + void NotifyRemoveEntity(CBaseEntity* pEnt); + CBaseEntity* NextEnt(CBaseEntity* pCurrentEnt); + CBaseEntity* FirstEnt() { return NextEnt(NULL); } + + template< class T > + T* NextEntByClass(T* start) + { + for (CBaseEntity* x = NextEnt(start); x; x = NextEnt(x)) + { + start = dynamic_cast(x); + if (start) + return start; + } + return NULL; + } + + bool IsEntityPtr(void* pTest); + CBaseEntity* FindEntityByClassname(CBaseEntity* pStartEntity, const char* szName); + CBaseEntity* FindEntityByName(CBaseEntity* pStartEntity, const char* szName, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL, IEntityFindFilter* pFilter = NULL); + CBaseEntity* FindEntityByName(CBaseEntity* pStartEntity, string_t iszName, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL, IEntityFindFilter* pFilter = NULL) + { + return FindEntityByName(pStartEntity, STRING(iszName), pSearchingEntity, pActivator, pCaller, pFilter); + } + CBaseEntity* FindEntityInSphere(CBaseEntity* pStartEntity, const Vector& vecCenter, float flRadius); + CBaseEntity* FindEntityByTarget(CBaseEntity* pStartEntity, const char* szName); + CBaseEntity* FindEntityByModel(CBaseEntity* pStartEntity, const char* szModelName); + CBaseEntity* FindEntityByOutputTarget(CBaseEntity* pStartEntity, string_t iTarget); + + CBaseEntity* FindEntityByNameNearest(const char* szName, const Vector& vecSrc, float flRadius, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL); + CBaseEntity* FindEntityByNameWithin(CBaseEntity* pStartEntity, const char* szName, const Vector& vecSrc, float flRadius, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL); + CBaseEntity* FindEntityByClassnameNearest(const char* szName, const Vector& vecSrc, float flRadius); + CBaseEntity* FindEntityByClassnameNearest2D(const char* szName, const Vector& vecSrc, float flRadius); + CBaseEntity* FindEntityByClassnameWithin(CBaseEntity* pStartEntity, const char* szName, const Vector& vecSrc, float flRadius); + CBaseEntity* FindEntityByClassnameWithin(CBaseEntity* pStartEntity, const char* szName, const Vector& vecMins, const Vector& vecMaxs); + + CBaseEntity* FindEntityGeneric(CBaseEntity* pStartEntity, const char* szName, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL); + CBaseEntity* FindEntityGenericWithin(CBaseEntity* pStartEntity, const char* szName, const Vector& vecSrc, float flRadius, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL); + CBaseEntity* FindEntityGenericNearest(const char* szName, const Vector& vecSrc, float flRadius, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL); + + CBaseEntity* FindEntityNearestFacing(const Vector& origin, const Vector& facing, float threshold); + CBaseEntity* FindEntityClassNearestFacing(const Vector& origin, const Vector& facing, float threshold, char* classname); + CBaseEntity* FindEntityByNetname(CBaseEntity* pStartEntity, const char* szModelName); + + CBaseEntity* FindEntityProcedural(const char* szName, CBaseEntity* pSearchingEntity = NULL, CBaseEntity* pActivator = NULL, CBaseEntity* pCaller = NULL); + + CBaseEntity* FindEntityByClassnameFast(CBaseEntity* pStartEntity, string_t iszClassname); + CBaseEntity* FindEntityByClassnameNearestFast(string_t iszClassname, const Vector& vecSrc, float flRadius); + CBaseEntity* FindEntityByNameFast(CBaseEntity* pStartEntity, string_t iszName); + + CGlobalEntityList(); + +protected: + + virtual void OnAddEntity(IHandleEntity* pEnt, CBaseHandle handle); + virtual void OnRemoveEntity(IHandleEntity* pEnt, CBaseHandle handle); + +}; + +extern CGlobalEntityList gEntList; + + +inline CBaseHandle CGlobalEntityList::AddNetworkableEntity(IHandleEntity* pEnt, int index, int iForcedSerialNum) +{ + CBaseHandle h = CBaseEntityList::AddNetworkableEntity(pEnt, index, iForcedSerialNum); + UpdateName(pEnt, h); + return h; +} + +inline CBaseHandle CGlobalEntityList::AddNonNetworkableEntity(IHandleEntity* pEnt) +{ + CBaseHandle h = CBaseEntityList::AddNonNetworkableEntity(pEnt); + UpdateName(pEnt, h); + return h; +} + +inline edict_t* CGlobalEntityList::GetEdict(CBaseHandle hEnt) const +{ + IServerUnknown* pUnk = static_cast(LookupEntity(hEnt)); + if (pUnk) + return pUnk->GetNetworkable()->GetEdict(); + else + return NULL; +} + +inline CBaseNetworkable* CGlobalEntityList::GetBaseNetworkable(CBaseHandle hEnt) const +{ + IServerUnknown* pUnk = static_cast(LookupEntity(hEnt)); + if (pUnk) + return pUnk->GetNetworkable()->GetBaseNetworkable(); + else + return NULL; +} + +inline IServerNetworkable* CGlobalEntityList::GetServerNetworkable(CBaseHandle hEnt) const +{ + IServerUnknown* pUnk = static_cast(LookupEntity(hEnt)); + if (pUnk) + return pUnk->GetNetworkable(); + else + return NULL; +} + +inline CBaseEntity* CGlobalEntityList::GetBaseEntity(CBaseHandle hEnt) const +{ + IServerUnknown* pUnk = static_cast(LookupEntity(hEnt)); + if (pUnk) + return pUnk->GetBaseEntity(); + else + return NULL; +} + + +#if 0 + +template +inline bool FindEntityByName(const char* pszName, ENT_TYPE** ppResult) +{ + CBaseEntity* pBaseEntity = gEntList.FindEntityByName(NULL, pszName); + + if (pBaseEntity) + *ppResult = dynamic_cast(pBaseEntity); + else + *ppResult = NULL; + + return (*ppResult != NULL); +} + +template <> +inline bool FindEntityByName(const char* pszName, CBaseEntity** ppResult) +{ + *ppResult = gEntList.FindEntityByName(NULL, pszName); + return (*ppResult != NULL); +} + +template <> +inline bool FindEntityByName(const char* pszName, CAI_BaseNPC** ppResult) +{ + CBaseEntity* pBaseEntity = gEntList.FindEntityByName(NULL, pszName); + + if (pBaseEntity) + *ppResult = pBaseEntity->MyNPCPointer(); + else + *ppResult = NULL; + + return (*ppResult != NULL); +} +#endif +struct entitem_t +{ + EHANDLE hEnt; + struct entitem_t* pNext; + + static void* operator new(size_t stAllocateBlock); + static void* operator new(size_t stAllocateBlock, int nBlockUse, const char* pFileName, int nLine); + static void operator delete(void* pMem); + static void operator delete(void* pMem, int nBlockUse, const char* pFileName, int nLine) { operator delete(pMem); } +}; + +class CEntityList +{ +public: + CEntityList(); + ~CEntityList(); + + int m_iNumItems; + entitem_t* m_pItemList; + + void AddEntity(CBaseEntity*); + void DeleteEntity(CBaseEntity*); +}; + +enum notify_system_event_t +{ + NOTIFY_EVENT_TELEPORT = 0, + NOTIFY_EVENT_DESTROY, +}; + +struct notify_teleport_params_t +{ + Vector prevOrigin; + QAngle prevAngles; + bool physicsRotate; +}; + +struct notify_destroy_params_t +{ +}; + +struct notify_system_event_params_t +{ + union + { + const notify_teleport_params_t* pTeleport; + const notify_destroy_params_t* pDestroy; + }; + notify_system_event_params_t(const notify_teleport_params_t* pInTeleport) { pTeleport = pInTeleport; } + notify_system_event_params_t(const notify_destroy_params_t* pInDestroy) { pDestroy = pInDestroy; } +}; + + +abstract_class INotify +{ +public: + virtual void AddEntity(CBaseEntity * pNotify, CBaseEntity * pWatched) = 0; + + virtual void RemoveEntity(CBaseEntity* pNotify, CBaseEntity* pWatched) = 0; + + virtual void ReportNamedEvent(CBaseEntity* pEntity, const char* pEventName) = 0; + + virtual void ReportSystemEvent(CBaseEntity* pEntity, notify_system_event_t eventType, const notify_system_event_params_t& params) = 0; + + inline void ReportDestroyEvent(CBaseEntity* pEntity) + { + notify_destroy_params_t destroy; + ReportSystemEvent(pEntity, NOTIFY_EVENT_DESTROY, notify_system_event_params_t(&destroy)); + } + + inline void ReportTeleportEvent(CBaseEntity* pEntity, const Vector& prevOrigin, const QAngle& prevAngles, bool physicsRotate) + { + notify_teleport_params_t teleport; + teleport.prevOrigin = prevOrigin; + teleport.prevAngles = prevAngles; + teleport.physicsRotate = physicsRotate; + ReportSystemEvent(pEntity, NOTIFY_EVENT_TELEPORT, notify_system_event_params_t(&teleport)); + } + + virtual void ClearEntity(CBaseEntity* pNotify) = 0; +}; + +class IEntityListener +{ +public: + virtual void OnEntityCreated(CBaseEntity* pEntity) {}; + virtual void OnEntitySpawned(CBaseEntity* pEntity) {}; + virtual void OnEntityDeleted(CBaseEntity* pEntity) {}; +}; + +extern INotify* g_pNotify; + +void EntityTouch_Add(CBaseEntity* pEntity); +void EntityTouch_Remove(CBaseEntity* pEntity); +int AimTarget_ListCount(); +int AimTarget_ListCopy(CBaseEntity* pList[], int listMax); +CBaseEntity* AimTarget_ListElement(int iIndex); +void AimTarget_ForceRepopulateList(); + +void SimThink_EntityChanged(CBaseEntity* pEntity); +int SimThink_ListCount(); +int SimThink_ListCopy(CBaseEntity* pList[], int listMax); + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/entitylist_base.h b/SpyCustom/sdk/entitylist_base.h new file mode 100644 index 0000000..9402e40 --- /dev/null +++ b/SpyCustom/sdk/entitylist_base.h @@ -0,0 +1,184 @@ +#ifndef ENTITYLIST_BASE_H +#define ENTITYLIST_BASE_H +#ifdef _WIN32 +#pragma once +#endif + + +#include "const.h" +#include "basehandle.h" +#include "utllinkedlist.h" +#include "ihandleentity.h" + + +class CEntInfo +{ +public: + IHandleEntity* m_pEntity; + int m_SerialNumber; + CEntInfo* m_pPrev; + CEntInfo* m_pNext; + + void ClearLinks(); +}; + + +class CBaseEntityList +{ +public: + CBaseEntityList(); + ~CBaseEntityList(); + + CBaseHandle AddNetworkableEntity(IHandleEntity* pEnt, int index, int iForcedSerialNum = -1); + CBaseHandle AddNonNetworkableEntity(IHandleEntity* pEnt); + void RemoveEntity(CBaseHandle handle); + + CBaseHandle GetNetworkableHandle(int iEntity) const; + + IHandleEntity* LookupEntity(const CBaseHandle& handle) const; + IHandleEntity* LookupEntityByNetworkIndex(int edictIndex) const; + + CBaseHandle FirstHandle() const; + CBaseHandle NextHandle(CBaseHandle hEnt) const; + static CBaseHandle InvalidHandle(); + + const CEntInfo* FirstEntInfo() const; + const CEntInfo* NextEntInfo(const CEntInfo* pInfo) const; + const CEntInfo* GetEntInfoPtr(const CBaseHandle& hEnt) const; + const CEntInfo* GetEntInfoPtrByIndex(int index) const; + +protected: + + virtual void OnAddEntity(IHandleEntity* pEnt, CBaseHandle handle); + + virtual void OnRemoveEntity(IHandleEntity* pEnt, CBaseHandle handle); + + +private: + + CBaseHandle AddEntityAtSlot(IHandleEntity* pEnt, int iSlot, int iForcedSerialNum); + void RemoveEntityAtSlot(int iSlot); + + +private: + + class CEntInfoList + { + public: + CEntInfoList(); + + const CEntInfo* Head() const { return m_pHead; } + const CEntInfo* Tail() const { return m_pTail; } + CEntInfo* Head() { return m_pHead; } + CEntInfo* Tail() { return m_pTail; } + void AddToHead(CEntInfo* pElement) { LinkAfter(NULL, pElement); } + void AddToTail(CEntInfo* pElement) { LinkBefore(NULL, pElement); } + + void LinkBefore(CEntInfo* pBefore, CEntInfo* pElement); + void LinkAfter(CEntInfo* pBefore, CEntInfo* pElement); + void Unlink(CEntInfo* pElement); + bool IsInList(CEntInfo* pElement); + + private: + CEntInfo* m_pHead; + CEntInfo* m_pTail; + }; + + int GetEntInfoIndex(const CEntInfo* pEntInfo) const; + + + CEntInfo m_EntPtrArray[NUM_ENT_ENTRIES]; + CEntInfoList m_activeList; + CEntInfoList m_freeNonNetworkableList; +}; + + +inline int CBaseEntityList::GetEntInfoIndex(const CEntInfo* pEntInfo) const +{ + Assert(pEntInfo); + int index = (int)(pEntInfo - m_EntPtrArray); + Assert(index >= 0 && index < NUM_ENT_ENTRIES); + return index; +} + +inline CBaseHandle CBaseEntityList::GetNetworkableHandle(int iEntity) const +{ + Assert(iEntity >= 0 && iEntity < MAX_EDICTS); + if (m_EntPtrArray[iEntity].m_pEntity) + return CBaseHandle(iEntity, m_EntPtrArray[iEntity].m_SerialNumber); + else + return CBaseHandle(); +} + + +inline IHandleEntity* CBaseEntityList::LookupEntity(const CBaseHandle& handle) const +{ + if (handle.m_Index == INVALID_EHANDLE_INDEX) + return NULL; + + const CEntInfo* pInfo = &m_EntPtrArray[handle.GetEntryIndex()]; + if (pInfo->m_SerialNumber == handle.GetSerialNumber()) + return (IHandleEntity*)pInfo->m_pEntity; + else + return NULL; +} + + +inline IHandleEntity* CBaseEntityList::LookupEntityByNetworkIndex(int edictIndex) const +{ + if (edictIndex < 0) + return NULL; + + Assert(edictIndex < NUM_ENT_ENTRIES); + return (IHandleEntity*)m_EntPtrArray[edictIndex].m_pEntity; +} + + +inline CBaseHandle CBaseEntityList::FirstHandle() const +{ + if (!m_activeList.Head()) + return INVALID_EHANDLE_INDEX; + + int index = GetEntInfoIndex(m_activeList.Head()); + return CBaseHandle(index, m_EntPtrArray[index].m_SerialNumber); +} + +inline CBaseHandle CBaseEntityList::NextHandle(CBaseHandle hEnt) const +{ + int iSlot = hEnt.GetEntryIndex(); + CEntInfo* pNext = m_EntPtrArray[iSlot].m_pNext; + if (!pNext) + return INVALID_EHANDLE_INDEX; + + int index = GetEntInfoIndex(pNext); + + return CBaseHandle(index, m_EntPtrArray[index].m_SerialNumber); +} + +inline CBaseHandle CBaseEntityList::InvalidHandle() +{ + return INVALID_EHANDLE_INDEX; +} + +inline const CEntInfo* CBaseEntityList::FirstEntInfo() const +{ + return m_activeList.Head(); +} + +inline const CEntInfo* CBaseEntityList::NextEntInfo(const CEntInfo* pInfo) const +{ + return pInfo->m_pNext; +} + +inline const CEntInfo* CBaseEntityList::GetEntInfoPtr(const CBaseHandle& hEnt) const +{ + int iSlot = hEnt.GetEntryIndex(); + return &m_EntPtrArray[iSlot]; +} + +inline const CEntInfo* CBaseEntityList::GetEntInfoPtrByIndex(int index) const +{ + return &m_EntPtrArray[index]; +} + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/expressioncalculator.h b/SpyCustom/sdk/expressioncalculator.h new file mode 100644 index 0000000..b7e27f8 --- /dev/null +++ b/SpyCustom/sdk/expressioncalculator.h @@ -0,0 +1,65 @@ +#ifndef MATHLIB_EXPRESSION_CALCULATOR_H +#define MATHLIB_EXPRESSION_CALCULATOR_H +#ifdef _WIN32 +#pragma once +#endif + +#include "utlstring.h" +#include "utlstack.h" +#include "utlvector.h" + + +class CExpressionCalculator +{ +public: + CExpressionCalculator(const char* expr = NULL) : m_expr(expr) {} + + CExpressionCalculator(const CExpressionCalculator& x); + CExpressionCalculator& operator=(const CExpressionCalculator& x); + +public: + void SetExpression(const char* expr) + { + m_expr = expr; + } + + void SetVariable(const char* var, float value); + void SetVariable(int nVariableIndex, float value); + void ModifyVariable(const char* var, float value); + + int FindVariableIndex(const char* var); + + bool Evaluate(float& value); + + bool BuildVariableListFromExpression(); + + int VariableCount(); + const char* VariableName(int nIndex); + +private: + bool ParseExpr(const char*& expr); + bool ParseConditional(const char*& expr); + bool ParseOr(const char*& expr); + bool ParseAnd(const char*& expr); + bool ParseEquality(const char*& expr); + bool ParseLessGreater(const char*& expr); + bool ParseAddSub(const char*& expr); + bool ParseDivMul(const char*& expr); + bool ParseUnary(const char*& expr); + bool ParsePrimary(const char*& expr); + bool Parse1ArgFunc(const char*& expr); + bool Parse2ArgFunc(const char*& expr); + bool Parse3ArgFunc(const char*& expr); + bool Parse5ArgFunc(const char*& expr); + + CUtlString m_expr; + CUtlVector< CUtlString > m_varNames; + CUtlVector m_varValues; + CUtlStack m_stack; + bool m_bIsBuildingArgumentList; +}; + +float EvaluateExpression(char const* pExprString, float flValueToReturnIfFailure); + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/exprevaluator.h b/SpyCustom/sdk/exprevaluator.h new file mode 100644 index 0000000..9d8c619 --- /dev/null +++ b/SpyCustom/sdk/exprevaluator.h @@ -0,0 +1,66 @@ +#ifndef EXPREVALUATOR_H +#define EXPREVALUATOR_H + +#if defined( _WIN32 ) +#pragma once +#endif + +static const char OR_OP = '|'; +static const char AND_OP = '&'; +static const char NOT_OP = '!'; + +#define MAX_IDENTIFIER_LEN 128 +enum Kind { CONDITIONAL, NOT, LITERAL }; + +struct ExprNode +{ + ExprNode* left; + ExprNode* right; + Kind kind; + union + { + char cond; + bool value; + } data; +}; + +typedef ExprNode* ExprTree; + +typedef bool (*GetSymbolProc_t)(const char* pKey); +typedef void (*SyntaxErrorProc_t)(const char* pReason); + +class CExpressionEvaluator +{ +public: + CExpressionEvaluator(); + ~CExpressionEvaluator(); + bool Evaluate(bool& result, const char* pInfixExpression, GetSymbolProc_t pGetSymbolProc = 0, SyntaxErrorProc_t pSyntaxErrorProc = 0); + +private: + CExpressionEvaluator(CExpressionEvaluator&); + + char GetNextToken(void); + void FreeNode(ExprNode* pNode); + ExprNode* AllocateNode(void); + void FreeTree(ExprTree& node); + bool IsConditional(bool& bCondition, const char token); + bool IsNotOp(const char token); + bool IsIdentifierOrConstant(const char token); + bool MakeExprNode(ExprTree& tree, char token, Kind kind, ExprTree left, ExprTree right); + bool MakeFactor(ExprTree& tree); + bool MakeTerm(ExprTree& tree); + bool MakeExpression(ExprTree& tree); + bool BuildExpression(void); + bool SimplifyNode(ExprTree& node); + + ExprTree m_ExprTree; + char m_CurToken; + const char* m_pExpression; + int m_CurPosition; + char m_Identifier[MAX_IDENTIFIER_LEN]; + GetSymbolProc_t m_pGetSymbolProc; + SyntaxErrorProc_t m_pSyntaxErrorProc; + bool m_bSetup; +}; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/fasttimer.h b/SpyCustom/sdk/fasttimer.h new file mode 100644 index 0000000..226f061 --- /dev/null +++ b/SpyCustom/sdk/fasttimer.h @@ -0,0 +1,505 @@ +#ifndef FASTTIMER_H +#define FASTTIMER_H +#ifdef _WIN32 +#pragma once +#endif + +#ifdef _WIN32 +#include +#endif + +#include +#include "platform.h" + +PLATFORM_INTERFACE uint64 g_ClockSpeed; +#if defined( _X360 ) && defined( _CERT ) +PLATFORM_INTERFACE unsigned long g_dwFakeFastCounter; +#endif + +PLATFORM_INTERFACE double g_ClockSpeedMicrosecondsMultiplier; +PLATFORM_INTERFACE double g_ClockSpeedMillisecondsMultiplier; +PLATFORM_INTERFACE double g_ClockSpeedSecondsMultiplier; + +class CCycleCount +{ + friend class CFastTimer; + +public: + CCycleCount(); + CCycleCount(uint64 cycles); + + void Sample(); + + void Init(); + void Init(float initTimeMsec); + void Init(double initTimeMsec) { Init((float)initTimeMsec); } + void Init(uint64 cycles); + bool IsLessThan(CCycleCount const& other) const; + + unsigned long GetCycles() const; + uint64 GetLongCycles() const; + + unsigned long GetMicroseconds() const; + uint64 GetUlMicroseconds() const; + double GetMicrosecondsF() const; + void SetMicroseconds(unsigned long nMicroseconds); + + unsigned long GetMilliseconds() const; + double GetMillisecondsF() const; + + double GetSeconds() const; + + CCycleCount& operator+=(CCycleCount const& other); + + static void Add(CCycleCount const& rSrc1, CCycleCount const& rSrc2, CCycleCount& dest); + + static void Sub(CCycleCount const& rSrc1, CCycleCount const& rSrc2, CCycleCount& dest); + + static uint64 GetTimestamp(); + + uint64 m_Int64; +}; + +class PLATFORM_CLASS CClockSpeedInit +{ +public: + CClockSpeedInit() + { + Init(); + } + + static void Init(); +}; + +class CFastTimer +{ +public: + void Start(); + void End(); + + const CCycleCount& GetDuration() const; + CCycleCount GetDurationInProgress() const; + + static inline int64 GetClockSpeed(); + +private: + CCycleCount m_Duration; +#ifdef DEBUG_FASTTIMER + bool m_bRunning; +#endif +}; + + +class CTimeScope +{ +public: + CTimeScope(CFastTimer* pTimer); + ~CTimeScope(); + +private: + CFastTimer* m_pTimer; +}; + +inline CTimeScope::CTimeScope(CFastTimer* pTotal) +{ + m_pTimer = pTotal; + m_pTimer->Start(); +} + +inline CTimeScope::~CTimeScope() +{ + m_pTimer->End(); +} + +class CTimeAdder +{ +public: + CTimeAdder(CCycleCount* pTotal); + ~CTimeAdder(); + + void End(); + +private: + CCycleCount* m_pTotal; + CFastTimer m_Timer; +}; + +inline CTimeAdder::CTimeAdder(CCycleCount* pTotal) +{ + m_pTotal = pTotal; + m_Timer.Start(); +} + +inline CTimeAdder::~CTimeAdder() +{ + End(); +} + +inline void CTimeAdder::End() +{ + if (m_pTotal) + { + m_Timer.End(); + *m_pTotal += m_Timer.GetDuration(); + m_pTotal = 0; + } +} + + + +#define PROFILE_SCOPE(name) \ + class C##name##ACC : public CAverageCycleCounter \ + { \ + public: \ + ~C##name##ACC() \ + { \ + Msg("%-48s: %6.3f avg (%8.1f total, %7.3f peak, %5d iters)\n", \ + #name, \ + GetAverageMilliseconds(), \ + GetTotalMilliseconds(), \ + GetPeakMilliseconds(), \ + GetIters() ); \ + } \ + }; \ + static C##name##ACC name##_ACC; \ + CAverageTimeMarker name##_ATM( &name##_ACC ) + +#define TIME_SCOPE(name) \ + class CTimeScopeMsg_##name \ + { \ + public: \ + CTimeScopeMsg_##name() { m_Timer.Start(); } \ + ~CTimeScopeMsg_##name() \ + { \ + m_Timer.End(); \ + Msg( #name "time: %.4fms\n", m_Timer.GetDuration().GetMillisecondsF() ); \ + } \ + private: \ + CFastTimer m_Timer; \ + } name##_TSM; + + +class CAverageCycleCounter +{ +public: + CAverageCycleCounter(); + + void Init(); + void MarkIter(const CCycleCount& duration); + + unsigned GetIters() const; + + double GetAverageMilliseconds() const; + double GetTotalMilliseconds() const; + double GetPeakMilliseconds() const; + +private: + unsigned m_nIters; + CCycleCount m_Total; + CCycleCount m_Peak; +}; + +class CAverageTimeMarker +{ +public: + CAverageTimeMarker(CAverageCycleCounter* pCounter); + ~CAverageTimeMarker(); + +private: + CAverageCycleCounter* m_pCounter; + CFastTimer m_Timer; +}; + + +inline CCycleCount::CCycleCount() +{ + Init((uint64)0); +} + +inline CCycleCount::CCycleCount(uint64 cycles) +{ + Init(cycles); +} + +inline void CCycleCount::Init() +{ + Init((uint64)0); +} + +inline void CCycleCount::Init(float initTimeMsec) +{ + if (g_ClockSpeedMillisecondsMultiplier > 0) + Init((uint64)(initTimeMsec / g_ClockSpeedMillisecondsMultiplier)); + else + Init((uint64)0); +} + +inline void CCycleCount::Init(uint64 cycles) +{ + m_Int64 = cycles; +} + +inline void CCycleCount::Sample() +{ + m_Int64 = Plat_Rdtsc(); +} + +inline CCycleCount& CCycleCount::operator+=(CCycleCount const& other) +{ + m_Int64 += other.m_Int64; + return *this; +} + + +inline void CCycleCount::Add(CCycleCount const& rSrc1, CCycleCount const& rSrc2, CCycleCount& dest) +{ + dest.m_Int64 = rSrc1.m_Int64 + rSrc2.m_Int64; +} + +inline void CCycleCount::Sub(CCycleCount const& rSrc1, CCycleCount const& rSrc2, CCycleCount& dest) +{ + dest.m_Int64 = rSrc1.m_Int64 - rSrc2.m_Int64; +} + +inline uint64 CCycleCount::GetTimestamp() +{ + CCycleCount c; + c.Sample(); + return c.GetLongCycles(); +} + +inline bool CCycleCount::IsLessThan(CCycleCount const& other) const +{ + return m_Int64 < other.m_Int64; +} + + +inline unsigned long CCycleCount::GetCycles() const +{ + return (unsigned long)m_Int64; +} + +inline uint64 CCycleCount::GetLongCycles() const +{ + return m_Int64; +} + +inline unsigned long CCycleCount::GetMicroseconds() const +{ + return (unsigned long)((m_Int64 * 1000000) / g_ClockSpeed); +} + +inline uint64 CCycleCount::GetUlMicroseconds() const +{ + return ((m_Int64 * 1000000) / g_ClockSpeed); +} + + +inline double CCycleCount::GetMicrosecondsF() const +{ + return (double)(m_Int64 * g_ClockSpeedMicrosecondsMultiplier); +} + + +inline void CCycleCount::SetMicroseconds(unsigned long nMicroseconds) +{ + m_Int64 = ((uint64)nMicroseconds * g_ClockSpeed) / 1000000; +} + + +inline unsigned long CCycleCount::GetMilliseconds() const +{ + return (unsigned long)((m_Int64 * 1000) / g_ClockSpeed); +} + + +inline double CCycleCount::GetMillisecondsF() const +{ + return (double)(m_Int64 * g_ClockSpeedMillisecondsMultiplier); +} + + +inline double CCycleCount::GetSeconds() const +{ + return (double)(m_Int64 * g_ClockSpeedSecondsMultiplier); +} + + +inline void CFastTimer::Start() +{ + m_Duration.Sample(); +#ifdef DEBUG_FASTTIMER + m_bRunning = true; +#endif +} + + +inline void CFastTimer::End() +{ + CCycleCount cnt; + cnt.Sample(); + if (IsX360()) + { + if ((uint64)cnt.m_Int64 <= (uint64)m_Duration.m_Int64) + { + cnt.m_Int64 += 0x100000000LL; + } + } + + m_Duration.m_Int64 = cnt.m_Int64 - m_Duration.m_Int64; + +#ifdef DEBUG_FASTTIMER + m_bRunning = false; +#endif +} + +inline CCycleCount CFastTimer::GetDurationInProgress() const +{ + CCycleCount cnt; + cnt.Sample(); + if (IsX360()) + { + if ((uint64)cnt.m_Int64 <= (uint64)m_Duration.m_Int64) + { + cnt.m_Int64 += 0x100000000LL; + } + } + + CCycleCount result; + result.m_Int64 = cnt.m_Int64 - m_Duration.m_Int64; + + return result; +} + + +inline int64 CFastTimer::GetClockSpeed() +{ + return g_ClockSpeed; +} + + +inline CCycleCount const& CFastTimer::GetDuration() const +{ +#ifdef DEBUG_FASTTIMER + assert(!m_bRunning); +#endif + return m_Duration; +} + + +inline CAverageCycleCounter::CAverageCycleCounter() + : m_nIters(0) +{ +} + +inline void CAverageCycleCounter::Init() +{ + m_Total.Init(); + m_Peak.Init(); + m_nIters = 0; +} + +inline void CAverageCycleCounter::MarkIter(const CCycleCount& duration) +{ + ++m_nIters; + m_Total += duration; + if (m_Peak.IsLessThan(duration)) + m_Peak = duration; +} + +inline unsigned CAverageCycleCounter::GetIters() const +{ + return m_nIters; +} + +inline double CAverageCycleCounter::GetAverageMilliseconds() const +{ + if (m_nIters) + return (m_Total.GetMillisecondsF() / (double)m_nIters); + else + return 0; +} + +inline double CAverageCycleCounter::GetTotalMilliseconds() const +{ + return m_Total.GetMillisecondsF(); +} + +inline double CAverageCycleCounter::GetPeakMilliseconds() const +{ + return m_Peak.GetMillisecondsF(); +} + +inline CAverageTimeMarker::CAverageTimeMarker(CAverageCycleCounter* pCounter) +{ + m_pCounter = pCounter; + m_Timer.Start(); +} + +inline CAverageTimeMarker::~CAverageTimeMarker() +{ + m_Timer.End(); + m_pCounter->MarkIter(m_Timer.GetDuration()); +} + + +class CLimitTimer +{ +public: + CLimitTimer() {} + CLimitTimer(uint64 cMicroSecDuration) { SetLimit(cMicroSecDuration); } + void SetLimit(uint64 m_cMicroSecDuration); + bool BLimitReached() const; + + int CMicroSecOverage() const; + uint64 CMicroSecLeft() const; + +private: + uint64 m_lCycleLimit; +}; + + +inline void CLimitTimer::SetLimit(uint64 cMicroSecDuration) +{ + uint64 dlCycles = ((uint64)cMicroSecDuration * g_ClockSpeed) / (uint64)1000000L; + CCycleCount cycleCount; + cycleCount.Sample(); + m_lCycleLimit = cycleCount.GetLongCycles() + dlCycles; +} + + +inline bool CLimitTimer::BLimitReached() const +{ + CCycleCount cycleCount; + cycleCount.Sample(); + return (cycleCount.GetLongCycles() >= m_lCycleLimit); +} + + +inline int CLimitTimer::CMicroSecOverage() const +{ + CCycleCount cycleCount; + cycleCount.Sample(); + uint64 lcCycles = cycleCount.GetLongCycles(); + + if (lcCycles < m_lCycleLimit) + return 0; + + return((int)((lcCycles - m_lCycleLimit) * (uint64)1000000L / g_ClockSpeed)); +} + + +inline uint64 CLimitTimer::CMicroSecLeft() const +{ + CCycleCount cycleCount; + cycleCount.Sample(); + uint64 lcCycles = cycleCount.GetLongCycles(); + + if (lcCycles >= m_lCycleLimit) + return 0; + + return((uint64)((m_lCycleLimit - lcCycles) * (uint64)1000000L / g_ClockSpeed)); +} + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/filesystem.h b/SpyCustom/sdk/filesystem.h new file mode 100644 index 0000000..567dd5f --- /dev/null +++ b/SpyCustom/sdk/filesystem.h @@ -0,0 +1,747 @@ +#ifndef FILESYSTEM_H +#define FILESYSTEM_H + +#ifdef _WIN32 +#pragma once +#endif + +#include + +#include "threadtools.h" +#include "memalloc.h" +#include "tslist.h" +#include "interface.h" +#include "utlsymbol.h" +#include "utlstring.h" +#include "functors.h" +#include "checksum_crc.h" +#include "checksum_md5.h" +#include "utlqueue.h" +#include "iappsystem.h" +#include "tier2.h" +#ifdef _PS3 +#include +#include +struct HddCacheFileStatus; +extern char gSrcGameDataPath[]; +class CFileGroupSystem; +#endif + +class CUtlBuffer; +class KeyValues; +class IFileList; + +typedef void* FileHandle_t; +typedef int FileFindHandle_t; +typedef void (*FileSystemLoggingFunc_t)(const char* fileName, const char* accessType); +typedef int WaitForResourcesHandle_t; + +#ifdef _X360 +typedef void* HANDLE; +#endif + +#define FILESYSTEM_MAX_SEARCH_PATHS 128 + +enum FileSystemSeek_t +{ + FILESYSTEM_SEEK_HEAD = SEEK_SET, + FILESYSTEM_SEEK_CURRENT = SEEK_CUR, + FILESYSTEM_SEEK_TAIL = SEEK_END, +}; + +enum +{ + FILESYSTEM_INVALID_FIND_HANDLE = -1 +}; + +enum FileWarningLevel_t +{ + FILESYSTEM_WARNING = -1, + + FILESYSTEM_WARNING_QUIET = 0, + + FILESYSTEM_WARNING_REPORTUNCLOSED, + + FILESYSTEM_WARNING_REPORTUSAGE, + + FILESYSTEM_WARNING_REPORTALLACCESSES, + + FILESYSTEM_WARNING_REPORTALLACCESSES_READ, + + FILESYSTEM_WARNING_REPORTALLACCESSES_READWRITE, + + FILESYSTEM_WARNING_REPORTALLACCESSES_ASYNC, + +}; + +enum PathTypeFilter_t +{ + FILTER_NONE = 0, + FILTER_CULLPACK = 1, + FILTER_CULLNONPACK = 2, + FILTER_CULLLOCALIZED = 3, + FILTER_CULLLOCALIZED_ANY = 4, +}; + +enum +{ + PATH_IS_NORMAL = 0x00, + PATH_IS_PACKFILE = 0x01, + PATH_IS_MAPPACKFILE = 0x02, + PATH_IS_DVDDEV = 0x04, +}; +typedef uint32 PathTypeQuery_t; + +#define IS_PACKFILE( n ) ( n & ( PATH_IS_PACKFILE | PATH_IS_MAPPACKFILE ) ) +#define IS_DVDDEV( n ) ( n & PATH_IS_DVDDEV ) + +enum DVDMode_t +{ + DVDMODE_OFF = 0, + DVDMODE_STRICT = 1, + DVDMODE_DEV = 2, + DVDMODE_DEV_VISTA = 3, +}; + +#ifdef _PS3 + +enum FsState_t +{ + FS_STATE_INIT = 0, + FS_STATE_LEVEL_LOAD = 1, + FS_STATE_LEVEL_RUN = 2, + FS_STATE_LEVEL_RESTORE = 3, + FS_STATE_LEVEL_LOAD_END = 4, + FS_STATE_EXITING = 5 +}; + +enum Ps3FileType_t +{ + PS3_FILETYPE_WAV, + PS3_FILETYPE_ANI, + PS3_FILETYPE_BSP, + PS3_FILETYPE_VMT, + PS3_FILETYPE_QPRE, + PS3_FILETYPE_OTHER, + PS3_FILETYPE_DIR, + PS3_FILETYPE_UNKNOWN +}; + + +#endif + +#if defined( TRACK_BLOCKING_IO ) +enum FileBlockingWarning_t +{ + FILESYSTEM_BLOCKING_SYNCHRONOUS = 0, + FILESYSTEM_BLOCKING_ASYNCHRONOUS_BLOCK, + FILESYSTEM_BLOCKING_ASYNCHRONOUS, + FILESYSTEM_BLOCKING_CALLBACKTIMING, + + FILESYSTEM_BLOCKING_NUMBINS, +}; + +#pragma pack(1) +class FileBlockingItem +{ +public: + enum + { + FB_ACCESS_OPEN = 1, + FB_ACCESS_CLOSE = 2, + FB_ACCESS_READ = 3, + FB_ACCESS_WRITE = 4, + FB_ACCESS_APPEND = 5, + FB_ACCESS_SIZE = 6 + }; + + FileBlockingItem() : + m_ItemType((FileBlockingWarning_t)0), + m_flElapsed(0.0f), + m_nAccessType(0) + { + SetFileName(NULL); + } + + FileBlockingItem(int type, char const* filename, float elapsed, int accessType) : + m_ItemType((FileBlockingWarning_t)type), + m_flElapsed(elapsed), + m_nAccessType(accessType) + { + SetFileName(filename); + } + + void SetFileName(char const* filename) + { + if (!filename) + { + m_szFilename[0] = 0; + return; + } + + int len = Q_strlen(filename); + if (len >= sizeof(m_szFilename)) + { + Q_strncpy(m_szFilename, &filename[len - sizeof(m_szFilename) + 1], sizeof(m_szFilename)); + } + else + { + Q_strncpy(m_szFilename, filename, sizeof(m_szFilename)); + } + } + + char const* GetFileName() const + { + return m_szFilename; + } + + FileBlockingWarning_t m_ItemType; + float m_flElapsed; + byte m_nAccessType; +private: + + char m_szFilename[32]; +}; +#pragma pack() + +class IBlockingFileItemList +{ +public: + + virtual void LockMutex() = 0; + virtual void UnlockMutex() = 0; + + virtual int First() const = 0; + virtual int Next(int i) const = 0; + virtual int InvalidIndex() const = 0; + + virtual const FileBlockingItem& Get(int index) const = 0; + + virtual void Reset() = 0; +}; + +#endif + +enum FilesystemMountRetval_t +{ + FILESYSTEM_MOUNT_OK = 0, + FILESYSTEM_MOUNT_FAILED, +}; + +enum SearchPathAdd_t +{ + PATH_ADD_TO_HEAD, + PATH_ADD_TO_TAIL, + PATH_ADD_TO_TAIL_ATINDEX, +}; + +enum FilesystemOpenExFlags_t +{ + FSOPEN_UNBUFFERED = (1 << 0), + FSOPEN_FORCE_TRACK_CRC = (1 << 1), + FSOPEN_NEVERINPACK = (1 << 2), +}; + +#define FILESYSTEM_INVALID_HANDLE ( FileHandle_t )0 + +struct FileSystemStatistics +{ + CInterlockedUInt nReads, + nWrites, + nBytesRead, + nBytesWritten, + nSeeks; +}; + +typedef void* (*FSAllocFunc_t)(const char* pszFilename, unsigned nBytes); + + +typedef void (*FSDirtyDiskReportFunc_t)(); + + +DECLARE_POINTER_HANDLE(FSAsyncControl_t); +DECLARE_POINTER_HANDLE(FSAsyncFile_t); +const FSAsyncFile_t FS_INVALID_ASYNC_FILE = (FSAsyncFile_t)(0x0000ffff); + + +enum FSAsyncStatus_t +{ + FSASYNC_ERR_ALIGNMENT = -6, + FSASYNC_ERR_FAILURE = -5, + FSASYNC_ERR_READING = -4, + FSASYNC_ERR_NOMEMORY = -3, + FSASYNC_ERR_UNKNOWNID = -2, + FSASYNC_ERR_FILEOPEN = -1, + FSASYNC_OK = 0, + FSASYNC_STATUS_PENDING, + FSASYNC_STATUS_INPROGRESS, + FSASYNC_STATUS_ABORTED, + FSASYNC_STATUS_UNSERVICED, +}; + +enum FSAsyncFlags_t +{ + FSASYNC_FLAGS_ALLOCNOFREE = (1 << 0), + FSASYNC_FLAGS_FREEDATAPTR = (1 << 1), + FSASYNC_FLAGS_SYNC = (1 << 2), + FSASYNC_FLAGS_NULLTERMINATE = (1 << 3), +}; + +enum EFileCRCStatus +{ + k_eFileCRCStatus_CantOpenFile, + k_eFileCRCStatus_GotCRC, + k_eFileCRCStatus_FileInVPK, +}; + +enum ECacheCRCType +{ + k_eCacheCRCType_SingleFile, + k_eCacheCRCType_Directory, + k_eCacheCRCType_Directory_Recursive +}; + +struct FileAsyncRequest_t; +typedef void (*FSAsyncCallbackFunc_t)(const FileAsyncRequest_t& request, int nBytesRead, FSAsyncStatus_t err); + +typedef void (*FSAsyncScanAddFunc_t)(void* pContext, char* pFoundPath, char* pFoundFile); +typedef void (*FSAsyncScanCompleteFunc_t)(void* pContext, FSAsyncStatus_t err); + +struct FileAsyncRequest_t +{ + FileAsyncRequest_t() { memset(this, 0, sizeof(*this)); hSpecificAsyncFile = FS_INVALID_ASYNC_FILE; } + const char* pszFilename; + void* pData; + int nOffset; + int nBytes; + FSAsyncCallbackFunc_t pfnCallback; + void* pContext; + int priority; + unsigned flags; + const char* pszPathID; + FSAsyncFile_t hSpecificAsyncFile; + FSAllocFunc_t pfnAlloc; +}; + + +struct FileHash_t +{ + enum EFileHashType_t + { + k_EFileHashTypeUnknown = 0, + k_EFileHashTypeEntireFile = 1, + k_EFileHashTypeIncompleteFile = 2, + }; + FileHash_t() + { + m_eFileHashType = FileHash_t::k_EFileHashTypeUnknown; + m_cbFileLen = 0; + m_PackFileID = 0; + m_nPackFileNumber = 0; + } + int m_eFileHashType; + CRC32_t m_crcIOSequence; + MD5Value_t m_md5contents; + int m_cbFileLen; + int m_PackFileID; + int m_nPackFileNumber; + + bool operator==(const FileHash_t& src) const + { + return m_crcIOSequence == src.m_crcIOSequence && + m_md5contents == src.m_md5contents && + m_eFileHashType == src.m_eFileHashType; + } + bool operator!=(const FileHash_t& src) const + { + return m_crcIOSequence != src.m_crcIOSequence || + m_md5contents != src.m_md5contents || + m_eFileHashType != src.m_eFileHashType; + } + +}; + +class CUnverifiedFileHash +{ +public: + char m_PathID[MAX_PATH]; + char m_Filename[MAX_PATH]; + int m_nFileFraction; + FileHash_t m_FileHash; +}; + +class CUnverifiedCRCFile +{ +public: + char m_PathID[MAX_PATH]; + char m_Filename[MAX_PATH]; + CRC32_t m_CRC; +}; + + +#define WHITELIST_SPEW_WHILE_LOADING 0x0001 +#define WHITELIST_SPEW_RELOAD_FILES 0x0002 +#define WHITELIST_SPEW_DONT_RELOAD_FILES 0x0004 + + + +#define DLC_LICENSE_ID( x ) ( ( ( (unsigned int)( x ) ) >> 24 ) & 0x000000FF ) +#define DLC_LICENSE_MINORVERSION( x ) ( ( ( (unsigned int)( x ) ) >> 16 ) & 0x000000FF ) +#define DLC_LICENSE_FLAGS( x ) ( ( ( (unsigned int)( x ) ) & 0x0000FFFF ) ) + +#define DLCFLAGS_PRESENCE_ONLY 0x0001 + + + +#define BASEFILESYSTEM_INTERFACE_VERSION "VBaseFileSystem011" + +abstract_class IThreadedFileMD5Processor +{ +public: + virtual int SubmitThreadedMD5Request(uint8 * pubBuffer, int cubBuffer, int PackFileID, int nPackFileNumber, int nPackFileFraction) = 0; + virtual bool BlockUntilMD5RequestComplete(int iRequest, MD5Value_t* pMd5ValueOut) = 0; + virtual bool IsMD5RequestComplete(int iRequest, MD5Value_t* pMd5ValueOut) = 0; +}; + +abstract_class IBaseFileSystem +{ +public: + virtual int Read(void* pOutput, int size, FileHandle_t file) = 0; + virtual int Write(void const* pInput, int size, FileHandle_t file) = 0; + + virtual FileHandle_t Open(const char* pFileName, const char* pOptions, const char* pathID = 0) = 0; + virtual void Close(FileHandle_t file) = 0; + + + virtual void Seek(FileHandle_t file, int pos, FileSystemSeek_t seekType) = 0; + virtual unsigned int Tell(FileHandle_t file) = 0; + virtual unsigned int Size(FileHandle_t file) = 0; + virtual unsigned int Size(const char* pFileName, const char* pPathID = 0) = 0; + + virtual void Flush(FileHandle_t file) = 0; + virtual bool Precache(const char* pFileName, const char* pPathID = 0) = 0; + + virtual bool FileExists(const char* pFileName, const char* pPathID = 0) = 0; + virtual bool IsFileWritable(char const* pFileName, const char* pPathID = 0) = 0; + virtual bool SetFileWritable(char const* pFileName, bool writable, const char* pPathID = 0) = 0; + + virtual long GetFileTime(const char* pFileName, const char* pPathID = 0) = 0; + + virtual bool ReadFile(const char* pFileName, const char* pPath, CUtlBuffer& buf, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL) = 0; + virtual bool WriteFile(const char* pFileName, const char* pPath, CUtlBuffer& buf) = 0; + virtual bool UnzipFile(const char* pFileName, const char* pPath, const char* pDestination) = 0; +}; + +abstract_class IIoStats +{ +public: + virtual void OnFileSeek(int nTimeInMs) = 0; + virtual void OnFileRead(int nTimeInMs, int nBytesRead) = 0; + virtual void OnFileOpen(const char* pFileName) = 0; + + virtual int GetNumberOfFileSeeks() = 0; + virtual int GetTimeInFileSeek() = 0; + + virtual int GetNumberOfFileReads() = 0; + virtual int GetTimeInFileReads() = 0; + virtual int GetFileReadTotalSize() = 0; + + virtual int GetNumberOfFileOpens() = 0; + + virtual void Reset() = 0; + +protected: + virtual ~IIoStats() + { + } +}; + +abstract_class IFileSystem : public IAppSystem, public IBaseFileSystem +{ +public: + virtual bool IsSteam() const = 0; + + virtual FilesystemMountRetval_t MountSteamContent(int nExtraAppId = -1) = 0; + + virtual void AddSearchPath(const char* pPath, const char* pathID, SearchPathAdd_t addType = PATH_ADD_TO_TAIL) = 0; + virtual bool RemoveSearchPath(const char* pPath, const char* pathID = 0) = 0; + + virtual void RemoveAllSearchPaths(void) = 0; + + virtual void RemoveSearchPaths(const char* szPathID) = 0; + + virtual void MarkPathIDByRequestOnly(const char* pPathID, bool bRequestOnly) = 0; + + virtual bool IsFileInReadOnlySearchPath(const char* pPath, const char* pathID = 0) = 0; + + virtual const char* RelativePathToFullPath(const char* pFileName, const char* pPathID, char* pLocalPath, int localPathBufferSize, PathTypeFilter_t pathFilter = FILTER_NONE, PathTypeQuery_t* pPathType = NULL) = 0; +#if IsGameConsole() + virtual bool GetPackFileInfoFromRelativePath(const char* pFileName, const char* pPathID, char* pPackPath, int nPackPathBufferSize, int64& nPosition, int64& nLength) = 0; +#endif + virtual int GetSearchPath(const char* pathID, bool bGetPackFiles, char* pPath, int nMaxLen) = 0; + + virtual bool AddPackFile(const char* fullpath, const char* pathID) = 0; + + virtual void RemoveFile(char const* pRelativePath, const char* pathID = 0) = 0; + + virtual bool RenameFile(char const* pOldPath, char const* pNewPath, const char* pathID = 0) = 0; + + virtual void CreateDirHierarchy(const char* path, const char* pathID = 0) = 0; + + virtual bool IsDirectory(const char* pFileName, const char* pathID = 0) = 0; + + virtual void FileTimeToString(char* pStrip, int maxCharsIncludingTerminator, long fileTime) = 0; + + virtual void SetBufferSize(FileHandle_t file, unsigned nBytes) = 0; + + virtual bool IsOk(FileHandle_t file) = 0; + + virtual bool EndOfFile(FileHandle_t file) = 0; + + virtual char* ReadLine(char* pOutput, int maxChars, FileHandle_t file) = 0; +#if ! defined(SWIG) + virtual int FPrintf(FileHandle_t file, PRINTF_FORMAT_STRING const char* pFormat, ...) FMTFUNCTION(3, 4) = 0; +#else + virtual int FPrintf(FileHandle_t file, const char* pFormat, ...) FMTFUNCTION(3, 4) = 0; +#endif + + virtual CSysModule* LoadModule(const char* pFileName, const char* pPathID = 0, bool bValidatedDllOnly = true) = 0; + virtual void UnloadModule(CSysModule* pModule) = 0; + + virtual const char* FindFirst(const char* pWildCard, FileFindHandle_t* pHandle) = 0; + virtual const char* FindNext(FileFindHandle_t handle) = 0; + virtual bool FindIsDirectory(FileFindHandle_t handle) = 0; + virtual void FindClose(FileFindHandle_t handle) = 0; + + virtual const char* FindFirstEx( + const char* pWildCard, + const char* pPathID, + FileFindHandle_t* pHandle + ) = 0; + + virtual void FindFileAbsoluteList(CUtlVector< CUtlString >& outAbsolutePathNames, const char* pWildCard, const char* pPathID) = 0; + + virtual const char* GetLocalPath(const char* pFileName, char* pLocalPath, int localPathBufferSize) = 0; + + virtual bool FullPathToRelativePath(const char* pFullpath, char* pRelative, int maxlen) = 0; + + virtual bool GetCurrentDirectory(char* pDirectory, int maxlen) = 0; + + virtual FileNameHandle_t FindOrAddFileName(char const* pFileName) = 0; + virtual bool String(const FileNameHandle_t& handle, char* buf, int buflen) = 0; + + FSAsyncStatus_t AsyncRead(const FileAsyncRequest_t& request, FSAsyncControl_t* phControl = NULL) { return AsyncReadMultiple(&request, 1, phControl); } + virtual FSAsyncStatus_t AsyncReadMultiple(const FileAsyncRequest_t* pRequests, int nRequests, FSAsyncControl_t* phControls = NULL) = 0; + virtual FSAsyncStatus_t AsyncAppend(const char* pFileName, const void* pSrc, int nSrcBytes, bool bFreeMemory, FSAsyncControl_t* pControl = NULL) = 0; + virtual FSAsyncStatus_t AsyncAppendFile(const char* pAppendToFileName, const char* pAppendFromFileName, FSAsyncControl_t* pControl = NULL) = 0; + virtual void AsyncFinishAll(int iToPriority = 0) = 0; + virtual void AsyncFinishAllWrites() = 0; + virtual FSAsyncStatus_t AsyncFlush() = 0; + virtual bool AsyncSuspend() = 0; + virtual bool AsyncResume() = 0; + + virtual FSAsyncStatus_t AsyncBeginRead(const char* pszFile, FSAsyncFile_t* phFile) = 0; + virtual FSAsyncStatus_t AsyncEndRead(FSAsyncFile_t hFile) = 0; + + virtual FSAsyncStatus_t AsyncFinish(FSAsyncControl_t hControl, bool wait = true) = 0; + virtual FSAsyncStatus_t AsyncGetResult(FSAsyncControl_t hControl, void** ppData, int* pSize) = 0; + virtual FSAsyncStatus_t AsyncAbort(FSAsyncControl_t hControl) = 0; + virtual FSAsyncStatus_t AsyncStatus(FSAsyncControl_t hControl) = 0; + virtual FSAsyncStatus_t AsyncSetPriority(FSAsyncControl_t hControl, int newPriority) = 0; + virtual void AsyncAddRef(FSAsyncControl_t hControl) = 0; + virtual void AsyncRelease(FSAsyncControl_t hControl) = 0; + + virtual WaitForResourcesHandle_t WaitForResources(const char* resourcelist) = 0; + virtual bool GetWaitForResourcesProgress(WaitForResourcesHandle_t handle, float* progress , bool* complete ) = 0; + virtual void CancelWaitForResources(WaitForResourcesHandle_t handle) = 0; + + virtual int HintResourceNeed(const char* hintlist, int forgetEverything) = 0; + virtual bool IsFileImmediatelyAvailable(const char* pFileName) = 0; + + virtual void GetLocalCopy(const char* pFileName) = 0; + + virtual void PrintOpenedFiles(void) = 0; + virtual void PrintSearchPaths(void) = 0; + + virtual void SetWarningFunc(void (*pfnWarning)(const char* fmt, ...)) = 0; + virtual void SetWarningLevel(FileWarningLevel_t level) = 0; + virtual void AddLoggingFunc(void (*pfnLogFunc)(const char* fileName, const char* accessType)) = 0; + virtual void RemoveLoggingFunc(FileSystemLoggingFunc_t logFunc) = 0; + + virtual const FileSystemStatistics* GetFilesystemStatistics() = 0; + +#if defined( _PS3 ) + virtual void LogFileAccess(const char* pFullFileName) = 0; + + virtual bool PrefetchFile(const char* pFileName, int nPriority, bool bPersist) = 0; + virtual bool PrefetchFile(const char* pFileName, int nPriority, bool bPersist, int64 nOffset, int64 nSize) = 0; + virtual void FlushCache() = 0; + virtual void SuspendPrefetches(const char* pWhy) = 0; + virtual void ResumePrefetches(const char* pWhy) = 0; + + virtual void OnSaveStateChanged(bool bSaving) = 0; + + virtual bool IsPrefetchingDone() = 0; + +#endif + virtual FileHandle_t OpenEx(const char* pFileName, const char* pOptions, unsigned flags = 0, const char* pathID = 0, char** ppszResolvedFilename = NULL) = 0; + + virtual int ReadEx(void* pOutput, int sizeDest, int size, FileHandle_t file) = 0; + virtual int ReadFileEx(const char* pFileName, const char* pPath, void** ppBuf, bool bNullTerminate = false, bool bOptimalAlloc = false, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL) = 0; + + virtual FileNameHandle_t FindFileName(char const* pFileName) = 0; + +#if defined( TRACK_BLOCKING_IO ) + virtual void EnableBlockingFileAccessTracking(bool state) = 0; + virtual bool IsBlockingFileAccessEnabled() const = 0; + + virtual IBlockingFileItemList* RetrieveBlockingFileAccessInfo() = 0; +#endif + + virtual void SetupPreloadData() = 0; + virtual void DiscardPreloadData() = 0; + + enum KeyValuesPreloadType_t + { + TYPE_VMT, + TYPE_SOUNDEMITTER, + TYPE_SOUNDSCAPE, + TYPE_SOUNDOPERATORS, + NUM_PRELOAD_TYPES + }; + + virtual KeyValues* LoadKeyValues(KeyValuesPreloadType_t type, char const* filename, char const* pPathID = 0) = 0; + virtual bool LoadKeyValues(KeyValues& head, KeyValuesPreloadType_t type, char const* filename, char const* pPathID = 0) = 0; + + virtual FSAsyncStatus_t AsyncWrite(const char* pFileName, const void* pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend = false, FSAsyncControl_t* pControl = NULL) = 0; + virtual FSAsyncStatus_t AsyncWriteFile(const char* pFileName, const CUtlBuffer* pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend = false, FSAsyncControl_t* pControl = NULL) = 0; + FSAsyncStatus_t AsyncReadCreditAlloc(const FileAsyncRequest_t& request, const char* pszFile, int line, FSAsyncControl_t* phControl = NULL) { return AsyncReadMultipleCreditAlloc(&request, 1, pszFile, line, phControl); } + virtual FSAsyncStatus_t AsyncReadMultipleCreditAlloc(const FileAsyncRequest_t* pRequests, int nRequests, const char* pszFile, int line, FSAsyncControl_t* phControls = NULL) = 0; + + virtual FSAsyncStatus_t AsyncDirectoryScan(const char* pSearchSpec, bool recurseFolders, void* pContext, FSAsyncScanAddFunc_t pfnAdd, FSAsyncScanCompleteFunc_t pfnDone, FSAsyncControl_t* pControl = NULL) = 0; + + virtual bool GetFileTypeForFullPath(char const* pFullPath, wchar_t* buf, size_t bufSizeInBytes) = 0; + + virtual bool ReadToBuffer(FileHandle_t hFile, CUtlBuffer& buf, int nMaxBytes = 0, FSAllocFunc_t pfnAlloc = NULL) = 0; + + virtual bool GetOptimalIOConstraints(FileHandle_t hFile, unsigned* pOffsetAlign, unsigned* pSizeAlign, unsigned* pBufferAlign) = 0; + inline unsigned GetOptimalReadSize(FileHandle_t hFile, unsigned nLogicalSize); + virtual void* AllocOptimalReadBuffer(FileHandle_t hFile, unsigned nSize = 0, unsigned nOffset = 0) = 0; + virtual void FreeOptimalReadBuffer(void*) = 0; + + virtual void BeginMapAccess() = 0; + virtual void EndMapAccess() = 0; + + virtual bool FullPathToRelativePathEx(const char* pFullpath, const char* pPathId, char* pRelative, int maxlen) = 0; + + virtual int GetPathIndex(const FileNameHandle_t& handle) = 0; + virtual long GetPathTime(const char* pPath, const char* pPathID) = 0; + + virtual DVDMode_t GetDVDMode() = 0; + + virtual void EnableWhitelistFileTracking(bool bEnable, bool bCacheAllVPKHashes, bool bRecalculateAndCheckHashes) = 0; + + virtual void RegisterFileWhitelist(IFileList* pWantCRCList, IFileList* pAllowFromDiskList, IFileList** pFilesToReload) = 0; + + virtual void MarkAllCRCsUnverified() = 0; + + virtual void CacheFileCRCs(const char* pPathname, ECacheCRCType eType, IFileList* pFilter) = 0; + virtual EFileCRCStatus CheckCachedFileHash(const char* pPathID, const char* pRelativeFilename, int nFileFraction, FileHash_t* pFileHash) = 0; + + virtual int GetUnverifiedFileHashes(CUnverifiedFileHash* pFiles, int nMaxFiles) = 0; + + virtual int GetWhitelistSpewFlags() = 0; + virtual void SetWhitelistSpewFlags(int flags) = 0; + + virtual void InstallDirtyDiskReportFunc(FSDirtyDiskReportFunc_t func) = 0; + + virtual bool IsLaunchedFromXboxHDD() = 0; + virtual bool IsInstalledToXboxHDDCache() = 0; + virtual bool IsDVDHosted() = 0; + virtual bool IsInstallAllowed() = 0; + + virtual int GetSearchPathID(char* pPath, int nMaxLen) = 0; + virtual bool FixupSearchPathsAfterInstall() = 0; + + virtual FSDirtyDiskReportFunc_t GetDirtyDiskReportFunc() = 0; + + virtual void AddVPKFile(char const* pszName, SearchPathAdd_t addType = PATH_ADD_TO_TAIL) = 0; + virtual void RemoveVPKFile(char const* pszName) = 0; + virtual void GetVPKFileNames(CUtlVector& destVector) = 0; + virtual void RemoveAllMapSearchPaths() = 0; + virtual void SyncDvdDevCache() = 0; + + virtual bool GetStringFromKVPool(CRC32_t poolKey, unsigned int key, char* pOutBuff, int buflen) = 0; + + virtual bool DiscoverDLC(int iController) = 0; + virtual int IsAnyDLCPresent(bool* pbDLCSearchPathMounted = NULL) = 0; + virtual bool GetAnyDLCInfo(int iDLC, unsigned int* pLicenseMask, wchar_t* pTitleBuff, int nOutTitleSize) = 0; + virtual int IsAnyCorruptDLC() = 0; + virtual bool GetAnyCorruptDLCInfo(int iCorruptDLC, wchar_t* pTitleBuff, int nOutTitleSize) = 0; + virtual bool AddDLCSearchPaths() = 0; + virtual bool IsSpecificDLCPresent(unsigned int nDLCPackage) = 0; + + virtual void SetIODelayAlarm(float flThreshhold) = 0; + + virtual bool AddXLSPUpdateSearchPath(const void* pData, int nSize) = 0; + + virtual IIoStats* GetIoStats() = 0; + + virtual void CacheAllVPKFileHashes(bool bCacheAllVPKHashes, bool bRecalculateAndCheckHashes) = 0; + virtual bool CheckVPKFileHash(int PackFileID, int nPackFileNumber, int nFileFraction, MD5Value_t& md5Value) = 0; + + virtual void GetVPKFileStatisticsKV(KeyValues* pKV) = 0; + +}; + +#if defined( _X360 ) && !defined( _CERT ) +extern char g_szXboxProfileLastFileOpened[MAX_PATH]; +#define SetLastProfileFileRead( s ) Q_strncpy( g_szXboxProfileLastFileOpened, sizeof( g_szXboxProfileLastFileOpened), pFileName ) +#define GetLastProfileFileRead() (&g_szXboxProfileLastFileOpened[0]) +#else +#define SetLastProfileFileRead( s ) ((void)0) +#define GetLastProfileFileRead() NULL +#endif + +#if defined( _X360 ) && defined( _BASETSD_H_ ) +class CXboxDiskCacheSetter +{ +public: + CXboxDiskCacheSetter(SIZE_T newSize) + { + m_oldSize = XGetFileCacheSize(); + XSetFileCacheSize(newSize); + } + + ~CXboxDiskCacheSetter() + { + XSetFileCacheSize(m_oldSize); + } +private: + SIZE_T m_oldSize; +}; +#define DISK_INTENSIVE() CXboxDiskCacheSetter cacheSetter( 1024*1024 ) +#else +#define DISK_INTENSIVE() ((void)0) +#endif + +inline unsigned IFileSystem::GetOptimalReadSize(FileHandle_t hFile, unsigned nLogicalSize) +{ + unsigned align; + if (GetOptimalIOConstraints(hFile, &align, NULL, NULL)) + return AlignValue(nLogicalSize, align); + else + return nLogicalSize; +} + +#include "filesystem_passthru.h" + +#if (defined(_DEBUG) || defined(USE_MEM_DEBUG)) +#define AsyncRead( a, b ) AsyncReadCreditAlloc( a, __FILE__, __LINE__, b ) +#define AsyncReadMutiple( a, b, c ) AsyncReadMultipleCreditAlloc( a, b, __FILE__, __LINE__, c ) +#endif + + + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/filesystem_passthru.h b/SpyCustom/sdk/filesystem_passthru.h new file mode 100644 index 0000000..feed51a --- /dev/null +++ b/SpyCustom/sdk/filesystem_passthru.h @@ -0,0 +1,305 @@ +#ifndef FILESYSTEM_PASSTHRU_H +#define FILESYSTEM_PASSTHRU_H +#ifdef _WIN32 +#pragma once +#endif + + +#include "filesystem.h" +#include +#include + +#ifdef AsyncRead +#undef AsyncRead +#undef AsyncReadMutiple +#endif + +template +class CInternalFileSystemPassThru : public Base +{ +public: + CInternalFileSystemPassThru() + { + m_pBaseFileSystemPassThru = NULL; + } + virtual void InitPassThru(IBaseFileSystem* pBaseFileSystemPassThru) + { + m_pBaseFileSystemPassThru = pBaseFileSystemPassThru; + } + virtual int Read(void* pOutput, int size, FileHandle_t file) { return m_pBaseFileSystemPassThru->Read(pOutput, size, file); } + virtual int Write(void const* pInput, int size, FileHandle_t file) { return m_pBaseFileSystemPassThru->Write(pInput, size, file); } + virtual FileHandle_t Open(const char* pFileName, const char* pOptions, const char* pathID) { return m_pBaseFileSystemPassThru->Open(pFileName, pOptions, pathID); } + virtual void Close(FileHandle_t file) { m_pBaseFileSystemPassThru->Close(file); } + virtual void Seek(FileHandle_t file, int pos, FileSystemSeek_t seekType) { m_pBaseFileSystemPassThru->Seek(file, pos, seekType); } + virtual unsigned int Tell(FileHandle_t file) { return m_pBaseFileSystemPassThru->Tell(file); } + virtual unsigned int Size(FileHandle_t file) { return m_pBaseFileSystemPassThru->Size(file); } + virtual unsigned int Size(const char* pFileName, const char* pPathID) { return m_pBaseFileSystemPassThru->Size(pFileName, pPathID); } + virtual void Flush(FileHandle_t file) { m_pBaseFileSystemPassThru->Flush(file); } + virtual bool Precache(const char* pFileName, const char* pPathID) { return m_pBaseFileSystemPassThru->Precache(pFileName, pPathID); } + virtual bool FileExists(const char* pFileName, const char* pPathID) { return m_pBaseFileSystemPassThru->FileExists(pFileName, pPathID); } + virtual bool IsFileWritable(char const* pFileName, const char* pPathID) { return m_pBaseFileSystemPassThru->IsFileWritable(pFileName, pPathID); } + virtual bool SetFileWritable(char const* pFileName, bool writable, const char* pPathID) { return m_pBaseFileSystemPassThru->SetFileWritable(pFileName, writable, pPathID); } + virtual long GetFileTime(const char* pFileName, const char* pPathID) { return m_pBaseFileSystemPassThru->GetFileTime(pFileName, pPathID); } + virtual bool ReadFile(const char* pFileName, const char* pPath, CUtlBuffer& buf, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL) { return m_pBaseFileSystemPassThru->ReadFile(pFileName, pPath, buf, nMaxBytes, nStartingByte, pfnAlloc); } + virtual bool WriteFile(const char* pFileName, const char* pPath, CUtlBuffer& buf) { return m_pBaseFileSystemPassThru->WriteFile(pFileName, pPath, buf); } + virtual bool UnzipFile(const char* pFileName, const char* pPath, const char* pDestination) { return m_pBaseFileSystemPassThru->UnzipFile(pFileName, pPath, pDestination); } + +protected: + IBaseFileSystem* m_pBaseFileSystemPassThru; +}; + + +class CBaseFileSystemPassThru : public CInternalFileSystemPassThru +{ +public: +}; + + +class CFileSystemPassThru : public CInternalFileSystemPassThru +{ +public: + typedef CInternalFileSystemPassThru BaseClass; + + CFileSystemPassThru() + { + m_pFileSystemPassThru = NULL; + } + virtual void InitPassThru(IFileSystem* pFileSystemPassThru, bool bBaseOnly) + { + if (!bBaseOnly) + m_pFileSystemPassThru = pFileSystemPassThru; + + BaseClass::InitPassThru(pFileSystemPassThru); + } + + virtual bool Connect(CreateInterfaceFn factory) { return m_pFileSystemPassThru->Connect(factory); } + virtual void Disconnect() { m_pFileSystemPassThru->Disconnect(); } + virtual void* QueryInterface(const char* pInterfaceName) { return m_pFileSystemPassThru->QueryInterface(pInterfaceName); } + virtual InitReturnVal_t Init() { return m_pFileSystemPassThru->Init(); } + virtual void Shutdown() { m_pFileSystemPassThru->Shutdown(); } + virtual const AppSystemInfo_t* GetDependencies() { return m_pFileSystemPassThru->GetDependencies(); } + virtual AppSystemTier_t GetTier() { return m_pFileSystemPassThru->GetTier(); } + virtual void Reconnect(CreateInterfaceFn factory, const char* pInterfaceName) { m_pFileSystemPassThru->Reconnect(factory, pInterfaceName); } + + virtual void RemoveAllSearchPaths(void) { m_pFileSystemPassThru->RemoveAllSearchPaths(); } + virtual void AddSearchPath(const char* pPath, const char* pathID, SearchPathAdd_t addType) { m_pFileSystemPassThru->AddSearchPath(pPath, pathID, addType); } + virtual bool RemoveSearchPath(const char* pPath, const char* pathID) { return m_pFileSystemPassThru->RemoveSearchPath(pPath, pathID); } + virtual void RemoveFile(char const* pRelativePath, const char* pathID) { m_pFileSystemPassThru->RemoveFile(pRelativePath, pathID); } + virtual bool RenameFile(char const* pOldPath, char const* pNewPath, const char* pathID) { return m_pFileSystemPassThru->RenameFile(pOldPath, pNewPath, pathID); } + virtual void CreateDirHierarchy(const char* path, const char* pathID) { m_pFileSystemPassThru->CreateDirHierarchy(path, pathID); } + virtual bool IsDirectory(const char* pFileName, const char* pathID) { return m_pFileSystemPassThru->IsDirectory(pFileName, pathID); } + virtual void FileTimeToString(char* pStrip, int maxCharsIncludingTerminator, long fileTime) { m_pFileSystemPassThru->FileTimeToString(pStrip, maxCharsIncludingTerminator, fileTime); } + virtual void SetBufferSize(FileHandle_t file, unsigned nBytes) { m_pFileSystemPassThru->SetBufferSize(file, nBytes); } + virtual bool IsOk(FileHandle_t file) { return m_pFileSystemPassThru->IsOk(file); } + virtual bool EndOfFile(FileHandle_t file) { return m_pFileSystemPassThru->EndOfFile(file); } + virtual char* ReadLine(char* pOutput, int maxChars, FileHandle_t file) { return m_pFileSystemPassThru->ReadLine(pOutput, maxChars, file); } + virtual int FPrintf(FileHandle_t file, const char* pFormat, ...) + { + char str[8192]; + va_list marker; + va_start(marker, pFormat); + _vsnprintf(str, sizeof(str), pFormat, marker); + va_end(marker); + return m_pFileSystemPassThru->FPrintf(file, "%s", str); + } + virtual CSysModule* LoadModule(const char* pFileName, const char* pPathID, bool bValidatedDllOnly) { return m_pFileSystemPassThru->LoadModule(pFileName, pPathID, bValidatedDllOnly); } + virtual void UnloadModule(CSysModule* pModule) { m_pFileSystemPassThru->UnloadModule(pModule); } + virtual const char* FindFirst(const char* pWildCard, FileFindHandle_t* pHandle) { return m_pFileSystemPassThru->FindFirst(pWildCard, pHandle); } + virtual const char* FindNext(FileFindHandle_t handle) { return m_pFileSystemPassThru->FindNext(handle); } + virtual bool FindIsDirectory(FileFindHandle_t handle) { return m_pFileSystemPassThru->FindIsDirectory(handle); } + virtual void FindClose(FileFindHandle_t handle) { m_pFileSystemPassThru->FindClose(handle); } + virtual void FindFileAbsoluteList(CUtlVector< CUtlString >& outAbsolutePathNames, const char* pWildCard, const char* pPathID) { m_pFileSystemPassThru->FindFileAbsoluteList(outAbsolutePathNames, pWildCard, pPathID); } + virtual const char* GetLocalPath(const char* pFileName, char* pLocalPath, int localPathBufferSize) { return m_pFileSystemPassThru->GetLocalPath(pFileName, pLocalPath, localPathBufferSize); } + virtual bool FullPathToRelativePath(const char* pFullpath, char* pRelative, int maxlen) { return m_pFileSystemPassThru->FullPathToRelativePath(pFullpath, pRelative, maxlen); } + virtual bool GetCurrentDirectory(char* pDirectory, int maxlen) { return m_pFileSystemPassThru->GetCurrentDirectory(pDirectory, maxlen); } + virtual void PrintOpenedFiles(void) { m_pFileSystemPassThru->PrintOpenedFiles(); } + virtual void PrintSearchPaths(void) { m_pFileSystemPassThru->PrintSearchPaths(); } + virtual void SetWarningFunc(void (*pfnWarning)(const char* fmt, ...)) { m_pFileSystemPassThru->SetWarningFunc(pfnWarning); } + virtual void SetWarningLevel(FileWarningLevel_t level) { m_pFileSystemPassThru->SetWarningLevel(level); } + virtual void AddLoggingFunc(void (*pfnLogFunc)(const char* fileName, const char* accessType)) { m_pFileSystemPassThru->AddLoggingFunc(pfnLogFunc); } + virtual void RemoveLoggingFunc(FileSystemLoggingFunc_t logFunc) { m_pFileSystemPassThru->RemoveLoggingFunc(logFunc); } + virtual FSAsyncStatus_t AsyncReadMultiple(const FileAsyncRequest_t* pRequests, int nRequests, FSAsyncControl_t* pControls) { return m_pFileSystemPassThru->AsyncReadMultiple(pRequests, nRequests, pControls); } + virtual FSAsyncStatus_t AsyncReadMultipleCreditAlloc(const FileAsyncRequest_t* pRequests, int nRequests, const char* pszFile, int line, FSAsyncControl_t* pControls) { return m_pFileSystemPassThru->AsyncReadMultipleCreditAlloc(pRequests, nRequests, pszFile, line, pControls); } + virtual FSAsyncStatus_t AsyncDirectoryScan(const char* pSearchSpec, bool recurseFolders, void* pContext, FSAsyncScanAddFunc_t pfnAdd, FSAsyncScanCompleteFunc_t pfnDone, FSAsyncControl_t* pControl = NULL) { return m_pFileSystemPassThru->AsyncDirectoryScan(pSearchSpec, recurseFolders, pContext, pfnAdd, pfnDone, pControl); } + virtual FSAsyncStatus_t AsyncFinish(FSAsyncControl_t hControl, bool wait) { return m_pFileSystemPassThru->AsyncFinish(hControl, wait); } + virtual FSAsyncStatus_t AsyncGetResult(FSAsyncControl_t hControl, void** ppData, int* pSize) { return m_pFileSystemPassThru->AsyncGetResult(hControl, ppData, pSize); } + virtual FSAsyncStatus_t AsyncAbort(FSAsyncControl_t hControl) { return m_pFileSystemPassThru->AsyncAbort(hControl); } + virtual FSAsyncStatus_t AsyncStatus(FSAsyncControl_t hControl) { return m_pFileSystemPassThru->AsyncStatus(hControl); } + virtual FSAsyncStatus_t AsyncFlush() { return m_pFileSystemPassThru->AsyncFlush(); } + virtual void AsyncAddRef(FSAsyncControl_t hControl) { m_pFileSystemPassThru->AsyncAddRef(hControl); } + virtual void AsyncRelease(FSAsyncControl_t hControl) { m_pFileSystemPassThru->AsyncRelease(hControl); } + virtual FSAsyncStatus_t AsyncBeginRead(const char* pszFile, FSAsyncFile_t* phFile) { return m_pFileSystemPassThru->AsyncBeginRead(pszFile, phFile); } + virtual FSAsyncStatus_t AsyncEndRead(FSAsyncFile_t hFile) { return m_pFileSystemPassThru->AsyncEndRead(hFile); } + virtual const FileSystemStatistics* GetFilesystemStatistics() { return m_pFileSystemPassThru->GetFilesystemStatistics(); } + + +#if defined( _PS3 ) + virtual Ps3FileType_t GetPs3FileType(const char* path) { return PS3_FILETYPE_UNKNOWN; } + virtual void LogFileAccess(const char* pFullFileName) { } + + virtual bool PrefetchFile(const char* pFileName, int nPriority, bool bPersist) { return m_pFileSystemPassThru->PrefetchFile(pFileName, nPriority, bPersist); } + virtual bool PrefetchFile(const char* pFileName, int nPriority, bool bPersist, int64 nOffset, int64 nSize) { return m_pFileSystemPassThru->PrefetchFile(pFileName, nPriority, bPersist, nOffset, nSize); } + virtual void FlushCache() { m_pFileSystemPassThru->FlushCache(); } + virtual void SuspendPrefetches(const char* pWhy) { m_pFileSystemPassThru->SuspendPrefetches(pWhy); } + virtual void ResumePrefetches(const char* pWhy) { m_pFileSystemPassThru->ResumePrefetches(pWhy); } + virtual void OnSaveStateChanged(bool bSaving) { m_pFileSystemPassThru->OnSaveStateChanged(bSaving); } + virtual bool IsPrefetchingDone() { return m_pFileSystemPassThru->IsPrefetchingDone(); } +#endif + + virtual WaitForResourcesHandle_t WaitForResources(const char* resourcelist) { return m_pFileSystemPassThru->WaitForResources(resourcelist); } + virtual bool GetWaitForResourcesProgress(WaitForResourcesHandle_t handle, + float* progress, bool* complete) { + return m_pFileSystemPassThru->GetWaitForResourcesProgress(handle, progress, complete); + } + virtual void CancelWaitForResources(WaitForResourcesHandle_t handle) { m_pFileSystemPassThru->CancelWaitForResources(handle); } + virtual int HintResourceNeed(const char* hintlist, int forgetEverything) { return m_pFileSystemPassThru->HintResourceNeed(hintlist, forgetEverything); } + virtual bool IsFileImmediatelyAvailable(const char* pFileName) { return m_pFileSystemPassThru->IsFileImmediatelyAvailable(pFileName); } + virtual void GetLocalCopy(const char* pFileName) { m_pFileSystemPassThru->GetLocalCopy(pFileName); } + virtual FileNameHandle_t FindOrAddFileName(char const* pFileName) { return m_pFileSystemPassThru->FindOrAddFileName(pFileName); } + virtual FileNameHandle_t FindFileName(char const* pFileName) { return m_pFileSystemPassThru->FindFileName(pFileName); } + virtual bool String(const FileNameHandle_t& handle, char* buf, int buflen) { return m_pFileSystemPassThru->String(handle, buf, buflen); } + virtual bool IsOk2(FileHandle_t file) { return IsOk(file); } + virtual void RemoveSearchPaths(const char* szPathID) { m_pFileSystemPassThru->RemoveSearchPaths(szPathID); } + virtual bool IsSteam() const { return m_pFileSystemPassThru->IsSteam(); } + virtual FilesystemMountRetval_t MountSteamContent(int nExtraAppId = -1) { return m_pFileSystemPassThru->MountSteamContent(nExtraAppId); } + + virtual const char* FindFirstEx( + const char* pWildCard, + const char* pPathID, + FileFindHandle_t* pHandle + ) { + return m_pFileSystemPassThru->FindFirstEx(pWildCard, pPathID, pHandle); + } + virtual void MarkPathIDByRequestOnly(const char* pPathID, bool bRequestOnly) { m_pFileSystemPassThru->MarkPathIDByRequestOnly(pPathID, bRequestOnly); } + virtual bool IsFileInReadOnlySearchPath(const char* pPath, const char* pathID) { return m_pFileSystemPassThru->IsFileInReadOnlySearchPath(pPath, pathID); } + + virtual bool AddPackFile(const char* fullpath, const char* pathID) { return m_pFileSystemPassThru->AddPackFile(fullpath, pathID); } + virtual FSAsyncStatus_t AsyncAppend(const char* pFileName, const void* pSrc, int nSrcBytes, bool bFreeMemory, FSAsyncControl_t* pControl) { return m_pFileSystemPassThru->AsyncAppend(pFileName, pSrc, nSrcBytes, bFreeMemory, pControl); } + virtual FSAsyncStatus_t AsyncWrite(const char* pFileName, const void* pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend, FSAsyncControl_t* pControl) { return m_pFileSystemPassThru->AsyncWrite(pFileName, pSrc, nSrcBytes, bFreeMemory, bAppend, pControl); } + virtual FSAsyncStatus_t AsyncWriteFile(const char* pFileName, const CUtlBuffer* pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend, FSAsyncControl_t* pControl) { return m_pFileSystemPassThru->AsyncWriteFile(pFileName, pSrc, nSrcBytes, bFreeMemory, bAppend, pControl); } + virtual FSAsyncStatus_t AsyncAppendFile(const char* pDestFileName, const char* pSrcFileName, FSAsyncControl_t* pControl) { return m_pFileSystemPassThru->AsyncAppendFile(pDestFileName, pSrcFileName, pControl); } + virtual void AsyncFinishAll(int iToPriority) { m_pFileSystemPassThru->AsyncFinishAll(iToPriority); } + virtual void AsyncFinishAllWrites() { m_pFileSystemPassThru->AsyncFinishAllWrites(); } + virtual FSAsyncStatus_t AsyncSetPriority(FSAsyncControl_t hControl, int newPriority) { return m_pFileSystemPassThru->AsyncSetPriority(hControl, newPriority); } + virtual bool AsyncSuspend() { return m_pFileSystemPassThru->AsyncSuspend(); } + virtual bool AsyncResume() { return m_pFileSystemPassThru->AsyncResume(); } + virtual const char* RelativePathToFullPath(const char* pFileName, const char* pPathID, char* pLocalPath, int localPathBufferSize, PathTypeFilter_t pathFilter = FILTER_NONE, PathTypeQuery_t* pPathType = NULL) { return m_pFileSystemPassThru->RelativePathToFullPath(pFileName, pPathID, pLocalPath, localPathBufferSize, pathFilter, pPathType); } +#if IsGameConsole() + virtual bool GetPackFileInfoFromRelativePath(const char* pFileName, const char* pPathID, char* pPackPath, int nPackPathBufferSize, int64& nPosition, int64& nLength) { return m_pFileSystemPassThru->GetPackFileInfoFromRelativePath(pFileName, pPathID, pPackPath, nPackPathBufferSize, nPosition, nLength); } +#endif + + virtual int GetSearchPath(const char* pathID, bool bGetPackFiles, char* pPath, int nMaxLen) { return m_pFileSystemPassThru->GetSearchPath(pathID, bGetPackFiles, pPath, nMaxLen); } + + virtual FileHandle_t OpenEx(const char* pFileName, const char* pOptions, unsigned flags = 0, const char* pathID = 0, char** ppszResolvedFilename = NULL) { return m_pFileSystemPassThru->OpenEx(pFileName, pOptions, flags, pathID, ppszResolvedFilename); } + virtual int ReadEx(void* pOutput, int destSize, int size, FileHandle_t file) { return m_pFileSystemPassThru->ReadEx(pOutput, destSize, size, file); } + virtual int ReadFileEx(const char* pFileName, const char* pPath, void** ppBuf, bool bNullTerminate, bool bOptimalAlloc, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL) { return m_pFileSystemPassThru->ReadFileEx(pFileName, pPath, ppBuf, bNullTerminate, bOptimalAlloc, nMaxBytes, nStartingByte, pfnAlloc); } + +#if defined( TRACK_BLOCKING_IO ) + virtual void EnableBlockingFileAccessTracking(bool state) { m_pFileSystemPassThru->EnableBlockingFileAccessTracking(state); } + virtual bool IsBlockingFileAccessEnabled() const { return m_pFileSystemPassThru->IsBlockingFileAccessEnabled(); } + + virtual IBlockingFileItemList* RetrieveBlockingFileAccessInfo() { return m_pFileSystemPassThru->RetrieveBlockingFileAccessInfo(); } +#endif + virtual void SetupPreloadData() {} + virtual void DiscardPreloadData() {} + + virtual KeyValues* LoadKeyValues(KeyValuesPreloadType_t type, char const* filename, char const* pPathID = 0) { return m_pFileSystemPassThru->LoadKeyValues(type, filename, pPathID); } + virtual bool LoadKeyValues(KeyValues& head, KeyValuesPreloadType_t type, char const* filename, char const* pPathID = 0) { return m_pFileSystemPassThru->LoadKeyValues(head, type, filename, pPathID); } + + virtual bool GetFileTypeForFullPath(char const* pFullPath, OUT_Z_BYTECAP(bufSizeInBytes) wchar_t* buf, size_t bufSizeInBytes) { return m_pFileSystemPassThru->GetFileTypeForFullPath(pFullPath, buf, bufSizeInBytes); } + + virtual bool GetOptimalIOConstraints(FileHandle_t hFile, unsigned* pOffsetAlign, unsigned* pSizeAlign, unsigned* pBufferAlign) { return m_pFileSystemPassThru->GetOptimalIOConstraints(hFile, pOffsetAlign, pSizeAlign, pBufferAlign); } + virtual void* AllocOptimalReadBuffer(FileHandle_t hFile, unsigned nSize, unsigned nOffset) { return m_pFileSystemPassThru->AllocOptimalReadBuffer(hFile, nOffset, nSize); } + virtual void FreeOptimalReadBuffer(void* p) { m_pFileSystemPassThru->FreeOptimalReadBuffer(p); } + + virtual void BeginMapAccess() { m_pFileSystemPassThru->BeginMapAccess(); } + virtual void EndMapAccess() { m_pFileSystemPassThru->EndMapAccess(); } + + virtual bool ReadToBuffer(FileHandle_t hFile, CUtlBuffer& buf, int nMaxBytes = 0, FSAllocFunc_t pfnAlloc = NULL) { return m_pFileSystemPassThru->ReadToBuffer(hFile, buf, nMaxBytes, pfnAlloc); } + virtual bool FullPathToRelativePathEx(const char* pFullPath, const char* pPathId, char* pRelative, int nMaxLen) { return m_pFileSystemPassThru->FullPathToRelativePathEx(pFullPath, pPathId, pRelative, nMaxLen); } + virtual int GetPathIndex(const FileNameHandle_t& handle) { return m_pFileSystemPassThru->GetPathIndex(handle); } + virtual long GetPathTime(const char* pPath, const char* pPathID) { return m_pFileSystemPassThru->GetPathTime(pPath, pPathID); } + + virtual DVDMode_t GetDVDMode() { return m_pFileSystemPassThru->GetDVDMode(); } + + virtual void EnableWhitelistFileTracking(bool bEnable, bool bCacheAllVPKHashes, bool bRecalculateAndCheckHashes) + { + m_pFileSystemPassThru->EnableWhitelistFileTracking(bEnable, bCacheAllVPKHashes, bRecalculateAndCheckHashes); + } + + virtual void RegisterFileWhitelist(IFileList* pForceMatchList, IFileList* pAllowFromDiskList, IFileList** pFilesToReload) + { + m_pFileSystemPassThru->RegisterFileWhitelist(pForceMatchList, pAllowFromDiskList, pFilesToReload); + } + virtual void MarkAllCRCsUnverified() + { + m_pFileSystemPassThru->MarkAllCRCsUnverified(); + } + virtual void CacheFileCRCs(const char* pPathname, ECacheCRCType eType, IFileList* pFilter) + { + return m_pFileSystemPassThru->CacheFileCRCs(pPathname, eType, pFilter); + } + virtual EFileCRCStatus CheckCachedFileHash(const char* pPathID, const char* pRelativeFilename, int nFileFraction, FileHash_t* pFileHash) + { + return m_pFileSystemPassThru->CheckCachedFileHash(pPathID, pRelativeFilename, nFileFraction, pFileHash); + } + virtual int GetUnverifiedFileHashes(CUnverifiedFileHash* pFiles, int nMaxFiles) + { + return m_pFileSystemPassThru->GetUnverifiedFileHashes(pFiles, nMaxFiles); + } + virtual int GetWhitelistSpewFlags() + { + return m_pFileSystemPassThru->GetWhitelistSpewFlags(); + } + virtual void SetWhitelistSpewFlags(int spewFlags) + { + m_pFileSystemPassThru->SetWhitelistSpewFlags(spewFlags); + } + virtual void InstallDirtyDiskReportFunc(FSDirtyDiskReportFunc_t func) { m_pFileSystemPassThru->InstallDirtyDiskReportFunc(func); } + + virtual bool IsLaunchedFromXboxHDD() { return m_pFileSystemPassThru->IsLaunchedFromXboxHDD(); } + virtual bool IsInstalledToXboxHDDCache() { return m_pFileSystemPassThru->IsInstalledToXboxHDDCache(); } + virtual bool IsDVDHosted() { return m_pFileSystemPassThru->IsDVDHosted(); } + virtual bool IsInstallAllowed() { return m_pFileSystemPassThru->IsInstallAllowed(); } + virtual int GetSearchPathID(char* pPath, int nMaxLen) { return m_pFileSystemPassThru->GetSearchPathID(pPath, nMaxLen); } + virtual bool FixupSearchPathsAfterInstall() { return m_pFileSystemPassThru->FixupSearchPathsAfterInstall(); } + + virtual FSDirtyDiskReportFunc_t GetDirtyDiskReportFunc() { return m_pFileSystemPassThru->GetDirtyDiskReportFunc(); } + + virtual void AddVPKFile(char const* pPkName, SearchPathAdd_t addType = PATH_ADD_TO_TAIL) { m_pFileSystemPassThru->AddVPKFile(pPkName, addType); } + virtual void RemoveVPKFile(char const* pPkName) { m_pFileSystemPassThru->RemoveVPKFile(pPkName); } + virtual void GetVPKFileNames(CUtlVector& destVector) { m_pFileSystemPassThru->GetVPKFileNames(destVector); } + + virtual void RemoveAllMapSearchPaths(void) { m_pFileSystemPassThru->RemoveAllMapSearchPaths(); } + + virtual void SyncDvdDevCache(void) { m_pFileSystemPassThru->SyncDvdDevCache(); } + + virtual bool GetStringFromKVPool(CRC32_t poolKey, unsigned int key, char* pOutBuff, int buflen) { return m_pFileSystemPassThru->GetStringFromKVPool(poolKey, key, pOutBuff, buflen); } + + virtual bool DiscoverDLC(int iController) { return m_pFileSystemPassThru->DiscoverDLC(iController); } + virtual int IsAnyDLCPresent(bool* pbDLCSearchPathMounted = NULL) { return m_pFileSystemPassThru->IsAnyDLCPresent(pbDLCSearchPathMounted); } + virtual bool GetAnyDLCInfo(int iDLC, unsigned int* pLicenseMask, wchar_t* pTitleBuff, int nOutTitleSize) { return m_pFileSystemPassThru->GetAnyDLCInfo(iDLC, pLicenseMask, pTitleBuff, nOutTitleSize); } + virtual int IsAnyCorruptDLC() { return m_pFileSystemPassThru->IsAnyCorruptDLC(); } + virtual bool GetAnyCorruptDLCInfo(int iCorruptDLC, wchar_t* pTitleBuff, int nOutTitleSize) { return m_pFileSystemPassThru->GetAnyCorruptDLCInfo(iCorruptDLC, pTitleBuff, nOutTitleSize); } + virtual bool AddDLCSearchPaths() { return m_pFileSystemPassThru->AddDLCSearchPaths(); } + virtual bool IsSpecificDLCPresent(unsigned int nDLCPackage) { return m_pFileSystemPassThru->IsSpecificDLCPresent(nDLCPackage); } + virtual void SetIODelayAlarm(float flThreshhold) { m_pFileSystemPassThru->SetIODelayAlarm(flThreshhold); } + virtual bool AddXLSPUpdateSearchPath(const void* pData, int nSize) { return m_pFileSystemPassThru->AddXLSPUpdateSearchPath(pData, nSize); } + virtual IIoStats* GetIoStats() { return m_pFileSystemPassThru->GetIoStats(); } + + virtual void CacheAllVPKFileHashes(bool bCacheAllVPKHashes, bool bRecalculateAndCheckHashes) + { + return m_pFileSystemPassThru->CacheAllVPKFileHashes(bCacheAllVPKHashes, bRecalculateAndCheckHashes); + } + virtual bool CheckVPKFileHash(int PackFileID, int nPackFileNumber, int nFileFraction, MD5Value_t& md5Value) + { + return m_pFileSystemPassThru->CheckVPKFileHash(PackFileID, nPackFileNumber, nFileFraction, md5Value); + } + virtual void GetVPKFileStatisticsKV(KeyValues* pKV) { m_pFileSystemPassThru->GetVPKFileStatisticsKV(pKV); } + +protected: + IFileSystem* m_pFileSystemPassThru; +}; + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/flashlighteffect.h b/SpyCustom/sdk/flashlighteffect.h new file mode 100644 index 0000000..895f552 --- /dev/null +++ b/SpyCustom/sdk/flashlighteffect.h @@ -0,0 +1,319 @@ +#ifndef FLASHLIGHTEFFECT_H +#define FLASHLIGHTEFFECT_H +#ifdef _WIN32 +#pragma once +#endif + +#include "MaterialSystemUtil.h" + + +class CountdownTimer +{ +public: +#ifdef CLIENT_DLL + DECLARE_PREDICTABLE(); +#endif + DECLARE_CLASS_NOBASE(CountdownTimer); + DECLARE_EMBEDDED_NETWORKVAR(); + + CountdownTimer(void); + + void Reset(void) + { + m_timestamp = Now() + m_duration; + } + + void Start(float duration) + { + m_timestamp = Now() + duration; + m_duration = duration; + } + + void StartFromTime(float startTime, float duration) + { + m_timestamp = startTime + duration; + m_duration = duration; + } + + void Invalidate(void) + { + m_timestamp = -1.0f; + } + + bool HasStarted(void) const + { + return (m_timestamp > 0.0f); + } + + bool IsElapsed(void) const + { + return (Now() > m_timestamp); + } + + float GetElapsedTime(void) const + { + return Now() - m_timestamp + m_duration; + } + + float GetRemainingTime(void) const + { + return (m_timestamp - Now()); + } + + float GetCountdownDuration(void) const + { + return (m_timestamp > 0.0f) ? m_duration : 0.0f; + } + + float GetRemainingRatio(void) const + { + if (HasStarted()) + { + float left = GetRemainingTime() / m_duration; + if (left < 0.0f) + return 0.0f; + if (left > 1.0f) + return 1.0f; + return left; + } + + return 0.0f; + } + +private: + CNetworkVar(float, m_duration); + CNetworkVar(float, m_timestamp); + float Now(void) const; +}; + +struct dlight_t; + + + + +class CFlashlightEffect +{ +public: + + CFlashlightEffect(int nEntIndex = 0, const char* pszTextureName = NULL, float flFov = 0.0f, float flFarZ = 0.0f, float flLinearAtten = 0.0f); + ~CFlashlightEffect(); + + void UpdateLight(int nEntIdx, const Vector& vecPos, const Vector& vecDir, const Vector& vecRight, const Vector& vecUp, float flFov, + float flFarZ, float flLinearAtten, bool castsShadows, const char* pTextureName); + void UpdateLight(int nEntIdx, const Vector& vecPos, const Vector& vecDir, const Vector& vecRight, const Vector& vecUp, float flFov, + bool castsShadows, ITexture* pFlashlightTexture, const Vector& vecBrightness, bool bTracePlayers = true); + + void TurnOn(); + void TurnOff(); + void SetMuzzleFlashEnabled(bool bEnabled, float flBrightness); + bool IsOn(void) { return m_bIsOn; } + + ClientShadowHandle_t GetFlashlightHandle(void) { return m_FlashlightHandle; } + void SetFlashlightHandle(ClientShadowHandle_t Handle) { m_FlashlightHandle = Handle; } + + const char* GetFlashlightTextureName(void) const + { + return m_textureName; + } + + int GetEntIndex(void) const + { + return m_nEntIndex; + } + + bool UpdateDefaultFlashlightState(FlashlightState_t& state, const Vector& vecPos, const Vector& vecDir, const Vector& vecRight, + const Vector& vecUp, bool castsShadows, bool bTracePlayers = true); + bool ComputeLightPosAndOrientation(const Vector& vecPos, const Vector& vecDir, const Vector& vecRight, const Vector& vecUp, + Vector& vecFinalPos, Quaternion& quatOrientation, bool bTracePlayers); + void LightOff(); + + void UpdateFlashlightTexture(const char* pTextureName); + void UpdateLightTopDown(const Vector& vecPos, const Vector& vecDir, const Vector& vecRight, const Vector& vecUp); + + bool m_bIsOn; + int m_nEntIndex; + ClientShadowHandle_t m_FlashlightHandle; + + bool m_bMuzzleFlashEnabled; + float m_flMuzzleFlashBrightness; + + float m_flFov; + float m_flFarZ; + float m_flLinearAtten; + bool m_bCastsShadows; + + float m_flCurrentPullBackDist; + + CTextureReference m_FlashlightTexture; + + CTextureReference m_MuzzleFlashTexture; + + char m_textureName[64]; +}; + +class CHeadlightEffect : public CFlashlightEffect +{ +public: + + CHeadlightEffect(); + ~CHeadlightEffect(); + + virtual void UpdateLight(const Vector& vecPos, const Vector& vecDir, const Vector& vecRight, const Vector& vecUp, int nDistance); +}; + + + +class CFlashlightEffectManager +{ +private: + CFlashlightEffect* m_pFlashlightEffect; + const char* m_pFlashlightTextureName; + int m_nFlashlightEntIndex; + float m_flFov; + float m_flFarZ; + float m_flLinearAtten; + int m_nMuzzleFlashFrameCountdown; + CountdownTimer m_muzzleFlashTimer; + float m_flMuzzleFlashBrightness; + bool m_bFlashlightOn; + int m_nFXComputeFrame; + bool m_bFlashlightOverride; + +public: + CFlashlightEffectManager() : m_pFlashlightEffect(NULL), m_pFlashlightTextureName(NULL), m_nFlashlightEntIndex(-1), m_flFov(0.0f), + m_flFarZ(0.0f), m_flLinearAtten(0.0f), m_nMuzzleFlashFrameCountdown(0), m_flMuzzleFlashBrightness(1.0f), + m_bFlashlightOn(false), m_nFXComputeFrame(-1), m_bFlashlightOverride(false) {} + + void TurnOnFlashlight(int nEntIndex = 0, const char* pszTextureName = NULL, float flFov = 0.0f, float flFarZ = 0.0f, float flLinearAtten = 0.0f) + { + m_pFlashlightTextureName = pszTextureName; + m_nFlashlightEntIndex = nEntIndex; + m_flFov = flFov; + m_flFarZ = flFarZ; + m_flLinearAtten = flLinearAtten; + m_bFlashlightOn = true; + + if (m_bFlashlightOverride) + { + return; + } + + if (!m_pFlashlightEffect) + { + if (pszTextureName) + { + m_pFlashlightEffect = new CFlashlightEffect(m_nFlashlightEntIndex, pszTextureName, flFov, flFarZ, flLinearAtten); + } + else + { + m_pFlashlightEffect = new CFlashlightEffect(m_nFlashlightEntIndex); + } + + if (!m_pFlashlightEffect) + { + return; + } + } + + m_pFlashlightEffect->TurnOn(); + } + + void TurnOffFlashlight(bool bForce = false) + { + m_pFlashlightTextureName = NULL; + m_bFlashlightOn = false; + + if (bForce) + { + m_bFlashlightOverride = false; + m_nMuzzleFlashFrameCountdown = 0; + m_muzzleFlashTimer.Invalidate(); + delete m_pFlashlightEffect; + m_pFlashlightEffect = NULL; + return; + } + + if (m_bFlashlightOverride) + { + return; + } + + if (m_nMuzzleFlashFrameCountdown == 0 && m_muzzleFlashTimer.IsElapsed()) + { + delete m_pFlashlightEffect; + m_pFlashlightEffect = NULL; + } + } + + bool IsFlashlightOn() const { return m_bFlashlightOn; } + + void UpdateFlashlight(const Vector& vecPos, const Vector& vecDir, const Vector& vecRight, const Vector& vecUp, float flFov, bool castsShadows, + float flFarZ, float flLinearAtten, const char* pTextureName = NULL); + void SetEntityIndex(int index) + { + m_nFlashlightEntIndex = index; + } + + void TriggerMuzzleFlash() + { + } + + const char* GetFlashlightTextureName(void) const + { + return m_pFlashlightTextureName; + } + + int GetFlashlightEntIndex(void) const + { + return m_nFlashlightEntIndex; + } + + void EnableFlashlightOverride(bool bEnable) + { + m_bFlashlightOverride = bEnable; + + if (!m_bFlashlightOverride) + { + if (m_bFlashlightOn && m_pFlashlightEffect == NULL) + { + TurnOnFlashlight(m_nFlashlightEntIndex, m_pFlashlightTextureName, m_flFov, m_flFarZ, m_flLinearAtten); + } + else if (!m_bFlashlightOn && m_pFlashlightEffect) + { + delete m_pFlashlightEffect; + m_pFlashlightEffect = NULL; + } + } + } + + void UpdateFlashlightOverride(bool bFlashlightOn, const Vector& vecPos, const Vector& vecDir, const Vector& vecRight, const Vector& vecUp, + float flFov, bool castsShadows, ITexture* pFlashlightTexture, const Vector& vecBrightness) + { + Assert(m_bFlashlightOverride); + if (!m_bFlashlightOverride) + { + return; + } + + if (bFlashlightOn && !m_pFlashlightEffect) + { + m_pFlashlightEffect = new CFlashlightEffect(m_nFlashlightEntIndex); + } + else if (!bFlashlightOn && m_pFlashlightEffect) + { + delete m_pFlashlightEffect; + m_pFlashlightEffect = NULL; + } + + if (m_pFlashlightEffect) + { + m_pFlashlightEffect->UpdateLight(m_nFlashlightEntIndex, vecPos, vecDir, vecRight, vecUp, flFov, castsShadows, pFlashlightTexture, vecBrightness, false); + } + } +}; + + + + + +#endif diff --git a/SpyCustom/sdk/fltx4.h b/SpyCustom/sdk/fltx4.h new file mode 100644 index 0000000..99fd005 --- /dev/null +++ b/SpyCustom/sdk/fltx4.h @@ -0,0 +1,93 @@ +#ifndef FLTX4_H +#define FLTX4_H + +#if defined(GNUC) +#define USE_STDC_FOR_SIMD 0 +#else +#define USE_STDC_FOR_SIMD 0 +#endif + +#if (!defined(PLATFORM_PPC) && (USE_STDC_FOR_SIMD == 0)) +#define _SSE1 1 +#endif + +#if USE_STDC_FOR_SIMD +#error "hello" +typedef union +{ + float m128_f32[4]; + uint32 m128_u32[4]; +} fltx4; + +typedef fltx4 i32x4; +typedef fltx4 u32x4; + +#ifdef _PS3 +typedef fltx4 u32x4; +typedef fltx4 i32x4; +#endif +typedef fltx4 bi32x4; + +#elif ( defined( _PS3 ) ) + +typedef union +{ + vec_float4 vmxf; + vec_int4 vmxi; + vec_uint4 vmxui; +#if defined(__SPU__) + vec_uint4 vmxbi; +#else + __vector bool vmxbi; +#endif + + struct + { + float x; + float y; + float z; + float w; + }; + + float m128_f32[4]; + uint32 m128_u32[4]; + int32 m128_i32[4]; + +} fltx4_union; + +typedef vec_float4 fltx4; +typedef vec_uint4 u32x4; +typedef vec_int4 i32x4; + +#if defined(__SPU__) +typedef vec_uint4 bi32x4; +#else +typedef __vector bool bi32x4; +#endif + +#define DIFFERENT_NATIVE_VECTOR_TYPES + +#elif ( defined( _X360 ) ) + +typedef union +{ + __vector4 vmx; + float m128_f32[4]; + uint32 m128_u32[4]; +} fltx4_union; + +typedef __vector4 fltx4; +typedef __vector4 i32x4; +typedef __vector4 u32x4; +typedef fltx4 bi32x4; +#else + +typedef __m128 fltx4; +typedef __m128 i32x4; +typedef __m128 u32x4; +typedef __m128i shortx8; +typedef fltx4 bi32x4; + +#endif + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/functors.h b/SpyCustom/sdk/functors.h new file mode 100644 index 0000000..fa99d3d --- /dev/null +++ b/SpyCustom/sdk/functors.h @@ -0,0 +1,798 @@ +#ifndef FUNCTORS_H +#define FUNCTORS_H + +#if defined( _WIN32 ) +#pragma once +#endif + +#include "platform.h" +#include "refcount.h" +#include "utlenvelope.h" +#include + + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_0 +#define FUNC_TEMPLATE_ARG_PARAMS_0 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_0 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_0 +#define FUNC_ARG_MEMBERS_0 +#define FUNC_ARG_FORMAL_PARAMS_0 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_0 +#define FUNC_CALL_ARGS_INIT_0 +#define FUNC_SOLO_CALL_ARGS_INIT_0 +#define FUNC_CALL_MEMBER_ARGS_0 +#define FUNC_CALL_ARGS_0 +#define FUNC_CALL_DATA_ARGS_0( _var ) +#define FUNC_FUNCTOR_CALL_ARGS_0 +#define FUNC_TEMPLATE_FUNC_PARAMS_0 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_0 +#define FUNC_VALIDATION_STRING_0 Q_snprintf( pString, nBufLen, "method( void )" ); +#define FUNC_SEPARATOR_0 + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_1 typename ARG_TYPE_1 +#define FUNC_TEMPLATE_ARG_PARAMS_1 , typename ARG_TYPE_1 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_1 , ARG_TYPE_1 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_1 ARG_TYPE_1 +#define FUNC_ARG_MEMBERS_1 ARG_TYPE_1 m_arg1 +#define FUNC_ARG_FORMAL_PARAMS_1 , const ARG_TYPE_1 &arg1 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_1 const ARG_TYPE_1 &arg1 +#define FUNC_CALL_ARGS_INIT_1 , m_arg1( arg1 ) +#define FUNC_SOLO_CALL_ARGS_INIT_1 : m_arg1( arg1 ) +#define FUNC_CALL_MEMBER_ARGS_1 m_arg1 +#define FUNC_CALL_ARGS_1 arg1 +#define FUNC_CALL_DATA_ARGS_1( _var ) _var->m_arg1 +#define FUNC_FUNCTOR_CALL_ARGS_1 , arg1 +#define FUNC_TEMPLATE_FUNC_PARAMS_1 , typename FUNC_ARG_TYPE_1 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_1 FUNC_ARG_TYPE_1 +#define FUNC_VALIDATION_STRING_1 Q_snprintf( pString, nBufLen, "method( %s )", typeid( ARG_TYPE_1 ).name() ); +#define FUNC_SEPARATOR_1 , + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_2 typename ARG_TYPE_1, typename ARG_TYPE_2 +#define FUNC_TEMPLATE_ARG_PARAMS_2 , typename ARG_TYPE_1, typename ARG_TYPE_2 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_2 , ARG_TYPE_1, ARG_TYPE_2 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_2 ARG_TYPE_1, ARG_TYPE_2 +#define FUNC_ARG_MEMBERS_2 ARG_TYPE_1 m_arg1; ARG_TYPE_2 m_arg2 +#define FUNC_ARG_FORMAL_PARAMS_2 , const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_2 const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2 +#define FUNC_CALL_ARGS_INIT_2 , m_arg1( arg1 ), m_arg2( arg2 ) +#define FUNC_SOLO_CALL_ARGS_INIT_2 : m_arg1( arg1 ), m_arg2( arg2 ) +#define FUNC_CALL_MEMBER_ARGS_2 m_arg1, m_arg2 +#define FUNC_CALL_ARGS_2 arg1, arg2 +#define FUNC_CALL_DATA_ARGS_2( _var ) _var->m_arg1, _var->m_arg2 +#define FUNC_FUNCTOR_CALL_ARGS_2 , arg1, arg2 +#define FUNC_TEMPLATE_FUNC_PARAMS_2 , typename FUNC_ARG_TYPE_1, typename FUNC_ARG_TYPE_2 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_2 FUNC_ARG_TYPE_1, FUNC_ARG_TYPE_2 +#define FUNC_VALIDATION_STRING_2 Q_snprintf( pString, nBufLen, "method( %s, %s )", typeid( ARG_TYPE_1 ).name(), typeid( ARG_TYPE_2 ).name() ); +#define FUNC_SEPARATOR_2 , + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_3 typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3 +#define FUNC_TEMPLATE_ARG_PARAMS_3 , typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_3 , ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_3 ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3 +#define FUNC_ARG_MEMBERS_3 ARG_TYPE_1 m_arg1; ARG_TYPE_2 m_arg2; ARG_TYPE_3 m_arg3 +#define FUNC_ARG_FORMAL_PARAMS_3 , const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_3 const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3 +#define FUNC_CALL_ARGS_INIT_3 , m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ) +#define FUNC_SOLO_CALL_ARGS_INIT_3 : m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ) +#define FUNC_CALL_MEMBER_ARGS_3 m_arg1, m_arg2, m_arg3 +#define FUNC_CALL_ARGS_3 arg1, arg2, arg3 +#define FUNC_CALL_DATA_ARGS_3( _var ) _var->m_arg1, _var->m_arg2, _var->m_arg3 +#define FUNC_FUNCTOR_CALL_ARGS_3 , arg1, arg2, arg3 +#define FUNC_TEMPLATE_FUNC_PARAMS_3 , typename FUNC_ARG_TYPE_1, typename FUNC_ARG_TYPE_2, typename FUNC_ARG_TYPE_3 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_3 FUNC_ARG_TYPE_1, FUNC_ARG_TYPE_2, FUNC_ARG_TYPE_3 +#define FUNC_VALIDATION_STRING_3 Q_snprintf( pString, nBufLen, "method( %s, %s, %s )", typeid( ARG_TYPE_1 ).name(), typeid( ARG_TYPE_2 ).name(), typeid( ARG_TYPE_3 ).name() ); +#define FUNC_SEPARATOR_3 , + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_4 typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4 +#define FUNC_TEMPLATE_ARG_PARAMS_4 , typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_4 , ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_4 ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4 +#define FUNC_ARG_MEMBERS_4 ARG_TYPE_1 m_arg1; ARG_TYPE_2 m_arg2; ARG_TYPE_3 m_arg3; ARG_TYPE_4 m_arg4 +#define FUNC_ARG_FORMAL_PARAMS_4 , const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_4 const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4 +#define FUNC_CALL_ARGS_INIT_4 , m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ) +#define FUNC_SOLO_CALL_ARGS_INIT_4 : m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ) +#define FUNC_CALL_MEMBER_ARGS_4 m_arg1, m_arg2, m_arg3, m_arg4 +#define FUNC_CALL_ARGS_4 arg1, arg2, arg3, arg4 +#define FUNC_CALL_DATA_ARGS_4( _var ) _var->m_arg1, _var->m_arg2, _var->m_arg3, _var->m_arg4 +#define FUNC_FUNCTOR_CALL_ARGS_4 , arg1, arg2, arg3, arg4 +#define FUNC_TEMPLATE_FUNC_PARAMS_4 , typename FUNC_ARG_TYPE_1, typename FUNC_ARG_TYPE_2, typename FUNC_ARG_TYPE_3, typename FUNC_ARG_TYPE_4 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_4 FUNC_ARG_TYPE_1, FUNC_ARG_TYPE_2, FUNC_ARG_TYPE_3, FUNC_ARG_TYPE_4 +#define FUNC_VALIDATION_STRING_4 Q_snprintf( pString, nBufLen, "method( %s, %s, %s, %s )", typeid( ARG_TYPE_1 ).name(), typeid( ARG_TYPE_2 ).name(), typeid( ARG_TYPE_3 ).name(), typeid( ARG_TYPE_4 ).name() ); +#define FUNC_SEPARATOR_4 , + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_5 typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5 +#define FUNC_TEMPLATE_ARG_PARAMS_5 , typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_5 , ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_5 ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5 +#define FUNC_ARG_MEMBERS_5 ARG_TYPE_1 m_arg1; ARG_TYPE_2 m_arg2; ARG_TYPE_3 m_arg3; ARG_TYPE_4 m_arg4; ARG_TYPE_5 m_arg5 +#define FUNC_ARG_FORMAL_PARAMS_5 , const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_5 const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5 +#define FUNC_CALL_ARGS_INIT_5 , m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ) +#define FUNC_SOLO_CALL_ARGS_INIT_5 : m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ) +#define FUNC_CALL_MEMBER_ARGS_5 m_arg1, m_arg2, m_arg3, m_arg4, m_arg5 +#define FUNC_CALL_ARGS_5 arg1, arg2, arg3, arg4, arg5 +#define FUNC_CALL_DATA_ARGS_5( _var ) _var->m_arg1, _var->m_arg2, _var->m_arg3, _var->m_arg4, _var->m_arg5 +#define FUNC_FUNCTOR_CALL_ARGS_5 , arg1, arg2, arg3, arg4, arg5 +#define FUNC_TEMPLATE_FUNC_PARAMS_5 , typename FUNC_ARG_TYPE_1, typename FUNC_ARG_TYPE_2, typename FUNC_ARG_TYPE_3, typename FUNC_ARG_TYPE_4, typename FUNC_ARG_TYPE_5 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_5 FUNC_ARG_TYPE_1, FUNC_ARG_TYPE_2, FUNC_ARG_TYPE_3, FUNC_ARG_TYPE_4, FUNC_ARG_TYPE_5 +#define FUNC_VALIDATION_STRING_5 Q_snprintf( pString, nBufLen, "method( %s, %s, %s, %s, %s )", typeid( ARG_TYPE_1 ).name(), typeid( ARG_TYPE_2 ).name(), typeid( ARG_TYPE_3 ).name(), typeid( ARG_TYPE_4 ).name(), typeid( ARG_TYPE_5 ).name() ); +#define FUNC_SEPARATOR_5 , + + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_6 typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6 +#define FUNC_TEMPLATE_ARG_PARAMS_6 , typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_6 , ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_6 ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6 +#define FUNC_ARG_MEMBERS_6 ARG_TYPE_1 m_arg1; ARG_TYPE_2 m_arg2; ARG_TYPE_3 m_arg3; ARG_TYPE_4 m_arg4; ARG_TYPE_5 m_arg5; ARG_TYPE_6 m_arg6 +#define FUNC_ARG_FORMAL_PARAMS_6 , const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_6 const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6 +#define FUNC_CALL_ARGS_INIT_6 , m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ) +#define FUNC_SOLO_CALL_ARGS_INIT_6 : m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ) +#define FUNC_CALL_MEMBER_ARGS_6 m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6 +#define FUNC_CALL_ARGS_6 arg1, arg2, arg3, arg4, arg5, arg6 +#define FUNC_CALL_DATA_ARGS_6( _var ) _var->m_arg1, _var->m_arg2, _var->m_arg3, _var->m_arg4, _var->m_arg5, _var->m_arg6 +#define FUNC_FUNCTOR_CALL_ARGS_6 , arg1, arg2, arg3, arg4, arg5, arg6 +#define FUNC_TEMPLATE_FUNC_PARAMS_6 , typename FUNC_ARG_TYPE_1, typename FUNC_ARG_TYPE_2, typename FUNC_ARG_TYPE_3, typename FUNC_ARG_TYPE_4, typename FUNC_ARG_TYPE_5, typename FUNC_ARG_TYPE_6 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_6 FUNC_ARG_TYPE_1, FUNC_ARG_TYPE_2, FUNC_ARG_TYPE_3, FUNC_ARG_TYPE_4, FUNC_ARG_TYPE_5, FUNC_ARG_TYPE_6 +#define FUNC_VALIDATION_STRING_6 Q_snprintf( pString, nBufLen, "method( %s, %s, %s, %s, %s, %s )", typeid( ARG_TYPE_1 ).name(), typeid( ARG_TYPE_2 ).name(), typeid( ARG_TYPE_3 ).name(), typeid( ARG_TYPE_4 ).name(), typeid( ARG_TYPE_5 ).name(), typeid( ARG_TYPE_6 ).name() ); +#define FUNC_SEPARATOR_6 , + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_7 typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7 +#define FUNC_TEMPLATE_ARG_PARAMS_7 , typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_7 , ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_7 ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7 +#define FUNC_ARG_MEMBERS_7 ARG_TYPE_1 m_arg1; ARG_TYPE_2 m_arg2; ARG_TYPE_3 m_arg3; ARG_TYPE_4 m_arg4; ARG_TYPE_5 m_arg5; ARG_TYPE_6 m_arg6; ARG_TYPE_7 m_arg7; +#define FUNC_ARG_FORMAL_PARAMS_7 , const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_7 const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7 +#define FUNC_CALL_ARGS_INIT_7 , m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ) +#define FUNC_SOLO_CALL_ARGS_INIT_7 : m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ) +#define FUNC_CALL_MEMBER_ARGS_7 m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7 +#define FUNC_CALL_ARGS_7 arg1, arg2, arg3, arg4, arg5, arg6, arg7 +#define FUNC_CALL_DATA_ARGS_7( _var ) _var->m_arg1, _var->m_arg2, _var->m_arg3, _var->m_arg4, _var->m_arg5, _var->m_arg6, _var->m_arg7 +#define FUNC_FUNCTOR_CALL_ARGS_7 , arg1, arg2, arg3, arg4, arg5, arg6, arg7 +#define FUNC_TEMPLATE_FUNC_PARAMS_7 , typename FUNC_ARG_TYPE_1, typename FUNC_ARG_TYPE_2, typename FUNC_ARG_TYPE_3, typename FUNC_ARG_TYPE_4, typename FUNC_ARG_TYPE_5, typename FUNC_ARG_TYPE_6, typename FUNC_ARG_TYPE_7 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_7 FUNC_ARG_TYPE_1, FUNC_ARG_TYPE_2, FUNC_ARG_TYPE_3, FUNC_ARG_TYPE_4, FUNC_ARG_TYPE_5, FUNC_ARG_TYPE_6, FUNC_ARG_TYPE_7 +#define FUNC_VALIDATION_STRING_7 Q_snprintf( pString, nBufLen, "method( %s, %s, %s, %s, %s, %s, %s )", typeid( ARG_TYPE_1 ).name(), typeid( ARG_TYPE_2 ).name(), typeid( ARG_TYPE_3 ).name(), typeid( ARG_TYPE_4 ).name(), typeid( ARG_TYPE_5 ).name(), typeid( ARG_TYPE_6 ).name(), typeid( ARG_TYPE_7 ).name() ); +#define FUNC_SEPARATOR_7 , + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_8 typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8 +#define FUNC_TEMPLATE_ARG_PARAMS_8 , typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_8 , ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_8 ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8 +#define FUNC_ARG_MEMBERS_8 ARG_TYPE_1 m_arg1; ARG_TYPE_2 m_arg2; ARG_TYPE_3 m_arg3; ARG_TYPE_4 m_arg4; ARG_TYPE_5 m_arg5; ARG_TYPE_6 m_arg6; ARG_TYPE_7 m_arg7; ARG_TYPE_8 m_arg8; +#define FUNC_ARG_FORMAL_PARAMS_8 , const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_8 const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8 +#define FUNC_CALL_ARGS_INIT_8 , m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ) +#define FUNC_SOLO_CALL_ARGS_INIT_8 : m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ) +#define FUNC_CALL_MEMBER_ARGS_8 m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8 +#define FUNC_CALL_ARGS_8 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 +#define FUNC_CALL_DATA_ARGS_8( _var ) _var->m_arg1, _var->m_arg2, _var->m_arg3, _var->m_arg4, _var->m_arg5, _var->m_arg6, _var->m_arg7, _var->m_arg8 +#define FUNC_FUNCTOR_CALL_ARGS_8 , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 +#define FUNC_TEMPLATE_FUNC_PARAMS_8 , typename FUNC_ARG_TYPE_1, typename FUNC_ARG_TYPE_2, typename FUNC_ARG_TYPE_3, typename FUNC_ARG_TYPE_4, typename FUNC_ARG_TYPE_5, typename FUNC_ARG_TYPE_6, typename FUNC_ARG_TYPE_7, typename FUNC_ARG_TYPE_8 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_8 FUNC_ARG_TYPE_1, FUNC_ARG_TYPE_2, FUNC_ARG_TYPE_3, FUNC_ARG_TYPE_4, FUNC_ARG_TYPE_5, FUNC_ARG_TYPE_6, FUNC_ARG_TYPE_7, FUNC_ARG_TYPE_8 +#define FUNC_VALIDATION_STRING_8 Q_snprintf( pString, nBufLen, "method( %s, %s, %s, %s, %s, %s, %s, %s )", typeid( ARG_TYPE_1 ).name(), typeid( ARG_TYPE_2 ).name(), typeid( ARG_TYPE_3 ).name(), typeid( ARG_TYPE_4 ).name(), typeid( ARG_TYPE_5 ).name(), typeid( ARG_TYPE_6 ).name(), typeid( ARG_TYPE_7 ).name(), typeid( ARG_TYPE_8 ).name() ); +#define FUNC_SEPARATOR_8 , + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_9 typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8, typename ARG_TYPE_9 +#define FUNC_TEMPLATE_ARG_PARAMS_9 , typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8, typename ARG_TYPE_9 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_9 , ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8, ARG_TYPE_9 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_9 ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8, ARG_TYPE_9 +#define FUNC_ARG_MEMBERS_9 ARG_TYPE_1 m_arg1; ARG_TYPE_2 m_arg2; ARG_TYPE_3 m_arg3; ARG_TYPE_4 m_arg4; ARG_TYPE_5 m_arg5; ARG_TYPE_6 m_arg6; ARG_TYPE_7 m_arg7; ARG_TYPE_8 m_arg8; ARG_TYPE_9 m_arg9; +#define FUNC_ARG_FORMAL_PARAMS_9 , const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8, const ARG_TYPE_9 &arg9 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_9 const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8, const ARG_TYPE_9 &arg9 +#define FUNC_CALL_ARGS_INIT_9 , m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ), m_arg9( arg9 ) +#define FUNC_SOLO_CALL_ARGS_INIT_9 : m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ), m_arg9( arg9 ) +#define FUNC_CALL_MEMBER_ARGS_9 m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9 +#define FUNC_CALL_ARGS_9 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 +#define FUNC_CALL_DATA_ARGS_9( _var ) _var->m_arg1, _var->m_arg2, _var->m_arg3, _var->m_arg4, _var->m_arg5, _var->m_arg6, _var->m_arg7, _var->m_arg8, _var->m_arg9 +#define FUNC_FUNCTOR_CALL_ARGS_9 , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 +#define FUNC_TEMPLATE_FUNC_PARAMS_9 , typename FUNC_ARG_TYPE_1, typename FUNC_ARG_TYPE_2, typename FUNC_ARG_TYPE_3, typename FUNC_ARG_TYPE_4, typename FUNC_ARG_TYPE_5, typename FUNC_ARG_TYPE_6, typename FUNC_ARG_TYPE_7, typename FUNC_ARG_TYPE_8, typename FUNC_ARG_TYPE_9 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_9 FUNC_ARG_TYPE_1, FUNC_ARG_TYPE_2, FUNC_ARG_TYPE_3, FUNC_ARG_TYPE_4, FUNC_ARG_TYPE_5, FUNC_ARG_TYPE_6, FUNC_ARG_TYPE_7, FUNC_ARG_TYPE_8, FUNC_ARG_TYPE_9 +#define FUNC_VALIDATION_STRING_9 Q_snprintf( pString, nBufLen, "method( %s, %s, %s, %s, %s, %s, %s, %s, %s )", typeid( ARG_TYPE_1 ).name(), typeid( ARG_TYPE_2 ).name(), typeid( ARG_TYPE_3 ).name(), typeid( ARG_TYPE_4 ).name(), typeid( ARG_TYPE_5 ).name(), typeid( ARG_TYPE_6 ).name(), typeid( ARG_TYPE_7 ).name(), typeid( ARG_TYPE_8 ).name(), typeid( ARG_TYPE_9 ).name() ); +#define FUNC_SEPARATOR_9 , + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_10 typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8, typename ARG_TYPE_9, typename ARG_TYPE_10 +#define FUNC_TEMPLATE_ARG_PARAMS_10 , typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8, typename ARG_TYPE_9, typename ARG_TYPE_10 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_10 , ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8, ARG_TYPE_9, ARG_TYPE_10 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_10 ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8, ARG_TYPE_9, ARG_TYPE_10 +#define FUNC_ARG_MEMBERS_10 ARG_TYPE_1 m_arg1; ARG_TYPE_2 m_arg2; ARG_TYPE_3 m_arg3; ARG_TYPE_4 m_arg4; ARG_TYPE_5 m_arg5; ARG_TYPE_6 m_arg6; ARG_TYPE_7 m_arg7; ARG_TYPE_8 m_arg8; ARG_TYPE_9 m_arg9; ARG_TYPE_10 m_arg10; +#define FUNC_ARG_FORMAL_PARAMS_10 , const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8, const ARG_TYPE_9 &arg9, const ARG_TYPE_10 &arg10 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_10 const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8, const ARG_TYPE_9 &arg9, const ARG_TYPE_10 &arg10 +#define FUNC_CALL_ARGS_INIT_10 , m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ), m_arg9( arg9 ), m_arg10( arg10 ) +#define FUNC_SOLO_CALL_ARGS_INIT_10 : m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ), m_arg9( arg9 ), m_arg10( arg10 ) +#define FUNC_CALL_MEMBER_ARGS_10 m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10 +#define FUNC_CALL_ARGS_10 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 +#define FUNC_CALL_DATA_ARGS_10( _var ) _var->m_arg1, _var->m_arg2, _var->m_arg3, _var->m_arg4, _var->m_arg5, _var->m_arg6, _var->m_arg7, _var->m_arg8, _var->m_arg9, _var->m_arg10 +#define FUNC_FUNCTOR_CALL_ARGS_10 , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10 +#define FUNC_TEMPLATE_FUNC_PARAMS_10 , typename FUNC_ARG_TYPE_1, typename FUNC_ARG_TYPE_2, typename FUNC_ARG_TYPE_3, typename FUNC_ARG_TYPE_4, typename FUNC_ARG_TYPE_5, typename FUNC_ARG_TYPE_6, typename FUNC_ARG_TYPE_7, typename FUNC_ARG_TYPE_8, typename FUNC_ARG_TYPE_9, typename FUNC_ARG_TYPE_10 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_10 FUNC_ARG_TYPE_1, FUNC_ARG_TYPE_2, FUNC_ARG_TYPE_3, FUNC_ARG_TYPE_4, FUNC_ARG_TYPE_5, FUNC_ARG_TYPE_6, FUNC_ARG_TYPE_7, FUNC_ARG_TYPE_8, FUNC_ARG_TYPE_9, FUNC_ARG_TYPE_10 +#define FUNC_VALIDATION_STRING_10 Q_snprintf( pString, nBufLen, "method( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )", typeid( ARG_TYPE_1 ).name(), typeid( ARG_TYPE_2 ).name(), typeid( ARG_TYPE_3 ).name(), typeid( ARG_TYPE_4 ).name(), typeid( ARG_TYPE_5 ).name(), typeid( ARG_TYPE_6 ).name(), typeid( ARG_TYPE_7 ).name(), typeid( ARG_TYPE_8 ).name(), typeid( ARG_TYPE_9 ).name(), typeid( ARG_TYPE_10 ).name() ); +#define FUNC_SEPARATOR_10 , + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_11 typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8, typename ARG_TYPE_9, typename ARG_TYPE_10, typename ARG_TYPE_11 +#define FUNC_TEMPLATE_ARG_PARAMS_11 , typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8, typename ARG_TYPE_9, typename ARG_TYPE_10, typename ARG_TYPE_11 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_11 , ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8, ARG_TYPE_9, ARG_TYPE_10, ARG_TYPE_11 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_11 ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8, ARG_TYPE_9, ARG_TYPE_10, ARG_TYPE_11 +#define FUNC_ARG_MEMBERS_11 ARG_TYPE_1 m_arg1; ARG_TYPE_2 m_arg2; ARG_TYPE_3 m_arg3; ARG_TYPE_4 m_arg4; ARG_TYPE_5 m_arg5; ARG_TYPE_6 m_arg6; ARG_TYPE_7 m_arg7; ARG_TYPE_8 m_arg8; ARG_TYPE_9 m_arg9; ARG_TYPE_10 m_arg10; ARG_TYPE_11 m_arg11 +#define FUNC_ARG_FORMAL_PARAMS_11 , const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8, const ARG_TYPE_9 &arg9, const ARG_TYPE_10 &arg10, const ARG_TYPE_11 &arg11 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_11 const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8, const ARG_TYPE_9 &arg9, const ARG_TYPE_10 &arg10, const ARG_TYPE_11 &arg11 +#define FUNC_CALL_ARGS_INIT_11 , m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ), m_arg9( arg9 ), m_arg10( arg10 ), m_arg11( arg11 ) +#define FUNC_SOLO_CALL_ARGS_INIT_11 : m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ), m_arg9( arg9 ), m_arg10( arg10 ), m_arg11( arg11 ) +#define FUNC_CALL_MEMBER_ARGS_11 m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10, m_arg11 +#define FUNC_CALL_ARGS_11 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11 +#define FUNC_CALL_DATA_ARGS_11( _var ) _var->m_arg1, _var->m_arg2, _var->m_arg3, _var->m_arg4, _var->m_arg5, _var->m_arg6, _var->m_arg7, _var->m_arg8, _var->m_arg9, _var->m_arg10, _var->m_arg11 +#define FUNC_FUNCTOR_CALL_ARGS_11 , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11 +#define FUNC_TEMPLATE_FUNC_PARAMS_11 , typename FUNC_ARG_TYPE_1, typename FUNC_ARG_TYPE_2, typename FUNC_ARG_TYPE_3, typename FUNC_ARG_TYPE_4, typename FUNC_ARG_TYPE_5, typename FUNC_ARG_TYPE_6, typename FUNC_ARG_TYPE_7, typename FUNC_ARG_TYPE_8, typename FUNC_ARG_TYPE_9, typename FUNC_ARG_TYPE_10, typename FUNC_ARG_TYPE_11 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_11 FUNC_ARG_TYPE_1, FUNC_ARG_TYPE_2, FUNC_ARG_TYPE_3, FUNC_ARG_TYPE_4, FUNC_ARG_TYPE_5, FUNC_ARG_TYPE_6, FUNC_ARG_TYPE_7, FUNC_ARG_TYPE_8, FUNC_ARG_TYPE_9, FUNC_ARG_TYPE_10, FUNC_ARG_TYPE_11 +#define FUNC_VALIDATION_STRING_11 Q_snprintf( pString, nBufLen, "method( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )", typeid( ARG_TYPE_1 ).name(), typeid( ARG_TYPE_2 ).name(), typeid( ARG_TYPE_3 ).name(), typeid( ARG_TYPE_4 ).name(), typeid( ARG_TYPE_5 ).name(), typeid( ARG_TYPE_6 ).name(), typeid( ARG_TYPE_7 ).name(), typeid( ARG_TYPE_8 ).name(), typeid( ARG_TYPE_9 ).name(), typeid( ARG_TYPE_10 ).name(), typeid( ARG_TYPE_11 ).name() ); +#define FUNC_SEPARATOR_11 , + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_12 typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8, typename ARG_TYPE_9, typename ARG_TYPE_10, typename ARG_TYPE_11, typename ARG_TYPE_12 +#define FUNC_TEMPLATE_ARG_PARAMS_12 , typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8, typename ARG_TYPE_9, typename ARG_TYPE_10, typename ARG_TYPE_11, typename ARG_TYPE_12 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_12 , ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8, ARG_TYPE_9, ARG_TYPE_10, ARG_TYPE_11, ARG_TYPE_12 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_12 ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8, ARG_TYPE_9, ARG_TYPE_10, ARG_TYPE_11, ARG_TYPE_12 +#define FUNC_ARG_MEMBERS_12 ARG_TYPE_1 m_arg1; ARG_TYPE_2 m_arg2; ARG_TYPE_3 m_arg3; ARG_TYPE_4 m_arg4; ARG_TYPE_5 m_arg5; ARG_TYPE_6 m_arg6; ARG_TYPE_7 m_arg7; ARG_TYPE_8 m_arg8; ARG_TYPE_9 m_arg9; ARG_TYPE_10 m_arg10; ARG_TYPE_11 m_arg11; ARG_TYPE_12 m_arg12 +#define FUNC_ARG_FORMAL_PARAMS_12 , const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8, const ARG_TYPE_9 &arg9, const ARG_TYPE_10 &arg10, const ARG_TYPE_11 &arg11, const ARG_TYPE_12 &arg12 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_12 const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8, const ARG_TYPE_9 &arg9, const ARG_TYPE_10 &arg10, const ARG_TYPE_11 &arg11, const ARG_TYPE_12 &arg12 +#define FUNC_CALL_ARGS_INIT_12 , m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ), m_arg9( arg9 ), m_arg10( arg10 ), m_arg11( arg11 ), m_arg12( arg12 ) +#define FUNC_SOLO_CALL_ARGS_INIT_12 : m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ), m_arg9( arg9 ), m_arg10( arg10 ), m_arg11( arg11 ), m_arg12( arg12 ) +#define FUNC_CALL_MEMBER_ARGS_12 m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10, m_arg11, m_arg12 +#define FUNC_CALL_ARGS_12 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12 +#define FUNC_CALL_DATA_ARGS_12( _var ) _var->m_arg1, _var->m_arg2, _var->m_arg3, _var->m_arg4, _var->m_arg5, _var->m_arg6, _var->m_arg7, _var->m_arg8, _var->m_arg9, _var->m_arg10, _var->m_arg11, _var->m_arg12 +#define FUNC_FUNCTOR_CALL_ARGS_12 , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12 +#define FUNC_TEMPLATE_FUNC_PARAMS_12 , typename FUNC_ARG_TYPE_1, typename FUNC_ARG_TYPE_2, typename FUNC_ARG_TYPE_3, typename FUNC_ARG_TYPE_4, typename FUNC_ARG_TYPE_5, typename FUNC_ARG_TYPE_6, typename FUNC_ARG_TYPE_7, typename FUNC_ARG_TYPE_8, typename FUNC_ARG_TYPE_9, typename FUNC_ARG_TYPE_10, typename FUNC_ARG_TYPE_11, typename FUNC_ARG_TYPE_12 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_12 FUNC_ARG_TYPE_1, FUNC_ARG_TYPE_2, FUNC_ARG_TYPE_3, FUNC_ARG_TYPE_4, FUNC_ARG_TYPE_5, FUNC_ARG_TYPE_6, FUNC_ARG_TYPE_7, FUNC_ARG_TYPE_8, FUNC_ARG_TYPE_9, FUNC_ARG_TYPE_10, FUNC_ARG_TYPE_11, FUNC_ARG_TYPE_12 +#define FUNC_VALIDATION_STRING_12 Q_snprintf( pString, nBufLen, "method( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )", typeid( ARG_TYPE_1 ).name(), typeid( ARG_TYPE_2 ).name(), typeid( ARG_TYPE_3 ).name(), typeid( ARG_TYPE_4 ).name(), typeid( ARG_TYPE_5 ).name(), typeid( ARG_TYPE_6 ).name(), typeid( ARG_TYPE_7 ).name(), typeid( ARG_TYPE_8 ).name(), typeid( ARG_TYPE_9 ).name(), typeid( ARG_TYPE_10 ).name(), typeid( ARG_TYPE_11 ).name(), typeid( ARG_TYPE_12 ).name() ); +#define FUNC_SEPARATOR_12 , + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_13 typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8, typename ARG_TYPE_9, typename ARG_TYPE_10, typename ARG_TYPE_11, typename ARG_TYPE_12, typename ARG_TYPE_13 +#define FUNC_TEMPLATE_ARG_PARAMS_13 , typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8, typename ARG_TYPE_9, typename ARG_TYPE_10, typename ARG_TYPE_11, typename ARG_TYPE_12, typename ARG_TYPE_13 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_13 , ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8, ARG_TYPE_9, ARG_TYPE_10, ARG_TYPE_11, ARG_TYPE_12, ARG_TYPE_13 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_13 ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8, ARG_TYPE_9, ARG_TYPE_10, ARG_TYPE_11, ARG_TYPE_12, ARG_TYPE_13 +#define FUNC_ARG_MEMBERS_13 ARG_TYPE_1 m_arg1; ARG_TYPE_2 m_arg2; ARG_TYPE_3 m_arg3; ARG_TYPE_4 m_arg4; ARG_TYPE_5 m_arg5; ARG_TYPE_6 m_arg6; ARG_TYPE_7 m_arg7; ARG_TYPE_8 m_arg8; ARG_TYPE_9 m_arg9; ARG_TYPE_10 m_arg10; ARG_TYPE_11 m_arg11; ARG_TYPE_12 m_arg12; ARG_TYPE_13 m_arg13 +#define FUNC_ARG_FORMAL_PARAMS_13 , const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8, const ARG_TYPE_9 &arg9, const ARG_TYPE_10 &arg10, const ARG_TYPE_11 &arg11, const ARG_TYPE_12 &arg12, const ARG_TYPE_13 &arg13 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_13 const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8, const ARG_TYPE_9 &arg9, const ARG_TYPE_10 &arg10, const ARG_TYPE_11 &arg11, const ARG_TYPE_12 &arg12, const ARG_TYPE_13 &arg13 +#define FUNC_CALL_ARGS_INIT_13 , m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ), m_arg9( arg9 ), m_arg10( arg10 ), m_arg11( arg11 ), m_arg12( arg12 ), m_arg13( arg13 ) +#define FUNC_SOLO_CALL_ARGS_INIT_13 : m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ), m_arg9( arg9 ), m_arg10( arg10 ), m_arg11( arg11 ), m_arg12( arg12 ), m_arg13( arg13 ) +#define FUNC_CALL_MEMBER_ARGS_13 m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10, m_arg11, m_arg12, m_arg13 +#define FUNC_CALL_ARGS_13 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13 +#define FUNC_CALL_DATA_ARGS_13( _var ) _var->m_arg1, _var->m_arg2, _var->m_arg3, _var->m_arg4, _var->m_arg5, _var->m_arg6, _var->m_arg7, _var->m_arg8, _var->m_arg9, _var->m_arg10, _var->m_arg11, _var->m_arg12, _var->m_arg13 +#define FUNC_FUNCTOR_CALL_ARGS_13 , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13 +#define FUNC_TEMPLATE_FUNC_PARAMS_13 , typename FUNC_ARG_TYPE_1, typename FUNC_ARG_TYPE_2, typename FUNC_ARG_TYPE_3, typename FUNC_ARG_TYPE_4, typename FUNC_ARG_TYPE_5, typename FUNC_ARG_TYPE_6, typename FUNC_ARG_TYPE_7, typename FUNC_ARG_TYPE_8, typename FUNC_ARG_TYPE_9, typename FUNC_ARG_TYPE_10, typename FUNC_ARG_TYPE_11, typename FUNC_ARG_TYPE_12, typename FUNC_ARG_TYPE_13 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_13 FUNC_ARG_TYPE_1, FUNC_ARG_TYPE_2, FUNC_ARG_TYPE_3, FUNC_ARG_TYPE_4, FUNC_ARG_TYPE_5, FUNC_ARG_TYPE_6, FUNC_ARG_TYPE_7, FUNC_ARG_TYPE_8, FUNC_ARG_TYPE_9, FUNC_ARG_TYPE_10, FUNC_ARG_TYPE_11, FUNC_ARG_TYPE_12, FUNC_ARG_TYPE_13 +#define FUNC_VALIDATION_STRING_13 Q_snprintf( pString, nBufLen, "method( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )", typeid( ARG_TYPE_1 ).name(), typeid( ARG_TYPE_2 ).name(), typeid( ARG_TYPE_3 ).name(), typeid( ARG_TYPE_4 ).name(), typeid( ARG_TYPE_5 ).name(), typeid( ARG_TYPE_6 ).name(), typeid( ARG_TYPE_7 ).name(), typeid( ARG_TYPE_8 ).name(), typeid( ARG_TYPE_9 ).name(), typeid( ARG_TYPE_10 ).name(), typeid( ARG_TYPE_11 ).name(), typeid( ARG_TYPE_12 ).name(), typeid( ARG_TYPE_13 ).name() ); +#define FUNC_SEPARATOR_13 , + +#define FUNC_SOLO_TEMPLATE_ARG_PARAMS_14 typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8, typename ARG_TYPE_9, typename ARG_TYPE_10, typename ARG_TYPE_11, typename ARG_TYPE_12, typename ARG_TYPE_13, typename ARG_TYPE_14 +#define FUNC_TEMPLATE_ARG_PARAMS_14 , typename ARG_TYPE_1, typename ARG_TYPE_2, typename ARG_TYPE_3, typename ARG_TYPE_4, typename ARG_TYPE_5, typename ARG_TYPE_6, typename ARG_TYPE_7, typename ARG_TYPE_8, typename ARG_TYPE_9, typename ARG_TYPE_10, typename ARG_TYPE_11, typename ARG_TYPE_12, typename ARG_TYPE_13, typename ARG_TYPE_14 +#define FUNC_BASE_TEMPLATE_ARG_PARAMS_14 , ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8, ARG_TYPE_9, ARG_TYPE_10, ARG_TYPE_11, ARG_TYPE_12, ARG_TYPE_13, ARG_TYPE_14 +#define FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_14 ARG_TYPE_1, ARG_TYPE_2, ARG_TYPE_3, ARG_TYPE_4, ARG_TYPE_5, ARG_TYPE_6, ARG_TYPE_7, ARG_TYPE_8, ARG_TYPE_9, ARG_TYPE_10, ARG_TYPE_11, ARG_TYPE_12, ARG_TYPE_13, ARG_TYPE_14 +#define FUNC_ARG_MEMBERS_14 ARG_TYPE_1 m_arg1; ARG_TYPE_2 m_arg2; ARG_TYPE_3 m_arg3; ARG_TYPE_4 m_arg4; ARG_TYPE_5 m_arg5; ARG_TYPE_6 m_arg6; ARG_TYPE_7 m_arg7; ARG_TYPE_8 m_arg8; ARG_TYPE_9 m_arg9; ARG_TYPE_10 m_arg10; ARG_TYPE_11 m_arg11; ARG_TYPE_12 m_arg12; ARG_TYPE_13 m_arg13; ARG_TYPE_14 m_arg14 +#define FUNC_ARG_FORMAL_PARAMS_14 , const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8, const ARG_TYPE_9 &arg9, const ARG_TYPE_10 &arg10, const ARG_TYPE_11 &arg11, const ARG_TYPE_12 &arg12, const ARG_TYPE_13 &arg13, const ARG_TYPE_14 &arg14 +#define FUNC_PROXY_ARG_FORMAL_PARAMS_14 const ARG_TYPE_1 &arg1, const ARG_TYPE_2 &arg2, const ARG_TYPE_3 &arg3, const ARG_TYPE_4 &arg4, const ARG_TYPE_5 &arg5, const ARG_TYPE_6 &arg6, const ARG_TYPE_7 &arg7, const ARG_TYPE_8 &arg8, const ARG_TYPE_9 &arg9, const ARG_TYPE_10 &arg10, const ARG_TYPE_11 &arg11, const ARG_TYPE_12 &arg12, const ARG_TYPE_13 &arg13, const ARG_TYPE_14 &arg14 +#define FUNC_CALL_ARGS_INIT_14 , m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ), m_arg9( arg9 ), m_arg10( arg10 ), m_arg11( arg11 ), m_arg12( arg12 ), m_arg13( arg13 ), m_arg14( arg14 ) +#define FUNC_SOLO_CALL_ARGS_INIT_14 : m_arg1( arg1 ), m_arg2( arg2 ), m_arg3( arg3 ), m_arg4( arg4 ), m_arg5( arg5 ), m_arg6( arg6 ), m_arg7( arg7 ), m_arg8( arg8 ), m_arg9( arg9 ), m_arg10( arg10 ), m_arg11( arg11 ), m_arg12( arg12 ), m_arg13( arg13 ), m_arg14( arg14 ) +#define FUNC_CALL_MEMBER_ARGS_14 m_arg1, m_arg2, m_arg3, m_arg4, m_arg5, m_arg6, m_arg7, m_arg8, m_arg9, m_arg10, m_arg11, m_arg12, m_arg13, m_arg14 +#define FUNC_CALL_ARGS_14 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14 +#define FUNC_CALL_DATA_ARGS_14( _var ) _var->m_arg1, _var->m_arg2, _var->m_arg3, _var->m_arg4, _var->m_arg5, _var->m_arg6, _var->m_arg7, _var->m_arg8, _var->m_arg9, _var->m_arg10, _var->m_arg11, _var->m_arg12, _var->m_arg13, _var->m_arg14 +#define FUNC_FUNCTOR_CALL_ARGS_14 , arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14 +#define FUNC_TEMPLATE_FUNC_PARAMS_14 , typename FUNC_ARG_TYPE_1, typename FUNC_ARG_TYPE_2, typename FUNC_ARG_TYPE_3, typename FUNC_ARG_TYPE_4, typename FUNC_ARG_TYPE_5, typename FUNC_ARG_TYPE_6, typename FUNC_ARG_TYPE_7, typename FUNC_ARG_TYPE_8, typename FUNC_ARG_TYPE_9, typename FUNC_ARG_TYPE_10, typename FUNC_ARG_TYPE_11, typename FUNC_ARG_TYPE_12, typename FUNC_ARG_TYPE_13, typename FUNC_ARG_TYPE_14 +#define FUNC_BASE_TEMPLATE_FUNC_PARAMS_14 FUNC_ARG_TYPE_1, FUNC_ARG_TYPE_2, FUNC_ARG_TYPE_3, FUNC_ARG_TYPE_4, FUNC_ARG_TYPE_5, FUNC_ARG_TYPE_6, FUNC_ARG_TYPE_7, FUNC_ARG_TYPE_8, FUNC_ARG_TYPE_9, FUNC_ARG_TYPE_10, FUNC_ARG_TYPE_11, FUNC_ARG_TYPE_12, FUNC_ARG_TYPE_13, FUNC_ARG_TYPE_14 +#define FUNC_VALIDATION_STRING_14 Q_snprintf( pString, nBufLen, "method( %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s )", typeid( ARG_TYPE_1 ).name(), typeid( ARG_TYPE_2 ).name(), typeid( ARG_TYPE_3 ).name(), typeid( ARG_TYPE_4 ).name(), typeid( ARG_TYPE_5 ).name(), typeid( ARG_TYPE_6 ).name(), typeid( ARG_TYPE_7 ).name(), typeid( ARG_TYPE_8 ).name(), typeid( ARG_TYPE_9 ).name(), typeid( ARG_TYPE_10 ).name(), typeid( ARG_TYPE_11 ).name(), typeid( ARG_TYPE_12 ).name(), typeid( ARG_TYPE_13 ).name(), typeid( ARG_TYPE_14 ).name() ); +#define FUNC_SEPARATOR_14 , + +#define FUNC_GENERATE_ALL_BUT0( INNERMACRONAME ) \ + INNERMACRONAME(1); \ + INNERMACRONAME(2); \ + INNERMACRONAME(3); \ + INNERMACRONAME(4); \ + INNERMACRONAME(5); \ + INNERMACRONAME(6); \ + INNERMACRONAME(7); \ + INNERMACRONAME(8); \ + INNERMACRONAME(9); \ + INNERMACRONAME(10);\ + INNERMACRONAME(11);\ + INNERMACRONAME(12);\ + INNERMACRONAME(13);\ + INNERMACRONAME(14) + +#define FUNC_GENERATE_ALL( INNERMACRONAME ) \ + INNERMACRONAME(0); \ + FUNC_GENERATE_ALL_BUT0( INNERMACRONAME ) + + +abstract_class CFunctor : public IRefCounted +{ +public: + CFunctor() + { +#ifdef DEBUG + m_nUserID = 0; +#endif + } + virtual ~CFunctor() {} + virtual void operator()() = 0; + + unsigned m_nUserID; +}; + + +abstract_class CFunctorData : public IRefCounted +{ +public: + virtual void ComputeValidationString(char* pString, size_t nBufLen) const = 0; +}; + +abstract_class CFunctorCallback : public IRefCounted +{ +public: + virtual bool IsEqual(CFunctorCallback * pSrc) const = 0; + virtual void operator()(CFunctorData* pData) = 0; + virtual void ComputeValidationString(char* pString, size_t nBufLen) const = 0; + virtual const char* GetImplClassName() const = 0; + virtual const void* GetTarget() const = 0; +}; + + +template +inline T RefToVal(const T& item) +{ + return item; +} + + +template +class CLateBoundPtr +{ +public: + CLateBoundPtr(T** ppObject) + : m_ppObject(ppObject) + { + } + + T* operator->() { return *m_ppObject; } + T& operator *() { return **m_ppObject; } + operator T* () const { return (T*)(*m_ppObject); } + operator void* () { return *m_ppObject; } + +private: + T** m_ppObject; +}; + + +class CFuncMemPolicyNone +{ +public: + static void OnAcquire(void* pObject) {} + static void OnRelease(void* pObject) {} +}; + +template +class CFuncMemPolicyRefCount +{ +public: + static void OnAcquire(OBJECT_TYPE_PTR pObject) { pObject->AddRef(); } + static void OnRelease(OBJECT_TYPE_PTR pObject) { pObject->Release(); } +}; + + +template +class CMemberFuncProxyBase +{ +public: + bool operator==(const CMemberFuncProxyBase& src) const + { + return m_pfnProxied == src.m_pfnProxied && m_pObject == src.m_pObject; + } + + const void* GetTarget() const + { + return m_pObject; + } + +protected: + CMemberFuncProxyBase(OBJECT_TYPE_PTR pObject, FUNCTION_TYPE pfnProxied) + : m_pObject(pObject), + m_pfnProxied(pfnProxied) + { + MEM_POLICY::OnAcquire(m_pObject); + } + + ~CMemberFuncProxyBase() + { + MEM_POLICY::OnRelease(m_pObject); + } + + void Set(OBJECT_TYPE_PTR pObject, FUNCTION_TYPE pfnProxied) + { + m_pfnProxied = pfnProxied; + m_pObject = pObject; + } + + void OnCall() + { + Assert((void*)m_pObject != NULL); + } + + FUNCTION_TYPE m_pfnProxied; + OBJECT_TYPE_PTR m_pObject; +}; + + +#define DEFINE_MEMBER_FUNC_PROXY( N ) \ + template \ + class CMemberFuncProxy##N : public CMemberFuncProxyBase \ + { \ + public: \ + CMemberFuncProxy##N( OBJECT_TYPE_PTR pObject = NULL, FUNCTION_TYPE pfnProxied = NULL ) \ + : CMemberFuncProxyBase( pObject, pfnProxied ) \ + { \ + } \ + \ + void operator()( FUNC_PROXY_ARG_FORMAL_PARAMS_##N ) \ + { \ + this->OnCall(); \ + ((*this->m_pObject).*this->m_pfnProxied)( FUNC_CALL_ARGS_##N ); \ + } \ + } + +FUNC_GENERATE_ALL(DEFINE_MEMBER_FUNC_PROXY); + + +#include "memdbgon.h" + +typedef CRefCounted1 CFunctorBase; + +#define DEFINE_FUNCTOR_TEMPLATE(N) \ + template \ + class CFunctor##N : public CFunctorBase \ + { \ + public: \ + CFunctor##N( FUNC_TYPE pfnProxied FUNC_ARG_FORMAL_PARAMS_##N ) : m_pfnProxied( pfnProxied ) FUNC_CALL_ARGS_INIT_##N {} \ + void operator()() { m_pfnProxied(FUNC_CALL_MEMBER_ARGS_##N); } \ + \ + private: \ + FUNC_TYPE m_pfnProxied; \ + FUNC_ARG_MEMBERS_##N; \ + } + +FUNC_GENERATE_ALL(DEFINE_FUNCTOR_TEMPLATE); + +#define DEFINE_MEMBER_FUNCTOR( N ) \ + template \ + class CMemberFunctor##N : public FUNCTOR_BASE \ + { \ + public: \ + CMemberFunctor##N( OBJECT_TYPE_PTR pObject, FUNCTION_TYPE pfnProxied FUNC_ARG_FORMAL_PARAMS_##N ) : m_Proxy( pObject, pfnProxied ) FUNC_CALL_ARGS_INIT_##N {} \ + void operator()() { m_Proxy(FUNC_CALL_MEMBER_ARGS_##N); } \ + \ + private: \ + CMemberFuncProxy##N m_Proxy; \ + FUNC_ARG_MEMBERS_##N; \ + }; + + +FUNC_GENERATE_ALL(DEFINE_MEMBER_FUNCTOR); + +typedef CRefCounted1 CFunctorDataBase; +class CFunctorCallbackBase : public CRefCounted1 +{ +protected: + virtual void ValidateFunctorData(CFunctorData* pData) + { +#ifdef _DEBUG + char pDataString[1024]; + char pCallbackString[1024]; + ComputeValidationString(pCallbackString, sizeof(pCallbackString)); + pData->ComputeValidationString(pDataString, sizeof(pDataString)); + bool bMatch = !Q_stricmp(pDataString, pCallbackString); + if (!bMatch) + { + Warning("Functor doesn't match data!\n\tExpected:\t%s\n\tEncountered:\t%s\n", + pCallbackString, pDataString); + Assert(0); + } +#endif + } +}; + +#define DEFINE_FUNCTOR_DATA_TEMPLATE(N) \ + template < FUNC_SOLO_TEMPLATE_ARG_PARAMS_##N > \ + class CFunctorData##N : public CFunctorDataBase \ + { \ + public: \ + CFunctorData##N( FUNC_PROXY_ARG_FORMAL_PARAMS_##N ) FUNC_SOLO_CALL_ARGS_INIT_##N {} \ + virtual void ComputeValidationString( char *pString, size_t nBufLen ) const { FUNC_VALIDATION_STRING_##N } \ + FUNC_ARG_MEMBERS_##N; \ + } + +class CFunctorData0 : public CFunctorDataBase +{ +public: + CFunctorData0() {} + virtual void ComputeValidationString(char* pString, size_t nBufLen_) const { int nBufLen = (int)nBufLen_; FUNC_VALIDATION_STRING_0 } +}; + +FUNC_GENERATE_ALL_BUT0(DEFINE_FUNCTOR_DATA_TEMPLATE); + +#define DEFINE_FUNCTOR_CALLBACK_TEMPLATE(N) \ + template < FUNC_SOLO_TEMPLATE_ARG_PARAMS_##N > \ + class CFunctorCallback##N : public CFunctorCallbackBase \ + { \ + typedef void (*Callback_t)( FUNC_PROXY_ARG_FORMAL_PARAMS_##N ); \ + public: \ + CFunctorCallback##N( Callback_t pfnProxied ) : m_pfnProxied( pfnProxied ) {} \ + void operator()( CFunctorData *pFunctorDataBase ) \ + { \ + ValidateFunctorData( pFunctorDataBase ); \ + CFunctorData##N< FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_##N > *pFunctorData = static_cast< CFunctorData##N< FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_##N >* >( pFunctorDataBase ); \ + m_pfnProxied( FUNC_CALL_DATA_ARGS_##N(pFunctorData) ); \ + } \ + virtual bool IsEqual( CFunctorCallback *pSrc ) const { return !Q_stricmp( GetImplClassName(), pSrc->GetImplClassName() ) && ( m_pfnProxied == static_cast< CFunctorCallback##N * >( pSrc )->m_pfnProxied ); } \ + virtual void ComputeValidationString( char *pString, size_t nBufLen ) const { FUNC_VALIDATION_STRING_##N } \ + virtual const char *GetImplClassName() const { return "CFunctorCallback" #N; } \ + virtual const void *GetTarget() const { return m_pfnProxied; } \ + private: \ + Callback_t m_pfnProxied; \ + } + +class CFunctorCallback0 : public CFunctorCallbackBase +{ + typedef void (*Callback_t)(); +public: + CFunctorCallback0(Callback_t pfnProxied) : m_pfnProxied(pfnProxied) {} + void operator()(CFunctorData* pFunctorDataBase) + { + ValidateFunctorData(pFunctorDataBase); + m_pfnProxied(); + } + virtual void ComputeValidationString(char* pString, size_t nBufLen_) const { int nBufLen = (int)nBufLen_; FUNC_VALIDATION_STRING_0 } + virtual bool IsEqual(CFunctorCallback* pSrc) const + { + if (Q_stricmp(GetImplClassName(), pSrc->GetImplClassName())) + return false; + return m_pfnProxied == static_cast(pSrc)->m_pfnProxied; + } + virtual const char* GetImplClassName() const { return "CFunctorCallback0"; } + virtual const void* GetTarget() const { return (void*)m_pfnProxied; } +private: + Callback_t m_pfnProxied; +}; + +FUNC_GENERATE_ALL_BUT0(DEFINE_FUNCTOR_CALLBACK_TEMPLATE); + +#define DEFINE_MEMBER_FUNCTOR_CALLBACK_TEMPLATE( N ) \ + template < class FUNCTION_CLASS FUNC_TEMPLATE_ARG_PARAMS_##N, class MEM_POLICY = CFuncMemPolicyNone > \ + class CMemberFunctorCallback##N : public CFunctorCallbackBase \ + { \ + typedef void (FUNCTION_CLASS::*MemberCallback_t)( FUNC_PROXY_ARG_FORMAL_PARAMS_##N ); \ + public: \ + CMemberFunctorCallback##N( FUNCTION_CLASS *pObject, MemberCallback_t pfnProxied ) : m_Proxy( pObject, pfnProxied ) {} \ + void operator()( CFunctorData *pFunctorDataBase ) \ + { \ + ValidateFunctorData( pFunctorDataBase ); \ + CFunctorData##N< FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_##N > *pFunctorData = static_cast< CFunctorData##N< FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_##N >* >( pFunctorDataBase ); \ + m_Proxy( FUNC_CALL_DATA_ARGS_##N( pFunctorData ) ); \ + } \ + virtual void ComputeValidationString( char *pString, size_t nBufLen ) const { FUNC_VALIDATION_STRING_##N } \ + virtual bool IsEqual( CFunctorCallback *pSrc ) const { return !Q_stricmp( GetImplClassName(), pSrc->GetImplClassName() ) && ( m_Proxy == static_cast< CMemberFunctorCallback##N* >( pSrc )->m_Proxy ); } \ + virtual const char *GetImplClassName() const { return "CMemberFunctorCallback" #N; } \ + virtual const void *GetTarget() const { return m_Proxy.GetTarget(); } \ + private: \ + CMemberFuncProxy##N< FUNCTION_CLASS *, MemberCallback_t FUNC_BASE_TEMPLATE_ARG_PARAMS_##N, MEM_POLICY> m_Proxy; \ + } + +template < class FUNCTION_CLASS, class MEM_POLICY = CFuncMemPolicyNone > +class CMemberFunctorCallback0 : public CFunctorCallbackBase +{ + typedef void (FUNCTION_CLASS::* MemberCallback_t)(); +public: + CMemberFunctorCallback0(FUNCTION_CLASS* pObject, MemberCallback_t pfnProxied) : m_Proxy(pObject, pfnProxied) {} + void operator()(CFunctorData* pFunctorDataBase) + { + ValidateFunctorData(pFunctorDataBase); + m_Proxy(); + } + virtual void ComputeValidationString(char* pString, size_t nBufLen) const { FUNC_VALIDATION_STRING_0 } + virtual bool IsEqual(CFunctorCallback* pSrc) const + { + if (Q_stricmp(GetImplClassName(), pSrc->GetImplClassName())) + return false; + return m_Proxy == static_cast(pSrc)->m_Proxy; + } + virtual const char* GetImplClassName() const { return "CMemberFunctorCallback0"; } + virtual const void* GetTarget() const { return m_Proxy.GetTarget(); } +private: + CMemberFuncProxy0< FUNCTION_CLASS*, MemberCallback_t, MEM_POLICY > m_Proxy; +}; + +FUNC_GENERATE_ALL_BUT0(DEFINE_MEMBER_FUNCTOR_CALLBACK_TEMPLATE); + + +#define DEFINE_NONMEMBER_FUNCTOR_FACTORY(N) \ + template \ + inline CFunctor *CreateFunctor(FUNCTION_RETTYPE (*pfnProxied)( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) FUNC_ARG_FORMAL_PARAMS_##N ) \ + { \ + typedef FUNCTION_RETTYPE (*Func_t)(FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N); \ + return new CFunctor##N( pfnProxied FUNC_FUNCTOR_CALL_ARGS_##N ); \ + } + +FUNC_GENERATE_ALL(DEFINE_NONMEMBER_FUNCTOR_FACTORY); + +#define DEFINE_MEMBER_FUNCTOR_FACTORY(N) \ + template \ + inline CFunctor *CreateFunctor(OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE ( FUNCTION_CLASS::*pfnProxied )( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) FUNC_ARG_FORMAL_PARAMS_##N ) \ + { \ + return new CMemberFunctor##N(pObject, pfnProxied FUNC_FUNCTOR_CALL_ARGS_##N); \ + } + +FUNC_GENERATE_ALL(DEFINE_MEMBER_FUNCTOR_FACTORY); + +#define DEFINE_CONST_MEMBER_FUNCTOR_FACTORY(N) \ + template \ + inline CFunctor *CreateFunctor(OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE ( FUNCTION_CLASS::*pfnProxied )( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) const FUNC_ARG_FORMAL_PARAMS_##N ) \ + { \ + return new CMemberFunctor##N(pObject, pfnProxied FUNC_FUNCTOR_CALL_ARGS_##N); \ + } + +FUNC_GENERATE_ALL(DEFINE_CONST_MEMBER_FUNCTOR_FACTORY); + +#define DEFINE_REF_COUNTING_MEMBER_FUNCTOR_FACTORY(N) \ + template \ + inline CFunctor *CreateRefCountingFunctor(OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE ( FUNCTION_CLASS::*pfnProxied )( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) FUNC_ARG_FORMAL_PARAMS_##N ) \ + { \ + return new CMemberFunctor##N >(pObject, pfnProxied FUNC_FUNCTOR_CALL_ARGS_##N); \ + } + +FUNC_GENERATE_ALL(DEFINE_REF_COUNTING_MEMBER_FUNCTOR_FACTORY); + +#define DEFINE_REF_COUNTING_CONST_MEMBER_FUNCTOR_FACTORY(N) \ + template \ + inline CFunctor *CreateRefCountingFunctor(OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE ( FUNCTION_CLASS::*pfnProxied )( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) const FUNC_ARG_FORMAL_PARAMS_##N ) \ + { \ + return new CMemberFunctor##N >(pObject, pfnProxied FUNC_FUNCTOR_CALL_ARGS_##N); \ + } + +FUNC_GENERATE_ALL(DEFINE_REF_COUNTING_CONST_MEMBER_FUNCTOR_FACTORY); + +#define DEFINE_FUNCTOR_DATA_FACTORY(N) \ + template < FUNC_SOLO_TEMPLATE_ARG_PARAMS_##N > \ + inline CFunctorData *CreateFunctorData( FUNC_PROXY_ARG_FORMAL_PARAMS_##N ) \ + { \ + return new CFunctorData##N< FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_##N >( FUNC_CALL_ARGS_##N ); \ + } + +inline CFunctorData* CreateFunctorData() +{ + return new CFunctorData0(); +} + +FUNC_GENERATE_ALL_BUT0(DEFINE_FUNCTOR_DATA_FACTORY); + +#define DEFINE_FUNCTOR_CALLBACK_FACTORY(N) \ + template < FUNC_SOLO_TEMPLATE_ARG_PARAMS_##N > \ + inline CFunctorCallback *CreateFunctorCallback( void (*pfnProxied)( FUNC_PROXY_ARG_FORMAL_PARAMS_##N ) ) \ + { \ + return new CFunctorCallback##N< FUNC_SOLO_BASE_TEMPLATE_ARG_PARAMS_##N >( pfnProxied ); \ + } + +inline CFunctorCallback* CreateFunctorCallback(void (*pfnProxied)()) +{ + return new CFunctorCallback0(pfnProxied); +} + +FUNC_GENERATE_ALL_BUT0(DEFINE_FUNCTOR_CALLBACK_FACTORY); + +#define DEFINE_MEMBER_FUNCTOR_CALLBACK_FACTORY(N) \ + template < typename FUNCTION_CLASS FUNC_TEMPLATE_ARG_PARAMS_##N > \ + inline CFunctorCallback *CreateFunctorCallback( FUNCTION_CLASS *pObject, void ( FUNCTION_CLASS::*pfnProxied )( FUNC_PROXY_ARG_FORMAL_PARAMS_##N ) ) \ + { \ + return new CMemberFunctorCallback##N< FUNCTION_CLASS FUNC_BASE_TEMPLATE_ARG_PARAMS_##N >( pObject, pfnProxied ); \ + } + +FUNC_GENERATE_ALL(DEFINE_MEMBER_FUNCTOR_CALLBACK_FACTORY); + + +#define DEFINE_NONMEMBER_FUNCTOR_DIRECT(N) \ + template \ + inline void FunctorDirectCall(FUNCTION_RETTYPE (*pfnProxied)( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) FUNC_ARG_FORMAL_PARAMS_##N ) \ +{ \ + (*pfnProxied)( FUNC_CALL_ARGS_##N ); \ +} + +FUNC_GENERATE_ALL(DEFINE_NONMEMBER_FUNCTOR_DIRECT); + + +#define DEFINE_MEMBER_FUNCTOR_DIRECT(N) \ + template \ + inline void FunctorDirectCall(OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE ( FUNCTION_CLASS::*pfnProxied )( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) FUNC_ARG_FORMAL_PARAMS_##N ) \ +{ \ + ((*pObject).*pfnProxied)(FUNC_CALL_ARGS_##N); \ +} + +FUNC_GENERATE_ALL(DEFINE_MEMBER_FUNCTOR_DIRECT); + +#define DEFINE_CONST_MEMBER_FUNCTOR_DIRECT(N) \ + template \ + inline void FunctorDirectCall(OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE ( FUNCTION_CLASS::*pfnProxied )( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) const FUNC_ARG_FORMAL_PARAMS_##N ) \ +{ \ + ((*pObject).*pfnProxied)(FUNC_CALL_ARGS_##N); \ +} + +FUNC_GENERATE_ALL(DEFINE_CONST_MEMBER_FUNCTOR_DIRECT); + +#include "memdbgoff.h" + +class CDefaultFunctorFactory +{ +public: + FUNC_GENERATE_ALL(DEFINE_NONMEMBER_FUNCTOR_FACTORY); + FUNC_GENERATE_ALL(DEFINE_MEMBER_FUNCTOR_FACTORY); + FUNC_GENERATE_ALL(DEFINE_CONST_MEMBER_FUNCTOR_FACTORY); + FUNC_GENERATE_ALL(DEFINE_REF_COUNTING_MEMBER_FUNCTOR_FACTORY); + FUNC_GENERATE_ALL(DEFINE_REF_COUNTING_CONST_MEMBER_FUNCTOR_FACTORY); +}; + +template +class CCustomizedFunctorFactory +{ +public: + void SetAllocator(CAllocator* pAllocator) + { + m_pAllocator = pAllocator; + } + +#define DEFINE_NONMEMBER_FUNCTOR_FACTORY_CUSTOM(N) \ + template \ + inline CFunctor *CreateFunctor( FUNCTION_RETTYPE (*pfnProxied)( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) FUNC_ARG_FORMAL_PARAMS_##N ) \ + { \ + typedef FUNCTION_RETTYPE (*Func_t)(FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N); \ + return new (m_pAllocator->Alloc( sizeof(CFunctor##N) )) CFunctor##N( pfnProxied FUNC_FUNCTOR_CALL_ARGS_##N ); \ + } + + FUNC_GENERATE_ALL(DEFINE_NONMEMBER_FUNCTOR_FACTORY_CUSTOM); + +#define DEFINE_MEMBER_FUNCTOR_FACTORY_CUSTOM(N) \ + template \ + inline CFunctor *CreateFunctor(OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE ( FUNCTION_CLASS::*pfnProxied )( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) FUNC_ARG_FORMAL_PARAMS_##N ) \ + { \ + return new (m_pAllocator->Alloc( sizeof(CMemberFunctor##N) )) CMemberFunctor##N(pObject, pfnProxied FUNC_FUNCTOR_CALL_ARGS_##N); \ + } + + FUNC_GENERATE_ALL(DEFINE_MEMBER_FUNCTOR_FACTORY_CUSTOM); + +#define DEFINE_CONST_MEMBER_FUNCTOR_FACTORY_CUSTOM(N) \ + template \ + inline CFunctor *CreateFunctor( OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE ( FUNCTION_CLASS::*pfnProxied )( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) const FUNC_ARG_FORMAL_PARAMS_##N ) \ + { \ + return new (m_pAllocator->Alloc( sizeof(CMemberFunctor##N) )) CMemberFunctor##N(pObject, pfnProxied FUNC_FUNCTOR_CALL_ARGS_##N); \ + } + + FUNC_GENERATE_ALL(DEFINE_CONST_MEMBER_FUNCTOR_FACTORY_CUSTOM); + +#define DEFINE_REF_COUNTING_MEMBER_FUNCTOR_FACTORY_CUSTOM(N) \ + template \ + inline CFunctor *CreateRefCountingFunctor( OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE ( FUNCTION_CLASS::*pfnProxied )( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) FUNC_ARG_FORMAL_PARAMS_##N ) \ + { \ + return new (m_pAllocator->Alloc( sizeof(CMemberFunctor##N >) )) CMemberFunctor##N >(pObject, pfnProxied FUNC_FUNCTOR_CALL_ARGS_##N); \ + } + + FUNC_GENERATE_ALL(DEFINE_REF_COUNTING_MEMBER_FUNCTOR_FACTORY_CUSTOM); + +#define DEFINE_REF_COUNTING_CONST_MEMBER_FUNCTOR_FACTORY_CUSTOM(N) \ + template \ + inline CFunctor *CreateRefCountingFunctor( OBJECT_TYPE_PTR pObject, FUNCTION_RETTYPE ( FUNCTION_CLASS::*pfnProxied )( FUNC_BASE_TEMPLATE_FUNC_PARAMS_##N ) const FUNC_ARG_FORMAL_PARAMS_##N ) \ + { \ + return new (m_pAllocator->Alloc( sizeof(CMemberFunctor##N >) )) CMemberFunctor##N >(pObject, pfnProxied FUNC_FUNCTOR_CALL_ARGS_##N); \ + } + + FUNC_GENERATE_ALL(DEFINE_REF_COUNTING_CONST_MEMBER_FUNCTOR_FACTORY_CUSTOM); + +private: + CAllocator* m_pAllocator; + +}; + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/fx.h b/SpyCustom/sdk/fx.h new file mode 100644 index 0000000..4d15357 --- /dev/null +++ b/SpyCustom/sdk/fx.h @@ -0,0 +1,156 @@ +#if !defined( FX_H ) +#define FX_H +#ifdef _WIN32 +#pragma once +#endif + +#include "vector.h" +#include "c_pixel_visibility.h" +#include "mathlib.h" +typedef CBaseHandle ClientEntityHandle_t; +#include "smartptr.h" + +class Vector; +class CGameTrace; +typedef CGameTrace trace_t; +enum +{ + FX_ENERGYSPLASH_EXPLOSIVE = 0x1, + FX_ENERGYSPLASH_SMOKE = 0x2, + FX_ENERGYSPLASH_LITTLESPARKS = 0x4, + FX_ENERGYSPLASH_BIGSPARKS = 0x8, + FX_ENERGYSPLASH_BIGSPARKSCOLLIDE = 0x10, + FX_ENERGYSPLASH_ENERGYBALLS = 0x20, + FX_ENERGYSPLASH_DLIGHT = 0x40, + + FX_ENERGYSPLASH_DEFAULT = ~FX_ENERGYSPLASH_EXPLOSIVE, + FX_ENERGYSPLASH_DEFAULT_EXPLOSIVE = ~0, +}; + +bool FX_GetAttachmentTransform(ClientEntityHandle_t hEntity, int attachmentIndex, matrix3x4_t& transform); +bool FX_GetAttachmentTransform(ClientEntityHandle_t hEntity, int attachmentIndex, Vector* origin, QAngle* angles); + +void FX_RicochetSound(const Vector& pos); + +void FX_AntlionImpact(const Vector& pos, trace_t* tr); +void FX_DebrisFlecks(const Vector& origin, trace_t* trace, char materialType, int iScale, bool bNoFlecks = false); +void FX_Tracer(Vector& start, Vector& end, int velocity, bool makeWhiz = true); +void FX_GunshipTracer(Vector& start, Vector& end, int velocity, bool makeWhiz = true); +void FX_StriderTracer(Vector& start, Vector& end, int velocity, bool makeWhiz = true); +void FX_HunterTracer(Vector& start, Vector& end, int velocity, bool makeWhiz = true); +void FX_PlayerTracer(Vector& start, Vector& end); +void FX_BulletPass(Vector& start, Vector& end); +void FX_MetalSpark(const Vector& position, const Vector& direction, const Vector& surfaceNormal, int iScale = 1); +void FX_MetalScrape(Vector& position, Vector& normal); +void FX_Sparks(const Vector& pos, int nMagnitude, int nTrailLength, const Vector& vecDir, float flWidth, float flMinSpeed, float flMaxSpeed, char* pSparkMaterial = NULL); +void FX_ElectricSpark(const Vector& pos, int nMagnitude, int nTrailLength, const Vector* vecDir); +void FX_BugBlood(Vector& pos, Vector& dir, Vector& vWorldMins, Vector& vWorldMaxs); +void FX_Blood(Vector& pos, Vector& dir, float r, float g, float b, float a); +void FX_CreateImpactDust(Vector& origin, Vector& normal); +void FX_EnergySplash(const Vector& pos, const Vector& normal, int nFlags = FX_ENERGYSPLASH_DEFAULT); +void FX_MicroExplosion(Vector& position, Vector& normal); +void FX_Explosion(Vector& origin, Vector& normal, char materialType); +void FX_ConcussiveExplosion(Vector& origin, Vector& normal); +void FX_DustImpact(const Vector& origin, trace_t* tr, int iScale); +void FX_DustImpact(const Vector& origin, trace_t* tr, float flScale); +void FX_MuzzleEffect(const Vector& origin, const QAngle& angles, float scale, ClientEntityHandle_t hEntity, unsigned char* pFlashColor = NULL, bool bOneFrame = false); +void FX_MuzzleEffectAttached(float scale, ClientEntityHandle_t hEntity, int attachmentIndex, unsigned char* pFlashColor = NULL, bool bOneFrame = false); +void FX_StriderMuzzleEffect(const Vector& origin, const QAngle& angles, float scale, ClientEntityHandle_t hEntity, unsigned char* pFlashColor = NULL); +void FX_GunshipMuzzleEffect(const Vector& origin, const QAngle& angles, float scale, ClientEntityHandle_t hEntity, unsigned char* pFlashColor = NULL); +void FX_Smoke(const Vector& origin, const Vector& velocity, float scale, int numParticles, float flDietime, unsigned char* pColor, int iAlpha, const char* pMaterial, float flRoll, float flRollDelta); + +void FX_Smoke(const Vector& origin, const QAngle& angles, float scale, int numParticles, unsigned char* pColor = NULL, int iAlpha = -1); +void FX_Dust(const Vector& vecOrigin, const Vector& vecDirection, float flSize, float flSpeed); +void FX_CreateGaussExplosion(const Vector& pos, const Vector& dir, int type); +void FX_GaussTracer(Vector& start, Vector& end, int velocity, bool makeWhiz = true); +void FX_TracerSound(const Vector& start, const Vector& end, int iTracerType); + +void UTIL_GetNormalizedColorTintAndLuminosity(const Vector& color, Vector* tint = NULL, float* luminosity = NULL); + +bool EffectOccluded(const Vector& pos, pixelvis_handle_t* queryHandle = 0); + +class CTeslaInfo +{ +public: + Vector m_vPos; + QAngle m_vAngles; + int m_nEntIndex; + char* m_pszSpriteName; + float m_flBeamWidth; + int m_nBeams; + Vector m_vColor; + float m_flTimeVisible; + float m_flRadius; +}; + +void FX_Tesla(const CTeslaInfo& teslaInfo); + +#include "particle_parse.h" + +class CEffectData +{ +public: + Vector m_vOrigin; + Vector m_vStart; + Vector m_vNormal; + QAngle m_vAngles; + int m_fFlags; + int m_nEntIndex; + float m_flScale; + float m_flMagnitude; + float m_flRadius; + int m_nAttachmentIndex; + short m_nSurfaceProp; + + int m_nMaterial; + int m_nDamageType; + int m_nHitBox; + + unsigned char m_nColor; + + bool m_bCustomColors; + te_tf_particle_effects_colors_t m_CustomColors; + + bool m_bControlPoint1; + te_tf_particle_effects_control_point_t m_ControlPoint1; + +public: + CEffectData() + { + m_vOrigin.Init(); + m_vStart.Init(); + m_vNormal.Init(); + m_vAngles.Init(); + + m_fFlags = 0; + m_nEntIndex = 0; + m_flScale = 1.f; + m_nAttachmentIndex = 0; + m_nSurfaceProp = 0; + + m_flMagnitude = 0.0f; + m_flRadius = 0.0f; + + m_nMaterial = 0; + m_nDamageType = 0; + m_nHitBox = 0; + + m_nColor = 0; + + m_bCustomColors = false; + m_CustomColors.m_vecColor1.Init(1.f, 1.f, 1.f); + m_CustomColors.m_vecColor2.Init(1.f, 1.f, 1.f); + + m_bControlPoint1 = false; + m_ControlPoint1.m_eParticleAttachment = PATTACH_ABSORIGIN; + m_ControlPoint1.m_vecOffset.Init(); + } + + int GetEffectNameIndex() { return m_iEffectName; } + +private: + int m_iEffectName; +}; + + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/game_item_schema.h b/SpyCustom/sdk/game_item_schema.h new file mode 100644 index 0000000..3ffb588 --- /dev/null +++ b/SpyCustom/sdk/game_item_schema.h @@ -0,0 +1,61 @@ +#ifndef GAME_ITEM_SCHEMA_H +#define GAME_ITEM_SCHEMA_H +#ifdef _WIN32 +#pragma once +#endif + +#if defined(TF_CLIENT_DLL) || defined(TF_DLL) || defined(TF_GC_DLL) +class CTFItemSchema; +class CTFItemDefinition; +class CTFItemSystem; + +typedef CTFItemSchema GameItemSchema_t; +typedef CTFItemDefinition GameItemDefinition_t; +typedef CTFItemSystem GameItemSystem_t; + +#include "tf_item_schema.h" +#elif defined( DOTA_CLIENT_DLL ) || defined( DOTA_DLL ) || defined ( DOTA_GC_DLL ) +class CDOTAItemSchema; +class CDOTAItemDefinition; +class CDOTAItemSystem; + +typedef CDOTAItemSchema GameItemSchema_t; +typedef CDOTAItemDefinition GameItemDefinition_t; +typedef CDOTAItemSystem GameItemSystem_t; + +#include "econ/dota_item_schema.h" +#elif defined( PORTAL2 ) || defined( PORTAL2_GC_DLL ) +class CPortal2ItemSchema; +class CPortal2ItemDefinition; +class CPortal2ItemSystem; + +typedef CPortal2ItemSchema GameItemSchema_t; +typedef CPortal2ItemDefinition GameItemDefinition_t; +typedef CPortal2ItemSystem GameItemSystem_t; + +#include "portal2_item_schema.h" +#elif defined( CSTRIKE15 ) || defined( CSTRIKE_GC_DLL ) +class CCStrike15ItemSchema; +class CCStrike15ItemDefinition; +class CCStrike15ItemSystem; + +typedef CCStrike15ItemSchema GameItemSchema_t; +typedef CCStrike15ItemDefinition GameItemDefinition_t; +typedef CCStrike15ItemSystem GameItemSystem_t; + +#include "cstrike15_item_schema.h" +#else +class CEconItemSchema; +class CEconItemDefinition; +class CEconItemSystem; + +typedef CEconItemSchema GameItemSchema_t; +typedef CEconItemDefinition GameItemDefinition_t; +typedef CEconItemSystem GameItemSystem_t; + +#include "econ_item_schema.h" +#endif + +extern GameItemSchema_t* GetItemSchema(); + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/gameconsole.h b/SpyCustom/sdk/gameconsole.h new file mode 100644 index 0000000..907df43 --- /dev/null +++ b/SpyCustom/sdk/gameconsole.h @@ -0,0 +1,42 @@ +#ifndef GAMECONSOLE_H +#define GAMECONSOLE_H +#ifdef _WIN32 +#pragma once +#endif + +#include "IGameConsole.h" + +class CGameConsoleDialog; + +class CGameConsole : public IGameConsole +{ +public: + CGameConsole(); + ~CGameConsole(); + + void Initialize(); + + virtual void Activate(); + virtual void Hide(); + virtual void Clear(); + + void HideImmediately(void); + + virtual bool IsConsoleVisible(); + + void ActivateDelayed(float time); + + void SetParent(int parent); + + void Shutdown(void); + + static void OnCmdCondump(); +private: + + bool m_bInitialized; + CGameConsoleDialog* m_pConsole; +}; + +extern CGameConsole& GameConsole(); + +#endif \ No newline at end of file diff --git a/SpyCustom/sdk/gamestringpool.h b/SpyCustom/sdk/gamestringpool.h new file mode 100644 index 0000000..9d2696c --- /dev/null +++ b/SpyCustom/sdk/gamestringpool.h @@ -0,0 +1,105 @@ +#ifndef GAMESTRINGPOOL_H +#define GAMESTRINGPOOL_H + +#if defined( _WIN32 ) +#pragma once +#endif + +#if !defined( GC ) +class IGameSystem; +#endif + +string_t AllocPooledString(const char* pszValue); +#define AllocPooledStringConstant( pszValue ) AllocPooledString( pszValue ) +string_t FindPooledString(const char* pszValue); +void RemovePooledString(const char* pszValue); + +#define AssertIsValidString( s ) AssertMsg( s == NULL_STRING || s == FindPooledString( STRING(s) ), "Invalid string " #s ); + +#if !defined( GC ) +IGameSystem* GameStringSystem(); +#endif + +class CGameString +{ +public: + CGameString() : + m_iszString(NULL_STRING), m_pszString(NULL), m_iSerial(0) + { + + } + + CGameString(const char* pszString, bool bCopy = false) : + m_iszString(NULL_STRING), m_pszString(NULL), m_iSerial(0) + { + Set(pszString, bCopy); + } + + ~CGameString() + { + if (m_bCopy) + free((void*)m_pszString); + } + + void Set(const char* pszString, bool bCopy = false) + { + if (m_bCopy && m_pszString) + free((void*)m_pszString); + m_iszString = NULL_STRING; + m_pszString = (!bCopy) ? pszString : strdup(pszString); + } + + void SetFastNoCopy(string_t iszString) + { + m_iszString = iszString; + m_iSerial = gm_iSerialNumber; + } + + bool IsSerialNumberOutOfDate(void) const + { + return m_iSerial != gm_iSerialNumber; + } + + string_t Get() const + { + if (m_iszString == NULL_STRING || IsSerialNumberOutOfDate()) + { + if (!m_pszString) + return NULL_STRING; + + m_iszString = AllocPooledString(m_pszString); + m_iSerial = gm_iSerialNumber; + } + + return m_iszString; + } + + operator const char* () const + { + return (m_pszString) ? m_pszString : ""; + } + +#ifndef NO_STRING_T + operator string_t() const + { + return Get(); + } +#endif + + static void IncrementSerialNumber() + { + gm_iSerialNumber++; + } + +private: + mutable string_t m_iszString; + const char* m_pszString; + mutable int m_iSerial; + bool m_bCopy; + + + static int gm_iSerialNumber; + +}; + +#endif \ No newline at end of file