Skip to content

Commit

Permalink
Add chat commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ws committed Nov 10, 2023
1 parent 0b29f38 commit 7e16b64
Show file tree
Hide file tree
Showing 22 changed files with 1,429 additions and 71 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
metamod/.idea
metamod/build
metamod/cmake-build-debug
59 changes: 31 additions & 28 deletions metamod/AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def ResolveEnvPath(env, folder):
head, tail = os.path.split(head)
return None

def Normalize(path):
def Normalize(path):
return os.path.abspath(os.path.normpath(path))

class MMSPluginConfig(object):
Expand Down Expand Up @@ -181,25 +181,25 @@ class MMSPluginConfig(object):

if len(self.sdks) < 1 and len(sdk_list):
raise Exception('No SDKs were found, nothing to build.')

if len(self.sdks) > 1:
raise Exception('Only one sdk at a time is supported, for multi-sdk approach use loader based solution.')
if builder.options.mms_path:
self.mms_root = builder.options.mms_path
else:

if builder.options.mms_path:
self.mms_root = builder.options.mms_path
else:
self.mms_root = ResolveEnvPath('MMSOURCE20', 'mmsource-2.0')
if not self.mms_root:
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE112', 'mmsource-1.12')
if not self.mms_root:
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE111', 'mmsource-1.11')
if not self.mms_root:
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10')
if not self.mms_root:
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'metamod-source')
if not self.mms_root:
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'mmsource-central')
if not self.mms_root or not os.path.isdir(self.mms_root):
if not self.mms_root or not os.path.isdir(self.mms_root):
raise Exception('Could not find a source copy of Metamod:Source')
self.mms_root = Normalize(self.mms_root)

Expand Down Expand Up @@ -239,19 +239,19 @@ class MMSPluginConfig(object):
if cxx.version == 'apple-clang-6.0' or cxx.version == 'clang-3.4':
cxx.cxxflags += ['-std=c++1y']
else:
cxx.cxxflags += ['-std=c++14']
cxx.cxxflags += ['--std=c++2a', '-Wno-error']
if (cxx.version >= 'gcc-4.0') or cxx.family == 'clang':
cxx.cflags += ['-fvisibility=hidden']
cxx.cxxflags += ['-fvisibility-inlines-hidden']
cxx.cxxflags += [
'-fno-exceptions',
'-fno-rtti',
#'-fno-rtti',
'-fno-threadsafe-statics',
'-Wno-non-virtual-dtor',
'-Wno-overloaded-virtual',
'-Wno-overloaded-virtual'
]
if (cxx.version >= 'gcc-4.7' or cxx.family == 'clang'):
cxx.cxxflags += ['-Wno-delete-non-virtual-dtor']
cxx.cxxflags += ['-Wno-delete-non-virtual-dtor', '-std=c++2a']
if cxx.family == 'gcc':
cxx.cflags += ['-mfpmath=sse']
if cxx.family == 'clang':
Expand All @@ -264,7 +264,7 @@ class MMSPluginConfig(object):
cxx.cxxflags += ['-Wno-deprecated-register']
else:
cxx.cxxflags += ['-Wno-deprecated']

# Work around SDK warnings.
if cxx.version >= 'clang-10.0' or cxx.version >= 'apple-clang-12.0':
cxx.cflags += [
Expand All @@ -274,10 +274,11 @@ class MMSPluginConfig(object):

elif cxx.like('msvc'):
if builder.options.debug == '1':
cxx.cflags += ['/MTd']
cxx.cflags += ['/MDd']
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
else:
cxx.cflags += ['/MT']
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
cxx.defines += [
'_CRT_SECURE_NO_DEPRECATE',
'_CRT_SECURE_NO_WARNINGS',
Expand All @@ -288,7 +289,7 @@ class MMSPluginConfig(object):
'/Zi',
]
cxx.cxxflags += ['/TP']

cxx.linkflags += [
'/SUBSYSTEM:WINDOWS',
'kernel32.lib',
Expand Down Expand Up @@ -316,7 +317,7 @@ class MMSPluginConfig(object):

# Debugging
if builder.options.debug == '1':
cxx.defines += ['DEBUG', '_DEBUG']
cxx.defines += ['DEBUG', '_DEBUG', '_ITERATOR_DEBUG_LEVEL=0']
if cxx.behavior == 'gcc':
cxx.cflags += ['-g3']
elif cxx.behavior == 'msvc':
Expand Down Expand Up @@ -354,7 +355,7 @@ class MMSPluginConfig(object):
'-lc++',
]
elif cxx.target.platform == 'windows':
cxx.defines += ['WIN32', '_WINDOWS']
cxx.defines += ['WIN32', '_WINDOWS', 'SUBHOOK_STATIC']

# Finish up.
# Custom defines here
Expand All @@ -366,7 +367,7 @@ class MMSPluginConfig(object):
compiler = cxx.clone()
mms_core_path = os.path.join(self.mms_root, 'core')
compiler.cxxincludes += [
os.path.join(mms_core_path),
os.path.join(mms_core_path),
os.path.join(mms_core_path, 'sourcehook'),
os.path.join(context.currentSourcePath),
]
Expand All @@ -385,6 +386,8 @@ class MMSPluginConfig(object):
paths.append(['public', 'game', 'server'])
paths.append(['game', 'shared'])
paths.append(['common'])
paths.append(['public', 'entity2'])
paths.append(['game', 'server'])
compiler.defines += ['SOURCE_ENGINE=' + sdk.code]

if sdk.name in ['sdk2013', 'bms', 'pvkii'] and compiler.like('gcc'):
Expand All @@ -400,16 +403,16 @@ class MMSPluginConfig(object):
compiler.defines += ['COMPILER_MSVC32']
elif compiler.target.arch == 'x86_64':
compiler.defines += ['COMPILER_MSVC64']

if compiler.version >= 1900:
compiler.linkflags += ['legacy_stdio_definitions.lib']
else:
compiler.defines += ['COMPILER_GCC']

if compiler.target.arch == 'x86_64':
compiler.defines += ['X64BITS', 'PLATFORM_64BITS']

if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'bms', 'tf2', 'l4d', 'nucleardawn', 'l4d2', 'dota', 'cs2', 'pvkii']:
if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'bms', 'tf2', 'l4d', 'nucleardawn', 'l4d2', 'pvkii']:
if compiler.target.platform in ['linux', 'mac']:
compiler.defines += ['NO_HOOK_MALLOC', 'NO_MALLOC_OVERRIDE']

Expand All @@ -434,7 +437,7 @@ class MMSPluginConfig(object):

def HL2Library(self, context, compiler, name, sdk):
compiler = self.HL2Compiler(context, compiler, sdk)

if compiler.target.platform == 'linux':
if sdk.name == 'episode1':
lib_folder = os.path.join(sdk.path, 'linux_sdk')
Expand Down Expand Up @@ -466,7 +469,7 @@ class MMSPluginConfig(object):
compiler.postlink += [os.path.join(lib_folder, 'interfaces.a')]
else:
compiler.postlink += [os.path.join(lib_folder, 'interfaces_i486.a')]

if sdk.name == 'bms':
compiler.postlink += [os.path.join(lib_folder, 'mathlib.a')]

Expand Down Expand Up @@ -525,4 +528,4 @@ BuildScripts = [
'PackageScript',
]

builder.Build(BuildScripts, { 'MMSPlugin': MMSPlugin })
builder.Build(BuildScripts, { 'MMSPlugin': MMSPlugin })
26 changes: 22 additions & 4 deletions metamod/AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,33 @@ for sdk_name in MMSPlugin.sdks:

binary = MMSPlugin.HL2Library(builder, cxx, MMSPlugin.plugin_name, sdk)

binary.compiler.cxxincludes += [
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'include'),
]

if binary.compiler.target.platform == 'linux':
binary.compiler.postlink += [
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'libfunchook.a'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'libdistorm.a'),
]
elif binary.compiler.target.platform == 'windows':
binary.compiler.postlink += [
os.path.join('psapi.lib'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'funchook.lib'),
os.path.join(builder.sourcePath, 'vendor', 'funchook', 'lib', 'distorm.lib'),
]

binary.sources += [
'./src/wst.cpp',
'src/wst.cpp',
'src/core/schemasystem.cpp'
]

if sdk_name in ['dota', 'cs2']:
binary.sources += [
os.path.join(sdk.path, 'tier1', 'convar.cpp'),
os.path.join(sdk.path, 'public', 'tier0', 'memoverride.cpp'),
]
os.path.join(sdk.path, 'public', 'tier0', 'memoverride.cpp'),
os.path.join(sdk.path, 'tier1', 'convar.cpp')
]


if cxx.target.arch == 'x86':
binary.sources += ['sourcehook/sourcehook_hookmangen.cpp']
Expand Down
38 changes: 38 additions & 0 deletions metamod/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
cmake_minimum_required(VERSION 3.0)
project(wst)

include_directories(
hl2sdk
hl2sdk/common
hl2sdk/game/shared
hl2sdk/game/server
hl2sdk/public
hl2sdk/public/engine
hl2sdk/public/mathlib
hl2sdk/public/tier0
hl2sdk/public/tier1
hl2sdk/public/entity2
hl2sdk/public/game/server
metamod-source/core
metamod-source/core/sourcehook
vendor/funchook/include
)

add_executable(wst
src/wst.cpp
src/wst.h
src/core/framework.h
src/core/module.h
src/core/virtual.h
src/core/schemasystem.cpp
src/core/schemasystem.h
src/core/cbaseentity.h
)

# Dummy target to integrate custom build script
add_custom_target(MetamodBuild ALL
COMMAND PowerShell.exe -File ${CMAKE_SOURCE_DIR}/local_build.ps1
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})



40 changes: 20 additions & 20 deletions metamod/configure.py
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
# vim: set sts=2 ts=8 sw=2 tw=99 et:
import sys
try:
from ambuild2 import run, util
from ambuild2 import run, util
except:
try:
import ambuild
sys.stderr.write('It looks like you have AMBuild 1 installed, but this project uses AMBuild 2.\n')
sys.stderr.write('Upgrade to the latest version of AMBuild to continue.\n')
except:
sys.stderr.write('AMBuild must be installed to build this project.\n')
sys.stderr.write('http://www.alliedmods.net/ambuild\n')
sys.exit(1)
try:
import ambuild
sys.stderr.write('It looks like you have AMBuild 1 installed, but this project uses AMBuild 2.\n')
sys.stderr.write('Upgrade to the latest version of AMBuild to continue.\n')
except:
sys.stderr.write('AMBuild must be installed to build this project.\n')
sys.stderr.write('http://www.alliedmods.net/ambuild\n')
sys.exit(1)

# Hack to show a decent upgrade message, which wasn't done until 2.2.
ambuild_version = getattr(run, 'CURRENT_API', '2.1')
if ambuild_version.startswith('2.1'):
sys.stderr.write("AMBuild 2.2 or higher is required; please update\n")
sys.exit(1)
sys.stderr.write("AMBuild 2.2 or higher is required; please update\n")
sys.exit(1)

parser = run.BuildParser(sourcePath=sys.path[0], api='2.2')
parser.options.add_argument('-n', '--plugin-name', type=str, dest='plugin_name', default=None,
help='Plugin name')
help='Plugin name')
parser.options.add_argument('-a', '--plugin-alias', type=str, dest='plugin_alias', default=None,
help='Plugin alias')
help='Plugin alias')
parser.options.add_argument('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
help='Root search folder for HL2SDKs')
help='Root search folder for HL2SDKs')
parser.options.add_argument('--mms_path', type=str, dest='mms_path', default=None,
help='Metamod:Source source tree folder')
help='Metamod:Source source tree folder')
parser.options.add_argument('--enable-debug', action='store_const', const='1', dest='debug',
help='Enable debugging symbols')
help='Enable debugging symbols')
parser.options.add_argument('--enable-optimize', action='store_const', const='1', dest='opt',
help='Enable optimization')
help='Enable optimization')
parser.options.add_argument('-s', '--sdks', default='all', dest='sdks',
help='Build against specified SDKs; valid args are "all", "present", or '
'comma-delimited list of engine names (default: "all")')
help='Build against specified SDKs; valid args are "all", "present", or '
'comma-delimited list of engine names (default: "all")')
parser.options.add_argument('--targets', type=str, dest='targets', default=None,
help="Override the target architecture (use commas to separate multiple targets).")
parser.Configure()
parser.Configure()
8 changes: 6 additions & 2 deletions metamod/local_build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ $packageDir = "$buildDir\package\addons\*"

# Define the target directory for the plugin
$targetDir = "C:\cs2\game\csgo\addons"
$command = "C:\cs2\game\bin\win64\cs2.exe"


# Check if the build directory exists, and delete it if it does
Expand All @@ -33,5 +34,8 @@ if (Test-Path $packageDir) {
Copy-Item -Path $packageDir -Destination $targetDir -Recurse -Force
}

# Return to the root directory
Set-Location -Path $currentDir
# Spawn a process running $command with args -dedicated +map de_dust2
Start-Process -FilePath $command -ArgumentList "-dedicated +map de_dust2"



33 changes: 33 additions & 0 deletions metamod/src/core/cbaseentity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef WST_CBASEENTITY_H
#define WST_CBASEENTITY_H

#pragma once
#include <entityidentity.h>
#include <baseentity.h>
#include "schemasystem.h"

//inline CEntityInstance* UTIL_FindEntityByClassname(CEntityInstance* pStart, const char* name)
//{
// extern CEntitySystem* g_pEntitySystem;
// CEntityIdentity* pEntity = pStart ? pStart->m_pEntity->m_pNext : g_pEntitySystem->m_EntityList.m_pFirstActiveEntity;
//
// for (; pEntity; pEntity = pEntity->m_pNext)
// {
// if (!strcmp(pEntity->m_designerName.String(), name))
// return pEntity->m_pInstance;
// };
//
// return nullptr;
//}

class SC_CBaseEntity : public CBaseEntity
{
public:
SCHEMA_FIELD(int32_t, CBaseEntity, m_iHealth);
SCHEMA_FIELD(int32_t, CBaseEntity, m_iMaxHealth);
SCHEMA_FIELD(LifeState_t, CBaseEntity, m_lifeState);
SCHEMA_FIELD(uint8_t, CBaseEntity, m_iTeamNum);
SCHEMA_FIELD(float, CBaseEntity, m_flGravityScale);
};

#endif //WST_CBASEENTITY_H
Loading

0 comments on commit 7e16b64

Please sign in to comment.