Update Premake5 (100% no hacks)

This commit is contained in:
Diavolo 2022-04-07 11:41:20 +02:00
parent 57513c61d9
commit 538ef7e491
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
115 changed files with 864 additions and 1209 deletions

View File

@ -28,7 +28,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check out files - name: Check out files
uses: actions/checkout@v2 uses: actions/checkout@v3
with: with:
submodules: true submodules: true
fetch-depth: 0 fetch-depth: 0
@ -39,22 +39,21 @@ jobs:
uses: microsoft/setup-msbuild@v1.1 uses: microsoft/setup-msbuild@v1.1
- name: Generate project files - name: Generate project files
#run: tools/premake5 vs2022 --ci-build --ac-disable
run: tools/premake5 vs2022 --ac-disable run: tools/premake5 vs2022 --ac-disable
- name: Set up problem matching - name: Set up problem matching
uses: ammaraskar/msvc-problem-matcher@master uses: ammaraskar/msvc-problem-matcher@master
- name: Build ${{matrix.configuration}} binaries - name: Build ${{matrix.configuration}} binaries
run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} build/iw4x.sln run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:Platform=Win32 build/iw4x.sln
- name: Upload ${{matrix.configuration}} binaries - name: Upload ${{matrix.configuration}} binaries
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: ${{matrix.configuration}} binaries name: ${{matrix.configuration}} binaries
path: | path: |
build/bin/${{matrix.configuration}}/iw4x.dll build/bin/Win32/${{matrix.configuration}}/iw4x.dll
build/bin/${{matrix.configuration}}/iw4x.pdb build/bin/Win32/${{matrix.configuration}}/iw4x.pdb
# - name: Upload ${{matrix.configuration}} data artifacts # - name: Upload ${{matrix.configuration}} data artifacts
# uses: actions/upload-artifact@v2 # uses: actions/upload-artifact@v2
@ -63,7 +62,6 @@ jobs:
# path: | # path: |
# data/* # data/*
deploy: deploy:
name: Deploy artifacts name: Deploy artifacts
needs: build needs: build

2
deps/libtomcrypt vendored

@ -1 +1 @@
Subproject commit 673f5ce29015a9bba3c96792920a10601b5b0718 Subproject commit 06a81aeb227424182125363f7554fad5146d6d2a

2
deps/libtommath vendored

@ -1 +1 @@
Subproject commit 04e9d1e7a0493910b2eb5e757d623870692ada04 Subproject commit 5108f12350b6daa4aa5dbc846517ad1db2f8388a

19
deps/premake/dxsdk.lua vendored Normal file
View File

@ -0,0 +1,19 @@
dxsdk = {
source = path.join(dependencies.basePath, "dxsdk"),
}
function dxsdk.import()
libdirs {path.join(dxsdk.source, "Lib/x86")}
dxsdk.includes()
end
function dxsdk.includes()
includedirs {
path.join(dxsdk.source, "Include"),
}
end
function dxsdk.project()
end
table.insert(dependencies, dxsdk)

32
deps/premake/json11.lua vendored Normal file
View File

@ -0,0 +1,32 @@
json11 = {
source = path.join(dependencies.basePath, "json11"),
}
function json11.import()
links {"json11"}
json11.includes()
end
function json11.includes()
includedirs {json11.source}
end
function json11.project()
project "json11"
language "C++"
files
{
path.join(json11.source, "*.cpp"),
path.join(json11.source, "*.hpp"),
}
warnings "Off"
defines {"_LIB"}
removedefines {"_USRDLL", "_DLL"}
kind "StaticLib"
end
table.insert(dependencies, json11)

59
deps/premake/libtomcrypt.lua vendored Normal file
View File

@ -0,0 +1,59 @@
libtomcrypt = {
source = path.join(dependencies.basePath, "libtomcrypt"),
}
function libtomcrypt.import()
links {"libtomcrypt"}
libtomcrypt.includes()
end
function libtomcrypt.includes()
includedirs {
path.join(libtomcrypt.source, "src/headers")
}
defines {
"LTC_NO_FAST",
"LTC_NO_PROTOTYPES",
"LTC_NO_RSA_BLINDING",
}
end
function libtomcrypt.project()
project "libtomcrypt"
language "C"
libtomcrypt.includes()
libtommath.import()
files {
path.join(libtomcrypt.source, "src/**.c"),
}
removefiles {
path.join(libtomcrypt.source, "src/**/*tab.c"),
path.join(libtomcrypt.source, "src/encauth/ocb3/**.c"),
}
defines {
"_CRT_SECURE_NO_WARNINGS",
"LTC_SOURCE",
"_LIB",
"USE_LTM"
}
removedefines {
"_DLL",
"_USRDLL"
}
linkoptions {
"-IGNORE:4221"
}
warnings "Off"
kind "StaticLib"
end
table.insert(dependencies, libtomcrypt)

50
deps/premake/libtommath.lua vendored Normal file
View File

@ -0,0 +1,50 @@
libtommath = {
source = path.join(dependencies.basePath, "libtommath"),
}
function libtommath.import()
links {"libtommath"}
libtommath.includes()
end
function libtommath.includes()
includedirs {
libtommath.source
}
defines {
"LTM_DESC",
"__STDC_IEC_559__",
"MP_NO_DEV_URANDOM",
}
end
function libtommath.project()
project "libtommath"
language "C"
libtommath.includes()
files {
path.join(libtommath.source, "*.c"),
}
defines {
"_LIB"
}
removedefines {
"_DLL",
"_USRDLL"
}
linkoptions {
"-IGNORE:4221"
}
warnings "Off"
kind "StaticLib"
end
table.insert(dependencies, libtommath)

43
deps/premake/minizip.lua vendored Normal file
View File

@ -0,0 +1,43 @@
minizip = {
source = path.join(dependencies.basePath, "zlib/contrib/minizip"),
}
function minizip.import()
links {"minizip"}
zlib.import()
minizip.includes()
end
function minizip.includes()
includedirs {
minizip.source
}
zlib.includes()
end
function minizip.project()
project "minizip"
language "C"
minizip.includes()
files {
path.join(minizip.source, "*.h"),
path.join(minizip.source, "*.c"),
}
removefiles {
path.join(minizip.source, "miniunz.c"),
path.join(minizip.source, "minizip.c"),
}
defines {
"_CRT_SECURE_NO_DEPRECATE",
}
warnings "Off"
kind "StaticLib"
end
table.insert(dependencies, minizip)

32
deps/premake/mongoose.lua vendored Normal file
View File

@ -0,0 +1,32 @@
mongoose = {
source = path.join(dependencies.basePath, "mongoose"),
}
function mongoose.import()
links {"mongoose"}
mongoose.includes()
end
function mongoose.includes()
includedirs {mongoose.source}
end
function mongoose.project()
project "mongoose"
language "C"
mongoose.includes()
files
{
path.join(mongoose.source, "*.c"),
path.join(mongoose.source, "*.h"),
}
warnings "Off"
kind "StaticLib"
end
table.insert(dependencies, mongoose)

34
deps/premake/pdcurses.lua vendored Normal file
View File

@ -0,0 +1,34 @@
pdcurses = {
source = path.join(dependencies.basePath, "pdcurses"),
}
function pdcurses.import()
links {"pdcurses"}
pdcurses.includes()
end
function pdcurses.includes()
includedirs {pdcurses.source}
end
function pdcurses.project()
project "pdcurses"
language "C"
pdcurses.includes()
files
{
path.join(pdcurses.source, "pdcurses/*.c"),
path.join(pdcurses.source, "pdcurses/*.h"),
path.join(pdcurses.source, "wincon/*.c"),
path.join(pdcurses.source, "wincon/*.h"),
}
warnings "Off"
kind "StaticLib"
end
table.insert(dependencies, pdcurses)

50
deps/premake/protobuf.lua vendored Normal file
View File

@ -0,0 +1,50 @@
protobuf = {
source = path.join(dependencies.basePath, "protobuf"),
}
function protobuf.import()
links {"protobuf"}
protobuf.includes()
end
function protobuf.includes()
includedirs {
path.join(protobuf.source, "src"),
}
end
function protobuf.project()
project "protobuf"
language "C++"
protobuf.includes()
files {
path.join(protobuf.source, "src/**.cc"),
"./src/**.proto",
}
removefiles {
path.join(protobuf.source, "src/**/*test.cc"),
path.join(protobuf.source, "src/google/protobuf/*test*.cc"),
path.join(protobuf.source, "src/google/protobuf/testing/**.cc"),
path.join(protobuf.source, "src/google/protobuf/compiler/**.cc"),
path.join(protobuf.source, "src/google/protobuf/arena_nc.cc"),
path.join(protobuf.source, "src/google/protobuf/util/internal/error_listener.cc"),
path.join(protobuf.source, "**/*_gcc.cc"),
}
rules {"ProtobufCompiler"}
defines {"_SCL_SECURE_NO_WARNINGS"}
linkoptions {"-IGNORE:4221"}
warnings "Off"
kind "StaticLib"
end
table.insert(dependencies, protobuf)

35
deps/premake/udis86.lua vendored Normal file
View File

@ -0,0 +1,35 @@
udis86 = {
source = path.join(dependencies.basePath, "udis86"),
}
function udis86.import()
links {"udis86"}
udis86.includes()
end
function udis86.includes()
includedirs {
udis86.source,
path.join(udis86.source, "libudis86"),
path.join(dependencies.basePath, "extra/udis86"),
path.join(dependencies.basePath, "extra/udis86/libudis86"),
}
end
function udis86.project()
project "udis86"
language "C"
udis86.includes()
files {
path.join(udis86.source, "libudis86/*.c"),
path.join(dependencies.basePath, "extra/udis86/libudis86/*.c"),
}
warnings "Off"
kind "StaticLib"
end
table.insert(dependencies, udis86)

39
deps/premake/zlib.lua vendored Normal file
View File

@ -0,0 +1,39 @@
zlib = {
source = path.join(dependencies.basePath, "zlib"),
}
function zlib.import()
links {"zlib"}
zlib.includes()
end
function zlib.includes()
includedirs {
zlib.source
}
defines {
"ZLIB_CONST",
}
end
function zlib.project()
project "zlib"
language "C"
zlib.includes()
files {
path.join(zlib.source, "*.h"),
path.join(zlib.source, "*.c"),
}
defines {
"_CRT_SECURE_NO_DEPRECATE",
}
warnings "Off"
kind "StaticLib"
end
table.insert(dependencies, zlib)

2
deps/zlib vendored

@ -1 +1 @@
Subproject commit 2014a993addbc8f1b9785d97f55fd189792c2f78 Subproject commit ec3df00224d4b396e2ac6586ab5d25f673caa4c2

View File

@ -1,35 +0,0 @@
dxsdk = {
settings = nil
}
function dxsdk.setup(settings)
if not settings.source then error("Missing source.") end
dxsdk.settings = settings
if not dxsdk.settings.defines then dxsdk.settings.defines = {} end
end
function dxsdk.import()
if not dxsdk.settings then error("You need to call dxsdk.setup first") end
--filter "platforms:*32"
libdirs { path.join(dxsdk.settings.source, "Lib/x86") }
--filter "platforms:*64"
-- libdirs { path.join(dxsdk.settings.source, "Lib/x64") }
--filter {}
dxsdk.includes()
end
function dxsdk.includes()
if not dxsdk.settings then error("You need to call dxsdk.setup first") end
includedirs { path.join(dxsdk.settings.source, "Include") }
defines(dxsdk.settings.defines)
end
function dxsdk.project()
end

View File

@ -1,51 +0,0 @@
json11 = {
settings = nil,
}
function json11.setup(settings)
if not settings.source then error("Missing source.") end
json11.settings = settings
end
function json11.import()
if not json11.settings then error("Run json11.setup first") end
links { "json11" }
json11.includes()
end
function json11.includes()
if not json11.settings then error("Run json11.setup first") end
includedirs { json11.settings.source }
end
function json11.project()
if not json11.settings then error("Run json11.setup first") end
project "json11"
language "C++"
includedirs
{
json11.settings.source,
}
files
{
path.join(json11.settings.source, "*.cpp"),
path.join(json11.settings.source, "*.hpp"),
}
removefiles
{
path.join(json11.settings.source, "test*"),
}
-- not our code, ignore POSIX usage warnings for now
warnings "Off"
defines { "_LIB" }
removedefines { "_USRDLL", "_DLL" }
kind "StaticLib"
end

View File

@ -1,62 +0,0 @@
libtomcrypt = {
settings = nil
}
function libtomcrypt.setup(settings)
if not settings.source then error("Missing source") end
libtomcrypt.settings = settings
if not libtomcrypt.settings.defines then libtomcrypt.settings.defines = {} end
end
function libtomcrypt.import()
if not libtomcrypt.settings then error("Run libtomcrypt.setup first") end
links { "libtomcrypt" }
libtomcrypt.includes()
end
function libtomcrypt.includes()
if not libtomcrypt.settings then error("Run libtomcrypt.setup first") end
defines(libtomcrypt.settings.defines)
includedirs { path.join(libtomcrypt.settings.source, "src/headers") }
end
function libtomcrypt.project()
if not libtomcrypt.settings then error("Run libtomcrypt.setup first") end
project "libtomcrypt"
language "C"
libtomcrypt.includes()
files
{
path.join(libtomcrypt.settings.source, "src/**.c"),
}
removefiles
{
path.join(libtomcrypt.settings.source, "src/**/*tab.c"), -- included by files as necessary already afaik
path.join(libtomcrypt.settings.source, "src/encauth/ocb3/**.c"), -- fails in Visual Studio with invalid syntax
}
defines
{
"_CRT_SECURE_NO_WARNINGS",
"LTC_SOURCE", -- we are compiling from source code
}
-- dependencies
if libtommath and libtommath.settings then
defines { "USE_LTM" }
libtommath.import()
end
-- not our code, ignore POSIX usage warnings for now
warnings "Off"
defines { "_LIB" }
removedefines { "_DLL", "_USRDLL" }
linkoptions { "-IGNORE:4221" }
kind "StaticLib"
end

View File

@ -1,46 +0,0 @@
libtommath = {
settings = nil
}
function libtommath.setup(settings)
if not settings.source then error("Missing source") end
libtommath.settings = settings
if not libtommath.settings.defines then libtommath.settings.defines = {} end
end
function libtommath.import()
if not libtommath.settings then error("Run libtommath.setup first") end
links { "libtommath" }
libtommath.includes()
end
function libtommath.includes()
if not libtommath.settings then error("Run libtommath.setup first") end
defines(libtommath.settings.defines)
includedirs { libtommath.settings.source }
end
function libtommath.project()
if not libtommath.settings then error("Run libtommath.setup first") end
project "libtommath"
language "C"
libtommath.includes()
files
{
path.join(libtommath.settings.source, "*.c"),
}
-- not our code, ignore POSIX usage warnings for now
warnings "Off"
defines { "_LIB" }
removedefines { "_DLL", "_USRDLL" }
linkoptions { "-IGNORE:4221" }
kind "StaticLib"
end

View File

@ -1,42 +0,0 @@
mongoose = {
settings = nil,
}
function mongoose.setup(settings)
if not settings.source then error("Missing source.") end
mongoose.settings = settings
end
function mongoose.import()
if not mongoose.settings then error("Run mongoose.setup first") end
links { "mongoose" }
mongoose.includes()
end
function mongoose.includes()
if not mongoose.settings then error("Run mongoose.setup first") end
includedirs { mongoose.settings.source }
end
function mongoose.project()
if not mongoose.settings then error("Run mongoose.setup first") end
project "mongoose"
language "C"
mongoose.includes()
files
{
path.join(mongoose.settings.source, "*.c"),
path.join(mongoose.settings.source, "*.h"),
}
-- not our code, ignore POSIX usage warnings for now
warnings "Off"
-- always build as static lib, as mongoose doesn't export anything
kind "StaticLib"
end

View File

@ -1,48 +0,0 @@
pdcurses = {
settings = nil,
}
function pdcurses.setup(settings)
if not settings.source then error("Missing source.") end
pdcurses.settings = settings
end
function pdcurses.import()
if not pdcurses.settings then error("Run pdcurses.setup first") end
links { "pdcurses" }
pdcurses.includes()
end
function pdcurses.includes()
if not pdcurses.settings then error("Run pdcurses.setup first") end
includedirs { pdcurses.settings.source }
end
function pdcurses.project()
if not pdcurses.settings then error("Run pdcurses.setup first") end
project "pdcurses"
language "C"
includedirs
{
pdcurses.settings.source,
}
files
{
path.join(pdcurses.settings.source, "pdcurses/*.c"),
path.join(pdcurses.settings.source, "pdcurses/*.h"),
path.join(pdcurses.settings.source, "wincon/*.c"),
path.join(pdcurses.settings.source, "wincon/*.h"),
}
-- not our code, ignore POSIX usage warnings for now
warnings "Off"
-- always build as static lib, as pdcurses doesn't export anything
kind "StaticLib"
end

View File

@ -1,68 +0,0 @@
protobuf = {
settings = nil,
}
function protobuf.setup(settings)
if not settings.source then error("Missing source.") end
protobuf.settings = settings
end
function protobuf.import()
if not protobuf.settings then error("Run protobuf.setup first") end
links { "protobuf" }
protobuf.includes()
end
function protobuf.includes()
if not protobuf.settings then error("Run protobuf.setup first") end
includedirs
{
path.join(protobuf.settings.source, "src"),
}
end
function protobuf.project()
if not protobuf.settings then error("Run protobuf.setup first") end
project "protobuf"
language "C++"
includedirs
{
path.join(protobuf.settings.source, "src"),
}
files
{
path.join(protobuf.settings.source, "src/**.cc"),
"./src/**.proto",
}
removefiles
{
path.join(protobuf.settings.source, "src/**/*test.cc"),
path.join(protobuf.settings.source, "src/google/protobuf/*test*.cc"),
path.join(protobuf.settings.source, "src/google/protobuf/testing/**.cc"),
path.join(protobuf.settings.source, "src/google/protobuf/compiler/**.cc"),
path.join(protobuf.settings.source, "src/google/protobuf/arena_nc.cc"),
path.join(protobuf.settings.source, "src/google/protobuf/util/internal/error_listener.cc"),
path.join(protobuf.settings.source, "**/*_gcc.cc"),
}
-- Generate source code from protobuf definitions
rules { "ProtobufCompiler" }
-- dependencies
zlib.import()
-- not our code, ignore POSIX usage warnings for now
defines { "_SCL_SECURE_NO_WARNINGS" }
warnings "Off"
linkoptions { "-IGNORE:4221" }
-- always build as static lib, as we include our custom classes and therefore can't perform shared linking
kind "StaticLib"
end

View File

@ -1,51 +0,0 @@
udis86 = {
settings = nil
}
function udis86.setup(settings)
if not settings.source then error("Missing source.") end
udis86.settings = settings
if not udis86.settings.defines then udis86.settings.defines = {} end
end
function udis86.import()
if not udis86.settings then error("You need to call udis86.setup first") end
links { "udis86" }
udis86.includes()
end
function udis86.includes()
if not udis86.settings then error("You need to call udis86.setup first") end
includedirs
{
udis86.settings.source,
path.join(udis86.settings.source, "libudis86/"),
path.join(udis86.settings.source, "../extra/udis86/"),
path.join(udis86.settings.source, "../extra/udis86/libudis86/")
}
defines(udis86.settings.defines)
end
function udis86.project()
if not udis86.settings then error("You need to call udis86.setup first") end
project "udis86"
language "C"
udis86.includes()
files
{
path.join(udis86.settings.source, "libudis86/*.h"),
path.join(udis86.settings.source, "libudis86/*.c"),
path.join(udis86.settings.source, "../extra/udis86/libudis86/*.c"),
}
-- not our code, ignore POSIX usage warnings for now
warnings "Off"
kind "StaticLib"
end

View File

@ -1,48 +0,0 @@
zlib = {
settings = nil
}
function zlib.setup(settings)
if not settings.source then error("Missing source.") end
zlib.settings = settings
if not zlib.settings.defines then zlib.settings.defines = {} end
end
function zlib.import()
if not zlib.settings then error("You need to call zlib.setup first") end
links { "zlib" }
zlib.includes()
end
function zlib.includes()
if not zlib.settings then error("You need to call zlib.setup first") end
includedirs { zlib.settings.source }
defines(zlib.settings.defines)
end
function zlib.project()
if not zlib.settings then error("You need to call zlib.setup first") end
project "zlib"
language "C"
zlib.includes()
files
{
path.join(zlib.settings.source, "*.h"),
path.join(zlib.settings.source, "*.c"),
}
defines
{
"_CRT_SECURE_NO_DEPRECATE",
}
-- not our code, ignore POSIX usage warnings for now
warnings "Off"
kind "StaticLib"
end

View File

@ -3,6 +3,9 @@ gitCurrentBranchCommand = "git symbolic-ref -q --short HEAD"
-- Quote the given string input as a C string -- Quote the given string input as a C string
function cstrquote(value) function cstrquote(value)
if value == nil then
return "\"\""
end
result = value:gsub("\\", "\\\\") result = value:gsub("\\", "\\\\")
result = result:gsub("\"", "\\\"") result = result:gsub("\"", "\\\"")
result = result:gsub("\n", "\\n") result = result:gsub("\n", "\\n")
@ -27,18 +30,42 @@ function vertonumarr(value, vernumber)
return vernum return vernum
end end
-- Option to allow copying the DLL file to a custom folder after build dependencies = {
basePath = "./deps"
}
function dependencies.load()
dir = path.join(dependencies.basePath, "premake/*.lua")
deps = os.matchfiles(dir)
for i, dep in pairs(deps) do
dep = dep:gsub(".lua", "")
require(dep)
end
end
function dependencies.imports()
for i, proj in pairs(dependencies) do
if type(i) == 'number' then
proj.import()
end
end
end
function dependencies.projects()
for i, proj in pairs(dependencies) do
if type(i) == 'number' then
proj.project()
end
end
end
newoption { newoption {
trigger = "copy-to", trigger = "copy-to",
description = "Optional, copy the DLL to a custom folder after build, define the path here if wanted.", description = "Optional, copy the DLL to a custom folder after build, define the path here if wanted.",
value = "PATH" value = "PATH"
} }
newoption {
trigger = "no-new-structure",
description = "Do not use new virtual path structure (separating headers and source files)."
}
newoption { newoption {
trigger = "copy-pdb", trigger = "copy-pdb",
description = "Copy debug information for binaries as well to the path given via --copy-to." description = "Copy debug information for binaries as well to the path given via --copy-to."
@ -183,66 +210,7 @@ newaction {
end end
} }
depsBasePath = "./deps" dependencies.load()
require "premake/json11"
require "premake/libtomcrypt"
require "premake/libtommath"
require "premake/mongoose"
require "premake/pdcurses"
require "premake/protobuf"
require "premake/zlib"
require "premake/udis86"
require "premake/dxsdk"
json11.setup
{
source = path.join(depsBasePath, "json11"),
}
libtomcrypt.setup
{
defines = {
"LTC_NO_FAST",
"LTC_NO_PROTOTYPES",
"LTC_NO_RSA_BLINDING",
},
source = path.join(depsBasePath, "libtomcrypt"),
}
libtommath.setup
{
defines = {
"LTM_DESC",
"__STDC_IEC_559__",
},
source = path.join(depsBasePath, "libtommath"),
}
mongoose.setup
{
source = path.join(depsBasePath, "mongoose"),
}
pdcurses.setup
{
source = path.join(depsBasePath, "pdcurses"),
}
protobuf.setup
{
source = path.join(depsBasePath, "protobuf"),
}
zlib.setup
{
defines = {
"ZLIB_CONST"
},
source = path.join(depsBasePath, "zlib"),
}
udis86.setup
{
source = path.join(depsBasePath, "udis86"),
}
dxsdk.setup
{
source = path.join(depsBasePath, "dxsdk"),
}
workspace "iw4x" workspace "iw4x"
startproject "iw4x" startproject "iw4x"
@ -251,13 +219,13 @@ workspace "iw4x"
targetdir "%{wks.location}/bin/%{cfg.buildcfg}" targetdir "%{wks.location}/bin/%{cfg.buildcfg}"
buildlog "%{wks.location}/obj/%{cfg.architecture}/%{cfg.buildcfg}/%{prj.name}/%{prj.name}.log" buildlog "%{wks.location}/obj/%{cfg.architecture}/%{cfg.buildcfg}/%{prj.name}/%{prj.name}.log"
configurations { "Debug", "Release" } configurations {"Debug", "Release"}
language "C++" language "C++"
cppdialect "C++17" cppdialect "C++17"
architecture "x86" architecture "x86"
platforms "x86" platforms "Win32"
systemversion "latest" systemversion "latest"
symbols "On" symbols "On"
@ -266,18 +234,18 @@ workspace "iw4x"
warnings "Extra" warnings "Extra"
characterset "ASCII" characterset "ASCII"
flags { "NoIncrementalLink", "NoMinimalRebuild", "MultiProcessorCompile", "No64BitChecks" } flags {"NoIncrementalLink", "NoMinimalRebuild", "MultiProcessorCompile", "No64BitChecks"}
filter "platforms:x86" filter "platforms:Win*"
defines {"_WINDOWS", "WIN32"} defines {"_WINDOWS", "WIN32"}
filter {} filter {}
filter "configurations:Release" filter "configurations:Release"
optimize "On" optimize "Size"
buildoptions { "/GL" } buildoptions {"/GL"}
linkoptions { "/IGNORE:4702", "/LTCG" } linkoptions {"/IGNORE:4702", "/LTCG"}
defines { "NDEBUG" } defines {"NDEBUG"}
flags { "FatalCompileWarnings", "FatalLinkWarnings" } flags {"FatalCompileWarnings", "FatalLinkWarnings"}
if not _OPTIONS["force-unit-tests"] then if not _OPTIONS["force-unit-tests"] then
rtti ("Off") rtti ("Off")
@ -286,7 +254,7 @@ workspace "iw4x"
filter "configurations:Debug" filter "configurations:Debug"
optimize "Debug" optimize "Debug"
defines { "DEBUG", "_DEBUG" } defines {"DEBUG", "_DEBUG"}
filter {} filter {}
project "iw4x" project "iw4x"
@ -296,7 +264,6 @@ workspace "iw4x"
"./src/**.rc", "./src/**.rc",
"./src/**.hpp", "./src/**.hpp",
"./src/**.cpp", "./src/**.cpp",
--"./src/**.proto",
} }
includedirs { includedirs {
"%{prj.location}/src", "%{prj.location}/src",
@ -312,66 +279,32 @@ workspace "iw4x"
-- Debug flags -- Debug flags
if _OPTIONS["ac-disable"] then if _OPTIONS["ac-disable"] then
defines { "DISABLE_ANTICHEAT" } defines {"DISABLE_ANTICHEAT"}
end end
if _OPTIONS["ac-debug-detections"] then if _OPTIONS["ac-debug-detections"] then
defines { "DEBUG_DETECTIONS" } defines {"DEBUG_DETECTIONS"}
end end
if _OPTIONS["ac-debug-load-library"] then if _OPTIONS["ac-debug-load-library"] then
defines { "DEBUG_LOAD_LIBRARY" } defines {"DEBUG_LOAD_LIBRARY"}
end end
if _OPTIONS["force-unit-tests"] then if _OPTIONS["force-unit-tests"] then
defines { "FORCE_UNIT_TESTS" } defines {"FORCE_UNIT_TESTS"}
end end
if _OPTIONS["force-minidump-upload"] then if _OPTIONS["force-minidump-upload"] then
defines { "FORCE_MINIDUMP_UPLOAD" } defines {"FORCE_MINIDUMP_UPLOAD"}
end end
if _OPTIONS["force-exception-handler"] then if _OPTIONS["force-exception-handler"] then
defines { "FORCE_EXCEPTION_HANDLER" } defines {"FORCE_EXCEPTION_HANDLER"}
end end
if _OPTIONS["iw4x-zones"] then if _OPTIONS["iw4x-zones"] then
defines { "GENERATE_IW4X_SPECIFIC_ZONES" } defines {"GENERATE_IW4X_SPECIFIC_ZONES"}
end end
-- Pre-compiled header -- Pre-compiled header
pchheader "STDInclude.hpp" -- must be exactly same as used in #include directives pchheader "STDInclude.hpp" -- must be exactly same as used in #include directives
pchsource "src/STDInclude.cpp" -- real path pchsource "src/STDInclude.cpp" -- real path
buildoptions { "/Zm200" }
-- Dependency libraries dependencies.imports()
json11.import()
libtomcrypt.import()
libtommath.import()
mongoose.import()
pdcurses.import()
protobuf.import()
zlib.import()
udis86.import()
dxsdk.import()
-- fix vpaths for protobuf sources
vpaths
{
["*"] = { "./src/**" },
--["Proto/Generated"] = { "**.pb.*" }, -- meh.
}
-- Virtual paths
if not _OPTIONS["no-new-structure"] then
vpaths
{
["Headers/*"] = { "./src/**.hpp" },
["Sources/*"] = { "./src/**.cpp" },
["Resource/*"] = { "./src/**.rc" },
--["Proto/Definitions/*"] = { "./src/Proto/**.proto" },
--["Proto/Generated/*"] = { "**.pb.*" }, -- meh.
}
end
vpaths
{
["Docs/*"] = { "**.txt","**.md" },
}
-- Pre-build -- Pre-build
prebuildcommands prebuildcommands
@ -400,49 +333,9 @@ workspace "iw4x"
} }
end end
--[[
-- Generate source code from protobuf definitions
rules { "ProtobufCompiler" }
-- Workaround: Consume protobuf generated source files group "External Dependencies"
matches = os.matchfiles(path.join("src/Proto/**.proto")) dependencies.projects()
for i, srcPath in ipairs(matches) do
basename = path.getbasename(srcPath)
files
{
string.format("%%{prj.location}/src/proto/%s.pb.h", basename),
string.format("%%{prj.location}/src/proto/%s.pb.cc", basename),
}
end
includedirs
{
"%{prj.location}/src/proto",
}
filter "files:**.pb.*"
flags {
"NoPCH",
}
buildoptions {
"/wd4100", -- "Unused formal parameter"
"/wd4389", -- "Signed/Unsigned mismatch"
"/wd6011", -- "Dereferencing NULL pointer"
"/wd4125", -- "Decimal digit terminates octal escape sequence"
}
defines {
"_SCL_SECURE_NO_WARNINGS",
}
filter {}
]]
group "External dependencies"
json11.project()
libtomcrypt.project()
libtommath.project()
mongoose.project()
pdcurses.project()
protobuf.project()
zlib.project()
udis86.project()
rule "ProtobufCompiler" rule "ProtobufCompiler"
display "Protobuf compiler" display "Protobuf compiler"

View File

@ -494,7 +494,7 @@ namespace Components
{ {
this->reallocateEntryPool(); this->reallocateEntryPool();
Dvar::Register<bool>("r_noVoid", false, Game::DVAR_FLAG_SAVED, "Disable void model (red fx)"); Dvar::Register<bool>("r_noVoid", false, Game::DVAR_ARCHIVE, "Disable void model (red fx)");
AssetHandler::ClearTemporaryAssets(); AssetHandler::ClearTemporaryAssets();

View File

@ -61,7 +61,7 @@ namespace Assets
glyph.pixelHeight = static_cast<char>(gh); glyph.pixelHeight = static_cast<char>(gh);
glyph.x0 = static_cast<char>(x0); glyph.x0 = static_cast<char>(x0);
glyph.y0 = static_cast<char>(y0 + yOffset); glyph.y0 = static_cast<char>(y0 + yOffset);
glyph.dx = static_cast<char>(roundf(scale * advance)); glyph.dx = static_cast<char>(std::roundf(scale * advance));
// Advance to next col // Advance to next col
x = x + gw + 1; x = x + gw + 1;
@ -92,7 +92,7 @@ namespace Assets
} }
} }
void IFont_s::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone*) void IFont_s::load(Game::XAssetHeader* header, const std::string& name, Components::ZoneBuilder::Zone* builder)
{ {
Components::FileSystem::File fontDefFile(Utils::String::VA("%s.json", name.data())); Components::FileSystem::File fontDefFile(Utils::String::VA("%s.json", name.data()));
Components::FileSystem::File fontFile(Utils::String::VA("%s.ttf", name.data())); Components::FileSystem::File fontFile(Utils::String::VA("%s.ttf", name.data()));
@ -105,11 +105,13 @@ namespace Assets
if (!errors.empty()) if (!errors.empty())
{ {
Components::Logger::Error("Font define %s is broken: %s.", name.data(), errors.data()); Components::Logger::Error("Font define %s is broken: %s.", name.data(), errors.data());
return;
} }
if (!fontDef.is_object()) if (!fontDef.is_object())
{ {
Components::Logger::Error("Font define %s is invaild.", name.data(), errors.data()); Components::Logger::Error("Font define %s is invaild.", name.data(), errors.data());
return;
} }
int w = fontDef["textureWidth"].int_value(); int w = fontDef["textureWidth"].int_value();
@ -118,22 +120,28 @@ namespace Assets
int size = fontDef["size"].int_value(); int size = fontDef["size"].int_value();
int yOffset = fontDef["yOffset"].int_value(); int yOffset = fontDef["yOffset"].int_value();
uint8_t* pixels = Utils::Memory::AllocateArray<uint8_t>(w * h); auto* pixels = builder->getAllocator()->allocateArray<uint8_t>(w * h);
// Setup assets // Setup assets
auto* texName = Utils::Memory::DuplicateString(Utils::String::VA("if_%s", name.data() + 6 /* skip "fonts/" */)); const auto* texName = builder->getAllocator()->duplicateString(Utils::String::VA("if_%s", name.data() + 6 /* skip "fonts/" */));
auto* fontName = Utils::Memory::DuplicateString(name.data()); const auto* fontName = builder->getAllocator()->duplicateString(name.data());
auto* glowMaterialName = Utils::Memory::DuplicateString(Utils::String::VA("%s_glow", name.data())); const auto* glowMaterialName = builder->getAllocator()->duplicateString(Utils::String::VA("%s_glow", name.data()));
auto* image = builder->getAllocator()->allocate<Game::GfxImage>();
std::memcpy(image, Game::DB_FindXAssetHeader(Game::ASSET_TYPE_IMAGE, "gamefonts_pc").image, sizeof(Game::GfxImage));
auto* image = Utils::Memory::Duplicate(Game::DB_FindXAssetHeader(Game::ASSET_TYPE_IMAGE, "gamefonts_pc").image);
image->name = texName; image->name = texName;
auto* material = Utils::Memory::Duplicate(Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "fonts/gamefonts_pc").material); auto* material = builder->getAllocator()->allocate<Game::Material>();
material->textureTable = Utils::Memory::Duplicate(material->textureTable); std::memcpy(material, Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "fonts/gamefonts_pc").material, sizeof(Game::Material));
material->textureTable = builder->getAllocator()->allocate<Game::MaterialTextureDef>();
material->textureTable->u.image = image; material->textureTable->u.image = image;
material->info.name = fontName; material->info.name = fontName;
auto* glowMaterial = Utils::Memory::Duplicate(Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "fonts/gamefonts_pc_glow").material); auto* glowMaterial = builder->getAllocator()->allocate<Game::Material>();
std::memcpy(glowMaterial, Game::DB_FindXAssetHeader(Game::ASSET_TYPE_MATERIAL, "fonts/gamefonts_pc_glow").material, sizeof(Game::Material));
glowMaterial->textureTable = material->textureTable; glowMaterial->textureTable = material->textureTable;
glowMaterial->info.name = glowMaterialName; glowMaterial->info.name = glowMaterialName;
@ -161,14 +169,14 @@ namespace Assets
charset.push_back(i); charset.push_back(i);
} }
auto* font = Utils::Memory::Allocate<Game::Font_s>(); auto* font = builder->getAllocator()->allocate<Game::Font_s>();
font->fontName = fontName; font->fontName = fontName;
font->pixelHeight = size; font->pixelHeight = size;
font->material = material; font->material = material;
font->glowMaterial = glowMaterial; font->glowMaterial = glowMaterial;
font->glyphCount = charset.size(); font->glyphCount = charset.size();
font->glyphs = Utils::Memory::AllocateArray<Game::Glyph>(charset.size()); font->glyphs = builder->getAllocator()->allocateArray<Game::Glyph>(charset.size());
// Generate glyph data // Generate glyph data
int result = PackFonts(reinterpret_cast<const uint8_t*>(fontFile.getBuffer().data()), charset, font->glyphs, static_cast<float>(size), pixels, w, h, yOffset); int result = PackFonts(reinterpret_cast<const uint8_t*>(fontFile.getBuffer().data()), charset, font->glyphs, static_cast<float>(size), pixels, w, h, yOffset);
@ -239,7 +247,6 @@ namespace Assets
} }
Utils::IO::WriteFile(Utils::String::VA("userraw\\images\\%s.iwi", texName), outIwi); Utils::IO::WriteFile(Utils::String::VA("userraw\\images\\%s.iwi", texName), outIwi);
Utils::Memory::Free(pixels);
} }
} }

View File

@ -83,7 +83,7 @@ namespace Components
Command::ServerParams params; Command::ServerParams params;
if (params.length() < 3) if (params.size() < 3)
{ {
Game::SV_Cmd_EndTokenizedString(); Game::SV_Cmd_EndTokenizedString();
Logger::SoftError("Connecting failed: Command parsing error!"); Logger::SoftError("Connecting failed: Command parsing error!");
@ -170,7 +170,7 @@ namespace Components
Command::ServerParams params; Command::ServerParams params;
// Ensure there are enough params // Ensure there are enough params
if (params.length() < 3) if (params.size() < 3)
{ {
Network::Send(address, "error\nInvalid connect string!"); Network::Send(address, "error\nInvalid connect string!");
return; return;
@ -432,7 +432,7 @@ namespace Components
Scheduler::OnFrame(Auth::Frame); Scheduler::OnFrame(Auth::Frame);
// Register dvar // Register dvar
Dvar::Register<int>("sv_securityLevel", 23, 0, 512, Game::dvar_flag::DVAR_FLAG_SERVERINFO, "Security level for GUID certificates (POW)"); Dvar::Register<int>("sv_securityLevel", 23, 0, 512, Game::dvar_flag::DVAR_SERVERINFO, "Security level for GUID certificates (POW)");
// Install registration hook // Install registration hook
Utils::Hook(0x6265F9, Auth::DirectConnectStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x6265F9, Auth::DirectConnectStub, HOOK_JUMP).install()->quick();
@ -455,7 +455,7 @@ namespace Components
{ {
Command::Add("securityLevel", [](Command::Params* params) Command::Add("securityLevel", [](Command::Params* params)
{ {
if (params->length() < 2) if (params->size() < 2)
{ {
uint32_t level = Auth::GetZeroBits(Auth::GuidToken, Auth::GuidKey.getPublicKey()); uint32_t level = Auth::GetZeroBits(Auth::GuidToken, Auth::GuidKey.getPublicKey());
Logger::Print("Your current security level is %d\n", level); Logger::Print("Your current security level is %d\n", level);

View File

@ -234,17 +234,17 @@ namespace Components
{ {
Command::Add("banclient", [](Command::Params* params) Command::Add("banclient", [](Command::Params* params)
{ {
if (params->length() < 2) return; if (params->size() < 2) return;
std::string reason = "EXE_ERR_BANNED_PERM"; std::string reason = "EXE_ERR_BANNED_PERM";
if (params->length() >= 3) reason = params->join(2); if (params->size() >= 3) reason = params->join(2);
Bans::BanClientNum(atoi(params->get(1)), reason); Bans::BanClientNum(atoi(params->get(1)), reason);
}); });
Command::Add("unbanclient", [](Command::Params* params) Command::Add("unbanclient", [](Command::Params* params)
{ {
if (params->length() < 2) return; if (params->size() < 2) return;
std::string type = params->get(1); std::string type = params->get(1);
@ -274,9 +274,4 @@ namespace Components
Bans::LoadBans(&list); Bans::LoadBans(&list);
}); });
} }
Bans::~Bans()
{
}
} }

View File

@ -8,7 +8,6 @@ namespace Components
typedef std::pair<SteamID, Game::netIP_t> Entry; typedef std::pair<SteamID, Game::netIP_t> Entry;
Bans(); Bans();
~Bans();
static void BanClientNum(int num, const std::string& reason); static void BanClientNum(int num, const std::string& reason);
static void UnbanClient(SteamID id); static void UnbanClient(SteamID id);

View File

@ -447,7 +447,7 @@ namespace Components
{ {
unsigned int count = 1; unsigned int count = 1;
if (params->length() > 1) if (params->size() > 1)
{ {
if (params->get(1) == "all"s) count = static_cast<unsigned int>(-1); if (params->get(1) == "all"s) count = static_cast<unsigned int>(-1);
else count = atoi(params->get(1)); else count = atoi(params->get(1));

View File

@ -192,14 +192,14 @@ namespace Components
{ {
Dvar::OnInit([]() Dvar::OnInit([]()
{ {
CardTitles::CustomTitleDvar = Dvar::Register<const char*>("customtitle", "", Game::dvar_flag::DVAR_FLAG_USERINFO | Game::dvar_flag::DVAR_FLAG_SAVED, "Custom card title"); CardTitles::CustomTitleDvar = Dvar::Register<const char*>("customtitle", "", Game::dvar_flag::DVAR_USERINFO | Game::dvar_flag::DVAR_ARCHIVE, "Custom card title");
}); });
ServerCommands::OnCommand(21, [](Command::Params* params) ServerCommands::OnCommand(21, [](Command::Params* params)
{ {
if (params->get(1) == "customTitles"s && !Dedicated::IsEnabled()) if (params->get(1) == "customTitles"s && !Dedicated::IsEnabled())
{ {
if (params->length() == 3) if (params->size() == 3)
{ {
CardTitles::ParseCustomTitles(params->get(2)); CardTitles::ParseCustomTitles(params->get(2));
return true; return true;
@ -210,11 +210,6 @@ namespace Components
}); });
for (int i = 0; i < ARRAYSIZE(CardTitles::CustomTitles); ++i)
{
CardTitles::CustomTitles[i].clear();
}
Utils::Hook(0x62EB26, CardTitles::GetPlayerCardClientInfoStub).install()->quick(); Utils::Hook(0x62EB26, CardTitles::GetPlayerCardClientInfoStub).install()->quick();
// Table lookup stuff // Table lookup stuff
@ -227,12 +222,4 @@ namespace Components
AntiCheat::CheckStartupTime(); AntiCheat::CheckStartupTime();
#endif #endif
} }
CardTitles::~CardTitles()
{
for (int i = 0; i < ARRAYSIZE(CardTitles::CustomTitles); ++i)
{
CardTitles::CustomTitles[i].clear();
}
}
} }

View File

@ -60,7 +60,6 @@ namespace Components
static void ParseCustomTitles(const char * msg); static void ParseCustomTitles(const char * msg);
CardTitles(); CardTitles();
~CardTitles();
private: private:
static CClient * GetClientByIndex(std::uint32_t index); static CClient * GetClientByIndex(std::uint32_t index);

View File

@ -60,12 +60,4 @@ namespace Components
Scheduler::OnFrameAsync(AntiCheat::QuickCodeScanner1); Scheduler::OnFrameAsync(AntiCheat::QuickCodeScanner1);
#endif #endif
} }
Changelog::~Changelog()
{
{
std::lock_guard<std::mutex> _(Changelog::Mutex);
Changelog::Lines.clear();
}
}
} }

View File

@ -6,7 +6,6 @@ namespace Components
{ {
public: public:
Changelog(); Changelog();
~Changelog();
static void LoadChangelog(); static void LoadChangelog();

View File

@ -263,7 +263,7 @@ namespace Components
} }
const auto* cmd = params->get(0); const auto* cmd = params->get(0);
if (params->length() < 2) if (params->size() < 2)
{ {
Logger::Print("Usage: %s <client number> : prevent the player from using the chat\n", cmd); Logger::Print("Usage: %s <client number> : prevent the player from using the chat\n", cmd);
return; return;
@ -285,7 +285,7 @@ namespace Components
} }
const auto* cmd = params->get(0); const auto* cmd = params->get(0);
if (params->length() < 2) if (params->size() < 2)
{ {
Logger::Print("Usage: %s <client number or guid>\n%s all = unmute everyone\n", cmd, cmd); Logger::Print("Usage: %s <client number or guid>\n%s all = unmute everyone\n", cmd, cmd);
return; return;
@ -299,7 +299,7 @@ namespace Components
return; return;
} }
if (params->get(1) == "all"s) if (std::strcmp(params->get(1), "all") == 0)
{ {
Logger::Print("All players were unmuted\n"); Logger::Print("All players were unmuted\n");
Chat::UnmuteInternal(0, true); Chat::UnmuteInternal(0, true);
@ -316,7 +316,7 @@ namespace Components
{ {
Dvar::OnInit([] Dvar::OnInit([]
{ {
cg_chatWidth = Dvar::Register<int>("cg_chatWidth", 52, 1, std::numeric_limits<int>::max(), Game::DVAR_FLAG_SAVED, "The normalized maximum width of a chat message"); cg_chatWidth = Dvar::Register<int>("cg_chatWidth", 52, 1, std::numeric_limits<int>::max(), Game::DVAR_ARCHIVE, "The normalized maximum width of a chat message");
Chat::AddChatCommands(); Chat::AddChatCommands();
}); });
@ -328,9 +328,4 @@ namespace Components
// Change logic that does word splitting with new lines for chat messages to support fonticons // Change logic that does word splitting with new lines for chat messages to support fonticons
Utils::Hook(0x592E10, CG_AddToTeamChat_Stub, HOOK_JUMP).install()->quick(); Utils::Hook(0x592E10, CG_AddToTeamChat_Stub, HOOK_JUMP).install()->quick();
} }
Chat::~Chat()
{
Chat::MuteList.clear();
}
} }

View File

@ -7,7 +7,6 @@ namespace Components
static constexpr auto FONT_ICON_CHAT_WIDTH_CALCULATION_MULTIPLIER = 2.0f; static constexpr auto FONT_ICON_CHAT_WIDTH_CALCULATION_MULTIPLIER = 2.0f;
public: public:
Chat(); Chat();
~Chat();
private: private:
static Game::dvar_t** cg_chatHeight; static Game::dvar_t** cg_chatHeight;

View File

@ -75,7 +75,7 @@ namespace Components
// Create clantag dvar // Create clantag dvar
Dvar::OnInit([]() Dvar::OnInit([]()
{ {
Dvar::Register<const char*>("clantag", "", Game::dvar_flag::DVAR_FLAG_USERINFO | Game::dvar_flag::DVAR_FLAG_SAVED, "If set, your clantag will be shown on the scoreboard."); Dvar::Register<const char*>("clantag", "", Game::dvar_flag::DVAR_USERINFO | Game::dvar_flag::DVAR_ARCHIVE, "If set, your clantag will be shown on the scoreboard.");
}); });
// Servercommand hook // Servercommand hook
@ -83,7 +83,7 @@ namespace Components
{ {
if (params->get(1) == "clantags"s && !Dedicated::IsEnabled()) if (params->get(1) == "clantags"s && !Dedicated::IsEnabled())
{ {
if (params->length() == 3) if (params->size() == 3)
{ {
ClanTags::ParseClantags(params->get(2)); ClanTags::ParseClantags(params->get(2));
return true; return true;
@ -93,20 +93,7 @@ namespace Components
return false; return false;
}); });
for (int i = 0; i < ARRAYSIZE(ClanTags::Tags); ++i)
{
ClanTags::Tags[i].clear();
}
// Draw clantag before playername // Draw clantag before playername
Utils::Hook(0x591242, ClanTags::DrawPlayerNameOnScoreboard).install()->quick(); Utils::Hook(0x591242, ClanTags::DrawPlayerNameOnScoreboard).install()->quick();
} }
ClanTags::~ClanTags()
{
for (int i = 0; i < ARRAYSIZE(ClanTags::Tags); ++i)
{
ClanTags::Tags[i].clear();
}
}
} }

View File

@ -10,7 +10,6 @@ namespace Components
static const char* GetUserClantag(std::uint32_t clientnum, const char * playername); static const char* GetUserClantag(std::uint32_t clientnum, const char * playername);
ClanTags(); ClanTags();
~ClanTags();
private: private:
static std::string Tags[18]; static std::string Tags[18];

View File

@ -147,7 +147,7 @@ namespace Components
Command::ServerParams params = {}; Command::ServerParams params = {};
Game::vec3_t origin, angles{0.f, 0.f, 0.f}; Game::vec3_t origin, angles{0.f, 0.f, 0.f};
if (params.length() < 4u || params.length() > 6u) if (params.size() < 4 || params.size() > 6)
{ {
Game::SV_GameSendServerCommand(ent->s.number, 0, Game::SV_GameSendServerCommand(ent->s.number, 0,
Utils::String::VA("%c \"GAME_USAGE\x15: setviewpos x y z [yaw] [pitch]\n\"", 0x65)); Utils::String::VA("%c \"GAME_USAGE\x15: setviewpos x y z [yaw] [pitch]\n\"", 0x65));
@ -159,12 +159,12 @@ namespace Components
origin[i] = std::strtof(params.get(i + 1), nullptr); origin[i] = std::strtof(params.get(i + 1), nullptr);
} }
if (params.length() >= 5u) if (params.size() >= 5)
{ {
angles[1] = std::strtof(params.get(4), nullptr); // Yaw angles[1] = std::strtof(params.get(4), nullptr); // Yaw
} }
if (params.length() == 6u) if (params.size() == 6)
{ {
angles[0] = std::strtof(params.get(5), nullptr); // Pitch angles[0] = std::strtof(params.get(5), nullptr); // Pitch
} }
@ -309,9 +309,4 @@ namespace Components
ClientCommand::AddCheatCommands(); ClientCommand::AddCheatCommands();
ClientCommand::AddScriptFunctions(); ClientCommand::AddScriptFunctions();
} }
ClientCommand::~ClientCommand()
{
ClientCommand::FunctionMap.clear();
}
} }

View File

@ -8,7 +8,7 @@ namespace Components
typedef void(Callback)(Game::gentity_s* entity); typedef void(Callback)(Game::gentity_s* entity);
ClientCommand(); ClientCommand();
~ClientCommand();
static void Add(const char* name, Utils::Slot<Callback> callback); static void Add(const char* name, Utils::Slot<Callback> callback);
static bool CheatsOk(const Game::gentity_s* ent); static bool CheatsOk(const Game::gentity_s* ent);

View File

@ -5,56 +5,71 @@ namespace Components
std::unordered_map<std::string, Utils::Slot<Command::Callback>> Command::FunctionMap; std::unordered_map<std::string, Utils::Slot<Command::Callback>> Command::FunctionMap;
std::unordered_map<std::string, Utils::Slot<Command::Callback>> Command::FunctionMapSV; std::unordered_map<std::string, Utils::Slot<Command::Callback>> Command::FunctionMapSV;
std::string Command::Params::join(size_t startIndex) std::string Command::Params::join(const int index)
{ {
std::string result; std::string result;
for (size_t i = startIndex; i < this->length(); ++i) for (auto i = index; i < this->size(); i++)
{ {
if (i > startIndex) result.append(" "); if (i > index) result.append(" ");
result.append(this->operator[](i)); result.append(this->get(i));
} }
return result; return result;
} }
const char* Command::Params::operator[](size_t index) Command::ClientParams::ClientParams()
: nesting_(Game::cmd_args->nesting)
{ {
return this->get(index); assert(Game::cmd_args->nesting < Game::CMD_MAX_NESTING);
} }
const char* Command::ClientParams::get(size_t index) int Command::ClientParams::size()
{ {
if (index >= this->length()) return ""; return Game::cmd_args->argc[this->nesting_];
return Game::cmd_argv[this->commandId][index];
} }
size_t Command::ClientParams::length() const char* Command::ClientParams::get(const int index)
{ {
return Game::cmd_argc[this->commandId]; if (index >= this->size())
{
return "";
}
return Game::cmd_args->argv[this->nesting_][index];
} }
const char* Command::ServerParams::get(size_t index) Command::ServerParams::ServerParams()
: nesting_(Game::sv_cmd_args->nesting)
{ {
if (index >= this->length()) return ""; assert(Game::sv_cmd_args->nesting < Game::CMD_MAX_NESTING);
return Game::cmd_argv_sv[this->commandId][index];
} }
size_t Command::ServerParams::length() int Command::ServerParams::size()
{ {
return Game::cmd_argc_sv[this->commandId]; return Game::sv_cmd_args->argc[this->nesting_];
}
const char* Command::ServerParams::get(const int index)
{
if (index >= this->size())
{
return "";
}
return Game::sv_cmd_args->argv[this->nesting_][index];
} }
void Command::Add(const char* name, Utils::Slot<Command::Callback> callback) void Command::Add(const char* name, Utils::Slot<Command::Callback> callback)
{ {
std::string command = Utils::String::ToLower(name); const auto command = Utils::String::ToLower(name);
if (Command::FunctionMap.find(command) == Command::FunctionMap.end()) if (Command::FunctionMap.find(command) == Command::FunctionMap.end())
{ {
Command::AddRaw(name, Command::MainCallback); Command::AddRaw(name, Command::MainCallback);
} }
Command::FunctionMap[command] = callback; Command::FunctionMap[command] = std::move(callback);
} }
void Command::AddSV(const char* name, Utils::Slot<Command::Callback> callback) void Command::AddSV(const char* name, Utils::Slot<Command::Callback> callback)
@ -70,7 +85,7 @@ namespace Components
return; return;
} }
std::string command = Utils::String::ToLower(name); const auto command = Utils::String::ToLower(name);
if (Command::FunctionMapSV.find(command) == Command::FunctionMapSV.end()) if (Command::FunctionMapSV.find(command) == Command::FunctionMapSV.end())
{ {
@ -80,7 +95,7 @@ namespace Components
Command::AddRaw(name, Game::Cbuf_AddServerText); Command::AddRaw(name, Game::Cbuf_AddServerText);
} }
Command::FunctionMapSV[command] = callback; FunctionMapSV[command] = std::move(callback);
} }
void Command::AddRaw(const char* name, void(*callback)(), bool key) void Command::AddRaw(const char* name, void(*callback)(), bool key)
@ -134,25 +149,27 @@ namespace Components
void Command::MainCallback() void Command::MainCallback()
{ {
Command::ClientParams params(*Game::cmd_id); Command::ClientParams params;
std::string command = Utils::String::ToLower(params[0]); const auto command = Utils::String::ToLower(params[0]);
const auto got = Command::FunctionMap.find(command);
if (Command::FunctionMap.find(command) != Command::FunctionMap.end()) if (got != Command::FunctionMap.end())
{ {
Command::FunctionMap[command](&params); got->second(&params);
} }
} }
void Command::MainCallbackSV() void Command::MainCallbackSV()
{ {
Command::ServerParams params(*Game::cmd_id_sv); Command::ServerParams params;
std::string command = Utils::String::ToLower(params[0]); const auto command = Utils::String::ToLower(params[0]);
const auto got = Command::FunctionMapSV.find(command);
if (Command::FunctionMapSV.find(command) != Command::FunctionMapSV.end()) if (got != Command::FunctionMapSV.end())
{ {
Command::FunctionMapSV[command](&params); got->second(&params);
} }
} }
@ -162,16 +179,10 @@ namespace Components
Command::Add("openLink", [](Command::Params* params) Command::Add("openLink", [](Command::Params* params)
{ {
if (params->length() > 1) if (params->size() > 1)
{ {
Utils::OpenUrl(params->get(1)); Utils::OpenUrl(params->get(1));
} }
}); });
} }
Command::~Command()
{
Command::FunctionMap.clear();
Command::FunctionMapSV.clear();
}
} }

View File

@ -9,46 +9,44 @@ namespace Components
{ {
public: public:
Params() {}; Params() {};
virtual ~Params() {};
virtual const char* get(size_t index) = 0;
virtual size_t length() = 0;
virtual std::string join(size_t startIndex); virtual int size() = 0;
virtual const char* operator[](size_t index); virtual const char* get(int index) = 0;
virtual std::string join(int index);
virtual const char* operator[](const int index)
{
return this->get(index);
}
}; };
class ClientParams : public Params class ClientParams : public Params
{ {
public: public:
ClientParams(unsigned int id) : commandId(id) {}; ClientParams();
ClientParams(const ClientParams &obj) : commandId(obj.commandId) {};
ClientParams() : ClientParams(*Game::cmd_id) {};
const char* get(size_t index) override; int size() override;
size_t length() override; const char* get(int index) override;
private: private:
unsigned int commandId; int nesting_;
}; };
class ServerParams : public Params class ServerParams : public Params
{ {
public: public:
ServerParams(unsigned int id) : commandId(id) {}; ServerParams();
ServerParams(const ServerParams &obj) : commandId(obj.commandId) {};
ServerParams() : ServerParams(*Game::cmd_id_sv) {};
const char* get(size_t index) override; int size() override;
size_t length() override; const char* get(int index) override;
private: private:
unsigned int commandId; int nesting_;
}; };
typedef void(Callback)(Command::Params* params); typedef void(Callback)(Command::Params* params);
Command(); Command();
~Command();
static Game::cmd_function_t* Allocate(); static Game::cmd_function_t* Allocate();

View File

@ -504,7 +504,8 @@ namespace Components
Console::ConsoleThread = std::thread(Console::ConsoleRunner); Console::ConsoleThread = std::thread(Console::ConsoleRunner);
} }
Game::dvar_t* Console::RegisterConColor(const char* name, float r, float g, float b, float a, float min, float max, int flags, const char* description) Game::dvar_t* Console::RegisterConColor(const char* dvarName, float r, float g, float b, float a, float min,
float max, unsigned __int16 flags, const char* description)
{ {
static struct static struct
{ {
@ -521,7 +522,7 @@ namespace Components
for (int i = 0; i < ARRAYSIZE(patchedColors); ++i) for (int i = 0; i < ARRAYSIZE(patchedColors); ++i)
{ {
if (std::string(name) == patchedColors[i].name) if (std::strcmp(dvarName, patchedColors[i].name) == 0)
{ {
r = patchedColors[i].color[0]; r = patchedColors[i].color[0];
g = patchedColors[i].color[1]; g = patchedColors[i].color[1];
@ -531,7 +532,7 @@ namespace Components
} }
} }
return reinterpret_cast<Game::Dvar_RegisterVec4_t>(0x471500)(name, r, g, b, a, min, max, flags, description); return reinterpret_cast<Game::Dvar_RegisterVec4_t>(0x471500)(dvarName, r, g, b, a, min, max, flags, description);
} }
Console::Console() Console::Console()

View File

@ -66,6 +66,6 @@ namespace Components
static void ToggleConsole(); static void ToggleConsole();
static char** GetAutoCompleteFileList(const char *path, const char *extension, Game::FsListBehavior_e behavior, int *numfiles, int allocTrackType); static char** GetAutoCompleteFileList(const char *path, const char *extension, Game::FsListBehavior_e behavior, int *numfiles, int allocTrackType);
static Game::dvar_t* RegisterConColor(const char* name, float r, float g, float b, float a, float min, float max, int flags, const char* description); static Game::dvar_t* RegisterConColor(const char* dvarName, float r, float g, float b, float a, float min, float max, unsigned __int16 flags, const char* description);
}; };
} }

View File

@ -748,7 +748,7 @@ namespace Components
{ {
if (Dedicated::IsEnabled()) return; if (Dedicated::IsEnabled()) return;
Dvar::Register<bool>("r_useD3D9Ex", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Use extended d3d9 interface!"); Dvar::Register<bool>("r_useD3D9Ex", false, Game::dvar_flag::DVAR_ARCHIVE, "Use extended d3d9 interface!");
// Hook Interface creation // Hook Interface creation
Utils::Hook::Set(0x6D74D0, D3D9Ex::Direct3DCreate9Stub); Utils::Hook::Set(0x6D74D0, D3D9Ex::Direct3DCreate9Stub);

View File

@ -275,22 +275,22 @@ namespace Components
Game::dvar_t* Dedicated::Dvar_RegisterSVNetworkFps(const char* dvarName, int, int min, int, int, const char* description) Game::dvar_t* Dedicated::Dvar_RegisterSVNetworkFps(const char* dvarName, int, int min, int, int, const char* description)
{ {
return Game::Dvar_RegisterInt(dvarName, 1000, min, 1000, Game::dvar_flag::DVAR_FLAG_NONE, description); return Game::Dvar_RegisterInt(dvarName, 1000, min, 1000, Game::dvar_flag::DVAR_NONE, description);
} }
Dedicated::Dedicated() Dedicated::Dedicated()
{ {
// Map rotation // Map rotation
Utils::Hook::Set(0x4152E8, Dedicated::MapRotate); Utils::Hook::Set(0x4152E8, Dedicated::MapRotate);
Dvar::Register<bool>("sv_dontrotate", false, Game::dvar_flag::DVAR_FLAG_CHEAT, ""); Dvar::Register<bool>("sv_dontrotate", false, Game::dvar_flag::DVAR_CHEAT, "");
Dvar::Register<bool>("com_logFilter", true, Game::dvar_flag::DVAR_FLAG_LATCHED, "Removes ~95% of unneeded lines from the log"); Dvar::Register<bool>("com_logFilter", true, Game::dvar_flag::DVAR_LATCH, "Removes ~95% of unneeded lines from the log");
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled()) if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled())
{ {
// Make sure all callbacks are handled // Make sure all callbacks are handled
Scheduler::OnFrame(Steam::SteamAPI_RunCallbacks); Scheduler::OnFrame(Steam::SteamAPI_RunCallbacks);
Dvar::Register<bool>("sv_lanOnly", false, Game::dvar_flag::DVAR_FLAG_NONE, "Don't act as node"); Dvar::Register<bool>("sv_lanOnly", false, Game::dvar_flag::DVAR_NONE, "Don't act as node");
Utils::Hook(0x60BE98, Dedicated::InitDedicatedServer, HOOK_CALL).install()->quick(); Utils::Hook(0x60BE98, Dedicated::InitDedicatedServer, HOOK_CALL).install()->quick();
@ -391,14 +391,14 @@ namespace Components
Dvar::OnInit([]() Dvar::OnInit([]()
{ {
Dedicated::SVRandomMapRotation = Dvar::Register<bool>("sv_randomMapRotation", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Randomize map rotation when true"); Dedicated::SVRandomMapRotation = Dvar::Register<bool>("sv_randomMapRotation", false, Game::dvar_flag::DVAR_ARCHIVE, "Randomize map rotation when true");
Dvar::Register<const char*>("sv_sayName", "^7Console", Game::dvar_flag::DVAR_FLAG_NONE, "The name to pose as for 'say' commands"); Dvar::Register<const char*>("sv_sayName", "^7Console", Game::dvar_flag::DVAR_NONE, "The name to pose as for 'say' commands");
Dvar::Register<const char*>("sv_motd", "", Game::dvar_flag::DVAR_FLAG_NONE, "A custom message of the day for servers"); Dvar::Register<const char*>("sv_motd", "", Game::dvar_flag::DVAR_NONE, "A custom message of the day for servers");
// Say command // Say command
Command::AddSV("say", [](Command::Params* params) Command::AddSV("say", [](Command::Params* params)
{ {
if (params->length() < 2) return; if (params->size() < 2) return;
std::string message = params->join(1); std::string message = params->join(1);
std::string name = Dvar::Var("sv_sayName").get<std::string>(); std::string name = Dvar::Var("sv_sayName").get<std::string>();
@ -418,7 +418,7 @@ namespace Components
// Tell command // Tell command
Command::AddSV("tell", [](Command::Params* params) Command::AddSV("tell", [](Command::Params* params)
{ {
if (params->length() < 3) return; if (params->size() < 3) return;
int client = atoi(params->get(1)); int client = atoi(params->get(1));
std::string message = params->join(2); std::string message = params->join(2);
@ -439,7 +439,7 @@ namespace Components
// Sayraw command // Sayraw command
Command::AddSV("sayraw", [](Command::Params* params) Command::AddSV("sayraw", [](Command::Params* params)
{ {
if (params->length() < 2) return; if (params->size() < 2) return;
std::string message = params->join(1); std::string message = params->join(1);
Game::SV_GameSendServerCommand(-1, 0, Utils::String::VA("%c \"%s\"", 104, message.data())); Game::SV_GameSendServerCommand(-1, 0, Utils::String::VA("%c \"%s\"", 104, message.data()));
@ -449,33 +449,13 @@ namespace Components
// Tellraw command // Tellraw command
Command::AddSV("tellraw", [](Command::Params* params) Command::AddSV("tellraw", [](Command::Params* params)
{ {
if (params->length() < 3) return; if (params->size() < 3) return;
int client = atoi(params->get(1)); int client = atoi(params->get(1));
std::string message = params->join(2); std::string message = params->join(2);
Game::SV_GameSendServerCommand(client, 0, Utils::String::VA("%c \"%s\"", 104, message.data())); Game::SV_GameSendServerCommand(client, 0, Utils::String::VA("%c \"%s\"", 104, message.data()));
Game::Com_Printf(15, "Raw -> %i: %s\n", client, message.data()); Game::Com_Printf(15, "Raw -> %i: %s\n", client, message.data());
}); });
// ! command
Command::AddSV("!", [](Command::Params* params)
{
if (params->length() != 2) return;
int client = -1;
if (params->get(1) != "all"s)
{
client = atoi(params->get(1));
if (client >= *reinterpret_cast<int*>(0x31D938C))
{
Game::Com_Printf(0, "Invalid player.\n");
return;
}
}
Game::SV_GameSendServerCommand(client, 0, Utils::String::VA("%c \"\"", 106));
});
}); });
} }
} }
@ -519,9 +499,4 @@ namespace Components
} }
}); });
} }
Dedicated::~Dedicated()
{
}
} }

View File

@ -6,7 +6,6 @@ namespace Components
{ {
public: public:
Dedicated(); Dedicated();
~Dedicated();
static SteamID PlayerGuids[18][2]; static SteamID PlayerGuids[18][2];

View File

@ -14,8 +14,8 @@ namespace Components
Discovery::Discovery() Discovery::Discovery()
{ {
Dvar::Register<int>("net_discoveryPortRangeMin", 25000, 0, 65535, Game::dvar_flag::DVAR_FLAG_SAVED, "Minimum scan range port for local server discovery"); Dvar::Register<int>("net_discoveryPortRangeMin", 25000, 0, 65535, Game::dvar_flag::DVAR_ARCHIVE, "Minimum scan range port for local server discovery");
Dvar::Register<int>("net_discoveryPortRangeMax", 35000, 1, 65536, Game::dvar_flag::DVAR_FLAG_SAVED, "Maximum scan range port for local server discovery"); Dvar::Register<int>("net_discoveryPortRangeMax", 35000, 1, 65536, Game::dvar_flag::DVAR_ARCHIVE, "Maximum scan range port for local server discovery");
// An additional thread prevents lags // An additional thread prevents lags
// Not sure if that's the best way though // Not sure if that's the best way though
@ -95,11 +95,6 @@ namespace Components
#endif #endif
} }
Discovery::~Discovery()
{
}
void Discovery::preDestroy() void Discovery::preDestroy()
{ {
Discovery::IsPerforming = false; Discovery::IsPerforming = false;

View File

@ -6,7 +6,6 @@ namespace Components
{ {
public: public:
Discovery(); Discovery();
~Discovery();
void preDestroy() override; void preDestroy() override;

View File

@ -902,9 +902,9 @@ namespace Components
{ {
Dvar::OnInit([]() Dvar::OnInit([]()
{ {
Dvar::Register<const char*>("ui_dl_timeLeft", "", Game::dvar_flag::DVAR_FLAG_NONE, ""); Dvar::Register<const char*>("ui_dl_timeLeft", "", Game::dvar_flag::DVAR_NONE, "");
Dvar::Register<const char*>("ui_dl_progress", "", Game::dvar_flag::DVAR_FLAG_NONE, ""); Dvar::Register<const char*>("ui_dl_progress", "", Game::dvar_flag::DVAR_NONE, "");
Dvar::Register<const char*>("ui_dl_transRate", "", Game::dvar_flag::DVAR_FLAG_NONE, ""); Dvar::Register<const char*>("ui_dl_transRate", "", Game::dvar_flag::DVAR_NONE, "");
}); });
UIScript::Add("mod_download_cancel", [](UIScript::Token) UIScript::Add("mod_download_cancel", [](UIScript::Token)
@ -915,13 +915,13 @@ namespace Components
Dvar::OnInit([]() Dvar::OnInit([]()
{ {
Dvar::Register<bool>("sv_wwwDownload", false, Game::dvar_flag::DVAR_FLAG_DEDISAVED, "Set to true to enable downloading maps/mods from an external server."); Dvar::Register<bool>("sv_wwwDownload", false, Game::dvar_flag::DVAR_ARCHIVE, "Set to true to enable downloading maps/mods from an external server.");
Dvar::Register<const char*>("sv_wwwBaseUrl", "", Game::dvar_flag::DVAR_FLAG_DEDISAVED, "Set to the base url for the external map download."); Dvar::Register<const char*>("sv_wwwBaseUrl", "", Game::dvar_flag::DVAR_ARCHIVE, "Set to the base url for the external map download.");
// Force users to enable this because we don't want to accidentally turn everyone's pc into a http server into all their files again // Force users to enable this because we don't want to accidentally turn everyone's pc into a http server into all their files again
// not saying we are but ya know... accidents happen // not saying we are but ya know... accidents happen
// by having it saved we force the user to enable it in config_mp because it only checks the dvar on startup to see if we should init download or not // by having it saved we force the user to enable it in config_mp because it only checks the dvar on startup to see if we should init download or not
Dvar::Register<bool>("mod_force_download_server", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Set to true to force the client to run the download server for mods (for mods in private matches)."); Dvar::Register<bool>("mod_force_download_server", false, Game::dvar_flag::DVAR_ARCHIVE, "Set to true to force the client to run the download server for mods (for mods in private matches).");
}); });
Scheduler::OnFrame([]() Scheduler::OnFrame([]()

View File

@ -181,24 +181,24 @@ namespace Components
} }
} }
template<> static Dvar::Var Dvar::Register(const char* name, bool value, Dvar::Flag flag, const char* description) template<> Dvar::Var Dvar::Register(const char* dvarName, bool value, Dvar::Flag flag, const char* description)
{ {
return Game::Dvar_RegisterBool(name, value, flag.val, description); return Game::Dvar_RegisterBool(dvarName, value, flag.val, description);
} }
template<> static Dvar::Var Dvar::Register(const char* name, const char* value, Dvar::Flag flag, const char* description) template<> Dvar::Var Dvar::Register(const char* dvarName, const char* value, Dvar::Flag flag, const char* description)
{ {
return Game::Dvar_RegisterString(name, value, flag.val, description); return Game::Dvar_RegisterString(dvarName, value, flag.val, description);
} }
template<> static Dvar::Var Dvar::Register(const char* name, int value, int min, int max, Dvar::Flag flag, const char* description) template<> Dvar::Var Dvar::Register(const char* dvarName, int value, int min, int max, Dvar::Flag flag, const char* description)
{ {
return Game::Dvar_RegisterInt(name, value, min, max, flag.val, description); return Game::Dvar_RegisterInt(dvarName, value, min, max, flag.val, description);
} }
template<> static Dvar::Var Dvar::Register(const char* name, float value, float min, float max, Dvar::Flag flag, const char* description) template<> Dvar::Var Dvar::Register(const char* dvarName, float value, float min, float max, Dvar::Flag flag, const char* description)
{ {
return Game::Dvar_RegisterFloat(name, value, min, max, flag.val, description); return Game::Dvar_RegisterFloat(dvarName, value, min, max, flag.val, description);
} }
void Dvar::OnInit(Utils::Slot<Scheduler::Callback> callback) void Dvar::OnInit(Utils::Slot<Scheduler::Callback> callback)
@ -255,7 +255,7 @@ namespace Components
} }
} }
return Dvar::Register<const char*>(name, username.data(), Dvar::Flag(flag | Game::dvar_flag::DVAR_FLAG_SAVED).val, description).get<Game::dvar_t*>(); return Dvar::Register<const char*>(name, username.data(), Dvar::Flag(flag | Game::dvar_flag::DVAR_ARCHIVE).val, description).get<Game::dvar_t*>();
} }
void Dvar::SetFromStringByNameSafeExternal(const char* dvarName, const char* string) void Dvar::SetFromStringByNameSafeExternal(const char* dvarName, const char* string)
@ -305,7 +305,7 @@ namespace Components
{ {
// Save the dvar original value if it has the archive flag // Save the dvar original value if it has the archive flag
const auto* dvar = Game::Dvar_FindVar(dvarName); const auto* dvar = Game::Dvar_FindVar(dvarName);
if (dvar != nullptr && dvar->flags & Game::dvar_flag::DVAR_FLAG_SAVED) if (dvar != nullptr && dvar->flags & Game::dvar_flag::DVAR_ARCHIVE)
{ {
Dvar::SaveArchiveDvar(dvar); Dvar::SaveArchiveDvar(dvar);
} }
@ -316,49 +316,49 @@ namespace Components
Dvar::Dvar() Dvar::Dvar()
{ {
// set flags of cg_drawFPS to archive // set flags of cg_drawFPS to archive
Utils::Hook::Or<BYTE>(0x4F8F69, Game::dvar_flag::DVAR_FLAG_SAVED); Utils::Hook::Or<BYTE>(0x4F8F69, Game::dvar_flag::DVAR_ARCHIVE);
// un-cheat camera_thirdPersonCrosshairOffset and add archive flags // un-cheat camera_thirdPersonCrosshairOffset and add archive flags
Utils::Hook::Xor<BYTE>(0x447B41, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); Utils::Hook::Xor<BYTE>(0x447B41, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE);
// un-cheat cg_fov and add archive flags // un-cheat cg_fov and add archive flags
Utils::Hook::Xor<BYTE>(0x4F8E35, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); Utils::Hook::Xor<BYTE>(0x4F8E35, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE);
// un-cheat cg_fovscale and add archive flags // un-cheat cg_fovscale and add archive flags
Utils::Hook::Xor<BYTE>(0x4F8E68, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); Utils::Hook::Xor<BYTE>(0x4F8E68, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE);
// un-cheat cg_debugInfoCornerOffset and add archive flags // un-cheat cg_debugInfoCornerOffset and add archive flags
Utils::Hook::Xor<BYTE>(0x4F8FC2, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); Utils::Hook::Xor<BYTE>(0x4F8FC2, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE);
// remove archive flags for cg_hudchatposition // remove archive flags for cg_hudchatposition
Utils::Hook::Xor<BYTE>(0x4F9992, Game::dvar_flag::DVAR_FLAG_SAVED); Utils::Hook::Xor<BYTE>(0x4F9992, Game::dvar_flag::DVAR_ARCHIVE);
// remove write protection from fs_game // remove write protection from fs_game
Utils::Hook::Xor<DWORD>(0x6431EA, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED); Utils::Hook::Xor<DWORD>(0x6431EA, Game::dvar_flag::DVAR_WRITEPROTECTED);
// set cg_fov max to 90.0 // set cg_fov max to 160.0
// ...120 because of V2 // because that's the max on SP
static float cgFov90 = 120.0f; static float cg_Fov = 160.0f;
Utils::Hook::Set<float*>(0x4F8E28, &cgFov90); Utils::Hook::Set<float*>(0x4F8E28, &cg_Fov);
// set max volume to 1 // set max volume to 1
static float volume = 1.0f; static float volume = 1.0f;
Utils::Hook::Set<float*>(0x408078, &volume); Utils::Hook::Set<float*>(0x408078, &volume);
// Uncheat ui_showList // Uncheat ui_showList
Utils::Hook::Xor<BYTE>(0x6310DC, Game::dvar_flag::DVAR_FLAG_CHEAT); Utils::Hook::Xor<BYTE>(0x6310DC, Game::dvar_flag::DVAR_CHEAT);
// Uncheat ui_debugMode // Uncheat ui_debugMode
Utils::Hook::Xor<BYTE>(0x6312DE, Game::dvar_flag::DVAR_FLAG_CHEAT); Utils::Hook::Xor<BYTE>(0x6312DE, Game::dvar_flag::DVAR_CHEAT);
// Hook dvar 'name' registration // Hook dvar 'name' registration
Utils::Hook(0x40531C, Dvar::RegisterName, HOOK_CALL).install()->quick(); Utils::Hook(0x40531C, Dvar::RegisterName, HOOK_CALL).install()->quick();
// un-cheat safeArea_* and add archive flags // un-cheat safeArea_* and add archive flags
Utils::Hook::Xor<INT>(0x42E3F5, Game::dvar_flag::DVAR_FLAG_READONLY | Game::dvar_flag::DVAR_FLAG_SAVED); //safeArea_adjusted_horizontal Utils::Hook::Xor<INT>(0x42E3F5, Game::dvar_flag::DVAR_READONLY | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_adjusted_horizontal
Utils::Hook::Xor<INT>(0x42E423, Game::dvar_flag::DVAR_FLAG_READONLY | Game::dvar_flag::DVAR_FLAG_SAVED); //safeArea_adjusted_vertical Utils::Hook::Xor<INT>(0x42E423, Game::dvar_flag::DVAR_READONLY | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_adjusted_vertical
Utils::Hook::Xor<BYTE>(0x42E398, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); //safeArea_horizontal Utils::Hook::Xor<BYTE>(0x42E398, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_horizontal
Utils::Hook::Xor<BYTE>(0x42E3C4, Game::dvar_flag::DVAR_FLAG_CHEAT | Game::dvar_flag::DVAR_FLAG_SAVED); //safeArea_vertical Utils::Hook::Xor<BYTE>(0x42E3C4, Game::dvar_flag::DVAR_CHEAT | Game::dvar_flag::DVAR_ARCHIVE); //safeArea_vertical
// Don't allow setting cheat protected dvars via menus // Don't allow setting cheat protected dvars via menus
Utils::Hook(0x63C897, Dvar::SetFromStringByNameExternal, HOOK_CALL).install()->quick(); Utils::Hook(0x63C897, Dvar::SetFromStringByNameExternal, HOOK_CALL).install()->quick();
@ -385,7 +385,6 @@ namespace Components
Utils::Hook(0x59386A, Dvar::DvarSetFromStringByNameStub, HOOK_CALL).install()->quick(); Utils::Hook(0x59386A, Dvar::DvarSetFromStringByNameStub, HOOK_CALL).install()->quick();
// If the game closed abruptly, the dvars would not have been restored // If the game closed abruptly, the dvars would not have been restored
Dvar::OnInit([] Dvar::OnInit([]
{ {
Dvar::ResetDvarsValue(); Dvar::ResetDvarsValue();

View File

@ -9,7 +9,7 @@ namespace Components
{ {
public: public:
Flag(Game::dvar_flag flag) : val(flag) {}; Flag(Game::dvar_flag flag) : val(flag) {};
Flag(int flag) : Flag(static_cast<Game::dvar_flag>(flag)) {}; Flag(unsigned __int16 flag) : Flag(static_cast<Game::dvar_flag>(flag)) {};
Game::dvar_flag val; Game::dvar_flag val;
}; };
@ -46,8 +46,8 @@ namespace Components
static void OnInit(Utils::Slot<Scheduler::Callback> callback); static void OnInit(Utils::Slot<Scheduler::Callback> callback);
// Only strings and bools use this type of declaration // Only strings and bools use this type of declaration
template<typename T> static Var Register(const char* name, T value, Flag flag, const char* description); template<typename T> static Var Register(const char* dvarName, T value, Flag flag, const char* description);
template<typename T> static Var Register(const char* name, T value, T min, T max, Flag flag, const char* description); template<typename T> static Var Register(const char* dvarName, T value, T min, T max, Flag flag, const char* description);
static void ResetDvarsValue(); static void ResetDvarsValue();

View File

@ -108,7 +108,7 @@ namespace Components
}; };
Elevators::BG_Elevators = Game::Dvar_RegisterEnum("bg_elevators", values, Elevators::BG_Elevators = Game::Dvar_RegisterEnum("bg_elevators", values,
Elevators::ENABLED, Game::DVAR_FLAG_REPLICATED, "Elevators glitch settings"); Elevators::ENABLED, Game::DVAR_CODINFO, "Elevators glitch settings");
}); });
//Replace PM_CorrectAllSolid //Replace PM_CorrectAllSolid
@ -120,8 +120,4 @@ namespace Components
Utils::Hook(0x570E0B, Elevators::PM_Trace_Hk, HOOK_CALL).install()->quick(); Utils::Hook(0x570E0B, Elevators::PM_Trace_Hk, HOOK_CALL).install()->quick();
Utils::Hook(0x570D70, Elevators::PM_Trace_Hk, HOOK_CALL).install()->quick(); Utils::Hook(0x570D70, Elevators::PM_Trace_Hk, HOOK_CALL).install()->quick();
} }
Elevators::~Elevators()
{
}
} }

View File

@ -6,7 +6,6 @@ namespace Components
{ {
public: public:
Elevators(); Elevators();
~Elevators();
private: private:
enum ElevatorSettings { DISABLED, ENABLED, EASY }; enum ElevatorSettings { DISABLED, ENABLED, EASY };

View File

@ -234,7 +234,7 @@ namespace Components
Game::UI_UpdateArenas(); Game::UI_UpdateArenas();
std::string command; std::string command;
for (auto i = 0; i < (params->length() >= 2 ? atoi(params->get(1)) : *Game::arenaCount); ++i) for (auto i = 0; i < (params->size() >= 2 ? atoi(params->get(1)) : *Game::arenaCount); ++i)
{ {
const auto* mapname = ArenaLength::NewArenas[i % *Game::arenaCount].mapName; const auto* mapname = ArenaLength::NewArenas[i % *Game::arenaCount].mapName;

View File

@ -495,7 +495,7 @@ namespace Components
FastFiles::FastFiles() FastFiles::FastFiles()
{ {
Dvar::Register<bool>("ui_zoneDebug", false, Game::dvar_flag::DVAR_FLAG_SAVED, "Display current loaded zone."); Dvar::Register<bool>("ui_zoneDebug", false, Game::dvar_flag::DVAR_ARCHIVE, "Display current loaded zone.");
// Fix XSurface assets // Fix XSurface assets
Utils::Hook(0x0048E8A5, FastFiles::Load_XSurfaceArray, HOOK_CALL).install()->quick(); Utils::Hook(0x0048E8A5, FastFiles::Load_XSurfaceArray, HOOK_CALL).install()->quick();
@ -594,7 +594,7 @@ namespace Components
Command::Add("loadzone", [](Command::Params* params) Command::Add("loadzone", [](Command::Params* params)
{ {
if (params->length() < 2) return; if (params->size() < 2) return;
Game::XZoneInfo info; Game::XZoneInfo info;
info.name = params->get(1); info.name = params->get(1);
@ -622,9 +622,4 @@ namespace Components
}, HOOK_CALL).install()/*->quick()*/; }, HOOK_CALL).install()/*->quick()*/;
#endif #endif
} }
FastFiles::~FastFiles()
{
FastFiles::ZonePaths.clear();
}
} }

View File

@ -6,7 +6,6 @@ namespace Components
{ {
public: public:
FastFiles(); FastFiles();
~FastFiles();
static void AddZonePath(const std::string& path); static void AddZonePath(const std::string& path);
static std::string Current(); static std::string Current();

View File

@ -6,13 +6,7 @@ namespace Components
bool Flags::HasFlag(const std::string& flag) bool Flags::HasFlag(const std::string& flag)
{ {
static auto parsed = false; Flags::ParseFlags();
if (!parsed)
{
Flags::ParseFlags();
parsed = true;
}
for (const auto& entry : Flags::EnabledFlags) for (const auto& entry : Flags::EnabledFlags)
{ {
@ -27,11 +21,17 @@ namespace Components
void Flags::ParseFlags() void Flags::ParseFlags()
{ {
static auto flagsParsed = false;
if (flagsParsed)
{
return;
}
// Only parse flags once
flagsParsed = true;
int numArgs; int numArgs;
auto* const argv = CommandLineToArgvW(GetCommandLineW(), &numArgs); auto* const argv = CommandLineToArgvW(GetCommandLineW(), &numArgs);
assert(Flags::EnabledFlags.empty());
if (argv) if (argv)
{ {
for (auto i = 0; i < numArgs; ++i) for (auto i = 0; i < numArgs; ++i)
@ -40,7 +40,7 @@ namespace Components
if (wFlag[0] == L'-') if (wFlag[0] == L'-')
{ {
wFlag.erase(wFlag.begin()); wFlag.erase(wFlag.begin());
Flags::EnabledFlags.push_back(Utils::String::Convert(wFlag)); Flags::EnabledFlags.emplace_back(Utils::String::Convert(wFlag));
} }
} }
@ -50,11 +50,7 @@ namespace Components
// Workaround for wine // Workaround for wine
if (Utils::IsWineEnvironment() && Dedicated::IsEnabled() && !Flags::HasFlag("console") && !Flags::HasFlag("stdout")) if (Utils::IsWineEnvironment() && Dedicated::IsEnabled() && !Flags::HasFlag("console") && !Flags::HasFlag("stdout"))
{ {
Flags::EnabledFlags.push_back("stdout"); Flags::EnabledFlags.emplace_back("stdout");
} }
} }
Flags::Flags()
{
}
} }

View File

@ -5,7 +5,7 @@ namespace Components
class Flags : public Component class Flags : public Component
{ {
public: public:
Flags(); Flags() = default;
static bool HasFlag(const std::string& flag); static bool HasFlag(const std::string& flag);

View File

@ -578,12 +578,12 @@ namespace Components
if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled() || Monitor::IsEnabled()) return; if (Dedicated::IsEnabled() || ZoneBuilder::IsEnabled() || Monitor::IsEnabled()) return;
Dvar::Register<bool>("cl_anonymous", false, Game::DVAR_FLAG_SAVED, "Enable invisible mode for Steam"); Dvar::Register<bool>("cl_anonymous", false, Game::DVAR_ARCHIVE, "Enable invisible mode for Steam");
Dvar::Register<bool>("cl_notifyFriendState", true, Game::DVAR_FLAG_SAVED, "Update friends about current game status"); Dvar::Register<bool>("cl_notifyFriendState", true, Game::DVAR_ARCHIVE, "Update friends about current game status");
Command::Add("addFriend", [](Command::Params* params) Command::Add("addFriend", [](Command::Params* params)
{ {
if (params->length() < 2u) if (params->size() < 2u)
{ {
Logger::Print("Usage: %s <Steam ID in hexadecimal format>\n", params->get(0)); Logger::Print("Usage: %s <Steam ID in hexadecimal format>\n", params->get(0));
return; return;

View File

@ -1641,7 +1641,7 @@ namespace Components
void Gamepad::Axis_Bind_f(Command::Params* params) void Gamepad::Axis_Bind_f(Command::Params* params)
{ {
if (params->length() < 4) if (params->size() < 4)
{ {
Logger::Print("bindaxis <real axis> <virtual axis> <input type>\n"); Logger::Print("bindaxis <real axis> <virtual axis> <input type>\n");
return; return;
@ -1711,32 +1711,32 @@ namespace Components
void Gamepad::InitDvars() void Gamepad::InitDvars()
{ {
gpad_enabled = Dvar::Register<bool>("gpad_enabled", false, Game::DVAR_FLAG_SAVED, "Game pad enabled"); gpad_enabled = Dvar::Register<bool>("gpad_enabled", false, Game::DVAR_ARCHIVE, "Game pad enabled");
gpad_debug = Dvar::Register<bool>("gpad_debug", false, Game::DVAR_FLAG_NONE, "Game pad debugging"); gpad_debug = Dvar::Register<bool>("gpad_debug", false, Game::DVAR_NONE, "Game pad debugging");
gpad_present = Dvar::Register<bool>("gpad_present", false, Game::DVAR_FLAG_NONE, "Game pad present"); gpad_present = Dvar::Register<bool>("gpad_present", false, Game::DVAR_NONE, "Game pad present");
gpad_in_use = Dvar::Register<bool>("gpad_in_use", false, Game::DVAR_FLAG_NONE, "A game pad is in use"); gpad_in_use = Dvar::Register<bool>("gpad_in_use", false, Game::DVAR_NONE, "A game pad is in use");
gpad_style = Dvar::Register<bool>("gpad_style", false, Game::DVAR_FLAG_SAVED, "Switch between Xbox and PS HUD"); gpad_style = Dvar::Register<bool>("gpad_style", false, Game::DVAR_ARCHIVE, "Switch between Xbox and PS HUD");
gpad_sticksConfig = Dvar::Register<const char*>("gpad_sticksConfig", "", Game::DVAR_FLAG_SAVED, "Game pad stick configuration"); gpad_sticksConfig = Dvar::Register<const char*>("gpad_sticksConfig", "", Game::DVAR_ARCHIVE, "Game pad stick configuration");
gpad_buttonConfig = Dvar::Register<const char*>("gpad_buttonConfig", "", Game::DVAR_FLAG_SAVED, "Game pad button configuration"); gpad_buttonConfig = Dvar::Register<const char*>("gpad_buttonConfig", "", Game::DVAR_ARCHIVE, "Game pad button configuration");
gpad_menu_scroll_delay_first = Dvar::Register<int>("gpad_menu_scroll_delay_first", 420, 0, 1000, Game::DVAR_FLAG_SAVED, "Menu scroll key-repeat delay, for the first repeat, in milliseconds"); gpad_menu_scroll_delay_first = Dvar::Register<int>("gpad_menu_scroll_delay_first", 420, 0, 1000, Game::DVAR_ARCHIVE, "Menu scroll key-repeat delay, for the first repeat, in milliseconds");
gpad_menu_scroll_delay_rest = Dvar::Register<int>("gpad_menu_scroll_delay_rest", 210, 0, 1000, Game::DVAR_FLAG_SAVED, gpad_menu_scroll_delay_rest = Dvar::Register<int>("gpad_menu_scroll_delay_rest", 210, 0, 1000, Game::DVAR_ARCHIVE,
"Menu scroll key-repeat delay, for repeats after the first, in milliseconds"); "Menu scroll key-repeat delay, for repeats after the first, in milliseconds");
gpad_rumble = Dvar::Register<bool>("gpad_rumble", true, Game::DVAR_FLAG_SAVED, "Enable game pad rumble"); gpad_rumble = Dvar::Register<bool>("gpad_rumble", true, Game::DVAR_ARCHIVE, "Enable game pad rumble");
gpad_stick_pressed_hysteresis = Dvar::Register<float>("gpad_stick_pressed_hysteresis", 0.1f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, gpad_stick_pressed_hysteresis = Dvar::Register<float>("gpad_stick_pressed_hysteresis", 0.1f, 0.0f, 1.0f, Game::DVAR_NONE,
"Game pad stick pressed no-change-zone around gpad_stick_pressed to prevent bouncing"); "Game pad stick pressed no-change-zone around gpad_stick_pressed to prevent bouncing");
gpad_stick_pressed = Dvar::Register<float>("gpad_stick_pressed", 0.4f, 0.0, 1.0, Game::DVAR_FLAG_NONE, "Game pad stick pressed threshhold"); gpad_stick_pressed = Dvar::Register<float>("gpad_stick_pressed", 0.4f, 0.0, 1.0, Game::DVAR_NONE, "Game pad stick pressed threshhold");
gpad_stick_deadzone_max = Dvar::Register<float>("gpad_stick_deadzone_max", 0.01f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad maximum stick deadzone"); gpad_stick_deadzone_max = Dvar::Register<float>("gpad_stick_deadzone_max", 0.01f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad maximum stick deadzone");
gpad_stick_deadzone_min = Dvar::Register<float>("gpad_stick_deadzone_min", 0.2f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad minimum stick deadzone"); gpad_stick_deadzone_min = Dvar::Register<float>("gpad_stick_deadzone_min", 0.2f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad minimum stick deadzone");
gpad_button_deadzone = Dvar::Register<float>("gpad_button_deadzone", 0.13f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad button deadzone threshhold"); gpad_button_deadzone = Dvar::Register<float>("gpad_button_deadzone", 0.13f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad button deadzone threshhold");
gpad_button_lstick_deflect_max = Dvar::Register<float>("gpad_button_lstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad maximum pad stick pressed value"); gpad_button_lstick_deflect_max = Dvar::Register<float>("gpad_button_lstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad maximum pad stick pressed value");
gpad_button_rstick_deflect_max = Dvar::Register<float>("gpad_button_rstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_FLAG_NONE, "Game pad maximum pad stick pressed value"); gpad_button_rstick_deflect_max = Dvar::Register<float>("gpad_button_rstick_deflect_max", 1.0f, 0.0f, 1.0f, Game::DVAR_NONE, "Game pad maximum pad stick pressed value");
gpad_use_hold_time = Dvar::Register<int>("gpad_use_hold_time", 250, 0, std::numeric_limits<int>::max(), Game::DVAR_FLAG_NONE, "Time to hold the 'use' button on gamepads to activate use"); gpad_use_hold_time = Dvar::Register<int>("gpad_use_hold_time", 250, 0, std::numeric_limits<int>::max(), Game::DVAR_NONE, "Time to hold the 'use' button on gamepads to activate use");
gpad_lockon_enabled = Dvar::Register<bool>("gpad_lockon_enabled", true, Game::DVAR_FLAG_SAVED, "Game pad lockon aim assist enabled"); gpad_lockon_enabled = Dvar::Register<bool>("gpad_lockon_enabled", true, Game::DVAR_ARCHIVE, "Game pad lockon aim assist enabled");
gpad_slowdown_enabled = Dvar::Register<bool>("gpad_slowdown_enabled", true, Game::DVAR_FLAG_SAVED, "Game pad slowdown aim assist enabled"); gpad_slowdown_enabled = Dvar::Register<bool>("gpad_slowdown_enabled", true, Game::DVAR_ARCHIVE, "Game pad slowdown aim assist enabled");
input_viewSensitivity = Dvar::Register<float>("input_viewSensitivity", 1.0f, 0.0001f, 5.0f, Game::DVAR_FLAG_SAVED, "View Sensitivity"); input_viewSensitivity = Dvar::Register<float>("input_viewSensitivity", 1.0f, 0.0001f, 5.0f, Game::DVAR_ARCHIVE, "View Sensitivity");
input_invertPitch = Dvar::Register<bool>("input_invertPitch", false, Game::DVAR_FLAG_SAVED, "Invert gamepad pitch"); input_invertPitch = Dvar::Register<bool>("input_invertPitch", false, Game::DVAR_ARCHIVE, "Invert gamepad pitch");
sv_allowAimAssist = Dvar::Register<bool>("sv_allowAimAssist", true, Game::DVAR_FLAG_NONE, "Controls whether aim assist features on clients are enabled"); sv_allowAimAssist = Dvar::Register<bool>("sv_allowAimAssist", true, Game::DVAR_NONE, "Controls whether aim assist features on clients are enabled");
aim_turnrate_pitch = Dvar::Var("aim_turnrate_pitch"); aim_turnrate_pitch = Dvar::Var("aim_turnrate_pitch");
aim_turnrate_pitch_ads = Dvar::Var("aim_turnrate_pitch_ads"); aim_turnrate_pitch_ads = Dvar::Var("aim_turnrate_pitch_ads");
aim_turnrate_yaw = Dvar::Var("aim_turnrate_yaw"); aim_turnrate_yaw = Dvar::Var("aim_turnrate_yaw");

View File

@ -277,7 +277,7 @@ namespace Components
// Overwrite SetString // Overwrite SetString
Utils::Hook(0x4CE5EE, Localization::SetStringStub, HOOK_CALL).install()->quick(); Utils::Hook(0x4CE5EE, Localization::SetStringStub, HOOK_CALL).install()->quick();
Localization::UseLocalization = Dvar::Register<bool>("ui_localize", true, Game::dvar_flag::DVAR_FLAG_NONE, "Use localization strings"); Localization::UseLocalization = Dvar::Register<bool>("ui_localize", true, Game::dvar_flag::DVAR_NONE, "Use localization strings");
// Generate localized entries for custom classes above 10 // Generate localized entries for custom classes above 10
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& name, bool* /*restrict*/) AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& name, bool* /*restrict*/)

View File

@ -242,7 +242,7 @@ namespace Components
Logger::Logger() Logger::Logger()
{ {
Dvar::Register<bool>("iw4x_onelog", false, Game::dvar_flag::DVAR_FLAG_LATCHED | Game::dvar_flag::DVAR_FLAG_SAVED, "Only write the game log to the 'userraw' OS folder"); Dvar::Register<bool>("iw4x_onelog", false, Game::dvar_flag::DVAR_LATCH | Game::dvar_flag::DVAR_ARCHIVE, "Only write the game log to the 'userraw' OS folder");
Utils::Hook(0x642139, Logger::BuildOSPathStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x642139, Logger::BuildOSPathStub, HOOK_JUMP).install()->quick();
Logger::PipeOutput(nullptr); Logger::PipeOutput(nullptr);
@ -261,7 +261,7 @@ namespace Components
{ {
Command::AddSV("log_add", [](Command::Params* params) Command::AddSV("log_add", [](Command::Params* params)
{ {
if (params->length() < 2) return; if (params->size() < 2) return;
Network::Address addr(params->get(1)); Network::Address addr(params->get(1));
@ -273,7 +273,7 @@ namespace Components
Command::AddSV("log_del", [](Command::Params* params) Command::AddSV("log_del", [](Command::Params* params)
{ {
if (params->length() < 2) return; if (params->size() < 2) return;
int num = atoi(params->get(1)); int num = atoi(params->get(1));
if (Utils::String::VA("%i", num) == std::string(params->get(1)) && static_cast<unsigned int>(num) < Logger::LoggingAddresses[0].size()) if (Utils::String::VA("%i", num) == std::string(params->get(1)) && static_cast<unsigned int>(num) < Logger::LoggingAddresses[0].size())
@ -312,7 +312,7 @@ namespace Components
Command::AddSV("g_log_add", [](Command::Params* params) Command::AddSV("g_log_add", [](Command::Params* params)
{ {
if (params->length() < 2) return; if (params->size() < 2) return;
Network::Address addr(params->get(1)); Network::Address addr(params->get(1));
@ -324,7 +324,7 @@ namespace Components
Command::AddSV("g_log_del", [](Command::Params* params) Command::AddSV("g_log_del", [](Command::Params* params)
{ {
if (params->length() < 2) return; if (params->size() < 2) return;
int num = atoi(params->get(1)); int num = atoi(params->get(1));
if (Utils::String::VA("%i", num) == std::string(params->get(1)) && static_cast<unsigned int>(num) < Logger::LoggingAddresses[1].size()) if (Utils::String::VA("%i", num) == std::string(params->get(1)) && static_cast<unsigned int>(num) < Logger::LoggingAddresses[1].size())

View File

@ -544,7 +544,7 @@ namespace Components
} }
} }
Dvar::Register<bool>(Utils::String::VA("isDlcInstalled_%d", dlc.index), false, Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); Dvar::Register<bool>(Utils::String::VA("isDlcInstalled_%d", dlc.index), false, Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, "");
Maps::DlcPacks.push_back(dlc); Maps::DlcPacks.push_back(dlc);
Maps::UpdateDlcStatus(); Maps::UpdateDlcStatus();
@ -690,7 +690,7 @@ namespace Components
Game::dvar_t* Maps::GetSpecularDvar() Game::dvar_t* Maps::GetSpecularDvar()
{ {
Game::dvar_t*& r_specular = *reinterpret_cast<Game::dvar_t**>(0x69F0D94); Game::dvar_t*& r_specular = *reinterpret_cast<Game::dvar_t**>(0x69F0D94);
static Game::dvar_t* r_specularCustomMaps = Game::Dvar_RegisterBool("r_specularCustomMaps", false, Game::DVAR_FLAG_SAVED, "Allows shaders to use phong specular lighting on custom maps"); static Game::dvar_t* r_specularCustomMaps = Game::Dvar_RegisterBool("r_specularCustomMaps", false, Game::DVAR_ARCHIVE, "Allows shaders to use phong specular lighting on custom maps");
if (Maps::IsCustomMap()) if (Maps::IsCustomMap())
{ {
@ -769,8 +769,8 @@ namespace Components
{ {
Dvar::OnInit([]() Dvar::OnInit([]()
{ {
Dvar::Register<bool>("isDlcInstalled_All", false, Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); Dvar::Register<bool>("isDlcInstalled_All", false, Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, "");
Dvar::Register<bool>("r_listSModels", false, Game::DVAR_FLAG_NONE, "Display a list of visible SModels"); Dvar::Register<bool>("r_listSModels", false, Game::DVAR_NONE, "Display a list of visible SModels");
Maps::AddDlc({ 1, "Stimulus Pack", {"mp_complex", "mp_compact", "mp_storm", "mp_overgrown", "mp_crash"} }); Maps::AddDlc({ 1, "Stimulus Pack", {"mp_complex", "mp_compact", "mp_storm", "mp_overgrown", "mp_crash"} });
Maps::AddDlc({ 2, "Resurgence Pack", {"mp_abandon", "mp_vacant", "mp_trailerpark", "mp_strike", "mp_fuel2"} }); Maps::AddDlc({ 2, "Resurgence Pack", {"mp_abandon", "mp_vacant", "mp_trailerpark", "mp_strike", "mp_fuel2"} });

View File

@ -845,7 +845,7 @@ namespace Components
Command::Add("openmenu", [](Command::Params* params) Command::Add("openmenu", [](Command::Params* params)
{ {
if (params->length() != 2) if (params->size() != 2)
{ {
Logger::Print("USAGE: openmenu <menu name>\n"); Logger::Print("USAGE: openmenu <menu name>\n");
return; return;
@ -913,7 +913,6 @@ namespace Components
Menus::~Menus() Menus::~Menus()
{ {
Menus::CustomMenus.clear();
Menus::FreeEverything(); Menus::FreeEverything();
} }
} }

View File

@ -93,7 +93,7 @@ namespace Components
if (Dedicated::IsEnabled()) return; if (Dedicated::IsEnabled()) return;
ModList::CurrentMod = 0; ModList::CurrentMod = 0;
Dvar::Register("cl_modVidRestart", true, Game::dvar_flag::DVAR_FLAG_SAVED, "Perform a vid_restart when loading a mod."); Dvar::Register("cl_modVidRestart", true, Game::dvar_flag::DVAR_ARCHIVE, "Perform a vid_restart when loading a mod.");
UIScript::Add("LoadMods", ModList::UIScript_LoadMods); UIScript::Add("LoadMods", ModList::UIScript_LoadMods);
UIScript::Add("RunMod", ModList::UIScript_RunMod); UIScript::Add("RunMod", ModList::UIScript_RunMod);
@ -101,9 +101,4 @@ namespace Components
UIFeeder::Add(9.0f, ModList::GetItemCount, ModList::GetItemText, ModList::Select); UIFeeder::Add(9.0f, ModList::GetItemCount, ModList::GetItemText, ModList::Select);
} }
ModList::~ModList()
{
ModList::Mods.clear();
}
} }

View File

@ -6,7 +6,6 @@ namespace Components
{ {
public: public:
ModList(); ModList();
~ModList();
static void RunMod(const std::string& mod); static void RunMod(const std::string& mod);

View File

@ -260,20 +260,20 @@ namespace Components
} }
} }
Game::dvar_t* Movement::Dvar_RegisterLastStandSpeedScale(const char* name, float value, Game::dvar_t* Movement::Dvar_RegisterLastStandSpeedScale(const char* dvarName, float value,
float min, float max, int, const char* desc) float min, float max, unsigned __int16 /*flags*/, const char* description)
{ {
Movement::PlayerLastStandCrawlSpeedScale = Dvar::Register<float>(name, value, Movement::PlayerLastStandCrawlSpeedScale = Dvar::Register<float>(dvarName, value,
min, max, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, desc); min, max, Game::DVAR_CHEAT | Game::DVAR_CODINFO, description);
return Movement::PlayerLastStandCrawlSpeedScale.get<Game::dvar_t*>(); return Movement::PlayerLastStandCrawlSpeedScale.get<Game::dvar_t*>();
} }
Game::dvar_t* Movement::Dvar_RegisterSpectateSpeedScale(const char* name, float value, Game::dvar_t* Movement::Dvar_RegisterSpectateSpeedScale(const char* dvarName, float value,
float min, float max, int, const char* desc) float min, float max, unsigned __int16 /*flags*/, const char* description)
{ {
Movement::PlayerSpectateSpeedScale = Dvar::Register<float>(name, value, Movement::PlayerSpectateSpeedScale = Dvar::Register<float>(dvarName, value,
min, max, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, desc); min, max, Game::DVAR_CHEAT | Game::DVAR_CODINFO, description);
return Movement::PlayerSpectateSpeedScale.get<Game::dvar_t*>(); return Movement::PlayerSpectateSpeedScale.get<Game::dvar_t*>();
} }
@ -291,36 +291,36 @@ namespace Components
}; };
Movement::PlayerDuckedSpeedScale = Dvar::Register<float>("player_duckedSpeedScale", Movement::PlayerDuckedSpeedScale = Dvar::Register<float>("player_duckedSpeedScale",
0.65f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, 0.65f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO,
"The scale applied to the player speed when ducking"); "The scale applied to the player speed when ducking");
Movement::PlayerProneSpeedScale = Dvar::Register<float>("player_proneSpeedScale", Movement::PlayerProneSpeedScale = Dvar::Register<float>("player_proneSpeedScale",
0.15f, 0.0f, 5.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, 0.15f, 0.0f, 5.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO,
"The scale applied to the player speed when crawling"); "The scale applied to the player speed when crawling");
// 3arc naming convention // 3arc naming convention
Movement::CGUfoScaler = Dvar::Register<float>("cg_ufo_scaler", Movement::CGUfoScaler = Dvar::Register<float>("cg_ufo_scaler",
6.0f, 0.001f, 1000.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, 6.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO,
"The speed at which ufo camera moves"); "The speed at which ufo camera moves");
Movement::CGNoclipScaler = Dvar::Register<float>("cg_noclip_scaler", Movement::CGNoclipScaler = Dvar::Register<float>("cg_noclip_scaler",
3.0f, 0.001f, 1000.0f, Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_REPLICATED, 3.0f, 0.001f, 1000.0f, Game::DVAR_CHEAT | Game::DVAR_CODINFO,
"The speed at which noclip camera moves"); "The speed at which noclip camera moves");
Movement::BGBounces = Game::Dvar_RegisterEnum("bg_bounces", Movement::BGBounces = Game::Dvar_RegisterEnum("bg_bounces",
bg_bouncesValues, Movement::DISABLED, Game::DVAR_FLAG_REPLICATED, "Bounce glitch settings"); bg_bouncesValues, Movement::DISABLED, Game::DVAR_CODINFO, "Bounce glitch settings");
Movement::BGBouncesAllAngles = Dvar::Register<bool>("bg_bouncesAllAngles", Movement::BGBouncesAllAngles = Dvar::Register<bool>("bg_bouncesAllAngles",
false, Game::DVAR_FLAG_REPLICATED, "Force bounce from all angles"); false, Game::DVAR_CODINFO, "Force bounce from all angles");
Movement::BGRocketJump = Dvar::Register<bool>("bg_rocketJump", Movement::BGRocketJump = Dvar::Register<bool>("bg_rocketJump",
false, Game::DVAR_FLAG_REPLICATED, "Enable CoD4 rocket jumps"); false, Game::DVAR_CODINFO, "Enable CoD4 rocket jumps");
Movement::BGPlayerEjection = Dvar::Register<bool>("bg_playerEjection", Movement::BGPlayerEjection = Dvar::Register<bool>("bg_playerEjection",
true, Game::DVAR_FLAG_REPLICATED, "Push intersecting players away from each other"); true, Game::DVAR_CODINFO, "Push intersecting players away from each other");
Movement::BGPlayerCollision = Dvar::Register<bool>("bg_playerCollision", Movement::BGPlayerCollision = Dvar::Register<bool>("bg_playerCollision",
true, Game::DVAR_FLAG_REPLICATED, "Push intersecting players away from each other"); true, Game::DVAR_CODINFO, "Push intersecting players away from each other");
}); });
// Hook PM_CmdScaleForStance in PM_CmdScale_Walk // Hook PM_CmdScaleForStance in PM_CmdScale_Walk

View File

@ -40,7 +40,7 @@ namespace Components
static int StuckInClient_Hk(Game::gentity_s* self); static int StuckInClient_Hk(Game::gentity_s* self);
static void CM_TransformedCapsuleTrace_Hk(Game::trace_t* results, const float* start, const float* end, const Game::Bounds* bounds, const Game::Bounds* capsule, int contents, const float* origin, const float* angles); static void CM_TransformedCapsuleTrace_Hk(Game::trace_t* results, const float* start, const float* end, const Game::Bounds* bounds, const Game::Bounds* capsule, int contents, const float* origin, const float* angles);
static Game::dvar_t* Dvar_RegisterLastStandSpeedScale(const char* name, float value, float min, float max, int flags, const char* desc); static Game::dvar_t* Dvar_RegisterLastStandSpeedScale(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description);
static Game::dvar_t* Dvar_RegisterSpectateSpeedScale(const char* name, float value, float min, float max, int flags, const char* desc); static Game::dvar_t* Dvar_RegisterSpectateSpeedScale(const char* dvarName, float value, float min, float max, unsigned __int16 flags, const char* description);
}; };
} }

View File

@ -39,9 +39,4 @@ namespace Components
MusicalTalent::Replace("music_mainmenu_mp", "hz_t_menumusic.mp3"); MusicalTalent::Replace("music_mainmenu_mp", "hz_t_menumusic.mp3");
} }
MusicalTalent::~MusicalTalent()
{
MusicalTalent::SoundAliasList.clear();
}
} }

View File

@ -6,7 +6,6 @@ namespace Components
{ {
public: public:
MusicalTalent(); MusicalTalent();
~MusicalTalent();
static void Replace(const std::string& sound, const char* file); static void Replace(const std::string& sound, const char* file);

View File

@ -403,11 +403,4 @@ namespace Components
Network::SendRaw(address, address.getString()); Network::SendRaw(address, address.getString());
}); });
} }
Network::~Network()
{
Network::SelectedPacket.clear();
Network::PacketHandlers.clear();
Network::StartupSignal.clear();
}
} }

View File

@ -52,7 +52,6 @@ namespace Components
typedef void(CallbackRaw)(); typedef void(CallbackRaw)();
Network(); Network();
~Network();
static unsigned short GetPort(); static unsigned short GetPort();

View File

@ -39,9 +39,9 @@ namespace Components
{ {
if (ZoneBuilder::IsEnabled() || Dedicated::IsEnabled()) return; // Maybe also dedi? if (ZoneBuilder::IsEnabled() || Dedicated::IsEnabled()) return; // Maybe also dedi?
Dvar::Register<bool>("g_firstLaunch", true, Game::DVAR_FLAG_SAVED, ""); Dvar::Register<bool>("g_firstLaunch", true, Game::DVAR_ARCHIVE, "");
Dvar::Register<int>("cl_updateoldversion", REVISION, REVISION, REVISION, Game::DVAR_FLAG_WRITEPROTECTED, "Current version number."); Dvar::Register<int>("cl_updateoldversion", REVISION, REVISION, REVISION, Game::DVAR_WRITEPROTECTED, "Current version number.");
UIScript::Add("checkFirstLaunch", [](UIScript::Token) UIScript::Add("checkFirstLaunch", [](UIScript::Token)
{ {

View File

@ -377,7 +377,7 @@ namespace Components
Command::Add("addnode", [](Command::Params* params) Command::Add("addnode", [](Command::Params* params)
{ {
if (params->length() < 2) return; if (params->size() < 2) return;
Node::Add({ params->get(1) }); Node::Add({ params->get(1) });
}); });
} }

View File

@ -79,7 +79,7 @@ namespace Components
Game::dvar_t* Party::RegisterMinPlayers(const char* name, int /*value*/, int /*min*/, int max, Game::dvar_flag flag, const char* description) Game::dvar_t* Party::RegisterMinPlayers(const char* name, int /*value*/, int /*min*/, int max, Game::dvar_flag flag, const char* description)
{ {
return Dvar::Register<int>(name, 1, 1, max, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED | flag, description).get<Game::dvar_t*>(); return Dvar::Register<int>(name, 1, 1, max, Game::dvar_flag::DVAR_WRITEPROTECTED | flag, description).get<Game::dvar_t*>();
} }
bool Party::PlaylistAwaiting() bool Party::PlaylistAwaiting()
@ -150,8 +150,8 @@ namespace Components
Party::Party() Party::Party()
{ {
static Game::dvar_t* partyEnable = Dvar::Register<bool>("party_enable", Dedicated::IsEnabled(), Game::dvar_flag::DVAR_FLAG_NONE, "Enable party system").get<Game::dvar_t*>(); static Game::dvar_t* partyEnable = Dvar::Register<bool>("party_enable", Dedicated::IsEnabled(), Game::dvar_flag::DVAR_NONE, "Enable party system").get<Game::dvar_t*>();
Dvar::Register<bool>("xblive_privatematch", true, Game::dvar_flag::DVAR_FLAG_WRITEPROTECTED, ""); Dvar::Register<bool>("xblive_privatematch", true, Game::dvar_flag::DVAR_WRITEPROTECTED, "");
// various changes to SV_DirectConnect-y stuff to allow non-party joinees // various changes to SV_DirectConnect-y stuff to allow non-party joinees
Utils::Hook::Set<WORD>(0x460D96, 0x90E9); Utils::Hook::Set<WORD>(0x460D96, 0x90E9);
@ -249,19 +249,19 @@ namespace Components
Utils::Hook::Set<const char*>(0x5E3772, "sv_maxclients"); Utils::Hook::Set<const char*>(0x5E3772, "sv_maxclients");
// Unlatch maxclient dvars // Unlatch maxclient dvars
Utils::Hook::Xor<BYTE>(0x426187, Game::dvar_flag::DVAR_FLAG_LATCHED); Utils::Hook::Xor<BYTE>(0x426187, Game::dvar_flag::DVAR_LATCH);
Utils::Hook::Xor<BYTE>(0x4D374E, Game::dvar_flag::DVAR_FLAG_LATCHED); Utils::Hook::Xor<BYTE>(0x4D374E, Game::dvar_flag::DVAR_LATCH);
Utils::Hook::Xor<BYTE>(0x5E376A, Game::dvar_flag::DVAR_FLAG_LATCHED); Utils::Hook::Xor<BYTE>(0x5E376A, Game::dvar_flag::DVAR_LATCH);
Utils::Hook::Xor<DWORD>(0x4261A1, Game::dvar_flag::DVAR_FLAG_LATCHED); Utils::Hook::Xor<DWORD>(0x4261A1, Game::dvar_flag::DVAR_LATCH);
Utils::Hook::Xor<DWORD>(0x4D376D, Game::dvar_flag::DVAR_FLAG_LATCHED); Utils::Hook::Xor<DWORD>(0x4D376D, Game::dvar_flag::DVAR_LATCH);
Utils::Hook::Xor<DWORD>(0x5E3789, Game::dvar_flag::DVAR_FLAG_LATCHED); Utils::Hook::Xor<DWORD>(0x5E3789, Game::dvar_flag::DVAR_LATCH);
// Patch Live_PlayerHasLoopbackAddr // Patch Live_PlayerHasLoopbackAddr
//Utils::Hook::Set<DWORD>(0x418F30, 0x90C3C033); //Utils::Hook::Set<DWORD>(0x418F30, 0x90C3C033);
Command::Add("connect", [](Command::Params* params) Command::Add("connect", [](Command::Params* params)
{ {
if (params->length() < 2) if (params->size() < 2)
{ {
return; return;
} }
@ -513,9 +513,4 @@ namespace Components
Friends::UpdateServer(address, info.get("hostname"), info.get("mapname")); Friends::UpdateServer(address, info.get("hostname"), info.get("mapname"));
}); });
} }
Party::~Party()
{
Party::LobbyMap.clear();
}
} }

View File

@ -6,7 +6,6 @@ namespace Components
{ {
public: public:
Party(); Party();
~Party();
static Network::Address Target(); static Network::Address Target();
static void Connect(Network::Address target); static void Connect(Network::Address target);

View File

@ -61,7 +61,7 @@ namespace Components
PlayerName::PlayerName() PlayerName::PlayerName()
{ {
sv_allowColoredNames = Dvar::Register<bool>("sv_allowColoredNames", true, Game::dvar_flag::DVAR_FLAG_NONE, "Allow colored names on the server"); sv_allowColoredNames = Dvar::Register<bool>("sv_allowColoredNames", true, Game::dvar_flag::DVAR_NONE, "Allow colored names on the server");
// Disable SV_UpdateUserinfo_f, to block changing the name ingame // Disable SV_UpdateUserinfo_f, to block changing the name ingame
Utils::Hook::Set<BYTE>(0x6258D0, 0xC3); Utils::Hook::Set<BYTE>(0x6258D0, 0xC3);

View File

@ -21,7 +21,7 @@ namespace Components
Dvar::Var("xblive_privateserver").set(false); Dvar::Var("xblive_privateserver").set(false);
std::string playlistFilename = Dvar::Var("playlistFilename").get<const char*>(); auto playlistFilename = Dvar::Var("playlistFilename").get<std::string>();
FileSystem::File playlist(playlistFilename); FileSystem::File playlist(playlistFilename);
if (playlist.exists()) if (playlist.exists())
@ -190,11 +190,4 @@ namespace Components
Network::Handle("playlistResponse", PlaylistReponse); Network::Handle("playlistResponse", PlaylistReponse);
Network::Handle("playlistInvalidPassword", PlaylistInvalidPassword); Network::Handle("playlistInvalidPassword", PlaylistInvalidPassword);
} }
Playlist::~Playlist()
{
Playlist::MapRelocation.clear();
Playlist::CurrentPlaylistBuffer.clear();
Playlist::ReceivedPlaylistBuffer.clear();
}
} }

View File

@ -8,7 +8,6 @@ namespace Components
typedef void(*Callback)(); typedef void(*Callback)();
Playlist(); Playlist();
~Playlist();
static void LoadPlaylist(); static void LoadPlaylist();

View File

@ -86,17 +86,15 @@ namespace Components
void QuickPatch::SelectStringTableEntryInDvarStub() void QuickPatch::SelectStringTableEntryInDvarStub()
{ {
Command::ClientParams args; Command::ClientParams params;
if (args.length() >= 4) if (params.size() >= 4)
{ {
std::string cmd = args[0]; const auto* dvarName = params[3];
std::string table = args[1]; const auto* dvar = Game::Dvar_FindVar(dvarName);
std::string col = args[2];
std::string dvarName = args[3];
Game::dvar_t* dvar = Game::Dvar_FindVar(dvarName.data());
if (Command::Find(dvarName) || (dvar && (dvar->flags & (Game::DVAR_FLAG_WRITEPROTECTED | Game::DVAR_FLAG_CHEAT | Game::DVAR_FLAG_READONLY)))) if (Command::Find(dvarName) ||
(dvar != nullptr && dvar->flags & (Game::DVAR_WRITEPROTECTED | Game::DVAR_CHEAT | Game::DVAR_READONLY)))
{ {
return; return;
} }
@ -238,7 +236,7 @@ namespace Components
} }
} }
Game::dvar_t* QuickPatch::Dvar_RegisterAspectRatioDvar(const char* name, char**, int defaultVal, int flags, const char* description) Game::dvar_t* QuickPatch::Dvar_RegisterAspectRatioDvar(const char* dvarName, const char** /*valueList*/, int defaultIndex, unsigned __int16 flags, const char* description)
{ {
static const char* r_aspectRatioEnum[] = static const char* r_aspectRatioEnum[] =
{ {
@ -256,7 +254,7 @@ namespace Components
"Screen aspect ratio. Divide the width by the height in order to get the aspect ratio value. For example: 16 / 9 = 1,77"); "Screen aspect ratio. Divide the width by the height in order to get the aspect ratio value. For example: 16 / 9 = 1,77");
// register enumeration dvar // register enumeration dvar
return Game::Dvar_RegisterEnum(name, r_aspectRatioEnum, defaultVal, flags, description); return Game::Dvar_RegisterEnum(dvarName, r_aspectRatioEnum, defaultIndex, flags, description);
} }
void QuickPatch::SetAspectRatio() void QuickPatch::SetAspectRatio()
@ -353,13 +351,13 @@ namespace Components
Game::dvar_t* QuickPatch::Dvar_RegisterUIBuildLocation(const char* dvarName, Game::dvar_t* QuickPatch::Dvar_RegisterUIBuildLocation(const char* dvarName,
float /*x*/, float /*y*/, float min, float max, int /*flags*/, const char* description) float /*x*/, float /*y*/, float min, float max, int /*flags*/, const char* description)
{ {
return Game::Dvar_RegisterVec2(dvarName, -60.0f, 474.0f, min, max, Game::DVAR_FLAG_READONLY, description); return Game::Dvar_RegisterVec2(dvarName, -60.0f, 474.0f, min, max, Game::DVAR_READONLY, description);
} }
QuickPatch::QuickPatch() QuickPatch::QuickPatch()
{ {
// quit_hard // quitHard
Command::Add("quit_hard", [](Command::Params*) Command::Add("quitHard", [](Command::Params*)
{ {
int data = false; int data = false;
const Utils::Library ntdll("ntdll.dll"); const Utils::Library ntdll("ntdll.dll");
@ -374,9 +372,9 @@ namespace Components
Utils::Hook(0x4F66A3, CL_KeyEvent_ConsoleEscape_Stub, HOOK_JUMP).install()->quick(); Utils::Hook(0x4F66A3, CL_KeyEvent_ConsoleEscape_Stub, HOOK_JUMP).install()->quick();
// Intermission time dvar // Intermission time dvar
Game::Dvar_RegisterFloat("scr_intermissionTime", 10, 0, 120, Game::DVAR_FLAG_REPLICATED | Game::DVAR_FLAG_DEDISAVED, "Time in seconds before match server loads the next map"); Game::Dvar_RegisterFloat("scr_intermissionTime", 10, 0, 120, Game::dvar_flag::DVAR_NONE, "Time in seconds before match server loads the next map");
g_antilag = Game::Dvar_RegisterBool("g_antilag", true, Game::DVAR_FLAG_REPLICATED, "Perform antilag"); g_antilag = Game::Dvar_RegisterBool("g_antilag", true, Game::DVAR_CODINFO, "Perform antilag");
Utils::Hook(0x5D6D56, QuickPatch::ClientEventsFireWeaponStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x5D6D56, QuickPatch::ClientEventsFireWeaponStub, HOOK_JUMP).install()->quick();
Utils::Hook(0x5D6D6A, QuickPatch::ClientEventsFireWeaponMeleeStub, HOOK_JUMP).install()->quick(); Utils::Hook(0x5D6D6A, QuickPatch::ClientEventsFireWeaponMeleeStub, HOOK_JUMP).install()->quick();
@ -477,7 +475,7 @@ namespace Components
// Numerical ping (cg_scoreboardPingText 1) // Numerical ping (cg_scoreboardPingText 1)
Utils::Hook::Set<BYTE>(0x45888E, 1); Utils::Hook::Set<BYTE>(0x45888E, 1);
Utils::Hook::Set<BYTE>(0x45888C, Game::dvar_flag::DVAR_FLAG_CHEAT); Utils::Hook::Set<BYTE>(0x45888C, Game::dvar_flag::DVAR_CHEAT);
// increase font sizes for chat on higher resolutions // increase font sizes for chat on higher resolutions
static float float13 = 13.0f; static float float13 = 13.0f;
@ -633,7 +631,7 @@ namespace Components
}); });
// Fix mouse pitch adjustments // Fix mouse pitch adjustments
Dvar::Register<bool>("ui_mousePitch", false, Game::DVAR_FLAG_SAVED, ""); Dvar::Register<bool>("ui_mousePitch", false, Game::DVAR_ARCHIVE, "");
UIScript::Add("updateui_mousePitch", [](UIScript::Token) UIScript::Add("updateui_mousePitch", [](UIScript::Token)
{ {
if (Dvar::Var("ui_mousePitch").get<bool>()) if (Dvar::Var("ui_mousePitch").get<bool>())
@ -671,7 +669,7 @@ namespace Components
Command::Add("dumptechsets", [](Command::Params* param) Command::Add("dumptechsets", [](Command::Params* param)
{ {
if (param->length() != 2) if (param->size() != 2)
{ {
Logger::Print("usage: dumptechsets <fastfile> | all\n"); Logger::Print("usage: dumptechsets <fastfile> | all\n");
return; return;
@ -843,6 +841,7 @@ namespace Components
} }
}); });
#ifdef DEBUG
AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& /*name*/, bool* /*restrict*/) AssetHandler::OnLoad([](Game::XAssetType type, Game::XAssetHeader asset, const std::string& /*name*/, bool* /*restrict*/)
{ {
if (type == Game::XAssetType::ASSET_TYPE_GFXWORLD) if (type == Game::XAssetType::ASSET_TYPE_GFXWORLD)
@ -857,9 +856,10 @@ namespace Components
Utils::IO::WriteFile("userraw/logs/matlog.txt", buffer); Utils::IO::WriteFile("userraw/logs/matlog.txt", buffer);
} }
}); });
#endif
// Dvars // Dvars
Dvar::Register<bool>("ui_streamFriendly", false, Game::DVAR_FLAG_SAVED, "Stream friendly UI"); Dvar::Register<bool>("ui_streamFriendly", false, Game::DVAR_ARCHIVE, "Stream friendly UI");
// Debug patches // Debug patches
#ifdef DEBUG #ifdef DEBUG

View File

@ -28,7 +28,7 @@ namespace Components
static void InvalidNameStub(); static void InvalidNameStub();
static Dvar::Var r_customAspectRatio; static Dvar::Var r_customAspectRatio;
static Game::dvar_t* Dvar_RegisterAspectRatioDvar(const char* name, char** enumValues, int defaultVal, int flags, const char* description); static Game::dvar_t* Dvar_RegisterAspectRatioDvar(const char* dvarName, const char** valueList, int defaultIndex, unsigned __int16 flags, const char* description);
static void SetAspectRatioStub(); static void SetAspectRatioStub();
static void SetAspectRatio(); static void SetAspectRatio();

View File

@ -7,19 +7,22 @@ namespace Components
std::string RCon::Password; std::string RCon::Password;
Dvar::Var RCon::RconPassword;
Dvar::Var RCon::RconLogRequests;
RCon::RCon() RCon::RCon()
{ {
Command::Add("rcon", [](Command::Params* params) Command::Add("rcon", [](Command::Params* params)
{ {
if (params->length() < 2) return; if (params->size() < 2) return;
std::string operation = params->get(1); const auto* operation = params->get(1);
if (operation == "login") if (std::strcmp(operation, "login") == 0)
{ {
if (params->length() < 3) return; if (params->size() < 3) return;
RCon::Password = params->get(2); RCon::Password = params->get(2);
} }
else if (operation == "logout") else if (std::strcmp(operation, "logout") == 0)
{ {
RCon::Password.clear(); RCon::Password.clear();
} }
@ -75,8 +78,8 @@ namespace Components
Dvar::OnInit([]() Dvar::OnInit([]()
{ {
Dvar::Register<const char*>("rcon_password", "", Game::dvar_flag::DVAR_FLAG_NONE, "The password for rcon"); RCon::RconPassword = Dvar::Register<const char*>("rcon_password", "", Game::dvar_flag::DVAR_NONE, "The password for rcon");
Dvar::Register<bool>("log_rcon_requests", false, Game::dvar_flag::DVAR_FLAG_NONE, "Print remote commands in the output log"); RCon::RconLogRequests = Dvar::Register<bool>("rcon_log_requests", false, Game::dvar_flag::DVAR_NONE, "Print remote commands in the output log");
}); });
Network::Handle("rcon", [](Network::Address address, const std::string& _data) Network::Handle("rcon", [](Network::Address address, const std::string& _data)
@ -100,7 +103,7 @@ namespace Components
password.erase(password.begin()); password.erase(password.begin());
} }
std::string svPassword = Dvar::Var("rcon_password").get<std::string>(); const std::string svPassword = RCon::RconPassword.get<std::string>();
if (svPassword.empty()) if (svPassword.empty())
{ {
@ -114,7 +117,7 @@ namespace Components
outputBuffer.clear(); outputBuffer.clear();
#ifndef DEBUG #ifndef DEBUG
if (Dvar::Var("log_rcon_requests").get<bool>()) if (RCon::RconLogRequests.get<bool>())
#endif #endif
{ {
Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data()); Logger::Print("Executing RCon request from %s: %s\n", address.getCString(), command.data());
@ -173,9 +176,4 @@ namespace Components
} }
}); });
} }
RCon::~RCon()
{
RCon::Password.clear();
}
} }

View File

@ -6,7 +6,6 @@ namespace Components
{ {
public: public:
RCon(); RCon();
~RCon();
private: private:
class Container class Container
@ -25,5 +24,8 @@ namespace Components
// For sr0's fucking rcon command // For sr0's fucking rcon command
// Son of a bitch! Annoying me day and night with that shit... // Son of a bitch! Annoying me day and night with that shit...
static std::string Password; static std::string Password;
static Dvar::Var RconPassword;
static Dvar::Var RconLogRequests;
}; };
} }

View File

@ -24,7 +24,7 @@ namespace Components
Command::Add("dumpraw", [](Command::Params* params) Command::Add("dumpraw", [](Command::Params* params)
{ {
if (params->length() < 2) if (params->size() < 2)
{ {
Logger::Print("Specify a filename!\n"); Logger::Print("Specify a filename!\n");
return; return;

View File

@ -546,12 +546,12 @@ namespace Components
nullptr nullptr
}; };
Renderer::r_drawModelBoundingBoxes = Game::Dvar_RegisterEnum("r_drawModelBoundingBoxes", values, 0, Game::DVAR_FLAG_CHEAT, "Draw scene model bounding boxes"); Renderer::r_drawModelBoundingBoxes = Game::Dvar_RegisterEnum("r_drawModelBoundingBoxes", values, 0, Game::DVAR_CHEAT, "Draw scene model bounding boxes");
Renderer::r_drawSceneModelCollisions = Game::Dvar_RegisterBool("r_drawSceneModelCollisions", false, Game::DVAR_FLAG_CHEAT, "Draw scene model collisions"); Renderer::r_drawSceneModelCollisions = Game::Dvar_RegisterBool("r_drawSceneModelCollisions", false, Game::DVAR_CHEAT, "Draw scene model collisions");
Renderer::r_drawTriggers = Game::Dvar_RegisterBool("r_drawTriggers", false, Game::DVAR_FLAG_CHEAT, "Draw triggers"); Renderer::r_drawTriggers = Game::Dvar_RegisterBool("r_drawTriggers", false, Game::DVAR_CHEAT, "Draw triggers");
Renderer::r_drawModelNames = Game::Dvar_RegisterEnum("r_drawModelNames", values, 0, Game::DVAR_FLAG_CHEAT, "Draw all model names"); Renderer::r_drawModelNames = Game::Dvar_RegisterEnum("r_drawModelNames", values, 0, Game::DVAR_CHEAT, "Draw all model names");
Renderer::r_drawAABBTrees = Game::Dvar_RegisterBool("r_drawAabbTrees", false, Game::DVAR_FLAG_CHEAT, "Draw aabb trees"); Renderer::r_drawAABBTrees = Game::Dvar_RegisterBool("r_drawAabbTrees", false, Game::DVAR_CHEAT, "Draw aabb trees");
Renderer::r_playerDrawDebugDistance = Game::Dvar_RegisterInt("r_drawDebugDistance", 1000, 0, 50000, Game::DVAR_FLAG_SAVED, "r_draw debug functions draw distance, relative to the player"); Renderer::r_playerDrawDebugDistance = Game::Dvar_RegisterInt("r_drawDebugDistance", 1000, 0, 50000, Game::DVAR_ARCHIVE, "r_draw debug functions draw distance, relative to the player");
}); });
} }

View File

@ -705,14 +705,6 @@ namespace Components
Script::~Script() Script::~Script()
{ {
Script::ScriptName.clear();
Script::ScriptHandles.clear();
Script::ScriptNameStack.clear();
Script::ScriptFunctions.clear();
Script::ReplacedFunctions.clear();
Script::VMShutdownSignal.clear(); Script::VMShutdownSignal.clear();
Script::ScriptStorage.clear();
Script::ScriptBaseProgramNum.clear();
} }
} }

View File

@ -11,11 +11,11 @@ namespace Components
bool ServerCommands::OnServerCommand() bool ServerCommands::OnServerCommand()
{ {
Command::ClientParams params(*Game::cmd_id); Command::ClientParams params;
for (auto &serverCommandCB : ServerCommands::Commands) for (const auto& serverCommandCB : ServerCommands::Commands)
{ {
if (params.length() >= 1) if (params.size() >= 1)
{ {
if (params.get(0)[0] == serverCommandCB.first) if (params.get(0)[0] == serverCommandCB.first)
{ {
@ -65,9 +65,4 @@ namespace Components
// Server command receive hook // Server command receive hook
Utils::Hook(0x59449F, ServerCommands::OnServerCommandStub).install()->quick(); Utils::Hook(0x59449F, ServerCommands::OnServerCommandStub).install()->quick();
} }
ServerCommands::~ServerCommands()
{
ServerCommands::Commands.clear();
}
} }

View File

@ -6,7 +6,6 @@ namespace Components
{ {
public: public:
ServerCommands(); ServerCommands();
~ServerCommands();
static void OnCommand(std::int32_t cmd, Utils::Slot<bool(Command::Params*)> cb); static void OnCommand(std::int32_t cmd, Utils::Slot<bool(Command::Params*)> cb);

View File

@ -734,16 +734,16 @@ namespace Components
Dvar::OnInit([]() Dvar::OnInit([]()
{ {
Dvar::Register<bool>("ui_serverSelected", false, Game::dvar_flag::DVAR_FLAG_NONE, "Whether a server has been selected in the serverlist"); Dvar::Register<bool>("ui_serverSelected", false, Game::dvar_flag::DVAR_NONE, "Whether a server has been selected in the serverlist");
Dvar::Register<const char*>("ui_serverSelectedMap", "mp_afghan", Game::dvar_flag::DVAR_FLAG_NONE, "Map of the selected server"); Dvar::Register<const char*>("ui_serverSelectedMap", "mp_afghan", Game::dvar_flag::DVAR_NONE, "Map of the selected server");
Dvar::Register<int>("net_serverQueryLimit", 1, 1, 10, Dedicated::IsEnabled() ? 0 : Game::dvar_flag::DVAR_FLAG_SAVED, "Amount of server queries per frame"); Dvar::Register<int>("net_serverQueryLimit", 1, 1, 10, Dedicated::IsEnabled() ? Game::dvar_flag::DVAR_NONE : Game::dvar_flag::DVAR_ARCHIVE, "Amount of server queries per frame");
Dvar::Register<int>("net_serverFrames", 30, 1, 60, Dedicated::IsEnabled() ? 0 : Game::dvar_flag::DVAR_FLAG_SAVED, "Amount of server query frames per second"); Dvar::Register<int>("net_serverFrames", 30, 1, 60, Dedicated::IsEnabled() ? Game::dvar_flag::DVAR_NONE : Game::dvar_flag::DVAR_ARCHIVE, "Amount of server query frames per second");
}); });
// Fix ui_netsource dvar // Fix ui_netsource dvar
Utils::Hook::Nop(0x4CDEEC, 5); // Don't reset the netsource when gametypes aren't loaded Utils::Hook::Nop(0x4CDEEC, 5); // Don't reset the netsource when gametypes aren't loaded
Dvar::Register<int>("ui_netSource", 1, 0, 2, Game::DVAR_FLAG_SAVED, reinterpret_cast<const char*>(0x6D9F08)); Dvar::Register<int>("ui_netSource", 1, 0, 2, Game::DVAR_ARCHIVE, reinterpret_cast<const char*>(0x6D9F08));
//Localization::Set("MPUI_SERVERQUERIED", "Sent requests: 0/0"); //Localization::Set("MPUI_SERVERQUERIED", "Sent requests: 0/0");
Localization::Set("MPUI_SERVERQUERIED", "Servers: 0\nPlayers: 0 (0)"); Localization::Set("MPUI_SERVERQUERIED", "Servers: 0\nPlayers: 0 (0)");
@ -782,8 +782,8 @@ namespace Components
// Set default masterServerName + port and save it // Set default masterServerName + port and save it
#ifdef USE_LEGACY_SERVER_LIST #ifdef USE_LEGACY_SERVER_LIST
Utils::Hook::Set<char*>(0x60AD92, "127.0.0.1"); Utils::Hook::Set<char*>(0x60AD92, "127.0.0.1");
Utils::Hook::Set<BYTE>(0x60AD90, Game::dvar_flag::DVAR_FLAG_SAVED); // masterServerName Utils::Hook::Set<BYTE>(0x60AD90, Game::dvar_flag::DVAR_ARCHIVE); // masterServerName
Utils::Hook::Set<BYTE>(0x60ADC6, Game::dvar_flag::DVAR_FLAG_SAVED); // masterPort Utils::Hook::Set<BYTE>(0x60ADC6, Game::dvar_flag::DVAR_ARCHIVE); // masterPort
#endif #endif
// Add server list feeder // Add server list feeder
@ -880,15 +880,8 @@ namespace Components
ServerList::~ServerList() ServerList::~ServerList()
{ {
ServerList::OnlineList.clear(); std::lock_guard<std::recursive_mutex> _(ServerList::RefreshContainer.mutex);
ServerList::OfflineList.clear(); ServerList::RefreshContainer.awatingList = false;
ServerList::FavouriteList.clear(); ServerList::RefreshContainer.servers.clear();
ServerList::VisibleList.clear();
{
std::lock_guard<std::recursive_mutex> _(ServerList::RefreshContainer.mutex);
ServerList::RefreshContainer.awatingList = false;
ServerList::RefreshContainer.servers.clear();
}
} }
} }

View File

@ -9,9 +9,9 @@ namespace Components
{ {
Dvar::OnInit([]() Dvar::OnInit([]()
{ {
Dvar::Register<const char*>("ui_startupMessage", "", Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); Dvar::Register<const char*>("ui_startupMessage", "", Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, "");
Dvar::Register<const char*>("ui_startupMessageTitle", "", Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); Dvar::Register<const char*>("ui_startupMessageTitle", "", Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, "");
Dvar::Register<const char*>("ui_startupNextButtonText", "", Game::DVAR_FLAG_USERCREATED | Game::DVAR_FLAG_WRITEPROTECTED, ""); Dvar::Register<const char*>("ui_startupNextButtonText", "", Game::DVAR_EXTERNAL | Game::DVAR_WRITEPROTECTED, "");
}); });
UIScript::Add("nextStartupMessage", [](UIScript::Token) UIScript::Add("nextStartupMessage", [](UIScript::Token)
@ -34,11 +34,6 @@ namespace Components
}); });
} }
StartupMessages::~StartupMessages()
{
StartupMessages::MessageList.clear();
}
void StartupMessages::AddMessage(const std::string& message) void StartupMessages::AddMessage(const std::string& message)
{ {
StartupMessages::MessageList.push_back(message); StartupMessages::MessageList.push_back(message);

View File

@ -6,7 +6,6 @@ namespace Components
{ {
public: public:
StartupMessages(); StartupMessages();
~StartupMessages();
static void AddMessage(const std::string& message); static void AddMessage(const std::string& message);

View File

@ -107,9 +107,4 @@ namespace Components
// Write stats to mod folder if a mod is loaded // Write stats to mod folder if a mod is loaded
Utils::Hook(0x682F7B, Stats::SaveStats, HOOK_CALL).install()->quick(); Utils::Hook(0x682F7B, Stats::SaveStats, HOOK_CALL).install()->quick();
} }
Stats::~Stats()
{
}
} }

View File

@ -6,7 +6,6 @@ namespace Components
{ {
public: public:
Stats(); Stats();
~Stats();
static bool IsMaxLevel(); static bool IsMaxLevel();

View File

@ -76,9 +76,4 @@ namespace Components
return header; return header;
}); });
} }
StringTable::~StringTable()
{
StringTable::StringTableMap.clear();
}
} }

View File

@ -6,7 +6,6 @@ namespace Components
{ {
public: public:
StringTable(); StringTable();
~StringTable();
private: private:
static std::unordered_map<std::string, Game::StringTable*> StringTableMap; static std::unordered_map<std::string, Game::StringTable*> StringTableMap;

View File

@ -311,9 +311,4 @@ namespace Components
} }
}); });
} }
StructuredData::~StructuredData()
{
StructuredData::MemAllocator.clear();
}
} }

View File

@ -24,7 +24,6 @@ namespace Components
}; };
StructuredData(); StructuredData();
~StructuredData();
private: private:
static bool UpdateVersionOffsets(Game::StructuredDataDefSet *set, Game::StructuredDataBuffer *buffer, Game::StructuredDataDef *oldDef); static bool UpdateVersionOffsets(Game::StructuredDataDefSet *set, Game::StructuredDataBuffer *buffer, Game::StructuredDataDef *oldDef);

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