Remove hookers stuff

Refactoring & cleanup code
This commit is contained in:
s1lent 2017-10-20 00:12:02 +07:00 committed by Dmitry Novikov
parent 9a91e9ca38
commit 32df585edc
235 changed files with 7287 additions and 17544 deletions

View File

@ -1,26 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug MP Play|Win32">
<Configuration>Debug MP Play</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MP|Win32">
<Configuration>Debug MP</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Release MP Play|Win32">
<Configuration>Release MP Play</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MP|Win32">
<Configuration>Release MP</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32"> <ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>Win32</Platform> <Platform>Win32</Platform>
@ -55,34 +39,6 @@
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset> <PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MP|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MP|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MP Play|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MP Play|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '12.0'">v120</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Nav|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Nav|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType> <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
@ -104,18 +60,6 @@
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MP|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MP|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MP Play|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MP Play|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup> </ImportGroup>
@ -137,70 +81,6 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MP|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_LIB;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>$(ProjectDir)..\include\</AdditionalIncludeDirectories>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MP|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_LIB;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>$(ProjectDir)..\include\</AdditionalIncludeDirectories>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MP Play|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_LIB;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>$(ProjectDir)..\include\</AdditionalIncludeDirectories>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MP Play|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_LIB;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalIncludeDirectories>$(ProjectDir)..\include\</AdditionalIncludeDirectories>
<CompileAs>CompileAsCpp</CompileAs>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>

View File

@ -1,7 +1,7 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013 # Visual Studio 14
VisualStudioVersion = 12.0.21005.1 VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReGameDLL", "..\regamedll\msvc\ReGameDLL.vcxproj", "{70A2B904-B7DB-4C48-8DE0-AF567360D572}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ReGameDLL", "..\regamedll\msvc\ReGameDLL.vcxproj", "{70A2B904-B7DB-4C48-8DE0-AF567360D572}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
@ -20,47 +20,27 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "gradle", "gradle", "{DB5703
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug MP Play|Win32 = Debug MP Play|Win32
Debug MP|Win32 = Debug MP|Win32
Debug Play|Win32 = Debug Play|Win32 Debug Play|Win32 = Debug Play|Win32
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
Release MP Play|Win32 = Release MP Play|Win32
Release MP|Win32 = Release MP|Win32
Release Play|Win32 = Release Play|Win32 Release Play|Win32 = Release Play|Win32
Release|Win32 = Release|Win32 Release|Win32 = Release|Win32
Tests|Win32 = Tests|Win32 Tests|Win32 = Tests|Win32
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Debug MP Play|Win32.ActiveCfg = Debug MP Play|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Debug MP Play|Win32.Build.0 = Debug MP Play|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Debug MP|Win32.ActiveCfg = Debug MP|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Debug MP|Win32.Build.0 = Debug MP|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Debug Play|Win32.ActiveCfg = Debug Play|Win32 {70A2B904-B7DB-4C48-8DE0-AF567360D572}.Debug Play|Win32.ActiveCfg = Debug Play|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Debug Play|Win32.Build.0 = Debug Play|Win32 {70A2B904-B7DB-4C48-8DE0-AF567360D572}.Debug Play|Win32.Build.0 = Debug Play|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Debug|Win32.ActiveCfg = Debug|Win32 {70A2B904-B7DB-4C48-8DE0-AF567360D572}.Debug|Win32.ActiveCfg = Debug|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Debug|Win32.Build.0 = Debug|Win32 {70A2B904-B7DB-4C48-8DE0-AF567360D572}.Debug|Win32.Build.0 = Debug|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Release MP Play|Win32.ActiveCfg = Release MP Play|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Release MP Play|Win32.Build.0 = Release MP Play|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Release MP|Win32.ActiveCfg = Release MP|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Release MP|Win32.Build.0 = Release MP|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Release Play|Win32.ActiveCfg = Release Play|Win32 {70A2B904-B7DB-4C48-8DE0-AF567360D572}.Release Play|Win32.ActiveCfg = Release Play|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Release Play|Win32.Build.0 = Release Play|Win32 {70A2B904-B7DB-4C48-8DE0-AF567360D572}.Release Play|Win32.Build.0 = Release Play|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Release|Win32.ActiveCfg = Release|Win32 {70A2B904-B7DB-4C48-8DE0-AF567360D572}.Release|Win32.ActiveCfg = Release|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Release|Win32.Build.0 = Release|Win32 {70A2B904-B7DB-4C48-8DE0-AF567360D572}.Release|Win32.Build.0 = Release|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Tests|Win32.ActiveCfg = Tests|Win32 {70A2B904-B7DB-4C48-8DE0-AF567360D572}.Tests|Win32.ActiveCfg = Tests|Win32
{70A2B904-B7DB-4C48-8DE0-AF567360D572}.Tests|Win32.Build.0 = Tests|Win32 {70A2B904-B7DB-4C48-8DE0-AF567360D572}.Tests|Win32.Build.0 = Tests|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Debug MP Play|Win32.ActiveCfg = Debug MP Play|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Debug MP Play|Win32.Build.0 = Debug MP Play|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Debug MP|Win32.ActiveCfg = Debug MP|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Debug MP|Win32.Build.0 = Debug MP|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Debug Play|Win32.ActiveCfg = Debug|Win32 {CEB94F7C-E459-4673-AABB-36E2074396C0}.Debug Play|Win32.ActiveCfg = Debug|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Debug Play|Win32.Build.0 = Debug|Win32 {CEB94F7C-E459-4673-AABB-36E2074396C0}.Debug Play|Win32.Build.0 = Debug|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Debug|Win32.ActiveCfg = Debug|Win32 {CEB94F7C-E459-4673-AABB-36E2074396C0}.Debug|Win32.ActiveCfg = Debug|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Debug|Win32.Build.0 = Debug|Win32 {CEB94F7C-E459-4673-AABB-36E2074396C0}.Debug|Win32.Build.0 = Debug|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Release MP Play|Win32.ActiveCfg = Release MP Play|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Release MP Play|Win32.Build.0 = Release MP Play|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Release MP|Win32.ActiveCfg = Release MP|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Release MP|Win32.Build.0 = Release MP|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Release Play|Win32.ActiveCfg = Release|Win32 {CEB94F7C-E459-4673-AABB-36E2074396C0}.Release Play|Win32.ActiveCfg = Release|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Release Play|Win32.Build.0 = Release|Win32 {CEB94F7C-E459-4673-AABB-36E2074396C0}.Release Play|Win32.Build.0 = Release|Win32
{CEB94F7C-E459-4673-AABB-36E2074396C0}.Release|Win32.ActiveCfg = Release|Win32 {CEB94F7C-E459-4673-AABB-36E2074396C0}.Release|Win32.ActiveCfg = Release|Win32

View File

@ -21,31 +21,25 @@ task publishPrepareFiles {
pubRootDir.mkdirs() pubRootDir.mkdirs()
// hookers binaries // bugfixed binaries
//project.file('publish/publishRoot/bin/hookers').mkdirs()
//_copyFileToDir('publish/releaseRegamedllNofixes/filesystem_stdio.dll', 'publish/publishRoot/bin/hookers/')
//_copyFileToDir('publish/releaseRegamedllNofixes/filesystem_stdio.pdb', 'publish/publishRoot/bin/hookers/')
//_copyFile('publish/releaseRegamedllNofixes/libfilesystem_stdio.so', 'publish/publishRoot/bin/hookers/filesystem_stdio.so')
//bugfixed binaries
project.file('publish/publishRoot/bin/bugfixed').mkdirs() project.file('publish/publishRoot/bin/bugfixed').mkdirs()
_copyFileToDir('publish/releaseRegamedllFixes/mp.dll', 'publish/publishRoot/bin/bugfixed/') _copyFileToDir('publish/releaseRegamedllFixes/mp.dll', 'publish/publishRoot/bin/bugfixed/')
_copyFileToDir('publish/releaseRegamedllFixes/mp.pdb', 'publish/publishRoot/bin/bugfixed/') _copyFileToDir('publish/releaseRegamedllFixes/mp.pdb', 'publish/publishRoot/bin/bugfixed/')
_copyFile('publish/releaseRegamedllFixes/libcs.so', 'publish/publishRoot/bin/bugfixed/cs.so') _copyFile('publish/releaseRegamedllFixes/libcs.so', 'publish/publishRoot/bin/bugfixed/cs.so')
//pure binaries // pure binaries
project.file('publish/publishRoot/bin/pure').mkdirs() project.file('publish/publishRoot/bin/pure').mkdirs()
_copyFileToDir('publish/releaseRegamedllNofixes/mp.dll', 'publish/publishRoot/bin/pure/') _copyFileToDir('publish/releaseRegamedllNofixes/mp.dll', 'publish/publishRoot/bin/pure/')
_copyFileToDir('publish/releaseRegamedllNofixes/mp.pdb', 'publish/publishRoot/bin/pure/') _copyFileToDir('publish/releaseRegamedllNofixes/mp.pdb', 'publish/publishRoot/bin/pure/')
_copyFile('publish/releaseRegamedllNofixes/libcs.so', 'publish/publishRoot/bin/pure/cs.so') _copyFile('publish/releaseRegamedllNofixes/libcs.so', 'publish/publishRoot/bin/pure/cs.so')
//copy files from folder dist // copy files from folder dist
copy { copy {
from('dist') from('dist')
into 'publish/publishRoot' into 'publish/publishRoot'
} }
//cssdk // cssdk
project.file('publish/publishRoot/cssdk').mkdirs() project.file('publish/publishRoot/cssdk').mkdirs()
copy { copy {
from 'regamedll/extra/cssdk' from 'regamedll/extra/cssdk'

View File

@ -45,12 +45,10 @@ project.ext.dep_cppunitlite = project(':dep/cppunitlite')
void createIntergrationTestTask(NativeBinarySpec b) { void createIntergrationTestTask(NativeBinarySpec b) {
boolean regamedllFixes = b.flavor.name.contains('regamedllFixes') boolean regamedllFixes = b.flavor.name.contains('regamedllFixes')
boolean mpLib = b.name.toLowerCase().contains('mp')
if (!(b instanceof SharedLibraryBinarySpec)) return if (!(b instanceof SharedLibraryBinarySpec)) return
if (!GradleCppUtils.windows) return if (!GradleCppUtils.windows) return
if (regamedllFixes) return if (regamedllFixes) return
if (!mpLib) return
String unitTestTask = b.hasProperty('cppUnitTestTask') ? b.cppUnitTestTask : null String unitTestTask = b.hasProperty('cppUnitTestTask') ? b.cppUnitTestTask : null
@ -93,11 +91,10 @@ void postEvaluate(NativeBinarySpec b) {
void setupToolchain(NativeBinarySpec b) void setupToolchain(NativeBinarySpec b)
{ {
boolean unitTestExecutable = b.component.name.endsWith('_tests') boolean unitTestExecutable = b.component.name.endsWith('_tests')
boolean mpLib = b.name.toLowerCase().contains('mp')
boolean regamedllFixes = b.flavor.name.contains('regamedllFixes') boolean regamedllFixes = b.flavor.name.contains('regamedllFixes')
ToolchainConfig cfg = rootProject.createToolchainConfig(b) ToolchainConfig cfg = rootProject.createToolchainConfig(b)
cfg.projectInclude(project, '', '/engine', '/common', '/dlls', '/game_shared', '/pm_shared', '/regamedll', '/hookers', '/public', '/public/regamedll') cfg.projectInclude(project, '', '/engine', '/common', '/dlls', '/game_shared', '/pm_shared', '/regamedll', '/public', '/public/regamedll')
if (unitTestExecutable) if (unitTestExecutable)
{ {
@ -125,11 +122,6 @@ void setupToolchain(NativeBinarySpec b)
cfg.compilerOptions.args '/Oi', '/GF', '/GS-', '/GR-' cfg.compilerOptions.args '/Oi', '/GF', '/GS-', '/GR-'
} }
if (mpLib)
{
cfg.linkerOptions.randomizedBaseAddress = false
cfg.linkerOptions.baseAddress = '0x4970000'
}
cfg.projectLibpath(project, '/lib') cfg.projectLibpath(project, '/lib')
cfg.extraLibs 'libacof32.lib' cfg.extraLibs 'libacof32.lib'
} }
@ -159,14 +151,12 @@ void setupToolchain(NativeBinarySpec b)
cfg.extraLibs 'dl', 'm', 'stdc++', 'aelf32' cfg.extraLibs 'dl', 'm', 'stdc++', 'aelf32'
} }
if (mpLib && GradleCppUtils.windows && !unitTestExecutable) { if (GradleCppUtils.windows && !unitTestExecutable) {
cfg.linkerOptions.definitionFile = "${projectDir}\\msvc\\mp.def"; cfg.linkerOptions.definitionFile = "${projectDir}\\msvc\\mp.def";
} }
if (unitTestExecutable) { if (unitTestExecutable) {
cfg.singleDefines 'REGAMEDLL_UNIT_TESTS' cfg.singleDefines 'REGAMEDLL_UNIT_TESTS'
} else if (!mpLib) {
cfg.singleDefines 'HOOK_GAMEDLL'
} }
if (regamedllFixes) { if (regamedllFixes) {
@ -186,7 +176,7 @@ class RegamedllSrc {
h.regamedll_src(CppSourceSet) { h.regamedll_src(CppSourceSet) {
source { source {
srcDirs "engine", "dlls", "dlls/addons", "game_shared", "pm_shared", "regamedll", "public", "version" srcDirs "engine", "dlls", "dlls/API", "dlls/addons", "game_shared", "pm_shared", "regamedll", "public", "version"
include "**/*.cpp" include "**/*.cpp"
exclude "precompiled.cpp" exclude "precompiled.cpp"
@ -214,24 +204,6 @@ class RegamedllSrc {
} }
} }
static void regamedll_hooker_src(def h) {
h.regamedll_hooker_src(CppSourceSet) {
source {
srcDirs "hookers"
include "main.cpp", "6153_hooker.cpp", "hooker.cpp", "memory.cpp", "hooker_impl.cpp", "RegameDLLRuntimeConfig.cpp"
}
}
}
static void regamedll_mp_src(def h) {
h.regamedll_mp_src(CppSourceSet) {
source {
srcDirs "hookers"
include "main_mp.cpp"
}
}
}
static void regamedll_tests_src(def h) { static void regamedll_tests_src(def h) {
h.regamedll_tests_src(CppSourceSet) { h.regamedll_tests_src(CppSourceSet) {
source { source {
@ -267,18 +239,6 @@ model {
} }
components { components {
regamedll_hooker_gamedll(NativeLibrarySpec) {
targetPlatform 'x86'
baseName 'filesystem_stdio'
sources {
RegamedllSrc.regamedll_pch(it)
RegamedllSrc.regamedll_src(it)
RegamedllSrc.regamedll_hooker_src(it)
}
binaries.all { NativeBinarySpec b -> project.setupToolchain(b) }
}
regamedll_mp_gamedll(NativeLibrarySpec) { regamedll_mp_gamedll(NativeLibrarySpec) {
targetPlatform 'x86' targetPlatform 'x86'
@ -286,22 +246,10 @@ model {
sources { sources {
RegamedllSrc.regamedll_pch(it) RegamedllSrc.regamedll_pch(it)
RegamedllSrc.regamedll_src(it) RegamedllSrc.regamedll_src(it)
RegamedllSrc.regamedll_mp_src(it)
} }
binaries.all { NativeBinarySpec b -> project.setupToolchain(b) } binaries.all { NativeBinarySpec b -> project.setupToolchain(b) }
} }
regamedll_hooker_gamedll_tests(NativeExecutableSpec) {
targetPlatform 'x86'
sources {
RegamedllSrc.regamedll_pch(it)
RegamedllSrc.regamedll_src(it)
RegamedllSrc.regamedll_tests_src(it)
}
binaries.all { NativeBinarySpec b -> project.setupToolchain(b) }
}
regamedll_mp_gamedll_tests(NativeExecutableSpec) { regamedll_mp_gamedll_tests(NativeExecutableSpec) {
targetPlatform 'x86' targetPlatform 'x86'
sources { sources {
@ -317,7 +265,7 @@ model {
task buildRelease { task buildRelease {
dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib -> dependsOn binaries.withType(SharedLibraryBinarySpec).matching { SharedLibraryBinarySpec blib ->
blib.buildable && blib.buildType.name == 'release' && !blib.name.contains('Regamedll_hooker_gamedll') blib.buildable && blib.buildType.name == 'release'
} }
} }

View File

@ -90,22 +90,6 @@ const T& clamp(const T& a, const T& min, const T& max) { return (a > max) ? max
#define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val))) #define clamp(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
#endif // __cplusplus #endif // __cplusplus
// bitwise operators templates
//template<class T, class type=typename std::underlying_type<T>::type>
//inline T operator~ (T a) { return (T)~(type)a; }
//template<class T, class type=typename std::underlying_type<T>::type>
//inline T operator| (T a, T b) { return (T)((type)a | (type)b); }
//template<class T, class type=typename std::underlying_type<T>::type>
//inline T operator& (T a, T b) { return (T)((type)a & (type)b); }
//template<class T, class type=typename std::underlying_type<T>::type>
//inline T operator^ (T a, T b) { return (T)((type)a ^ (type)b); }
//template<class T, class type=typename std::underlying_type<T>::type>
//inline T& operator|= (T& a, T b) { return (T&)((type&)a |= (type)b); }
//template<class T, class type=typename std::underlying_type<T>::type>
//inline T& operator&= (T& a, T b) { return (T&)((type&)a &= (type)b); }
//template<class T, class type=typename std::underlying_type<T>::type>
//inline T& operator^= (T& a, T b) { return (T&)((type&)a ^= (type)b); }
inline float M_sqrt(float value) { inline float M_sqrt(float value) {
return _mm_cvtss_f32(_mm_sqrt_ss(_mm_load_ss(&value))); return _mm_cvtss_f32(_mm_sqrt_ss(_mm_load_ss(&value)));
} }

View File

@ -1,7 +0,0 @@
#if _MSC_VER >= 1500 // MSVC++ 9.0 (Visual Studio 2008)
#pragma push_macro("ARRAYSIZE")
#ifdef ARRAYSIZE
#undef ARRAYSIZE
#endif
#define HSPRITE WINDOWS_HSPRITE
#endif

View File

@ -1,4 +0,0 @@
#if _MSC_VER >= 1500 // MSVC++ 9.0 (Visual Studio 2008)
#undef HSPRITE
#pragma pop_macro("ARRAYSIZE")
#endif

View File

@ -143,48 +143,48 @@ GAMEHOOK_REGISTRY(CSGameRules_OnRoundFreezeEnd);
GAMEHOOK_REGISTRY(PM_UpdateStepSound); GAMEHOOK_REGISTRY(PM_UpdateStepSound);
GAMEHOOK_REGISTRY(CBasePlayer_StartDeathCam); GAMEHOOK_REGISTRY(CBasePlayer_StartDeathCam);
int EXT_FUNC CReGameApi::GetMajorVersion() { int CReGameApi::GetMajorVersion() {
return REGAMEDLL_API_VERSION_MAJOR; return REGAMEDLL_API_VERSION_MAJOR;
} }
int EXT_FUNC CReGameApi::GetMinorVersion() { int CReGameApi::GetMinorVersion() {
return REGAMEDLL_API_VERSION_MINOR; return REGAMEDLL_API_VERSION_MINOR;
} }
const EXT_FUNC ReGameFuncs_t *CReGameApi::GetFuncs() { const ReGameFuncs_t *CReGameApi::GetFuncs() {
return &g_ReGameApiFuncs; return &g_ReGameApiFuncs;
} }
IReGameHookchains *EXT_FUNC CReGameApi::GetHookchains() { IReGameHookchains *CReGameApi::GetHookchains() {
return &g_ReGameHookchains; return &g_ReGameHookchains;
} }
CGameRules *EXT_FUNC CReGameApi::GetGameRules() { CGameRules *CReGameApi::GetGameRules() {
return g_pGameRules; return g_pGameRules;
} }
WeaponInfoStruct *EXT_FUNC CReGameApi::GetWeaponInfo(int weaponID) { WeaponInfoStruct *CReGameApi::GetWeaponInfo(int weaponID) {
return ::GetWeaponInfo(weaponID); return ::GetWeaponInfo(weaponID);
} }
WeaponInfoStruct *EXT_FUNC CReGameApi::GetWeaponInfo(const char *weaponName) { WeaponInfoStruct *CReGameApi::GetWeaponInfo(const char *weaponName) {
return ::GetWeaponInfo(weaponName); return ::GetWeaponInfo(weaponName);
} }
playermove_t *EXT_FUNC CReGameApi::GetPlayerMove() { playermove_t *CReGameApi::GetPlayerMove() {
return pmove; return pmove;
} }
WeaponSlotInfo *EXT_FUNC CReGameApi::GetWeaponSlot(WeaponIdType weaponID) { return ::GetWeaponSlot(weaponID); } WeaponSlotInfo *CReGameApi::GetWeaponSlot(WeaponIdType weaponID) { return ::GetWeaponSlot(weaponID); }
WeaponSlotInfo *EXT_FUNC CReGameApi::GetWeaponSlot(const char *weaponName) { return ::GetWeaponSlot(weaponName); } WeaponSlotInfo *CReGameApi::GetWeaponSlot(const char *weaponName) { return ::GetWeaponSlot(weaponName); }
ItemInfo *EXT_FUNC CReGameApi::GetItemInfo(WeaponIdType weaponID) { return &IMPL_CLASS(CBasePlayerItem, m_ItemInfoArray)[weaponID]; } ItemInfo *CReGameApi::GetItemInfo(WeaponIdType weaponID) { return &CBasePlayerItem::m_ItemInfoArray[weaponID]; }
AmmoInfo *EXT_FUNC CReGameApi::GetAmmoInfo(AmmoType ammoID) { return &IMPL_CLASS(CBasePlayerItem, m_AmmoInfoArray)[ammoID]; } AmmoInfo *CReGameApi::GetAmmoInfo(AmmoType ammoID) { return &CBasePlayerItem::m_AmmoInfoArray[ammoID]; }
AmmoInfoStruct *EXT_FUNC CReGameApi::GetAmmoInfoEx(AmmoType ammoID) { return ::GetAmmoInfo(ammoID); } AmmoInfoStruct *CReGameApi::GetAmmoInfoEx(AmmoType ammoID) { return ::GetAmmoInfo(ammoID); }
AmmoInfoStruct *EXT_FUNC CReGameApi::GetAmmoInfoEx(const char *ammoName) { return ::GetAmmoInfo(ammoName); } AmmoInfoStruct *CReGameApi::GetAmmoInfoEx(const char *ammoName) { return ::GetAmmoInfo(ammoName); }
void EXT_FUNC Regamedll_ChangeString_api(char *&dest, const char *source) EXT_FUNC void Regamedll_ChangeString_api(char *&dest, const char *source)
{ {
size_t len = Q_strlen(source); size_t len = Q_strlen(source);
if (dest == nullptr || Q_strlen(dest) != len) { if (dest == nullptr || Q_strlen(dest) != len) {
@ -195,22 +195,22 @@ void EXT_FUNC Regamedll_ChangeString_api(char *&dest, const char *source)
Q_strcpy(dest, source); Q_strcpy(dest, source);
} }
void EXT_FUNC RadiusDamage_api(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType) EXT_FUNC void RadiusDamage_api(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType)
{ {
RadiusDamage(vecSrc, pevInflictor, pevAttacker, flDamage, flRadius, iClassIgnore, bitsDamageType); RadiusDamage(vecSrc, pevInflictor, pevAttacker, flDamage, flRadius, iClassIgnore, bitsDamageType);
} }
void EXT_FUNC ClearMultiDamage_api() EXT_FUNC void ClearMultiDamage_api()
{ {
ClearMultiDamage(); ClearMultiDamage();
} }
void EXT_FUNC ApplyMultiDamage_api(entvars_t *pevInflictor, entvars_t *pevAttacker) EXT_FUNC void ApplyMultiDamage_api(entvars_t *pevInflictor, entvars_t *pevAttacker)
{ {
ApplyMultiDamage(pevInflictor, pevAttacker); ApplyMultiDamage(pevInflictor, pevAttacker);
} }
void EXT_FUNC AddMultiDamage_api(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType) EXT_FUNC void AddMultiDamage_api(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType)
{ {
AddMultiDamage(pevInflictor, pEntity, flDamage, bitsDamageType); AddMultiDamage(pevInflictor, pEntity, flDamage, bitsDamageType);
} }

View File

@ -30,7 +30,86 @@
#include "archtypes.h" #include "archtypes.h"
#include "regamedll_api.h" #include "regamedll_api.h"
#include "regamedll_interfaces_impl.h"
#ifdef REGAMEDLL_API
#define __API_HOOK(fname)\
fname##_OrigFunc
#define LINK_HOOK_CLASS_VOID_CHAIN(className, functionName, args, ...)\
void className::functionName args {\
g_ReGameHookchains.m_##className##_##functionName.callChain(&className::functionName##_OrigFunc, this, __VA_ARGS__);\
}
#define LINK_HOOK_CLASS_VOID_CHAIN2(className, functionName)\
void EXT_FUNC className::functionName() {\
g_ReGameHookchains.m_##className##_##functionName.callChain(&className::functionName##_OrigFunc, this);\
}
#define LINK_HOOK_CLASS_CHAIN(ret, className, functionName, args, ...)\
ret className::functionName args {\
return g_ReGameHookchains.m_##className##_##functionName.callChain(&className::functionName##_OrigFunc, this, __VA_ARGS__);\
}
#define LINK_HOOK_CLASS_CHAIN2(ret, className, functionName)\
ret className::functionName() {\
return g_ReGameHookchains.m_##className##_##functionName.callChain(&className::functionName##_OrigFunc, this);\
}
#define LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN(className, customPrefix, functionName, args, ...)\
void className::functionName args {\
g_ReGameHookchains.m_##customPrefix##_##functionName.callChain(&className::functionName##_OrigFunc, this, __VA_ARGS__);\
}
#define LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(className, customPrefix, functionName)\
void className::functionName() {\
g_ReGameHookchains.m_##customPrefix##_##functionName.callChain(&className::functionName##_OrigFunc, this);\
}
#define LINK_HOOK_CLASS_CUSTOM_CHAIN(ret, className, customPrefix, functionName, args, ...)\
ret className::functionName args {\
return g_ReGameHookchains.m_##customPrefix##_##functionName.callChain(&className::functionName##_OrigFunc, this, __VA_ARGS__);\
}
#define LINK_HOOK_CLASS_CUSTOM_CHAIN2(ret, className, customPrefix, functionName)\
ret className::functionName() {\
return g_ReGameHookchains.m_##customPrefix##_##functionName.callChain(&className::functionName##_OrigFunc, this);\
}
#define LINK_HOOK_VOID_CHAIN(functionName, args, ...)\
void functionName args {\
g_ReGameHookchains.m_##functionName.callChain(functionName##_OrigFunc, __VA_ARGS__);\
}
#define LINK_HOOK_CHAIN(ret, functionName, args, ...)\
ret functionName args {\
return g_ReGameHookchains.m_##functionName.callChain(functionName##_OrigFunc, __VA_ARGS__);\
}
#define LINK_HOOK_VOID_CHAIN2(functionName)\
void functionName() {\
g_ReGameHookchains.m_##functionName.callChain(functionName##_OrigFunc);\
}
#define LINK_HOOK_CHAIN2(ret, functionName)\
ret functionName() {\
return g_ReGameHookchains.m_##functionName.callChain(functionName##_OrigFunc);\
}
#else
#define __API_HOOK(fname)\
fname
#define LINK_HOOK_CLASS_VOID_CHAIN(...)
#define LINK_HOOK_CLASS_VOID_CHAIN2(...)
#define LINK_HOOK_CLASS_CHAIN(...)
#define LINK_HOOK_CLASS_CHAIN2(...)
#define LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN(...)
#define LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(...)
#define LINK_HOOK_CLASS_CUSTOM_CHAIN(...)
#define LINK_HOOK_CLASS_CUSTOM_CHAIN2(...)
#define LINK_HOOK_VOID_CHAIN(...)
#define LINK_HOOK_VOID_CHAIN2(...)
#define LINK_HOOK_CHAIN(...)
#define LINK_HOOK_CHAIN2(...)
#endif // REGAMEDLL_API
#define GAMEHOOK_REGISTRY(func)\ #define GAMEHOOK_REGISTRY(func)\
IReGameHookRegistry_##func *CReGameHookchains::func() { return &m_##func; } IReGameHookRegistry_##func *CReGameHookchains::func() { return &m_##func; }
@ -541,22 +620,22 @@ extern ReGameFuncs_t g_ReGameApiFuncs;
class CReGameApi: public IReGameApi { class CReGameApi: public IReGameApi {
public: public:
virtual int GetMajorVersion(); EXT_FUNC virtual int GetMajorVersion();
virtual int GetMinorVersion(); EXT_FUNC virtual int GetMinorVersion();
virtual const ReGameFuncs_t *GetFuncs(); EXT_FUNC virtual const ReGameFuncs_t *GetFuncs();
virtual IReGameHookchains *GetHookchains(); EXT_FUNC virtual IReGameHookchains *GetHookchains();
virtual CGameRules *GetGameRules(); EXT_FUNC virtual CGameRules *GetGameRules();
virtual WeaponInfoStruct *GetWeaponInfo(int weaponID); EXT_FUNC virtual WeaponInfoStruct *GetWeaponInfo(int weaponID);
virtual WeaponInfoStruct *GetWeaponInfo(const char *weaponName); EXT_FUNC virtual WeaponInfoStruct *GetWeaponInfo(const char *weaponName);
virtual playermove_t *GetPlayerMove(); EXT_FUNC virtual playermove_t *GetPlayerMove();
virtual WeaponSlotInfo *GetWeaponSlot(WeaponIdType weaponID); EXT_FUNC virtual WeaponSlotInfo *GetWeaponSlot(WeaponIdType weaponID);
virtual WeaponSlotInfo *GetWeaponSlot(const char *weaponName); EXT_FUNC virtual WeaponSlotInfo *GetWeaponSlot(const char *weaponName);
virtual ItemInfo *GetItemInfo(WeaponIdType weaponID); EXT_FUNC virtual ItemInfo *GetItemInfo(WeaponIdType weaponID);
virtual AmmoInfo *GetAmmoInfo(AmmoType ammoID); EXT_FUNC virtual AmmoInfo *GetAmmoInfo(AmmoType ammoID);
virtual AmmoInfoStruct *GetAmmoInfoEx(AmmoType ammoID); EXT_FUNC virtual AmmoInfoStruct *GetAmmoInfoEx(AmmoType ammoID);
virtual AmmoInfoStruct *GetAmmoInfoEx(const char *ammoName); EXT_FUNC virtual AmmoInfoStruct *GetAmmoInfoEx(const char *ammoName);
}; };
void Regamedll_ChangeString_api(char *&dest, const char *source); void Regamedll_ChangeString_api(char *&dest, const char *source);

View File

@ -0,0 +1,39 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h"
void CCSEntity::FireBullets(int iShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker)
{
m_pContainingEntity->FireBullets(iShots, vecSrc, vecDirShooting, vecSpread, flDistance, iBulletType, iTracerFreq, iDamage, pevAttacker);
}
Vector CCSEntity::FireBullets3(Vector &vecSrc, Vector &vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand)
{
return m_pContainingEntity->FireBullets3(vecSrc, vecDirShooting, vecSpread, flDistance, iPenetration, iBulletType, iDamage, flRangeModifier, pevAttacker, bPistol, shared_rand);
}

View File

@ -28,15 +28,7 @@
#include "precompiled.h" #include "precompiled.h"
void EXT_FUNC CCSEntity::FireBullets(int iShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker) { EXT_FUNC bool CCSPlayer::JoinTeam(TeamName team)
m_pContainingEntity->FireBullets(iShots, vecSrc, vecDirShooting, vecSpread, flDistance, iBulletType, iTracerFreq, iDamage, pevAttacker);
};
Vector EXT_FUNC CCSEntity::FireBullets3(Vector &vecSrc, Vector &vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand) {
return m_pContainingEntity->FireBullets3(vecSrc, vecDirShooting, vecSpread, flDistance, iPenetration, iBulletType, iDamage, flRangeModifier, pevAttacker, bPistol, shared_rand);
};
bool EXT_FUNC CCSPlayer::JoinTeam(TeamName team)
{ {
CBasePlayer *pPlayer = BasePlayer(); CBasePlayer *pPlayer = BasePlayer();
switch (team) switch (team)
@ -140,7 +132,7 @@ bool EXT_FUNC CCSPlayer::JoinTeam(TeamName team)
return true; return true;
} }
bool EXT_FUNC CCSPlayer::RemovePlayerItem(const char *pszItemName) EXT_FUNC bool CCSPlayer::RemovePlayerItem(const char *pszItemName)
{ {
if (!pszItemName) if (!pszItemName)
return false; return false;
@ -148,7 +140,8 @@ bool EXT_FUNC CCSPlayer::RemovePlayerItem(const char *pszItemName)
CBasePlayer *pPlayer = BasePlayer(); CBasePlayer *pPlayer = BasePlayer();
// if it item_ ? // if it item_ ?
if (pszItemName[0] == 'i') { if (pszItemName[0] == 'i')
{
pszItemName += sizeof("item_") - 1; pszItemName += sizeof("item_") - 1;
// item_thighpack // item_thighpack
@ -208,7 +201,8 @@ bool EXT_FUNC CCSPlayer::RemovePlayerItem(const char *pszItemName)
return true; return true;
} }
else if (FStrEq(pszItemName, "weapon_shield")) { else if (FStrEq(pszItemName, "weapon_shield"))
{
if (!pPlayer->HasShield()) if (!pPlayer->HasShield())
return false; return false;
@ -223,7 +217,7 @@ bool EXT_FUNC CCSPlayer::RemovePlayerItem(const char *pszItemName)
if (pWeapon->m_iId == WEAPON_HEGRENADE || pWeapon->m_iId == WEAPON_FLASHBANG || pWeapon->m_iId == WEAPON_SMOKEGRENADE) if (pWeapon->m_iId == WEAPON_HEGRENADE || pWeapon->m_iId == WEAPON_FLASHBANG || pWeapon->m_iId == WEAPON_SMOKEGRENADE)
{ {
if (pPlayer->m_rgAmmo[ pWeapon->m_iPrimaryAmmoType ] <= 0) if (pPlayer->m_rgAmmo[pWeapon->m_iPrimaryAmmoType] <= 0)
g_pGameRules->GetNextBestWeapon(pPlayer, pWeapon); g_pGameRules->GetNextBestWeapon(pPlayer, pWeapon);
} }
@ -274,7 +268,7 @@ bool EXT_FUNC CCSPlayer::RemovePlayerItem(const char *pszItemName)
return false; return false;
} }
CBaseEntity *EXT_FUNC CCSPlayer::GiveNamedItemEx(const char *pszName) EXT_FUNC CBaseEntity *CCSPlayer::GiveNamedItemEx(const char *pszName)
{ {
CBasePlayer *pPlayer = BasePlayer(); CBasePlayer *pPlayer = BasePlayer();
@ -294,41 +288,192 @@ CBaseEntity *EXT_FUNC CCSPlayer::GiveNamedItemEx(const char *pszName)
return pPlayer->GiveNamedItemEx(pszName); return pPlayer->GiveNamedItemEx(pszName);
} }
bool EXT_FUNC CCSPlayer::IsConnected() const { return m_pContainingEntity->has_disconnected == false; } EXT_FUNC bool CCSPlayer::IsConnected() const
void EXT_FUNC CCSPlayer::SetAnimation(PLAYER_ANIM playerAnim) { BasePlayer()->SetAnimation(playerAnim); } {
void EXT_FUNC CCSPlayer::AddAccount(int amount, RewardType type, bool bTrackChange) { BasePlayer()->AddAccount(amount, type, bTrackChange); } return m_pContainingEntity->has_disconnected == false;
CBaseEntity *EXT_FUNC CCSPlayer::GiveNamedItem(const char *pszName) { return BasePlayer()->GiveNamedItem(pszName); } }
void EXT_FUNC CCSPlayer::GiveDefaultItems() { BasePlayer()->GiveDefaultItems(); }
void EXT_FUNC CCSPlayer::GiveShield(bool bDeploy) { BasePlayer()->GiveShield(bDeploy); } EXT_FUNC void CCSPlayer::SetAnimation(PLAYER_ANIM playerAnim)
void EXT_FUNC CCSPlayer::DropShield(bool bDeploy) { BasePlayer()->DropShield(bDeploy); } {
void EXT_FUNC CCSPlayer::DropPlayerItem(const char *pszItemName) { BasePlayer()->DropPlayerItem(pszItemName); } BasePlayer()->SetAnimation(playerAnim);
void EXT_FUNC CCSPlayer::RemoveShield() { BasePlayer()->RemoveShield(); } }
void EXT_FUNC CCSPlayer::RemoveAllItems(bool bRemoveSuit) { BasePlayer()->RemoveAllItems(bRemoveSuit ? TRUE : FALSE); }
void EXT_FUNC CCSPlayer::SetPlayerModel(bool bHasC4) { BasePlayer()->SetPlayerModel(bHasC4 ? TRUE : FALSE); } EXT_FUNC void CCSPlayer::AddAccount(int amount, RewardType type, bool bTrackChange)
void EXT_FUNC CCSPlayer::SetPlayerModelEx(const char *modelName) { Q_strncpy(m_szModel, modelName, sizeof(m_szModel) - 1); m_szModel[sizeof(m_szModel) - 1] = '\0'; }; {
void EXT_FUNC CCSPlayer::SetNewPlayerModel(const char *modelName) { BasePlayer()->SetNewPlayerModel(STRING(ALLOC_STRING(modelName))); } BasePlayer()->AddAccount(amount, type, bTrackChange);
void EXT_FUNC CCSPlayer::ClientCommand(const char *cmd, const char *arg1, const char *arg2, const char *arg3) { BasePlayer()->ClientCommand(cmd, arg1, arg2, arg3); } }
void EXT_FUNC CCSPlayer::SetProgressBarTime(int time) { BasePlayer()->SetProgressBarTime(time); }
void EXT_FUNC CCSPlayer::SetProgressBarTime2(int time, float timeElapsed) { BasePlayer()->SetProgressBarTime2(time, timeElapsed); } EXT_FUNC CBaseEntity *CCSPlayer::GiveNamedItem(const char *pszName)
edict_t *EXT_FUNC CCSPlayer::EntSelectSpawnPoint() { return BasePlayer()->EntSelectSpawnPoint(); } {
void EXT_FUNC CCSPlayer::SendItemStatus() { BasePlayer()->SendItemStatus(); } return BasePlayer()->GiveNamedItem(pszName);
void EXT_FUNC CCSPlayer::SetBombIcon(bool bFlash) { BasePlayer()->SetBombIcon(bFlash ? TRUE : FALSE); } }
void EXT_FUNC CCSPlayer::SetScoreAttrib(CBasePlayer *dest) { BasePlayer()->SetScoreAttrib(dest); }
void EXT_FUNC CCSPlayer::ReloadWeapons(CBasePlayerItem *pWeapon, bool bForceReload, bool bForceRefill) { BasePlayer()->ReloadWeapons(pWeapon, bForceReload, bForceRefill); } EXT_FUNC void CCSPlayer::GiveDefaultItems()
void EXT_FUNC CCSPlayer::Observer_SetMode(int iMode) { BasePlayer()->Observer_SetMode(iMode); } {
bool EXT_FUNC CCSPlayer::SelectSpawnSpot(const char *pEntClassName, CBaseEntity *&pSpot) { return BasePlayer()->SelectSpawnSpot(pEntClassName, pSpot); } BasePlayer()->GiveDefaultItems();
bool EXT_FUNC CCSPlayer::SwitchWeapon(CBasePlayerItem *pWeapon) { return BasePlayer()->SwitchWeapon(pWeapon) != FALSE; } }
void EXT_FUNC CCSPlayer::SwitchTeam() { BasePlayer()->SwitchTeam(); }
void EXT_FUNC CCSPlayer::StartObserver(Vector& vecPosition, Vector& vecViewAngle) { BasePlayer()->StartObserver(vecPosition, vecViewAngle); } EXT_FUNC void CCSPlayer::GiveShield(bool bDeploy)
void EXT_FUNC CCSPlayer::TeamChangeUpdate() { BasePlayer()->TeamChangeUpdate(); } {
void EXT_FUNC CCSPlayer::DropSecondary() { BasePlayer()->DropSecondary(); } BasePlayer()->GiveShield(bDeploy);
void EXT_FUNC CCSPlayer::DropPrimary() { BasePlayer()->DropPrimary(); } }
bool EXT_FUNC CCSPlayer::HasPlayerItem(CBasePlayerItem *pCheckItem) { return BasePlayer()->HasPlayerItem(pCheckItem); }
bool EXT_FUNC CCSPlayer::HasNamedPlayerItem(const char *pszItemName) { return BasePlayer()->HasNamedPlayerItem(pszItemName); } EXT_FUNC void CCSPlayer::DropShield(bool bDeploy)
CBasePlayerItem *EXT_FUNC CCSPlayer::GetItemById(WeaponIdType weaponID) { return BasePlayer()->GetItemById(weaponID); } {
CBasePlayerItem *EXT_FUNC CCSPlayer::GetItemByName(const char *itemName) { return BasePlayer()->GetItemByName(itemName); } BasePlayer()->DropShield(bDeploy);
void EXT_FUNC CCSPlayer::Disappear() { BasePlayer()->Disappear(); } }
void EXT_FUNC CCSPlayer::MakeVIP() { BasePlayer()->MakeVIP(); }
bool EXT_FUNC CCSPlayer::MakeBomber() { return BasePlayer()->MakeBomber(); } EXT_FUNC void CCSPlayer::DropPlayerItem(const char *pszItemName)
void EXT_FUNC CCSPlayer::ResetSequenceInfo() { BasePlayer()->ResetSequenceInfo(); } {
void EXT_FUNC CCSPlayer::StartDeathCam() { BasePlayer()->StartDeathCam(); } BasePlayer()->DropPlayerItem(pszItemName);
}
EXT_FUNC void CCSPlayer::RemoveShield()
{
BasePlayer()->RemoveShield();
}
EXT_FUNC void CCSPlayer::RemoveAllItems(bool bRemoveSuit)
{
BasePlayer()->RemoveAllItems(bRemoveSuit ? TRUE : FALSE);
}
EXT_FUNC void CCSPlayer::SetPlayerModel(bool bHasC4)
{
BasePlayer()->SetPlayerModel(bHasC4 ? TRUE : FALSE);
}
EXT_FUNC void CCSPlayer::SetPlayerModelEx(const char *modelName)
{
Q_strlcpy(m_szModel, modelName);
}
EXT_FUNC void CCSPlayer::SetNewPlayerModel(const char *modelName)
{
BasePlayer()->SetNewPlayerModel(STRING(ALLOC_STRING(modelName)));
}
EXT_FUNC void CCSPlayer::ClientCommand(const char *cmd, const char *arg1, const char *arg2, const char *arg3)
{
BasePlayer()->ClientCommand(cmd, arg1, arg2, arg3);
}
EXT_FUNC void CCSPlayer::SetProgressBarTime(int time)
{
BasePlayer()->SetProgressBarTime(time);
}
EXT_FUNC void CCSPlayer::SetProgressBarTime2(int time, float timeElapsed)
{
BasePlayer()->SetProgressBarTime2(time, timeElapsed);
}
EXT_FUNC edict_t *CCSPlayer::EntSelectSpawnPoint()
{
return BasePlayer()->EntSelectSpawnPoint();
}
EXT_FUNC void CCSPlayer::SendItemStatus()
{
BasePlayer()->SendItemStatus();
}
EXT_FUNC void CCSPlayer::SetBombIcon(bool bFlash)
{
BasePlayer()->SetBombIcon(bFlash ? TRUE : FALSE);
}
EXT_FUNC void CCSPlayer::SetScoreAttrib(CBasePlayer *dest)
{
BasePlayer()->SetScoreAttrib(dest);
}
EXT_FUNC void CCSPlayer::ReloadWeapons(CBasePlayerItem *pWeapon, bool bForceReload, bool bForceRefill)
{
BasePlayer()->ReloadWeapons(pWeapon, bForceReload, bForceRefill);
}
EXT_FUNC void CCSPlayer::Observer_SetMode(int iMode)
{
BasePlayer()->Observer_SetMode(iMode);
}
EXT_FUNC bool CCSPlayer::SelectSpawnSpot(const char *pEntClassName, CBaseEntity *&pSpot)
{
return BasePlayer()->SelectSpawnSpot(pEntClassName, pSpot);
}
EXT_FUNC bool CCSPlayer::SwitchWeapon(CBasePlayerItem *pWeapon)
{
return BasePlayer()->SwitchWeapon(pWeapon) != FALSE;
}
EXT_FUNC void CCSPlayer::SwitchTeam()
{
BasePlayer()->SwitchTeam();
}
EXT_FUNC void CCSPlayer::StartObserver(Vector& vecPosition, Vector& vecViewAngle)
{
BasePlayer()->StartObserver(vecPosition, vecViewAngle);
}
EXT_FUNC void CCSPlayer::TeamChangeUpdate()
{
BasePlayer()->TeamChangeUpdate();
}
EXT_FUNC void CCSPlayer::DropSecondary()
{
BasePlayer()->DropSecondary();
}
EXT_FUNC void CCSPlayer::DropPrimary()
{
BasePlayer()->DropPrimary();
}
EXT_FUNC bool CCSPlayer::HasPlayerItem(CBasePlayerItem *pCheckItem)
{
return BasePlayer()->HasPlayerItem(pCheckItem);
}
EXT_FUNC bool CCSPlayer::HasNamedPlayerItem(const char *pszItemName)
{
return BasePlayer()->HasNamedPlayerItem(pszItemName);
}
EXT_FUNC CBasePlayerItem *CCSPlayer::GetItemById(WeaponIdType weaponID)
{
return BasePlayer()->GetItemById(weaponID);
}
EXT_FUNC CBasePlayerItem *CCSPlayer::GetItemByName(const char *itemName)
{
return BasePlayer()->GetItemByName(itemName);
}
EXT_FUNC void CCSPlayer::Disappear()
{
BasePlayer()->Disappear();
}
EXT_FUNC void CCSPlayer::MakeVIP()
{
BasePlayer()->MakeVIP();
}
EXT_FUNC bool CCSPlayer::MakeBomber()
{
return BasePlayer()->MakeBomber();
}
EXT_FUNC void CCSPlayer::ResetSequenceInfo()
{
BasePlayer()->ResetSequenceInfo();
}
EXT_FUNC void CCSPlayer::StartDeathCam()
{
BasePlayer()->StartDeathCam();
}

View File

@ -0,0 +1,46 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h"
EXT_FUNC void CCSPlayerItem::SetItemInfo(ItemInfo *pInfo)
{
Q_memcpy(&m_ItemInfo, pInfo, sizeof(m_ItemInfo));
}
#ifdef REGAMEDLL_API
int CBasePlayerItem::iPosition() const { return CSPlayerItem()->m_ItemInfo.iPosition; }
const char *CBasePlayerItem::pszAmmo1() const { return CSPlayerItem()->m_ItemInfo.pszAmmo1; }
int CBasePlayerItem::iMaxAmmo1() const { return CSPlayerItem()->m_ItemInfo.iMaxAmmo1; }
const char *CBasePlayerItem::pszAmmo2() const { return CSPlayerItem()->m_ItemInfo.pszAmmo2; }
int CBasePlayerItem::iMaxAmmo2() const { return CSPlayerItem()->m_ItemInfo.iMaxAmmo2; }
const char *CBasePlayerItem::pszName() const { return CSPlayerItem()->m_ItemInfo.pszName; }
int CBasePlayerItem::iMaxClip() const { return CSPlayerItem()->m_ItemInfo.iMaxClip; }
int CBasePlayerItem::iWeight() const { return CSPlayerItem()->m_ItemInfo.iWeight; }
int CBasePlayerItem::iFlags() const { return CSPlayerItem()->m_ItemInfo.iFlags; }
#endif

View File

@ -1,17 +1,10 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CAirtank::m_SaveData[] = TYPEDESCRIPTION CAirtank::m_SaveData[] =
{ {
DEFINE_FIELD(CAirtank, m_state, FIELD_INTEGER) DEFINE_FIELD(CAirtank, m_state, FIELD_INTEGER)
}; };
#endif
LINK_ENTITY_TO_CLASS(item_airtank, CAirtank, CCSAirtank) LINK_ENTITY_TO_CLASS(item_airtank, CAirtank, CCSAirtank)
IMPLEMENT_SAVERESTORE(CAirtank, CGrenade) IMPLEMENT_SAVERESTORE(CAirtank, CGrenade)

View File

@ -43,7 +43,7 @@ public:
void EXPORT TankTouch(CBaseEntity *pOther); void EXPORT TankTouch(CBaseEntity *pOther);
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[1]; static TYPEDESCRIPTION m_SaveData[];
private: private:
int m_state; int m_state;

View File

@ -1,10 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CBaseAnimating::m_SaveData[] = TYPEDESCRIPTION CBaseAnimating::m_SaveData[] =
{ {
DEFINE_FIELD(CBaseMonster, m_flFrameRate, FIELD_FLOAT), DEFINE_FIELD(CBaseMonster, m_flFrameRate, FIELD_FLOAT),
@ -14,8 +9,6 @@ TYPEDESCRIPTION CBaseAnimating::m_SaveData[] =
DEFINE_FIELD(CBaseMonster, m_fSequenceLoops, FIELD_BOOLEAN), DEFINE_FIELD(CBaseMonster, m_fSequenceLoops, FIELD_BOOLEAN),
}; };
#endif
IMPLEMENT_SAVERESTORE(CBaseAnimating, CBaseDelay) IMPLEMENT_SAVERESTORE(CBaseAnimating, CBaseDelay)
float CBaseAnimating::StudioFrameAdvance(float flInterval) float CBaseAnimating::StudioFrameAdvance(float flInterval)

View File

@ -1,10 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
void EXT_FUNC SV_StudioSetupBones(model_t *pModel, float frame, int sequence, const vec_t *angles, const vec_t *origin, const byte *pcontroller, const byte *pblending, int iBone, const edict_t *pEdict); void EXT_FUNC SV_StudioSetupBones(model_t *pModel, float frame, int sequence, const vec_t *angles, const vec_t *origin, const byte *pcontroller, const byte *pblending, int iBone, const edict_t *pEdict);
sv_blending_interface_t svBlending = sv_blending_interface_t svBlending =
@ -13,8 +8,6 @@ sv_blending_interface_t svBlending =
SV_StudioSetupBones SV_StudioSetupBones
}; };
#endif
server_studio_api_t IEngineStudio; server_studio_api_t IEngineStudio;
studiohdr_t *g_pstudiohdr; studiohdr_t *g_pstudiohdr;
@ -361,7 +354,7 @@ float SetController(void *pmodel, entvars_t *pev, int iController, float flValue
int setting = int64(255.0f * (flValue - pbonecontroller->start) / (pbonecontroller->end - pbonecontroller->start)); int setting = int64(255.0f * (flValue - pbonecontroller->start) / (pbonecontroller->end - pbonecontroller->start));
setting = Q_clamp(setting, 0, 255); setting = Q_clamp(setting, 0, 255);
pev->controller[ iController ] = setting; pev->controller[iController] = setting;
return setting * (1.0f / 255.0f) * (pbonecontroller->end - pbonecontroller->start) + pbonecontroller->start; return setting * (1.0f / 255.0f) * (pbonecontroller->end - pbonecontroller->start) + pbonecontroller->start;
} }
@ -693,12 +686,12 @@ mstudioanim_t *StudioGetAnim(model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc)
m_pSubModel->submodels = (dmodel_t *)paSequences; m_pSubModel->submodels = (dmodel_t *)paSequences;
} }
if (!IEngineStudio.Cache_Check((struct cache_user_s *)&(paSequences[ pseqdesc->seqgroup ]))) if (!IEngineStudio.Cache_Check((struct cache_user_s *)&(paSequences[pseqdesc->seqgroup])))
{ {
IEngineStudio.LoadCacheFile(pseqgroup->name, (struct cache_user_s *)&paSequences[ pseqdesc->seqgroup ]); IEngineStudio.LoadCacheFile(pseqgroup->name, (struct cache_user_s *)&paSequences[pseqdesc->seqgroup]);
} }
return (mstudioanim_t *)((byte *)paSequences[ pseqdesc->seqgroup ].data + pseqdesc->animindex); return (mstudioanim_t *)((byte *)paSequences[pseqdesc->seqgroup].data + pseqdesc->animindex);
} }
mstudioanim_t *LookupAnimation(model_t *model, mstudioseqdesc_t *pseqdesc, int index) mstudioanim_t *LookupAnimation(model_t *model, mstudioseqdesc_t *pseqdesc, int index)

View File

@ -812,7 +812,7 @@ int CBaseMonster::IRelationship(CBaseEntity *pTarget)
{ R_NO, R_NO, R_DL, R_DL, R_DL, R_AL, R_NO, R_DL, R_DL, R_NO, R_NO, R_DL, R_DL, R_NO }, // ABIOWEAPON { R_NO, R_NO, R_DL, R_DL, R_DL, R_AL, R_NO, R_DL, R_DL, R_NO, R_NO, R_DL, R_DL, R_NO }, // ABIOWEAPON
}; };
return iEnemy[ Classify() ][ pTarget->Classify() ]; return iEnemy[Classify()][pTarget->Classify()];
} }
// Base class monster function to find enemies or food by sight. // Base class monster function to find enemies or food by sight.

View File

@ -1,33 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CFuncRotating::m_SaveData[] =
{
DEFINE_FIELD(CFuncRotating, m_flFanFriction, FIELD_FLOAT),
DEFINE_FIELD(CFuncRotating, m_flAttenuation, FIELD_FLOAT),
DEFINE_FIELD(CFuncRotating, m_flVolume, FIELD_FLOAT),
DEFINE_FIELD(CFuncRotating, m_pitch, FIELD_FLOAT),
DEFINE_FIELD(CFuncRotating, m_sounds, FIELD_INTEGER)
};
TYPEDESCRIPTION CPendulum::m_SaveData[] =
{
DEFINE_FIELD(CPendulum, m_accel, FIELD_FLOAT),
DEFINE_FIELD(CPendulum, m_distance, FIELD_FLOAT),
DEFINE_FIELD(CPendulum, m_time, FIELD_TIME),
DEFINE_FIELD(CPendulum, m_damp, FIELD_FLOAT),
DEFINE_FIELD(CPendulum, m_maxSpeed, FIELD_FLOAT),
DEFINE_FIELD(CPendulum, m_dampSpeed, FIELD_FLOAT),
DEFINE_FIELD(CPendulum, m_center, FIELD_VECTOR),
DEFINE_FIELD(CPendulum, m_start, FIELD_VECTOR),
};
#endif
// BModelOrigin - calculates origin of a bmodel from absmin/size because all bmodel origins are 0 0 0 // BModelOrigin - calculates origin of a bmodel from absmin/size because all bmodel origins are 0 0 0
Vector VecBModelOrigin(entvars_t *pevBModel) Vector VecBModelOrigin(entvars_t *pevBModel)
{ {
@ -223,6 +195,15 @@ void CFuncMonsterClip::Spawn()
pev->flags |= FL_MONSTERCLIP; pev->flags |= FL_MONSTERCLIP;
} }
TYPEDESCRIPTION CFuncRotating::m_SaveData[] =
{
DEFINE_FIELD(CFuncRotating, m_flFanFriction, FIELD_FLOAT),
DEFINE_FIELD(CFuncRotating, m_flAttenuation, FIELD_FLOAT),
DEFINE_FIELD(CFuncRotating, m_flVolume, FIELD_FLOAT),
DEFINE_FIELD(CFuncRotating, m_pitch, FIELD_FLOAT),
DEFINE_FIELD(CFuncRotating, m_sounds, FIELD_INTEGER)
};
LINK_ENTITY_TO_CLASS(func_rotating, CFuncRotating, CCSFuncRotating) LINK_ENTITY_TO_CLASS(func_rotating, CFuncRotating, CCSFuncRotating)
IMPLEMENT_SAVERESTORE(CFuncRotating, CBaseEntity) IMPLEMENT_SAVERESTORE(CFuncRotating, CBaseEntity)
@ -687,6 +668,18 @@ void CFuncRotating::Blocked(CBaseEntity *pOther)
pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH); pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH);
} }
TYPEDESCRIPTION CPendulum::m_SaveData[] =
{
DEFINE_FIELD(CPendulum, m_accel, FIELD_FLOAT),
DEFINE_FIELD(CPendulum, m_distance, FIELD_FLOAT),
DEFINE_FIELD(CPendulum, m_time, FIELD_TIME),
DEFINE_FIELD(CPendulum, m_damp, FIELD_FLOAT),
DEFINE_FIELD(CPendulum, m_maxSpeed, FIELD_FLOAT),
DEFINE_FIELD(CPendulum, m_dampSpeed, FIELD_FLOAT),
DEFINE_FIELD(CPendulum, m_center, FIELD_VECTOR),
DEFINE_FIELD(CPendulum, m_start, FIELD_VECTOR),
};
LINK_ENTITY_TO_CLASS(func_pendulum, CPendulum, CCSPendulum) LINK_ENTITY_TO_CLASS(func_pendulum, CPendulum, CCSPendulum)
IMPLEMENT_SAVERESTORE(CPendulum, CBaseEntity) IMPLEMENT_SAVERESTORE(CPendulum, CBaseEntity)

View File

@ -144,7 +144,7 @@ public:
void RampPitchVol(BOOL fUp); void RampPitchVol(BOOL fUp);
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[5]; static TYPEDESCRIPTION m_SaveData[];
float m_flFanFriction; float m_flFanFriction;
float m_flAttenuation; float m_flAttenuation;
@ -183,7 +183,7 @@ public:
void EXPORT RopeTouch(CBaseEntity *pOther); void EXPORT RopeTouch(CBaseEntity *pOther);
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[8]; static TYPEDESCRIPTION m_SaveData[];
float m_accel; // acceleration float m_accel; // acceleration
float m_distance; float m_distance;

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
@ -565,15 +593,15 @@ void CCSBot::SetHidingSpotCheckTimestamp(HidingSpot *spot)
// if there is room for more spots, append this one // if there is room for more spots, append this one
if (m_checkedHidingSpotCount < MAX_CHECKED_SPOTS) if (m_checkedHidingSpotCount < MAX_CHECKED_SPOTS)
{ {
m_checkedHidingSpot[ m_checkedHidingSpotCount ].spot = spot; m_checkedHidingSpot[m_checkedHidingSpotCount].spot = spot;
m_checkedHidingSpot[ m_checkedHidingSpotCount ].timestamp = gpGlobals->time; m_checkedHidingSpot[m_checkedHidingSpotCount].timestamp = gpGlobals->time;
m_checkedHidingSpotCount++; m_checkedHidingSpotCount++;
} }
else else
{ {
// replace the least recent spot // replace the least recent spot
m_checkedHidingSpot[ leastRecent ].spot = spot; m_checkedHidingSpot[leastRecent].spot = spot;
m_checkedHidingSpot[ leastRecent ].timestamp = gpGlobals->time; m_checkedHidingSpot[leastRecent].timestamp = gpGlobals->time;
} }
} }
@ -840,7 +868,7 @@ const Vector *FindNearbyRetreatSpot(CCSBot *me, float maxRange)
// select a hiding spot at random // select a hiding spot at random
int which = RANDOM_LONG(0, collector.m_count - 1); int which = RANDOM_LONG(0, collector.m_count - 1);
return collector.m_spot[ which ]; return collector.m_spot[which];
} }
// Return euclidean distance to farthest escorted hostage. // Return euclidean distance to farthest escorted hostage.

View File

@ -45,12 +45,6 @@ enum
extern int _navAreaCount; extern int _navAreaCount;
extern int _currentIndex; extern int _currentIndex;
extern struct BuyInfo primaryWeaponBuyInfoCT[MAX_BUY_WEAPON_PRIMARY];
extern struct BuyInfo secondaryWeaponBuyInfoCT[MAX_BUY_WEAPON_SECONDARY];
extern struct BuyInfo primaryWeaponBuyInfoT[MAX_BUY_WEAPON_PRIMARY];
extern struct BuyInfo secondaryWeaponBuyInfoT[MAX_BUY_WEAPON_SECONDARY];
class CCSBot; class CCSBot;
class BotChatterInterface; class BotChatterInterface;

View File

@ -1,16 +1,37 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
#include <algorithm> #include <algorithm>
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
BotPhraseManager *TheBotPhrases = nullptr; BotPhraseManager *TheBotPhrases = nullptr;
CountdownTimer BotChatterInterface::m_encourageTimer; CountdownTimer BotChatterInterface::m_encourageTimer;
IntervalTimer BotChatterInterface::m_radioSilenceInterval[ 2 ]; IntervalTimer BotChatterInterface::m_radioSilenceInterval[2];
#endif
const Vector *GetRandomSpotAtPlace(Place place) const Vector *GetRandomSpotAtPlace(Place place)
{ {
@ -297,16 +318,16 @@ char *BotPhrase::GetSpeakable(int bankIndex, float *duration) const
} }
// find phrase that meets the current criteria // find phrase that meets the current criteria
int start = m_index[ bankIndex ]; int start = m_index[bankIndex];
while (true) while (true)
{ {
BotSpeakableVector *speakables = m_voiceBank[ bankIndex ]; BotSpeakableVector *speakables = m_voiceBank[bankIndex];
int &index = m_index[ bankIndex ]; int &index = m_index[bankIndex];
const BotSpeakable *speak = (*speakables)[index++]; const BotSpeakable *speak = (*speakables)[index++];
if (m_index[ bankIndex ] >= m_count[ bankIndex ]) if (m_index[bankIndex] >= m_count[bankIndex])
m_index[ bankIndex ] = 0; m_index[bankIndex] = 0;
// check place criteria // check place criteria
// if this speakable has a place criteria, it must match to be used // if this speakable has a place criteria, it must match to be used
@ -341,7 +362,6 @@ char *BotPhrase::GetSpeakable(int bankIndex, float *duration) const
} }
// Randomly shuffle the speakable order // Randomly shuffle the speakable order
#ifndef HOOK_GAMEDLL
void BotPhrase::Randomize() void BotPhrase::Randomize()
{ {
for (size_t i = 0; i < m_voiceBank.size(); i++) for (size_t i = 0; i < m_voiceBank.size(); i++)
@ -349,7 +369,6 @@ void BotPhrase::Randomize()
std::random_shuffle(m_voiceBank[i]->begin(), m_voiceBank[i]->end()); std::random_shuffle(m_voiceBank[i]->begin(), m_voiceBank[i]->end());
} }
} }
#endif
BotPhraseManager::BotPhraseManager() BotPhraseManager::BotPhraseManager()
{ {
@ -617,10 +636,10 @@ bool BotPhraseManager::Initialize(const char *filename, int bankIndex)
speak->m_duration = 1.0f; speak->m_duration = 1.0f;
} }
BotSpeakableVector *speakables = phrase->m_voiceBank[ bankIndex ]; BotSpeakableVector *speakables = phrase->m_voiceBank[bankIndex];
speakables->push_back(speak); speakables->push_back(speak);
phrase->m_count[ bankIndex ]++; phrase->m_count[bankIndex]++;
} }
if (isDefault) if (isDefault)
@ -792,7 +811,7 @@ void BotStatement::AttachMeme(BotMeme *meme)
void BotStatement::AddCondition(ConditionType condition) void BotStatement::AddCondition(ConditionType condition)
{ {
if (m_conditionCount < MAX_BOT_CONDITIONS) if (m_conditionCount < MAX_BOT_CONDITIONS)
m_condition[ m_conditionCount++ ] = condition; m_condition[m_conditionCount++] = condition;
} }
// Return true if this statement is "important" and not personality chatter // Return true if this statement is "important" and not personality chatter
@ -938,8 +957,9 @@ void BotStatement::AppendPhrase(const BotPhrase *phrase)
if (m_count < MAX_BOT_PHRASES) if (m_count < MAX_BOT_PHRASES)
{ {
m_statement[ m_count ].isPhrase = true; m_statement[m_count].isPhrase = true;
m_statement[ m_count++ ].phrase = phrase; m_statement[m_count].phrase = phrase;
m_count++;
} }
} }
@ -948,8 +968,9 @@ void BotStatement::AppendPhrase(ContextType contextPhrase)
{ {
if (m_count < MAX_BOT_PHRASES) if (m_count < MAX_BOT_PHRASES)
{ {
m_statement[ m_count ].isPhrase = false; m_statement[m_count].isPhrase = false;
m_statement[ m_count++ ].context = contextPhrase; m_statement[m_count].context = contextPhrase;
m_count++;
} }
} }
@ -970,7 +991,7 @@ bool BotStatement::Update()
} }
// special case - context dependent delay // special case - context dependent delay
if (m_index >= 0 && m_statement[ m_index ].context == ACCUMULATE_ENEMIES_DELAY) if (m_index >= 0 && m_statement[m_index].context == ACCUMULATE_ENEMIES_DELAY)
{ {
// report if we see a lot of enemies, or if enough time has passed // report if we see a lot of enemies, or if enough time has passed
const float reportTime = 2.0f; const float reportTime = 2.0f;
@ -999,15 +1020,15 @@ bool BotStatement::Update()
float duration = 0.0f; float duration = 0.0f;
const BotPhrase *phrase = nullptr; const BotPhrase *phrase = nullptr;
if (m_statement[ m_index ].isPhrase) if (m_statement[m_index].isPhrase)
{ {
// normal phrase // normal phrase
phrase = m_statement[ m_index ].phrase; phrase = m_statement[m_index].phrase;
} }
else else
{ {
// context-dependant phrase // context-dependant phrase
switch (m_statement[ m_index ].context) switch (m_statement[m_index].context)
{ {
case CURRENT_ENEMY_COUNT: case CURRENT_ENEMY_COUNT:
{ {
@ -1047,7 +1068,7 @@ bool BotStatement::Update()
} }
else else
{ {
phrase = TheBotPhrases->GetPhrase(speak[ enemyCount ]); phrase = TheBotPhrases->GetPhrase(speak[enemyCount]);
} }
break; break;
} }
@ -1247,7 +1268,7 @@ void BotChatterInterface::Reset()
m_heardNoiseTimer.Invalidate(); m_heardNoiseTimer.Invalidate();
m_scaredInterval.Invalidate(); m_scaredInterval.Invalidate();
m_planInterval.Invalidate(); m_planInterval.Invalidate();
IMPL(m_encourageTimer).Invalidate(); m_encourageTimer.Invalidate();
m_escortingHostageTimer.Invalidate(); m_escortingHostageTimer.Invalidate();
} }
@ -1571,7 +1592,7 @@ float BotChatterInterface::GetRadioSilenceDuration()
return 0; return 0;
#endif #endif
return IMPL(m_radioSilenceInterval)[m_me->m_iTeam - 1].GetElapsedTime(); return m_radioSilenceInterval[m_me->m_iTeam - 1].GetElapsedTime();
} }
void BotChatterInterface::ResetRadioSilenceDuration() void BotChatterInterface::ResetRadioSilenceDuration()
@ -1581,7 +1602,7 @@ void BotChatterInterface::ResetRadioSilenceDuration()
return; return;
#endif #endif
IMPL(m_radioSilenceInterval)[m_me->m_iTeam - 1].Reset(); m_radioSilenceInterval[m_me->m_iTeam - 1].Reset();
} }
inline void SayWhere(BotStatement *say, Place place) inline void SayWhere(BotStatement *say, Place place)
@ -2176,10 +2197,10 @@ NOXREF void BotChatterInterface::HostageDown()
void BotChatterInterface::Encourage(const char *phraseName, float repeatInterval, float lifetime) void BotChatterInterface::Encourage(const char *phraseName, float repeatInterval, float lifetime)
{ {
if (IMPL(m_encourageTimer).IsElapsed()) if (m_encourageTimer.IsElapsed())
{ {
Say(phraseName, lifetime); Say(phraseName, lifetime);
IMPL(m_encourageTimer).Start(repeatInterval); m_encourageTimer.Start(repeatInterval);
} }
} }

View File

@ -176,8 +176,8 @@ public:
CountCriteria m_count; CountCriteria m_count;
}; };
typedef std::STD_VECTOR<BotSpeakable *> BotSpeakableVector; typedef std::vector<BotSpeakable *> BotSpeakableVector;
typedef std::STD_VECTOR<BotSpeakableVector *> BotVoiceBankVector; typedef std::vector<BotSpeakableVector *> BotVoiceBankVector;
// The BotPhrase class is a collection of Speakables associated with a name, ID, and criteria // The BotPhrase class is a collection of Speakables associated with a name, ID, and criteria
class BotPhrase class BotPhrase
@ -210,8 +210,8 @@ private:
bool m_isImportant; // mission-critical statement bool m_isImportant; // mission-critical statement
mutable BotVoiceBankVector m_voiceBank; // array of voice banks (arrays of speakables) mutable BotVoiceBankVector m_voiceBank; // array of voice banks (arrays of speakables)
std::STD_VECTOR<int> m_count; // number of speakables std::vector<int> m_count; // number of speakables
mutable std::STD_VECTOR< int > m_index; // index of next speakable to return mutable std::vector< int > m_index; // index of next speakable to return
int m_numVoiceBanks; // number of voice banks that have been initialized int m_numVoiceBanks; // number of voice banks that have been initialized
void InitVoiceBank(int bankIndex); // sets up the vector of voice banks for the first bankIndex voice banks void InitVoiceBank(int bankIndex); // sets up the vector of voice banks for the first bankIndex voice banks
@ -219,7 +219,7 @@ private:
mutable CountCriteria m_countCriteria; mutable CountCriteria m_countCriteria;
}; };
typedef std::STD_LIST<BotPhrase *> BotPhraseList; typedef std::list<BotPhrase *> BotPhraseList;
inline void BotPhrase::ClearCriteria() const inline void BotPhrase::ClearCriteria() const
{ {
@ -538,7 +538,8 @@ private:
int m_pitch; int m_pitch;
static IntervalTimer IMPL(m_radioSilenceInterval)[2]; // one timer for each team static IntervalTimer m_radioSilenceInterval[]; // one timer for each team
static CountdownTimer m_encourageTimer; // timer to know when we can "encourage" the human player again - shared by all bots
IntervalTimer m_needBackupInterval; IntervalTimer m_needBackupInterval;
IntervalTimer m_spottedBomberInterval; IntervalTimer m_spottedBomberInterval;
@ -547,7 +548,6 @@ private:
CountdownTimer m_spottedLooseBombTimer; CountdownTimer m_spottedLooseBombTimer;
CountdownTimer m_heardNoiseTimer; CountdownTimer m_heardNoiseTimer;
CountdownTimer m_escortingHostageTimer; CountdownTimer m_escortingHostageTimer;
static CountdownTimer IMPL(m_encourageTimer); // timer to know when we can "encourage" the human player again - shared by all bots
}; };
inline BotChatterInterface::VerbosityType BotChatterInterface::GetVerbosity() const inline BotChatterInterface::VerbosityType BotChatterInterface::GetVerbosity() const

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) void CCSBot::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other)

View File

@ -1,9 +1,32 @@
#include "precompiled.h"
/* /*
* Globals initialization *
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/ */
#ifndef HOOK_GAMEDLL
#include "precompiled.h"
cvar_t cv_bot_traceview = { "bot_traceview", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_traceview = { "bot_traceview", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_bot_stop = { "bot_stop", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_stop = { "bot_stop", "0", FCVAR_SERVER, 0.0f, nullptr };
@ -35,8 +58,6 @@ cvar_t cv_bot_defer_to_human = { "bot_defer_to_human", "0", FCVAR_SERVER, 0.0f,
cvar_t cv_bot_chatter = { "bot_chatter", "normal", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_chatter = { "bot_chatter", "normal", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_bot_profile_db = { "bot_profile_db", "BotProfile.db", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_profile_db = { "bot_profile_db", "BotProfile.db", FCVAR_SERVER, 0.0f, nullptr };
#endif
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
cvar_t cv_bot_deathmatch = { "bot_deathmatch", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_deathmatch = { "bot_deathmatch", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_bot_quota_mode = { "bot_quota_mode", "normal", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_bot_quota_mode = { "bot_quota_mode", "normal", FCVAR_SERVER, 0.0f, nullptr };

View File

@ -0,0 +1,64 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#pragma once
extern cvar_t cv_bot_traceview;
extern cvar_t cv_bot_stop;
extern cvar_t cv_bot_show_nav;
extern cvar_t cv_bot_show_danger;
extern cvar_t cv_bot_nav_edit;
extern cvar_t cv_bot_nav_zdraw;
extern cvar_t cv_bot_walk;
extern cvar_t cv_bot_difficulty;
extern cvar_t cv_bot_debug;
extern cvar_t cv_bot_quicksave;
extern cvar_t cv_bot_quota;
extern cvar_t cv_bot_quota_match;
extern cvar_t cv_bot_prefix;
extern cvar_t cv_bot_allow_rogues;
extern cvar_t cv_bot_allow_pistols;
extern cvar_t cv_bot_allow_shotguns;
extern cvar_t cv_bot_allow_sub_machine_guns;
extern cvar_t cv_bot_allow_rifles;
extern cvar_t cv_bot_allow_machine_guns;
extern cvar_t cv_bot_allow_grenades;
extern cvar_t cv_bot_allow_snipers;
extern cvar_t cv_bot_allow_shield;
extern cvar_t cv_bot_join_team;
extern cvar_t cv_bot_join_after_player;
extern cvar_t cv_bot_auto_vacate;
extern cvar_t cv_bot_zombie;
extern cvar_t cv_bot_defer_to_human;
extern cvar_t cv_bot_chatter;
extern cvar_t cv_bot_profile_db;
#ifdef REGAMEDLL_ADD
extern cvar_t cv_bot_deathmatch;
extern cvar_t cv_bot_quota_mode;
#endif

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
const float updateTimesliceDuration = 0.5f; const float updateTimesliceDuration = 0.5f;

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Listen for enemy noises, and determine if we should react to them. // Listen for enemy noises, and determine if we should react to them.

View File

@ -1,9 +1,32 @@
#include "precompiled.h"
/* /*
* Globals initialization *
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/ */
#ifndef HOOK_GAMEDLL
#include "precompiled.h"
CBotManager *TheBots = nullptr; CBotManager *TheBots = nullptr;
@ -13,11 +36,9 @@ bool CCSBotManager::m_isLearningMap = false;
bool CCSBotManager::m_isAnalysisRequested = false; bool CCSBotManager::m_isAnalysisRequested = false;
NavEditCmdType CCSBotManager::m_editCmd = EDIT_NONE; NavEditCmdType CCSBotManager::m_editCmd = EDIT_NONE;
#endif
CCSBotManager::CCSBotManager() CCSBotManager::CCSBotManager()
{ {
IMPL(m_flNextCVarCheck) = 0.0f; m_flNextCVarCheck = 0.0f;
m_zoneCount = 0; m_zoneCount = 0;
SetLooseBomb(nullptr); SetLooseBomb(nullptr);
@ -25,9 +46,9 @@ CCSBotManager::CCSBotManager()
m_isBombPlanted = false; m_isBombPlanted = false;
m_bombDefuser = nullptr; m_bombDefuser = nullptr;
IMPL(m_isLearningMap) = false; m_isLearningMap = false;
IMPL(m_isAnalysisRequested) = false; m_isAnalysisRequested = false;
IMPL(m_editCmd) = EDIT_NONE; m_editCmd = EDIT_NONE;
m_navPlace = 0; m_navPlace = 0;
m_roundStartTimestamp = 0.0f; m_roundStartTimestamp = 0.0f;
@ -96,7 +117,7 @@ void CCSBotManager::RestartRound()
m_earliestBombPlantTimestamp = gpGlobals->time + RANDOM_FLOAT(10.0f, 30.0f); m_earliestBombPlantTimestamp = gpGlobals->time + RANDOM_FLOAT(10.0f, 30.0f);
m_bombDefuser = nullptr; m_bombDefuser = nullptr;
IMPL(m_editCmd) = EDIT_NONE; m_editCmd = EDIT_NONE;
ResetRadioMessageTimestamps(); ResetRadioMessageTimestamps();
@ -114,59 +135,7 @@ void CCSBotManager::RestartRound()
m_canRespawn = true; m_canRespawn = true;
} }
void UTIL_DrawBox(Extent *extent, int lifetime, int red, int green, int blue)
{
Vector v[8];
v[0].x = extent->lo.x; v[0].y = extent->lo.y; v[0].z = extent->lo.z;
v[1].x = extent->hi.x; v[1].y = extent->lo.y; v[1].z = extent->lo.z;
v[2].x = extent->hi.x; v[2].y = extent->hi.y; v[2].z = extent->lo.z;
v[3].x = extent->lo.x; v[3].y = extent->hi.y; v[3].z = extent->lo.z;
v[4].x = extent->lo.x; v[4].y = extent->lo.y; v[4].z = extent->hi.z;
v[5].x = extent->hi.x; v[5].y = extent->lo.y; v[5].z = extent->hi.z;
v[6].x = extent->hi.x; v[6].y = extent->hi.y; v[6].z = extent->hi.z;
v[7].x = extent->lo.x; v[7].y = extent->hi.y; v[7].z = extent->hi.z;
static int edge[] =
{
1, 2, 3, 4, -1,
5, 6, 7, 8, -5,
1, -5,
2, -6,
3, -7,
4, -8,
0 // end iterator
};
Vector from, to;
bool restart = true;
for (int i = 0; edge[i] != 0; i++)
{
if (restart)
{
to = v[ edge[i] - 1 ];
restart = false;
continue;
}
from = to;
int index = edge[i];
if (index < 0)
{
restart = true;
index = -index;
}
to = v[ index - 1 ];
UTIL_DrawBeamPoints(from, to, lifetime, red, green, blue);
UTIL_DrawBeamPoints(to, from, lifetime, red, green, blue);
}
}
// Called each frame // Called each frame
void CCSBotManager::StartFrame() void CCSBotManager::StartFrame()
{ {
// EXTEND // EXTEND
@ -244,7 +213,7 @@ bool CCSBotManager::IsOnOffense(CBasePlayer *player) const
void CCSBotManager::ServerActivate() void CCSBotManager::ServerActivate()
{ {
DestroyNavigationMap(); DestroyNavigationMap();
IMPL(m_isMapDataLoaded) = false; m_isMapDataLoaded = false;
m_zoneCount = 0; m_zoneCount = 0;
m_gameScenario = SCENARIO_DEATHMATCH; m_gameScenario = SCENARIO_DEATHMATCH;
@ -252,8 +221,8 @@ void CCSBotManager::ServerActivate()
ValidateMapData(); ValidateMapData();
RestartRound(); RestartRound();
IMPL(m_isLearningMap) = false; m_isLearningMap = false;
IMPL(m_isAnalysisRequested) = false; m_isAnalysisRequested = false;
m_bServerActive = true; m_bServerActive = true;
AddServerCommands(); AddServerCommands();
@ -510,59 +479,59 @@ void CCSBotManager::ServerCommand(const char *pcmd)
} }
else if (FStrEq(pcmd, "bot_nav_delete")) else if (FStrEq(pcmd, "bot_nav_delete"))
{ {
IMPL(m_editCmd) = EDIT_DELETE; m_editCmd = EDIT_DELETE;
} }
else if (FStrEq(pcmd, "bot_nav_split")) else if (FStrEq(pcmd, "bot_nav_split"))
{ {
IMPL(m_editCmd) = EDIT_SPLIT; m_editCmd = EDIT_SPLIT;
} }
else if (FStrEq(pcmd, "bot_nav_merge")) else if (FStrEq(pcmd, "bot_nav_merge"))
{ {
IMPL(m_editCmd) = EDIT_MERGE; m_editCmd = EDIT_MERGE;
} }
else if (FStrEq(pcmd, "bot_nav_mark")) else if (FStrEq(pcmd, "bot_nav_mark"))
{ {
IMPL(m_editCmd) = EDIT_MARK; m_editCmd = EDIT_MARK;
} }
else if (FStrEq(pcmd, "bot_nav_begin_area")) else if (FStrEq(pcmd, "bot_nav_begin_area"))
{ {
IMPL(m_editCmd) = EDIT_BEGIN_AREA; m_editCmd = EDIT_BEGIN_AREA;
} }
else if (FStrEq(pcmd, "bot_nav_end_area")) else if (FStrEq(pcmd, "bot_nav_end_area"))
{ {
IMPL(m_editCmd) = EDIT_END_AREA; m_editCmd = EDIT_END_AREA;
} }
else if (FStrEq(pcmd, "bot_nav_connect")) else if (FStrEq(pcmd, "bot_nav_connect"))
{ {
IMPL(m_editCmd) = EDIT_CONNECT; m_editCmd = EDIT_CONNECT;
} }
else if (FStrEq(pcmd, "bot_nav_disconnect")) else if (FStrEq(pcmd, "bot_nav_disconnect"))
{ {
IMPL(m_editCmd) = EDIT_DISCONNECT; m_editCmd = EDIT_DISCONNECT;
} }
else if (FStrEq(pcmd, "bot_nav_splice")) else if (FStrEq(pcmd, "bot_nav_splice"))
{ {
IMPL(m_editCmd) = EDIT_SPLICE; m_editCmd = EDIT_SPLICE;
} }
else if (FStrEq(pcmd, "bot_nav_crouch")) else if (FStrEq(pcmd, "bot_nav_crouch"))
{ {
IMPL(m_editCmd) = EDIT_ATTRIB_CROUCH; m_editCmd = EDIT_ATTRIB_CROUCH;
} }
else if (FStrEq(pcmd, "bot_nav_jump")) else if (FStrEq(pcmd, "bot_nav_jump"))
{ {
IMPL(m_editCmd) = EDIT_ATTRIB_JUMP; m_editCmd = EDIT_ATTRIB_JUMP;
} }
else if (FStrEq(pcmd, "bot_nav_precise")) else if (FStrEq(pcmd, "bot_nav_precise"))
{ {
IMPL(m_editCmd) = EDIT_ATTRIB_PRECISE; m_editCmd = EDIT_ATTRIB_PRECISE;
} }
else if (FStrEq(pcmd, "bot_nav_no_jump")) else if (FStrEq(pcmd, "bot_nav_no_jump"))
{ {
IMPL(m_editCmd) = EDIT_ATTRIB_NO_JUMP; m_editCmd = EDIT_ATTRIB_NO_JUMP;
} }
else if (FStrEq(pcmd, "bot_nav_analyze")) else if (FStrEq(pcmd, "bot_nav_analyze"))
{ {
IMPL(m_isAnalysisRequested) = true; m_isAnalysisRequested = true;
} }
else if (FStrEq(pcmd, "bot_nav_strip")) else if (FStrEq(pcmd, "bot_nav_strip"))
{ {
@ -645,19 +614,19 @@ void CCSBotManager::ServerCommand(const char *pcmd)
} }
else if (FStrEq(pcmd, "bot_nav_toggle_place_mode")) else if (FStrEq(pcmd, "bot_nav_toggle_place_mode"))
{ {
IMPL(m_editCmd) = EDIT_TOGGLE_PLACE_MODE; m_editCmd = EDIT_TOGGLE_PLACE_MODE;
} }
else if (FStrEq(pcmd, "bot_nav_place_floodfill")) else if (FStrEq(pcmd, "bot_nav_place_floodfill"))
{ {
IMPL(m_editCmd) = EDIT_PLACE_FLOODFILL; m_editCmd = EDIT_PLACE_FLOODFILL;
} }
else if (FStrEq(pcmd, "bot_nav_place_pick")) else if (FStrEq(pcmd, "bot_nav_place_pick"))
{ {
IMPL(m_editCmd) = EDIT_PLACE_PICK; m_editCmd = EDIT_PLACE_PICK;
} }
else if (FStrEq(pcmd, "bot_nav_toggle_place_painting")) else if (FStrEq(pcmd, "bot_nav_toggle_place_painting"))
{ {
IMPL(m_editCmd) = EDIT_TOGGLE_PLACE_PAINTING; m_editCmd = EDIT_TOGGLE_PLACE_PAINTING;
} }
else if (FStrEq(pcmd, "bot_goto_mark")) else if (FStrEq(pcmd, "bot_goto_mark"))
{ {
@ -716,23 +685,23 @@ void CCSBotManager::ServerCommand(const char *pcmd)
} }
else if (FStrEq(pcmd, "bot_nav_mark_unnamed")) else if (FStrEq(pcmd, "bot_nav_mark_unnamed"))
{ {
IMPL(m_editCmd) = EDIT_MARK_UNNAMED; m_editCmd = EDIT_MARK_UNNAMED;
} }
else if (FStrEq(pcmd, "bot_nav_warp")) else if (FStrEq(pcmd, "bot_nav_warp"))
{ {
IMPL(m_editCmd) = EDIT_WARP_TO_MARK; m_editCmd = EDIT_WARP_TO_MARK;
} }
else if (FStrEq(pcmd, "bot_nav_corner_select")) else if (FStrEq(pcmd, "bot_nav_corner_select"))
{ {
IMPL(m_editCmd) = EDIT_SELECT_CORNER; m_editCmd = EDIT_SELECT_CORNER;
} }
else if (FStrEq(pcmd, "bot_nav_corner_raise")) else if (FStrEq(pcmd, "bot_nav_corner_raise"))
{ {
IMPL(m_editCmd) = EDIT_RAISE_CORNER; m_editCmd = EDIT_RAISE_CORNER;
} }
else if (FStrEq(pcmd, "bot_nav_corner_lower")) else if (FStrEq(pcmd, "bot_nav_corner_lower"))
{ {
IMPL(m_editCmd) = EDIT_LOWER_CORNER; m_editCmd = EDIT_LOWER_CORNER;
} }
else if (FStrEq(pcmd, "bot_nav_check_consistency")) else if (FStrEq(pcmd, "bot_nav_check_consistency"))
{ {
@ -762,11 +731,10 @@ BOOL CCSBotManager::ClientCommand(CBasePlayer *pPlayer, const char *pcmd)
bool CCSBotManager::BotAddCommand(BotProfileTeamType team, bool isFromConsole) bool CCSBotManager::BotAddCommand(BotProfileTeamType team, bool isFromConsole)
{ {
// dont allow bots to join if the Navigation Area is being generated // dont allow bots to join if the Navigation Area is being generated
if (IMPL(m_isLearningMap)) if (m_isLearningMap)
return false; return false;
const BotProfile *profile = nullptr; const BotProfile *profile = nullptr;
if (!isFromConsole || CMD_ARGC() < 2) if (!isFromConsole || CMD_ARGC() < 2)
{ {
// if team not specified, check cv_bot_join_team cvar for preference // if team not specified, check cv_bot_join_team cvar for preference
@ -838,7 +806,7 @@ void CCSBotManager::MaintainBotQuota()
return; return;
#endif #endif
if (IMPL(m_isLearningMap)) if (m_isLearningMap)
return; return;
int totalHumansInGame = UTIL_HumansInGame(); int totalHumansInGame = UTIL_HumansInGame();
@ -961,17 +929,17 @@ void CCSBotManager::MonitorBotCVars()
{ {
if (cv_bot_nav_edit.value != 0.0f) if (cv_bot_nav_edit.value != 0.0f)
{ {
EditNavAreas(IMPL(m_editCmd)); EditNavAreas(m_editCmd);
IMPL(m_editCmd) = EDIT_NONE; m_editCmd = EDIT_NONE;
} }
if (gpGlobals->time >= IMPL(m_flNextCVarCheck)) if (gpGlobals->time >= m_flNextCVarCheck)
{ {
if (cv_bot_show_danger.value != 0.0f) if (cv_bot_show_danger.value != 0.0f)
DrawDanger(); DrawDanger();
MaintainBotQuota(); MaintainBotQuota();
IMPL(m_flNextCVarCheck) = gpGlobals->time + 0.3f; m_flNextCVarCheck = gpGlobals->time + 0.3f;
} }
} }
@ -993,7 +961,7 @@ class CollectOverlappingAreas
&& areaExtent->hi.z >= m_zone->m_extent.lo.z && areaExtent->lo.z <= m_zone->m_extent.hi.z) && areaExtent->hi.z >= m_zone->m_extent.lo.z && areaExtent->lo.z <= m_zone->m_extent.hi.z)
{ {
// area overlaps m_zone // area overlaps m_zone
m_zone->m_area[ m_zone->m_areaCount++ ] = area; m_zone->m_area[m_zone->m_areaCount++] = area;
if (m_zone->m_areaCount == CCSBotManager::MAX_ZONE_NAV_AREAS) if (m_zone->m_areaCount == CCSBotManager::MAX_ZONE_NAV_AREAS)
{ {
return false; return false;
@ -1010,10 +978,10 @@ class CollectOverlappingAreas
// Search the map entities to determine the game scenario and define important zones. // Search the map entities to determine the game scenario and define important zones.
void CCSBotManager::ValidateMapData() void CCSBotManager::ValidateMapData()
{ {
if (IMPL(m_isMapDataLoaded) || !AreBotsAllowed()) if (m_isMapDataLoaded || !AreBotsAllowed())
return; return;
IMPL(m_isMapDataLoaded) = true; m_isMapDataLoaded = true;
if (LoadNavigationMap()) if (LoadNavigationMap())
{ {
@ -1079,10 +1047,10 @@ void CCSBotManager::ValidateMapData()
{ {
if (m_zoneCount < MAX_ZONES) if (m_zoneCount < MAX_ZONES)
{ {
m_zone[ m_zoneCount ].m_center = isLegacy ? pEntity->pev->origin : (pEntity->pev->absmax + pEntity->pev->absmin) / 2.0f; m_zone[m_zoneCount].m_center = isLegacy ? pEntity->pev->origin : (pEntity->pev->absmax + pEntity->pev->absmin) / 2.0f;
m_zone[ m_zoneCount ].m_isLegacy = isLegacy; m_zone[m_zoneCount].m_isLegacy = isLegacy;
m_zone[ m_zoneCount ].m_index = m_zoneCount; m_zone[m_zoneCount].m_index = m_zoneCount;
m_zone[ m_zoneCount ].m_entity = pEntity; m_zone[m_zoneCount].m_entity = pEntity;
m_zoneCount++; m_zoneCount++;
} }
else else
@ -1110,10 +1078,10 @@ void CCSBotManager::ValidateMapData()
if (m_zoneCount < MAX_ZONES) if (m_zoneCount < MAX_ZONES)
{ {
m_zone[ m_zoneCount ].m_center = pEntity->pev->origin; m_zone[m_zoneCount].m_center = pEntity->pev->origin;
m_zone[ m_zoneCount ].m_isLegacy = true; m_zone[m_zoneCount].m_isLegacy = true;
m_zone[ m_zoneCount ].m_index = m_zoneCount; m_zone[m_zoneCount].m_index = m_zoneCount;
m_zone[ m_zoneCount ].m_entity = pEntity; m_zone[m_zoneCount].m_entity = pEntity;
m_zoneCount++; m_zoneCount++;
} }
else else
@ -1306,7 +1274,7 @@ CNavArea *CCSBotManager::GetRandomAreaInZone(const Zone *zone) const
if (!zone->m_areaCount) if (!zone->m_areaCount)
return nullptr; return nullptr;
return zone->m_area[ RANDOM_LONG(0, zone->m_areaCount - 1) ]; return zone->m_area[RANDOM_LONG(0, zone->m_areaCount - 1)];
} }
void CCSBotManager::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other) void CCSBotManager::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEntity *other)
@ -1455,7 +1423,7 @@ float CCSBotManager::GetRadioMessageTimestamp(GameEventType event, int teamID) c
return 0.0f; return 0.0f;
int i = (teamID == TERRORIST) ? 0 : 1; int i = (teamID == TERRORIST) ? 0 : 1;
return m_radioMsgTimestamp[ event - EVENT_START_RADIO_1 ][ i ]; return m_radioMsgTimestamp[event - EVENT_START_RADIO_1][i];
} }
// Return the interval since the last time this message was sent // Return the interval since the last time this message was sent
@ -1465,7 +1433,7 @@ float CCSBotManager::GetRadioMessageInterval(GameEventType event, int teamID) co
return 99999999.9f; return 99999999.9f;
int i = (teamID == TERRORIST) ? 0 : 1; int i = (teamID == TERRORIST) ? 0 : 1;
return gpGlobals->time - m_radioMsgTimestamp[ event - EVENT_START_RADIO_1 ][ i ]; return gpGlobals->time - m_radioMsgTimestamp[event - EVENT_START_RADIO_1][i];
} }
// Set the given radio message timestamp. // Set the given radio message timestamp.
@ -1476,7 +1444,7 @@ void CCSBotManager::SetRadioMessageTimestamp(GameEventType event, int teamID)
return; return;
int i = (teamID == TERRORIST) ? 0 : 1; int i = (teamID == TERRORIST) ? 0 : 1;
m_radioMsgTimestamp[ event - EVENT_START_RADIO_1 ][ i ] = gpGlobals->time; m_radioMsgTimestamp[event - EVENT_START_RADIO_1][i] = gpGlobals->time;
} }
// Reset all radio message timestamps // Reset all radio message timestamps

View File

@ -28,6 +28,8 @@
#pragma once #pragma once
#include "cs_bot_init.h"
extern CBotManager *TheBots; extern CBotManager *TheBots;
// The manager for Counter-Strike specific bots // The manager for Counter-Strike specific bots
@ -56,11 +58,11 @@ public:
public: public:
void ValidateMapData(); void ValidateMapData();
void OnFreeEntPrivateData(CBaseEntity *pEntity); void OnFreeEntPrivateData(CBaseEntity *pEntity);
bool IsLearningMap() const { return IMPL(m_isLearningMap); } bool IsLearningMap() const { return m_isLearningMap; }
void SetLearningMapFlag() { IMPL(m_isLearningMap) = true; } void SetLearningMapFlag() { m_isLearningMap = true; }
bool IsAnalysisRequested() const { return IMPL(m_isAnalysisRequested); } bool IsAnalysisRequested() const { return m_isAnalysisRequested; }
void RequestAnalysis() { IMPL(m_isAnalysisRequested) = true; } void RequestAnalysis() { m_isAnalysisRequested = true; }
void AckAnalysisRequest() { IMPL(m_isAnalysisRequested) = false; } void AckAnalysisRequest() { m_isAnalysisRequested = false; }
// difficulty levels // difficulty levels
static BotDifficultyType GetDifficultyLevel() static BotDifficultyType GetDifficultyLevel()
@ -85,6 +87,7 @@ public:
SCENARIO_RESCUE_HOSTAGES, SCENARIO_RESCUE_HOSTAGES,
SCENARIO_ESCORT_VIP SCENARIO_ESCORT_VIP
}; };
GameScenarioType GetScenario() const GameScenarioType GetScenario() const
{ {
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
@ -213,10 +216,10 @@ public:
bool BotAddCommand(BotProfileTeamType team, bool isFromConsole = false); // process the "bot_add" console command bool BotAddCommand(BotProfileTeamType team, bool isFromConsole = false); // process the "bot_add" console command
private: private:
static float IMPL(m_flNextCVarCheck); static float m_flNextCVarCheck;
static bool IMPL(m_isMapDataLoaded); // true if we've attempted to load map data static bool m_isMapDataLoaded; // true if we've attempted to load map data
static bool IMPL(m_isLearningMap); static bool m_isLearningMap;
static bool IMPL(m_isAnalysisRequested); static bool m_isAnalysisRequested;
GameScenarioType m_gameScenario; // what kind of game are we playing GameScenarioType m_gameScenario; // what kind of game are we playing
@ -239,7 +242,7 @@ private:
bool m_isDefenseRushing; // whether defensive team is rushing this round or not bool m_isDefenseRushing; // whether defensive team is rushing this round or not
static NavEditCmdType IMPL(m_editCmd); static NavEditCmdType m_editCmd;
unsigned int m_navPlace; unsigned int m_navPlace;
CountdownTimer m_respawnTimer; CountdownTimer m_respawnTimer;
bool m_isRespawnStarted; bool m_isRespawnStarted;
@ -264,4 +267,3 @@ inline bool AreBotsAllowed()
} }
void PrintAllEntities(); void PrintAllEntities();
void UTIL_DrawBox(Extent *extent, int lifetime, int red, int green, int blue);

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Reset the stuck-checker. // Reset the stuck-checker.
@ -51,7 +79,7 @@ void CCSBot::StuckCheck()
float moveDist = vel.Length(); float moveDist = vel.Length();
float deltaT = g_flBotFullThinkInterval; float deltaT = g_flBotFullThinkInterval;
m_avgVel[ m_avgVelIndex++ ] = moveDist / deltaT; m_avgVel[m_avgVelIndex++] = moveDist / deltaT;
if (m_avgVelIndex == MAX_VEL_SAMPLES) if (m_avgVelIndex == MAX_VEL_SAMPLES)
m_avgVelIndex = 0; m_avgVelIndex = 0;
@ -258,7 +286,7 @@ void CCSBot::MoveTowardsPosition(const Vector *pos)
NOXREF void CCSBot::MoveAwayFromPosition(const Vector *pos) NOXREF void CCSBot::MoveAwayFromPosition(const Vector *pos)
{ {
// compute our current forward and lateral vectors // compute our current forward and lateral vectors
float angle = pev->v_angle[ YAW ]; float angle = pev->v_angle[YAW];
Vector2D dir(BotCOS(angle), BotSIN(angle)); Vector2D dir(BotCOS(angle), BotSIN(angle));
Vector2D lat(-dir.y, dir.x); Vector2D lat(-dir.y, dir.x);
@ -287,7 +315,7 @@ NOXREF void CCSBot::MoveAwayFromPosition(const Vector *pos)
void CCSBot::StrafeAwayFromPosition(const Vector *pos) void CCSBot::StrafeAwayFromPosition(const Vector *pos)
{ {
// compute our current forward and lateral vectors // compute our current forward and lateral vectors
float angle = pev->v_angle[ YAW ]; float angle = pev->v_angle[YAW];
Vector2D dir(BotCOS(angle), BotSIN(angle)); Vector2D dir(BotCOS(angle), BotSIN(angle));
Vector2D lat(-dir.y, dir.x); Vector2D lat(-dir.y, dir.x);
@ -400,7 +428,7 @@ void CCSBot::ComputeApproachPoints()
Vector bendPoint; Vector bendPoint;
if (BendLineOfSight(&eye, &ap, &bendPoint)) if (BendLineOfSight(&eye, &ap, &bendPoint))
{ {
m_approachPoint[ m_approachPointCount++ ] = bendPoint; m_approachPoint[m_approachPointCount++] = bendPoint;
} }
} }
} }

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Determine actual path positions bot will move between along the path // Determine actual path positions bot will move between along the path
@ -14,7 +42,7 @@ bool CCSBot::ComputePathPositions()
for (int i = 1; i < m_pathLength; i++) for (int i = 1; i < m_pathLength; i++)
{ {
const ConnectInfo *from = &m_path[i - 1]; const ConnectInfo *from = &m_path[i - 1];
ConnectInfo *to = &m_path[ i ]; ConnectInfo *to = &m_path[i ];
// walk along the floor to the next area // walk along the floor to the next area
if (to->how <= GO_WEST) if (to->how <= GO_WEST)
@ -128,7 +156,7 @@ void CCSBot::SetupLadderMovement()
if (m_pathIndex < 1 || m_pathLength == 0) if (m_pathIndex < 1 || m_pathLength == 0)
return; return;
const ConnectInfo *to = &m_path[ m_pathIndex ]; const ConnectInfo *to = &m_path[m_pathIndex];
if (to->ladder) if (to->ladder)
{ {
@ -337,7 +365,7 @@ bool CCSBot::UpdateLadderMovement()
PrintIfWatched("Fell from ladder.\n"); PrintIfWatched("Fell from ladder.\n");
m_pathLadderState = MOVE_TO_DESTINATION; m_pathLadderState = MOVE_TO_DESTINATION;
m_path[ m_pathIndex ].area->GetClosestPointOnArea(&m_pathLadder->m_bottom, &m_goalPosition); m_path[m_pathIndex].area->GetClosestPointOnArea(&m_pathLadder->m_bottom, &m_goalPosition);
AddDirectionVector(&m_goalPosition, m_pathLadder->m_dir, HalfHumanWidth); AddDirectionVector(&m_goalPosition, m_pathLadder->m_dir, HalfHumanWidth);
PrintIfWatched("MOVE_TO_DESTINATION\n"); PrintIfWatched("MOVE_TO_DESTINATION\n");
@ -443,7 +471,7 @@ bool CCSBot::UpdateLadderMovement()
PrintIfWatched("Fell from ladder.\n"); PrintIfWatched("Fell from ladder.\n");
m_pathLadderState = MOVE_TO_DESTINATION; m_pathLadderState = MOVE_TO_DESTINATION;
m_path[ m_pathIndex ].area->GetClosestPointOnArea(&m_pathLadder->m_bottom, &m_goalPosition); m_path[m_pathIndex].area->GetClosestPointOnArea(&m_pathLadder->m_bottom, &m_goalPosition);
AddDirectionVector(&m_goalPosition, m_pathLadder->m_dir, HalfHumanWidth); AddDirectionVector(&m_goalPosition, m_pathLadder->m_dir, HalfHumanWidth);
PrintIfWatched("MOVE_TO_DESTINATION\n"); PrintIfWatched("MOVE_TO_DESTINATION\n");
@ -470,7 +498,7 @@ bool CCSBot::UpdateLadderMovement()
Run(); Run();
// if our destination area requires us to crouch, do it // if our destination area requires us to crouch, do it
if (m_path[ m_pathIndex ].area->GetAttributes() & NAV_CROUCH) if (m_path[m_pathIndex].area->GetAttributes() & NAV_CROUCH)
Crouch(); Crouch();
// did we reach the top? // did we reach the top?
@ -480,11 +508,11 @@ bool CCSBot::UpdateLadderMovement()
m_pathLadderState = DISMOUNT_ASCENDING_LADDER; m_pathLadderState = DISMOUNT_ASCENDING_LADDER;
PrintIfWatched("DISMOUNT_ASCENDING_LADDER\n"); PrintIfWatched("DISMOUNT_ASCENDING_LADDER\n");
if (m_path[ m_pathIndex ].area == m_pathLadder->m_topForwardArea) if (m_path[m_pathIndex].area == m_pathLadder->m_topForwardArea)
m_pathLadderDismountDir = FORWARD; m_pathLadderDismountDir = FORWARD;
else if (m_path[ m_pathIndex ].area == m_pathLadder->m_topLeftArea) else if (m_path[m_pathIndex].area == m_pathLadder->m_topLeftArea)
m_pathLadderDismountDir = LEFT; m_pathLadderDismountDir = LEFT;
else if (m_path[ m_pathIndex ].area == m_pathLadder->m_topRightArea) else if (m_path[m_pathIndex].area == m_pathLadder->m_topRightArea)
m_pathLadderDismountDir = RIGHT; m_pathLadderDismountDir = RIGHT;
m_pathLadderDismountTimestamp = gpGlobals->time; m_pathLadderDismountTimestamp = gpGlobals->time;
@ -509,7 +537,7 @@ bool CCSBot::UpdateLadderMovement()
{ {
// we reached the bottom, or we fell off - dismount // we reached the bottom, or we fell off - dismount
m_pathLadderState = MOVE_TO_DESTINATION; m_pathLadderState = MOVE_TO_DESTINATION;
m_path[ m_pathIndex ].area->GetClosestPointOnArea(&m_pathLadder->m_bottom, &m_goalPosition); m_path[m_pathIndex].area->GetClosestPointOnArea(&m_pathLadder->m_bottom, &m_goalPosition);
AddDirectionVector(&m_goalPosition, m_pathLadder->m_dir, HalfHumanWidth); AddDirectionVector(&m_goalPosition, m_pathLadder->m_dir, HalfHumanWidth);
PrintIfWatched("MOVE_TO_DESTINATION\n"); PrintIfWatched("MOVE_TO_DESTINATION\n");
@ -524,7 +552,7 @@ bool CCSBot::UpdateLadderMovement()
if (gpGlobals->time - m_pathLadderDismountTimestamp >= 0.4f) if (gpGlobals->time - m_pathLadderDismountTimestamp >= 0.4f)
{ {
m_pathLadderState = MOVE_TO_DESTINATION; m_pathLadderState = MOVE_TO_DESTINATION;
m_path[ m_pathIndex ].area->GetClosestPointOnArea(&pev->origin, &m_goalPosition); m_path[m_pathIndex].area->GetClosestPointOnArea(&pev->origin, &m_goalPosition);
PrintIfWatched("MOVE_TO_DESTINATION\n"); PrintIfWatched("MOVE_TO_DESTINATION\n");
} }
@ -551,7 +579,7 @@ bool CCSBot::UpdateLadderMovement()
} }
case MOVE_TO_DESTINATION: case MOVE_TO_DESTINATION:
{ {
if (m_path[ m_pathIndex ].area->Contains(&pev->origin)) if (m_path[m_pathIndex].area->Contains(&pev->origin))
{ {
// successfully traversed ladder and reached destination area // successfully traversed ladder and reached destination area
// exit ladder state machine // exit ladder state machine
@ -796,7 +824,7 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex)
if (index >= m_pathLength) if (index >= m_pathLength)
index = m_pathLength - 1; index = m_pathLength - 1;
*point = m_path[ index ].pos; *point = m_path[index].pos;
// if we are very close to the next point in the path, skip ahead to the next one to avoid wiggling // if we are very close to the next point in the path, skip ahead to the next one to avoid wiggling
// we must do a 2D check here, in case the goal point is floating in space due to jump down, etc // we must do a 2D check here, in case the goal point is floating in space due to jump down, etc
@ -811,7 +839,7 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex)
break; break;
} }
*point = m_path[ index ].pos; *point = m_path[index].pos;
} }
return index; return index;
@ -820,7 +848,7 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex)
// make sure we use a node a minimum distance ahead of us, to avoid wiggling // make sure we use a node a minimum distance ahead of us, to avoid wiggling
while (startIndex < m_pathLength - 1) while (startIndex < m_pathLength - 1)
{ {
Vector pos = m_path[ startIndex + 1 ].pos; Vector pos = m_path[startIndex + 1].pos;
// we must do a 2D check here, in case the goal point is floating in space due to jump down, etc // we must do a 2D check here, in case the goal point is floating in space due to jump down, etc
const float closeEpsilon = 20.0f; const float closeEpsilon = 20.0f;
@ -836,9 +864,9 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex)
// if we hit a ladder, stop, or jump area, must stop (dont use ladder behind us) // if we hit a ladder, stop, or jump area, must stop (dont use ladder behind us)
if (startIndex > m_pathIndex && startIndex < m_pathLength if (startIndex > m_pathIndex && startIndex < m_pathLength
&& (m_path[ startIndex ].ladder || (m_path[ startIndex ].area->GetAttributes() & NAV_JUMP))) && (m_path[startIndex].ladder || (m_path[startIndex].area->GetAttributes() & NAV_JUMP)))
{ {
*point = m_path[ startIndex ].pos; *point = m_path[startIndex].pos;
return startIndex; return startIndex;
} }
@ -847,14 +875,14 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex)
startIndex = m_pathLength - 1; startIndex = m_pathLength - 1;
// if we hit a ladder, stop, or jump area, must stop // if we hit a ladder, stop, or jump area, must stop
if (startIndex < m_pathLength && (m_path[ startIndex ].ladder || (m_path[ startIndex ].area->GetAttributes() & NAV_JUMP))) if (startIndex < m_pathLength && (m_path[startIndex].ladder || (m_path[startIndex].area->GetAttributes() & NAV_JUMP)))
{ {
*point = m_path[ startIndex ].pos; *point = m_path[startIndex].pos;
return startIndex; return startIndex;
} }
// note direction of path segment we are standing on // note direction of path segment we are standing on
Vector initDir = m_path[ startIndex ].pos - m_path[ startIndex - 1 ].pos; Vector initDir = m_path[startIndex].pos - m_path[startIndex - 1].pos;
initDir.NormalizeInPlace(); initDir.NormalizeInPlace();
Vector feet(pev->origin.x, pev->origin.y, GetFeetZ()); Vector feet(pev->origin.x, pev->origin.y, GetFeetZ());
@ -902,7 +930,7 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex)
} }
// if we encounter a ladder or jump area, we must stop // if we encounter a ladder or jump area, we must stop
if (i < m_pathLength && (m_path[ i ].ladder || (m_path[ i ].area->GetAttributes() & NAV_JUMP))) if (i < m_pathLength && (m_path[i].ladder || (m_path[i].area->GetAttributes() & NAV_JUMP)))
break; break;
// Check straight-line path from our current position to this position // Check straight-line path from our current position to this position
@ -936,8 +964,8 @@ int CCSBot::FindPathPoint(float aheadRange, Vector *point, int *prevIndex)
else else
{ {
// interpolate point along path segment // interpolate point along path segment
const Vector *afterPoint = &m_path[ afterIndex ].pos; const Vector *afterPoint = &m_path[afterIndex].pos;
const Vector *beforePoint = &m_path[ afterIndex - 1 ].pos; const Vector *beforePoint = &m_path[afterIndex - 1].pos;
Vector to = *afterPoint - *beforePoint; Vector to = *afterPoint - *beforePoint;
float length = to.Length2D(); float length = to.Length2D();
@ -1009,7 +1037,7 @@ void CCSBot::SetPathIndex(int newIndex)
m_pathIndex = Q_min(newIndex, m_pathLength - 1); m_pathIndex = Q_min(newIndex, m_pathLength - 1);
m_areaEnteredTimestamp = gpGlobals->time; m_areaEnteredTimestamp = gpGlobals->time;
if (m_path[ m_pathIndex ].ladder) if (m_path[m_pathIndex].ladder)
{ {
SetupLadderMovement(); SetupLadderMovement();
} }
@ -1017,7 +1045,7 @@ void CCSBot::SetPathIndex(int newIndex)
{ {
// get our "encounter spots" for this leg of the path // get our "encounter spots" for this leg of the path
if (m_pathIndex < m_pathLength && m_pathIndex >= 2) if (m_pathIndex < m_pathLength && m_pathIndex >= 2)
m_spotEncounter = m_path[ m_pathIndex - 1 ].area->GetSpotEncounter(m_path[ m_pathIndex - 2 ].area, m_path[ m_pathIndex ].area); m_spotEncounter = m_path[m_pathIndex - 1].area->GetSpotEncounter(m_path[m_pathIndex - 2].area, m_path[m_pathIndex].area);
else else
m_spotEncounter = nullptr; m_spotEncounter = nullptr;
@ -1033,9 +1061,9 @@ bool CCSBot::IsNearJump() const
for (int i = m_pathIndex - 1; i < m_pathIndex; i++) for (int i = m_pathIndex - 1; i < m_pathIndex; i++)
{ {
if (m_path[ i ].area->GetAttributes() & NAV_JUMP) if (m_path[i].area->GetAttributes() & NAV_JUMP)
{ {
float dz = m_path[ i + 1 ].pos.z - m_path[ i ].pos.z; float dz = m_path[i + 1].pos.z - m_path[i].pos.z;
if (dz > 0.0f) if (dz > 0.0f)
{ {
return true; return true;
@ -1374,11 +1402,11 @@ CCSBot::PathResult CCSBot::UpdatePathMovement(bool allowSpeedChange)
} }
else if (m_pathIndex < m_pathLength) else if (m_pathIndex < m_pathLength)
{ {
toGoal = m_path[ m_pathIndex ].pos - pev->origin; toGoal = m_path[m_pathIndex].pos - pev->origin;
// actually aim our view farther down the path // actually aim our view farther down the path
const float lookAheadRange = 500.0f; const float lookAheadRange = 500.0f;
if (!m_path[ m_pathIndex ].ladder && !IsNearJump() && toGoal.Make2D().IsLengthLessThan(lookAheadRange)) if (!m_path[m_pathIndex].ladder && !IsNearJump() && toGoal.Make2D().IsLengthLessThan(lookAheadRange))
{ {
float along = toGoal.Length2D(); float along = toGoal.Length2D();
int i; int i;
@ -1444,7 +1472,7 @@ CCSBot::PathResult CCSBot::UpdatePathMovement(bool allowSpeedChange)
{ {
DrawPath(); DrawPath();
const Vector *pos = &m_path[ m_pathIndex ].pos; const Vector *pos = &m_path[m_pathIndex].pos;
UTIL_DrawBeamPoints(*pos, *pos + Vector(0, 0, 50), 1, 255, 255, 0); UTIL_DrawBeamPoints(*pos, *pos + Vector(0, 0, 50), 1, 255, 255, 0);
UTIL_DrawBeamPoints(adjustedGoal, adjustedGoal + Vector(0, 0, 50), 1, 255, 0, 255); UTIL_DrawBeamPoints(adjustedGoal, adjustedGoal + Vector(0, 0, 50), 1, 255, 0, 255);
UTIL_DrawBeamPoints(pev->origin, adjustedGoal + Vector(0, 0, 50), 1, 255, 0, 255); UTIL_DrawBeamPoints(pev->origin, adjustedGoal + Vector(0, 0, 50), 1, 255, 0, 255);
@ -1503,7 +1531,7 @@ CCSBot::PathResult CCSBot::UpdatePathMovement(bool allowSpeedChange)
// check if we can reach the next node, in case this was a "jump down" situation // check if we can reach the next node, in case this was a "jump down" situation
if (m_pathIndex < m_pathLength - 1) if (m_pathIndex < m_pathLength - 1)
{ {
if (m_path[ m_pathIndex + 1 ].pos.z - GetFeetZ() > JumpCrouchHeight) if (m_path[m_pathIndex + 1].pos.z - GetFeetZ() > JumpCrouchHeight)
{ {
// the next node is too high, too - we really did fall of the path // the next node is too high, too - we really did fall of the path
didFall = true; didFall = true;
@ -1531,7 +1559,7 @@ CCSBot::PathResult CCSBot::UpdatePathMovement(bool allowSpeedChange)
// if we havent made any progress in a long time, give up // if we havent made any progress in a long time, give up
if (m_pathIndex < m_pathLength - 1) if (m_pathIndex < m_pathLength - 1)
{ {
PrintIfWatched("Giving up trying to get to area #%d\n", m_path[ m_pathIndex ].area->GetID()); PrintIfWatched("Giving up trying to get to area #%d\n", m_path[m_pathIndex].area->GetID());
} }
else else
{ {
@ -1648,8 +1676,8 @@ bool CCSBot::ComputePath(CNavArea *goalArea, const Vector *goal, RouteType route
for (area = effectiveGoalArea; count && area; area = area->GetParent()) for (area = effectiveGoalArea; count && area; area = area->GetParent())
{ {
count--; count--;
m_path[ count ].area = area; m_path[count].area = area;
m_path[ count ].how = area->GetParentHow(); m_path[count].how = area->GetParentHow();
} }
// compute path positions // compute path positions
@ -1681,10 +1709,10 @@ bool CCSBot::ComputePath(CNavArea *goalArea, const Vector *goal, RouteType route
} }
// append path end position // append path end position
m_path[ m_pathLength ].area = effectiveGoalArea; m_path[m_pathLength].area = effectiveGoalArea;
m_path[ m_pathLength ].pos = pathEndPosition; m_path[m_pathLength].pos = pathEndPosition;
m_path[ m_pathLength ].ladder = nullptr; m_path[m_pathLength].ladder = nullptr;
m_path[ m_pathLength ].how = NUM_TRAVERSE_TYPES; m_path[m_pathLength].how = NUM_TRAVERSE_TYPES;
m_pathLength++; m_pathLength++;
// do movement setup // do movement setup

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Returns true if the radio message is an order to do something // Returns true if the radio message is an order to do something
@ -286,7 +314,7 @@ void CCSBot::SendRadioMessage(GameEventType event)
return; return;
} }
PrintIfWatched("%3.1f: SendRadioMessage( %s )\n", gpGlobals->time, GameEventName[ event ]); PrintIfWatched("%3.1f: SendRadioMessage( %s )\n", gpGlobals->time, GameEventName[event]);
// note the time the message was sent // note the time the message was sent
TheCSBots()->SetRadioMessageTimestamp(event, m_iTeam); TheCSBots()->SetRadioMessageTimestamp(event, m_iTeam);

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// This method is the ONLY legal way to change a bot's current state // This method is the ONLY legal way to change a bot's current state

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Lightweight maintenance, invoked frequently // Lightweight maintenance, invoked frequently

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Used to update view angles to stay on a ladder // Used to update view angles to stay on a ladder
@ -23,7 +51,6 @@ float StayOnLadderLine(CCSBot *me, const CNavLadder *ladder)
return 0.0f; return 0.0f;
} }
#ifndef HOOK_GAMEDLL
// Move actual view angles towards desired ones. // Move actual view angles towards desired ones.
// This is the only place v_angle is altered. // This is the only place v_angle is altered.
// TODO: Make stiffness and turn rate constants timestep invariant. // TODO: Make stiffness and turn rate constants timestep invariant.
@ -191,7 +218,6 @@ void CCSBot::UpdateLookAngles()
pev->v_angle.z = 0.0f; pev->v_angle.z = 0.0f;
} }
#endif // HOOK_GAMEDLL
// Return true if we can see the point // Return true if we can see the point
bool CCSBot::IsVisible(const Vector *pos, bool testFOV) const bool CCSBot::IsVisible(const Vector *pos, bool testFOV) const
@ -647,7 +673,7 @@ CBasePlayer *CCSBot::FindMostDangerousThreat()
if (prevIndex < 0) if (prevIndex < 0)
prevIndex = MAX_ENEMY_QUEUE - 1; prevIndex = MAX_ENEMY_QUEUE - 1;
CBasePlayer *currentThreat = m_enemyQueue[ prevIndex ].player; CBasePlayer *currentThreat = m_enemyQueue[prevIndex].player;
#endif #endif
m_bomber = nullptr; m_bomber = nullptr;

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Fire our active weapon towards our current enemy // Fire our active weapon towards our current enemy
@ -34,7 +62,7 @@ void CCSBot::FireWeaponAtEnemy()
float rangeToEnemy = toAimSpot.NormalizeInPlace(); float rangeToEnemy = toAimSpot.NormalizeInPlace();
const float_precision halfPI = (M_PI / 180.0f); const float_precision halfPI = (M_PI / 180.0f);
float_precision yaw = pev->v_angle[ YAW ] * halfPI; float_precision yaw = pev->v_angle[YAW] * halfPI;
Vector2D dir(Q_cos(yaw), Q_sin(yaw)); Vector2D dir(Q_cos(yaw), Q_sin(yaw));
float_precision onTarget = DotProduct(toAimSpot, dir); float_precision onTarget = DotProduct(toAimSpot, dir);
@ -367,7 +395,7 @@ bool CCSBot::IsPrimaryWeaponEmpty() const
// Return true if pistol doesn't exist or is totally out of ammo // Return true if pistol doesn't exist or is totally out of ammo
bool CCSBot::IsPistolEmpty() const bool CCSBot::IsPistolEmpty() const
{ {
CBasePlayerWeapon *pCurrentWeapon = static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[ PISTOL_SLOT ]); CBasePlayerWeapon *pCurrentWeapon = static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[PISTOL_SLOT]);
if (!pCurrentWeapon) if (!pCurrentWeapon)
return true; return true;
@ -407,7 +435,7 @@ void CCSBot::EquipBestWeapon(bool mustEquip)
if (!mustEquip && m_equipTimer.GetElapsedTime() < minEquipInterval) if (!mustEquip && m_equipTimer.GetElapsedTime() < minEquipInterval)
return; return;
CBasePlayerWeapon *pPrimary = static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]); CBasePlayerWeapon *pPrimary = static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[PRIMARY_WEAPON_SLOT]);
if (pPrimary) if (pPrimary)
{ {
WeaponClassType weaponClass = WeaponIDToWeaponClass(pPrimary->m_iId); WeaponClassType weaponClass = WeaponIDToWeaponClass(pPrimary->m_iId);
@ -430,7 +458,7 @@ void CCSBot::EquipBestWeapon(bool mustEquip)
if (TheCSBots()->AllowPistols()) if (TheCSBots()->AllowPistols())
{ {
if (DoEquip(static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[ PISTOL_SLOT ]))) if (DoEquip(static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[PISTOL_SLOT])))
return; return;
} }
@ -447,7 +475,7 @@ void CCSBot::EquipPistol()
if (TheCSBots()->AllowPistols() && !IsUsingPistol()) if (TheCSBots()->AllowPistols() && !IsUsingPistol())
{ {
CBasePlayerWeapon *pistol = static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[ PISTOL_SLOT ]); CBasePlayerWeapon *pistol = static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[PISTOL_SLOT]);
DoEquip(pistol); DoEquip(pistol);
} }
} }
@ -457,7 +485,7 @@ void CCSBot::EquipKnife()
{ {
if (!IsUsingKnife()) if (!IsUsingKnife())
{ {
CBasePlayerWeapon *pKnife = static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[ KNIFE_SLOT ]); CBasePlayerWeapon *pKnife = static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[KNIFE_SLOT]);
if (pKnife) if (pKnife)
{ {
SelectItem(STRING(pKnife->pev->classname)); SelectItem(STRING(pKnife->pev->classname));
@ -468,7 +496,7 @@ void CCSBot::EquipKnife()
// Return true if we have a grenade in our inventory // Return true if we have a grenade in our inventory
bool CCSBot::HasGrenade() const bool CCSBot::HasGrenade() const
{ {
CBasePlayerWeapon *pGrenade = static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[ GRENADE_SLOT ]); CBasePlayerWeapon *pGrenade = static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[GRENADE_SLOT]);
return pGrenade != nullptr; return pGrenade != nullptr;
} }
@ -484,7 +512,7 @@ bool CCSBot::EquipGrenade(bool noSmoke)
if (HasGrenade()) if (HasGrenade())
{ {
CBasePlayerWeapon *pGrenade = static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[ GRENADE_SLOT ]); CBasePlayerWeapon *pGrenade = static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[GRENADE_SLOT]);
if (pGrenade) if (pGrenade)
{ {
if (noSmoke && pGrenade->m_iId == WEAPON_SMOKEGRENADE) if (noSmoke && pGrenade->m_iId == WEAPON_SMOKEGRENADE)
@ -774,12 +802,12 @@ void CCSBot::SilencerCheck()
// Invoked when in contact with a CWeaponBox // Invoked when in contact with a CWeaponBox
void CCSBot::OnTouchingWeapon(CWeaponBox *box) void CCSBot::OnTouchingWeapon(CWeaponBox *box)
{ {
auto pDroppedWeapon = box->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]; auto pDroppedWeapon = box->m_rgpPlayerItems[PRIMARY_WEAPON_SLOT];
// right now we only care about primary weapons on the ground // right now we only care about primary weapons on the ground
if (pDroppedWeapon) if (pDroppedWeapon)
{ {
CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]; CBasePlayerWeapon *pWeapon = static_cast<CBasePlayerWeapon *>(m_rgpPlayerItems[PRIMARY_WEAPON_SLOT]);
// if the gun on the ground is the same one we have, dont bother // if the gun on the ground is the same one we have, dont bother
if (pWeapon && pWeapon->IsWeapon() && pDroppedWeapon->m_iId != pWeapon->m_iId) if (pWeapon && pWeapon->IsWeapon() && pDroppedWeapon->m_iId != pWeapon->m_iId)

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
CSGameState::CSGameState(CCSBot *owner) CSGameState::CSGameState(CCSBot *owner)
@ -403,7 +431,7 @@ const Vector *CSGameState::GetRandomFreeHostagePosition()
if (info->hostage->IsFollowingSomeone()) if (info->hostage->IsFollowingSomeone())
continue; continue;
freePos[ freeCount++ ] = &info->hostage->pev->origin; freePos[freeCount++] = &info->hostage->pev->origin;
} }
else else
{ {
@ -411,7 +439,7 @@ const Vector *CSGameState::GetRandomFreeHostagePosition()
if (info->isValid == false) if (info->isValid == false)
continue; continue;
freePos[ freeCount++ ] = &info->knownPos; freePos[freeCount++] = &info->knownPos;
} }
} }

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Begin attacking // Begin attacking

View File

@ -1,8 +1,36 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
bool HasDefaultPistol(CCSBot *me) bool HasDefaultPistol(CCSBot *me)
{ {
CBasePlayerWeapon *pSecondary = static_cast<CBasePlayerWeapon *>(me->m_rgpPlayerItems[ PISTOL_SLOT ]); CBasePlayerWeapon *pSecondary = static_cast<CBasePlayerWeapon *>(me->m_rgpPlayerItems[PISTOL_SLOT]);
if (!pSecondary) if (!pSecondary)
return false; return false;
@ -73,7 +101,7 @@ void BuyState::OnEnter(CCSBot *me)
if (TheCSBots()->AllowPistols()) if (TheCSBots()->AllowPistols())
{ {
CBasePlayerWeapon *pSecondary = static_cast<CBasePlayerWeapon *>(me->m_rgpPlayerItems[ PISTOL_SLOT ]); CBasePlayerWeapon *pSecondary = static_cast<CBasePlayerWeapon *>(me->m_rgpPlayerItems[PISTOL_SLOT]);
// check if we have a pistol // check if we have a pistol
if (pSecondary) if (pSecondary)
@ -130,10 +158,7 @@ struct BuyInfo
}; };
// These tables MUST be kept in sync with the CT and T buy aliases // These tables MUST be kept in sync with the CT and T buy aliases
BuyInfo primaryWeaponBuyInfoCT[MAX_BUY_WEAPON_PRIMARY] =
#ifndef HOOK_GAMEDLL
BuyInfo primaryWeaponBuyInfoCT[ MAX_BUY_WEAPON_PRIMARY ] =
{ {
{ SHOTGUN, false, "m3" }, // WEAPON_M3 { SHOTGUN, false, "m3" }, // WEAPON_M3
{ SHOTGUN, false, "xm1014" }, // WEAPON_XM1014 { SHOTGUN, false, "xm1014" }, // WEAPON_XM1014
@ -150,7 +175,7 @@ BuyInfo primaryWeaponBuyInfoCT[ MAX_BUY_WEAPON_PRIMARY ] =
{ MACHINE_GUN, false, "m249" }, // WEAPON_M249 { MACHINE_GUN, false, "m249" }, // WEAPON_M249
}; };
BuyInfo secondaryWeaponBuyInfoCT[ MAX_BUY_WEAPON_SECONDARY ] = BuyInfo secondaryWeaponBuyInfoCT[MAX_BUY_WEAPON_SECONDARY] =
{ {
// { PISTOL, false, "glock" }, // { PISTOL, false, "glock" },
// { PISTOL, false, "usp" }, // { PISTOL, false, "usp" },
@ -159,7 +184,7 @@ BuyInfo secondaryWeaponBuyInfoCT[ MAX_BUY_WEAPON_SECONDARY ] =
{ PISTOL, true, "fn57" }, { PISTOL, true, "fn57" },
}; };
BuyInfo primaryWeaponBuyInfoT[ MAX_BUY_WEAPON_PRIMARY ] = BuyInfo primaryWeaponBuyInfoT[MAX_BUY_WEAPON_PRIMARY] =
{ {
{ SHOTGUN, false, "m3" }, // WEAPON_M3 { SHOTGUN, false, "m3" }, // WEAPON_M3
{ SHOTGUN, false, "xm1014" }, // WEAPON_XM1014 { SHOTGUN, false, "xm1014" }, // WEAPON_XM1014
@ -176,7 +201,7 @@ BuyInfo primaryWeaponBuyInfoT[ MAX_BUY_WEAPON_PRIMARY ] =
{ MACHINE_GUN, false, "m249" }, // WEAPON_M249 { MACHINE_GUN, false, "m249" }, // WEAPON_M249
}; };
BuyInfo secondaryWeaponBuyInfoT[ MAX_BUY_WEAPON_SECONDARY ] = BuyInfo secondaryWeaponBuyInfoT[MAX_BUY_WEAPON_SECONDARY] =
{ {
// { PISTOL, false, "glock" }, // { PISTOL, false, "glock" },
// { PISTOL, false, "usp" }, // { PISTOL, false, "usp" },
@ -185,16 +210,6 @@ BuyInfo secondaryWeaponBuyInfoT[ MAX_BUY_WEAPON_SECONDARY ] =
{ PISTOL, true, "elites" }, { PISTOL, true, "elites" },
}; };
#else // HOOK_GAMEDLL
BuyInfo primaryWeaponBuyInfoCT[ MAX_BUY_WEAPON_PRIMARY ];
BuyInfo secondaryWeaponBuyInfoCT[ MAX_BUY_WEAPON_SECONDARY];
BuyInfo primaryWeaponBuyInfoT[ MAX_BUY_WEAPON_PRIMARY ];
BuyInfo secondaryWeaponBuyInfoT[ MAX_BUY_WEAPON_SECONDARY ];
#endif // HOOK_GAMEDLL
// Given a weapon alias, return the kind of weapon it is // Given a weapon alias, return the kind of weapon it is
inline WeaponType GetWeaponType(const char *alias) inline WeaponType GetWeaponType(const char *alias)
{ {
@ -373,7 +388,7 @@ void BuyState::OnUpdate(CCSBot *me)
{ {
// build list of allowable weapons to buy // build list of allowable weapons to buy
BuyInfo *masterPrimary = (me->m_iTeam == TERRORIST) ? primaryWeaponBuyInfoT : primaryWeaponBuyInfoCT; BuyInfo *masterPrimary = (me->m_iTeam == TERRORIST) ? primaryWeaponBuyInfoT : primaryWeaponBuyInfoCT;
BuyInfo *stockPrimary[ MAX_BUY_WEAPON_PRIMARY ]; BuyInfo *stockPrimary[MAX_BUY_WEAPON_PRIMARY];
int stockPrimaryCount = 0; int stockPrimaryCount = 0;
// dont choose sniper rifles as often // dont choose sniper rifles as often
@ -388,7 +403,7 @@ void BuyState::OnUpdate(CCSBot *me)
(masterPrimary[i].type == SNIPER_RIFLE && TheCSBots()->AllowSnipers() && wantSniper) || (masterPrimary[i].type == SNIPER_RIFLE && TheCSBots()->AllowSnipers() && wantSniper) ||
(masterPrimary[i].type == MACHINE_GUN && TheCSBots()->AllowMachineGuns())) (masterPrimary[i].type == MACHINE_GUN && TheCSBots()->AllowMachineGuns()))
{ {
stockPrimary[ stockPrimaryCount++ ] = &masterPrimary[i]; stockPrimary[stockPrimaryCount++] = &masterPrimary[i];
} }
} }
@ -428,8 +443,8 @@ void BuyState::OnUpdate(CCSBot *me)
which = RANDOM_LONG(0, stockPrimaryCount - 1); which = RANDOM_LONG(0, stockPrimaryCount - 1);
} }
me->ClientCommand(stockPrimary[ which ]->buyAlias); me->ClientCommand(stockPrimary[which]->buyAlias);
me->PrintIfWatched("Tried to buy %s.\n", stockPrimary[ which ]->buyAlias); me->PrintIfWatched("Tried to buy %s.\n", stockPrimary[which]->buyAlias);
} }
} }
} }
@ -455,9 +470,9 @@ void BuyState::OnUpdate(CCSBot *me)
int which = RANDOM_LONG(0, MAX_BUY_WEAPON_SECONDARY - 1); int which = RANDOM_LONG(0, MAX_BUY_WEAPON_SECONDARY - 1);
if (me->m_iTeam == TERRORIST) if (me->m_iTeam == TERRORIST)
me->ClientCommand(secondaryWeaponBuyInfoT[ which ].buyAlias); me->ClientCommand(secondaryWeaponBuyInfoT[which].buyAlias);
else else
me->ClientCommand(secondaryWeaponBuyInfoCT[ which ].buyAlias); me->ClientCommand(secondaryWeaponBuyInfoCT[which].buyAlias);
// only buy one pistol // only buy one pistol
m_buyPistol = false; m_buyPistol = false;

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Begin defusing the bomb // Begin defusing the bomb

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
void EscapeFromBombState::OnEnter(CCSBot *me) void EscapeFromBombState::OnEnter(CCSBot *me)

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Move to the bomb on the floor and pick it up // Move to the bomb on the floor and pick it up

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Follow our leader // Follow our leader
@ -216,7 +244,7 @@ void FollowState::OnUpdate(CCSBot *me)
// if we are idle, pick a random area // if we are idle, pick a random area
if (m_idleTimer.IsElapsed()) if (m_idleTimer.IsElapsed())
{ {
target = collector.m_targetArea[ RANDOM_LONG(0, collector.m_targetAreaCount - 1) ]; target = collector.m_targetArea[RANDOM_LONG(0, collector.m_targetAreaCount - 1)];
targetPos = *target->GetCenter(); targetPos = *target->GetCenter();
me->PrintIfWatched("%4.1f: Bored. Repathing to a new nearby area\n", gpGlobals->time); me->PrintIfWatched("%4.1f: Bored. Repathing to a new nearby area\n", gpGlobals->time);
} }

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Begin moving to a nearby hidey-hole. // Begin moving to a nearby hidey-hole.

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Begin the hunt // Begin the hunt

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// range for snipers to select a hiding spot // range for snipers to select a hiding spot

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Move towards currently heard noise // Move towards currently heard noise

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Move to a potentially far away position. // Move to a potentially far away position.

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Plant the bomb. // Plant the bomb.

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
// Face the entity and "use" it // Face the entity and "use" it

View File

@ -1,10 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CEnvGlobal::m_SaveData[] = TYPEDESCRIPTION CEnvGlobal::m_SaveData[] =
{ {
DEFINE_FIELD(CEnvGlobal, m_globalstate, FIELD_STRING), DEFINE_FIELD(CEnvGlobal, m_globalstate, FIELD_STRING),
@ -12,46 +7,6 @@ TYPEDESCRIPTION CEnvGlobal::m_SaveData[] =
DEFINE_FIELD(CEnvGlobal, m_initialstate, FIELD_INTEGER), DEFINE_FIELD(CEnvGlobal, m_initialstate, FIELD_INTEGER),
}; };
TYPEDESCRIPTION CMultiSource::m_SaveData[] =
{
// BUGBUG FIX
DEFINE_ARRAY(CMultiSource, m_rgEntities, FIELD_EHANDLE, MAX_MS_TARGETS),
DEFINE_ARRAY(CMultiSource, m_rgTriggered, FIELD_INTEGER, MAX_MS_TARGETS),
DEFINE_FIELD(CMultiSource, m_iTotal, FIELD_INTEGER),
DEFINE_FIELD(CMultiSource, m_globalstate, FIELD_STRING),
};
// CBaseButton
TYPEDESCRIPTION CBaseButton::m_SaveData[] =
{
DEFINE_FIELD(CBaseButton, m_fStayPushed, FIELD_BOOLEAN),
DEFINE_FIELD(CBaseButton, m_fRotating, FIELD_BOOLEAN),
DEFINE_FIELD(CBaseButton, m_sounds, FIELD_INTEGER),
DEFINE_FIELD(CBaseButton, m_bLockedSound, FIELD_CHARACTER),
DEFINE_FIELD(CBaseButton, m_bLockedSentence, FIELD_CHARACTER),
DEFINE_FIELD(CBaseButton, m_bUnlockedSound, FIELD_CHARACTER),
DEFINE_FIELD(CBaseButton, m_bUnlockedSentence, FIELD_CHARACTER),
DEFINE_FIELD(CBaseButton, m_strChangeTarget, FIELD_STRING),
// DEFINE_FIELD(CBaseButton, m_ls, FIELD_???), // This is restored in Precache()
};
TYPEDESCRIPTION CMomentaryRotButton::m_SaveData[] =
{
DEFINE_FIELD(CMomentaryRotButton, m_lastUsed, FIELD_INTEGER),
DEFINE_FIELD(CMomentaryRotButton, m_direction, FIELD_INTEGER),
DEFINE_FIELD(CMomentaryRotButton, m_returnSpeed, FIELD_FLOAT),
DEFINE_FIELD(CMomentaryRotButton, m_start, FIELD_VECTOR),
DEFINE_FIELD(CMomentaryRotButton, m_end, FIELD_VECTOR),
DEFINE_FIELD(CMomentaryRotButton, m_sounds, FIELD_INTEGER),
};
TYPEDESCRIPTION CEnvSpark::m_SaveData[] =
{
DEFINE_FIELD(CEnvSpark, m_flDelay, FIELD_FLOAT),
};
#endif // HOOK_GAMEDLL
IMPLEMENT_SAVERESTORE(CEnvGlobal, CBaseEntity) IMPLEMENT_SAVERESTORE(CEnvGlobal, CBaseEntity)
LINK_ENTITY_TO_CLASS(env_global, CEnvGlobal, CCSEnvGlobal) LINK_ENTITY_TO_CLASS(env_global, CEnvGlobal, CCSEnvGlobal)
@ -136,6 +91,15 @@ void CEnvGlobal::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use
gGlobalState.EntityAdd(m_globalstate, gpGlobals->mapname, newState); gGlobalState.EntityAdd(m_globalstate, gpGlobals->mapname, newState);
} }
TYPEDESCRIPTION CMultiSource::m_SaveData[] =
{
// BUGBUG FIX
DEFINE_ARRAY(CMultiSource, m_rgEntities, FIELD_EHANDLE, MAX_MS_TARGETS),
DEFINE_ARRAY(CMultiSource, m_rgTriggered, FIELD_INTEGER, MAX_MS_TARGETS),
DEFINE_FIELD(CMultiSource, m_iTotal, FIELD_INTEGER),
DEFINE_FIELD(CMultiSource, m_globalstate, FIELD_STRING),
};
IMPLEMENT_SAVERESTORE(CMultiSource, CBaseEntity) IMPLEMENT_SAVERESTORE(CMultiSource, CBaseEntity)
LINK_ENTITY_TO_CLASS(multisource, CMultiSource, CCSMultiSource) LINK_ENTITY_TO_CLASS(multisource, CMultiSource, CCSMultiSource)
@ -297,6 +261,19 @@ void CMultiSource::Register()
pev->spawnflags &= ~SF_MULTI_INIT; pev->spawnflags &= ~SF_MULTI_INIT;
} }
TYPEDESCRIPTION CBaseButton::m_SaveData[] =
{
DEFINE_FIELD(CBaseButton, m_fStayPushed, FIELD_BOOLEAN),
DEFINE_FIELD(CBaseButton, m_fRotating, FIELD_BOOLEAN),
DEFINE_FIELD(CBaseButton, m_sounds, FIELD_INTEGER),
DEFINE_FIELD(CBaseButton, m_bLockedSound, FIELD_CHARACTER),
DEFINE_FIELD(CBaseButton, m_bLockedSentence, FIELD_CHARACTER),
DEFINE_FIELD(CBaseButton, m_bUnlockedSound, FIELD_CHARACTER),
DEFINE_FIELD(CBaseButton, m_bUnlockedSentence, FIELD_CHARACTER),
DEFINE_FIELD(CBaseButton, m_strChangeTarget, FIELD_STRING),
// DEFINE_FIELD(CBaseButton, m_ls, FIELD_???), // This is restored in Precache()
};
IMPLEMENT_SAVERESTORE(CBaseButton, CBaseToggle) IMPLEMENT_SAVERESTORE(CBaseButton, CBaseToggle)
void CBaseButton::Precache() void CBaseButton::Precache()
@ -922,6 +899,16 @@ void CRotButton::Restart()
} }
#endif #endif
TYPEDESCRIPTION CMomentaryRotButton::m_SaveData[] =
{
DEFINE_FIELD(CMomentaryRotButton, m_lastUsed, FIELD_INTEGER),
DEFINE_FIELD(CMomentaryRotButton, m_direction, FIELD_INTEGER),
DEFINE_FIELD(CMomentaryRotButton, m_returnSpeed, FIELD_FLOAT),
DEFINE_FIELD(CMomentaryRotButton, m_start, FIELD_VECTOR),
DEFINE_FIELD(CMomentaryRotButton, m_end, FIELD_VECTOR),
DEFINE_FIELD(CMomentaryRotButton, m_sounds, FIELD_INTEGER),
};
IMPLEMENT_SAVERESTORE(CMomentaryRotButton, CBaseToggle) IMPLEMENT_SAVERESTORE(CMomentaryRotButton, CBaseToggle)
LINK_ENTITY_TO_CLASS(momentary_rot_button, CMomentaryRotButton, CCSMomentaryRotButton) LINK_ENTITY_TO_CLASS(momentary_rot_button, CMomentaryRotButton, CCSMomentaryRotButton)
@ -1137,6 +1124,11 @@ void CMomentaryRotButton::UpdateSelfReturn(float value)
} }
} }
TYPEDESCRIPTION CEnvSpark::m_SaveData[] =
{
DEFINE_FIELD(CEnvSpark, m_flDelay, FIELD_FLOAT),
};
IMPLEMENT_SAVERESTORE(CEnvSpark, CBaseEntity) IMPLEMENT_SAVERESTORE(CEnvSpark, CBaseEntity)
LINK_ENTITY_TO_CLASS(env_spark, CEnvSpark, CCSEnvSpark) LINK_ENTITY_TO_CLASS(env_spark, CEnvSpark, CCSEnvSpark)
LINK_ENTITY_TO_CLASS(env_debris, CEnvSpark, CCSEnvSpark) LINK_ENTITY_TO_CLASS(env_debris, CEnvSpark, CCSEnvSpark)

View File

@ -40,7 +40,7 @@ public:
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[3]; static TYPEDESCRIPTION m_SaveData[];
string_t m_globalstate; string_t m_globalstate;
int m_triggermode; int m_triggermode;
@ -59,8 +59,9 @@ public:
virtual void Restart(); virtual void Restart();
virtual int Save(CSave &save); virtual int Save(CSave &save);
virtual int Restore(CRestore &restore); virtual int Restore(CRestore &restore);
public: public:
static TYPEDESCRIPTION m_SaveData[1]; static TYPEDESCRIPTION m_SaveData[];
Vector m_vecSpawn; Vector m_vecSpawn;
#endif #endif
@ -103,7 +104,7 @@ public:
public: public:
static CMomentaryRotButton *Instance(edict_t *pent) { return (CMomentaryRotButton *)GET_PRIVATE(pent); } static CMomentaryRotButton *Instance(edict_t *pent) { return (CMomentaryRotButton *)GET_PRIVATE(pent); }
static TYPEDESCRIPTION IMPL(m_SaveData)[6]; static TYPEDESCRIPTION m_SaveData[];
int m_lastUsed; int m_lastUsed;
int m_direction; int m_direction;
@ -131,7 +132,8 @@ public:
void EXPORT SparkStop(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); void EXPORT SparkStop(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[1]; static TYPEDESCRIPTION m_SaveData[];
float m_flDelay; float m_flDelay;
}; };

View File

@ -1,39 +1,7 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
CCareerTaskManager *TheCareerTasks = nullptr; CCareerTaskManager *TheCareerTasks = nullptr;
const TaskInfo taskInfo[] =
{
{ "defuse", EVENT_BOMB_DEFUSED, &CCareerTask::NewTask },
{ "plant", EVENT_BOMB_PLANTED, &CCareerTask::NewTask },
{ "rescue", EVENT_HOSTAGE_RESCUED, &CCareerTask::NewTask },
{ "killall", EVENT_KILL_ALL, &CCareerTask::NewTask },
{ "kill", EVENT_KILL, &CCareerTask::NewTask },
{ "killwith", EVENT_KILL, &CCareerTask::NewTask },
{ "killblind", EVENT_KILL_FLASHBANGED, &CCareerTask::NewTask },
{ "killvip", EVENT_KILL, &CCareerTask::NewTask },
{ "headshot", EVENT_HEADSHOT, &CCareerTask::NewTask },
{ "headshotwith", EVENT_HEADSHOT, &CCareerTask::NewTask },
{ "winfast", EVENT_ROUND_WIN, &CCareerTask::NewTask },
{ "rescue", EVENT_HOSTAGE_RESCUED, &CCareerTask::NewTask },
{ "rescueall", EVENT_ALL_HOSTAGES_RESCUED, &CCareerTask::NewTask },
{ "injure", EVENT_PLAYER_TOOK_DAMAGE, &CCareerTask::NewTask },
{ "injurewith", EVENT_PLAYER_TOOK_DAMAGE, &CCareerTask::NewTask },
{ "killdefuser", EVENT_KILL, &CCareerTask::NewTask },
{ "stoprescue", EVENT_KILL, &CCareerTask::NewTask },
{ "defendhostages", EVENT_ROUND_WIN, &CCareerTask::NewTask },
{ "hostagessurvive", EVENT_ROUND_WIN, &CCareerTask::NewTask },
{ "preventdefuse", EVENT_ROUND_WIN, &CPreventDefuseTask::NewTask },
{ nullptr, EVENT_INVALID, &CCareerTask::NewTask },
};
#endif
CCareerTask *CPreventDefuseTask::NewTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete) CCareerTask *CPreventDefuseTask::NewTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete)
{ {
CPreventDefuseTask *pNewTask = new CPreventDefuseTask(taskName, event, weaponName, n, mustLive, crossRounds, id, isComplete); CPreventDefuseTask *pNewTask = new CPreventDefuseTask(taskName, event, weaponName, n, mustLive, crossRounds, id, isComplete);
@ -439,22 +407,45 @@ void CCareerTaskManager::SetFinishedTaskTime(int val)
m_finishedTaskRound = CSGameRules()->m_iTotalRoundsPlayed; m_finishedTaskRound = CSGameRules()->m_iTotalRoundsPlayed;
} }
const TaskInfo CCareerTaskManager::m_taskInfo[] =
{
{ "defuse", EVENT_BOMB_DEFUSED, &CCareerTask::NewTask },
{ "plant", EVENT_BOMB_PLANTED, &CCareerTask::NewTask },
{ "rescue", EVENT_HOSTAGE_RESCUED, &CCareerTask::NewTask },
{ "killall", EVENT_KILL_ALL, &CCareerTask::NewTask },
{ "kill", EVENT_KILL, &CCareerTask::NewTask },
{ "killwith", EVENT_KILL, &CCareerTask::NewTask },
{ "killblind", EVENT_KILL_FLASHBANGED, &CCareerTask::NewTask },
{ "killvip", EVENT_KILL, &CCareerTask::NewTask },
{ "headshot", EVENT_HEADSHOT, &CCareerTask::NewTask },
{ "headshotwith", EVENT_HEADSHOT, &CCareerTask::NewTask },
{ "winfast", EVENT_ROUND_WIN, &CCareerTask::NewTask },
{ "rescue", EVENT_HOSTAGE_RESCUED, &CCareerTask::NewTask },
{ "rescueall", EVENT_ALL_HOSTAGES_RESCUED, &CCareerTask::NewTask },
{ "injure", EVENT_PLAYER_TOOK_DAMAGE, &CCareerTask::NewTask },
{ "injurewith", EVENT_PLAYER_TOOK_DAMAGE, &CCareerTask::NewTask },
{ "killdefuser", EVENT_KILL, &CCareerTask::NewTask },
{ "stoprescue", EVENT_KILL, &CCareerTask::NewTask },
{ "defendhostages", EVENT_ROUND_WIN, &CCareerTask::NewTask },
{ "hostagessurvive", EVENT_ROUND_WIN, &CCareerTask::NewTask },
{ "preventdefuse", EVENT_ROUND_WIN, &CPreventDefuseTask::NewTask },
{ nullptr, EVENT_INVALID, &CCareerTask::NewTask },
};
void CCareerTaskManager::AddTask(const char *taskName, const char *weaponName, int eventCount, bool mustLive, bool crossRounds, bool isComplete) void CCareerTaskManager::AddTask(const char *taskName, const char *weaponName, int eventCount, bool mustLive, bool crossRounds, bool isComplete)
{ {
++m_nextId; m_nextId++;
for (int i = 0; i < ARRAYSIZE(taskInfo); ++i) for (auto &taskInfo : m_taskInfo)
{ {
const TaskInfo *pTaskInfo = &taskInfo[ i ]; if (taskInfo.taskName)
if (pTaskInfo->taskName)
{ {
if (!Q_stricmp(pTaskInfo->taskName, taskName)) if (!Q_stricmp(taskInfo.taskName, taskName))
{ {
CCareerTask *newTask = pTaskInfo->factory CCareerTask *newTask = taskInfo.factory
( (
pTaskInfo->taskName, taskInfo.taskName,
pTaskInfo->event, taskInfo.event,
weaponName, weaponName,
eventCount, eventCount,
mustLive, mustLive,
@ -465,7 +456,7 @@ void CCareerTaskManager::AddTask(const char *taskName, const char *weaponName, i
m_tasks.push_back(newTask); m_tasks.push_back(newTask);
if (pTaskInfo->event == EVENT_ROUND_WIN && !Q_strcmp(taskName, "winfast")) if (taskInfo.event == EVENT_ROUND_WIN && !Q_strcmp(taskName, "winfast"))
{ {
m_taskTime = eventCount; m_taskTime = eventCount;

View File

@ -35,6 +35,7 @@ class CCareerTask
public: public:
CCareerTask() {}; CCareerTask() {};
CCareerTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete); CCareerTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete);
public: public:
virtual void OnEvent(GameEventType event, CBasePlayer *pAttacker, CBasePlayer *pVictim); virtual void OnEvent(GameEventType event, CBasePlayer *pAttacker, CBasePlayer *pVictim);
virtual void Reset(); virtual void Reset();
@ -72,15 +73,23 @@ private:
bool m_vip; bool m_vip;
}; };
typedef std::STD_LIST<CCareerTask *> CareerTaskList; typedef std::list<CCareerTask *> CareerTaskList;
typedef CareerTaskList::iterator CareerTaskListIt; typedef CareerTaskList::iterator CareerTaskListIt;
typedef CCareerTask *(*TaskFactoryFunction)(const char *taskName, GameEventType event, const char *weaponName, int eventCount, bool mustLive, bool crossRounds, int nextId, bool isComplete); using TaskFactoryFunction = CCareerTask *(*)(const char *taskName, GameEventType event, const char *weaponName, int eventCount, bool mustLive, bool crossRounds, int nextId, bool isComplete);
struct TaskInfo
{
const char *taskName;
GameEventType event;
TaskFactoryFunction factory;
};
class CPreventDefuseTask: public CCareerTask class CPreventDefuseTask: public CCareerTask
{ {
public: public:
CPreventDefuseTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete); CPreventDefuseTask(const char *taskName, GameEventType event, const char *weaponName, int n, bool mustLive, bool crossRounds, int id, bool isComplete);
public: public:
virtual void OnEvent(GameEventType event, CBasePlayer *pAttacker, CBasePlayer *pVictim); virtual void OnEvent(GameEventType event, CBasePlayer *pAttacker, CBasePlayer *pVictim);
virtual void Reset(); virtual void Reset();
@ -124,6 +133,8 @@ public:
void UnlatchRoundEndMessage(); void UnlatchRoundEndMessage();
private: private:
static const TaskInfo m_taskInfo[];
CareerTaskList m_tasks; CareerTaskList m_tasks;
int m_nextId; int m_nextId;
@ -136,11 +147,4 @@ private:
bool m_shouldLatchRoundEndMessage; bool m_shouldLatchRoundEndMessage;
}; };
struct TaskInfo
{
const char *taskName;
GameEventType event;
TaskFactoryFunction factory;
};
extern CCareerTaskManager *TheCareerTasks; extern CCareerTaskManager *TheCareerTasks;

View File

@ -1,10 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
DLL_FUNCTIONS gFunctionTable = DLL_FUNCTIONS gFunctionTable =
{ {
&GameDLLInit, &GameDLLInit,
@ -68,20 +63,8 @@ NEW_DLL_FUNCTIONS gNewDLLFunctions =
nullptr nullptr
}; };
// Global Savedata for Delay
TYPEDESCRIPTION CBaseEntity::m_SaveData[] =
{
DEFINE_FIELD(CBaseEntity, m_pGoalEnt, FIELD_CLASSPTR),
DEFINE_FIELD(CBaseEntity, m_pfnThink, FIELD_FUNCTION), // UNDONE: Build table of these!
DEFINE_FIELD(CBaseEntity, m_pfnTouch, FIELD_FUNCTION),
DEFINE_FIELD(CBaseEntity, m_pfnUse, FIELD_FUNCTION),
DEFINE_FIELD(CBaseEntity, m_pfnBlocked, FIELD_FUNCTION),
};
CMemoryPool hashItemMemPool(sizeof(hash_item_t), 64); CMemoryPool hashItemMemPool(sizeof(hash_item_t), 64);
#endif // HOOK_GAMEDLL
int CaseInsensitiveHash(const char *string, int iBounds) int CaseInsensitiveHash(const char *string, int iBounds)
{ {
unsigned int hash = 0; unsigned int hash = 0;
@ -107,7 +90,7 @@ void EmptyEntityHashTable()
int i; int i;
hash_item_t *item, *temp, *free; hash_item_t *item, *temp, *free;
for (i = 0; i < stringsHashTable.Count(); ++i) for (i = 0; i < stringsHashTable.Count(); i++)
{ {
item = &stringsHashTable[i]; item = &stringsHashTable[i];
temp = item->next; temp = item->next;
@ -292,7 +275,7 @@ C_DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS *pFunctionTable, int interfaceVersion
Q_memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS)); Q_memcpy(pFunctionTable, &gFunctionTable, sizeof(DLL_FUNCTIONS));
stringsHashTable.AddMultipleToTail(2048); stringsHashTable.AddMultipleToTail(2048);
for (int i = 0; i < stringsHashTable.Count(); ++i) for (int i = 0; i < stringsHashTable.Count(); i++)
{ {
stringsHashTable[i].next = nullptr; stringsHashTable[i].next = nullptr;
} }
@ -338,7 +321,7 @@ int DispatchSpawn(edict_t *pent)
// Try to get the pointer again, in case the spawn function deleted the entity. // Try to get the pointer again, in case the spawn function deleted the entity.
// UNDONE: Spawn() should really return a code to ask that the entity be deleted, but // UNDONE: Spawn() should really return a code to ask that the entity be deleted, but
// that would touch too much code for me to do that right now. // that would touch too much code for me to do that right now.
pEntity = (CBaseEntity *)GET_PRIVATE(pent); pEntity = GET_PRIVATE<CBaseEntity>(pent);
if (pEntity) if (pEntity)
{ {
@ -397,7 +380,7 @@ void DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd)
return; return;
// Get the actualy entity object // Get the actualy entity object
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentKeyvalue); CBaseEntity *pEntity = GET_PRIVATE<CBaseEntity>(pentKeyvalue);
if (!pEntity) if (!pEntity)
return; return;
@ -408,8 +391,8 @@ void DispatchKeyValue(edict_t *pentKeyvalue, KeyValueData *pkvd)
// while it builds the graph // while it builds the graph
void DispatchTouch(edict_t *pentTouched, edict_t *pentOther) void DispatchTouch(edict_t *pentTouched, edict_t *pentOther)
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentTouched); CBaseEntity *pEntity = GET_PRIVATE<CBaseEntity>(pentTouched);
CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); CBaseEntity *pOther = GET_PRIVATE<CBaseEntity>(pentOther);
if (pEntity && pOther && !((pEntity->pev->flags | pOther->pev->flags) & FL_KILLME)) if (pEntity && pOther && !((pEntity->pev->flags | pOther->pev->flags) & FL_KILLME))
pEntity->Touch(pOther); pEntity->Touch(pOther);
@ -417,8 +400,8 @@ void DispatchTouch(edict_t *pentTouched, edict_t *pentOther)
void DispatchUse(edict_t *pentUsed, edict_t *pentOther) void DispatchUse(edict_t *pentUsed, edict_t *pentOther)
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentUsed); CBaseEntity *pEntity = GET_PRIVATE<CBaseEntity>(pentUsed);
CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); CBaseEntity *pOther = GET_PRIVATE<CBaseEntity>(pentOther);
if (pEntity && !(pEntity->pev->flags & FL_KILLME)) if (pEntity && !(pEntity->pev->flags & FL_KILLME))
pEntity->Use(pOther, pOther, USE_TOGGLE, 0); pEntity->Use(pOther, pOther, USE_TOGGLE, 0);
@ -426,7 +409,7 @@ void DispatchUse(edict_t *pentUsed, edict_t *pentOther)
void DispatchThink(edict_t *pent) void DispatchThink(edict_t *pent)
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); CBaseEntity *pEntity = GET_PRIVATE<CBaseEntity>(pent);
if (pEntity) if (pEntity)
{ {
@ -441,8 +424,8 @@ void DispatchThink(edict_t *pent)
void DispatchBlocked(edict_t *pentBlocked, edict_t *pentOther) void DispatchBlocked(edict_t *pentBlocked, edict_t *pentOther)
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pentBlocked); CBaseEntity *pEntity = GET_PRIVATE<CBaseEntity>(pentBlocked);
CBaseEntity *pOther = (CBaseEntity *)GET_PRIVATE(pentOther); CBaseEntity *pOther = GET_PRIVATE<CBaseEntity>(pentOther);
if (pEntity) if (pEntity)
{ {
@ -452,11 +435,11 @@ void DispatchBlocked(edict_t *pentBlocked, edict_t *pentOther)
void DispatchSave(edict_t *pent, SAVERESTOREDATA *pSaveData) void DispatchSave(edict_t *pent, SAVERESTOREDATA *pSaveData)
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); CBaseEntity *pEntity = GET_PRIVATE<CBaseEntity>(pent);
if (pEntity && pSaveData) if (pEntity && pSaveData)
{ {
ENTITYTABLE *pTable = &pSaveData->pTable[ pSaveData->currentIndex ]; ENTITYTABLE *pTable = &pSaveData->pTable[pSaveData->currentIndex];
if (pTable->pent != pent) if (pTable->pent != pent)
{ {
@ -497,7 +480,7 @@ CBaseEntity *FindGlobalEntity(string_t classname, string_t globalname)
if (pReturn) if (pReturn)
{ {
if (!FClassnameIs(pReturn->pev, STRING(classname))) if (!FClassnameIs(pReturn->pev, classname))
{ {
ALERT(at_console, "Global entity found %s, wrong class %s\n", STRING(globalname), STRING(pReturn->pev->classname)); ALERT(at_console, "Global entity found %s, wrong class %s\n", STRING(globalname), STRING(pReturn->pev->classname));
pReturn = nullptr; pReturn = nullptr;
@ -509,7 +492,7 @@ CBaseEntity *FindGlobalEntity(string_t classname, string_t globalname)
int DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity) int DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity)
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); CBaseEntity *pEntity = GET_PRIVATE<CBaseEntity>(pent);
if (pEntity && pSaveData) if (pEntity && pSaveData)
{ {
@ -578,7 +561,7 @@ int DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity)
} }
// Again, could be deleted, get the pointer again. // Again, could be deleted, get the pointer again.
pEntity = (CBaseEntity *)GET_PRIVATE(pent); pEntity = GET_PRIVATE<CBaseEntity>(pent);
// Is this an overriding global entity (coming over the transition), or one restoring in a level // Is this an overriding global entity (coming over the transition), or one restoring in a level
if (globalEntity) if (globalEntity)
@ -623,14 +606,14 @@ int DispatchRestore(edict_t *pent, SAVERESTOREDATA *pSaveData, int globalEntity)
void DispatchObjectCollsionBox(edict_t *pent) void DispatchObjectCollsionBox(edict_t *pent)
{ {
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); CBaseEntity *pEntity = GET_PRIVATE<CBaseEntity>(pent);
if (pEntity) if (pEntity)
{ {
pEntity->SetObjectCollisionBox(); pEntity->SetObjectCollisionBox();
return;
} }
else
SetObjectCollisionBox(&pent->v);
SetObjectCollisionBox(&pent->v);
} }
void SaveWriteFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount) void SaveWriteFields(SAVERESTOREDATA *pSaveData, const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount)
@ -735,11 +718,21 @@ CBaseEntity *CBaseEntity::GetNextTarget()
return Instance(pTarget); return Instance(pTarget);
} }
// Global Savedata for Delay
TYPEDESCRIPTION CBaseEntity::m_SaveData[] =
{
DEFINE_FIELD(CBaseEntity, m_pGoalEnt, FIELD_CLASSPTR),
DEFINE_FIELD(CBaseEntity, m_pfnThink, FIELD_FUNCTION), // UNDONE: Build table of these!
DEFINE_FIELD(CBaseEntity, m_pfnTouch, FIELD_FUNCTION),
DEFINE_FIELD(CBaseEntity, m_pfnUse, FIELD_FUNCTION),
DEFINE_FIELD(CBaseEntity, m_pfnBlocked, FIELD_FUNCTION),
};
int CBaseEntity::Save(CSave &save) int CBaseEntity::Save(CSave &save)
{ {
if (save.WriteEntVars("ENTVARS", pev)) if (save.WriteEntVars("ENTVARS", pev))
{ {
return save.WriteFields("BASE", this, IMPL(m_SaveData), ARRAYSIZE(IMPL(m_SaveData))); return save.WriteFields("BASE", this, m_SaveData, ARRAYSIZE(m_SaveData));
} }
return 0; return 0;
@ -750,7 +743,7 @@ int CBaseEntity::Restore(CRestore &restore)
int status = restore.ReadEntVars("ENTVARS", pev); int status = restore.ReadEntVars("ENTVARS", pev);
if (status) if (status)
{ {
status = restore.ReadFields("BASE", this, IMPL(m_SaveData), ARRAYSIZE(IMPL(m_SaveData))); status = restore.ReadFields("BASE", this, m_SaveData, ARRAYSIZE(m_SaveData));
} }
if (pev->modelindex != 0 && !FStringNull(pev->model)) if (pev->modelindex != 0 && !FStringNull(pev->model))
@ -781,7 +774,7 @@ void SetObjectCollisionBox(entvars_t *pev)
int i; int i;
max = 0; max = 0;
for (i = 0; i < 3; ++i) for (i = 0; i < 3; i++)
{ {
v = Q_fabs(float_precision(((float *)pev->mins)[i])); v = Q_fabs(float_precision(((float *)pev->mins)[i]));
if (v > max) if (v > max)
@ -795,7 +788,7 @@ void SetObjectCollisionBox(entvars_t *pev)
max = v; max = v;
} }
} }
for (i = 0; i < 3; ++i) for (i = 0; i < 3; i++)
{ {
((float *)pev->absmin)[i] = ((float *)pev->origin)[i] - max; ((float *)pev->absmin)[i] = ((float *)pev->origin)[i] - max;
((float *)pev->absmax)[i] = ((float *)pev->origin)[i] + max; ((float *)pev->absmax)[i] = ((float *)pev->origin)[i] + max;
@ -907,7 +900,7 @@ int CBaseEntity::DamageDecal(int bitsDamageType)
// NOTE: szName must be a pointer to constant memory, e.g. "monster_class" because the entity // NOTE: szName must be a pointer to constant memory, e.g. "monster_class" because the entity
// will keep a pointer to it after this call. // will keep a pointer to it after this call.
CBaseEntity *CBaseEntity::Create(char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner) CBaseEntity *CBaseEntity::Create(const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner)
{ {
edict_t *pent = CREATE_NAMED_ENTITY(MAKE_STRING(szName)); edict_t *pent = CREATE_NAMED_ENTITY(MAKE_STRING(szName));
if (FNullEnt(pent)) if (FNullEnt(pent))
@ -1021,7 +1014,7 @@ void CBaseEntity::FireBullets(ULONG cShots, Vector vecSrc, Vector vecDirShooting
ClearMultiDamage(); ClearMultiDamage();
gMultiDamage.type = (DMG_BULLET | DMG_NEVERGIB); gMultiDamage.type = (DMG_BULLET | DMG_NEVERGIB);
for (ULONG iShot = 1; iShot <= cShots; ++iShot) for (ULONG iShot = 1; iShot <= cShots; iShot++)
{ {
int spark = 0; int spark = 0;
@ -1395,7 +1388,7 @@ void CBaseEntity::TraceBleed(float flDamage, Vector vecDir, TraceResult *ptr, in
cCount = 4; cCount = 4;
} }
for (i = 0; i < cCount; ++i) for (i = 0; i < cCount; i++)
{ {
// trace in the opposite direction the shot came from (the direction the shot is going) // trace in the opposite direction the shot came from (the direction the shot is going)
vecTraceDir = vecDir * -1.0f; vecTraceDir = vecDir * -1.0f;

View File

@ -155,13 +155,12 @@ public:
BOOL IsLockedByMaster() { return FALSE; } BOOL IsLockedByMaster() { return FALSE; }
public: public:
static CBaseEntity *Instance(edict_t *pent) static CBaseEntity *Instance(edict_t *pEdict)
{ {
if (!pent) if (!pEdict)
pent = ENT(0); pEdict = ENT(0);
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent); return GET_PRIVATE<CBaseEntity>(pEdict);
return pEntity;
} }
static CBaseEntity *Instance(entvars_t *pev) { return Instance(ENT(pev)); } static CBaseEntity *Instance(entvars_t *pev) { return Instance(ENT(pev)); }
@ -185,7 +184,7 @@ public:
return nullptr; return nullptr;
} }
static CBaseEntity *Create(char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = nullptr); static CBaseEntity *Create(const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = nullptr);
edict_t *edict() { return ENT(pev); } edict_t *edict() { return ENT(pev); }
EOFFSET eoffset() { return OFFSET(pev); } EOFFSET eoffset() { return OFFSET(pev); }
int entindex() { return ENTINDEX(edict()); } int entindex() { return ENTINDEX(edict()); }
@ -199,7 +198,7 @@ public:
CBaseEntity *m_pGoalEnt; // path corner we are heading towards CBaseEntity *m_pGoalEnt; // path corner we are heading towards
CBaseEntity *m_pLink; // used for temporary link-list operations. CBaseEntity *m_pLink; // used for temporary link-list operations.
static TYPEDESCRIPTION IMPL(m_SaveData)[5]; static TYPEDESCRIPTION m_SaveData[];
// fundamental callbacks // fundamental callbacks
void (CBaseEntity::*m_pfnThink)(); void (CBaseEntity::*m_pfnThink)();
@ -330,7 +329,7 @@ public:
void SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, float value); void SUB_UseTargets(CBaseEntity *pActivator, USE_TYPE useType, float value);
void EXPORT DelayThink(); void EXPORT DelayThink();
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[2]; static TYPEDESCRIPTION m_SaveData[];
float m_flDelay; float m_flDelay;
string_t m_iszKillTarget; string_t m_iszKillTarget;
@ -370,7 +369,7 @@ public:
#endif #endif
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[5]; static TYPEDESCRIPTION m_SaveData[];
// animation needs // animation needs
float m_flFrameRate; // computed FPS for current sequence float m_flFrameRate; // computed FPS for current sequence
@ -402,7 +401,7 @@ public:
static float AxisDelta(int flags, const Vector &angle1, const Vector &angle2); static float AxisDelta(int flags, const Vector &angle1, const Vector &angle2);
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[19]; static TYPEDESCRIPTION m_SaveData[];
TOGGLE_STATE m_toggle_state; TOGGLE_STATE m_toggle_state;
float m_flActivateFinished; // like attack_finished, but for doors float m_flActivateFinished; // like attack_finished, but for doors
@ -501,7 +500,7 @@ public:
BUTTON_CODE ButtonResponseToTouch(); BUTTON_CODE ButtonResponseToTouch();
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[8]; static TYPEDESCRIPTION m_SaveData[];
BOOL m_fStayPushed; // button stays pushed in until touched again? BOOL m_fStayPushed; // button stays pushed in until touched again?
BOOL m_fRotating; // a rotating button? default is a sliding button. BOOL m_fRotating; // a rotating button? default is a sliding button.
@ -541,7 +540,7 @@ public:
void EXPORT Register(); void EXPORT Register();
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[4]; static TYPEDESCRIPTION m_SaveData[];
EHandle m_rgEntities[MAX_MS_TARGETS]; EHandle m_rgEntities[MAX_MS_TARGETS];
int m_rgTriggered[MAX_MS_TARGETS]; int m_rgTriggered[MAX_MS_TARGETS];
@ -575,9 +574,6 @@ T *GetClassPtr(T *a)
a->m_pEntity->m_pContainingEntity = a; a->m_pEntity->m_pContainingEntity = a;
#endif #endif
#if defined(HOOK_GAMEDLL) && defined(_WIN32) && !defined(REGAMEDLL_UNIT_TESTS)
VirtualTableInit((void *)a, stripClass(typeid(T).name()));
#endif
} }
return a; return a;

View File

@ -1,13 +1,9 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
int giPrecacheGrunt = 0; int giPrecacheGrunt = 0;
int gmsgWeapPickup = 0; int gmsgWeapPickup = 0;
int gmsgHudText = 0; int gmsgHudText = 0;
int gmsgHudTextPro = 0;
int gmsgHudTextArgs = 0; int gmsgHudTextArgs = 0;
int gmsgShake = 0; int gmsgShake = 0;
int gmsgFade = 0; int gmsgFade = 0;
@ -137,8 +133,6 @@ static entity_field_alias_t custom_entity_field_alias[] =
{ "animtime", 0 }, { "animtime", 0 },
}; };
#endif // HOOK_GAMEDLL
bool g_bServerActive = false; bool g_bServerActive = false;
PLAYERPVSSTATUS g_PVSStatus[MAX_CLIENTS]; PLAYERPVSSTATUS g_PVSStatus[MAX_CLIENTS];
unsigned short m_usResetDecals; unsigned short m_usResetDecals;
@ -157,8 +151,8 @@ void LinkUserMessages()
gmsgDamage = REG_USER_MSG("Damage", 12); gmsgDamage = REG_USER_MSG("Damage", 12);
gmsgBattery = REG_USER_MSG("Battery", 2); gmsgBattery = REG_USER_MSG("Battery", 2);
gmsgTrain = REG_USER_MSG("Train", 1); gmsgTrain = REG_USER_MSG("Train", 1);
gmsgHudText = REG_USER_MSG("HudTextPro", -1); gmsgHudTextPro = REG_USER_MSG("HudTextPro", -1);
REG_USER_MSG("HudText", -1); gmsgHudText = REG_USER_MSG("HudText", -1);
gmsgSayText = REG_USER_MSG("SayText", -1); gmsgSayText = REG_USER_MSG("SayText", -1);
gmsgTextMsg = REG_USER_MSG("TextMsg", -1); gmsgTextMsg = REG_USER_MSG("TextMsg", -1);
gmsgWeaponList = REG_USER_MSG("WeaponList", -1); gmsgWeaponList = REG_USER_MSG("WeaponList", -1);
@ -233,29 +227,28 @@ void LinkUserMessages()
void WriteSigonMessages() void WriteSigonMessages()
{ {
for (int i = 0; i < MAX_WEAPONS; ++i) for (int i = 0; i < MAX_WEAPONS; i++)
{ {
ItemInfo &II = IMPL_CLASS(CBasePlayerItem, m_ItemInfoArray)[i]; ItemInfo &info = CBasePlayerItem::m_ItemInfoArray[i];
if (!info.iId)
if (!II.iId)
continue; continue;
const char *pszName; const char *pszName;
if (!II.pszName) if (!info.pszName)
pszName = "Empty"; pszName = "Empty";
else else
pszName = II.pszName; pszName = info.pszName;
MESSAGE_BEGIN(MSG_INIT, gmsgWeaponList); MESSAGE_BEGIN(MSG_INIT, gmsgWeaponList);
WRITE_STRING(pszName); WRITE_STRING(pszName);
WRITE_BYTE(CBasePlayer::GetAmmoIndex(II.pszAmmo1)); WRITE_BYTE(CBasePlayer::GetAmmoIndex(info.pszAmmo1));
WRITE_BYTE(II.iMaxAmmo1); WRITE_BYTE(info.iMaxAmmo1);
WRITE_BYTE(CBasePlayer::GetAmmoIndex(II.pszAmmo2)); WRITE_BYTE(CBasePlayer::GetAmmoIndex(info.pszAmmo2));
WRITE_BYTE(II.iMaxAmmo2); WRITE_BYTE(info.iMaxAmmo2);
WRITE_BYTE(II.iSlot); WRITE_BYTE(info.iSlot);
WRITE_BYTE(II.iPosition); WRITE_BYTE(info.iPosition);
WRITE_BYTE(II.iId); WRITE_BYTE(info.iId);
WRITE_BYTE(II.iFlags); WRITE_BYTE(info.iFlags);
MESSAGE_END(); MESSAGE_END();
} }
} }
@ -1016,10 +1009,10 @@ bool CanBuyThis(CBasePlayer *pPlayer, int iWeapon)
if (pPlayer->HasShield() && iWeapon == WEAPON_SHIELDGUN) if (pPlayer->HasShield() && iWeapon == WEAPON_SHIELDGUN)
return false; return false;
if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == WEAPON_ELITE && iWeapon == WEAPON_SHIELDGUN) if (pPlayer->m_rgpPlayerItems[PISTOL_SLOT] && pPlayer->m_rgpPlayerItems[PISTOL_SLOT]->m_iId == WEAPON_ELITE && iWeapon == WEAPON_SHIELDGUN)
return false; return false;
if (pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ] && pPlayer->m_rgpPlayerItems[ PRIMARY_WEAPON_SLOT ]->m_iId == iWeapon) if (pPlayer->m_rgpPlayerItems[PRIMARY_WEAPON_SLOT] && pPlayer->m_rgpPlayerItems[PRIMARY_WEAPON_SLOT]->m_iId == iWeapon)
{ {
if (g_bClientPrintEnable) if (g_bClientPrintEnable)
{ {
@ -1029,7 +1022,7 @@ bool CanBuyThis(CBasePlayer *pPlayer, int iWeapon)
return false; return false;
} }
if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ] && pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]->m_iId == iWeapon) if (pPlayer->m_rgpPlayerItems[PISTOL_SLOT] && pPlayer->m_rgpPlayerItems[PISTOL_SLOT]->m_iId == iWeapon)
{ {
if (g_bClientPrintEnable) if (g_bClientPrintEnable)
{ {
@ -1673,7 +1666,7 @@ void EXT_FUNC __API_HOOK(HandleMenu_ChooseAppearance)(CBasePlayer *pPlayer, int
pPlayer->m_iModelName = appearance.model_id; pPlayer->m_iModelName = appearance.model_id;
pPlayer->SetClientUserInfoModel(GET_INFO_BUFFER(pPlayer->edict()), appearance.model_name); pPlayer->SetClientUserInfoModel(GET_INFO_BUFFER(pPlayer->edict()), appearance.model_name);
pPlayer->SetNewPlayerModel(sPlayerModelFiles[ appearance.model_name_index ]); pPlayer->SetNewPlayerModel(sPlayerModelFiles[appearance.model_name_index]);
if (CSGameRules()->m_bMapHasVIPSafetyZone) if (CSGameRules()->m_bMapHasVIPSafetyZone)
{ {
@ -2236,12 +2229,12 @@ bool BuyAmmo(CBasePlayer *pPlayer, int nSlot, bool bBlinkMoney)
// nSlot == 1 : Primary weapons // nSlot == 1 : Primary weapons
// nSlot == 2 : Secondary weapons // nSlot == 2 : Secondary weapons
CBasePlayerItem *pItem = pPlayer->m_rgpPlayerItems[ nSlot ]; CBasePlayerItem *pItem = pPlayer->m_rgpPlayerItems[nSlot];
if (pPlayer->HasShield()) if (pPlayer->HasShield())
{ {
if (pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]) if (pPlayer->m_rgpPlayerItems[PISTOL_SLOT])
pItem = pPlayer->m_rgpPlayerItems[ PISTOL_SLOT ]; pItem = pPlayer->m_rgpPlayerItems[PISTOL_SLOT];
} }
if (pItem) if (pItem)
@ -3625,19 +3618,8 @@ void EXT_FUNC StartFrame()
CLocalNav::Think(); CLocalNav::Think();
static cvar_t *skill = nullptr;
if (!skill)
{
skill = CVAR_GET_POINTER("skill");
}
gpGlobals->teamplay = 1.0f; gpGlobals->teamplay = 1.0f;
g_iSkillLevel = g_pskill ? (int)g_pskill->value : 0;
if (skill)
g_iSkillLevel = int(skill->value);
else
g_iSkillLevel = 0;
if (TheBots) { if (TheBots) {
TheBots->StartFrame(); TheBots->StartFrame();
@ -4422,12 +4404,12 @@ void EXT_FUNC CreateBaseline(int player, int eindex, struct entity_state_s *base
void Entity_FieldInit(struct delta_s *pFields) void Entity_FieldInit(struct delta_s *pFields)
{ {
entity_field_alias[ FIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN0 ].name); entity_field_alias[FIELD_ORIGIN0].field = DELTA_FINDFIELD(pFields, entity_field_alias[FIELD_ORIGIN0].name);
entity_field_alias[ FIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN1 ].name); entity_field_alias[FIELD_ORIGIN1].field = DELTA_FINDFIELD(pFields, entity_field_alias[FIELD_ORIGIN1].name);
entity_field_alias[ FIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ORIGIN2 ].name); entity_field_alias[FIELD_ORIGIN2].field = DELTA_FINDFIELD(pFields, entity_field_alias[FIELD_ORIGIN2].name);
entity_field_alias[ FIELD_ANGLES0 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES0 ].name); entity_field_alias[FIELD_ANGLES0].field = DELTA_FINDFIELD(pFields, entity_field_alias[FIELD_ANGLES0].name);
entity_field_alias[ FIELD_ANGLES1 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES1 ].name); entity_field_alias[FIELD_ANGLES1].field = DELTA_FINDFIELD(pFields, entity_field_alias[FIELD_ANGLES1].name);
entity_field_alias[ FIELD_ANGLES2 ].field = DELTA_FINDFIELD(pFields, entity_field_alias[ FIELD_ANGLES2 ].name); entity_field_alias[FIELD_ANGLES2].field = DELTA_FINDFIELD(pFields, entity_field_alias[FIELD_ANGLES2].name);
} }
// Callback for sending entity_state_t info over network. // Callback for sending entity_state_t info over network.
@ -4451,39 +4433,39 @@ void Entity_Encode(struct delta_s *pFields, const unsigned char *from, const uns
if (localplayer) if (localplayer)
{ {
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN0].field);
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN1].field);
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN2].field);
} }
if (t->impacttime != 0 && t->starttime != 0) if (t->impacttime != 0 && t->starttime != 0)
{ {
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN0].field);
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN1].field);
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN2].field);
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES0 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ANGLES0].field);
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES1 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ANGLES1].field);
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ANGLES2 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ANGLES2].field);
} }
if (t->movetype == MOVETYPE_FOLLOW && t->aiment != 0) if (t->movetype == MOVETYPE_FOLLOW && t->aiment != 0)
{ {
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN0].field);
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN1].field);
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN2].field);
} }
else if (t->aiment != f->aiment) else if (t->aiment != f->aiment)
{ {
DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); DELTA_SETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN0].field);
DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); DELTA_SETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN1].field);
DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); DELTA_SETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN2].field);
} }
} }
void Player_FieldInit(struct delta_s *pFields) void Player_FieldInit(struct delta_s *pFields)
{ {
player_field_alias[ FIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN0 ].name); player_field_alias[FIELD_ORIGIN0].field = DELTA_FINDFIELD(pFields, player_field_alias[FIELD_ORIGIN0].name);
player_field_alias[ FIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN1 ].name); player_field_alias[FIELD_ORIGIN1].field = DELTA_FINDFIELD(pFields, player_field_alias[FIELD_ORIGIN1].name);
player_field_alias[ FIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, player_field_alias[ FIELD_ORIGIN2 ].name); player_field_alias[FIELD_ORIGIN2].field = DELTA_FINDFIELD(pFields, player_field_alias[FIELD_ORIGIN2].name);
} }
// Callback for sending entity_state_t for players info over network. // Callback for sending entity_state_t for players info over network.
@ -4507,35 +4489,35 @@ void Player_Encode(struct delta_s *pFields, const unsigned char *from, const uns
if (localplayer) if (localplayer)
{ {
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN0].field);
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN1].field);
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN2].field);
} }
if (t->movetype == MOVETYPE_FOLLOW && t->aiment != 0) if (t->movetype == MOVETYPE_FOLLOW && t->aiment != 0)
{ {
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN0].field);
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN1].field);
DELTA_UNSETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); DELTA_UNSETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN2].field);
} }
else if (t->aiment != f->aiment) else if (t->aiment != f->aiment)
{ {
DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN0 ].field); DELTA_SETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN0].field);
DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN1 ].field); DELTA_SETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN1].field);
DELTA_SETBYINDEX(pFields, entity_field_alias[ FIELD_ORIGIN2 ].field); DELTA_SETBYINDEX(pFields, entity_field_alias[FIELD_ORIGIN2].field);
} }
} }
void Custom_Entity_FieldInit(delta_s *pFields) void Custom_Entity_FieldInit(delta_s *pFields)
{ {
custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].name); custom_entity_field_alias[CUSTOMFIELD_ORIGIN0].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN0].name);
custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].name); custom_entity_field_alias[CUSTOMFIELD_ORIGIN1].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN1].name);
custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].name); custom_entity_field_alias[CUSTOMFIELD_ORIGIN2].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN2].name);
custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].name); custom_entity_field_alias[CUSTOMFIELD_ANGLES0].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES0].name);
custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].name); custom_entity_field_alias[CUSTOMFIELD_ANGLES1].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES1].name);
custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].name); custom_entity_field_alias[CUSTOMFIELD_ANGLES2].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES2].name);
custom_entity_field_alias[ CUSTOMFIELD_SKIN ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_SKIN ].name); custom_entity_field_alias[CUSTOMFIELD_SKIN].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[CUSTOMFIELD_SKIN].name);
custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].name); custom_entity_field_alias[CUSTOMFIELD_SEQUENCE].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[CUSTOMFIELD_SEQUENCE].name);
custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].name); custom_entity_field_alias[CUSTOMFIELD_ANIMTIME].field = DELTA_FINDFIELD(pFields, custom_entity_field_alias[CUSTOMFIELD_ANIMTIME].name);
} }
// Callback for sending entity_state_t info ( for custom entities ) over network. // Callback for sending entity_state_t info ( for custom entities ) over network.
@ -4560,27 +4542,27 @@ void Custom_Encode(struct delta_s *pFields, const unsigned char *from, const uns
{ {
if (beamType != BEAM_ENTPOINT) if (beamType != BEAM_ENTPOINT)
{ {
DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN0 ].field); DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN0].field);
DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN1 ].field); DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN1].field);
DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ORIGIN2 ].field); DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[CUSTOMFIELD_ORIGIN2].field);
} }
DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES0 ].field); DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES0].field);
DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES1 ].field); DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES1].field);
DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANGLES2 ].field); DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[CUSTOMFIELD_ANGLES2].field);
} }
if (beamType != BEAM_ENTS && beamType != BEAM_ENTPOINT) if (beamType != BEAM_ENTS && beamType != BEAM_ENTPOINT)
{ {
DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_SKIN ].field); DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[CUSTOMFIELD_SKIN].field);
DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_SEQUENCE ].field); DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[CUSTOMFIELD_SEQUENCE].field);
} }
// animtime is compared by rounding first // animtime is compared by rounding first
// see if we really shouldn't actually send it // see if we really shouldn't actually send it
if (int(f->animtime) == int(t->animtime)) if (int(f->animtime) == int(t->animtime))
{ {
DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[ CUSTOMFIELD_ANIMTIME ].field); DELTA_UNSETBYINDEX(pFields, custom_entity_field_alias[CUSTOMFIELD_ANIMTIME].field);
} }
} }
@ -4756,7 +4738,7 @@ void EXT_FUNC UpdateClientData(const edict_t *ent, int sendweapons, struct clien
if ((unsigned int)weapon->m_iPrimaryAmmoType < MAX_AMMO_SLOTS) if ((unsigned int)weapon->m_iPrimaryAmmoType < MAX_AMMO_SLOTS)
{ {
cd->vuser4.x = weapon->m_iPrimaryAmmoType; cd->vuser4.x = weapon->m_iPrimaryAmmoType;
cd->vuser4.y = pPlayer->m_rgAmmo[ weapon->m_iPrimaryAmmoType ]; cd->vuser4.y = pPlayer->m_rgAmmo[weapon->m_iPrimaryAmmoType];
} }
else else
{ {

View File

@ -210,6 +210,7 @@ inline const char *GetTeamName(int team)
extern int giPrecacheGrunt; extern int giPrecacheGrunt;
extern int gmsgWeapPickup; extern int gmsgWeapPickup;
extern int gmsgHudText; extern int gmsgHudText;
extern int gmsgHudTextPro;
extern int gmsgHudTextArgs; extern int gmsgHudTextArgs;
extern int gmsgShake; extern int gmsgShake;
extern int gmsgFade; extern int gmsgFade;

View File

@ -1,10 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
DebugOutputLevel outputLevel[] = DebugOutputLevel outputLevel[] =
{ {
{ "bot", DEBUG_BOT }, { "bot", DEBUG_BOT },
@ -16,9 +11,7 @@ DebugOutputLevel outputLevel[] =
}; };
unsigned int theDebugOutputTypes; unsigned int theDebugOutputTypes;
static char theDebugBuffer[MAX_DEBUG_BUFF_SIZE]; char theDebugBuffer[MAX_DEBUG_BUFF_SIZE];
#endif
bool IsDeveloper() bool IsDeveloper()
{ {

View File

@ -1,10 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CBaseDoor::m_SaveData[] = TYPEDESCRIPTION CBaseDoor::m_SaveData[] =
{ {
DEFINE_FIELD(CBaseDoor, m_bHealthValue, FIELD_CHARACTER), DEFINE_FIELD(CBaseDoor, m_bHealthValue, FIELD_CHARACTER),
@ -16,13 +11,6 @@ TYPEDESCRIPTION CBaseDoor::m_SaveData[] =
DEFINE_FIELD(CBaseDoor, m_bUnlockedSentence, FIELD_CHARACTER), DEFINE_FIELD(CBaseDoor, m_bUnlockedSentence, FIELD_CHARACTER),
}; };
TYPEDESCRIPTION CMomentaryDoor::m_SaveData[] =
{
DEFINE_FIELD(CMomentaryDoor, m_bMoveSnd, FIELD_CHARACTER),
};
#endif
IMPLEMENT_SAVERESTORE(CBaseDoor, CBaseToggle) IMPLEMENT_SAVERESTORE(CBaseDoor, CBaseToggle)
// play door or button locked or unlocked sounds. // play door or button locked or unlocked sounds.
@ -957,6 +945,11 @@ void CRotDoor::SetToggleState(int state)
UTIL_SetOrigin(pev, pev->origin); UTIL_SetOrigin(pev, pev->origin);
} }
TYPEDESCRIPTION CMomentaryDoor::m_SaveData[] =
{
DEFINE_FIELD(CMomentaryDoor, m_bMoveSnd, FIELD_CHARACTER),
};
LINK_ENTITY_TO_CLASS(momentary_door, CMomentaryDoor, CCSMomentaryDoor) LINK_ENTITY_TO_CLASS(momentary_door, CMomentaryDoor, CCSMomentaryDoor)
IMPLEMENT_SAVERESTORE(CMomentaryDoor, CBaseToggle) IMPLEMENT_SAVERESTORE(CMomentaryDoor, CBaseToggle)

View File

@ -60,7 +60,7 @@ public:
virtual void Blocked(CBaseEntity *pOther); virtual void Blocked(CBaseEntity *pOther);
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[7]; static TYPEDESCRIPTION m_SaveData[];
// used to selectivly override defaults // used to selectivly override defaults
void EXPORT DoorTouch(CBaseEntity *pOther); void EXPORT DoorTouch(CBaseEntity *pOther);
@ -110,7 +110,7 @@ public:
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[1]; static TYPEDESCRIPTION m_SaveData[];
byte m_bMoveSnd; // sound a door makes while moving byte m_bMoveSnd; // sound a door makes while moving
}; };

View File

@ -1,10 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CBubbling::m_SaveData[] = TYPEDESCRIPTION CBubbling::m_SaveData[] =
{ {
DEFINE_FIELD(CBubbling, m_density, FIELD_INTEGER), DEFINE_FIELD(CBubbling, m_density, FIELD_INTEGER),
@ -12,56 +7,6 @@ TYPEDESCRIPTION CBubbling::m_SaveData[] =
DEFINE_FIELD(CBubbling, m_state, FIELD_INTEGER), DEFINE_FIELD(CBubbling, m_state, FIELD_INTEGER),
}; };
TYPEDESCRIPTION CLightning::m_SaveData[] =
{
DEFINE_FIELD(CLightning, m_active, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_iszStartEntity, FIELD_STRING),
DEFINE_FIELD(CLightning, m_iszEndEntity, FIELD_STRING),
DEFINE_FIELD(CLightning, m_life, FIELD_FLOAT),
DEFINE_FIELD(CLightning, m_boltWidth, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_noiseAmplitude, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_brightness, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_speed, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_restrike, FIELD_FLOAT),
DEFINE_FIELD(CLightning, m_spriteTexture, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_iszSpriteName, FIELD_STRING),
DEFINE_FIELD(CLightning, m_frameStart, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_radius, FIELD_FLOAT),
};
TYPEDESCRIPTION CLaser::m_SaveData[] =
{
DEFINE_FIELD(CLaser, m_pSprite, FIELD_CLASSPTR),
DEFINE_FIELD(CLaser, m_iszSpriteName, FIELD_STRING),
DEFINE_FIELD(CLaser, m_firePosition, FIELD_POSITION_VECTOR),
};
TYPEDESCRIPTION CGlow::m_SaveData[] =
{
DEFINE_FIELD(CGlow, m_lastTime, FIELD_TIME),
DEFINE_FIELD(CGlow, m_maxFrame, FIELD_FLOAT),
};
TYPEDESCRIPTION CSprite::m_SaveData[] =
{
DEFINE_FIELD(CSprite, m_lastTime, FIELD_TIME),
DEFINE_FIELD(CSprite, m_maxFrame, FIELD_FLOAT),
};
TYPEDESCRIPTION CGibShooter::m_SaveData[] =
{
DEFINE_FIELD(CGibShooter, m_iGibs, FIELD_INTEGER),
DEFINE_FIELD(CGibShooter, m_iGibCapacity, FIELD_INTEGER),
DEFINE_FIELD(CGibShooter, m_iGibMaterial, FIELD_INTEGER),
DEFINE_FIELD(CGibShooter, m_iGibModelIndex, FIELD_INTEGER),
DEFINE_FIELD(CGibShooter, m_flGibVelocity, FIELD_FLOAT),
DEFINE_FIELD(CGibShooter, m_flVariance, FIELD_FLOAT),
DEFINE_FIELD(CGibShooter, m_flGibLife, FIELD_FLOAT),
};
#endif // HOOK_GAMEDLL
LINK_ENTITY_TO_CLASS(info_target, CPointEntity, CCSPointEntity)
LINK_ENTITY_TO_CLASS(env_bubbles, CBubbling, CCSBubbling) LINK_ENTITY_TO_CLASS(env_bubbles, CBubbling, CCSBubbling)
IMPLEMENT_SAVERESTORE(CBubbling, CBaseEntity) IMPLEMENT_SAVERESTORE(CBubbling, CBaseEntity)
@ -352,6 +297,23 @@ void CBeam::DoSparks(const Vector &start, const Vector &end)
} }
} }
TYPEDESCRIPTION CLightning::m_SaveData[] =
{
DEFINE_FIELD(CLightning, m_active, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_iszStartEntity, FIELD_STRING),
DEFINE_FIELD(CLightning, m_iszEndEntity, FIELD_STRING),
DEFINE_FIELD(CLightning, m_life, FIELD_FLOAT),
DEFINE_FIELD(CLightning, m_boltWidth, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_noiseAmplitude, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_brightness, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_speed, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_restrike, FIELD_FLOAT),
DEFINE_FIELD(CLightning, m_spriteTexture, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_iszSpriteName, FIELD_STRING),
DEFINE_FIELD(CLightning, m_frameStart, FIELD_INTEGER),
DEFINE_FIELD(CLightning, m_radius, FIELD_FLOAT),
};
LINK_ENTITY_TO_CLASS(env_lightning, CLightning, CCSLightning) LINK_ENTITY_TO_CLASS(env_lightning, CLightning, CCSLightning)
LINK_ENTITY_TO_CLASS(env_beam, CLightning, CCSLightning) LINK_ENTITY_TO_CLASS(env_beam, CLightning, CCSLightning)
IMPLEMENT_SAVERESTORE(CLightning, CBeam) IMPLEMENT_SAVERESTORE(CLightning, CBeam)
@ -850,6 +812,13 @@ void CLightning::BeamUpdateVars()
} }
} }
TYPEDESCRIPTION CLaser::m_SaveData[] =
{
DEFINE_FIELD(CLaser, m_pSprite, FIELD_CLASSPTR),
DEFINE_FIELD(CLaser, m_iszSpriteName, FIELD_STRING),
DEFINE_FIELD(CLaser, m_firePosition, FIELD_POSITION_VECTOR),
};
LINK_ENTITY_TO_CLASS(env_laser, CLaser, CCSLaser) LINK_ENTITY_TO_CLASS(env_laser, CLaser, CCSLaser)
IMPLEMENT_SAVERESTORE(CLaser, CBeam) IMPLEMENT_SAVERESTORE(CLaser, CBeam)
@ -1011,6 +980,12 @@ void CLaser::StrikeThink()
pev->nextthink = gpGlobals->time + 0.1f; pev->nextthink = gpGlobals->time + 0.1f;
} }
TYPEDESCRIPTION CGlow::m_SaveData[] =
{
DEFINE_FIELD(CGlow, m_lastTime, FIELD_TIME),
DEFINE_FIELD(CGlow, m_maxFrame, FIELD_FLOAT),
};
LINK_ENTITY_TO_CLASS(env_glow, CGlow, CCSGlow) LINK_ENTITY_TO_CLASS(env_glow, CGlow, CCSGlow)
IMPLEMENT_SAVERESTORE(CGlow, CPointEntity) IMPLEMENT_SAVERESTORE(CGlow, CPointEntity)
@ -1102,6 +1077,12 @@ void CBombGlow::Think()
pev->nextthink = gpGlobals->time + 0.05f; pev->nextthink = gpGlobals->time + 0.05f;
} }
TYPEDESCRIPTION CSprite::m_SaveData[] =
{
DEFINE_FIELD(CSprite, m_lastTime, FIELD_TIME),
DEFINE_FIELD(CSprite, m_maxFrame, FIELD_FLOAT),
};
LINK_ENTITY_TO_CLASS(env_sprite, CSprite, CCSSprite) LINK_ENTITY_TO_CLASS(env_sprite, CSprite, CCSSprite)
IMPLEMENT_SAVERESTORE(CSprite, CPointEntity) IMPLEMENT_SAVERESTORE(CSprite, CPointEntity)
@ -1278,6 +1259,17 @@ void CSprite::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTyp
} }
} }
TYPEDESCRIPTION CGibShooter::m_SaveData[] =
{
DEFINE_FIELD(CGibShooter, m_iGibs, FIELD_INTEGER),
DEFINE_FIELD(CGibShooter, m_iGibCapacity, FIELD_INTEGER),
DEFINE_FIELD(CGibShooter, m_iGibMaterial, FIELD_INTEGER),
DEFINE_FIELD(CGibShooter, m_iGibModelIndex, FIELD_INTEGER),
DEFINE_FIELD(CGibShooter, m_flGibVelocity, FIELD_FLOAT),
DEFINE_FIELD(CGibShooter, m_flVariance, FIELD_FLOAT),
DEFINE_FIELD(CGibShooter, m_flGibLife, FIELD_FLOAT),
};
IMPLEMENT_SAVERESTORE(CGibShooter, CBaseDelay) IMPLEMENT_SAVERESTORE(CGibShooter, CBaseDelay)
LINK_ENTITY_TO_CLASS(gibshooter, CGibShooter, CCSGibShooter) LINK_ENTITY_TO_CLASS(gibshooter, CGibShooter, CCSGibShooter)
@ -2014,3 +2006,27 @@ void CItemSoda::CanTouch(CBaseEntity *pOther)
SetThink(&CItemSoda::SUB_Remove); SetThink(&CItemSoda::SUB_Remove);
pev->nextthink = gpGlobals->time; pev->nextthink = gpGlobals->time;
} }
LINK_ENTITY_TO_CLASS(info_intermission, CInfoIntermission, CCSInfoIntermission)
void CInfoIntermission::Spawn()
{
UTIL_SetOrigin(pev, pev->origin);
pev->solid = SOLID_NOT;
pev->effects = EF_NODRAW;
pev->v_angle = g_vecZero;
pev->nextthink = gpGlobals->time + 2.0f; // let targets spawn!
}
void CInfoIntermission::Think()
{
// find my target
edict_t *pTarget = FIND_ENTITY_BY_TARGETNAME(nullptr, STRING(pev->target));
if (!FNullEnt(pTarget))
{
pev->v_angle = UTIL_VecToAngles((pTarget->v.origin - pev->origin).Normalize());
pev->v_angle.x = -pev->v_angle.x;
}
}

View File

@ -99,7 +99,7 @@ public:
void EXPORT AnimateUntilDead(); void EXPORT AnimateUntilDead();
static CSprite *SpriteCreate(const char *pSpriteName, const Vector &origin, BOOL animate); static CSprite *SpriteCreate(const char *pSpriteName, const Vector &origin, BOOL animate);
static TYPEDESCRIPTION IMPL(m_SaveData)[2]; static TYPEDESCRIPTION m_SaveData[];
private: private:
float m_lastTime; float m_lastTime;
@ -211,7 +211,7 @@ public:
void EXPORT StrikeThink(); void EXPORT StrikeThink();
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[3]; static TYPEDESCRIPTION m_SaveData[];
CSprite *m_pSprite; CSprite *m_pSprite;
int m_iszSpriteName; int m_iszSpriteName;
@ -235,7 +235,7 @@ public:
void EXPORT FizzThink(); void EXPORT FizzThink();
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[3]; static TYPEDESCRIPTION m_SaveData[];
int m_density; int m_density;
int m_frequency; int m_frequency;
@ -272,7 +272,7 @@ public:
void BeamUpdateVars(); void BeamUpdateVars();
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[13]; static TYPEDESCRIPTION m_SaveData[];
int m_active; int m_active;
int m_iszStartEntity; int m_iszStartEntity;
@ -300,7 +300,7 @@ public:
void Animate(float frames); void Animate(float frames);
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[2]; static TYPEDESCRIPTION m_SaveData[];
float m_lastTime; float m_lastTime;
float m_maxFrame; float m_maxFrame;
@ -335,7 +335,7 @@ public:
void EXPORT ShootThink(); void EXPORT ShootThink();
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[7]; static TYPEDESCRIPTION m_SaveData[];
int m_iGibs; int m_iGibs;
int m_iGibCapacity; int m_iGibCapacity;
@ -487,4 +487,12 @@ public:
void EXPORT CanTouch(CBaseEntity *pOther); void EXPORT CanTouch(CBaseEntity *pOther);
}; };
// Multiplayer intermission spots.
class CInfoIntermission: public CPointEntity
{
public:
virtual void Spawn();
virtual void Think();
};
int IsPointEntity(CBaseEntity *pEnt); int IsPointEntity(CBaseEntity *pEnt);

View File

@ -189,7 +189,7 @@ inline bool EntityHandle<T>::operator==(T *pEntity) const
template <typename T> template <typename T>
inline EntityHandle<T>::operator bool() const inline EntityHandle<T>::operator bool() const
{ {
return Get() != nullptr; return IsValid();
} }
// Gets the Entity this handle refers to. // Gets the Entity this handle refers to.

View File

@ -1,18 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CEnvExplosion::m_SaveData[] =
{
DEFINE_FIELD(CEnvExplosion, m_iMagnitude, FIELD_INTEGER),
DEFINE_FIELD(CEnvExplosion, m_spriteScale, FIELD_INTEGER),
};
#endif
LINK_ENTITY_TO_CLASS(spark_shower, CShower, CCSShower) LINK_ENTITY_TO_CLASS(spark_shower, CShower, CCSShower)
void CShower::Spawn() void CShower::Spawn()
@ -67,6 +54,12 @@ void CShower::Touch(CBaseEntity *pOther)
} }
} }
TYPEDESCRIPTION CEnvExplosion::m_SaveData[] =
{
DEFINE_FIELD(CEnvExplosion, m_iMagnitude, FIELD_INTEGER),
DEFINE_FIELD(CEnvExplosion, m_spriteScale, FIELD_INTEGER),
};
IMPLEMENT_SAVERESTORE(CEnvExplosion, CBaseMonster) IMPLEMENT_SAVERESTORE(CEnvExplosion, CBaseMonster)
LINK_ENTITY_TO_CLASS(env_explosion, CEnvExplosion, CCSEnvExplosion) LINK_ENTITY_TO_CLASS(env_explosion, CEnvExplosion, CCSEnvExplosion)

View File

@ -57,7 +57,7 @@ public:
void EXPORT Smoke(); void EXPORT Smoke();
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[2]; static TYPEDESCRIPTION m_SaveData[];
int m_iMagnitude; int m_iMagnitude;
int m_spriteScale; int m_spriteScale;

View File

@ -39,15 +39,12 @@
#include "strtools.h" #include "strtools.h"
#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define NOWINRES #define NOWINRES
#define NOSERVICE #define NOSERVICE
#define NOMCX #define NOMCX
#define NOIME #define NOIME
#include "winsani_in.h" #include <windows.h>
#include "windows.h"
#include "winsani_out.h"
#undef PlaySound
#else #else
#include <limits.h> #include <limits.h>
#include <stdarg.h> #include <stdarg.h>

View File

@ -1,14 +1,9 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
// Just add more items to the bottom of this array and they will automagically be supported // Just add more items to the bottom of this array and they will automagically be supported
// This is done instead of just a classname in the FGD so we can control which entities can // This is done instead of just a classname in the FGD so we can control which entities can
// be spawned, and still remain fairly flexible // be spawned, and still remain fairly flexible
const char *CBreakable::pSpawnObjects[] = const char *CBreakable::m_pszSpawnObjects[] =
{ {
nullptr, nullptr,
"item_battery", "item_battery",
@ -44,14 +39,14 @@ const char *CBreakable::pSpawnObjects[] =
"weapon_flashbang" "weapon_flashbang"
}; };
const char *CBreakable::pSoundsWood[] = const char *CBreakable::m_pszSoundsWood[] =
{ {
"debris/wood1.wav", "debris/wood1.wav",
"debris/wood2.wav", "debris/wood2.wav",
"debris/wood3.wav" "debris/wood3.wav"
}; };
const char *CBreakable::pSoundsFlesh[] = const char *CBreakable::m_pszSoundsFlesh[] =
{ {
"debris/flesh1.wav", "debris/flesh1.wav",
"debris/flesh2.wav", "debris/flesh2.wav",
@ -61,34 +56,27 @@ const char *CBreakable::pSoundsFlesh[] =
"debris/flesh7.wav" "debris/flesh7.wav"
}; };
const char *CBreakable::pSoundsMetal[] = const char *CBreakable::m_pszSoundsMetal[] =
{ {
"debris/metal1.wav", "debris/metal1.wav",
"debris/metal2.wav", "debris/metal2.wav",
"debris/metal3.wav" "debris/metal3.wav"
}; };
const char *CBreakable::pSoundsConcrete[] = const char *CBreakable::m_pszSoundsConcrete[] =
{ {
"debris/concrete1.wav", "debris/concrete1.wav",
"debris/concrete2.wav", "debris/concrete2.wav",
"debris/concrete3.wav" "debris/concrete3.wav"
}; };
const char *CBreakable::pSoundsGlass[] = const char *CBreakable::m_pszSoundsGlass[] =
{ {
"debris/glass1.wav", "debris/glass1.wav",
"debris/glass2.wav", "debris/glass2.wav",
"debris/glass3.wav" "debris/glass3.wav"
}; };
char *CPushable::m_soundNames[] =
{
"debris/pushbox1.wav",
"debris/pushbox2.wav",
"debris/pushbox3.wav"
};
TYPEDESCRIPTION CBreakable::m_SaveData[] = TYPEDESCRIPTION CBreakable::m_SaveData[] =
{ {
DEFINE_FIELD(CBreakable, m_Material, FIELD_INTEGER), DEFINE_FIELD(CBreakable, m_Material, FIELD_INTEGER),
@ -98,80 +86,6 @@ TYPEDESCRIPTION CBreakable::m_SaveData[] =
DEFINE_FIELD(CBreakable, m_iszSpawnObject, FIELD_STRING), DEFINE_FIELD(CBreakable, m_iszSpawnObject, FIELD_STRING),
}; };
TYPEDESCRIPTION CPushable::m_SaveData[] =
{
DEFINE_FIELD(CPushable, m_maxSpeed, FIELD_FLOAT),
DEFINE_FIELD(CPushable, m_soundTime, FIELD_TIME),
};
#endif // HOOK_GAMEDLL
void CBreakable::KeyValue(KeyValueData *pkvd)
{
// UNDONE_WC: explicitly ignoring these fields, but they shouldn't be in the map file!
if (FStrEq(pkvd->szKeyName, "explosion"))
{
if (!Q_stricmp(pkvd->szValue, "directed"))
m_Explosion = expDirected;
else if (!Q_stricmp(pkvd->szValue, "random"))
m_Explosion = expRandom;
else
m_Explosion = expRandom;
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "material"))
{
Materials type = (Materials)Q_atoi(pkvd->szValue);
// 0:glass, 1:wood, 2:metal, 3:flesh etc
if (type < 0 || type >= matLastMaterial)
m_Material = matWood;
else
m_Material = type;
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "deadmodel"))
{
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "shards"))
{
//m_iShards = Q_atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "gibmodel"))
{
m_iszGibModel = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "spawnobject"))
{
int object = Q_atoi(pkvd->szValue);
if (object > 0 && object < ARRAYSIZE(pSpawnObjects))
{
m_iszSpawnObject = MAKE_STRING(pSpawnObjects[object]);
}
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "explodemagnitude"))
{
ExplosionSetMagnitude(Q_atoi(pkvd->szValue));
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "lip"))
{
pkvd->fHandled = TRUE;
}
else
{
CBaseDelay::KeyValue(pkvd);
}
}
LINK_ENTITY_TO_CLASS(func_breakable, CBreakable, CCSBreakable) LINK_ENTITY_TO_CLASS(func_breakable, CBreakable, CCSBreakable)
IMPLEMENT_SAVERESTORE(CBreakable, CBaseEntity) IMPLEMENT_SAVERESTORE(CBreakable, CBaseEntity)
@ -245,6 +159,72 @@ void CBreakable::Restart()
} }
} }
void CBreakable::KeyValue(KeyValueData *pkvd)
{
// UNDONE_WC: explicitly ignoring these fields, but they shouldn't be in the map file!
if (FStrEq(pkvd->szKeyName, "explosion"))
{
if (!Q_stricmp(pkvd->szValue, "directed"))
m_Explosion = expDirected;
else if (!Q_stricmp(pkvd->szValue, "random"))
m_Explosion = expRandom;
else
m_Explosion = expRandom;
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "material"))
{
Materials type = (Materials)Q_atoi(pkvd->szValue);
// 0:glass, 1:wood, 2:metal, 3:flesh etc
if (type < 0 || type >= matLastMaterial)
m_Material = matWood;
else
m_Material = type;
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "deadmodel"))
{
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "shards"))
{
//m_iShards = Q_atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "gibmodel"))
{
m_iszGibModel = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "spawnobject"))
{
int object = Q_atoi(pkvd->szValue);
if (object > 0 && object < ARRAYSIZE(m_pszSpawnObjects))
{
m_iszSpawnObject = MAKE_STRING(m_pszSpawnObjects[object]);
}
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "explodemagnitude"))
{
ExplosionSetMagnitude(Q_atoi(pkvd->szValue));
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "lip"))
{
pkvd->fHandled = TRUE;
}
else
{
CBaseDelay::KeyValue(pkvd);
}
}
const char **CBreakable::MaterialSoundList(Materials precacheMaterial, int &soundCount) const char **CBreakable::MaterialSoundList(Materials precacheMaterial, int &soundCount)
{ {
const char **pSoundList; const char **pSoundList;
@ -253,35 +233,35 @@ const char **CBreakable::MaterialSoundList(Materials precacheMaterial, int &soun
{ {
case matWood: case matWood:
{ {
pSoundList = pSoundsWood; pSoundList = m_pszSoundsWood;
soundCount = ARRAYSIZE(pSoundsWood); soundCount = ARRAYSIZE(m_pszSoundsWood);
break; break;
} }
case matFlesh: case matFlesh:
{ {
pSoundList = pSoundsFlesh; pSoundList = m_pszSoundsFlesh;
soundCount = ARRAYSIZE(pSoundsFlesh); soundCount = ARRAYSIZE(m_pszSoundsFlesh);
break; break;
} }
case matGlass: case matGlass:
case matComputer: case matComputer:
case matUnbreakableGlass: case matUnbreakableGlass:
{ {
pSoundList = pSoundsGlass; pSoundList = m_pszSoundsGlass;
soundCount = ARRAYSIZE(pSoundsGlass); soundCount = ARRAYSIZE(m_pszSoundsGlass);
break; break;
} }
case matMetal: case matMetal:
{ {
pSoundList = pSoundsMetal; pSoundList = m_pszSoundsMetal;
soundCount = ARRAYSIZE(pSoundsMetal); soundCount = ARRAYSIZE(m_pszSoundsMetal);
break; break;
} }
case matCinderBlock: case matCinderBlock:
case matRocks: case matRocks:
{ {
pSoundList = pSoundsConcrete; pSoundList = m_pszSoundsConcrete;
soundCount = ARRAYSIZE(pSoundsConcrete); soundCount = ARRAYSIZE(m_pszSoundsConcrete);
break; break;
} }
case matCeilingTile: case matCeilingTile:
@ -315,7 +295,7 @@ void CBreakable::MaterialSoundRandom(edict_t *pEdict, Materials soundMaterial, f
if (soundCount) if (soundCount)
{ {
EMIT_SOUND(pEdict, CHAN_BODY, pSoundList[ RANDOM_LONG(0, soundCount - 1) ], volume, 1.0); EMIT_SOUND(pEdict, CHAN_BODY, pSoundList[RANDOM_LONG(0, soundCount - 1)], volume, 1.0);
} }
} }
@ -386,13 +366,13 @@ void CBreakable::Precache()
if (pGibName) if (pGibName)
{ {
m_idShard = PRECACHE_MODEL((char *)pGibName); m_idShard = PRECACHE_MODEL(pGibName);
} }
// Precache the spawn item's data // Precache the spawn item's data
if (m_iszSpawnObject) if (m_iszSpawnObject)
{ {
UTIL_PrecacheOther((char *)STRING(m_iszSpawnObject)); UTIL_PrecacheOther(STRING(m_iszSpawnObject));
} }
} }
@ -863,6 +843,19 @@ int CBreakable::DamageDecal(int bitsDamageType)
return CBaseEntity::DamageDecal(bitsDamageType); return CBaseEntity::DamageDecal(bitsDamageType);
} }
TYPEDESCRIPTION CPushable::m_SaveData[] =
{
DEFINE_FIELD(CPushable, m_maxSpeed, FIELD_FLOAT),
DEFINE_FIELD(CPushable, m_soundTime, FIELD_TIME),
};
const char *CPushable::m_soundNames[] =
{
"debris/pushbox1.wav",
"debris/pushbox2.wav",
"debris/pushbox3.wav"
};
LINK_ENTITY_TO_CLASS(func_pushable, CPushable, CCSPushable) LINK_ENTITY_TO_CLASS(func_pushable, CPushable, CCSPushable)
IMPLEMENT_SAVERESTORE(CPushable, CBreakable) IMPLEMENT_SAVERESTORE(CPushable, CBreakable)
@ -903,7 +896,7 @@ void CPushable::Spawn()
void CPushable::Precache() void CPushable::Precache()
{ {
for (int i = 0; i < 3; ++i) for (int i = 0; i < ARRAYSIZE(m_soundNames); i++)
{ {
PRECACHE_SOUND(m_soundNames[i]); PRECACHE_SOUND(m_soundNames[i]);
} }

View File

@ -97,14 +97,14 @@ public:
static void MaterialSoundRandom(edict_t *pEdict, Materials soundMaterial, float volume); static void MaterialSoundRandom(edict_t *pEdict, Materials soundMaterial, float volume);
static const char **MaterialSoundList(Materials precacheMaterial, int &soundCount); static const char **MaterialSoundList(Materials precacheMaterial, int &soundCount);
static const char *pSoundsWood[3]; static const char *m_pszSpawnObjects[32];
static const char *pSoundsFlesh[6]; static const char *m_pszSoundsWood[3];
static const char *pSoundsGlass[3]; static const char *m_pszSoundsFlesh[6];
static const char *pSoundsMetal[3]; static const char *m_pszSoundsMetal[3];
static const char *pSoundsConcrete[3]; static const char *m_pszSoundsConcrete[3];
static const char *pSpawnObjects[32]; static const char *m_pszSoundsGlass[3];
static TYPEDESCRIPTION IMPL(m_SaveData)[5]; static TYPEDESCRIPTION m_SaveData[];
public: public:
Materials m_Material; Materials m_Material;
@ -149,8 +149,8 @@ public:
float MaxSpeed() const { return m_maxSpeed; } float MaxSpeed() const { return m_maxSpeed; }
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[2]; static TYPEDESCRIPTION m_SaveData[];
static char *m_soundNames[3]; static const char *m_soundNames[];
int m_lastSound; int m_lastSound;
float m_maxSpeed; float m_maxSpeed;

View File

@ -1,10 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CFuncTank::m_SaveData[] = TYPEDESCRIPTION CFuncTank::m_SaveData[] =
{ {
DEFINE_FIELD(CFuncTank, m_yawCenter, FIELD_FLOAT), DEFINE_FIELD(CFuncTank, m_yawCenter, FIELD_FLOAT),
@ -35,18 +30,7 @@ TYPEDESCRIPTION CFuncTank::m_SaveData[] =
DEFINE_FIELD(CFuncTank, m_iszMaster, FIELD_STRING), DEFINE_FIELD(CFuncTank, m_iszMaster, FIELD_STRING),
}; };
TYPEDESCRIPTION CFuncTankLaser::m_SaveData[] = Vector CFuncTank::m_TankSpread[] =
{
DEFINE_FIELD(CFuncTankLaser, m_pLaser, FIELD_CLASSPTR),
DEFINE_FIELD(CFuncTankLaser, m_laserTime, FIELD_TIME),
};
TYPEDESCRIPTION CFuncTankControls::m_SaveData[] =
{
DEFINE_FIELD(CFuncTankControls, m_pTank, FIELD_CLASSPTR),
};
Vector gTankSpread[] =
{ {
Vector(0, 0, 0), // perfect Vector(0, 0, 0), // perfect
Vector(0.025, 0.025, 0.025), // small cone Vector(0.025, 0.025, 0.025), // small cone
@ -55,9 +39,7 @@ Vector gTankSpread[] =
Vector(0.25, 0.25, 0.25), // extra-large cone Vector(0.25, 0.25, 0.25), // extra-large cone
}; };
#endif // HOOK_GAMEDLL constexpr int MAX_FIRING_SPREADS = ARRAYSIZE(CFuncTank::m_TankSpread);
const int MAX_FIRING_SPREADS = ARRAYSIZE(gTankSpread);
IMPLEMENT_SAVERESTORE(CFuncTank, CBaseEntity) IMPLEMENT_SAVERESTORE(CFuncTank, CBaseEntity)
@ -379,7 +361,7 @@ void CFuncTank::Think()
pev->avelocity = g_vecZero; pev->avelocity = g_vecZero;
TrackTarget(); TrackTarget();
if (Q_fabs(float_precision(pev->avelocity.x)) > 1 || Q_fabs(float_precision(pev->avelocity.y)) > 1) if (fabs(float_precision(pev->avelocity.x)) > 1 || fabs(float_precision(pev->avelocity.y)) > 1)
StartRotSound(); StartRotSound();
else else
StopRotSound(); StopRotSound();
@ -526,7 +508,7 @@ void CFuncTank::TrackTarget()
return; return;
} }
if (CanFire() && ((Q_fabs(distX) < m_pitchTolerance && Q_fabs(distY) < m_yawTolerance) || (pev->spawnflags & SF_TANK_LINEOFSIGHT))) if (CanFire() && ((fabs(distX) < m_pitchTolerance && fabs(distY) < m_yawTolerance) || (pev->spawnflags & SF_TANK_LINEOFSIGHT)))
{ {
bool fire = false; bool fire = false;
Vector forward; Vector forward;
@ -569,13 +551,13 @@ void CFuncTank::AdjustAnglesForBarrel(Vector &angles, float distance)
if (m_barrelPos.y) if (m_barrelPos.y)
{ {
r2 = m_barrelPos.y * m_barrelPos.y; r2 = m_barrelPos.y * m_barrelPos.y;
angles.y += (180.0f / M_PI) * Q_atan2(m_barrelPos.y, Q_sqrt(d2 - r2)); angles.y += (180.0f / M_PI) * atan2(m_barrelPos.y, Q_sqrt(d2 - r2));
} }
if (m_barrelPos.z) if (m_barrelPos.z)
{ {
r2 = m_barrelPos.z * m_barrelPos.z; r2 = m_barrelPos.z * m_barrelPos.z;
angles.x += (180.0f / M_PI) * Q_atan2(-m_barrelPos.z, Q_sqrt(d2 - r2)); angles.x += (180.0f / M_PI) * atan2(-m_barrelPos.z, Q_sqrt(d2 - r2));
} }
} }
} }
@ -665,7 +647,6 @@ void CFuncTankGun::Fire(const Vector &barrelEnd, const Vector &forward, entvars_
UTIL_MakeAimVectors(pev->angles); UTIL_MakeAimVectors(pev->angles);
int bulletCount = int((gpGlobals->time - m_fireLast) * m_fireRate); int bulletCount = int((gpGlobals->time - m_fireLast) * m_fireRate);
if (bulletCount > 0) if (bulletCount > 0)
{ {
for (int i = 0; i < bulletCount; i++) for (int i = 0; i < bulletCount; i++)
@ -673,13 +654,13 @@ void CFuncTankGun::Fire(const Vector &barrelEnd, const Vector &forward, entvars_
switch (m_bulletType) switch (m_bulletType)
{ {
case TANK_BULLET_9MM: case TANK_BULLET_9MM:
FireBullets(1, barrelEnd, forward, gTankSpread[m_spread], 4096, BULLET_MONSTER_9MM, 1, m_iBulletDamage, pevAttacker); FireBullets(1, barrelEnd, forward, m_TankSpread[m_spread], 4096, BULLET_MONSTER_9MM, 1, m_iBulletDamage, pevAttacker);
break; break;
case TANK_BULLET_MP5: case TANK_BULLET_MP5:
FireBullets(1, barrelEnd, forward, gTankSpread[m_spread], 4096, BULLET_MONSTER_MP5, 1, m_iBulletDamage, pevAttacker); FireBullets(1, barrelEnd, forward, m_TankSpread[m_spread], 4096, BULLET_MONSTER_MP5, 1, m_iBulletDamage, pevAttacker);
break; break;
case TANK_BULLET_12MM: case TANK_BULLET_12MM:
FireBullets(1, barrelEnd, forward, gTankSpread[m_spread], 4096, BULLET_MONSTER_12MM, 1, m_iBulletDamage, pevAttacker); FireBullets(1, barrelEnd, forward, m_TankSpread[m_spread], 4096, BULLET_MONSTER_12MM, 1, m_iBulletDamage, pevAttacker);
break; break;
default: default:
case TANK_BULLET_NONE: case TANK_BULLET_NONE:
@ -696,6 +677,12 @@ void CFuncTankGun::Fire(const Vector &barrelEnd, const Vector &forward, entvars_
} }
} }
TYPEDESCRIPTION CFuncTankLaser::m_SaveData[] =
{
DEFINE_FIELD(CFuncTankLaser, m_pLaser, FIELD_CLASSPTR),
DEFINE_FIELD(CFuncTankLaser, m_laserTime, FIELD_TIME),
};
LINK_ENTITY_TO_CLASS(func_tanklaser, CFuncTankLaser, CCSFuncTankLaser) LINK_ENTITY_TO_CLASS(func_tanklaser, CFuncTankLaser, CCSFuncTankLaser)
IMPLEMENT_SAVERESTORE(CFuncTankLaser, CFuncTank) IMPLEMENT_SAVERESTORE(CFuncTankLaser, CFuncTank)
@ -761,22 +748,19 @@ void CFuncTankLaser::Think()
void CFuncTankLaser::Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) void CFuncTankLaser::Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker)
{ {
int i;
TraceResult tr;
if (m_fireLast != 0.0f && GetLaser()) if (m_fireLast != 0.0f && GetLaser())
{ {
// TankTrace needs gpGlobals->v_up, etc. // TankTrace needs gpGlobals->v_up, etc.
UTIL_MakeAimVectors(pev->angles); UTIL_MakeAimVectors(pev->angles);
int bulletCount = int((gpGlobals->time - m_fireLast) * m_fireRate); int bulletCount = int((gpGlobals->time - m_fireLast) * m_fireRate);
if (bulletCount) if (bulletCount)
{ {
for (i = 0; i < bulletCount; i++) TraceResult tr;
for (int i = 0; i < bulletCount; i++)
{ {
m_pLaser->pev->origin = barrelEnd; m_pLaser->pev->origin = barrelEnd;
TankTrace(barrelEnd, forward, gTankSpread[m_spread], tr); TankTrace(barrelEnd, forward, m_TankSpread[m_spread], tr);
m_laserTime = gpGlobals->time; m_laserTime = gpGlobals->time;
m_pLaser->TurnOn(); m_pLaser->TurnOn();
@ -804,14 +788,12 @@ void CFuncTankRocket::Precache()
void CFuncTankRocket::Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker) void CFuncTankRocket::Fire(const Vector &barrelEnd, const Vector &forward, entvars_t *pevAttacker)
{ {
int i;
if (m_fireLast != 0.0f) if (m_fireLast != 0.0f)
{ {
int bulletCount = int((gpGlobals->time - m_fireLast) * m_fireRate); int bulletCount = int((gpGlobals->time - m_fireLast) * m_fireRate);
if (bulletCount > 0) if (bulletCount > 0)
{ {
for (i = 0; i < bulletCount; i++) for (int i = 0; i < bulletCount; i++)
{ {
CBaseEntity *pRocket = CBaseEntity::Create("rpg_rocket", barrelEnd, pev->angles, edict()); CBaseEntity *pRocket = CBaseEntity::Create("rpg_rocket", barrelEnd, pev->angles, edict());
} }
@ -854,7 +836,7 @@ void CFuncTankMortar::Fire(const Vector &barrelEnd, const Vector &forward, entva
// TankTrace needs gpGlobals->v_up, etc. // TankTrace needs gpGlobals->v_up, etc.
UTIL_MakeAimVectors(pev->angles); UTIL_MakeAimVectors(pev->angles);
TankTrace(barrelEnd, forward, gTankSpread[m_spread], tr); TankTrace(barrelEnd, forward, m_TankSpread[m_spread], tr);
ExplosionCreate(tr.vecEndPos, pev->angles, edict(), pev->impulse, TRUE); ExplosionCreate(tr.vecEndPos, pev->angles, edict(), pev->impulse, TRUE);
CFuncTank::Fire(barrelEnd, forward, pev); CFuncTank::Fire(barrelEnd, forward, pev);
} }
@ -865,6 +847,11 @@ void CFuncTankMortar::Fire(const Vector &barrelEnd, const Vector &forward, entva
} }
} }
TYPEDESCRIPTION CFuncTankControls::m_SaveData[] =
{
DEFINE_FIELD(CFuncTankControls, m_pTank, FIELD_CLASSPTR),
};
LINK_ENTITY_TO_CLASS(func_tankcontrols, CFuncTankControls, CCSFuncTankControls) LINK_ENTITY_TO_CLASS(func_tankcontrols, CFuncTankControls, CCSFuncTankControls)
IMPLEMENT_SAVERESTORE(CFuncTankControls, CBaseEntity) IMPLEMENT_SAVERESTORE(CFuncTankControls, CBaseEntity)

View File

@ -101,7 +101,8 @@ public:
void ControllerPostFrame(); void ControllerPostFrame();
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[26]; static TYPEDESCRIPTION m_SaveData[];
static Vector m_TankSpread[];
protected: protected:
CBasePlayer *m_pController; CBasePlayer *m_pController;
@ -158,7 +159,7 @@ public:
CLaser *GetLaser(); CLaser *GetLaser();
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[2]; static TYPEDESCRIPTION m_SaveData[];
private: private:
CLaser *m_pLaser; CLaser *m_pLaser;
@ -190,6 +191,6 @@ public:
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[1]; static TYPEDESCRIPTION m_SaveData[];
CFuncTank *m_pTank; CFuncTank *m_pTank;
}; };

View File

@ -1,99 +1,96 @@
#include "precompiled.h" #include "precompiled.h"
/* cvar_t *g_pskill = nullptr;
* Globals initialization cvar_t *g_psv_gravity = nullptr;
*/ cvar_t *g_psv_aim = nullptr;
#ifndef HOOK_GAMEDLL cvar_t *g_footsteps = nullptr;
cvar_t *g_psv_accelerate = nullptr;
cvar_t *g_psv_friction = nullptr;
cvar_t *g_psv_stopspeed = nullptr;
cvar_t *g_psv_stepsize = nullptr;
cvar_t *g_psv_clienttrace = nullptr;
cvar_t *g_psv_gravity = NULL; cvar_t displaysoundlist = { "displaysoundlist", "0", 0, 0.0f, nullptr };
cvar_t *g_psv_aim = NULL; cvar_t timelimit = { "mp_timelimit", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t *g_footsteps = NULL; cvar_t flashlight = { "mp_flashlight", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t *g_psv_accelerate = NULL; cvar_t decalfrequency = { "decalfrequency", "30", FCVAR_SERVER, 0.0f, nullptr };
cvar_t *g_psv_friction = NULL; cvar_t fadetoblack = { "mp_fadetoblack", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t *g_psv_stopspeed = NULL;
cvar_t displaysoundlist = { "displaysoundlist", "0", 0, 0.0f, NULL };
cvar_t timelimit = { "mp_timelimit", "0", FCVAR_SERVER, 0.0f, NULL };
cvar_t flashlight = { "mp_flashlight", "0", FCVAR_SERVER, 0.0f, NULL };
cvar_t decalfrequency = { "decalfrequency", "30", FCVAR_SERVER, 0.0f, NULL };
cvar_t fadetoblack = { "mp_fadetoblack", "0", FCVAR_SERVER, 0.0f, NULL };
cvar_t fragsleft = { "mp_fragsleft", "0", FCVAR_SERVER | FCVAR_UNLOGGED, 0.0f, NULL }; // Don't spam console/log files/users with this changing cvar_t fragsleft = { "mp_fragsleft", "0", FCVAR_SERVER | FCVAR_UNLOGGED, 0.0f, nullptr }; // Don't spam console/log files/users with this changing
cvar_t timeleft = { "mp_timeleft", "0", FCVAR_SERVER | FCVAR_UNLOGGED, 0.0f, NULL }; cvar_t timeleft = { "mp_timeleft", "0", FCVAR_SERVER | FCVAR_UNLOGGED, 0.0f, nullptr };
cvar_t friendlyfire = { "mp_friendlyfire", "0", FCVAR_SERVER, 0.0f, NULL }; cvar_t friendlyfire = { "mp_friendlyfire", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t allowmonsters = { "mp_allowmonsters", "0", FCVAR_SERVER, 0.0f, NULL }; cvar_t allowmonsters = { "mp_allowmonsters", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t roundtime = { "mp_roundtime", "5", FCVAR_SERVER, 0.0f, NULL }; cvar_t roundtime = { "mp_roundtime", "5", FCVAR_SERVER, 0.0f, nullptr };
cvar_t buytime = { "mp_buytime", "1.5", FCVAR_SERVER, 0.0f, NULL }; cvar_t buytime = { "mp_buytime", "1.5", FCVAR_SERVER, 0.0f, nullptr };
cvar_t freezetime = { "mp_freezetime", "6", FCVAR_SERVER, 0.0f, NULL }; cvar_t freezetime = { "mp_freezetime", "6", FCVAR_SERVER, 0.0f, nullptr };
cvar_t c4timer = { "mp_c4timer", "45", FCVAR_SERVER, 0.0f, NULL }; cvar_t c4timer = { "mp_c4timer", "45", FCVAR_SERVER, 0.0f, nullptr };
cvar_t ghostfrequency = { "mp_ghostfrequency", "0.1", FCVAR_SERVER, 0.0f, NULL }; cvar_t ghostfrequency = { "mp_ghostfrequency", "0.1", FCVAR_SERVER, 0.0f, nullptr };
cvar_t autokick = { "mp_autokick", "1", FCVAR_SERVER, 0.0f, NULL }; cvar_t autokick = { "mp_autokick", "1", FCVAR_SERVER, 0.0f, nullptr };
cvar_t autokick_timeout = { "mp_autokick_timeout", "-1", FCVAR_SERVER, 0.0f, NULL }; cvar_t autokick_timeout = { "mp_autokick_timeout", "-1", FCVAR_SERVER, 0.0f, nullptr };
cvar_t restartround = { "sv_restartround", "0", FCVAR_SERVER, 0.0f, NULL }; cvar_t restartround = { "sv_restartround", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t sv_restart = { "sv_restart", "0", FCVAR_SERVER, 0.0f, NULL }; cvar_t sv_restart = { "sv_restart", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t limitteams = { "mp_limitteams", "2", FCVAR_SERVER, 0.0f, NULL }; cvar_t limitteams = { "mp_limitteams", "2", FCVAR_SERVER, 0.0f, nullptr };
cvar_t autoteambalance = { "mp_autoteambalance", "1", FCVAR_SERVER, 0.0f, NULL }; cvar_t autoteambalance = { "mp_autoteambalance", "1", FCVAR_SERVER, 0.0f, nullptr };
cvar_t tkpunish = { "mp_tkpunish", "0", FCVAR_SERVER, 0.0f, NULL }; cvar_t tkpunish = { "mp_tkpunish", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t hostagepenalty = { "mp_hostagepenalty", "13", FCVAR_SERVER, 0.0f, NULL }; cvar_t hostagepenalty = { "mp_hostagepenalty", "13", FCVAR_SERVER, 0.0f, nullptr };
cvar_t mirrordamage = { "mp_mirrordamage", "0", FCVAR_SERVER, 0.0f, NULL }; cvar_t mirrordamage = { "mp_mirrordamage", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t logmessages = { "mp_logmessages", "1", FCVAR_SERVER, 0.0f, NULL }; cvar_t logmessages = { "mp_logmessages", "1", FCVAR_SERVER, 0.0f, nullptr };
cvar_t forcecamera = { "mp_forcecamera", "0", FCVAR_SERVER, 0.0f, NULL }; cvar_t forcecamera = { "mp_forcecamera", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t forcechasecam = { "mp_forcechasecam", "0", FCVAR_SERVER, 0.0f, NULL }; cvar_t forcechasecam = { "mp_forcechasecam", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t mapvoteratio = { "mp_mapvoteratio", "0.66", FCVAR_SERVER, 0.0f, NULL }; cvar_t mapvoteratio = { "mp_mapvoteratio", "0.66", FCVAR_SERVER, 0.0f, nullptr };
cvar_t logdetail = { "mp_logdetail", "0", FCVAR_SERVER, 0.0f, NULL }; cvar_t logdetail = { "mp_logdetail", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t startmoney = { "mp_startmoney", "800", FCVAR_SERVER, 0.0f, NULL }; cvar_t startmoney = { "mp_startmoney", "800", FCVAR_SERVER, 0.0f, nullptr };
cvar_t maxrounds = { "mp_maxrounds", "0", FCVAR_SERVER, 0.0f, NULL }; cvar_t maxrounds = { "mp_maxrounds", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t winlimit = { "mp_winlimit", "0", FCVAR_SERVER, 0.0f, NULL }; cvar_t winlimit = { "mp_winlimit", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t windifference = { "mp_windifference", "1", FCVAR_SERVER, 0.0f, NULL }; cvar_t windifference = { "mp_windifference", "1", FCVAR_SERVER, 0.0f, nullptr };
cvar_t playerid = { "mp_playerid", "0", FCVAR_SERVER, 0.0f, NULL }; cvar_t playerid = { "mp_playerid", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t allow_spectators = { "allow_spectators", "1.0", FCVAR_SERVER, 0.0f, NULL }; cvar_t allow_spectators = { "allow_spectators", "1.0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t mp_chattime = { "mp_chattime", "10", FCVAR_SERVER, 0.0f, NULL }; cvar_t mp_chattime = { "mp_chattime", "10", FCVAR_SERVER, 0.0f, nullptr };
cvar_t kick_percent = { "mp_kickpercent", "0.66", FCVAR_SERVER, 0.0f, NULL }; cvar_t kick_percent = { "mp_kickpercent", "0.66", FCVAR_SERVER, 0.0f, nullptr };
cvar_t humans_join_team = { "humans_join_team", "any", FCVAR_SERVER, 0.0f, NULL }; cvar_t humans_join_team = { "humans_join_team", "any", FCVAR_SERVER, 0.0f, nullptr };
cvar_t sk_plr_9mm_bullet1 = { "sk_plr_9mm_bullet1", "0", 0, 0.0f, NULL }; cvar_t sk_plr_9mm_bullet1 = { "sk_plr_9mm_bullet1", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_9mm_bullet2 = { "sk_plr_9mm_bullet2", "0", 0, 0.0f, NULL }; cvar_t sk_plr_9mm_bullet2 = { "sk_plr_9mm_bullet2", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_9mm_bullet3 = { "sk_plr_9mm_bullet3", "0", 0, 0.0f, NULL }; cvar_t sk_plr_9mm_bullet3 = { "sk_plr_9mm_bullet3", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_357_bullet1 = { "sk_plr_357_bullet1", "0", 0, 0.0f, NULL }; cvar_t sk_plr_357_bullet1 = { "sk_plr_357_bullet1", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_357_bullet2 = { "sk_plr_357_bullet2", "0", 0, 0.0f, NULL }; cvar_t sk_plr_357_bullet2 = { "sk_plr_357_bullet2", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_357_bullet3 = { "sk_plr_357_bullet3", "0", 0, 0.0f, NULL }; cvar_t sk_plr_357_bullet3 = { "sk_plr_357_bullet3", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_9mmAR_bullet1 = { "sk_plr_9mmAR_bullet1", "0", 0, 0.0f, NULL }; cvar_t sk_plr_9mmAR_bullet1 = { "sk_plr_9mmAR_bullet1", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_9mmAR_bullet2 = { "sk_plr_9mmAR_bullet2", "0", 0, 0.0f, NULL }; cvar_t sk_plr_9mmAR_bullet2 = { "sk_plr_9mmAR_bullet2", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_9mmAR_bullet3 = { "sk_plr_9mmAR_bullet3", "0", 0, 0.0f, NULL }; cvar_t sk_plr_9mmAR_bullet3 = { "sk_plr_9mmAR_bullet3", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_9mmAR_grenade1 = { "sk_plr_9mmAR_grenade1", "0", 0, 0.0f, NULL }; cvar_t sk_plr_9mmAR_grenade1 = { "sk_plr_9mmAR_grenade1", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_9mmAR_grenade2 = { "sk_plr_9mmAR_grenade2", "0", 0, 0.0f, NULL }; cvar_t sk_plr_9mmAR_grenade2 = { "sk_plr_9mmAR_grenade2", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_9mmAR_grenade3 = { "sk_plr_9mmAR_grenade3", "0", 0, 0.0f, NULL }; cvar_t sk_plr_9mmAR_grenade3 = { "sk_plr_9mmAR_grenade3", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_buckshot1 = { "sk_plr_buckshot1", "0", 0, 0.0f, NULL }; cvar_t sk_plr_buckshot1 = { "sk_plr_buckshot1", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_buckshot2 = { "sk_plr_buckshot2", "0", 0, 0.0f, NULL }; cvar_t sk_plr_buckshot2 = { "sk_plr_buckshot2", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_buckshot3 = { "sk_plr_buckshot3", "0", 0, 0.0f, NULL }; cvar_t sk_plr_buckshot3 = { "sk_plr_buckshot3", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_rpg1 = { "sk_plr_rpg1", "0", 0, 0.0f, NULL }; cvar_t sk_plr_rpg1 = { "sk_plr_rpg1", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_rpg2 = { "sk_plr_rpg2", "0", 0, 0.0f, NULL }; cvar_t sk_plr_rpg2 = { "sk_plr_rpg2", "0", 0, 0.0f, nullptr };
cvar_t sk_plr_rpg3 = { "sk_plr_rpg3", "0", 0, 0.0f, NULL }; cvar_t sk_plr_rpg3 = { "sk_plr_rpg3", "0", 0, 0.0f, nullptr };
cvar_t sk_12mm_bullet1 = { "sk_12mm_bullet1", "0", 0, 0.0f, NULL }; cvar_t sk_12mm_bullet1 = { "sk_12mm_bullet1", "0", 0, 0.0f, nullptr };
cvar_t sk_12mm_bullet2 = { "sk_12mm_bullet2", "0", 0, 0.0f, NULL }; cvar_t sk_12mm_bullet2 = { "sk_12mm_bullet2", "0", 0, 0.0f, nullptr };
cvar_t sk_12mm_bullet3 = { "sk_12mm_bullet3", "0", 0, 0.0f, NULL }; cvar_t sk_12mm_bullet3 = { "sk_12mm_bullet3", "0", 0, 0.0f, nullptr };
cvar_t sk_9mmAR_bullet1 = { "sk_9mmAR_bullet1", "0", 0, 0.0f, NULL }; cvar_t sk_9mmAR_bullet1 = { "sk_9mmAR_bullet1", "0", 0, 0.0f, nullptr };
cvar_t sk_9mmAR_bullet2 = { "sk_9mmAR_bullet2", "0", 0, 0.0f, NULL }; cvar_t sk_9mmAR_bullet2 = { "sk_9mmAR_bullet2", "0", 0, 0.0f, nullptr };
cvar_t sk_9mmAR_bullet3 = { "sk_9mmAR_bullet3", "0", 0, 0.0f, NULL }; cvar_t sk_9mmAR_bullet3 = { "sk_9mmAR_bullet3", "0", 0, 0.0f, nullptr };
cvar_t sk_9mm_bullet1 = { "sk_9mm_bullet1", "0", 0, 0.0f, NULL }; cvar_t sk_9mm_bullet1 = { "sk_9mm_bullet1", "0", 0, 0.0f, nullptr };
cvar_t sk_9mm_bullet2 = { "sk_9mm_bullet2", "0", 0, 0.0f, NULL }; cvar_t sk_9mm_bullet2 = { "sk_9mm_bullet2", "0", 0, 0.0f, nullptr };
cvar_t sk_9mm_bullet3 = { "sk_9mm_bullet3", "0", 0, 0.0f, NULL }; cvar_t sk_9mm_bullet3 = { "sk_9mm_bullet3", "0", 0, 0.0f, nullptr };
cvar_t sk_suitcharger1 = { "sk_suitcharger1", "0", 0, 0.0f, NULL }; cvar_t sk_suitcharger1 = { "sk_suitcharger1", "0", 0, 0.0f, nullptr };
cvar_t sk_suitcharger2 = { "sk_suitcharger2", "0", 0, 0.0f, NULL }; cvar_t sk_suitcharger2 = { "sk_suitcharger2", "0", 0, 0.0f, nullptr };
cvar_t sk_suitcharger3 = { "sk_suitcharger3", "0", 0, 0.0f, NULL }; cvar_t sk_suitcharger3 = { "sk_suitcharger3", "0", 0, 0.0f, nullptr };
cvar_t sk_battery1 = { "sk_battery1", "0", 0, 0.0f, NULL }; cvar_t sk_battery1 = { "sk_battery1", "0", 0, 0.0f, nullptr };
cvar_t sk_battery2 = { "sk_battery2", "0", 0, 0.0f, NULL }; cvar_t sk_battery2 = { "sk_battery2", "0", 0, 0.0f, nullptr };
cvar_t sk_battery3 = { "sk_battery3", "0", 0, 0.0f, NULL }; cvar_t sk_battery3 = { "sk_battery3", "0", 0, 0.0f, nullptr };
cvar_t sk_healthcharger1 = { "sk_healthcharger1", "0", 0, 0.0f, NULL }; cvar_t sk_healthcharger1 = { "sk_healthcharger1", "0", 0, 0.0f, nullptr };
cvar_t sk_healthcharger2 = { "sk_healthcharger2", "0", 0, 0.0f, NULL }; cvar_t sk_healthcharger2 = { "sk_healthcharger2", "0", 0, 0.0f, nullptr };
cvar_t sk_healthcharger3 = { "sk_healthcharger3", "0", 0, 0.0f, NULL }; cvar_t sk_healthcharger3 = { "sk_healthcharger3", "0", 0, 0.0f, nullptr };
cvar_t sk_healthkit1 = { "sk_healthkit1", "0", 0, 0.0f, NULL }; cvar_t sk_healthkit1 = { "sk_healthkit1", "0", 0, 0.0f, nullptr };
cvar_t sk_healthkit2 = { "sk_healthkit2", "0", 0, 0.0f, NULL }; cvar_t sk_healthkit2 = { "sk_healthkit2", "0", 0, 0.0f, nullptr };
cvar_t sk_healthkit3 = { "sk_healthkit3", "0", 0, 0.0f, NULL }; cvar_t sk_healthkit3 = { "sk_healthkit3", "0", 0, 0.0f, nullptr };
cvar_t sk_scientist_heal1 = { "sk_scientist_heal1", "0", 0, 0.0f, NULL }; cvar_t sk_scientist_heal1 = { "sk_scientist_heal1", "0", 0, 0.0f, nullptr };
cvar_t sk_scientist_heal2 = { "sk_scientist_heal2", "0", 0, 0.0f, NULL }; cvar_t sk_scientist_heal2 = { "sk_scientist_heal2", "0", 0, 0.0f, nullptr };
cvar_t sk_scientist_heal3 = { "sk_scientist_heal3", "0", 0, 0.0f, NULL }; cvar_t sk_scientist_heal3 = { "sk_scientist_heal3", "0", 0, 0.0f, nullptr };
#endif // HOOK_GAMEDLL
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
@ -110,7 +107,6 @@ cvar_t auto_join_team = { "mp_auto_join_team", "0", 0, 0.0f, nullptr };
cvar_t max_teamkills = { "mp_max_teamkills", "3", 0, 3.0f, nullptr }; cvar_t max_teamkills = { "mp_max_teamkills", "3", 0, 3.0f, nullptr };
cvar_t fraglimit = { "mp_fraglimit", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t fraglimit = { "mp_fraglimit", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t round_restart_delay = { "mp_round_restart_delay", "5", FCVAR_SERVER, 0.0f, nullptr }; cvar_t round_restart_delay = { "mp_round_restart_delay", "5", FCVAR_SERVER, 0.0f, nullptr };
cvar_t showtriggers = { "showtriggers", "0", 0, 0.0f, nullptr }; // debug cvar shows triggers cvar_t showtriggers = { "showtriggers", "0", 0, 0.0f, nullptr }; // debug cvar shows triggers
// TODO: Maybe it's better to register in the engine? // TODO: Maybe it's better to register in the engine?
@ -141,12 +137,15 @@ void GameDLL_EndRound_f()
void EXT_FUNC GameDLLInit() void EXT_FUNC GameDLLInit()
{ {
g_pskill = CVAR_GET_POINTER("skill");
g_psv_gravity = CVAR_GET_POINTER("sv_gravity"); g_psv_gravity = CVAR_GET_POINTER("sv_gravity");
g_psv_aim = CVAR_GET_POINTER("sv_aim"); g_psv_aim = CVAR_GET_POINTER("sv_aim");
g_footsteps = CVAR_GET_POINTER("mp_footsteps"); g_footsteps = CVAR_GET_POINTER("mp_footsteps");
g_psv_accelerate = CVAR_GET_POINTER("sv_accelerate"); g_psv_accelerate = CVAR_GET_POINTER("sv_accelerate");
g_psv_friction = CVAR_GET_POINTER("sv_friction"); g_psv_friction = CVAR_GET_POINTER("sv_friction");
g_psv_stopspeed = CVAR_GET_POINTER("sv_stopspeed"); g_psv_stopspeed = CVAR_GET_POINTER("sv_stopspeed");
g_psv_stepsize = CVAR_GET_POINTER("sv_stepsize");
g_psv_clienttrace = CVAR_GET_POINTER("sv_clienttrace");
CVAR_REGISTER(&displaysoundlist); CVAR_REGISTER(&displaysoundlist);
CVAR_REGISTER(&timelimit); CVAR_REGISTER(&timelimit);

View File

@ -40,12 +40,15 @@
#define PLAYERID_TEAMONLY 1 #define PLAYERID_TEAMONLY 1
#define PLAYERID_OFF 2 #define PLAYERID_OFF 2
extern cvar_t *g_pskill;
extern cvar_t *g_psv_gravity; extern cvar_t *g_psv_gravity;
extern cvar_t *g_psv_aim; extern cvar_t *g_psv_aim;
extern cvar_t *g_footsteps;
extern cvar_t *g_psv_accelerate; extern cvar_t *g_psv_accelerate;
extern cvar_t *g_psv_friction; extern cvar_t *g_psv_friction;
extern cvar_t *g_psv_stopspeed; extern cvar_t *g_psv_stopspeed;
extern cvar_t *g_psv_stepsize;
extern cvar_t *g_psv_clienttrace;
extern cvar_t *g_footsteps;
extern cvar_t displaysoundlist; extern cvar_t displaysoundlist;
extern cvar_t timelimit; extern cvar_t timelimit;

View File

@ -1,14 +1,7 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
CGameRules *g_pGameRules = nullptr; CGameRules *g_pGameRules = nullptr;
#endif
CGameRules::CGameRules() CGameRules::CGameRules()
{ {
m_bFreezePeriod = FALSE; m_bFreezePeriod = FALSE;
@ -19,13 +12,11 @@ CGameRules::CGameRules()
Q_strcpy(m_GameDesc, AreRunningCZero() ? "Condition Zero" : "Counter-Strike"); Q_strcpy(m_GameDesc, AreRunningCZero() ? "Condition Zero" : "Counter-Strike");
} }
#ifndef HOOK_GAMEDLL
CGameRules::~CGameRules() CGameRules::~CGameRules()
{ {
delete[] m_GameDesc; delete[] m_GameDesc;
m_GameDesc = nullptr; m_GameDesc = nullptr;
} }
#endif
// this is the game name that gets seen in the server browser // this is the game name that gets seen in the server browser
const char *CGameRules::GetGameDescription() const char *CGameRules::GetGameDescription()

View File

@ -217,10 +217,7 @@ class CGameRules
{ {
public: public:
CGameRules(); CGameRules();
#ifndef HOOK_GAMEDLL
virtual ~CGameRules(); virtual ~CGameRules();
#endif
virtual void RefreshSkillData(); // fill skill data struct with proper values virtual void RefreshSkillData(); // fill skill data struct with proper values
virtual void Think() = 0; // runs every server frame, should handle any timer tasks, periodic events, etc. virtual void Think() = 0; // runs every server frame, should handle any timer tasks, periodic events, etc.
@ -335,8 +332,8 @@ public:
BOOL m_bBombDropped; BOOL m_bBombDropped;
// custom // custom
CUSTOM_MEMBER char *m_GameDesc; char *m_GameDesc;
CUSTOM_MEMBER bool m_bGameOver; // intermission or finale (deprecated name g_fGameOver) bool m_bGameOver; // intermission or finale (deprecated name g_fGameOver)
}; };
// CHalfLifeRules - rules for the single player Half-Life game. // CHalfLifeRules - rules for the single player Half-Life game.
@ -344,10 +341,7 @@ class CHalfLifeRules: public CGameRules
{ {
public: public:
CHalfLifeRules(); CHalfLifeRules();
#ifndef HOOK_GAMEDLL
virtual ~CHalfLifeRules() {}; virtual ~CHalfLifeRules() {};
#endif
virtual void Think(); virtual void Think();
virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity); virtual BOOL IsAllowedToSpawn(CBaseEntity *pEntity);
@ -773,11 +767,11 @@ protected:
bool m_bSkipSpawn; bool m_bSkipSpawn;
// custom // custom
CUSTOM_MEMBER bool m_bSkipShowMenu; bool m_bSkipShowMenu;
CUSTOM_MEMBER bool m_bNeededPlayers; bool m_bNeededPlayers;
CUSTOM_MEMBER float m_flEscapeRatio; float m_flEscapeRatio;
CUSTOM_MEMBER float m_flTimeLimit; float m_flTimeLimit;
CUSTOM_MEMBER float m_flGameStartTime; float m_flGameStartTime;
}; };
typedef struct mapcycle_item_s typedef struct mapcycle_item_s

View File

@ -1,10 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CGrenade::m_SaveData[] = TYPEDESCRIPTION CGrenade::m_SaveData[] =
{ {
DEFINE_FIELD(CGrenade, m_fAttenu, FIELD_FLOAT), DEFINE_FIELD(CGrenade, m_fAttenu, FIELD_FLOAT),
@ -24,8 +19,6 @@ TYPEDESCRIPTION CGrenade::m_SaveData[] =
DEFINE_FIELD(CGrenade, m_usEvent, FIELD_INTEGER), DEFINE_FIELD(CGrenade, m_usEvent, FIELD_INTEGER),
}; };
#endif
LINK_ENTITY_TO_CLASS(grenade, CGrenade, CCSGrenade) LINK_ENTITY_TO_CLASS(grenade, CGrenade, CCSGrenade)
void CGrenade::Explode(Vector vecSrc, Vector vecAim) void CGrenade::Explode(Vector vecSrc, Vector vecAim)

View File

@ -1,14 +1,7 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
const Vector g_vecZero(0, 0, 0); const Vector g_vecZero(0, 0, 0);
#endif
int g_Language; int g_Language;
int g_iSkillLevel; int g_iSkillLevel;

View File

@ -1,10 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CRecharge::m_SaveData[] = TYPEDESCRIPTION CRecharge::m_SaveData[] =
{ {
DEFINE_FIELD(CRecharge, m_flNextCharge, FIELD_TIME), DEFINE_FIELD(CRecharge, m_flNextCharge, FIELD_TIME),
@ -14,8 +9,6 @@ TYPEDESCRIPTION CRecharge::m_SaveData[] =
DEFINE_FIELD(CRecharge, m_flSoundTime, FIELD_TIME), DEFINE_FIELD(CRecharge, m_flSoundTime, FIELD_TIME),
}; };
#endif
IMPLEMENT_SAVERESTORE(CRecharge, CBaseEntity) IMPLEMENT_SAVERESTORE(CRecharge, CBaseEntity)
LINK_ENTITY_TO_CLASS(func_recharge, CRecharge, CCSRecharge) LINK_ENTITY_TO_CLASS(func_recharge, CRecharge, CCSRecharge)

View File

@ -44,7 +44,7 @@ public:
void EXPORT Recharge(); void EXPORT Recharge();
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[5]; static TYPEDESCRIPTION m_SaveData[];
float m_flNextCharge; float m_flNextCharge;
int m_iReactivate; int m_iReactivate;

View File

@ -1,34 +1,15 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CCycler::m_SaveData[] = TYPEDESCRIPTION CCycler::m_SaveData[] =
{ {
DEFINE_FIELD(CCycler, m_animate, FIELD_INTEGER), DEFINE_FIELD(CCycler, m_animate, FIELD_INTEGER),
}; };
TYPEDESCRIPTION CCyclerSprite::m_SaveData[] =
{
DEFINE_FIELD(CCyclerSprite, m_animate, FIELD_INTEGER),
DEFINE_FIELD(CCyclerSprite, m_lastTime, FIELD_TIME),
DEFINE_FIELD(CCyclerSprite, m_maxFrame, FIELD_FLOAT),
};
TYPEDESCRIPTION CWreckage::m_SaveData[] =
{
DEFINE_FIELD(CWreckage, m_flStartTime, FIELD_TIME),
};
#endif
IMPLEMENT_SAVERESTORE(CCycler, CBaseToggle) IMPLEMENT_SAVERESTORE(CCycler, CBaseToggle)
void CGenericCycler::Spawn() void CGenericCycler::Spawn()
{ {
GenericCyclerSpawn((char *)STRING(pev->model), Vector(-16, -16, 0), Vector(16, 16, 72)); GenericCyclerSpawn(pev->model, Vector(-16, -16, 0), Vector(16, 16, 72));
} }
LINK_ENTITY_TO_CLASS(cycler, CGenericCycler, CCSGenericCycler) LINK_ENTITY_TO_CLASS(cycler, CGenericCycler, CCSGenericCycler)
@ -41,7 +22,7 @@ void CCyclerProbe::Spawn()
} }
// Cycler member functions // Cycler member functions
void CCycler::GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax) void CCycler::GenericCyclerSpawn(const char *szModel, Vector vecMin, Vector vecMax)
{ {
if (!szModel || !szModel[0]) if (!szModel || !szModel[0])
{ {
@ -161,6 +142,13 @@ BOOL CCycler::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float
return FALSE; return FALSE;
} }
TYPEDESCRIPTION CCyclerSprite::m_SaveData[] =
{
DEFINE_FIELD(CCyclerSprite, m_animate, FIELD_INTEGER),
DEFINE_FIELD(CCyclerSprite, m_lastTime, FIELD_TIME),
DEFINE_FIELD(CCyclerSprite, m_maxFrame, FIELD_FLOAT),
};
LINK_ENTITY_TO_CLASS(cycler_sprite, CCyclerSprite, CCSCyclerSprite) LINK_ENTITY_TO_CLASS(cycler_sprite, CCyclerSprite, CCSCyclerSprite)
IMPLEMENT_SAVERESTORE(CCyclerSprite, CBaseEntity) IMPLEMENT_SAVERESTORE(CCyclerSprite, CBaseEntity)
@ -176,8 +164,8 @@ void CCyclerSprite::Spawn()
m_animate = 1; m_animate = 1;
m_lastTime = gpGlobals->time; m_lastTime = gpGlobals->time;
PRECACHE_MODEL((char *)STRING(pev->model)); PRECACHE_MODEL(pev->model);
SET_MODEL(ENT(pev), STRING(pev->model)); SET_MODEL(ENT(pev), pev->model);
m_maxFrame = float(MODEL_FRAMES(pev->modelindex) - 1); m_maxFrame = float(MODEL_FRAMES(pev->modelindex) - 1);
@ -249,8 +237,8 @@ void CWeaponCycler::Spawn()
pev->solid = SOLID_SLIDEBOX; pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_NONE; pev->movetype = MOVETYPE_NONE;
PRECACHE_MODEL((char *)STRING(pev->model)); PRECACHE_MODEL(pev->model);
SET_MODEL(ENT(pev), STRING(pev->model)); SET_MODEL(ENT(pev), pev->model);
m_iszModel = pev->model; m_iszModel = pev->model;
m_iModel = pev->modelindex; m_iModel = pev->modelindex;
@ -302,6 +290,11 @@ void CWeaponCycler::SecondaryAttack()
m_flNextSecondaryAttack = gpGlobals->time + 0.3f; m_flNextSecondaryAttack = gpGlobals->time + 0.3f;
} }
TYPEDESCRIPTION CWreckage::m_SaveData[] =
{
DEFINE_FIELD(CWreckage, m_flStartTime, FIELD_TIME),
};
IMPLEMENT_SAVERESTORE(CWreckage, CBaseToggle) IMPLEMENT_SAVERESTORE(CWreckage, CBaseToggle)
LINK_ENTITY_TO_CLASS(cycler_wreckage, CWreckage, CCSWreckage) LINK_ENTITY_TO_CLASS(cycler_wreckage, CWreckage, CCSWreckage)
@ -315,10 +308,10 @@ void CWreckage::Spawn()
pev->frame = 0; pev->frame = 0;
pev->nextthink = gpGlobals->time + 0.1f; pev->nextthink = gpGlobals->time + 0.1f;
if (!FStringNull(pev->model)) if (!pev->model.IsNull())
{ {
PRECACHE_MODEL((char *)STRING(pev->model)); PRECACHE_MODEL(pev->model);
SET_MODEL(ENT(pev), STRING(pev->model)); SET_MODEL(ENT(pev), pev->model);
} }
// pev->scale = 5.0; // pev->scale = 5.0;
@ -327,9 +320,9 @@ void CWreckage::Spawn()
void CWreckage::Precache() void CWreckage::Precache()
{ {
if (!FStringNull(pev->model)) if (!pev->model.IsNull())
{ {
PRECACHE_MODEL((char *)STRING(pev->model)); PRECACHE_MODEL(pev->model);
} }
} }

View File

@ -42,11 +42,11 @@ public:
virtual void Think(); virtual void Think();
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
public: protected:
void GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax); void GenericCyclerSpawn(const char *szModel, Vector vecMin, Vector vecMax);
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[1]; static TYPEDESCRIPTION m_SaveData[];
int m_animate; int m_animate;
}; };
@ -82,7 +82,7 @@ public:
inline int ShouldAnimate() { return (m_animate && m_maxFrame > 1.0f); } inline int ShouldAnimate() { return (m_animate && m_maxFrame > 1.0f); }
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[3]; static TYPEDESCRIPTION m_SaveData[];
int m_animate; int m_animate;
float m_lastTime; float m_lastTime;
@ -120,7 +120,7 @@ public:
virtual void Think(); virtual void Think();
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[1]; static TYPEDESCRIPTION m_SaveData[];
int m_flStartTime; int m_flStartTime;
}; };

View File

@ -1,6 +1,6 @@
#include "precompiled.h" #include "precompiled.h"
//! Holds engine functionality callbacks // Holds engine functionality callbacks
enginefuncs_t g_engfuncs; enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals; globalvars_t *gpGlobals;
@ -14,3 +14,30 @@ C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t *pEnginefuncsTable, global
Regamedll_Game_Init(); Regamedll_Game_Init();
} }
#ifdef _WIN32
// DLL entry point
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
}
else if (fdwReason == DLL_PROCESS_DETACH)
{
}
return TRUE;
}
#else // _WIN32
void __attribute__((constructor)) DllMainLoad()
{
}
void __attribute__((destructor)) DllMainUnload()
{
}
#endif // _WIN32

View File

@ -1,21 +1,5 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CWallHealth::m_SaveData[] =
{
DEFINE_FIELD(CWallHealth, m_flNextCharge, FIELD_TIME),
DEFINE_FIELD(CWallHealth, m_iReactivate, FIELD_INTEGER),
DEFINE_FIELD(CWallHealth, m_iJuice, FIELD_INTEGER),
DEFINE_FIELD(CWallHealth, m_iOn, FIELD_INTEGER),
DEFINE_FIELD(CWallHealth, m_flSoundTime, FIELD_TIME),
};
#endif
LINK_ENTITY_TO_CLASS(item_healthkit, CHealthKit, CCSHealthKit) LINK_ENTITY_TO_CLASS(item_healthkit, CHealthKit, CCSHealthKit)
void CHealthKit::Spawn() void CHealthKit::Spawn()
@ -50,7 +34,7 @@ BOOL CHealthKit::MyTouch(CBasePlayer *pPlayer)
if (pPlayer->TakeHealth(healthValue, DMG_GENERIC)) if (pPlayer->TakeHealth(healthValue, DMG_GENERIC))
{ {
MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, nullptr, pPlayer->pev); MESSAGE_BEGIN(MSG_ONE, gmsgItemPickup, nullptr, pPlayer->pev);
WRITE_STRING(STRING(pev->classname)); WRITE_STRING(pev->classname);
MESSAGE_END(); MESSAGE_END();
EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/smallmedkit1.wav", VOL_NORM, ATTN_NORM); EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/smallmedkit1.wav", VOL_NORM, ATTN_NORM);
@ -66,6 +50,15 @@ BOOL CHealthKit::MyTouch(CBasePlayer *pPlayer)
return FALSE; return FALSE;
} }
TYPEDESCRIPTION CWallHealth::m_SaveData[] =
{
DEFINE_FIELD(CWallHealth, m_flNextCharge, FIELD_TIME),
DEFINE_FIELD(CWallHealth, m_iReactivate, FIELD_INTEGER),
DEFINE_FIELD(CWallHealth, m_iJuice, FIELD_INTEGER),
DEFINE_FIELD(CWallHealth, m_iOn, FIELD_INTEGER),
DEFINE_FIELD(CWallHealth, m_flSoundTime, FIELD_TIME),
};
IMPLEMENT_SAVERESTORE(CWallHealth, CBaseEntity) IMPLEMENT_SAVERESTORE(CWallHealth, CBaseEntity)
LINK_ENTITY_TO_CLASS(func_healthcharger, CWallHealth, CCSWallHealth) LINK_ENTITY_TO_CLASS(func_healthcharger, CWallHealth, CCSWallHealth)
@ -97,7 +90,7 @@ void CWallHealth::Spawn()
UTIL_SetOrigin(pev, pev->origin); UTIL_SetOrigin(pev, pev->origin);
UTIL_SetSize(pev, pev->mins, pev->maxs); UTIL_SetSize(pev, pev->mins, pev->maxs);
SET_MODEL(ENT(pev), STRING(pev->model)); SET_MODEL(ENT(pev), pev->model);
int healthValue = (int)gSkillData.healthchargerCapacity; int healthValue = (int)gSkillData.healthchargerCapacity;
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES

View File

@ -51,7 +51,7 @@ public:
void EXPORT Off(); void EXPORT Off();
void EXPORT Recharge(); void EXPORT Recharge();
static TYPEDESCRIPTION IMPL(m_SaveData)[5]; static TYPEDESCRIPTION m_SaveData[];
float m_flNextCharge; float m_flNextCharge;
int m_iReactivate; int m_iReactivate;

View File

@ -1,9 +1,32 @@
#include "precompiled.h"
/* /*
* Globals initialization *
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/ */
#ifndef HOOK_GAMEDLL
#include "precompiled.h"
cvar_t cv_hostage_debug = { "hostage_debug", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_hostage_debug = { "hostage_debug", "0", FCVAR_SERVER, 0.0f, nullptr };
cvar_t cv_hostage_stop = { "hostage_stop", "0", FCVAR_SERVER, 0.0f, nullptr }; cvar_t cv_hostage_stop = { "hostage_stop", "0", FCVAR_SERVER, 0.0f, nullptr };
@ -11,8 +34,6 @@ cvar_t cv_hostage_stop = { "hostage_stop", "0", FCVAR_SERVER, 0.0f, nullptr };
CHostageManager *g_pHostages = nullptr; CHostageManager *g_pHostages = nullptr;
int g_iHostageNumber = 0; int g_iHostageNumber = 0;
#endif
struct struct
{ {
HostageChatterType type; HostageChatterType type;
@ -231,7 +252,7 @@ void CHostage::Spawn()
m_vOldPos = Vector(9999, 9999, 9999); m_vOldPos = Vector(9999, 9999, 9999);
m_iHostageIndex = ++g_iHostageNumber; m_iHostageIndex = ++g_iHostageNumber;
nTargetNode = -1; m_nTargetNode = NODE_INVALID_EMPTY;
m_fHasPath = FALSE; m_fHasPath = FALSE;
m_flLastPathCheck = -1; m_flLastPathCheck = -1;
@ -247,10 +268,9 @@ void CHostage::Spawn()
void CHostage::Precache() void CHostage::Precache()
{ {
static int which = 0;
if (AreImprovAllowed()) if (AreImprovAllowed())
{ {
static int which = 0;
switch (which) switch (which)
{ {
case REGULAR_GUY: case REGULAR_GUY:
@ -277,13 +297,13 @@ void CHostage::Precache()
else else
{ {
m_whichModel = REGULAR_GUY; m_whichModel = REGULAR_GUY;
if (FStringNull(pev->model)) if (pev->model.IsNull())
{ {
pev->model = MAKE_STRING("models/scientist.mdl"); pev->model = MAKE_STRING("models/scientist.mdl");
} }
} }
PRECACHE_MODEL((char *)STRING(pev->model)); PRECACHE_MODEL(pev->model);
PRECACHE_SOUND("hostage/hos1.wav"); PRECACHE_SOUND("hostage/hos1.wav");
PRECACHE_SOUND("hostage/hos2.wav"); PRECACHE_SOUND("hostage/hos2.wav");
PRECACHE_SOUND("hostage/hos3.wav"); PRECACHE_SOUND("hostage/hos3.wav");
@ -292,12 +312,11 @@ void CHostage::Precache()
PRECACHE_MODEL("sprites/smoke.spr"); PRECACHE_MODEL("sprites/smoke.spr");
} }
void CHostage::SetActivity(int act) void CHostage::SetActivity(Activity act)
{ {
if (m_Activity != act) if (m_Activity != act)
{ {
int sequence = LookupActivity(act); int sequence = LookupActivity(act);
if (sequence != ACT_INVALID) if (sequence != ACT_INVALID)
{ {
if (pev->sequence != sequence) if (pev->sequence != sequence)
@ -393,7 +412,7 @@ void CHostage::IdleThink()
CBaseEntity *pSpot = nullptr; CBaseEntity *pSpot = nullptr;
while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_hostage_rescue"))) while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_hostage_rescue")))
{ {
if ((pSpot->pev->origin - pev->origin).Length() < RESCUE_HOSTAGES_RADIUS) if ((pSpot->pev->origin - pev->origin).Length() < MAX_HOSTAGES_RESCUE_RADIUS)
{ {
m_bRescueMe = TRUE; m_bRescueMe = TRUE;
break; break;
@ -406,7 +425,7 @@ void CHostage::IdleThink()
while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_start"))) while ((pSpot = UTIL_FindEntityByClassname(pSpot, "info_player_start")))
{ {
if ((pSpot->pev->origin - pev->origin).Length() < RESCUE_HOSTAGES_RADIUS) if ((pSpot->pev->origin - pev->origin).Length() < MAX_HOSTAGES_RESCUE_RADIUS)
{ {
m_bRescueMe = TRUE; m_bRescueMe = TRUE;
break; break;
@ -548,7 +567,7 @@ void CHostage::RePosition()
pev->nextthink = gpGlobals->time + RANDOM_FLOAT(0.1, 0.2); pev->nextthink = gpGlobals->time + RANDOM_FLOAT(0.1, 0.2);
m_fHasPath = FALSE; m_fHasPath = FALSE;
nTargetNode = -1; m_nTargetNode = NODE_INVALID_EMPTY;
m_flLastPathCheck = -1; m_flLastPathCheck = -1;
m_flPathAcquired = -1; m_flPathAcquired = -1;
@ -879,7 +898,7 @@ void CHostage::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy
{ {
m_State = STAND; m_State = STAND;
m_hTargetEnt = nullptr; m_hTargetEnt = nullptr;
m_hStoppedTargetEnt = pActivator; m_hStoppedTargetEnt = static_cast<CBasePlayer *>(pActivator);
} }
else else
m_State = FOLLOW; m_State = FOLLOW;
@ -1006,14 +1025,15 @@ void CHostage::DoFollow()
if (m_fHasPath) if (m_fHasPath)
{ {
nTargetNode = m_LocalNav->GetFurthestTraversableNode(pev->origin, vecNodes, m_nPathNodes, TRUE); m_nTargetNode = m_LocalNav->GetFurthestTraversableNode(pev->origin, vecNodes, m_nPathNodes, TRUE);
if (!nTargetNode) if (!m_nTargetNode)
{ {
if ((vecNodes[nTargetNode] - pev->origin).Length2D() < HOSTAGE_STEPSIZE) if ((vecNodes[m_nTargetNode] - pev->origin).Length2D() < HOSTAGE_STEPSIZE)
nTargetNode = -1; m_nTargetNode = NODE_INVALID_EMPTY;
} }
if (nTargetNode == -1)
if (m_nTargetNode == NODE_INVALID_EMPTY)
{ {
m_fHasPath = FALSE; m_fHasPath = FALSE;
m_flPathCheckInterval = 0.1f; m_flPathCheckInterval = 0.1f;
@ -1023,15 +1043,15 @@ void CHostage::DoFollow()
if (gpGlobals->time < m_flFlinchTime) if (gpGlobals->time < m_flFlinchTime)
return; return;
if (nTargetNode != -1) if (m_nTargetNode != NODE_INVALID_EMPTY)
{ {
if (pev->flags & FL_ONGROUND) if (pev->flags & FL_ONGROUND)
PointAt(vecNodes[nTargetNode]); PointAt(vecNodes[m_nTargetNode]);
if (pev->movetype == MOVETYPE_FLY) if (pev->movetype == MOVETYPE_FLY)
pev->v_angle.x = -60; pev->v_angle.x = -60;
MoveToward(vecNodes[nTargetNode]); MoveToward(vecNodes[m_nTargetNode]);
m_bStuck = FALSE; m_bStuck = FALSE;
} }
else if (IsAlive()) else if (IsAlive())
@ -1050,7 +1070,7 @@ void CHostage::DoFollow()
{ {
if (m_flPathAcquired != -1 && m_flPathAcquired + 2 > gpGlobals->time) if (m_flPathAcquired != -1 && m_flPathAcquired + 2 > gpGlobals->time)
{ {
if (pev->velocity.Length2D() < 1 || nTargetNode == -1) if (pev->velocity.Length2D() < 1 || m_nTargetNode == NODE_INVALID_EMPTY)
{ {
Wiggle(); Wiggle();
} }
@ -1067,7 +1087,6 @@ void CHostage::PointAt(const Vector &vecLoc)
void CHostage::MoveToward(const Vector &vecLoc) void CHostage::MoveToward(const Vector &vecLoc)
{ {
int nFwdMove;
Vector vecFwd; Vector vecFwd;
Vector vecbigDest; Vector vecbigDest;
Vector vecMove; Vector vecMove;
@ -1080,15 +1099,15 @@ void CHostage::MoveToward(const Vector &vecLoc)
Vector vecAng(0, UTIL_VecToAngles(vecMove).y, 0); Vector vecAng(0, UTIL_VecToAngles(vecMove).y, 0);
UTIL_MakeVectorsPrivate(vecAng, vecFwd, nullptr, nullptr); UTIL_MakeVectorsPrivate(vecAng, vecFwd, nullptr, nullptr);
if ((vecFwd * s_flStepSize_LocalNav).Length2D() <= (vecLoc - pev->origin).Length2D()) if ((vecFwd * m_LocalNav->m_flStepSize).Length2D() <= (vecLoc - pev->origin).Length2D())
flDist = (vecFwd * s_flStepSize_LocalNav).Length2D(); flDist = (vecFwd * m_LocalNav->m_flStepSize).Length2D();
else else
flDist = (vecLoc - pev->origin).Length2D(); flDist = (vecLoc - pev->origin).Length2D();
vecbigDest = pev->origin + (vecFwd * flDist); vecbigDest = pev->origin + (vecFwd * flDist);
nFwdMove = m_LocalNav->PathTraversable(pev->origin, vecbigDest, FALSE);
if (nFwdMove != PATH_TRAVERSABLE_EMPTY) auto nFwdMove = m_LocalNav->PathTraversable(pev->origin, vecbigDest, FALSE);
if (nFwdMove != PTRAVELS_EMPTY)
{ {
float_precision flSpeed = 250; float_precision flSpeed = 250;
@ -1111,7 +1130,7 @@ void CHostage::MoveToward(const Vector &vecLoc)
pev->velocity.x = vecFwd.x * flSpeed; pev->velocity.x = vecFwd.x * flSpeed;
pev->velocity.y = vecFwd.y * flSpeed; pev->velocity.y = vecFwd.y * flSpeed;
if (nFwdMove == PATH_TRAVERSABLE_STEPJUMPABLE) if (nFwdMove == PTRAVELS_STEPJUMPABLE)
{ {
if (pev->flags & FL_ONGROUND) if (pev->flags & FL_ONGROUND)
{ {
@ -1157,8 +1176,8 @@ void CHostage::NavReady()
vecDest.z += pFollowing->pev->mins.z; vecDest.z += pFollowing->pev->mins.z;
m_LocalNav->SetTargetEnt(pFollowing); m_LocalNav->SetTargetEnt(pFollowing);
node_index_t nindexPath = m_LocalNav->FindPath(pev->origin, vecDest, flRadius, 1); node_index_t nindexPath = m_LocalNav->FindPath(pev->origin, vecDest, flRadius, TRUE);
if (nindexPath == -1) if (nindexPath == NODE_INVALID_EMPTY)
{ {
if (!m_fHasPath) if (!m_fHasPath)
{ {
@ -1173,7 +1192,7 @@ void CHostage::NavReady()
else else
{ {
m_fHasPath = TRUE; m_fHasPath = TRUE;
nTargetNode = -1; m_nTargetNode = NODE_INVALID_EMPTY;
m_flPathAcquired = gpGlobals->time; m_flPathAcquired = gpGlobals->time;
m_flPathCheckInterval = 0.5f; m_flPathCheckInterval = 0.5f;
@ -1255,7 +1274,7 @@ void CHostage::Wiggle()
for (auto& dir : wiggle_directions) { for (auto& dir : wiggle_directions) {
Vector dest = pev->origin + dir; Vector dest = pev->origin + dir;
if (m_LocalNav->PathTraversable(pev->origin, dest, TRUE) == PATH_TRAVERSABLE_EMPTY) if (m_LocalNav->PathTraversable(pev->origin, dest, TRUE) == PTRAVELS_EMPTY)
vec = vec - dir; vec = vec - dir;
} }
@ -1297,7 +1316,7 @@ void CHostage::PreThink()
vecSrc = pev->origin; vecSrc = pev->origin;
flInterval = s_flStepSize_LocalNav; flInterval = m_LocalNav->m_flStepSize;
vecDest = vecSrc + pev->velocity * gpGlobals->frametime; vecDest = vecSrc + pev->velocity * gpGlobals->frametime;
vecDest.z = vecSrc.z; vecDest.z = vecSrc.z;
@ -1376,21 +1395,22 @@ void CHostageManager::ServerActivate()
{ {
m_hostageCount = 0; m_hostageCount = 0;
CBaseEntity *pEntity = nullptr; CHostage *pHostage = nullptr;
while ((pEntity = UTIL_FindEntityByClassname(pEntity, "hostage_entity"))) while ((pHostage = UTIL_FindEntityByClassname(pHostage, "hostage_entity")))
{ {
AddHostage((CHostage *)pEntity); AddHostage(pHostage);
} }
if (AreImprovAllowed()) if (AreImprovAllowed())
{ {
for (auto& sound : hostageSoundStruct) { for (auto& snd : hostageSoundStruct) {
m_chatter.AddSound(sound.type, sound.fileName); m_chatter.AddSound(snd.type, snd.fileName);
} }
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
if (!AreRunningCZero()) if (!AreRunningCZero()) {
LoadNavigationMap(); LoadNavigationMap();
}
#endif #endif
} }
} }
@ -1480,7 +1500,7 @@ void CHostageManager::OnEvent(GameEventType event, CBaseEntity *entity, CBaseEnt
{ {
for (int i = 0; i < m_hostageCount; i++) for (int i = 0; i < m_hostageCount; i++)
{ {
CHostageImprov *improv = m_hostage[ i ]->m_improv; CHostageImprov *improv = m_hostage[i]->m_improv;
if (improv) if (improv)
{ {
improv->OnGameEvent(event, entity, other); improv->OnGameEvent(event, entity, other);

View File

@ -28,19 +28,17 @@
#pragma once #pragma once
#define MAX_NODES 100 const int MAX_NODES = 100;
#define MAX_HOSTAGES 12 const int MAX_HOSTAGES = 12;
#define MAX_HOSTAGES_NAV 20 const int MAX_HOSTAGES_NAV = 20;
#define HOSTAGE_STEPSIZE 26.0f const float HOSTAGE_STEPSIZE = 26.0f;
#define HOSTAGE_STEPSIZE_DEFAULT 18.0f const float MAX_HOSTAGES_RESCUE_RADIUS = 256.0f; // rescue zones from legacy info_*
#define VEC_HOSTAGE_VIEW Vector(0, 0, 12) #define VEC_HOSTAGE_VIEW Vector(0, 0, 12)
#define VEC_HOSTAGE_HULL_MIN Vector(-10, -10, 0) #define VEC_HOSTAGE_HULL_MIN Vector(-10, -10, 0)
#define VEC_HOSTAGE_HULL_MAX Vector(10, 10, 62) #define VEC_HOSTAGE_HULL_MAX Vector(10, 10, 62)
#define VEC_HOSTAGE_CROUCH Vector(10, 10, 30) #define VEC_HOSTAGE_CROUCH Vector(10, 10, 30)
#define RESCUE_HOSTAGES_RADIUS 256.0f // rescue zones from legacy info_*
class CHostage; class CHostage;
class CLocalNav; class CLocalNav;
@ -105,8 +103,8 @@ public:
void EXPORT IdleThink(); void EXPORT IdleThink();
void EXPORT Remove(); void EXPORT Remove();
void RePosition(); void RePosition();
void SetActivity(int act); void SetActivity(Activity act);
int GetActivity() { return m_Activity; } Activity GetActivity() { return m_Activity; }
float GetModifiedDamage(float flDamage, int nHitGroup); float GetModifiedDamage(float flDamage, int nHitGroup);
void SetFlinchActivity(); void SetFlinchActivity();
void SetDeathActivity(); void SetDeathActivity();
@ -152,11 +150,10 @@ public:
bool IsValid() const { return (pev->takedamage == DAMAGE_YES); } bool IsValid() const { return (pev->takedamage == DAMAGE_YES); }
bool IsDead() const { return (pev->deadflag == DEAD_DEAD); } bool IsDead() const { return (pev->deadflag == DEAD_DEAD); }
bool IsAtHome() const { return (pev->origin - m_vStart).IsLengthGreaterThan(20) != true; } bool IsAtHome() const { return !(pev->origin - m_vStart).IsLengthGreaterThan(20); }
const Vector *GetHomePosition() const { return &m_vStart; } const Vector *GetHomePosition() const { return &m_vStart; }
public: public:
int m_Activity;
BOOL m_bTouched; BOOL m_bTouched;
BOOL m_bRescueMe; BOOL m_bRescueMe;
float m_flFlinchTime; float m_flFlinchTime;
@ -165,17 +162,17 @@ public:
int m_iModel; int m_iModel;
int m_iSkin; int m_iSkin;
float m_flNextRadarTime; float m_flNextRadarTime;
enum state { FOLLOW, STAND, DUCK, SCARED, IDLE, FOLLOWPATH } enum state { FOLLOW, STAND, DUCK, SCARED, IDLE, FOLLOWPATH };
m_State; state m_State;
Vector m_vStart; Vector m_vStart;
Vector m_vStartAngles; Vector m_vStartAngles;
Vector m_vPathToFollow[20]; Vector m_vPathToFollow[MAX_HOSTAGES_NAV];
int m_iWaypoint; int m_iWaypoint;
CBasePlayer *m_target; CBasePlayer *m_target;
CLocalNav *m_LocalNav; CLocalNav *m_LocalNav;
int nTargetNode; int m_nTargetNode;
Vector vecNodes[MAX_NODES]; Vector vecNodes[MAX_NODES];
EHANDLE m_hStoppedTargetEnt; EntityHandle<CBasePlayer> m_hStoppedTargetEnt;
float m_flNextFullThink; float m_flNextFullThink;
float m_flPathCheckInterval; float m_flPathCheckInterval;
float m_flLastPathCheck; float m_flLastPathCheck;
@ -188,8 +185,8 @@ public:
float m_flStuckTime; float m_flStuckTime;
CHostageImprov *m_improv; CHostageImprov *m_improv;
enum ModelType { REGULAR_GUY, OLD_GUY, BLACK_GUY, GOOFY_GUY } enum ModelType { REGULAR_GUY, OLD_GUY, BLACK_GUY, GOOFY_GUY };
m_whichModel; ModelType m_whichModel;
}; };
class SimpleChatter class SimpleChatter
@ -218,7 +215,7 @@ public:
void Shuffle(ChatterSet *chatter); void Shuffle(ChatterSet *chatter);
private: private:
ChatterSet m_chatter[21]; ChatterSet m_chatter[NUM_HOSTAGE_CHATTER_TYPES];
}; };
class CHostageManager class CHostageManager
@ -246,12 +243,12 @@ public:
{ {
for (int i = 0; i < m_hostageCount; i++) for (int i = 0; i < m_hostageCount; i++)
{ {
CHostage *hostage = m_hostage[i]; CHostage *pHostage = m_hostage[i];
if (!hostage || hostage->pev->deadflag == DEAD_DEAD) if (!pHostage || pHostage->pev->deadflag == DEAD_DEAD)
continue; continue;
if (func(hostage) == false) if (!func(pHostage))
return false; return false;
} }

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
inline void DrawAxes(const Vector &origin, int red, int green, int blue) inline void DrawAxes(const Vector &origin, int red, int green, int blue)

View File

@ -1,21 +1,44 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
/* EntityHandle<CHostage> CLocalNav::m_hQueue[MAX_HOSTAGES_NAV];
* Globals initialization EntityHandle<CHostage> CLocalNav::m_hHostages[MAX_HOSTAGES_NAV];
*/
#ifndef HOOK_GAMEDLL
float CLocalNav::s_flStepSize; int CLocalNav::m_CurRequest = 0;
int CLocalNav::qptr; int CLocalNav::m_NumRequest = 0;
EHANDLE CLocalNav::_queue[MAX_HOSTAGES_NAV]; int CLocalNav::m_NumHostages = 0;
int CLocalNav::tot_inqueue; int CLocalNav::m_NodeValue = 0;
float CLocalNav::nodeval;
float CLocalNav::flNextCvarCheck;
float CLocalNav::flLastThinkTime;
EHANDLE CLocalNav::hostages[MAX_HOSTAGES_NAV];
int CLocalNav::tot_hostages;
#endif float CLocalNav::m_flStepSize = 18.0f; // sv_stepsize by default
float CLocalNav::m_flNextCvarCheck = 0.0f;
float CLocalNav::m_flLastThinkTime = 0.0f;
CLocalNav::CLocalNav(CHostage *pOwner) CLocalNav::CLocalNav(CHostage *pOwner)
{ {
@ -23,12 +46,10 @@ CLocalNav::CLocalNav(CHostage *pOwner)
m_pTargetEnt = nullptr; m_pTargetEnt = nullptr;
m_nodeArr = new localnode_t[MAX_NODES]; m_nodeArr = new localnode_t[MAX_NODES];
if (tot_hostages >= MAX_HOSTAGES_NAV) if (m_NumHostages >= MAX_HOSTAGES_NAV)
{
return; return;
}
hostages[tot_hostages++] = pOwner; m_hHostages[m_NumHostages++] = pOwner;
} }
CLocalNav::~CLocalNav() CLocalNav::~CLocalNav()
@ -61,7 +82,7 @@ node_index_t CLocalNav::AddNode(node_index_t nindexParent, Vector &vecLoc, int o
localnode_t *CLocalNav::GetNode(node_index_t nindex) localnode_t *CLocalNav::GetNode(node_index_t nindex)
{ {
return &m_nodeArr[ nindex ]; return &m_nodeArr[nindex];
} }
node_index_t CLocalNav::NodeExists(int offsetX, int offsetY) node_index_t CLocalNav::NodeExists(int offsetX, int offsetY)
@ -82,7 +103,7 @@ node_index_t CLocalNav::NodeExists(int offsetX, int offsetY)
return nindexCurrent; return nindexCurrent;
} }
void CLocalNav::AddPathNodes(node_index_t nindexSource, int fNoMonsters) void CLocalNav::AddPathNodes(node_index_t nindexSource, BOOL fNoMonsters)
{ {
AddPathNode(nindexSource, 1, 0, fNoMonsters); AddPathNode(nindexSource, 1, 0, fNoMonsters);
AddPathNode(nindexSource, -1, 0, fNoMonsters); AddPathNode(nindexSource, -1, 0, fNoMonsters);
@ -94,9 +115,9 @@ void CLocalNav::AddPathNodes(node_index_t nindexSource, int fNoMonsters)
AddPathNode(nindexSource, -1, -1, fNoMonsters); AddPathNode(nindexSource, -1, -1, fNoMonsters);
} }
void CLocalNav::AddPathNode(node_index_t nindexSource, int offsetX, int offsetY, int fNoMonsters) void CLocalNav::AddPathNode(node_index_t nindexSource, int offsetX, int offsetY, BOOL fNoMonsters)
{ {
int bDepth; byte bDepth;
Vector vecSource, vecDest; Vector vecSource, vecDest;
int offsetXAbs, offsetYAbs; int offsetXAbs, offsetYAbs;
@ -173,7 +194,7 @@ void CLocalNav::AddPathNode(node_index_t nindexSource, int offsetX, int offsetY,
} }
} }
if (PathTraversable(nodeSource->vecLoc, vecDest, fNoMonsters) != PATH_TRAVERSABLE_EMPTY) if (PathTraversable(nodeSource->vecLoc, vecDest, fNoMonsters) != PTRAVELS_EMPTY)
{ {
nodeCurrent = nodeSource; nodeCurrent = nodeSource;
nindexSource = nindexCurrent; nindexSource = nindexCurrent;
@ -183,10 +204,10 @@ void CLocalNav::AddPathNode(node_index_t nindexSource, int offsetX, int offsetY,
} }
vecSource = nodeCurrent->vecLoc; vecSource = nodeCurrent->vecLoc;
bDepth = int(nodeCurrent->bDepth) + 1; bDepth = (nodeCurrent->bDepth + 1) & 0xff;
} }
if (PathTraversable(vecSource, vecDest, fNoMonsters) != PATH_TRAVERSABLE_EMPTY) if (PathTraversable(vecSource, vecDest, fNoMonsters) != PTRAVELS_EMPTY)
{ {
AddNode(nindexSource, vecDest, offsetXAbs, offsetYAbs, bDepth); AddNode(nindexSource, vecDest, offsetXAbs, offsetYAbs, bDepth);
} }
@ -225,7 +246,7 @@ node_index_t CLocalNav::GetBestNode(Vector &vecOrigin, Vector &vecDest)
flZDiff = 1.0; flZDiff = 1.0;
} }
if ((flDistToDest * flZDiff) <= s_flStepSize) if ((flDistToDest * flZDiff) <= m_flStepSize)
flZDiff = 1.0; flZDiff = 1.0;
else else
flZDiff = 1.25; flZDiff = 1.25;
@ -238,13 +259,13 @@ node_index_t CLocalNav::GetBestNode(Vector &vecOrigin, Vector &vecDest)
} }
} }
++nindexCurrent; nindexCurrent++;
} }
return nindexBest; return nindexBest;
} }
int CLocalNav::SetupPathNodes(node_index_t nindex, Vector *vecNodes, int fNoMonsters) int CLocalNav::SetupPathNodes(node_index_t nindex, Vector *vecNodes, BOOL fNoMonsters)
{ {
node_index_t nCurrentIndex = nindex; node_index_t nCurrentIndex = nindex;
int nNodeCount = 0; int nNodeCount = 0;
@ -253,7 +274,7 @@ int CLocalNav::SetupPathNodes(node_index_t nindex, Vector *vecNodes, int fNoMons
{ {
localnode_t *nodeCurrent = GetNode(nCurrentIndex); localnode_t *nodeCurrent = GetNode(nCurrentIndex);
Vector vecCurrentLoc = nodeCurrent->vecLoc; Vector vecCurrentLoc = nodeCurrent->vecLoc;
vecNodes[ nNodeCount++ ] = vecCurrentLoc; vecNodes[nNodeCount++] = vecCurrentLoc;
nCurrentIndex = nodeCurrent->nindexParent; nCurrentIndex = nodeCurrent->nindexParent;
} }
@ -261,21 +282,21 @@ int CLocalNav::SetupPathNodes(node_index_t nindex, Vector *vecNodes, int fNoMons
return nNodeCount; return nNodeCount;
} }
int CLocalNav::GetFurthestTraversableNode(Vector &vecStartingLoc, Vector *vecNodes, int nTotalNodes, int fNoMonsters) node_index_t CLocalNav::GetFurthestTraversableNode(Vector &vecStartingLoc, Vector *vecNodes, int nTotalNodes, BOOL fNoMonsters)
{ {
int nCount = 0; int nCount = 0;
while (nCount < nTotalNodes) while (nCount < nTotalNodes)
{ {
if (PathTraversable(vecStartingLoc, vecNodes[nCount], fNoMonsters) != PATH_TRAVERSABLE_EMPTY) if (PathTraversable(vecStartingLoc, vecNodes[nCount], fNoMonsters) != PTRAVELS_EMPTY)
return nCount; return nCount;
++nCount; nCount++;
} }
return -1; return NODE_INVALID_EMPTY;
} }
node_index_t CLocalNav::FindPath(Vector &vecStart, Vector &vecDest, float flTargetRadius, int fNoMonsters) node_index_t CLocalNav::FindPath(Vector &vecStart, Vector &vecDest, float flTargetRadius, BOOL fNoMonsters)
{ {
node_index_t nIndexBest = FindDirectPath(vecStart, vecDest, flTargetRadius, fNoMonsters); node_index_t nIndexBest = FindDirectPath(vecStart, vecDest, flTargetRadius, fNoMonsters);
@ -320,92 +341,92 @@ node_index_t CLocalNav::FindPath(Vector &vecStart, Vector &vecDest, float flTarg
} }
if (m_nindexAvailableNode <= 10) if (m_nindexAvailableNode <= 10)
nodeval += 2; m_NodeValue += 2;
else if (m_nindexAvailableNode <= 20) else if (m_nindexAvailableNode <= 20)
nodeval += 4; m_NodeValue += 4;
else if (m_nindexAvailableNode <= 30) else if (m_nindexAvailableNode <= 30)
nodeval += 8; m_NodeValue += 8;
else if (m_nindexAvailableNode <= 40) else if (m_nindexAvailableNode <= 40)
nodeval += 13; m_NodeValue += 13;
else if (m_nindexAvailableNode <= 50) else if (m_nindexAvailableNode <= 50)
nodeval += 19; m_NodeValue += 19;
else if (m_nindexAvailableNode <= 60) else if (m_nindexAvailableNode <= 60)
nodeval += 26; m_NodeValue += 26;
else if (m_nindexAvailableNode <= 70) else if (m_nindexAvailableNode <= 70)
nodeval += 34; m_NodeValue += 34;
else if (m_nindexAvailableNode <= 80) else if (m_nindexAvailableNode <= 80)
nodeval += 43; m_NodeValue += 43;
else if (m_nindexAvailableNode <= 90) else if (m_nindexAvailableNode <= 90)
nodeval += 53; m_NodeValue += 53;
else if (m_nindexAvailableNode <= 100) else if (m_nindexAvailableNode <= 100)
nodeval += 64; m_NodeValue += 64;
else if (m_nindexAvailableNode <= 110) else if (m_nindexAvailableNode <= 110)
nodeval += 76; m_NodeValue += 76;
else if (m_nindexAvailableNode <= 120) else if (m_nindexAvailableNode <= 120)
nodeval += 89; m_NodeValue += 89;
else if (m_nindexAvailableNode <= 130) else if (m_nindexAvailableNode <= 130)
nodeval += 103; m_NodeValue += 103;
else if (m_nindexAvailableNode <= 140) else if (m_nindexAvailableNode <= 140)
nodeval += 118; m_NodeValue += 118;
else if (m_nindexAvailableNode <= 150) else if (m_nindexAvailableNode <= 150)
nodeval += 134; m_NodeValue += 134;
else if (m_nindexAvailableNode <= 160) else if (m_nindexAvailableNode <= 160)
nodeval += 151; m_NodeValue += 151;
else else
nodeval += 169; m_NodeValue += 169;
return nIndexBest; return nIndexBest;
} }
node_index_t CLocalNav::FindDirectPath(Vector &vecStart, Vector &vecDest, float flTargetRadius, int fNoMonsters) node_index_t CLocalNav::FindDirectPath(Vector &vecStart, Vector &vecDest, float flTargetRadius, BOOL fNoMonsters)
{ {
Vector vecActualDest; Vector vecActualDest;
Vector vecPathDir; Vector vecPathDir;
Vector vecNodeLoc; Vector vecNodeLoc;
node_index_t nindexLast; node_index_t nIndexLast;
vecPathDir = NormalizeSubtract<float_precision, float, float, float_precision>(vecStart, vecDest); vecPathDir = NormalizeSubtract<float_precision, float, float, float_precision>(vecStart, vecDest);
vecActualDest = vecDest - (vecPathDir * flTargetRadius); vecActualDest = vecDest - (vecPathDir * flTargetRadius);
if (PathTraversable(vecStart, vecActualDest, fNoMonsters) == PATH_TRAVERSABLE_EMPTY) if (PathTraversable(vecStart, vecActualDest, fNoMonsters) == PTRAVELS_EMPTY)
{ {
return NODE_INVALID_EMPTY; return NODE_INVALID_EMPTY;
} }
nindexLast = NODE_INVALID_EMPTY; nIndexLast = NODE_INVALID_EMPTY;
vecNodeLoc = vecStart; vecNodeLoc = vecStart;
m_nindexAvailableNode = 0; m_nindexAvailableNode = 0;
while ((vecNodeLoc - vecActualDest).Length2D() >= HOSTAGE_STEPSIZE) while ((vecNodeLoc - vecActualDest).Length2D() >= HOSTAGE_STEPSIZE)
{ {
node_index_t nindexCurrent = nindexLast; node_index_t nindexCurrent = nIndexLast;
vecNodeLoc = vecNodeLoc + (vecPathDir * HOSTAGE_STEPSIZE); vecNodeLoc = vecNodeLoc + (vecPathDir * HOSTAGE_STEPSIZE);
nindexLast = AddNode(nindexCurrent, vecNodeLoc); nIndexLast = AddNode(nindexCurrent, vecNodeLoc);
if (nindexLast == NODE_INVALID_EMPTY) if (nIndexLast == NODE_INVALID_EMPTY)
break; break;
} }
return nindexLast; return nIndexLast;
} }
BOOL CLocalNav::PathClear(Vector &vecOrigin, Vector &vecDest, int fNoMonsters, TraceResult &tr) BOOL CLocalNav::PathClear(Vector &vecOrigin, Vector &vecDest, BOOL fNoMonsters, TraceResult &tr)
{ {
TRACE_MONSTER_HULL(m_pOwner->edict(), vecOrigin, vecDest, fNoMonsters, m_pOwner->edict(), &tr); TRACE_MONSTER_HULL(m_pOwner->edict(), vecOrigin, vecDest, fNoMonsters, m_pOwner->edict(), &tr);
@ -424,14 +445,20 @@ BOOL CLocalNav::PathClear(Vector &vecOrigin, Vector &vecDest, int fNoMonsters, T
return FALSE; return FALSE;
} }
int CLocalNav::PathTraversable(Vector &vecSource, Vector &vecDest, int fNoMonsters) BOOL CLocalNav::PathClear(Vector &vecSource, Vector &vecDest, BOOL fNoMonsters)
{
TraceResult tr;
return PathClear(vecSource, vecDest, fNoMonsters, tr);
}
PathTraversAble CLocalNav::PathTraversable(Vector &vecSource, Vector &vecDest, BOOL fNoMonsters)
{ {
TraceResult tr; TraceResult tr;
Vector vecSrcTmp; Vector vecSrcTmp;
Vector vecDestTmp; Vector vecDestTmp;
Vector vecDir; Vector vecDir;
float_precision flTotal; float_precision flTotal;
int retval = PATH_TRAVERSABLE_EMPTY; auto retval = PTRAVELS_EMPTY;
vecSrcTmp = vecSource; vecSrcTmp = vecSource;
vecDestTmp = vecDest - vecSource; vecDestTmp = vecDest - vecSource;
@ -443,15 +470,15 @@ int CLocalNav::PathTraversable(Vector &vecSource, Vector &vecDest, int fNoMonste
while (flTotal > 1.0f) while (flTotal > 1.0f)
{ {
if (flTotal >= s_flStepSize) if (flTotal >= m_flStepSize)
{ {
#ifndef PLAY_GAMEDLL #ifndef PLAY_GAMEDLL
vecDestTmp = vecSrcTmp + (vecDir * s_flStepSize); vecDestTmp = vecSrcTmp + (vecDir * m_flStepSize);
#else #else
// TODO: fix test demo // TODO: fix test demo
vecDestTmp[0] = vecSrcTmp[0] + (vecDir[0] * s_flStepSize); vecDestTmp[0] = vecSrcTmp[0] + (vecDir[0] * m_flStepSize);
vecDestTmp[1] = vecSrcTmp[1] + float(vecDir[1] * s_flStepSize); vecDestTmp[1] = vecSrcTmp[1] + float(vecDir[1] * m_flStepSize);
vecDestTmp[2] = vecSrcTmp[2] + (vecDir[2] * s_flStepSize); vecDestTmp[2] = vecSrcTmp[2] + (vecDir[2] * m_flStepSize);
#endif #endif
} }
@ -464,23 +491,23 @@ int CLocalNav::PathTraversable(Vector &vecSource, Vector &vecDest, int fNoMonste
{ {
vecDestTmp = tr.vecEndPos; vecDestTmp = tr.vecEndPos;
if (retval == PATH_TRAVERSABLE_EMPTY) if (retval == PTRAVELS_EMPTY)
{ {
retval = PATH_TRAVERSABLE_SLOPE; retval = PTRAVELS_SLOPE;
} }
} }
else else
{ {
if (tr.fStartSolid) if (tr.fStartSolid)
{ {
return PATH_TRAVERSABLE_EMPTY; return PTRAVELS_EMPTY;
} }
if (tr.pHit && !fNoMonsters && tr.pHit->v.classname) if (tr.pHit && !fNoMonsters && tr.pHit->v.classname)
{ {
if (FClassnameIs(tr.pHit, "hostage_entity")) if (FClassnameIs(tr.pHit, "hostage_entity"))
{ {
return PATH_TRAVERSABLE_EMPTY; return PTRAVELS_EMPTY;
} }
} }
@ -490,21 +517,21 @@ int CLocalNav::PathTraversable(Vector &vecSource, Vector &vecDest, int fNoMonste
{ {
if (StepTraversable(vecSrcTmp, vecDestTmp, fNoMonsters, tr)) if (StepTraversable(vecSrcTmp, vecDestTmp, fNoMonsters, tr))
{ {
if (retval == PATH_TRAVERSABLE_EMPTY) if (retval == PTRAVELS_EMPTY)
{ {
retval = PATH_TRAVERSABLE_STEP; retval = PTRAVELS_STEP;
} }
} }
else else
{ {
if (!StepJumpable(vecSrcTmp, vecDestTmp, fNoMonsters, tr)) if (!StepJumpable(vecSrcTmp, vecDestTmp, fNoMonsters, tr))
{ {
return PATH_TRAVERSABLE_EMPTY; return PTRAVELS_EMPTY;
} }
if (retval == PATH_TRAVERSABLE_EMPTY) if (retval == PTRAVELS_EMPTY)
{ {
retval = PATH_TRAVERSABLE_STEPJUMPABLE; retval = PTRAVELS_STEPJUMPABLE;
} }
} }
} }
@ -512,12 +539,12 @@ int CLocalNav::PathTraversable(Vector &vecSource, Vector &vecDest, int fNoMonste
{ {
if (!SlopeTraversable(vecSrcTmp, vecDestTmp, fNoMonsters, tr)) if (!SlopeTraversable(vecSrcTmp, vecDestTmp, fNoMonsters, tr))
{ {
return PATH_TRAVERSABLE_EMPTY; return PTRAVELS_EMPTY;
} }
if (retval == PATH_TRAVERSABLE_EMPTY) if (retval == PTRAVELS_EMPTY)
{ {
retval = PATH_TRAVERSABLE_SLOPE; retval = PTRAVELS_SLOPE;
} }
} }
} }
@ -526,7 +553,7 @@ int CLocalNav::PathTraversable(Vector &vecSource, Vector &vecDest, int fNoMonste
if (PathClear(vecDestTmp, vecDropDest, fNoMonsters, tr)) if (PathClear(vecDestTmp, vecDropDest, fNoMonsters, tr))
{ {
return PATH_TRAVERSABLE_EMPTY; return PTRAVELS_EMPTY;
} }
if (!tr.fStartSolid) if (!tr.fStartSolid)
@ -548,7 +575,7 @@ int CLocalNav::PathTraversable(Vector &vecSource, Vector &vecDest, int fNoMonste
return retval; return retval;
} }
BOOL CLocalNav::SlopeTraversable(Vector &vecSource, Vector &vecDest, int fNoMonsters, TraceResult &tr) BOOL CLocalNav::SlopeTraversable(Vector &vecSource, Vector &vecDest, BOOL fNoMonsters, TraceResult &tr)
{ {
Vector vecSlopeEnd; Vector vecSlopeEnd;
Vector vecDown; Vector vecDown;
@ -572,7 +599,7 @@ BOOL CLocalNav::SlopeTraversable(Vector &vecSource, Vector &vecDest, int fNoMons
vecSlopeEnd = tr.vecEndPos; vecSlopeEnd = tr.vecEndPos;
vecDown = vecSlopeEnd; vecDown = vecSlopeEnd;
vecDown.z -= s_flStepSize; vecDown.z -= m_flStepSize;
if (!PathClear(vecSlopeEnd, vecDown, fNoMonsters, tr)) if (!PathClear(vecSlopeEnd, vecDown, fNoMonsters, tr))
{ {
@ -587,7 +614,7 @@ BOOL CLocalNav::SlopeTraversable(Vector &vecSource, Vector &vecDest, int fNoMons
return TRUE; return TRUE;
} }
BOOL CLocalNav::LadderTraversable(Vector &vecSource, Vector &vecDest, int fNoMonsters, TraceResult &tr) BOOL CLocalNav::LadderTraversable(Vector &vecSource, Vector &vecDest, BOOL fNoMonsters, TraceResult &tr)
{ {
Vector vecStepStart; Vector vecStepStart;
Vector vecStepDest; Vector vecStepDest;
@ -611,7 +638,7 @@ BOOL CLocalNav::LadderTraversable(Vector &vecSource, Vector &vecDest, int fNoMon
return PathTraversable(vecStepStart, vecDest, fNoMonsters); return PathTraversable(vecStepStart, vecDest, fNoMonsters);
} }
BOOL CLocalNav::StepTraversable(Vector &vecSource, Vector &vecDest, int fNoMonsters, TraceResult &tr) BOOL CLocalNav::StepTraversable(Vector &vecSource, Vector &vecDest, BOOL fNoMonsters, TraceResult &tr)
{ {
Vector vecStepStart; Vector vecStepStart;
Vector vecStepDest; Vector vecStepDest;
@ -621,7 +648,7 @@ BOOL CLocalNav::StepTraversable(Vector &vecSource, Vector &vecDest, int fNoMonst
vecStepStart = vecSource; vecStepStart = vecSource;
vecStepDest = vecDest; vecStepDest = vecDest;
vecStepStart.z += s_flStepSize; vecStepStart.z += m_flStepSize;
vecStepDest.z = vecStepStart.z; vecStepDest.z = vecStepStart.z;
if (!PathClear(vecStepStart, vecStepDest, fNoMonsters, tr)) if (!PathClear(vecStepStart, vecStepDest, fNoMonsters, tr))
@ -638,7 +665,7 @@ BOOL CLocalNav::StepTraversable(Vector &vecSource, Vector &vecDest, int fNoMonst
vecStepStart = tr.vecEndPos; vecStepStart = tr.vecEndPos;
vecStepDest = vecStepStart; vecStepDest = vecStepStart;
vecStepDest.z -= s_flStepSize; vecStepDest.z -= m_flStepSize;
if (!PathClear(vecStepStart, vecStepDest, fNoMonsters, tr)) if (!PathClear(vecStepStart, vecStepDest, fNoMonsters, tr))
{ {
@ -653,12 +680,12 @@ BOOL CLocalNav::StepTraversable(Vector &vecSource, Vector &vecDest, int fNoMonst
return TRUE; return TRUE;
} }
BOOL CLocalNav::StepJumpable(Vector &vecSource, Vector &vecDest, int fNoMonsters, TraceResult &tr) BOOL CLocalNav::StepJumpable(Vector &vecSource, Vector &vecDest, BOOL fNoMonsters, TraceResult &tr)
{ {
Vector vecStepStart; Vector vecStepStart;
Vector vecStepDest; Vector vecStepDest;
float flFwdFraction; float flFwdFraction;
float flJumpHeight = s_flStepSize + 1.0f; float flJumpHeight = m_flStepSize + 1.0f;
vecStepStart = vecSource; vecStepStart = vecSource;
vecStepStart.z += flJumpHeight; vecStepStart.z += flJumpHeight;
@ -686,7 +713,7 @@ BOOL CLocalNav::StepJumpable(Vector &vecSource, Vector &vecDest, int fNoMonsters
vecStepStart = tr.vecEndPos; vecStepStart = tr.vecEndPos;
vecStepDest = vecStepStart; vecStepDest = vecStepStart;
vecStepDest.z -= s_flStepSize; vecStepDest.z -= m_flStepSize;
if (!PathClear(vecStepStart, vecStepDest, fNoMonsters, tr)) if (!PathClear(vecStepStart, vecStepDest, fNoMonsters, tr))
{ {
@ -746,120 +773,107 @@ BOOL CLocalNav::LadderHit(Vector &vecSource, Vector &vecDest, TraceResult &tr)
void CLocalNav::Think() void CLocalNav::Think()
{ {
EHANDLE hCallback; static cvar_t *sv_stepsize = NULL;
static cvar_t *sv_stepsize = nullptr; if (gpGlobals->time >= m_flNextCvarCheck)
if (gpGlobals->time >= flNextCvarCheck)
{ {
if (sv_stepsize) if (sv_stepsize != NULL)
s_flStepSize = sv_stepsize->value; m_flStepSize = sv_stepsize->value;
else else
{ {
sv_stepsize = CVAR_GET_POINTER("sv_stepsize"); sv_stepsize = CVAR_GET_POINTER("sv_stepsize");
s_flStepSize = s_flStepSize ? sv_stepsize->value : HOSTAGE_STEPSIZE_DEFAULT; m_flStepSize = sv_stepsize ? sv_stepsize->value : 18;
} }
flNextCvarCheck = gpGlobals->time + 1.0f; m_flNextCvarCheck = gpGlobals->time + 1.0f;
} }
HostagePrethink(); HostagePrethink();
float flElapsedTime = gpGlobals->time - flLastThinkTime; float flElapsedTime = gpGlobals->time - m_flLastThinkTime;
nodeval -= flElapsedTime * 250; m_NodeValue -= flElapsedTime * 250;
flLastThinkTime = gpGlobals->time; m_flLastThinkTime = gpGlobals->time;
if (nodeval < 0) if (m_NodeValue < 0)
nodeval = 0; m_NodeValue = 0;
else if (nodeval > 17) else if (m_NodeValue > 17)
return; return;
if (tot_inqueue) if (m_NumRequest)
{ {
hCallback = _queue[qptr]; auto hHostage = m_hQueue[m_CurRequest];
while (!hHostage.IsValid() && m_NumRequest > 0)
{
if (++m_CurRequest == MAX_HOSTAGES_NAV)
m_CurRequest = 0;
if (!hCallback) m_NumRequest--;
if (m_NumRequest <= 0)
{ {
while (tot_inqueue > 0) hHostage = nullptr;
{
if (++qptr == MAX_HOSTAGES_NAV)
qptr = 0;
tot_inqueue--;
if (!tot_inqueue)
{
hCallback = nullptr;
break; break;
} }
hCallback = _queue[qptr]; hHostage = m_hQueue[m_CurRequest];
if (hCallback)
break;
}
} }
if (hCallback) if (hHostage.IsValid())
{ {
CHostage *pHostage = GetClassPtr<CCSHostage>((CHostage *)hCallback->pev); if (++m_CurRequest == MAX_HOSTAGES_NAV)
m_CurRequest = 0;
if (++qptr == MAX_HOSTAGES_NAV) m_NumRequest--;
qptr = 0; hHostage->NavReady();
tot_inqueue--;
pHostage->NavReady();
} }
} }
} }
void CLocalNav::RequestNav(CHostage *pCaller) void CLocalNav::RequestNav(CHostage *pCaller)
{ {
int curr = qptr; int curr = m_CurRequest;
int found = 0; int found = 0;
if (nodeval <= 17 && !tot_inqueue) if (m_NodeValue <= 17 && !m_NumRequest)
{ {
pCaller->NavReady(); pCaller->NavReady();
return; return;
} }
if (tot_inqueue >= MAX_HOSTAGES_NAV) if (m_NumRequest >= MAX_HOSTAGES_NAV)
{ {
return; return;
} }
for (int i = 0; i < tot_inqueue; ++i) for (int i = 0; i < m_NumRequest; i++)
{ {
CHostage *pQueueItem = GetClassPtr<CCSHostage>((CHostage *)_queue[curr]->pev); if (m_hQueue[curr] == pCaller)
if (pQueueItem == pCaller)
return; return;
if (++curr == MAX_HOSTAGES_NAV) if (++curr == MAX_HOSTAGES_NAV)
curr = 0; curr = 0;
} }
_queue[curr] = pCaller; m_hQueue[curr] = pCaller;
++tot_inqueue; m_NumRequest++;
} }
void CLocalNav::Reset() void CLocalNav::Reset()
{ {
flNextCvarCheck = 0; m_flNextCvarCheck = 0.0f;
flLastThinkTime = 0; m_flLastThinkTime = 0.0f;
tot_inqueue = 0;
qptr = 0; m_NumRequest = 0;
nodeval = 0; m_CurRequest = 0;
tot_hostages = 0; m_NumHostages = 0;
m_NodeValue = 0;
} }
void CLocalNav::HostagePrethink() void CLocalNav::HostagePrethink()
{ {
for (int iCount = 0; iCount < tot_hostages; ++iCount) for (int i = 0; i < m_NumHostages; i++)
{ {
if (hostages[ iCount ]) if (m_hHostages[i].IsValid()) {
{ m_hHostages[i]->PreThink();
GetClassPtr<CCSHostage>((CHostage *)hostages[ iCount ]->pev)->PreThink();
} }
} }
} }

View File

@ -28,14 +28,16 @@
#pragma once #pragma once
#define NODE_INVALID_EMPTY -1 enum PathTraversAble
{
PTRAVELS_EMPTY,
PTRAVELS_SLOPE,
PTRAVELS_STEP,
PTRAVELS_STEPJUMPABLE,
};
#define PATH_TRAVERSABLE_EMPTY 0 using node_index_t = int;
#define PATH_TRAVERSABLE_SLOPE 1 constexpr node_index_t NODE_INVALID_EMPTY = {-1};
#define PATH_TRAVERSABLE_STEP 2
#define PATH_TRAVERSABLE_STEPJUMPABLE 3
typedef int node_index_t;
typedef struct localnode_s typedef struct localnode_s
{ {
@ -48,10 +50,6 @@ typedef struct localnode_s
} localnode_t; } localnode_t;
#ifndef HOOK_GAMEDLL
#define s_flStepSize_LocalNav m_LocalNav->s_flStepSize
#endif
class CLocalNav class CLocalNav
{ {
public: public:
@ -66,44 +64,40 @@ public:
m_pTargetEnt = nullptr; m_pTargetEnt = nullptr;
} }
node_index_t FindPath(Vector &vecStart, Vector &vecDest, float flTargetRadius, int fNoMonsters); node_index_t FindPath(Vector &vecStart, Vector &vecDest, float flTargetRadius, BOOL fNoMonsters);
int SetupPathNodes(node_index_t nindex, Vector *vecNodes, int fNoMonsters); int SetupPathNodes(node_index_t nindex, Vector *vecNodes, BOOL fNoMonsters);
int GetFurthestTraversableNode(Vector &vecStartingLoc, Vector *vecNodes, int nTotalNodes, int fNoMonsters); node_index_t GetFurthestTraversableNode(Vector &vecStartingLoc, Vector *vecNodes, int nTotalNodes, BOOL fNoMonsters);
int PathTraversable(Vector &vecSource, Vector &vecDest, int fNoMonsters); PathTraversAble PathTraversable(Vector &vecSource, Vector &vecDest, BOOL fNoMonsters);
BOOL PathClear(Vector &vecOrigin, Vector &vecDest, int fNoMonsters, TraceResult &tr); BOOL PathClear(Vector &vecOrigin, Vector &vecDest, BOOL fNoMonsters, TraceResult &tr);
BOOL PathClear(Vector &vecSource, Vector &vecDest, BOOL fNoMonsters) BOOL PathClear(Vector &vecSource, Vector &vecDest, BOOL fNoMonsters);
{
TraceResult tr;
return PathClear(vecSource, vecDest, fNoMonsters, tr);
}
node_index_t AddNode(node_index_t nindexParent, Vector &vecLoc, int offsetX = 0, int offsetY = 0, byte bDepth = 0); node_index_t AddNode(node_index_t nindexParent, Vector &vecLoc, int offsetX = 0, int offsetY = 0, byte bDepth = 0);
localnode_t *GetNode(node_index_t nindex); localnode_t *GetNode(node_index_t nindex);
node_index_t NodeExists(int offsetX, int offsetY); node_index_t NodeExists(int offsetX, int offsetY);
void AddPathNodes(node_index_t nindexSource, int fNoMonsters); void AddPathNodes(node_index_t nindexSource, BOOL fNoMonsters);
void AddPathNode(node_index_t nindexSource, int offsetX, int offsetY, int fNoMonsters); void AddPathNode(node_index_t nindexSource, int offsetX, int offsetY, BOOL fNoMonsters);
node_index_t GetBestNode(Vector &vecOrigin, Vector &vecDest); node_index_t GetBestNode(Vector &vecOrigin, Vector &vecDest);
BOOL SlopeTraversable(Vector &vecSource, Vector &vecDest, int fNoMonsters, TraceResult &tr); BOOL SlopeTraversable(Vector &vecSource, Vector &vecDest, BOOL fNoMonsters, TraceResult &tr);
BOOL LadderTraversable(Vector &vecSource, Vector &vecDest, int fNoMonsters, TraceResult &tr); BOOL LadderTraversable(Vector &vecSource, Vector &vecDest, BOOL fNoMonsters, TraceResult &tr);
BOOL StepTraversable(Vector &vecSource, Vector &vecDest, int fNoMonsters, TraceResult &tr); BOOL StepTraversable(Vector &vecSource, Vector &vecDest, BOOL fNoMonsters, TraceResult &tr);
BOOL StepJumpable(Vector &vecSource, Vector &vecDest, int fNoMonsters, TraceResult &tr); BOOL StepJumpable(Vector &vecSource, Vector &vecDest, BOOL fNoMonsters, TraceResult &tr);
node_index_t FindDirectPath(Vector &vecStart, Vector &vecDest, float flTargetRadius, int fNoMonsters); node_index_t FindDirectPath(Vector &vecStart, Vector &vecDest, float flTargetRadius, BOOL fNoMonsters);
BOOL LadderHit(Vector &vecSource, Vector &vecDest, TraceResult &tr); BOOL LadderHit(Vector &vecSource, Vector &vecDest, TraceResult &tr);
static void Think(); static void Think();
static void RequestNav(CHostage *pCaller); static void RequestNav(CHostage *pCaller);
static void Reset(); static void Reset();
static void HostagePrethink(); static void HostagePrethink();
static float s_flStepSize; static float m_flStepSize;
private: private:
static EHANDLE _queue[MAX_HOSTAGES_NAV]; static EntityHandle<CHostage> m_hQueue[MAX_HOSTAGES_NAV];
static int qptr; static EntityHandle<CHostage> m_hHostages[MAX_HOSTAGES_NAV];
static int tot_inqueue; static int m_CurRequest;
static float nodeval; static int m_NumRequest;
static float flNextCvarCheck; static int m_NumHostages;
static float flLastThinkTime; static int m_NodeValue;
static EHANDLE hostages[MAX_HOSTAGES_NAV]; static float m_flNextCvarCheck;
static int tot_hostages; static float m_flLastThinkTime;
CHostage *m_pOwner; CHostage *m_pOwner;
edict_t *m_pTargetEnt; edict_t *m_pTargetEnt;

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
void HostageAnimateState::Reset() void HostageAnimateState::Reset()

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
void HostageEscapeToCoverState::OnEnter(CHostageImprov *improv) void HostageEscapeToCoverState::OnEnter(CHostageImprov *improv)

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
void HostageFollowState::OnEnter(CHostageImprov *improv) void HostageFollowState::OnEnter(CHostageImprov *improv)

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
void HostageIdleState::OnEnter(CHostageImprov *improv) void HostageIdleState::OnEnter(CHostageImprov *improv)

View File

@ -1,3 +1,31 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "precompiled.h" #include "precompiled.h"
void HostageRetreatState::OnEnter(CHostageImprov *improv) void HostageRetreatState::OnEnter(CHostageImprov *improv)

View File

@ -278,7 +278,7 @@ BOOL CItemAntidote::MyTouch(CBasePlayer *pPlayer)
#endif #endif
pPlayer->SetSuitUpdate("!HEV_DET4", SUIT_SENTENCE, SUIT_NEXT_IN_1MIN); pPlayer->SetSuitUpdate("!HEV_DET4", SUIT_SENTENCE, SUIT_NEXT_IN_1MIN);
pPlayer->m_rgItems[ ITEM_ID_ANTIDOTE ] += 1; pPlayer->m_rgItems[ITEM_ID_ANTIDOTE] += 1;
return TRUE; return TRUE;
} }
@ -301,7 +301,7 @@ void CItemSecurity::Precache()
BOOL CItemSecurity::MyTouch(CBasePlayer *pPlayer) BOOL CItemSecurity::MyTouch(CBasePlayer *pPlayer)
{ {
pPlayer->m_rgItems[ ITEM_ID_SECURITY ] += 1; pPlayer->m_rgItems[ITEM_ID_SECURITY] += 1;
return TRUE; return TRUE;
} }

View File

@ -1,18 +1,11 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CLight::m_SaveData[] = TYPEDESCRIPTION CLight::m_SaveData[] =
{ {
DEFINE_FIELD(CLight, m_iStyle, FIELD_INTEGER), DEFINE_FIELD(CLight, m_iStyle, FIELD_INTEGER),
DEFINE_FIELD(CLight, m_iszPattern, FIELD_STRING), DEFINE_FIELD(CLight, m_iszPattern, FIELD_STRING),
}; };
#endif
LINK_ENTITY_TO_CLASS(light, CLight, CCSLight) LINK_ENTITY_TO_CLASS(light, CLight, CCSLight)
IMPLEMENT_SAVERESTORE(CLight, CPointEntity) IMPLEMENT_SAVERESTORE(CLight, CPointEntity)

View File

@ -40,7 +40,7 @@ public:
virtual int Restore(CRestore &restore); virtual int Restore(CRestore &restore);
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
static TYPEDESCRIPTION IMPL(m_SaveData)[2]; static TYPEDESCRIPTION m_SaveData[];
private: private:
int m_iStyle; int m_iStyle;

View File

@ -1,32 +1,10 @@
#include "precompiled.h" #include "precompiled.h"
/*
* Globals initialization
*/
#ifndef HOOK_GAMEDLL
TYPEDESCRIPTION CRuleEntity::m_SaveData[] = TYPEDESCRIPTION CRuleEntity::m_SaveData[] =
{ {
DEFINE_FIELD(CRuleEntity, m_iszMaster, FIELD_STRING), DEFINE_FIELD(CRuleEntity, m_iszMaster, FIELD_STRING),
}; };
// Save parms as a block. Will break save/restore if the structure changes, but this entity didn't ship with Half-Life, so
// it can't impact saved Half-Life games.
TYPEDESCRIPTION CGameText::m_SaveData[] =
{
DEFINE_ARRAY(CGameText, m_textParms, FIELD_CHARACTER, sizeof(hudtextparms_t)),
};
TYPEDESCRIPTION CGamePlayerZone::m_SaveData[] =
{
DEFINE_FIELD(CGamePlayerZone, m_iszInTarget, FIELD_STRING),
DEFINE_FIELD(CGamePlayerZone, m_iszOutTarget, FIELD_STRING),
DEFINE_FIELD(CGamePlayerZone, m_iszInCount, FIELD_STRING),
DEFINE_FIELD(CGamePlayerZone, m_iszOutCount, FIELD_STRING),
};
#endif
IMPLEMENT_SAVERESTORE(CRuleEntity, CBaseEntity) IMPLEMENT_SAVERESTORE(CRuleEntity, CBaseEntity)
void CRuleEntity::Spawn() void CRuleEntity::Spawn()
@ -121,6 +99,13 @@ void CGameEnd::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTy
g_pGameRules->EndMultiplayerGame(); g_pGameRules->EndMultiplayerGame();
} }
// Save parms as a block. Will break save/restore if the structure changes, but this entity didn't ship with Half-Life, so
// it can't impact saved Half-Life games.
TYPEDESCRIPTION CGameText::m_SaveData[] =
{
DEFINE_ARRAY(CGameText, m_textParms, FIELD_CHARACTER, sizeof(hudtextparms_t)),
};
LINK_ENTITY_TO_CLASS(game_text, CGameText, CCSGameText) LINK_ENTITY_TO_CLASS(game_text, CGameText, CCSGameText)
IMPLEMENT_SAVERESTORE(CGameText, CRulePointEntity) IMPLEMENT_SAVERESTORE(CGameText, CRulePointEntity)
@ -362,6 +347,14 @@ void CGameTeamSet::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u
} }
} }
TYPEDESCRIPTION CGamePlayerZone::m_SaveData[] =
{
DEFINE_FIELD(CGamePlayerZone, m_iszInTarget, FIELD_STRING),
DEFINE_FIELD(CGamePlayerZone, m_iszOutTarget, FIELD_STRING),
DEFINE_FIELD(CGamePlayerZone, m_iszInCount, FIELD_STRING),
DEFINE_FIELD(CGamePlayerZone, m_iszOutCount, FIELD_STRING),
};
LINK_ENTITY_TO_CLASS(game_zone_player, CGamePlayerZone, CCSGamePlayerZone) LINK_ENTITY_TO_CLASS(game_zone_player, CGamePlayerZone, CCSGamePlayerZone)
IMPLEMENT_SAVERESTORE(CGamePlayerZone, CRuleBrushEntity) IMPLEMENT_SAVERESTORE(CGamePlayerZone, CRuleBrushEntity)

View File

@ -37,7 +37,7 @@ public:
virtual int Restore(CRestore &restore); virtual int Restore(CRestore &restore);
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[1]; static TYPEDESCRIPTION m_SaveData[];
void SetMaster(string_t iszMaster) { m_iszMaster = iszMaster; } void SetMaster(string_t iszMaster) { m_iszMaster = iszMaster; }
@ -107,7 +107,7 @@ public:
const char *MessageGet() const { return STRING(pev->message); } const char *MessageGet() const { return STRING(pev->message); }
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[1]; static TYPEDESCRIPTION m_SaveData[];
private: private:
hudtextparms_t m_textParms; hudtextparms_t m_textParms;
@ -168,7 +168,7 @@ public:
virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value);
public: public:
static TYPEDESCRIPTION IMPL(m_SaveData)[4]; static TYPEDESCRIPTION m_SaveData[];
bool HasOnlyAlive() const { return (pev->spawnflags & SF_GAME_PZONE_ONLY_ALIVE) == SF_GAME_PZONE_ONLY_ALIVE; } bool HasOnlyAlive() const { return (pev->spawnflags & SF_GAME_PZONE_ONLY_ALIVE) == SF_GAME_PZONE_ONLY_ALIVE; }
private: private:

Some files were not shown because too many files have changed in this diff Show More