diff --git a/addons/source-python/data/source-python/client/gmod/CBaseClient.ini b/addons/source-python/data/source-python/client/gmod/CBaseClient.ini
new file mode 100644
index 000000000..9b05292dd
--- /dev/null
+++ b/addons/source-python/data/source-python/client/gmod/CBaseClient.ini
@@ -0,0 +1,7 @@
+# ../data/source-python/client/gmod/CBaseClient.ini
+
+[virtual_function]
+ [[set_name]]
+ offset_linux = 56
+ offset_windows = 17
+ arguments = STRING
diff --git a/addons/source-python/data/source-python/effects/gmod/CTEAntlionDust.ini b/addons/source-python/data/source-python/effects/gmod/CTEAntlionDust.ini
new file mode 100644
index 000000000..9779e327e
--- /dev/null
+++ b/addons/source-python/data/source-python/effects/gmod/CTEAntlionDust.ini
@@ -0,0 +1,9 @@
+# ../effects/gmod/CTEAntlionDust.ini
+# Temp Entity Name: AntlionDust
+
+is_spawner_blocked = m_bBlockedSpawner
+angles = m_vecAngles
+
+[origin]
+ name = m_vecOrigin[0]
+ type = Vector
diff --git a/addons/source-python/data/source-python/effects/gmod/CTEConcussiveExplosion.ini b/addons/source-python/data/source-python/effects/gmod/CTEConcussiveExplosion.ini
new file mode 100644
index 000000000..cbf19c334
--- /dev/null
+++ b/addons/source-python/data/source-python/effects/gmod/CTEConcussiveExplosion.ini
@@ -0,0 +1,11 @@
+# ../effects/gmod/CTEConcussiveExplosion.ini
+# Temp Entity Name: ConcussiveExplosion
+
+scale = m_flScale
+magnitude = m_nMagnitude
+radius = m_nRadius
+normal = m_vecNormal
+
+[origin]
+ name = m_vecOrigin[0]
+ type = Vector
diff --git a/addons/source-python/data/source-python/effects/gmod/CTEEffectDispatch.ini b/addons/source-python/data/source-python/effects/gmod/CTEEffectDispatch.ini
new file mode 100644
index 000000000..b947070cf
--- /dev/null
+++ b/addons/source-python/data/source-python/effects/gmod/CTEEffectDispatch.ini
@@ -0,0 +1,43 @@
+# ../effects/gmod/CTEEffectDispatch.ini
+# Temp Entity Name: EffectDispatch
+
+entity_index = m_EffectData.entindex
+particle_attachment = m_EffectData.m_ControlPoint1.m_eParticleAttachment
+primary_color = m_EffectData.m_CustomColors.m_vecColor1
+secondary_color = m_EffectData.m_CustomColors.m_vecColor2
+control_point = m_EffectData.m_bControlPoint1
+has_custom_colors = m_EffectData.m_bCustomColors
+flags = m_EffectData.m_fFlags
+magnitude = m_EffectData.m_flMagnitude
+radius = m_EffectData.m_flRadius
+scale = m_EffectData.m_flScale
+effect_name_index = m_EffectData.m_iEffectName
+attachment_index = m_EffectData.m_nAttachmentIndex
+color = m_EffectData.m_nColor
+damage_type = m_EffectData.m_nDamageType
+hitbox = m_EffectData.m_nHitBox
+material_index = m_EffectData.m_nMaterial
+surface_prop = m_EffectData.m_nSurfaceProp
+angles = m_EffectData.m_vAngles
+normal = m_EffectData.m_vNormal
+allow_override = m_bAllowOverride
+
+[offset]
+ name = m_EffectData.m_ControlPoint1.m_vecOffset[0]
+ type = Vector
+
+[origin]
+ name = m_EffectData.m_vOrigin[0]
+ type = Vector
+
+[start]
+ name = m_EffectData.m_vStart[0]
+ type = Vector
+
+[entity]
+ name = entity_index
+ type = Entity
+
+[material]
+ name = material_index
+ type = Model
diff --git a/addons/source-python/data/source-python/effects/gmod/CTEHL2MPFireBullets.ini b/addons/source-python/data/source-python/effects/gmod/CTEHL2MPFireBullets.ini
new file mode 100644
index 000000000..6ee55701b
--- /dev/null
+++ b/addons/source-python/data/source-python/effects/gmod/CTEHL2MPFireBullets.ini
@@ -0,0 +1,17 @@
+# ../effects/gmod/CTEHL2MPFireBullets.ini
+# Temp Entity Name: Shotgun Shot
+
+do_impacts = m_bDoImpacts
+do_tracers = m_bDoTracers
+spread = m_flSpread
+ammo_id = m_iAmmoID
+player_index = m_iPlayer
+seed = m_iSeed
+shots = m_iShots
+direction = m_vecDir
+origin = m_vecOrigin
+tracer_type = m_TracerType
+
+[player]
+ name = player_index
+ type = Player
diff --git a/addons/source-python/data/source-python/effects/gmod/CTEPhysicsProp.ini b/addons/source-python/data/source-python/effects/gmod/CTEPhysicsProp.ini
new file mode 100644
index 000000000..de8fd119b
--- /dev/null
+++ b/addons/source-python/data/source-python/effects/gmod/CTEPhysicsProp.ini
@@ -0,0 +1,17 @@
+# ../effects/gmod/CTEPhysicProp.ini
+# Temp Entity Name: physicsprop
+
+effects = m_nEffects
+flags = m_nFlags
+model_index = m_nModelIndex
+skin = m_nSkin
+origin = m_vecOrigin
+velocity = m_vecVelocity
+
+[rotation]
+ name = m_angRotation[0]
+ type = Vector
+
+[model]
+ name = model_index
+ type = Model
diff --git a/addons/source-python/data/source-python/effects/gmod/CTEPlayerAnimEvent.ini b/addons/source-python/data/source-python/effects/gmod/CTEPlayerAnimEvent.ini
new file mode 100644
index 000000000..0fe81d290
--- /dev/null
+++ b/addons/source-python/data/source-python/effects/gmod/CTEPlayerAnimEvent.ini
@@ -0,0 +1,6 @@
+# ../effects/gmod/CTEPlayerAnimEvent.ini
+# Temp Entity Name: PlayerAnimEvent
+
+player_handle = m_hPlayer
+event = m_iEvent
+data = m_nData
diff --git a/addons/source-python/data/source-python/entity_output/gmod/CBaseEntityOutput.ini b/addons/source-python/data/source-python/entity_output/gmod/CBaseEntityOutput.ini
new file mode 100644
index 000000000..54217336a
--- /dev/null
+++ b/addons/source-python/data/source-python/entity_output/gmod/CBaseEntityOutput.ini
@@ -0,0 +1,10 @@
+# ../data/source-python/entity_output/gmod/CBaseEntityOutput.ini
+
+binary = server
+
+[function]
+ [[fire_output]]
+ identifier_linux = _ZN17CBaseEntityOutput10FireOutputE9variant_tP11CBaseEntityS2_f
+ identifier_windows = 55 8B EC 81 EC 20 01 00 00 53 56 8B
+ arguments_linux = POINTER, POINTER, POINTER, FLOAT
+ arguments_windows = INT, INT, INT, INT, POINTER, POINTER, POINTER, FLOAT
diff --git a/addons/source-python/data/source-python/memory/gmod/global_pointers.ini b/addons/source-python/data/source-python/memory/gmod/global_pointers.ini
new file mode 100644
index 000000000..366a3992b
--- /dev/null
+++ b/addons/source-python/data/source-python/memory/gmod/global_pointers.ini
@@ -0,0 +1,23 @@
+# ../data/source-python/memory/gmod/global_pointers.ini
+
+[CGlobalEntityList]
+binary = server
+identifier_linux = gEntList
+identifier_windows = 55 8B EC 83 EC 08 56 57 8B 7D 08 6A 00 B9
+offset_windows = 14
+level_windows = 1
+
+[IServer]
+binary = bin/engine
+identifier_linux = sv
+identifier_windows = 55 8B EC 53 56 8B 75 0C 57 85 F6
+offset_windows = 27
+level_windows = 1
+
+[CBaseTempEntity]
+binary = server
+identifier_linux = _ZN15CBaseTempEntity15s_pTempEntitiesE
+identifier_windows = 56 8B 35 2A 2A 2A 2A 85 F6 74 2A EB 2A 8D 49 00 8B 06
+offset_windows = 3
+level_windows = 2
+level_linux = 1
diff --git a/addons/source-python/data/source-python/weapons/scripts/gmod/global_pointers.ini b/addons/source-python/data/source-python/weapons/scripts/gmod/global_pointers.ini
new file mode 100644
index 000000000..98823d945
--- /dev/null
+++ b/addons/source-python/data/source-python/weapons/scripts/gmod/global_pointers.ini
@@ -0,0 +1,7 @@
+# ../data/source-python/weapons/scripts/gmod/global_pointers.ini
+
+[_WeaponDatabase]
+identifier_linux = _ZL20m_WeaponInfoDatabase
+identifier_windows = 55 8B EC 81 EC 88 2A 2A 2A 56 8B 75 10 85 F6 75 07 32 C0 5E
+offset_windows = 37
+level_windows = 1
diff --git a/addons/source-python/packages/source-python/__init__.py b/addons/source-python/packages/source-python/__init__.py
index 6485998eb..85e4dda81 100644
--- a/addons/source-python/packages/source-python/__init__.py
+++ b/addons/source-python/packages/source-python/__init__.py
@@ -29,6 +29,10 @@
# =============================================================================
# >> IMPORTS
# =============================================================================
+# Python Imports
+# Context
+from contextlib import suppress
+
# Source.Python Imports
# Loggers
from loggers import _sp_logger # It's save to import this here
@@ -286,8 +290,9 @@ def remove_entities_listener():
from _core import _sp_plugin
from memory.manager import manager
- manager.get_global_pointer('GlobalEntityList').remove_entity_listener(
- _sp_plugin)
+ with suppress(NameError):
+ manager.get_global_pointer('GlobalEntityList').remove_entity_listener(
+ _sp_plugin)
# =============================================================================
diff --git a/addons/source-python/packages/source-python/listeners/__init__.py b/addons/source-python/packages/source-python/listeners/__init__.py
index bcec7db4a..adf44c631 100644
--- a/addons/source-python/packages/source-python/listeners/__init__.py
+++ b/addons/source-python/packages/source-python/listeners/__init__.py
@@ -540,7 +540,7 @@ def _pre_call_global_change_callbacks(args):
# >> Fix for issue #181.
# ============================================================================
# Get the function name to hook...
-if SOURCE_ENGINE in ('bms', 'orangebox'):
+if SOURCE_ENGINE in ('bms', 'orangebox', 'gmod'):
_hibernation_function_name = 'SetServerHibernation'
elif SOURCE_ENGINE in ('blade', 'csgo', 'l4d2'):
_hibernation_function_name = 'ServerHibernationUpdate'
diff --git a/addons/source-python/packages/source-python/memory/manager.py b/addons/source-python/packages/source-python/memory/manager.py
index 06b0efed7..8d000ecf3 100644
--- a/addons/source-python/packages/source-python/memory/manager.py
+++ b/addons/source-python/packages/source-python/memory/manager.py
@@ -5,11 +5,9 @@
# =============================================================================
# >> IMPORTS
# =============================================================================
-# Site-Package Imports
-# ConfigObj
-from configobj import ConfigObj
-
# Source.Python Imports
+# Core
+from core import GameConfigObj
# Memory
from memory import Convention
from memory import DataType
@@ -294,7 +292,7 @@ def create_pipe(cls_dict):
def create_pipe_from_file(self, f):
"""Create a pipe from a file or URL."""
- return self.create_pipe_from_dict(ConfigObj(f, file_error=True))
+ return self.create_pipe_from_dict(GameConfigObj(f))
def create_pipe_from_dict(self, raw_data):
"""Create a pipe from a dictionary."""
@@ -341,7 +339,7 @@ def pipe_function(
def create_type_from_file(self, type_name, f, bases=(CustomType,)):
"""Create and registers a new type from a file or URL."""
return self.create_type_from_dict(
- type_name, ConfigObj(f, file_error=True), bases)
+ type_name, GameConfigObj(f), bases)
def create_type_from_dict(self, type_name, raw_data, bases=(CustomType,)):
"""Create and registers a new type from a dictionary."""
@@ -697,7 +695,7 @@ def make_function(ptr):
def create_function_typedefs_from_file(self, f):
"""Create function typedefs from a file."""
# Read the data
- raw_data = ConfigObj(f, file_error=True)
+ raw_data = GameConfigObj(f)
# Prepare typedefs
typedefs = parse_data(
@@ -740,7 +738,7 @@ def create_global_pointers_from_file(self, f):
# Parse pointer data
pointers = parse_data(
self,
- ConfigObj(f, file_error=True),
+ GameConfigObj(f),
(
(Key.BINARY, Key.as_str, NO_DEFAULT),
(Key.IDENTIFIER, Key.as_identifier, NO_DEFAULT),
diff --git a/src/core/modules/cvars/gmod/cvars.h b/src/core/modules/cvars/gmod/cvars.h
new file mode 100644
index 000000000..8d0d44feb
--- /dev/null
+++ b/src/core/modules/cvars/gmod/cvars.h
@@ -0,0 +1,48 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2014 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _CVARS_GMOD_H
+#define _CVARS_GMOD_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "icvar.h"
+
+
+//-----------------------------------------------------------------------------
+// ICVar extension class.
+//-----------------------------------------------------------------------------
+class ICVarExt
+{
+public:
+ static ConCommandBase* GetCommands(ICvar* pCvar)
+ {
+ return pCvar->GetCommands();
+ };
+};
+
+#endif // _CVARS_GMOD_H
diff --git a/src/core/modules/effects/gmod/effects_base_wrap.h b/src/core/modules/effects/gmod/effects_base_wrap.h
new file mode 100644
index 000000000..a8e4b3f55
--- /dev/null
+++ b/src/core/modules/effects/gmod/effects_base_wrap.h
@@ -0,0 +1,54 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2012-2015 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _EFFECTS_BASE_WRAP_GMOD_H
+#define _EFFECTS_BASE_WRAP_GMOD_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "game/shared/itempents.h"
+#include "toolframework/itoolentity.h"
+#include "game/server/basetempentity.h"
+
+
+//-----------------------------------------------------------------------------
+// External variables.
+//-----------------------------------------------------------------------------
+extern IServerTools *servertools;
+
+
+//-----------------------------------------------------------------------------
+// Exports CBaseTempEntity.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_temp_entity(T _base, U TempEntity)
+{
+ // Nothing specific to GMod...
+}
+
+
+#endif // _EFFECTS_BASE_WRAP_GMOD_H
diff --git a/src/core/modules/engines/engines_server_wrap.cpp b/src/core/modules/engines/engines_server_wrap.cpp
index e064989ab..5caf322a1 100644
--- a/src/core/modules/engines/engines_server_wrap.cpp
+++ b/src/core/modules/engines/engines_server_wrap.cpp
@@ -565,6 +565,11 @@ static void export_engine_server(scope _server)
args("benchmark_mode")
)
+ .add_property("cluster_count",
+ &IVEngineServer::GetClusterCount,
+ "Returns total number of clusters."
+ )
+
/*
.def("is_split_screen_player",
&IVEngineServer::SetDedicatedServerBenchmarkMode,
@@ -572,11 +577,6 @@ static void export_engine_server(scope _server)
)
*/
- .add_property("cluster_count",
- &IVEngineServer::GetClusterCount,
- "Returns total number of clusters."
- )
-
/*
TODO: Create a wrapper that requires a list or tuple with bbox_t elements
.def("get_all_cluster_bounds",
diff --git a/src/core/modules/engines/gmod/engines.h b/src/core/modules/engines/gmod/engines.h
new file mode 100644
index 000000000..18ecad6b8
--- /dev/null
+++ b/src/core/modules/engines/gmod/engines.h
@@ -0,0 +1,90 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2014 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _ENGINES_GMOD_H
+#define _ENGINES_GMOD_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "engine/IEngineSound.h"
+
+
+//-----------------------------------------------------------------------------
+// IVEngineServer extension class.
+//-----------------------------------------------------------------------------
+class GameIVEngineServerExt
+{
+public:
+ static bool IsMapValid(IVEngineServer* pServer, const char* map_name)
+ {
+ return pServer->IsMapValid(map_name);
+ }
+};
+
+
+//-----------------------------------------------------------------------------
+// IEngineSound extension class.
+//-----------------------------------------------------------------------------
+class IEngineSoundExt
+{
+public:
+ static void EmitSound(IEngineSound* pEngineSound, IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSample,
+ float flVolume, float flAttenuation, int iFlags, int iPitch, const Vector *pOrigin, const Vector *pDirection,
+ tuple origins, bool bUpdatePositions, float soundtime, int speakerentity)
+ {
+ CUtlVector *pUtlVecOrigins = NULL;
+ CUtlVector vecOrigins;
+ if (len(origins) > 0)
+ {
+ pUtlVecOrigins = &vecOrigins;
+ for(int i=0; i < len(origins); i++)
+ {
+ vecOrigins.AddToTail(extract(origins[i]));
+ }
+ }
+
+ pEngineSound->EmitSound(filter, iEntIndex, iChannel, pSample, flVolume, flAttenuation, iFlags, iPitch, 0, pOrigin, pDirection,
+ pUtlVecOrigins, bUpdatePositions, soundtime, speakerentity);
+ }
+
+ static void StopSound(IEngineSound* pEngineSound, int iEntIndex, int iChannel, const char *pSample)
+ {
+ pEngineSound->StopSound(iEntIndex, iChannel, pSample);
+ }
+};
+
+
+//---------------------------------------------------------------------------------
+// IEngineTrace
+//---------------------------------------------------------------------------------
+inline int GetPointContents(const Vector &vecAbsPosition, IHandleEntity** ppEntity)
+{
+ return enginetrace->GetPointContents(vecAbsPosition, ppEntity);
+}
+
+
+#endif // _ENGINES_GMOD_H
diff --git a/src/core/modules/engines/gmod/engines_wrap.h b/src/core/modules/engines/gmod/engines_wrap.h
new file mode 100644
index 000000000..6efb12c11
--- /dev/null
+++ b/src/core/modules/engines/gmod/engines_wrap.h
@@ -0,0 +1,113 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2014 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _ENGINES_WRAP_GMOD_H
+#define _ENGINES_WRAP_GMOD_H
+
+//---------------------------------------------------------------------------------
+// Includes.
+//---------------------------------------------------------------------------------
+#include "eiface.h"
+#include "engine/IEngineSound.h"
+#include "engine/IEngineTrace.h"
+
+
+//---------------------------------------------------------------------------------
+// External variables.
+//---------------------------------------------------------------------------------
+extern IEngineTrace* enginetrace;
+
+
+//---------------------------------------------------------------------------------
+// IVEngineServer visitor function.
+//---------------------------------------------------------------------------------
+template
+T IVEngineServer_Visitor(T cls)
+{
+ cls
+ .add_property("game_server_steamid",
+ make_function(
+ &IVEngineServer::GetGameServerSteamID,
+ reference_existing_object_policy()
+ ),
+ "Returns the SteamID of the game server."
+ )
+
+ .def("server_version",
+ &IVEngineServer::GetServerVersion,
+ "Returns the version of the server."
+ )
+
+ .def("multiplayer_end_game",
+ &IVEngineServer::MultiplayerEndGame,
+ "Matchmaking"
+ )
+
+ .def("create_fake_client_ex",
+ &IVEngineServer::CreateFakeClientEx,
+ reference_existing_object_policy()
+ )
+
+ .add_property("achievement_mgr",
+ make_function(
+ &IVEngineServer::GetAchievementMgr,
+ reference_existing_object_policy()
+ ),
+ &IVEngineServer::SetAchievementMgr,
+ "Return the achievement manager."
+ )
+ ;
+
+ return cls;
+}
+
+
+//---------------------------------------------------------------------------------
+// IEngineSound visitor function.
+//---------------------------------------------------------------------------------
+template
+T IEngineSound_Visitor(T cls)
+{
+ return cls;
+}
+
+
+//-----------------------------------------------------------------------------
+// Exports IServerGameDLL.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_server_game_dll(T _server, U ServerGameDLL)
+{
+ // Methods...
+ ServerGameDLL.def("set_server_hibernation", &IServerGameDLL::SetServerHibernation);
+
+ // Class info...
+ BEGIN_CLASS_INFO(IServerGameDLL)
+ FUNCTION_INFO(SetServerHibernation)
+ END_CLASS_INFO()
+}
+
+#endif // _ENGINES_WRAP_GMOD_H
diff --git a/src/core/modules/entities/blade/entities_constants_wrap.h b/src/core/modules/entities/blade/entities_constants_wrap.h
index fac77a4a8..27c4c72b5 100644
--- a/src/core/modules/entities/blade/entities_constants_wrap.h
+++ b/src/core/modules/entities/blade/entities_constants_wrap.h
@@ -64,6 +64,16 @@ void export_engine_specific_entity_effects(T _constants)
}
+//-----------------------------------------------------------------------------
+// Exports RenderMode_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_render_mode(T _constants, U RenderEffects)
+{
+ // Nothing specific to Blade...
+}
+
+
//-----------------------------------------------------------------------------
// Exports RenderFx_t.
//-----------------------------------------------------------------------------
diff --git a/src/core/modules/entities/bms/entities_constants_wrap.h b/src/core/modules/entities/bms/entities_constants_wrap.h
index 7de3462e2..bd1492c3a 100644
--- a/src/core/modules/entities/bms/entities_constants_wrap.h
+++ b/src/core/modules/entities/bms/entities_constants_wrap.h
@@ -63,6 +63,16 @@ void export_engine_specific_entity_effects(T _constants)
}
+//-----------------------------------------------------------------------------
+// Exports RenderMode_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_render_mode(T _constants, U RenderEffects)
+{
+ // Nothing specific to BMS...
+}
+
+
//-----------------------------------------------------------------------------
// Exports RenderFx_t.
//-----------------------------------------------------------------------------
diff --git a/src/core/modules/entities/csgo/entities_constants_wrap.h b/src/core/modules/entities/csgo/entities_constants_wrap.h
index 1392edbef..9eed272e9 100644
--- a/src/core/modules/entities/csgo/entities_constants_wrap.h
+++ b/src/core/modules/entities/csgo/entities_constants_wrap.h
@@ -67,6 +67,16 @@ void export_engine_specific_entity_effects(T _constants)
}
+//-----------------------------------------------------------------------------
+// Exports RenderMode_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_render_mode(T _constants, U RenderEffects)
+{
+ // Nothing specific to CS:GO...
+}
+
+
//-----------------------------------------------------------------------------
// Exports RenderFx_t.
//-----------------------------------------------------------------------------
diff --git a/src/core/modules/entities/entities_constants_wrap.cpp b/src/core/modules/entities/entities_constants_wrap.cpp
index 0adec6121..4a5147cfc 100644
--- a/src/core/modules/entities/entities_constants_wrap.cpp
+++ b/src/core/modules/entities/entities_constants_wrap.cpp
@@ -291,6 +291,12 @@ void export_render_mode(scope _constants)
RenderMode.value("TRANS_ADD_FRAME_BLEND", kRenderTransAddFrameBlend);
RenderMode.value("WORLD_GLOW", kRenderWorldGlow);
RenderMode.value("NONE", kRenderNone);
+
+ // GMod specific values...
+ NOT_IMPLEMENTED_VALUE(RenderMode_t, "TRANS_ALPHA_ADD");
+
+ // Engine specific stuff...
+ export_engine_specific_render_mode(_constants, RenderMode);
}
diff --git a/src/core/modules/entities/gmod/entities.h b/src/core/modules/entities/gmod/entities.h
new file mode 100644
index 000000000..3f5e5b05d
--- /dev/null
+++ b/src/core/modules/entities/gmod/entities.h
@@ -0,0 +1,76 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2015 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _ENTITIES_GMOD_H
+#define _ENTITIES_GMOD_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "dt_send.h"
+#include "game/shared/ehandle.h"
+#include "isaverestore.h"
+#include "datamap.h"
+#include "game/shared/takedamageinfo.h"
+
+
+//-----------------------------------------------------------------------------
+// CTakeDamageInfo wrapper class.
+//-----------------------------------------------------------------------------
+class TakeDamageInfoWrapper: public TakeDamageInfoBaseWrapper
+{
+public:
+ int get_penetrated()
+ {
+ return m_iPlayerPenetrateCount;
+ }
+
+ void set_penetrated(int iPenetrated)
+ {
+ m_iPlayerPenetrateCount = iPenetrated;
+ }
+};
+
+
+//-----------------------------------------------------------------------------
+// CTakeDamageInfo extension class.
+//-----------------------------------------------------------------------------
+class TakeDamageInfoExt
+{
+public:
+ static int get_penetrated(CTakeDamageInfo *pTakeDamageInfo)
+ {
+ return ((TakeDamageInfoWrapper *)pTakeDamageInfo)->get_penetrated();
+ }
+
+ static void set_penetrated(CTakeDamageInfo *pTakeDamageInfo, int iPenetrated)
+ {
+ ((TakeDamageInfoWrapper *)pTakeDamageInfo)->set_penetrated(iPenetrated);
+ }
+};
+
+
+#endif // _ENTITIES_GMOD_H
diff --git a/src/core/modules/entities/gmod/entities_constants_wrap.h b/src/core/modules/entities/gmod/entities_constants_wrap.h
new file mode 100644
index 000000000..57464acca
--- /dev/null
+++ b/src/core/modules/entities/gmod/entities_constants_wrap.h
@@ -0,0 +1,104 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2015 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _ENTITIES_CONSTANTS_GMOD_WRAP_H
+#define _ENTITIES_CONSTANTS_GMOD_WRAP_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "utilities/wrap_macros.h"
+
+
+//-----------------------------------------------------------------------------
+// Exports damage types.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_damage_types(T _constants)
+{
+ // Nothing specific to GMod...
+}
+
+
+//-----------------------------------------------------------------------------
+// Exports SolidFlags_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_solid_flags(T _constants, U SolidFlags)
+{
+ // Nothing specific to GMod...
+}
+
+
+//-----------------------------------------------------------------------------
+// Exports entity effects.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_entity_effects(T _constants)
+{
+ // Nothing specific to GMod...
+}
+
+
+//-----------------------------------------------------------------------------
+// Exports RenderMode_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_render_mode(T _constants, U RenderEffects)
+{
+ RenderEffects.value("TRANS_ALPHA_ADD", kRenderTransAlphaAdd);
+}
+
+
+//-----------------------------------------------------------------------------
+// Exports RenderFx_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_render_effects(T _constants, U RenderEffects)
+{
+ RenderEffects.value("DISTORT", kRenderFxDistort);
+ RenderEffects.value("HOLOGRAM", kRenderFxHologram);
+ RenderEffects.value("EXPLODE", kRenderFxExplode);
+ RenderEffects.value("CLAMP_MIN_SCALE", kRenderFxClampMinScale);
+ RenderEffects.value("ENV_RAIN", kRenderFxEnvRain);
+ RenderEffects.value("ENV_SNOW", kRenderFxEnvSnow);
+ RenderEffects.value("SPOTLIGHT", kRenderFxSpotlight);
+ RenderEffects.value("RAGDOLL", kRenderFxRagdoll);
+ RenderEffects.value("PULSE_FAST_WIDER", kRenderFxPulseFastWider);
+}
+
+
+//-----------------------------------------------------------------------------
+// Exports Collision_Group_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_collision_group(T _constants, U CollisionGroup)
+{
+ // Nothing specific to GMod...
+}
+
+
+#endif // _ENTITIES_CONSTANTS_GMOD_WRAP_H
diff --git a/src/core/modules/entities/gmod/entities_datamaps.h b/src/core/modules/entities/gmod/entities_datamaps.h
new file mode 100644
index 000000000..8ff22baa4
--- /dev/null
+++ b/src/core/modules/entities/gmod/entities_datamaps.h
@@ -0,0 +1,54 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2014 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _ENTITIES_DATAMAP_GMOD_H
+#define _ENTITIES_DATAMAP_GMOD_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "datamap.h"
+
+
+//-----------------------------------------------------------------------------
+// typedescription_t extension class.
+//-----------------------------------------------------------------------------
+class TypeDescriptionExt
+{
+public:
+ static int get_offset(const typedescription_t& pTypeDesc)
+ {
+ return pTypeDesc.fieldOffset[TD_OFFSET_NORMAL];
+ }
+
+ static int get_packed_offset(const typedescription_t& pTypeDesc)
+ {
+ return pTypeDesc.fieldOffset[TD_OFFSET_PACKED];
+ }
+};
+
+
+#endif // _ENTITIES_DATAMAP_GMOD_WRAP_H
diff --git a/src/core/modules/entities/gmod/entities_datamaps_wrap.h b/src/core/modules/entities/gmod/entities_datamaps_wrap.h
new file mode 100644
index 000000000..9cc365253
--- /dev/null
+++ b/src/core/modules/entities/gmod/entities_datamaps_wrap.h
@@ -0,0 +1,68 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2014 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _ENTITIES_DATAMAPS_GMOD_H
+#define _ENTITIES_DATAMAPS_GMOD_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "entities_datamaps.h"
+
+
+//-----------------------------------------------------------------------------
+// Exports datamap_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_datamap(T _datamaps, U DataMap)
+{
+ DataMap.def_readonly("chains_validated", &datamap_t::chains_validated);
+ DataMap.def_readonly("packed_offsets_computed", &datamap_t::packed_offsets_computed);
+ DataMap.def_readonly("packed_size", &datamap_t::packed_size);
+}
+
+
+//-----------------------------------------------------------------------------
+// Exports typedescription_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_type_description(T _datamaps, U TypeDescription)
+{
+ TypeDescription.add_property("packed_offset", &TypeDescriptionExt::get_packed_offset) ;
+}
+
+
+//-----------------------------------------------------------------------------
+// Exports fieldtype_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_field_types(T _datamaps, U FieldTypes)
+{
+ // Nothing specific to GMod...
+}
+
+
+#endif // _ENTITIES_DATAMAPS_GMOD_H
diff --git a/src/core/modules/entities/gmod/entities_factories_wrap.h b/src/core/modules/entities/gmod/entities_factories_wrap.h
new file mode 100644
index 000000000..22e4f2532
--- /dev/null
+++ b/src/core/modules/entities/gmod/entities_factories_wrap.h
@@ -0,0 +1,56 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2014 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _ENTITIES_FACTORIES_WRAP_GMOD_H
+#define _ENTITIES_FACTORIES_WRAP_GMOD_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "utilities/wrap_macros.h"
+#include "toolframework/itoolentity.h"
+#include "utilities/conversions.h"
+#include "modules/memory/memory_tools.h"
+
+
+//-----------------------------------------------------------------------------
+// External variables.
+//-----------------------------------------------------------------------------
+extern IServerTools *servertools;
+
+
+//-----------------------------------------------------------------------------
+// Exports CEntityFactoryDictionary.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_entity_factory_dictionary(T _factories, U EntityFactoryDictionary)
+{
+ // Singleton...
+ _factories.attr("factory_dictionary") = object(ptr((CEntityFactoryDictionary *)servertools->GetEntityFactoryDictionary()));
+}
+
+
+#endif // _ENTITIES_FACTORIES_WRAP_GMOD_H
diff --git a/src/core/modules/entities/gmod/entities_props.h b/src/core/modules/entities/gmod/entities_props.h
new file mode 100644
index 000000000..0e0535b21
--- /dev/null
+++ b/src/core/modules/entities/gmod/entities_props.h
@@ -0,0 +1,32 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2015 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _ENTITIES_PROPS_GMOD_H
+#define _ENTITIES_PROPS_GMOD_H
+
+// Nothing specific to GMod...
+
+#endif // _ENTITIES_PROPS_GMOD_H
diff --git a/src/core/modules/entities/gmod/entities_props_wrap.h b/src/core/modules/entities/gmod/entities_props_wrap.h
new file mode 100644
index 000000000..067e2a92c
--- /dev/null
+++ b/src/core/modules/entities/gmod/entities_props_wrap.h
@@ -0,0 +1,79 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2015 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _ENTITIES_PROPS_WRAP_GMOD_H
+#define _ENTITIES_PROPS_WRAP_GMOD_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "dt_send.h"
+#include "server_class.h"
+#include "entities_props_wrap.h"
+
+
+//-----------------------------------------------------------------------------
+// Expose ServerClass.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_server_class(T _props, U ServerClass_)
+{
+ // Properties...
+ ServerClass_.def_readonly("name", &ServerClass::m_pNetworkName);
+}
+
+
+//-----------------------------------------------------------------------------
+// Expose SendProp.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_send_prop(T _props, U SendProp_)
+{
+ // Nothing specific to GMod...
+}
+
+
+//-----------------------------------------------------------------------------
+// Expose SendPropType.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_send_prop_types(T _props, U SendPropType_)
+{
+ // Nothing specific to GMod...
+}
+
+
+//-----------------------------------------------------------------------------
+// Expose SendPropVariant.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_send_prop_variant(T _props, U SendPropVariant)
+{
+ // Nothing specific to GMod...
+}
+
+
+#endif // _ENTITIES_PROPS_WRAP_GMOD_H
diff --git a/src/core/modules/entities/gmod/entities_wrap.h b/src/core/modules/entities/gmod/entities_wrap.h
new file mode 100644
index 000000000..f57dfaea7
--- /dev/null
+++ b/src/core/modules/entities/gmod/entities_wrap.h
@@ -0,0 +1,48 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2014 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _ENTITIES_WRAP_GMOD_H
+#define _ENTITIES_WRAP_GMOD_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "entities.h"
+
+
+//-----------------------------------------------------------------------------
+// Exports CTakeDamageInfo.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_take_damage_info(T _entities, U TakeDamageInfo)
+{
+ TakeDamageInfo.add_property("penetrated", &TakeDamageInfoExt::get_penetrated,
+ &TakeDamageInfoExt::set_penetrated
+ );
+}
+
+
+#endif // _ENTITIES_WRAP_GMOD_H
diff --git a/src/core/modules/entities/l4d2/entities_constants_wrap.h b/src/core/modules/entities/l4d2/entities_constants_wrap.h
index 8c7075f3c..a98127e6c 100644
--- a/src/core/modules/entities/l4d2/entities_constants_wrap.h
+++ b/src/core/modules/entities/l4d2/entities_constants_wrap.h
@@ -63,6 +63,16 @@ void export_engine_specific_entity_effects(T _constants)
}
+//-----------------------------------------------------------------------------
+// Exports RenderMode_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_render_mode(T _constants, U RenderEffects)
+{
+ // Nothing specific to Left4Dead2...
+}
+
+
//-----------------------------------------------------------------------------
// Exports RenderFx_t.
//-----------------------------------------------------------------------------
diff --git a/src/core/modules/entities/orangebox/entities_constants_wrap.h b/src/core/modules/entities/orangebox/entities_constants_wrap.h
index 591f3fa72..77c120ecf 100644
--- a/src/core/modules/entities/orangebox/entities_constants_wrap.h
+++ b/src/core/modules/entities/orangebox/entities_constants_wrap.h
@@ -66,6 +66,16 @@ void export_engine_specific_entity_effects(T _constants)
}
+//-----------------------------------------------------------------------------
+// Exports RenderMode_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_render_mode(T _constants, U RenderEffects)
+{
+ // Nothing specific to OrangeBox...
+}
+
+
//-----------------------------------------------------------------------------
// Exports RenderFx_t.
//-----------------------------------------------------------------------------
diff --git a/src/core/modules/globals/gmod/globals_wrap.h b/src/core/modules/globals/gmod/globals_wrap.h
new file mode 100644
index 000000000..8261f9c8a
--- /dev/null
+++ b/src/core/modules/globals/gmod/globals_wrap.h
@@ -0,0 +1,56 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2012 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _GLOBALS_WRAP_GMOD_H
+#define _GLOBALS_WRAP_GMOD_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "edict.h"
+
+
+//-----------------------------------------------------------------------------
+// CGlobalVarsBase visitor method.
+//-----------------------------------------------------------------------------
+template
+T GlobalsBase_Visitor(T cls)
+{
+ return cls;
+}
+
+
+//-----------------------------------------------------------------------------
+// CGlobalVars visitor method.
+//-----------------------------------------------------------------------------
+template
+T Globals_Visitor(T cls)
+{
+ return cls;
+}
+
+
+#endif // _GLOBALS_WRAP_GMOD_H
diff --git a/src/core/modules/players/gmod/players_constants_wrap.h b/src/core/modules/players/gmod/players_constants_wrap.h
new file mode 100644
index 000000000..d2c249b7d
--- /dev/null
+++ b/src/core/modules/players/gmod/players_constants_wrap.h
@@ -0,0 +1,56 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2015 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _PLAYERS_CONSTANTS_GMOD_WRAP_H
+#define _PLAYERS_CONSTANTS_GMOD_WRAP_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "utilities/wrap_macros.h"
+
+
+//-----------------------------------------------------------------------------
+// Exports DamageTypes.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_player_buttons(T _constants)
+{
+ // Nothing specific to GMod...
+}
+
+
+//-----------------------------------------------------------------------------
+// Exports HideHudFlags
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_hide_hud_flags(T _constants)
+{
+ // Nothing specific to GMod...
+}
+
+
+#endif // _PLAYERS_CONSTANTS_GMOD_WRAP_H
diff --git a/src/core/modules/players/gmod/players_wrap.h b/src/core/modules/players/gmod/players_wrap.h
new file mode 100644
index 000000000..1bfd680de
--- /dev/null
+++ b/src/core/modules/players/gmod/players_wrap.h
@@ -0,0 +1,39 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2012-2015 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _PLAYERS_WRAP_GMOD_H
+#define _PLAYERS_WRAP_GMOD_H
+
+
+//-----------------------------------------------------------------------------
+// IPlayerInfo extension class
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_user_cmd(scope _players, T UserCmd)
+{
+}
+
+#endif // _PLAYERS_WRAP_GMOD_H
diff --git a/src/core/modules/steam/gmod/steam_wrap.h b/src/core/modules/steam/gmod/steam_wrap.h
new file mode 100644
index 000000000..b4431f6e6
--- /dev/null
+++ b/src/core/modules/steam/gmod/steam_wrap.h
@@ -0,0 +1,47 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2015 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _STEAM_WRAP_GMOD_H
+#define _STEAM_WRAP_GMOD_H
+
+template
+void export_engine_specific_steamid(scope _steam, T SteamID)
+{
+ // Nothing specific to GMod...
+}
+
+template
+void export_engine_specific_universe(scope _steam, T Universe)
+{
+}
+
+template
+void export_engine_specific_account_type(scope _steam, T AccountType)
+{
+ // Nothing specific to GMod...
+}
+
+#endif // _STEAM_WRAP_GMOD_H
diff --git a/src/core/modules/weapons/gmod/weapons_constants_wrap.h b/src/core/modules/weapons/gmod/weapons_constants_wrap.h
new file mode 100644
index 000000000..b16054c71
--- /dev/null
+++ b/src/core/modules/weapons/gmod/weapons_constants_wrap.h
@@ -0,0 +1,40 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2015 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _WEAPONS_CONSTANTS_GMOD_WRAP_H
+#define _WEAPONS_CONSTANTS_GMOD_WRAP_H
+
+//-----------------------------------------------------------------------------
+// Exports WeaponSound_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_weapon_sound(T _constants, U WeaponSound)
+{
+ // Nothing specific to GMod...
+}
+
+
+#endif // _WEAPONS_CONSTANTS_GMOD_WRAP_H
diff --git a/src/core/modules/weapons/gmod/weapons_scripts.h b/src/core/modules/weapons/gmod/weapons_scripts.h
new file mode 100644
index 000000000..62281716c
--- /dev/null
+++ b/src/core/modules/weapons/gmod/weapons_scripts.h
@@ -0,0 +1,61 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2016 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _WEAPONS_SCRIPTS_GMOD_H
+#define _WEAPONS_SCRIPTS_GMOD_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "datamap.h"
+#include "game/shared/weapon_parse.h"
+#include "tier1/utldict.h"
+#include "utilities/wrap_macros.h"
+
+
+//-----------------------------------------------------------------------------
+// WeaponDataBase_t declaration.
+//-----------------------------------------------------------------------------
+typedef CUtlDict WeaponDataBase_t;
+
+
+//-----------------------------------------------------------------------------
+// WeaponDataBase_t extension class.
+//-----------------------------------------------------------------------------
+class WeaponDataBaseExt
+{
+public:
+ static CPointer *_find(WeaponDataBase_t *pWeaponDataBase, WEAPON_FILE_INFO_HANDLE uiIndex)
+ {
+ if (uiIndex >= pWeaponDataBase->Count())
+ BOOST_RAISE_EXCEPTION(PyExc_IndexError, "Index out of range.");
+
+ return new CPointer((unsigned long)(void *)pWeaponDataBase->Element(uiIndex));
+ }
+};
+
+
+#endif // _WEAPONS_SCRIPTS_GMOD_H
diff --git a/src/core/modules/weapons/gmod/weapons_scripts_wrap.h b/src/core/modules/weapons/gmod/weapons_scripts_wrap.h
new file mode 100644
index 000000000..7792745b2
--- /dev/null
+++ b/src/core/modules/weapons/gmod/weapons_scripts_wrap.h
@@ -0,0 +1,54 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2015 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef _WEAPONS_SCRIPTS_GMOD_WRAP_H
+#define _WEAPONS_SCRIPTS_GMOD_WRAP_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "weapons_scripts.h"
+
+
+//-----------------------------------------------------------------------------
+// Exports WeaponDataBase_t.
+//-----------------------------------------------------------------------------
+template
+void export_engine_specific_weapon_database(T _scripts)
+{
+ class_ _WeaponDatabase("_WeaponDatabase", no_init);
+
+ // Methods...
+ _WeaponDatabase.def("_find", &WeaponDataBaseExt::_find, manage_new_object_policy());
+
+ // Properties...
+ _WeaponDatabase.add_property("_length", &WeaponDataBase_t::Count);
+
+ // Add memory tools...
+ _WeaponDatabase ADD_MEM_TOOLS(WeaponDataBase_t);
+}
+
+#endif // _WEAPONS_SCRIPTS_GMOD_WRAP_H
diff --git a/src/core/patches/gmod/patches.cpp b/src/core/patches/gmod/patches.cpp
new file mode 100644
index 000000000..1df653297
--- /dev/null
+++ b/src/core/patches/gmod/patches.cpp
@@ -0,0 +1,30 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2012-2015 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#include "utilities/baseentity.h"
+#ifndef PATCH_NETWORK_HANDLE_BASE_DEFINITION
+#error "We need the CNetworkHandle definition..."
+#endif
diff --git a/src/core/patches/gmod/undefined_symbols.h b/src/core/patches/gmod/undefined_symbols.h
new file mode 100644
index 000000000..65f1cf0f8
--- /dev/null
+++ b/src/core/patches/gmod/undefined_symbols.h
@@ -0,0 +1,62 @@
+/**
+* =============================================================================
+* Source Python
+* Copyright (C) 2012-2015 Source Python Development Team. All rights reserved.
+* =============================================================================
+*
+* This program is free software; you can redistribute it and/or modify it under
+* the terms of the GNU General Public License, version 3.0, as published by the
+* Free Software Foundation.
+*
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+*
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see .
+*
+* As a special exception, the Source Python Team gives you permission
+* to link the code of this program (as well as its derivative works) to
+* "Half-Life 2," the "Source Engine," and any Game MODs that run on software
+* by the Valve Corporation. You must obey the GNU General Public License in
+* all respects for all other code used. Additionally, the Source.Python
+* Development Team grants this exception to all derivative works.
+*/
+
+#ifndef UNDEFINED_SYMBOLS_GMOD_H
+#define UNDEFINED_SYMBOLS_GMOD_H
+
+//-----------------------------------------------------------------------------
+// Includes.
+//-----------------------------------------------------------------------------
+#include "dt_send.h"
+#include "game/shared/ehandle.h"
+#include "isaverestore.h"
+#include "datamap.h"
+#include "game/shared/takedamageinfo.h"
+
+
+//-----------------------------------------------------------------------------
+// CTakeDamageInfo constructor declaration.
+//-----------------------------------------------------------------------------
+CTakeDamageInfo::CTakeDamageInfo()
+{
+ m_hInflictor = NULL;
+ m_hAttacker = NULL;
+ m_hWeapon = NULL;
+ m_flDamage = 0.0f;
+ m_flBaseDamage = BASEDAMAGE_NOT_SPECIFIED;
+ m_bitsDamageType = 0;
+ m_iDamageCustom = 0;
+ m_flMaxDamage = 0.0f;
+ m_vecDamageForce = vec3_origin;
+ m_vecDamagePosition = vec3_origin;
+ m_vecReportedPosition = vec3_origin;
+ m_iDamageStats;
+ m_iAmmoType = -1;
+ m_iDamagedOtherPlayers = 0;
+ m_iPlayerPenetrateCount = 0;
+}
+
+#endif // _UNDEFINED_SYMBOLS_GMOD_H
diff --git a/src/core/sp_main.cpp b/src/core/sp_main.cpp
index 7f1003813..a2ca160ce 100644
--- a/src/core/sp_main.cpp
+++ b/src/core/sp_main.cpp
@@ -182,7 +182,7 @@ bool GetInterfaces( InterfaceHelper_t* pInterfaceList, CreateInterfaceFn factory
//-----------------------------------------------------------------------------
// Server output hook.
//-----------------------------------------------------------------------------
-#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS)
+#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS) || defined(ENGINE_GMOD)
SpewRetval_t SP_SpewOutput( SpewType_t spewType, const tchar *pMsg )
{
extern CListenerManager* GetOnServerOutputListenerManager();
@@ -264,7 +264,7 @@ CSourcePython::CSourcePython()
m_iClientCommandIndex = 0;
m_pOldMDLCacheNotifier = NULL;
-#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS)
+#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS) || defined(ENGINE_GMOD)
m_pOldSpewOutputFunc = NULL;
#endif
}
@@ -321,7 +321,7 @@ bool CSourcePython::Load( CreateInterfaceFn interfaceFactory, CreateInterfaceFn
return false;
}
-#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS)
+#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS) || defined(ENGINE_GMOD)
DevMsg(1, MSG_PREFIX "Retrieving old output function...\n");
m_pOldSpewOutputFunc = GetSpewOutputFunc();
@@ -364,7 +364,7 @@ void CSourcePython::Unload( void )
DevMsg(1, MSG_PREFIX "Unhooking all functions...\n");
GetHookManager()->UnhookAllFunctions();
-#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS)
+#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS) || defined(ENGINE_GMOD)
if (m_pOldSpewOutputFunc)
{
DevMsg(1, MSG_PREFIX "Restoring old output function...\n");
diff --git a/src/core/sp_main.h b/src/core/sp_main.h
index 8f6eb3c83..a8bda1b5b 100644
--- a/src/core/sp_main.h
+++ b/src/core/sp_main.h
@@ -127,7 +127,7 @@ class CSourcePython: public IServerPluginCallbacks, public IEntityListener, publ
int m_iClientCommandIndex;
IMDLCacheNotify* m_pOldMDLCacheNotifier;
-#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS)
+#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS) || defined(ENGINE_GMOD)
SpewOutputFunc_t m_pOldSpewOutputFunc;
#endif
};
diff --git a/src/core/utilities/conversions/edict_from.cpp b/src/core/utilities/conversions/edict_from.cpp
index 0d1add842..b44f9e5be 100644
--- a/src/core/utilities/conversions/edict_from.cpp
+++ b/src/core/utilities/conversions/edict_from.cpp
@@ -39,7 +39,7 @@ bool EdictFromIndex( unsigned int iEntityIndex, edict_t*& output )
return false;
edict_t* pEdict;
-#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS)
+#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS) || defined(ENGINE_GMOD)
pEdict = engine->PEntityOfEntIndex(iEntityIndex);
#else
pEdict = (edict_t *)(gpGlobals->pEdicts + iEntityIndex);
diff --git a/src/core/utilities/conversions/index_from.cpp b/src/core/utilities/conversions/index_from.cpp
index 04689acfe..08da7ba1c 100644
--- a/src/core/utilities/conversions/index_from.cpp
+++ b/src/core/utilities/conversions/index_from.cpp
@@ -39,7 +39,7 @@ bool IndexFromEdict( edict_t *pEdict, unsigned int& output )
return false;
int iEntityIndex;
-#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS)
+#if defined(ENGINE_ORANGEBOX) || defined(ENGINE_BMS) || defined(ENGINE_GMOD)
iEntityIndex = engine->IndexOfEdict(pEdict);
#else
iEntityIndex = pEdict - gpGlobals->pEdicts;
diff --git a/src/makefiles/branch/gmod.cmake b/src/makefiles/branch/gmod.cmake
new file mode 100644
index 000000000..aefcbed68
--- /dev/null
+++ b/src/makefiles/branch/gmod.cmake
@@ -0,0 +1,10 @@
+# ------------------------------------------------------------------
+# File: src/makefiles/branch/gmod.cmake
+# Purpose: This is the CMake file for the gmod branch.
+# ------------------------------------------------------------------
+
+# ------------------------------------------------------------------
+# Set the engine version.
+# ------------------------------------------------------------------
+Set(SOURCE_ENGINE "gmod")
+add_definitions(-DENGINE_GMOD)
\ No newline at end of file
diff --git a/src/makefiles/linux/linux.base.cmake b/src/makefiles/linux/linux.base.cmake
index 96ce0a492..d80874c62 100644
--- a/src/makefiles/linux/linux.base.cmake
+++ b/src/makefiles/linux/linux.base.cmake
@@ -63,7 +63,7 @@ EndIf()
# ------------------------------------------------------------------
# Game specific library hacks.
# ------------------------------------------------------------------
-If(SOURCE_ENGINE MATCHES "orangebox" OR SOURCE_ENGINE MATCHES "l4d2")
+If(SOURCE_ENGINE MATCHES "orangebox" OR SOURCE_ENGINE MATCHES "l4d2" OR SOURCE_ENGINE MATCHES "gmod")
# Orangebox has all the tier libraries.
Set(SOURCEPYTHON_LINK_LIBRARIES
"${SOURCEPYTHON_LINK_LIBRARIES}"
@@ -96,7 +96,7 @@ EndIf()
# General definitions
Set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LINUX -DPOSIX -DLINUX -DGNUC -DCOMPILER_GCC")
-if(SOURCE_ENGINE MATCHES "orangebox" OR SOURCE_ENGINE MATCHES "bms")
+if(SOURCE_ENGINE MATCHES "orangebox" OR SOURCE_ENGINE MATCHES "bms" OR SOURCE_ENGINE MATCHES "gmod")
Set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_MALLOC_OVERRIDE")
Endif()
diff --git a/src/patches/gmod/lib/public/mathlib.lib b/src/patches/gmod/lib/public/mathlib.lib
new file mode 100644
index 000000000..453b4affb
Binary files /dev/null and b/src/patches/gmod/lib/public/mathlib.lib differ
diff --git a/src/patches/gmod/public/networkvar.h b/src/patches/gmod/public/networkvar.h
new file mode 100644
index 000000000..95ddd05ec
--- /dev/null
+++ b/src/patches/gmod/public/networkvar.h
@@ -0,0 +1,768 @@
+//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================//
+
+#ifndef NETWORKVAR_H
+#define NETWORKVAR_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+
+#include "tier0/dbg.h"
+#include "convar.h"
+
+#if defined( CLIENT_DLL ) || defined( GAME_DLL )
+ #include "basehandle.h"
+#endif
+
+#ifdef _MSC_VER
+#pragma warning( disable : 4284 ) // warning C4284: return type for 'CNetworkVarT::operator ->' is 'int *' (ie; not a UDT or reference to a UDT. Will produce errors if applied using infix notation)
+#endif
+
+#define MyOffsetOf( type, var ) ( (int)&((type*)0)->var )
+
+#ifdef _DEBUG
+ extern bool g_bUseNetworkVars;
+ #define CHECK_USENETWORKVARS if(g_bUseNetworkVars)
+#else
+ #define CHECK_USENETWORKVARS // don't check for g_bUseNetworkVars
+#endif
+
+
+
+inline int InternalCheckDeclareClass( const char *pClassName, const char *pClassNameMatch, void *pTestPtr, void *pBasePtr )
+{
+ // This makes sure that casting from ThisClass to BaseClass works right. You'll get a compiler error if it doesn't
+ // work at all, and you'll get a runtime error if you use multiple inheritance.
+ Assert( pTestPtr == pBasePtr );
+
+ // This is triggered by IMPLEMENT_SERVER_CLASS. It does DLLClassName::CheckDeclareClass( #DLLClassName ).
+ // If they didn't do a DECLARE_CLASS in DLLClassName, then it'll be calling its base class's version
+ // and the class names won't match.
+ Assert( (void*)pClassName == (void*)pClassNameMatch );
+ return 0;
+}
+
+
+template
+inline int CheckDeclareClass_Access( T *, const char *pShouldBe )
+{
+ return T::CheckDeclareClass( pShouldBe );
+}
+
+#ifndef _STATIC_LINKED
+#ifdef _MSC_VER
+#if defined(_DEBUG) && (_MSC_VER > 1200 )
+ #define VALIDATE_DECLARE_CLASS 1
+#endif
+#endif
+#endif
+
+#ifdef VALIDATE_DECLARE_CLASS
+
+ #define DECLARE_CLASS( className, baseClassName ) \
+ typedef baseClassName BaseClass; \
+ typedef className ThisClass; \
+ template friend int CheckDeclareClass_Access(T *, const char *pShouldBe); \
+ static int CheckDeclareClass( const char *pShouldBe ) \
+ { \
+ InternalCheckDeclareClass( pShouldBe, #className, (ThisClass*)0xFFFFF, (BaseClass*)(ThisClass*)0xFFFFF ); \
+ return CheckDeclareClass_Access( (BaseClass *)NULL, #baseClassName ); \
+ }
+
+ // Use this macro when you have a base class, but it's part of a library that doesn't use network vars
+ // or any of the things that use ThisClass or BaseClass.
+ #define DECLARE_CLASS_GAMEROOT( className, baseClassName ) \
+ typedef baseClassName BaseClass; \
+ typedef className ThisClass; \
+ template friend int CheckDeclareClass_Access(T *, const char *pShouldBe); \
+ static int CheckDeclareClass( const char *pShouldBe ) \
+ { \
+ return InternalCheckDeclareClass( pShouldBe, #className, (ThisClass*)0xFFFFF, (BaseClass*)(ThisClass*)0xFFFFF ); \
+ }
+
+ // Deprecated macro formerly used to work around VC++98 bug
+ #define DECLARE_CLASS_NOFRIEND( className, baseClassName ) \
+ DECLARE_CLASS( className, baseClassName )
+
+ #define DECLARE_CLASS_NOBASE( className ) \
+ typedef className ThisClass; \
+ template friend int CheckDeclareClass_Access(T *, const char *pShouldBe); \
+ static int CheckDeclareClass( const char *pShouldBe ) \
+ { \
+ return InternalCheckDeclareClass( pShouldBe, #className, 0, 0 ); \
+ }
+
+#else
+ #define DECLARE_CLASS( className, baseClassName ) \
+ typedef baseClassName BaseClass; \
+ typedef className ThisClass;
+
+ #define DECLARE_CLASS_GAMEROOT( className, baseClassName ) DECLARE_CLASS( className, baseClassName )
+ #define DECLARE_CLASS_NOFRIEND( className, baseClassName ) DECLARE_CLASS( className, baseClassName )
+
+ #define DECLARE_CLASS_NOBASE( className ) typedef className ThisClass;
+#endif
+
+
+
+
+// All classes that contain CNetworkVars need a NetworkStateChanged() function. If the class is not an entity,
+// it needs to forward the call to the entity it's in. These macros can help.
+
+ // These macros setup an entity pointer in your class. Use IMPLEMENT_NETWORKVAR_CHAIN before you do
+ // anything inside the class itself.
+ class CBaseEntity;
+ class CAutoInitEntPtr
+ {
+ public:
+ CAutoInitEntPtr()
+ {
+ m_pEnt = NULL;
+ }
+ CBaseEntity *m_pEnt;
+ };
+
+ //TODO: Currently, these don't get the benefit of tracking changes to individual vars.
+ // Would be nice if they did.
+ #define DECLARE_NETWORKVAR_CHAIN() \
+ CAutoInitEntPtr __m_pChainEntity; \
+ void NetworkStateChanged() { CHECK_USENETWORKVARS __m_pChainEntity.m_pEnt->NetworkStateChanged(); } \
+ void NetworkStateChanged( void *pVar ) { CHECK_USENETWORKVARS __m_pChainEntity.m_pEnt->NetworkStateChanged(); }
+
+ #define IMPLEMENT_NETWORKVAR_CHAIN( varName ) \
+ (varName)->__m_pChainEntity.m_pEnt = this;
+
+
+
+// Use this macro when you want to embed a structure inside your entity and have CNetworkVars in it.
+template< class T >
+static inline void DispatchNetworkStateChanged( T *pObj )
+{
+ CHECK_USENETWORKVARS pObj->NetworkStateChanged();
+}
+template< class T >
+static inline void DispatchNetworkStateChanged( T *pObj, void *pVar )
+{
+ CHECK_USENETWORKVARS pObj->NetworkStateChanged( pVar );
+}
+
+
+#define DECLARE_EMBEDDED_NETWORKVAR() \
+ template friend int ServerClassInit(T *); \
+ template friend int ClientClassInit(T *); \
+ virtual void NetworkStateChanged() {} virtual void NetworkStateChanged( void *pProp ) {}
+
+// NOTE: Assignment operator is disabled because it doesn't call copy constructors of scalar types within the aggregate, so they are not marked changed
+#define CNetworkVarEmbedded( type, name ) \
+ class NetworkVar_##name; \
+ friend class NetworkVar_##name; \
+ static inline int GetOffset_##name() { return MyOffsetOf(ThisClass,name); } \
+ typedef ThisClass ThisClass_##name; \
+ class NetworkVar_##name : public type \
+ { \
+ template< class T > NetworkVar_##name& operator=( const T &val ) { *((type*)this) = val; return *this; } \
+ public: \
+ void CopyFrom( const type &src ) { *((type *)this) = src; NetworkStateChanged(); } \
+ virtual void NetworkStateChanged() \
+ { \
+ DispatchNetworkStateChanged( (ThisClass_##name*)( ((char*)this) - GetOffset_##name() ) ); \
+ } \
+ virtual void NetworkStateChanged( void *pVar ) \
+ { \
+ DispatchNetworkStateChanged( (ThisClass_##name*)( ((char*)this) - GetOffset_##name() ), pVar ); \
+ } \
+ }; \
+ NetworkVar_##name name;
+
+
+
+template< class Type, class Changer >
+class CNetworkVarBase
+{
+public:
+ template< class C >
+ const Type& operator=( const C &val )
+ {
+ return Set( ( const Type )val );
+ }
+
+ template< class C >
+ const Type& operator=( const CNetworkVarBase< C, Changer > &val )
+ {
+ return Set( ( const Type )val.m_Value );
+ }
+
+ const Type& Set( const Type &val )
+ {
+ if ( memcmp( &m_Value, &val, sizeof(Type) ) )
+ {
+ NetworkStateChanged();
+ m_Value = val;
+ }
+ return m_Value;
+ }
+
+ Type& GetForModify()
+ {
+ NetworkStateChanged();
+ return m_Value;
+ }
+
+ template< class C >
+ const Type& operator+=( const C &val )
+ {
+ return Set( m_Value + ( const Type )val );
+ }
+
+ template< class C >
+ const Type& operator-=( const C &val )
+ {
+ return Set( m_Value - ( const Type )val );
+ }
+
+ template< class C >
+ const Type& operator/=( const C &val )
+ {
+ return Set( m_Value / ( const Type )val );
+ }
+
+ template< class C >
+ const Type& operator*=( const C &val )
+ {
+ return Set( m_Value * ( const Type )val );
+ }
+
+ template< class C >
+ const Type& operator^=( const C &val )
+ {
+ return Set( m_Value ^ ( const Type )val );
+ }
+
+ template< class C >
+ const Type& operator|=( const C &val )
+ {
+ return Set( m_Value | ( const Type )val );
+ }
+
+ const Type& operator++()
+ {
+ return (*this += 1);
+ }
+
+ Type operator--()
+ {
+ return (*this -= 1);
+ }
+
+ Type operator++( int ) // postfix version..
+ {
+ Type val = m_Value;
+ (*this += 1);
+ return val;
+ }
+
+ Type operator--( int ) // postfix version..
+ {
+ Type val = m_Value;
+ (*this -= 1);
+ return val;
+ }
+
+ // For some reason the compiler only generates type conversion warnings for this operator when used like
+ // CNetworkVarBase = 0x1
+ // (it warns about converting from an int to an unsigned char).
+ template< class C >
+ const Type& operator&=( const C &val )
+ {
+ return Set( m_Value & ( const Type )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;
+
+protected:
+ inline void NetworkStateChanged()
+ {
+ Changer::NetworkStateChanged( this );
+ }
+};
+
+
+template< class Type, class Changer >
+class CNetworkColor32Base : public CNetworkVarBase< Type, Changer >
+{
+public:
+ inline void Init( byte rVal, byte gVal, byte bVal )
+ {
+ SetR( rVal );
+ SetG( gVal );
+ SetB( bVal );
+ }
+ inline void Init( byte rVal, byte gVal, byte bVal, byte aVal )
+ {
+ SetR( rVal );
+ SetG( gVal );
+ SetB( bVal );
+ SetA( aVal );
+ }
+
+ const Type& operator=( const Type &val )
+ {
+ return Set( val );
+ }
+
+ const Type& operator=( const CNetworkColor32Base &val )
+ {
+ return CNetworkVarBase::Set( val.m_Value );
+ }
+
+ inline byte GetR() const { return CNetworkColor32Base::m_Value.r; }
+ inline byte GetG() const { return CNetworkColor32Base::m_Value.g; }
+ inline byte GetB() const { return CNetworkColor32Base::m_Value.b; }
+ inline byte GetA() const { return CNetworkColor32Base::m_Value.a; }
+ inline void SetR( byte val ) { SetVal( CNetworkColor32Base::m_Value.r, val ); }
+ inline void SetG( byte val ) { SetVal( CNetworkColor32Base::m_Value.g, val ); }
+ inline void SetB( byte val ) { SetVal( CNetworkColor32Base::m_Value.b, val ); }
+ inline void SetA( byte val ) { SetVal( CNetworkColor32Base::m_Value.a, val ); }
+
+protected:
+ inline void SetVal( byte &out, const byte &in )
+ {
+ if ( out != in )
+ {
+ this->NetworkStateChanged();
+ out = in;
+ }
+ }
+};
+
+
+// Network vector wrapper.
+template< class Type, class Changer >
+class CNetworkVectorBase : public CNetworkVarBase< Type, Changer >
+{
+public:
+ inline void Init( float ix=0, float iy=0, float iz=0 )
+ {
+ SetX( ix );
+ SetY( iy );
+ SetZ( iz );
+ }
+
+ const Type& operator=( const Type &val )
+ {
+ return CNetworkVarBase< Type, Changer >::Set( val );
+ }
+
+ const Type& operator=( const CNetworkVectorBase &val )
+ {
+ return CNetworkVarBase::Set( val.m_Value );
+ }
+
+ inline float GetX() const { return CNetworkVectorBase::m_Value.x; }
+ inline float GetY() const { return CNetworkVectorBase::m_Value.y; }
+ inline float GetZ() const { return CNetworkVectorBase::m_Value.z; }
+ inline float operator[]( int i ) const { return CNetworkVectorBase::m_Value[i]; }
+
+ inline void SetX( float val ) { DetectChange( CNetworkVectorBase::m_Value.x, val ); }
+ inline void SetY( float val ) { DetectChange( CNetworkVectorBase::m_Value.y, val ); }
+ inline void SetZ( float val ) { DetectChange( CNetworkVectorBase::m_Value.z, val ); }
+ inline void Set( int i, float val ) { DetectChange( CNetworkVectorBase::m_Value[i], val ); }
+
+ bool operator==( const Type &val ) const
+ {
+ return CNetworkVectorBase::m_Value == (Type)val;
+ }
+
+ bool operator!=( const Type &val ) const
+ {
+ return CNetworkVectorBase::m_Value != (Type)val;
+ }
+
+ const Type operator+( const Type &val ) const
+ {
+ return CNetworkVectorBase::m_Value + val;
+ }
+
+ const Type operator-( const Type &val ) const
+ {
+ return CNetworkVectorBase::m_Value - val;
+ }
+
+ const Type operator*( const Type &val ) const
+ {
+ return CNetworkVectorBase::m_Value * val;
+ }
+
+ const Type& operator*=( float val )
+ {
+ return CNetworkVarBase< Type, Changer >::Set( CNetworkVectorBase::m_Value * val );
+ }
+
+ const Type operator*( float val ) const
+ {
+ return CNetworkVectorBase::m_Value * val;
+ }
+
+ const Type operator/( const Type &val ) const
+ {
+ return CNetworkVectorBase::m_Value / val;
+ }
+
+private:
+ inline void DetectChange( float &out, float in )
+ {
+ if ( out != in )
+ {
+ this->NetworkStateChanged();
+ out = in;
+ }
+ }
+};
+
+
+// Network vector wrapper.
+template< class Type, class Changer >
+class CNetworkQuaternionBase : public CNetworkVarBase< Type, Changer >
+{
+public:
+ inline void Init( float ix=0, float iy=0, float iz=0, float iw = 0 )
+ {
+ SetX( ix );
+ SetY( iy );
+ SetZ( iz );
+ SetZ( iw );
+ }
+
+ const Type& operator=( const Type &val )
+ {
+ return CNetworkVarBase< Type, Changer >::Set( val );
+ }
+
+ const Type& operator=( const CNetworkQuaternionBase &val )
+ {
+ return CNetworkVarBase::Set( val.m_Value );
+ }
+
+ inline float GetX() const { return CNetworkQuaternionBase::m_Value.x; }
+ inline float GetY() const { return CNetworkQuaternionBase::m_Value.y; }
+ inline float GetZ() const { return CNetworkQuaternionBase::m_Value.z; }
+ inline float GetW() const { return CNetworkQuaternionBase::m_Value.w; }
+ inline float operator[]( int i ) const { return CNetworkQuaternionBase::m_Value[i]; }
+
+ inline void SetX( float val ) { DetectChange( CNetworkQuaternionBase::m_Value.x, val ); }
+ inline void SetY( float val ) { DetectChange( CNetworkQuaternionBase::m_Value.y, val ); }
+ inline void SetZ( float val ) { DetectChange( CNetworkQuaternionBase::m_Value.z, val ); }
+ inline void SetW( float val ) { DetectChange( CNetworkQuaternionBase::m_Value.w, val ); }
+ inline void Set( int i, float val ) { DetectChange( CNetworkQuaternionBase::m_Value[i], val ); }
+
+ bool operator==( const Type &val ) const
+ {
+ return CNetworkQuaternionBase::m_Value == (Type)val;
+ }
+
+ bool operator!=( const Type &val ) const
+ {
+ return CNetworkQuaternionBase::m_Value != (Type)val;
+ }
+
+ const Type operator+( const Type &val ) const
+ {
+ return CNetworkQuaternionBase::m_Value + val;
+ }
+
+ const Type operator-( const Type &val ) const
+ {
+ return CNetworkQuaternionBase::m_Value - val;
+ }
+
+ const Type operator*( const Type &val ) const
+ {
+ return CNetworkQuaternionBase::m_Value * val;
+ }
+
+ const Type& operator*=( float val )
+ {
+ return CNetworkQuaternionBase< Type, Changer >::Set( CNetworkQuaternionBase::m_Value * val );
+ }
+
+ const Type operator*( float val ) const
+ {
+ return CNetworkQuaternionBase::m_Value * val;
+ }
+
+ const Type operator/( const Type &val ) const
+ {
+ return CNetworkQuaternionBase::m_Value / val;
+ }
+
+private:
+ inline void DetectChange( float &out, float in )
+ {
+ if ( out != in )
+ {
+ this->NetworkStateChanged();
+ out = in;
+ }
+ }
+};
+
+#define PATCH_NETWORK_HANDLE_BASE_DEFINITION
+// Network ehandle wrapper.
+#if 1
+ template< class Type, class Changer >
+ class CNetworkHandleBase : public CNetworkVarBase< CBaseHandle, Changer >
+ {
+ public:
+ const Type* operator=( const Type *val )
+ {
+ return Set( val );
+ }
+
+ const Type& operator=( const CNetworkHandleBase &val )
+ {
+ const CBaseHandle &handle = CNetworkVarBase::Set( val.m_Value );
+ return *(const Type*)handle.Get();
+ }
+
+ bool operator !() const
+ {
+ return !CNetworkHandleBase::m_Value.Get();
+ }
+
+ operator Type*() const
+ {
+ return static_cast< Type* >( CNetworkHandleBase::m_Value.Get() );
+ }
+
+ const Type* Set( const Type *val )
+ {
+ if ( CNetworkHandleBase::m_Value != val )
+ {
+ this->NetworkStateChanged();
+ CNetworkHandleBase::m_Value = val;
+ }
+ return val;
+ }
+
+ Type* Get() const
+ {
+ return static_cast< Type* >( CNetworkHandleBase::m_Value.Get() );
+ }
+
+ Type* operator->() const
+ {
+ return static_cast< Type* >( CNetworkHandleBase::m_Value.Get() );
+ }
+
+ bool operator==( const Type *val ) const
+ {
+ return CNetworkHandleBase::m_Value == val;
+ }
+
+ bool operator!=( const Type *val ) const
+ {
+ return CNetworkHandleBase::m_Value != val;
+ }
+ };
+
+
+
+ #define CNetworkHandle( type, name ) CNetworkHandleInternal( type, name, NetworkStateChanged )
+
+ #define CNetworkHandleInternal( type, name, stateChangedFn ) \
+ NETWORK_VAR_START( type, name ) \
+ NETWORK_VAR_END( type, name, CNetworkHandleBase, stateChangedFn )
+#endif
+
+
+// Use this macro to define a network variable.
+#define CNetworkVar( type, name ) \
+ NETWORK_VAR_START( type, name ) \
+ NETWORK_VAR_END( type, name, CNetworkVarBase, NetworkStateChanged )
+
+
+// Use this macro when you have a base class with a variable, and it doesn't have that variable in a SendTable,
+// but a derived class does. Then, the entity is only flagged as changed when the variable is changed in
+// an entity that wants to transmit the variable.
+ #define CNetworkVarForDerived( type, name ) \
+ virtual void NetworkStateChanged_##name() {} \
+ virtual void NetworkStateChanged_##name( void *pVar ) {} \
+ NETWORK_VAR_START( type, name ) \
+ NETWORK_VAR_END( type, name, CNetworkVarBase, NetworkStateChanged_##name )
+
+ #define CNetworkVectorForDerived( name ) \
+ virtual void NetworkStateChanged_##name() {} \
+ virtual void NetworkStateChanged_##name( void *pVar ) {} \
+ CNetworkVectorInternal( Vector, name, NetworkStateChanged_##name )
+
+ #define CNetworkHandleForDerived( type, name ) \
+ virtual void NetworkStateChanged_##name() {} \
+ virtual void NetworkStateChanged_##name( void *pVar ) {} \
+ CNetworkHandleInternal( type, name, NetworkStateChanged_##name )
+
+ #define CNetworkArrayForDerived( type, name, count ) \
+ virtual void NetworkStateChanged_##name() {} \
+ virtual void NetworkStateChanged_##name( void *pVar ) {} \
+ CNetworkArrayInternal( type, name, count, NetworkStateChanged_##name )
+
+ #define IMPLEMENT_NETWORK_VAR_FOR_DERIVED( name ) \
+ virtual void NetworkStateChanged_##name() { CHECK_USENETWORKVARS NetworkStateChanged(); } \
+ virtual void NetworkStateChanged_##name( void *pVar ) { CHECK_USENETWORKVARS NetworkStateChanged( pVar ); }
+
+
+// This virtualizes the change detection on the variable, but it is ON by default.
+// Use this when you have a base class in which MOST of its derived classes use this variable
+// in their SendTables, but there are a couple that don't (and they
+// can use DISABLE_NETWORK_VAR_FOR_DERIVED).
+ #define CNetworkVarForDerived_OnByDefault( type, name ) \
+ virtual void NetworkStateChanged_##name() { CHECK_USENETWORKVARS NetworkStateChanged(); } \
+ virtual void NetworkStateChanged_##name( void *pVar ) { CHECK_USENETWORKVARS NetworkStateChanged( pVar ); } \
+ NETWORK_VAR_START( type, name ) \
+ NETWORK_VAR_END( type, name, CNetworkVarBase, NetworkStateChanged_##name )
+
+ #define DISABLE_NETWORK_VAR_FOR_DERIVED( name ) \
+ virtual void NetworkStateChanged_##name() {} \
+ virtual void NetworkStateChanged_##name( void *pVar ) {}
+
+
+
+// Vectors + some convenient helper functions.
+#define CNetworkVector( name ) CNetworkVectorInternal( Vector, name, NetworkStateChanged )
+#define CNetworkQAngle( name ) CNetworkVectorInternal( QAngle, name, NetworkStateChanged )
+
+#define CNetworkVectorInternal( type, name, stateChangedFn ) \
+ NETWORK_VAR_START( type, name ) \
+ NETWORK_VAR_END( type, name, CNetworkVectorBase, stateChangedFn )
+
+#define CNetworkQuaternion( name ) \
+ NETWORK_VAR_START( Quaternion, name ) \
+ NETWORK_VAR_END( Quaternion, name, CNetworkQuaternionBase, NetworkStateChanged )
+
+// Helper for color32's. Contains GetR(), SetR(), etc.. functions.
+#define CNetworkColor32( name ) \
+ NETWORK_VAR_START( color32, name ) \
+ NETWORK_VAR_END( color32, name, CNetworkColor32Base, NetworkStateChanged )
+
+
+#define CNetworkString( name, length ) \
+ class NetworkVar_##name; \
+ friend class NetworkVar_##name; \
+ typedef ThisClass MakeANetworkVar_##name; \
+ class NetworkVar_##name \
+ { \
+ public: \
+ operator const char*() const { return m_Value; } \
+ const char* Get() const { return m_Value; } \
+ char* GetForModify() \
+ { \
+ NetworkStateChanged(); \
+ return m_Value; \
+ } \
+ protected: \
+ inline void NetworkStateChanged() \
+ { \
+ CHECK_USENETWORKVARS ((ThisClass*)(((char*)this) - MyOffsetOf(ThisClass,name)))->NetworkStateChanged(); \
+ } \
+ private: \
+ char m_Value[length]; \
+ }; \
+ NetworkVar_##name name;
+
+
+
+
+// Use this to define networked arrays.
+// You can access elements for reading with operator[], and you can set elements with the Set() function.
+#define CNetworkArrayInternal( type, name, count, stateChangedFn ) \
+ class NetworkVar_##name; \
+ friend class NetworkVar_##name; \
+ typedef ThisClass MakeANetworkVar_##name; \
+ class NetworkVar_##name \
+ { \
+ public: \
+ template friend int ServerClassInit(T *); \
+ template friend datamap_t *DataMapInit(T *); \
+ const type& operator[]( int i ) const \
+ { \
+ return Get( i ); \
+ } \
+ \
+ const type& Get( int i ) const \
+ { \
+ Assert( i >= 0 && i < count ); \
+ return m_Value[i]; \
+ } \
+ \
+ type& GetForModify( int i ) \
+ { \
+ Assert( i >= 0 && i < count ); \
+ NetworkStateChanged( i ); \
+ return m_Value[i]; \
+ } \
+ \
+ void Set( int i, const type &val ) \
+ { \
+ Assert( i >= 0 && i < count ); \
+ if( memcmp( &m_Value[i], &val, sizeof(type) ) ) \
+ { \
+ NetworkStateChanged( i ); \
+ m_Value[i] = val; \
+ } \
+ } \
+ const type* Base() const { return m_Value; } \
+ int Count() const { return count; } \
+ protected: \
+ inline void NetworkStateChanged( int index ) \
+ { \
+ CHECK_USENETWORKVARS ((ThisClass*)(((char*)this) - MyOffsetOf(ThisClass,name)))->stateChangedFn( &m_Value[index] ); \
+ } \
+ type m_Value[count]; \
+ }; \
+ NetworkVar_##name name;
+
+
+#define CNetworkArray( type, name, count ) CNetworkArrayInternal( type, name, count, NetworkStateChanged )
+
+
+// Internal macros used in definitions of network vars.
+#define NETWORK_VAR_START( type, name ) \
+ class NetworkVar_##name; \
+ friend class NetworkVar_##name; \
+ typedef ThisClass MakeANetworkVar_##name; \
+ class NetworkVar_##name \
+ { \
+ public: \
+ template friend int ServerClassInit(T *);
+
+
+#define NETWORK_VAR_END( type, name, base, stateChangedFn ) \
+ public: \
+ static inline void NetworkStateChanged( void *ptr ) \
+ { \
+ CHECK_USENETWORKVARS ((ThisClass*)(((char*)ptr) - MyOffsetOf(ThisClass,name)))->stateChangedFn( ptr ); \
+ } \
+ }; \
+ base< type, NetworkVar_##name > name;
+
+
+
+#endif // NETWORKVAR_H