diff --git a/.gitignore b/.gitignore index 832390e..1210307 100644 --- a/.gitignore +++ b/.gitignore @@ -1,150 +1,150 @@ -### Windows - -version.hpp - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Windows Installer files -*.cab -*.msi -*.msm -*.msp - -# Shortcuts -*.lnk - -### OSX - -.DS_Store -.AppleDouble -.LSOverride - -# Icon must end with two \r -Icon - -# Thumbnails -._* - -# Files that might appear on external disk -.Spotlight-V100 -.Trashes - -# Directories potentially created on remote AFP share -.AppleDB -.AppleDesktop -Network Trash Folder -Temporary Items -.apdisk - -### Visual Studio - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -build - -# Visual Studio 2015 cache/options directory -.vs/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -### IDA -*.id0 -*.id1 -*.id2 -*.nam -*.til - -### Custom user files -# User scripts -user*.bat +### Windows + +version.hpp + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Shortcuts +*.lnk + +### OSX + +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Visual Studio + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +build + +# Visual Studio 2015 cache/options directory +.vs/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +### IDA +*.id0 +*.id1 +*.id2 +*.nam +*.til + +### Custom user files +# User scripts +user*.bat *.code-workspace \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index b0f7175..c85f3f4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,25 +1,25 @@ -[submodule "deps/minhook"] - path = deps/minhook - url = https://github.com/TsudaKageyu/minhook.git -[submodule "deps/GSL"] - path = deps/GSL - url = https://github.com/microsoft/GSL.git -[submodule "deps/zlib"] - path = deps/zlib - url = https://github.com/madler/zlib.git -[submodule "deps/asmjit"] - path = deps/asmjit - url = https://github.com/asmjit/asmjit.git -[submodule "deps/json"] - path = deps/json - url = https://github.com/nlohmann/json.git - branch = develop -[submodule "deps/curl"] - path = deps/curl - url = https://github.com/curl/curl.git -[submodule "deps/libtomcrypt"] - path = deps/libtomcrypt - url = https://github.com/libtom/libtomcrypt.git -[submodule "deps/libtommath"] - path = deps/libtommath - url = https://github.com/libtom/libtommath.git +[submodule "deps/minhook"] + path = deps/minhook + url = https://github.com/TsudaKageyu/minhook.git +[submodule "deps/GSL"] + path = deps/GSL + url = https://github.com/microsoft/GSL.git +[submodule "deps/zlib"] + path = deps/zlib + url = https://github.com/madler/zlib.git +[submodule "deps/asmjit"] + path = deps/asmjit + url = https://github.com/asmjit/asmjit.git +[submodule "deps/json"] + path = deps/json + url = https://github.com/nlohmann/json.git + branch = develop +[submodule "deps/curl"] + path = deps/curl + url = https://github.com/curl/curl.git +[submodule "deps/libtomcrypt"] + path = deps/libtomcrypt + url = https://github.com/libtom/libtomcrypt.git +[submodule "deps/libtommath"] + path = deps/libtommath + url = https://github.com/libtom/libtommath.git diff --git a/README.md b/README.md index 1b879ac..49372d0 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,21 @@ -# T4SP-Server-Plugin -A server plugin that has code that hopefully compiles and the game will load it to do things. Stability not guaranteed. - -Requires Git (https://git-scm.com/), Premake5 (https://premake.github.io/), and MSVC 2022 (https://visualstudio.microsoft.com/vs/features/cplusplus/) to build. - -# Installation -Move the `t4sp-server-plugin.dll` to `%LOCALAPPDATA%\Plutonium\storage\t4\plugins\`, the plugin will be loaded when you start up a dedicated server for Plutonium T4SP. - -# Credits -- momo5502 (https://github.com/momo5502) -- xensik (https://github.com/xensik/gsc-tool) -- fedddddd (https://github.com/fedddddd/t6-gsc-utils) -- VoroN (https://github.com/voron00/CoD2rev_Server) -- CoD4x team (https://github.com/callofduty4x/CoD4x_Server) -- id Software (https://github.com/id-Software/Quake-III-Arena) -- Treyarch -- Infinity Ward -- Activision +# T4SP-Server-Plugin +A plugin that has code that hopefully compiles and the game will load it to do things. Stability not guaranteed. + +Requires Git (https://git-scm.com/), Premake5 (https://premake.github.io/), and MSVC 2022 (https://visualstudio.microsoft.com/vs/features/cplusplus/) to build. + +# What does it do? +Nothing really right now, just detours and reimplements the entire GSC VM, for research purposes. + +# Installation +Move the `t4sp-server-plugin.dll` to `%LOCALAPPDATA%\Plutonium\storage\t4\plugins\`, the plugin will be loaded when you start up a dedicated server for Plutonium T4SP. + +# Credits +- momo5502 (https://github.com/momo5502) +- xensik (https://github.com/xensik/gsc-tool) +- fedddddd (https://github.com/fedddddd/t6-gsc-utils) +- VoroN (https://github.com/voron00/CoD2rev_Server) +- CoD4x team (https://github.com/callofduty4x/CoD4x_Server) +- id Software (https://github.com/id-Software/Quake-III-Arena) +- Treyarch +- Infinity Ward +- Activision diff --git a/deps/premake/asmjit.lua b/deps/premake/asmjit.lua index ee93259..850ce15 100644 --- a/deps/premake/asmjit.lua +++ b/deps/premake/asmjit.lua @@ -1,34 +1,34 @@ -asmjit = { - source = path.join(dependencies.basePath, "asmjit"), -} - -function asmjit.import() - links { "asmjit" } - asmjit.includes() -end - -function asmjit.includes() - includedirs { - path.join(asmjit.source, "src") - } - - defines { - "ASMJIT_STATIC" - } -end - -function asmjit.project() - project "asmjit" - language "C++" - - asmjit.includes() - - files { - path.join(asmjit.source, "src/**.cpp"), - } - - warnings "Off" - kind "StaticLib" -end - -table.insert(dependencies, asmjit) +asmjit = { + source = path.join(dependencies.basePath, "asmjit"), +} + +function asmjit.import() + links { "asmjit" } + asmjit.includes() +end + +function asmjit.includes() + includedirs { + path.join(asmjit.source, "src") + } + + defines { + "ASMJIT_STATIC" + } +end + +function asmjit.project() + project "asmjit" + language "C++" + + asmjit.includes() + + files { + path.join(asmjit.source, "src/**.cpp"), + } + + warnings "Off" + kind "StaticLib" +end + +table.insert(dependencies, asmjit) diff --git a/deps/premake/curl.lua b/deps/premake/curl.lua index 3d36749..36c23c4 100644 --- a/deps/premake/curl.lua +++ b/deps/premake/curl.lua @@ -1,73 +1,73 @@ -curl = { - source = path.join(dependencies.basePath, "curl"), -} - -function curl.import() - links { "curl" } - - filter "toolset:msc*" - links { "Crypt32.lib" } - filter {} - - curl.includes() -end - -function curl.includes() -filter "toolset:msc*" - includedirs { - path.join(curl.source, "include"), - } - - defines { - "CURL_STRICTER", - "CURL_STATICLIB", - "CURL_DISABLE_LDAP", - } -filter {} -end - -function curl.project() - if not os.istarget("windows") then - return - end - - project "curl" - language "C" - - curl.includes() - - includedirs { - path.join(curl.source, "lib"), - } - - files { - path.join(curl.source, "lib/**.c"), - path.join(curl.source, "lib/**.h"), - } - - defines { - "BUILDING_LIBCURL", - } - - filter "toolset:msc*" - - defines { - "USE_SCHANNEL", - "USE_WINDOWS_SSPI", - "USE_THREADS_WIN32", - } - - filter "toolset:not msc*" - - defines { - "USE_GNUTLS", - "USE_THREADS_POSIX", - } - - filter {} - - warnings "Off" - kind "StaticLib" -end - +curl = { + source = path.join(dependencies.basePath, "curl"), +} + +function curl.import() + links { "curl" } + + filter "toolset:msc*" + links { "Crypt32.lib" } + filter {} + + curl.includes() +end + +function curl.includes() +filter "toolset:msc*" + includedirs { + path.join(curl.source, "include"), + } + + defines { + "CURL_STRICTER", + "CURL_STATICLIB", + "CURL_DISABLE_LDAP", + } +filter {} +end + +function curl.project() + if not os.istarget("windows") then + return + end + + project "curl" + language "C" + + curl.includes() + + includedirs { + path.join(curl.source, "lib"), + } + + files { + path.join(curl.source, "lib/**.c"), + path.join(curl.source, "lib/**.h"), + } + + defines { + "BUILDING_LIBCURL", + } + + filter "toolset:msc*" + + defines { + "USE_SCHANNEL", + "USE_WINDOWS_SSPI", + "USE_THREADS_WIN32", + } + + filter "toolset:not msc*" + + defines { + "USE_GNUTLS", + "USE_THREADS_POSIX", + } + + filter {} + + warnings "Off" + kind "StaticLib" +end + table.insert(dependencies, curl) \ No newline at end of file diff --git a/deps/premake/gsl.lua b/deps/premake/gsl.lua index 7a2daf6..753a824 100644 --- a/deps/premake/gsl.lua +++ b/deps/premake/gsl.lua @@ -1,19 +1,19 @@ -gsl = { - source = path.join(dependencies.basePath, "GSL"), -} - -function gsl.import() - gsl.includes() -end - -function gsl.includes() - includedirs { - path.join(gsl.source, "include") - } -end - -function gsl.project() - -end - -table.insert(dependencies, gsl) +gsl = { + source = path.join(dependencies.basePath, "GSL"), +} + +function gsl.import() + gsl.includes() +end + +function gsl.includes() + includedirs { + path.join(gsl.source, "include") + } +end + +function gsl.project() + +end + +table.insert(dependencies, gsl) diff --git a/deps/premake/json.lua b/deps/premake/json.lua index e5eb493..c6d7c3a 100644 --- a/deps/premake/json.lua +++ b/deps/premake/json.lua @@ -1,19 +1,19 @@ -json = { - source = path.join(dependencies.basePath, "json"), -} - -function json.import() - json.includes() -end - -function json.includes() - includedirs { - path.join(json.source, "single_include/*") - } -end - -function json.project() - -end - -table.insert(dependencies, json) +json = { + source = path.join(dependencies.basePath, "json"), +} + +function json.import() + json.includes() +end + +function json.includes() + includedirs { + path.join(json.source, "single_include/*") + } +end + +function json.project() + +end + +table.insert(dependencies, json) diff --git a/deps/premake/minhook.lua b/deps/premake/minhook.lua index 396d4d3..059068f 100644 --- a/deps/premake/minhook.lua +++ b/deps/premake/minhook.lua @@ -1,31 +1,31 @@ -minhook = { - source = path.join(dependencies.basePath, "minhook"), -} - -function minhook.import() - links { "minhook" } - minhook.includes() -end - -function minhook.includes() - includedirs { - path.join(minhook.source, "include") - } -end - -function minhook.project() - project "minhook" - language "C" - - minhook.includes() - - files { - path.join(minhook.source, "src/**.h"), - path.join(minhook.source, "src/**.c"), - } - - warnings "Off" - kind "StaticLib" -end - -table.insert(dependencies, minhook) +minhook = { + source = path.join(dependencies.basePath, "minhook"), +} + +function minhook.import() + links { "minhook" } + minhook.includes() +end + +function minhook.includes() + includedirs { + path.join(minhook.source, "include") + } +end + +function minhook.project() + project "minhook" + language "C" + + minhook.includes() + + files { + path.join(minhook.source, "src/**.h"), + path.join(minhook.source, "src/**.c"), + } + + warnings "Off" + kind "StaticLib" +end + +table.insert(dependencies, minhook) diff --git a/deps/premake/minizip.lua b/deps/premake/minizip.lua index 4a5754b..52a4774 100644 --- a/deps/premake/minizip.lua +++ b/deps/premake/minizip.lua @@ -1,43 +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) +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) diff --git a/deps/premake/zlib.lua b/deps/premake/zlib.lua index 566a707..fffbdb1 100644 --- a/deps/premake/zlib.lua +++ b/deps/premake/zlib.lua @@ -1,39 +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) +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) diff --git a/generate.bat b/generate.bat index 93c595b..2410915 100644 --- a/generate.bat +++ b/generate.bat @@ -1,3 +1,3 @@ -@echo off -call git submodule update --init --recursive +@echo off +call git submodule update --init --recursive premake5.exe vs2022 \ No newline at end of file diff --git a/premake5.lua b/premake5.lua index 52c686c..564836b 100644 --- a/premake5.lua +++ b/premake5.lua @@ -1,125 +1,125 @@ -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 - -dependencies.load() - -workspace "t4sp-server-plugin" - location "./build" - objdir "%{wks.location}/obj/%{cfg.buildcfg}" - targetdir "%{wks.location}/bin/%{cfg.buildcfg}" - targetname "%{prj.name}" - - configurations { "Debug", "Release", } - - language "C++" - cppdialect "C++20" - - architecture "x86" - - systemversion "latest" - symbols "On" - staticruntime "On" - editandcontinue "Off" - warnings "Extra" - characterset "ASCII" - - defines { "_CRT_SECURE_NO_WARNINGS" } - - flags - { - "NoIncrementalLink", - "MultiProcessorCompile", - } - - filter "configurations:Release" - optimize "Full" - defines { "NDEBUG" } - flags { - "FatalCompileWarnings", - } - filter {} - - filter "configurations:Debug" - optimize "Debug" - defines { "DEBUG", "_DEBUG" } - filter {} - - startproject "t4sp-server-plugin" - - project "t4sp-server-plugin" - kind "SharedLib" - language "C++" - - files - { - "./src/**.h", - "./src/**.hpp", - "./src/**.cpp", - "./src/**.c", - "./src/**.asm" - } - - includedirs - { - "%{prj.location}/src", - "./src", - } - - resincludedirs - { - "$(ProjectDir)src" - } - - pchheader "stdinc.hpp" - pchsource "src/stdinc.cpp" - buildoptions { "/Zm100 -Zm100" } - - dependencies.imports() - - exceptionhandling ("Off") - - if _OPTIONS["copy-to"] then - postbuildcommands {"copy /y \"$(TargetPath)\" \"" .. _OPTIONS["copy-to"] .. "\""} - else - filter "configurations:Release" - postbuildcommands { - "if \"%COMPUTERNAME%\" == \"NEW-BUILT\" ( copy /y \"$(TargetPath)\" \"$(CODWAW_PATH)\\t4\\plugins\\\" )" - } - filter {} - - filter "configurations:Debug" - postbuildcommands { - "if \"%COMPUTERNAME%\" == \"NEW-BUILT\" ( copy /y \"$(TargetPath)\" \"$(CODWAW_PATH)\\t4staging\\plugins\\\" )" - } - filter {} - end - - group "Dependencies" +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 + +dependencies.load() + +workspace "t4sp-server-plugin" + location "./build" + objdir "%{wks.location}/obj/%{cfg.buildcfg}" + targetdir "%{wks.location}/bin/%{cfg.buildcfg}" + targetname "%{prj.name}" + + configurations { "Debug", "Release", } + + language "C++" + cppdialect "C++20" + + architecture "x86" + + systemversion "latest" + symbols "On" + staticruntime "On" + editandcontinue "Off" + warnings "Extra" + characterset "ASCII" + + defines { "_CRT_SECURE_NO_WARNINGS" } + + flags + { + "NoIncrementalLink", + "MultiProcessorCompile", + } + + filter "configurations:Release" + optimize "Full" + defines { "NDEBUG" } + flags { + "FatalCompileWarnings", + } + filter {} + + filter "configurations:Debug" + optimize "Debug" + defines { "DEBUG", "_DEBUG" } + filter {} + + startproject "t4sp-server-plugin" + + project "t4sp-server-plugin" + kind "SharedLib" + language "C++" + + files + { + "./src/**.h", + "./src/**.hpp", + "./src/**.cpp", + "./src/**.c", + "./src/**.asm" + } + + includedirs + { + "%{prj.location}/src", + "./src", + } + + resincludedirs + { + "$(ProjectDir)src" + } + + pchheader "stdinc.hpp" + pchsource "src/stdinc.cpp" + buildoptions { "/Zm100 -Zm100" } + + dependencies.imports() + + exceptionhandling ("Off") + + if _OPTIONS["copy-to"] then + postbuildcommands {"copy /y \"$(TargetPath)\" \"" .. _OPTIONS["copy-to"] .. "\""} + else + filter "configurations:Release" + postbuildcommands { + "if \"%COMPUTERNAME%\" == \"NEW-BUILT\" ( copy /y \"$(TargetPath)\" \"$(CODWAW_PATH)\\t4\\plugins\\\" )" + } + filter {} + + filter "configurations:Debug" + postbuildcommands { + "if \"%COMPUTERNAME%\" == \"NEW-BUILT\" ( copy /y \"$(TargetPath)\" \"$(CODWAW_PATH)\\t4staging\\plugins\\\" )" + } + filter {} + end + + group "Dependencies" dependencies.projects() \ No newline at end of file