Skip to content

Commit cf8547c

Browse files
committed
Add support for hl2sdk-mock.
1 parent 4bdc218 commit cf8547c

File tree

6 files changed

+26
-4
lines changed

6 files changed

+26
-4
lines changed

AMBuildScript

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ Source2 = {
3737
'windows': ['x86', 'x86_64'],
3838
'linux': ['x86_64'],
3939
}
40+
Mock = {
41+
'windows': ['x86', 'x86_64'],
42+
'linux': ['x86', 'x86_64'],
43+
'mac': ['x86_64']
44+
}
4045

4146
PossibleSDKs = {
4247
'episode1': SDK('HL2SDK', '2.ep1', '1', 'EPISODEONE', WinLinux, 'episode1'),
@@ -61,6 +66,7 @@ PossibleSDKs = {
6166
'doi': SDK('HL2SDKDOI', '2.doi', '20', 'DOI', WinLinuxMac, 'doi'),
6267
'contagion': SDK('HL2SDKCONTAGION', '2.contagion', '14', 'CONTAGION', WinOnly, 'contagion'),
6368
'bms': SDK('HL2SDKBMS', '2.bms', '10', 'BMS', WinLinux, 'bms'),
69+
'mock': SDK('HL2SDK-MOCK', '2.mock', '999', 'MOCK', Mock, 'mock'),
6470
}
6571

6672
def ResolveEnvPath(env, folder):
@@ -434,10 +440,13 @@ class MMSConfig(object):
434440
lib_folder = os.path.join(sdk.path, 'lib', 'mac')
435441

436442
if compiler.target.platform in ['linux', 'mac']:
437-
if sdk.name in ['sdk2013', 'bms'] or compiler.target.arch == 'x86_64':
438-
compiler.postlink += [os.path.join(lib_folder, 'tier1.a')]
443+
if sdk.name in ['sdk2013', 'bms', 'mock'] or compiler.target.arch == 'x86_64':
444+
tier1 = os.path.join(lib_folder, 'tier1.a')
439445
else:
440-
compiler.postlink += [os.path.join(lib_folder, 'tier1_i486.a')]
446+
tier1 = os.path.join(lib_folder, 'tier1_i486.a')
447+
if sdk.name == 'mock' and compiler.target.platform == 'linux':
448+
compiler.linkflags += ['-Wl,-z,origin']
449+
compiler.postlink += [tier1]
441450

442451
if sdk.name in ['blade', 'insurgency', 'doi', 'csgo', 'dota']:
443452
if compiler.target.arch == 'x86_64':
@@ -456,7 +465,7 @@ class MMSConfig(object):
456465
compiler.linkflags[0:0] = ['-lm']
457466
if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'bms', 'nucleardawn', 'l4d2', 'insurgency', 'doi']:
458467
dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so']
459-
elif compiler.target.arch == 'x86_64' and sdk.name in ['csgo', 'blade']:
468+
elif compiler.target.arch == 'x86_64' and sdk.name in ['csgo', 'blade', 'mock']:
460469
dynamic_libs = ['libtier0_client.so', 'libvstdlib_client.so']
461470
elif sdk.name in ['l4d', 'blade', 'insurgency', 'doi', 'csgo', 'dota']:
462471
dynamic_libs = ['libtier0.so', 'libvstdlib.so']

core/ISmmPluginExt.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#define SOURCE_ENGINE_CONTAGION 22 /**< Contagion */
6161
#define SOURCE_ENGINE_BMS 23 /**< Black Mesa Multiplayer */
6262
#define SOURCE_ENGINE_DOI 24 /**< Day of Infamy */
63+
#define SOURCE_ENGINE_MOCK 999 /**< Mock source engine */
6364

6465
#define METAMOD_PLAPI_VERSION 16 /**< Version of this header file */
6566
#define METAMOD_PLAPI_NAME "ISmmPlugin" /**< Name of the plugin interface */

core/provider/provider_ep2.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,8 @@ int BaseProvider::DetermineSourceEngine()
540540
return SOURCE_ENGINE_BMS;
541541
#elif SOURCE_ENGINE == SE_EPISODEONE
542542
return g_bOriginalEngine ? SOURCE_ENGINE_ORIGINAL : SOURCE_ENGINE_EPISODEONE;
543+
#elif SOURCE_ENGINE == SE_MOCK
544+
return SOURCE_ENGINE_MOCK;
543545
#else
544546
#error "SOURCE_ENGINE not defined to a known value"
545547
#endif
@@ -671,6 +673,8 @@ const char *BaseProvider::GetEngineDescription() const
671673
{
672674
return "Episode 1 (2004)";
673675
}
676+
#elif SOURCE_ENGINE == SE_MOCK
677+
return "Mock";
674678
#else
675679
#error "SOURCE_ENGINE not defined to a known value"
676680
#endif

loader/loader.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static const char *backend_names[] =
9191
"2.contagion",
9292
"2.bms",
9393
"2.doi",
94+
"2.mock",
9495
};
9596

9697
#if defined _WIN32
@@ -425,6 +426,10 @@ mm_DetermineBackend(QueryValveInterface engineFactory, QueryValveInterface serve
425426
{
426427
return MMBackend_HL2DM;
427428
}
429+
else if (strcmp(game_name, ".") == 0 && engineFactory("MOCK_ENGINE", NULL))
430+
{
431+
return MMBackend_Mock;
432+
}
428433
else
429434
{
430435
return MMBackend_SDK2013;

loader/loader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ enum MetamodBackend
104104
MMBackend_BMS,
105105
MMBackend_DOI,
106106

107+
MMBackend_Mock,
107108
MMBackend_UNKNOWN
108109
};
109110

loader/serverplugin.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ class ServerPlugin
9191
mm_GetGameName(game_name, sizeof(game_name));
9292

9393
mm_backend = mm_DetermineBackend(engineFactory, gsFactory, game_name);
94+
if (mm_backend == MMBackend_Mock)
95+
strcpy(game_name, "mock");
9496
}
9597

9698
if (mm_backend == MMBackend_UNKNOWN)

0 commit comments

Comments
 (0)