116 Commits

Author SHA1 Message Date
ineed bots 38a860e4ce Merge branch 'main' of https://github.com/JezuzLizard/T4SP-Server-Plugin 2023-12-15 15:05:41 -06:00
ineed bots 3995bed200 update 2023-12-15 15:05:36 -06:00
INeedGames 3502a70933 Update README.md 2023-12-15 15:03:41 -06:00
ineed bots 1a33de617d Copy fix from cod2rev 2023-12-15 12:40:46 -06:00
INeedGames 59e57d05f7 Merge pull request #115 from JezuzLizard/dependabot/submodules/deps/json-a259ecc
Bump deps/json from `3780b41` to `a259ecc`
2023-12-15 11:46:28 -06:00
INeedGames 23f5c28c29 Merge pull request #116 from JezuzLizard/dependabot/submodules/deps/curl-78a1814
Bump deps/curl from `1e4cd51` to `78a1814`
2023-12-15 11:46:21 -06:00
dependabot[bot] 0e29d35407 Bump deps/curl from 1e4cd51 to 78a1814
Bumps [deps/curl](https://github.com/curl/curl) from `1e4cd51` to `78a1814`.
- [Release notes](https://github.com/curl/curl/releases)
- [Commits](https://github.com/curl/curl/compare/1e4cd519355b63b26a0a9ee1f125153bfcc4995e...78a1814b331c3535a785aa1c501203ad5a947838)

---
updated-dependencies:
- dependency-name: deps/curl
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-15 08:06:17 +00:00
dependabot[bot] a756ab6cc0 Bump deps/json from 3780b41 to a259ecc
Bumps [deps/json](https://github.com/nlohmann/json) from `3780b41` to `a259ecc`.
- [Release notes](https://github.com/nlohmann/json/releases)
- [Commits](https://github.com/nlohmann/json/compare/3780b41dd070436f3f55327b0a88f27a52e2dfa8...a259ecc51e1951e12f757ce17db958e9881e9c6c)

---
updated-dependencies:
- dependency-name: deps/json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-15 08:06:09 +00:00
INeedGames c15f3c21d5 Merge pull request #113 from JezuzLizard/dependabot/submodules/deps/asmjit-416f735
Bump deps/asmjit from `1a81158` to `416f735`
2023-12-14 23:14:50 -06:00
INeedGames 5a944f8711 Merge pull request #114 from JezuzLizard/dependabot/submodules/deps/curl-1e4cd51
Bump deps/curl from `02d81c5` to `1e4cd51`
2023-12-14 23:14:42 -06:00
dependabot[bot] e0728eb375 Bump deps/curl from 02d81c5 to 1e4cd51
Bumps [deps/curl](https://github.com/curl/curl) from `02d81c5` to `1e4cd51`.
- [Release notes](https://github.com/curl/curl/releases)
- [Commits](https://github.com/curl/curl/compare/02d81c5a6808e189cd20418274abccbd9bb1385d...1e4cd519355b63b26a0a9ee1f125153bfcc4995e)

---
updated-dependencies:
- dependency-name: deps/curl
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-14 07:43:39 +00:00
dependabot[bot] bafc637be8 Bump deps/asmjit from 1a81158 to 416f735
Bumps [deps/asmjit](https://github.com/asmjit/asmjit) from `1a81158` to `416f735`.
- [Commits](https://github.com/asmjit/asmjit/compare/1a81158e8bee38a8be9fdd5e444c9ee28390c3c7...416f7356967c1f66784dc1580fe157f9406d8bff)

---
updated-dependencies:
- dependency-name: deps/asmjit
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-13 07:16:58 +00:00
INeedGames 7da012fdf3 Merge pull request #111 from JezuzLizard/dependabot/submodules/deps/curl-02d81c5
Bump deps/curl from `f899e91` to `02d81c5`
2023-12-12 16:19:21 -06:00
INeedGames d9c3b7cab5 Merge pull request #108 from JezuzLizard/dependabot/submodules/deps/asmjit-1a81158
Bump deps/asmjit from `6a13a93` to `1a81158`
2023-12-12 16:19:08 -06:00
dependabot[bot] 8a36e02fdd Bump deps/curl from f899e91 to 02d81c5
Bumps [deps/curl](https://github.com/curl/curl) from `f899e91` to `02d81c5`.
- [Release notes](https://github.com/curl/curl/releases)
- [Commits](https://github.com/curl/curl/compare/f899e914315d220ecdc5fa976c0a569d0c25269f...02d81c5a6808e189cd20418274abccbd9bb1385d)

---
updated-dependencies:
- dependency-name: deps/curl
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-12 07:41:05 +00:00
dependabot[bot] 944bab5e5c Bump deps/asmjit from 6a13a93 to 1a81158
Bumps [deps/asmjit](https://github.com/asmjit/asmjit) from `6a13a93` to `1a81158`.
- [Commits](https://github.com/asmjit/asmjit/compare/6a13a935d11ca45e2c220e143fe9a495e5ae4269...1a81158e8bee38a8be9fdd5e444c9ee28390c3c7)

---
updated-dependencies:
- dependency-name: deps/asmjit
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-08 07:14:33 +00:00
INeedGames 8ca8002067 Merge pull request #107 from JezuzLizard/dependabot/submodules/deps/curl-f899e91
Bump deps/curl from `4528690` to `f899e91`
2023-12-07 10:59:19 -06:00
INeedGames afc01a05e3 Merge pull request #106 from JezuzLizard/dependabot/submodules/deps/json-3780b41
Bump deps/json from `546370c` to `3780b41`
2023-12-07 10:59:10 -06:00
INeedGames 8cb282da97 Merge pull request #102 from JezuzLizard/dependabot/submodules/deps/asmjit-6a13a93
Bump deps/asmjit from `f1ea8a4` to `6a13a93`
2023-12-07 10:59:01 -06:00
INeedGames 0327434187 Merge pull request #95 from JezuzLizard/dependabot/submodules/deps/minhook-f5485b8
Bump deps/minhook from `49d03ad` to `f5485b8`
2023-12-07 10:58:53 -06:00
INeedGames b3b693a56e Merge pull request #85 from JezuzLizard/dependabot/submodules/deps/zlib-643e17b
Bump deps/zlib from `04f42ce` to `643e17b`
2023-12-07 10:58:43 -06:00
INeedGames 347033f424 Merge pull request #59 from JezuzLizard/dependabot/submodules/deps/GSL-e64c97f
Bump deps/GSL from `43d60c5` to `e64c97f`
2023-12-07 10:58:34 -06:00
INeedGames 4c78d6fe41 Merge pull request #51 from JezuzLizard/dependabot/submodules/deps/libtomcrypt-7e863d2
Bump deps/libtomcrypt from `b96e96c` to `7e863d2`
2023-12-07 10:58:25 -06:00
INeedGames 33b6006a34 Merge pull request #14 from JezuzLizard/dependabot/submodules/deps/libtommath-8314bde
Bump deps/libtommath from `7f96509` to `8314bde`
2023-12-07 10:58:15 -06:00
dependabot[bot] 98b2c3f4d6 Bump deps/curl from 4528690 to f899e91
Bumps [deps/curl](https://github.com/curl/curl) from `4528690` to `f899e91`.
- [Release notes](https://github.com/curl/curl/releases)
- [Commits](https://github.com/curl/curl/compare/4528690cd51e5445df74aef8f83470a602683797...f899e914315d220ecdc5fa976c0a569d0c25269f)

---
updated-dependencies:
- dependency-name: deps/curl
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-07 07:28:09 +00:00
dependabot[bot] beb90edc3d Bump deps/json from 546370c to 3780b41
Bumps [deps/json](https://github.com/nlohmann/json) from `546370c` to `3780b41`.
- [Release notes](https://github.com/nlohmann/json/releases)
- [Commits](https://github.com/nlohmann/json/compare/546370c9e778d99e7176641123e5cc1d0b62acab...3780b41dd070436f3f55327b0a88f27a52e2dfa8)

---
updated-dependencies:
- dependency-name: deps/json
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-07 07:28:01 +00:00
dependabot[bot] df9ef00a64 Bump deps/asmjit from f1ea8a4 to 6a13a93
Bumps [deps/asmjit](https://github.com/asmjit/asmjit) from `f1ea8a4` to `6a13a93`.
- [Commits](https://github.com/asmjit/asmjit/compare/f1ea8a46c3f2bce5c51f290050c9d194668206bf...6a13a935d11ca45e2c220e143fe9a495e5ae4269)

---
updated-dependencies:
- dependency-name: deps/asmjit
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-04 07:22:46 +00:00
ineed bots 1f0717edef fix double slashes 2023-12-03 18:13:22 -06:00
ineed bots 7a82be782d update count 2023-12-03 17:53:21 -06:00
ineed bots f0c95340bf Fixed up the builtin 2023-12-03 17:43:40 -06:00
ineed bots 4843c61e2e Merge branch 'main' of https://github.com/JezuzLizard/T4SP-Server-Plugin 2023-12-03 17:19:00 -06:00
ineed bots b79b776f63 add fs_listfiles 2023-12-03 17:18:54 -06:00
INeedGames d1a0277861 Update README.md 2023-12-03 15:35:03 -06:00
ineed bots 4963a9180a largest gsc string is 65535, but u cant concat gsc strings > 8191 chars, ull get an error 2023-12-02 15:58:56 -06:00
ineed bots 56e8c485af Final the fileio doc 2023-12-01 01:22:45 -06:00
ineed bots 9648a38fbe more explain 2023-12-01 01:15:54 -06:00
ineed bots 3fdcf3261d better exmaple 2023-12-01 01:08:36 -06:00
ineed bots deed3b66f5 More docs 2023-12-01 01:02:48 -06:00
ineed bots fce9fcee51 Merge branch 'main' of https://github.com/JezuzLizard/T4SP-Server-Plugin 2023-11-30 23:14:56 -06:00
ineed bots cfd4640035 less scr errors 2023-11-30 23:14:51 -06:00
INeedGames 827d7c955e Update README.md 2023-11-30 22:58:15 -06:00
ineed bots c5eaf6f961 fix comp 2023-11-30 20:20:58 -06:00
ineed bots eec84e91ff fixes 2023-11-30 20:20:16 -06:00
ineed bots 3f406c26e7 check if it already stars for it 2023-11-30 20:12:11 -06:00
ineed bots 18659448d7 Add cod4x file io gsc funcs 2023-11-30 19:57:07 -06:00
dependabot[bot] 3bff917ce3 Bump deps/minhook from 49d03ad to f5485b8
Bumps [deps/minhook](https://github.com/TsudaKageyu/minhook) from `49d03ad` to `f5485b8`.
- [Release notes](https://github.com/TsudaKageyu/minhook/releases)
- [Commits](https://github.com/TsudaKageyu/minhook/compare/49d03ad118cf7f6768c79a8f187e14b8f2a07f94...f5485b8454544c2f034c78f8f127c1d03dea3636)

---
updated-dependencies:
- dependency-name: deps/minhook
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-27 07:17:52 +00:00
dependabot[bot] d6a6a096fd Bump deps/zlib from 04f42ce to 643e17b
Bumps [deps/zlib](https://github.com/madler/zlib) from `04f42ce` to `643e17b`.
- [Release notes](https://github.com/madler/zlib/releases)
- [Commits](https://github.com/madler/zlib/compare/04f42ceca40f73e2978b50e93806c2a18c1281fc...643e17b7498d12ab8d15565662880579692f769d)

---
updated-dependencies:
- dependency-name: deps/zlib
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-11-15 07:48:12 +00:00
dependabot[bot] c147f3fbe2 Bump deps/GSL from 43d60c5 to e64c97f
Bumps [deps/GSL](https://github.com/microsoft/GSL) from `43d60c5` to `e64c97f`.
- [Release notes](https://github.com/microsoft/GSL/releases)
- [Commits](https://github.com/microsoft/GSL/compare/43d60c5e3891dab6491a76d0bac554a4a89d57f6...e64c97fc2cfc11992098bb38eda932de275e3f4d)

---
updated-dependencies:
- dependency-name: deps/GSL
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-19 08:00:25 +00:00
ineed bots 8ea93169da Fix this issue 2023-10-13 00:43:03 -06:00
ineed bots f22dc8d151 push syms 2023-10-12 13:43:16 -06:00
dependabot[bot] 7da463ccd3 Bump deps/libtomcrypt from b96e96c to 7e863d2
Bumps [deps/libtomcrypt](https://github.com/libtom/libtomcrypt) from `b96e96c` to `7e863d2`.
- [Release notes](https://github.com/libtom/libtomcrypt/releases)
- [Commits](https://github.com/libtom/libtomcrypt/compare/b96e96cf8b22a931e8e91098ac37bc72f9e2f033...7e863d21429f94ed6a720e24499a12a3f852bb31)

---
updated-dependencies:
- dependency-name: deps/libtomcrypt
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-10 07:23:32 +00:00
ineed bots e6a0913893 Some struct updates 2023-09-26 16:49:50 -06:00
ineed bots 069442dca9 cleanup 2023-09-22 13:02:20 -06:00
ineed bots 9b10a3e32f Add this func 2023-09-22 11:31:54 -06:00
ineed bots 7e87e04413 Add scr init callback 2023-09-20 14:20:39 -06:00
ineed bots fc336c490a Grealy improve boot times 2023-09-18 01:04:23 -06:00
ineed bots c5195b4983 Fix 2023-09-18 00:52:18 -06:00
ineed bots c1adb9aee3 Revert "Massively improve bootup times"
This reverts commit df2440a3ba.
2023-09-18 00:51:26 -06:00
dependabot[bot] 7503e8988b Bump deps/libtommath from 7f96509 to 8314bde
Bumps [deps/libtommath](https://github.com/libtom/libtommath) from `7f96509` to `8314bde`.
- [Release notes](https://github.com/libtom/libtommath/releases)
- [Commits](https://github.com/libtom/libtommath/compare/7f96509df1a6b44867bbda56bbf2cb92524be8ef...8314bde5e5c8e5d9331460130a9d1066e324f091)

---
updated-dependencies:
- dependency-name: deps/libtommath
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-18 01:08:59 +00:00
ineed bots df2440a3ba Massively improve bootup times 2023-09-17 18:52:02 -06:00
ineed bots 5d0e5e4227 Fix warning 2023-09-17 01:19:39 -06:00
ineed bots d976434e38 Verified 2023-09-17 01:00:44 -06:00
ineed bots 78b82978bc more enums 2023-09-17 00:15:05 -06:00
ineed bots 30332a743c move 2023-09-16 23:52:46 -06:00
ineed bots 1f7a75ca4c Some refactor and more enums 2023-09-16 23:38:00 -06:00
ineed bots 1b13ebbb35 more ENUMs 2023-09-16 19:52:08 -06:00
ineed bots f8ba9185ab More reorganization of the cases 2023-09-16 19:07:53 -06:00
ineed bots fe99318dce fix warning, fixing release build 2023-09-16 17:45:31 -06:00
ineed bots c380983b34 Refactor and make sure arrays are empty if they are 2023-09-16 17:38:44 -06:00
ineed bots 320c21fb66 some cleanup with ast traveral and json 2023-09-16 17:06:06 -06:00
ineed bots 24762485e0 fix ENUM_expression_list printing 2023-09-16 17:00:53 -06:00
ineed bots cdd7b2d656 json ast 2023-09-16 16:49:26 -06:00
ineed bots 63412a7017 add some ast dumping code 2023-09-15 23:39:09 -06:00
ineed bots 7f0403e487 Fix this issue 2023-09-15 18:27:48 -06:00
ineed bots 6b612395b5 Add our custom gsc funcs 2023-09-15 18:08:23 -06:00
ineed bots 2e50e3274d Cleanup and move gsc dump stuff 2023-09-15 17:49:25 -06:00
ineed bots 1f66cb6a43 Label this changes 2023-09-15 17:43:02 -06:00
ineed bots d8e10441ec Add pluto patches to compiler 2023-09-15 17:41:24 -06:00
ineed bots 15309fc2c0 Add compiler decomp 2023-09-15 16:35:58 -06:00
ineed bots bd25b6429b Fix this symbol 2023-09-14 13:16:38 -06:00
ineed bots 9b19bc56ac fix this symbol 2023-09-14 13:10:17 -06:00
ineed bots bde17390e5 Fix this symbol (again) 2023-09-13 00:50:17 -06:00
ineed bots a49298d915 Fix this symbol 2023-09-11 21:12:35 -06:00
ineed bots 2c922da647 Add yyac code 2023-09-11 17:18:53 -06:00
ineed bots 6627aff577 cleanup 2023-09-11 17:02:57 -06:00
ineed bots a970d02d98 Fix these enums 2023-09-10 20:49:09 -06:00
ineed bots a38c4ea524 Remove this test 2023-09-10 18:45:15 -06:00
ineed bots 93a9fd55d5 Reenable c++ exceptions 2023-09-10 18:33:43 -06:00
ineed bots 623d0001a9 fix this test 2023-09-10 18:31:34 -06:00
ineed bots 64f8dfca8d some test 2023-09-10 15:26:29 -06:00
ineed bots 84c212ed2b add sqlite (xd!) 2023-09-10 15:07:25 -06:00
ineed bots ff218452ec add sqlite (xd!) 2023-09-10 15:07:18 -06:00
ineed bots b830aba980 add csv test 2023-09-10 14:16:37 -06:00
ineed bots 14b96a0082 add to build 2023-09-10 14:09:51 -06:00
ineed bots c66cb27032 add csv parser dep 2023-09-10 14:09:47 -06:00
ineed bots c35a0e9bb2 update PlayerKeyState and Console structs 2023-09-10 13:49:07 -06:00
ineed bots e60c6c756b A little bit more cleanup 2023-09-10 13:36:05 -06:00
ineed bots 644097748c fix up data 2023-09-10 13:23:09 -06:00
ineed bots af697a4460 defines 2023-09-08 15:15:17 -06:00
ineed bots b99a335d96 Merge branch 'main' of https://github.com/JezuzLizard/T4SP-Server-Plugin 2023-09-08 13:10:17 -06:00
ineed bots a21b76b0a3 Added yacc and animtree detours 2023-09-08 13:10:08 -06:00
ineed bots d57945fece Added compiler wrappers and detours 2023-09-08 12:55:24 -06:00
INeedGames 81261522c3 Create LICENSE 2023-09-07 14:26:08 -06:00
ineed bots 4bddc60b05 cleanup 2023-09-07 14:09:38 -06:00
ineed bots d657f8ac65 add debug history 2023-09-06 00:15:41 -06:00
ineed bots 6b3996416a Added more debug dumping for gsc vm 2023-09-05 23:57:03 -06:00
ineed bots bd128a1366 Fix the endswitch opcode 2023-09-05 23:52:16 -06:00
ineed bots 601a661fe0 Some debug stuff 2023-09-05 01:19:27 -06:00
ineed bots 5e51712a02 added remaining pluto patches to our decomp 2023-09-04 14:17:02 -06:00
ineed bots cb7619851c small clean 2023-09-03 22:06:45 -06:00
ineed bots db053c05d2 gsc hook safe set 2023-09-01 20:05:59 -06:00
ineed bots ca306d785b Safe pluto hooks 2023-09-01 17:10:57 -06:00
ineed bots 8c36a218de Added pluto code 2023-09-01 14:57:46 -06:00
ineed bots 30ce0ad8eb Fix line endings and tabs 2023-09-01 11:18:24 -06:00
ineed bots bb216441bf fix line endings and tabs 2023-09-01 10:50:11 -06:00
ineed bots b17a56a7fd update hooking 2023-09-01 01:11:55 -06:00
103 changed files with 40069 additions and 23035 deletions
+3 -1
View File
@@ -58,6 +58,7 @@ jobs:
name: ${{matrix.configuration}} binaries
path: |
build/bin/${{matrix.configuration}}/t4sp-server-plugin.dll
build/bin/${{matrix.configuration}}/t4sp-server-plugin.pdb
deploy:
name: Deploy release
@@ -81,4 +82,5 @@ jobs:
prerelease: false
draft: true
files: |
t4sp-server-plugin.dll
t4sp-server-plugin.dll
t4sp-server-plugin.pdb
+149 -149
View File
@@ -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
+31 -25
View File
@@ -1,25 +1,31 @@
[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
[submodule "deps/csv-parser"]
path = deps/csv-parser
url = https://github.com/AriaFallah/csv-parser
[submodule "deps/SQLiteCpp"]
path = deps/SQLiteCpp
url = https://github.com/SRombauts/SQLiteCpp
+661
View File
@@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.
+118 -18
View File
@@ -1,18 +1,118 @@
# 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.
# Features
Detours and reimplements the entire GSC VM + compiler.
Adds custom GSC functions.
## FileIO
This plugin provides FileIO interface to GSC for reading and writing files, this is exact to [CoD4x's](https://github.com/callofduty4x/CoD4x_Server/blob/master/scriptdocumentation/script_functions_reference.md#file-operations) interface.
However, all reads and writes will take place strictly and only in the `scriptdata` folder, no up directory traversal allowed.
All files will be closed upon GSC restart (map_restart or fast_restart or missionfailed, etc), only a maximum of 10 files may be opened at once.
* `<bool> FS_TestFile(<filename string>)` Returns `true` if the file exists, `false` otherwise.
* `<bool> FS_Remove(<filename string>)` Deletes the file, return `true` if successful, `false` otherwise.
```gsc
// test to see if "scriptdata/test.txt" file exists
if (FS_TestFile("test.txt")) // not a typo, all file io will take place inside the "scriptdata" folder
{
PrintConsole("Found test.txt!");
// delete it!
if (FS_Remove("test.txt"))
{
PrintConsole("test.txt was deleted!");
}
}
```
* `FS_FCloseAll()` Closes every full file.
```gsc
// open some files
FS_FCloseAll(); // close them all
```
* `<int> FS_FOpen(<filename string>, <mode string>)` Tries to open the file, mode must be one of `read`, `write` (clears the file), `append` (appends to the file), returns the filehandle. Will return `0` if failed to open.
* `FS_FClose(<filehandle int>)` Closes the file pointed by the filehandle given, which was returned from `FS_FOpen`.
```gsc
// opens "scriptdata/test.txt", all io will take place inside the "scriptdata" folder
f = FS_FOpen("test.txt", "read"); // can be "read" "write", or "append"
if (!f)
{
PrintConsole("test.txt failed to be opened for reading!");
}
else
{
// do stuff with the file
FS_FClose(f); // make sure to close it
}
```
* `<string> FS_ReadLine(<filehandle int>)` Reads a line from the file pointed by the filehandle, removes the newline char. Returns `undefined` when nothing is left to read. Will not read more than 65536 characters at once. Filehandle must be opened for reading.
* `<string> FS_Read(<filehandle int>, <bytes int>(optional))` Reads number of bytes from the file. If bytes is `undefined`, reads the entire file. No more than 65536 characters will be read at once. Returns `undefined` if there are nothing left to read.
```gsc
// open the file for reading
line = FS_ReadLine(f);
while (isDefined(line))
{
// do something with line
line = FS_ReadLine(f);
}
// entire file is read
// close the file
```
* `<bool> FS_WriteLine(<filehandle int>, <contents string>)` Writes to the file pointed by the filehandle. Appends a newline character. Returns `true` if successful, `false` otherwise. Filehandle must be opened for writing.
* `<bool> FS_Write(<filehandle int>, <contents string>)` Same as above, does not add a newline character.
```gsc
// open the file for writing
FS_WriteLine(f, "writing some text with newline added");
FS_Write(f, "no newline here");
FS_Write(f, "i manually add a newline\n");
// close the file
```
* `<array of strings> FS_ListFiles(<folder string>)` Returns a list of files inside of the folder given.
```gsc
folder = "testfolder/";
files = FS_ListFiles(folder);
for (i = 0; i < files.size; i++)
{
filename = files[i];
// do something with the filename
filepath = folder + filename;
}
```
# 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
Vendored
+1 -1
Submodule deps/GSL updated: 43d60c5e38...e64c97fc2c
Vendored Submodule
+1
Submodule deps/SQLiteCpp added at bcb4c78fed
Vendored
+1 -1
Vendored Submodule
+1
Submodule deps/csv-parser added at 4965c9f320
Vendored
+1 -1
Submodule deps/curl updated: 4528690cd5...78a1814b33
Vendored
+1 -1
Submodule deps/json updated: 546370c9e7...a259ecc51e
+1 -1
+34
View File
@@ -0,0 +1,34 @@
SQLiteCpp = {
source = path.join(dependencies.basePath, "SQLiteCpp"),
}
function SQLiteCpp.import()
links { "SQLiteCpp" }
SQLiteCpp.includes()
end
function SQLiteCpp.includes()
includedirs {
path.join(SQLiteCpp.source, "include"),
path.join(SQLiteCpp.source, "sqlite3")
}
end
function SQLiteCpp.project()
project "SQLiteCpp"
language "C"
SQLiteCpp.includes()
files {
path.join(path.join(SQLiteCpp.source, "src"), "**.cpp"),
path.join(path.join(SQLiteCpp.source, "include"), "**.h"),
path.join(path.join(SQLiteCpp.source, "sqlite3"), "**.c"),
path.join(path.join(SQLiteCpp.source, "sqlite3"), "**.h")
}
warnings "Off"
kind "StaticLib"
end
table.insert(dependencies, SQLiteCpp)
+34 -34
View File
@@ -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)
+20
View File
@@ -0,0 +1,20 @@
csv_parser = {
source = path.join(dependencies.basePath, "csv-parser"),
}
function csv_parser.import()
dependson "csv-parser"
csv_parser.includes()
end
function csv_parser.includes()
includedirs {
csv_parser.source
}
end
function csv_parser.project()
end
table.insert(dependencies, csv_parser)
+72 -72
View File
@@ -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)
+19 -19
View File
@@ -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)
+19 -19
View File
@@ -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)
+31 -31
View File
@@ -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)
+43 -43
View File
@@ -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)
+39 -39
View File
@@ -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)
Vendored
+1 -1
Submodule deps/zlib updated: 04f42ceca4...643e17b749
+2 -2
View File
@@ -1,3 +1,3 @@
@echo off
call git submodule update --init --recursive
@echo off
call git submodule update --init --recursive
premake5.exe vs2022
+122 -124
View File
@@ -1,125 +1,123 @@
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()
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()
@@ -1,5 +1,6 @@
#pragma once
#include "cscr_compiler.hpp"
#include "cscr_main.hpp"
#include "cscr_memorytree.hpp"
#include "cscr_parser.hpp"
@@ -9,3 +10,4 @@
#include "cscr_tempmemory.hpp"
#include "cscr_variable.hpp"
#include "cscr_vm.hpp"
#include "cscr_yacc.hpp"
File diff suppressed because it is too large Load Diff
+202
View File
@@ -0,0 +1,202 @@
#pragma once
namespace codsrc
{
void RemoveRefToValue(game::scriptInstance_t inst, game::VariableValue* value);
void Scr_CompileRemoveRefToString(game::scriptInstance_t inst, unsigned int stringVal);
void EmitCanonicalString(game::scriptInstance_t inst, unsigned int stringVal);
void CompileTransferRefToString(unsigned int stringValue, game::scriptInstance_t inst, unsigned int user);
void EmitOpcode(game::scriptInstance_t inst, game::OpcodeVM op, int offset, int callType);
void EmitEnd(game::scriptInstance_t inst);
void EmitReturn(game::scriptInstance_t inst);
void EmitCodepos(game::scriptInstance_t inst, int codepos);
void EmitShort(game::scriptInstance_t inst, int value);
void EmitByte(game::scriptInstance_t inst, int value);
void EmitGetInteger(game::scriptInstance_t inst, int value, game::sval_u sourcePos);
void EmitGetFloat(game::scriptInstance_t inst, float value, game::sval_u sourcePos);
void EmitAnimTree(game::scriptInstance_t inst, game::sval_u sourcePos);
int Scr_FindLocalVarIndex(game::scriptInstance_t inst, unsigned int name, game::sval_u sourcePos, int create, game::scr_block_s* block);
void EmitCreateLocalVars(game::scriptInstance_t inst, game::scr_block_s* block);
void EmitRemoveLocalVars(game::scriptInstance_t inst, game::scr_block_s* outerBlock, game::scr_block_s* block);
void EmitNOP2(game::scr_block_s* block, game::scriptInstance_t inst, int lastStatement, unsigned int endSourcePos);
void Scr_InitFromChildBlocks(game::scr_block_s** childBlocks, int childCount, game::scr_block_s* block);
void Scr_AppendChildBlocks(game::scr_block_s* block, game::scr_block_s** childBlocks, int childCount);
void Scr_MergeChildBlocks(game::scr_block_s** childBlocks, int childCount, game::scr_block_s* block);
void Scr_TransferBlock(game::scr_block_s* to, game::scr_block_s* from);
void EmitSafeSetVariableField(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos);
void EmitSafeSetWaittillVariableField(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos);
void EmitGetString(unsigned int value, game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitGetIString(unsigned int value, game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitGetVector(const float* value, game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitValue(game::scriptInstance_t inst, game::VariableCompileValue* constValue);
void Scr_PushValue(game::scriptInstance_t inst, game::VariableCompileValue* constValue);
void EmitCastBool(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitBoolNot(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitBoolComplement(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitSize(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos);
void EmitSelf(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitLevel(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitGame(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitAnim(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitSelfObject(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitLevelObject(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitAnimObject(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitLocalVariable(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos);
void EmitLocalVariableRef(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos);
void Scr_RegisterLocalVar(unsigned int name, game::sval_u sourcePos, game::scr_block_s* block);
void EmitGameRef(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitClearArray(game::scriptInstance_t inst, game::sval_u sourcePos, game::sval_u indexSourcePos);
void EmitEmptyArray(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitAnimation(game::scriptInstance_t inst, game::sval_u anim, game::sval_u sourcePos);
void EmitFieldVariable(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u field, game::sval_u sourcePos);
void EmitClearFieldVariable(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u field, game::sval_u sourcePos, game::sval_u rhsSourcePos);
void EmitObject(game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos);
void EmitDecTop(game::scriptInstance_t inst);
void EmitCastFieldObject(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitArrayVariable(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u index, game::sval_u sourcePos, game::sval_u indexSourcePos);
void EmitArrayVariableRef(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u index, game::sval_u sourcePos, game::sval_u indexSourcePos);
void EmitClearArrayVariable(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u index, game::sval_u sourcePos, game::sval_u indexSourcePos);
void EmitVariableExpression(game::scriptInstance_t inst, game::sval_u expr, game::scr_block_s* block);
int EmitExpressionList(game::scriptInstance_t inst, game::sval_u exprlist, game::scr_block_s* block);
void AddExpressionListOpcodePos(game::scriptInstance_t inst, game::sval_u exprlist);
void AddFilePrecache(game::scriptInstance_t inst, unsigned int filename, unsigned int sourcePos, bool include, unsigned int* filePosId, unsigned int* fileCountId);
void EmitFunction(game::scriptInstance_t inst, game::sval_u func, game::sval_u sourcePos);
void EmitGetFunction(game::scriptInstance_t inst, game::sval_u func, game::sval_u sourcePos);
int AddFunction(game::scriptInstance_t inst, int func);
void EmitPostScriptFunction(game::scriptInstance_t inst, game::sval_u func, int param_count, int bMethod, game::sval_u nameSourcePos);
void EmitPostScriptFunctionPointer(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, int param_count, int bMethod, game::sval_u nameSourcePos, game::sval_u sourcePos);
void EmitPostScriptThread(game::scriptInstance_t inst, game::sval_u func, int param_count, int bMethod, game::sval_u sourcePos);
void EmitPostScriptThreadPointer(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, int param_count, int bMethod, game::sval_u sourcePos);
void EmitPostScriptFunctionCall(game::scriptInstance_t inst, int bMethod, int param_count, game::sval_u func_name, game::sval_u nameSourcePos, game::scr_block_s* block);
void EmitPostScriptThreadCall(game::scriptInstance_t inst, int isMethod, int param_count, game::sval_u func_name, game::sval_u sourcePos, game::sval_u nameSourcePos, game::scr_block_s* block);
void EmitPreFunctionCall(game::scriptInstance_t inst);
void EmitPostFunctionCall(game::scriptInstance_t inst, int bMethod, game::sval_u func_name, int param_count, game::scr_block_s* block);
void Scr_BeginDevScript(game::scriptInstance_t isnt, int* type, char** savedPos);
void Scr_EndDevScript(game::scriptInstance_t inst, char** savedPos);
void EmitCallBuiltinOpcode(game::scriptInstance_t inst, int param_count, game::sval_u sourcePos);
void EmitCallBuiltinMethodOpcode(game::scriptInstance_t inst, int param_count, game::sval_u sourcePos);
void EmitCall(game::scriptInstance_t inst, game::sval_u func_name, game::sval_u params, int bStatement, game::scr_block_s* block);
void EmitMethod(game::scriptInstance_t inst, game::sval_u expr, game::sval_u func_name, game::sval_u params, game::sval_u methodSourcePos, int bStatement, game::scr_block_s* block);
void LinkThread(game::scriptInstance_t inst, unsigned int threadCountId, game::VariableValue* pos, int allowFarCall);
void LinkFile(game::scriptInstance_t inst, unsigned int filePosId, unsigned int fileCountId);
void CheckThreadPosition(game::scriptInstance_t inst, unsigned int posId, unsigned int name, unsigned int sourcePos);
void EmitCallExpression(game::scriptInstance_t inst, game::scr_block_s* block, game::sval_u expr, int bStatement);
void EmitCallExpressionFieldObject(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr);
void Scr_CreateVector(game::scriptInstance_t inst, game::VariableCompileValue* constValue, game::VariableValue* value);
bool EvalPrimitiveExpressionList(game::scriptInstance_t inst, game::sval_u exprlist, game::sval_u sourcePos, game::VariableCompileValue* constValue);
bool EmitOrEvalPrimitiveExpressionList(game::scriptInstance_t inst, game::sval_u exprlist, game::sval_u sourcePos, game::VariableCompileValue* constValue, game::scr_block_s* a5);
void EmitExpressionListFieldObject(game::scriptInstance_t inst, game::sval_u exprlist, game::sval_u sourcePos, game::scr_block_s* block);
bool EvalPrimitiveExpression(game::scriptInstance_t inst, game::sval_u expr, game::VariableCompileValue* constValue);
bool EmitOrEvalPrimitiveExpression(game::scriptInstance_t inst, game::sval_u expr, game::VariableCompileValue* constValue, game::scr_block_s* block);
void EmitBoolOrExpression(game::scriptInstance_t inst, game::sval_u expr1, game::sval_u expr2, game::sval_u expr1sourcePos, game::sval_u expr2sourcePos, game::scr_block_s* block);
void EmitBoolAndExpression(game::scriptInstance_t inst, game::sval_u expr1, game::sval_u expr2, game::sval_u expr1sourcePos, game::sval_u expr2sourcePos, game::scr_block_s* a6);
bool EvalBinaryOperatorExpression(game::scriptInstance_t inst, game::sval_u expr1, game::sval_u expr2, game::sval_u opcode, game::sval_u sourcePos, game::VariableCompileValue* constValue);
bool EmitOrEvalBinaryOperatorExpression(game::scriptInstance_t inst, game::sval_u expr1, game::sval_u expr2, game::sval_u opcode, game::sval_u sourcePos, game::VariableCompileValue* constValue, game::scr_block_s* a8);
void EmitBinaryEqualsOperatorExpression(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u lhs, game::sval_u rhs, game::sval_u opcode, game::sval_u sourcePos);
void Scr_CalcLocalVarsVariableExpressionRef(game::scr_block_s* block, game::sval_u expr);
bool EvalExpression(game::VariableCompileValue* constValue, game::scriptInstance_t inst, game::sval_u expr);
bool EmitOrEvalExpression(game::scriptInstance_t inst, game::sval_u expr, game::VariableCompileValue* constValue, game::scr_block_s* block);
void EmitExpression(game::scriptInstance_t inst, game::sval_u expr, game::scr_block_s* block);
void EmitVariableExpressionRef(game::scriptInstance_t inst, game::sval_u expr, game::scr_block_s* block);
void EmitArrayPrimitiveExpressionRef(game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos, game::scr_block_s* block);
void Scr_CalcLocalVarsArrayVariableRef(game::sval_u expr, game::scr_block_s* block);
void EmitPrimitiveExpressionFieldObject(game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos, game::scr_block_s* block);
void ConnectBreakStatements(game::scriptInstance_t inst);
void ConnectContinueStatements(game::scriptInstance_t inst);
bool EmitClearVariableExpression(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u rhsSourcePos);
void EmitAssignmentStatement(game::scriptInstance_t inst, game::sval_u lhs, game::sval_u rhs, game::sval_u sourcePos, game::sval_u rhsSourcePos, game::scr_block_s* block);
void EmitCallExpressionStatement(game::scriptInstance_t inst, game::scr_block_s* block, game::sval_u expr);
void EmitReturnStatement(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos);
void EmitWaitStatement(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos, game::sval_u waitSourcePos);
void EmitWaittillFrameEnd(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitIfStatement(game::scriptInstance_t inst, game::sval_u expr, game::sval_u stmt, game::sval_u sourcePos, int lastStatement, unsigned int endSourcePos, game::scr_block_s* block, game::sval_u* ifStatBlock);
void Scr_CalcLocalVarsIfStatement(game::scriptInstance_t inst, game::sval_u stmt, game::scr_block_s* block, game::sval_u* ifStatBlock);
void EmitIfElseStatement(game::scriptInstance_t inst, game::sval_u expr, game::sval_u stmt1, game::sval_u stmt2, game::sval_u sourcePos, game::sval_u elseSourcePos, int lastStatement, unsigned int endSourcePos, game::scr_block_s* block, game::sval_u* ifStatBlock, game::sval_u* elseStatBlock);
void Scr_CalcLocalVarsIfElseStatement(game::scriptInstance_t inst, game::sval_u stmt1, game::sval_u stmt2, game::scr_block_s* block, game::sval_u* ifStatBlock, game::sval_u* elseStatBlock);
void Scr_AddBreakBlock(game::scriptInstance_t inst, game::scr_block_s* block);
void Scr_AddContinueBlock(game::scriptInstance_t inst, game::scr_block_s* block);
void EmitWhileStatement(game::scriptInstance_t inst, game::sval_u expr, game::sval_u stmt, game::sval_u sourcePos, game::sval_u whileSourcePos, game::scr_block_s* block, game::sval_u* whileStatBlock);
void Scr_CalcLocalVarsWhileStatement(game::scriptInstance_t inst, game::sval_u expr, game::sval_u stmt, game::scr_block_s* block, game::sval_u* whileStatBlock);
void EmitForStatement(game::scriptInstance_t inst, game::sval_u stmt1, game::sval_u expr, game::sval_u stmt2, game::sval_u stmt, game::sval_u sourcePos, game::sval_u forSourcePos, game::scr_block_s* block, game::sval_u* forStatBlock, game::sval_u* forStatPostBlock);
void Scr_CalcLocalVarsForStatement(game::scriptInstance_t inst, game::sval_u stmt1, game::sval_u expr, game::sval_u stmt2, game::sval_u stmt, game::scr_block_s* block, game::sval_u* forStatBlock, game::sval_u* forStatPostBlock);
void EmitIncStatement(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos);
void EmitDecStatement(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos);
void Scr_CalcLocalVarsFormalParameterListInternal(game::sval_u* node, game::scr_block_s* block);
void EmitWaittillStatement(game::scriptInstance_t inst, game::sval_u obj, game::sval_u exprlist, game::sval_u sourcePos, game::sval_u waitSourcePos, game::scr_block_s* block);
void EmitWaittillmatchStatement(game::scriptInstance_t inst, game::sval_u obj, game::sval_u exprlist, game::sval_u sourcePos, game::sval_u waitSourcePos, game::scr_block_s* block);
void EmitNotifyStatement(game::scriptInstance_t inst, game::sval_u obj, game::sval_u exprlist, game::sval_u sourcePos, game::sval_u notifySourcePos, game::scr_block_s* block);
void EmitEndOnStatement(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u obj, game::sval_u expr, game::sval_u sourcePos, game::sval_u exprSourcePos);
int CompareCaseInfo(const void* elem1, const void* elem2);
void EmitCaseStatement(game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos);
void EmitSwitchStatementList(game::scriptInstance_t inst, game::sval_u val, int lastStatement, unsigned int endSourcePos, game::scr_block_s* block);
void Scr_CalcLocalVarsSwitchStatement(game::scriptInstance_t inst, game::sval_u stmtlist, game::scr_block_s* block);
void EmitSwitchStatement(game::scriptInstance_t inst, game::sval_u expr, game::sval_u stmtlist, game::sval_u sourcePos, int lastStatement, unsigned int endSourcePos, game::scr_block_s* block);
void EmitCaseStatementInfo(game::scriptInstance_t inst, unsigned int name, game::sval_u sourcePos);
void EmitBreakStatement(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitContinueStatement(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitProfStatement(game::scriptInstance_t inst, game::sval_u profileName, game::sval_u sourcePos, game::OpcodeVM op);
void EmitStatement(game::scriptInstance_t inst, game::sval_u val, int lastStatement, unsigned int endSourcePos, game::scr_block_s* block);
void Scr_CalcLocalVarsStatement(game::scriptInstance_t inst, game::sval_u val, game::scr_block_s* block);
void EmitStatementList(game::scriptInstance_t inst, game::sval_u val, int lastStatement, unsigned int endSourcePos, game::scr_block_s* block);
void Scr_CalcLocalVarsStatementList(game::scr_block_s* block, game::scriptInstance_t inst, game::sval_u val);
void Scr_CalcLocalVarsDeveloperStatementList(game::scriptInstance_t inst, game::sval_u val, game::scr_block_s* block, game::sval_u* devStatBlock);
void EmitDeveloperStatementList(game::scriptInstance_t inst, game::sval_u val, game::sval_u sourcePos, game::scr_block_s* block, game::sval_u* devStatBlock);
void EmitFormalParameterList(game::scriptInstance_t inst, game::sval_u exprlist, game::sval_u sourcePos, game::scr_block_s* block);
void SpecifyThread(game::scriptInstance_t inst, game::sval_u val);
void EmitThreadInternal(game::scriptInstance_t inst, game::sval_u val, game::sval_u sourcePos, game::sval_u endSourcePos, game::scr_block_s* block);
void Scr_CalcLocalVarsThread(game::sval_u* stmttblock, game::scriptInstance_t inst, game::sval_u exprlist, game::sval_u stmtlist);
void InitThread(int type, game::scriptInstance_t inst);
void EmitNormalThread(game::scriptInstance_t inst, game::sval_u val, game::sval_u* stmttblock);
void EmitDeveloperThread(game::scriptInstance_t inst, game::sval_u val, game::sval_u* stmttblock);
void EmitThread(game::scriptInstance_t inst, game::sval_u val);
void EmitThreadList(game::scriptInstance_t inst, game::sval_u val);
void EmitInclude(game::scriptInstance_t inst, game::sval_u val);
void ScriptCompile(game::scriptInstance_t inst, game::sval_u val, unsigned int filePosId, unsigned int fileCountId, unsigned int scriptId, game::PrecacheEntry* entries, int entriesCount);
void EmitFloat(game::scriptInstance_t inst, float value);
void EmitCanonicalStringConst(game::scriptInstance_t inst, unsigned int stringValue);
int Scr_FindLocalVar(game::scr_block_s* block, int startIndex, unsigned int name);
void Scr_CheckLocalVarsCount(int localVarsCount);
void EmitGetUndefined(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitPrimitiveExpression(game::scriptInstance_t inst, game::sval_u expr, game::scr_block_s* block);
void Scr_EmitAnimation(game::scriptInstance_t inst, char* pos, unsigned int animName, unsigned int sourcePos);
void EmitEvalArray(game::scriptInstance_t inst, game::sval_u sourcePos, game::sval_u indexSourcePos);
void EmitEvalArrayRef(game::scriptInstance_t inst, game::sval_u sourcePos, game::sval_u indexSourcePos);
unsigned int Scr_GetBuiltin(game::scriptInstance_t inst, game::sval_u func_name);
int Scr_GetUncacheType(int type);
int Scr_GetCacheType(int type);
game::BuiltinFunction Scr_GetFunction(const char** pName, int* type);
game::BuiltinFunction GetFunction(game::scriptInstance_t inst, const char** pName, int* type);
game::BuiltinMethod GetMethod(game::scriptInstance_t inst, const char** pName, int* type);
unsigned int GetVariableName(game::scriptInstance_t inst, unsigned int id);
int GetExpressionCount(game::sval_u exprlist);
game::sval_u* GetSingleParameter(game::sval_u exprlist);
void EmitExpressionFieldObject(game::scriptInstance_t inst, game::sval_u expr, game::sval_u sourcePos, game::scr_block_s* block);
void EvalInteger(int value, game::sval_u sourcePos, game::VariableCompileValue* constValue);
void EvalFloat(float value, game::sval_u sourcePos, game::VariableCompileValue* constValue);
void EvalString(unsigned int value, game::sval_u sourcePos, game::VariableCompileValue* constValue);
void EvalIString(unsigned int value, game::sval_u sourcePos, game::VariableCompileValue* constValue);
void EvalUndefined(game::sval_u sourcePos, game::VariableCompileValue* constValue);
void Scr_PopValue(game::scriptInstance_t inst);
void EmitSetVariableField(game::scriptInstance_t inst, game::sval_u sourcePos);
void EmitFieldVariableRef(game::scriptInstance_t inst, game::sval_u expr, game::sval_u field, game::sval_u sourcePos, game::scr_block_s* block);
void Scr_CalcLocalVarsArrayPrimitiveExpressionRef(game::sval_u expr, game::scr_block_s* block);
BOOL IsUndefinedPrimitiveExpression(game::sval_u expr);
bool IsUndefinedExpression(game::sval_u expr);
void Scr_CopyBlock(game::scr_block_s* from, game::scr_block_s** to);
void Scr_CheckMaxSwitchCases(int count);
void Scr_CalcLocalVarsSafeSetVariableField(game::sval_u expr, game::sval_u sourcePos, game::scr_block_s* block);
void EmitFormalWaittillParameterListRefInternal(game::scriptInstance_t inst, game::sval_u* node, game::scr_block_s* block);
void EmitDefaultStatement(game::scriptInstance_t inst, game::sval_u sourcePos);
char Scr_IsLastStatement(game::scriptInstance_t inst, game::sval_u* node);
void EmitEndStatement(game::scriptInstance_t inst, game::sval_u sourcePos, game::scr_block_s* block);
void EmitProfBeginStatement(game::scriptInstance_t inst, game::sval_u profileName, game::sval_u sourcePos);
void EmitProfEndStatement(game::scriptInstance_t inst, game::sval_u profileName, game::sval_u sourcePos);
void Scr_CalcLocalVarsIncStatement(game::sval_u expr, game::scr_block_s* block);
void Scr_CalcLocalVarsWaittillStatement(game::sval_u exprlist, game::scr_block_s* block);
void EmitFormalParameterListInternal(game::scriptInstance_t inst, game::sval_u* node, game::scr_block_s* block);
unsigned int SpecifyThreadPosition(game::scriptInstance_t inst, unsigned int posId, unsigned int name, unsigned int sourcePos, int type);
void Scr_CalcLocalVarsFormalParameterList(game::sval_u exprlist, game::scr_block_s* block);
void SetThreadPosition(game::scriptInstance_t inst, unsigned int posId);
void EmitIncludeList(game::scriptInstance_t inst, game::sval_u val);
}
+409 -394
View File
@@ -3,434 +3,449 @@
namespace codsrc
{
// Restored inlined function
int Scr_IsInOpcodeMemory(game::scriptInstance_t inst, const char* pos)
{
assert(game::gScrVarPub[inst].programBuffer);
assert(pos);
// Restored inlined function
int Scr_IsInOpcodeMemory(game::scriptInstance_t inst, const char* pos)
{
assert(game::gScrVarPub[inst].programBuffer);
assert(pos);
return (unsigned int)(pos - game::gScrVarPub[inst].programBuffer) < game::gScrCompilePub[inst].programLen;
}
return (unsigned int)(pos - game::gScrVarPub[inst].programBuffer) < game::gScrCompilePub[inst].programLen;
}
// Decomp Status: Completed
bool Scr_IsIdentifier(char* token)
{
while ( *token )
{
if (!iscsym(*token))
{
return false;
}
// Decomp Status: Completed
bool Scr_IsIdentifier(char* token)
{
while ( *token )
{
if (!iscsym(*token))
{
return false;
}
++token;
}
return true;
}
++token;
}
return true;
}
// Decomp Status: Completed
unsigned int Scr_GetFunctionHandle(const char* file, game::scriptInstance_t inst, const char* handle)
{
assert(game::gScrCompilePub[inst].scriptsPos);
assert(strlen(file) < 0x40);
// Decomp Status: Completed
unsigned int Scr_GetFunctionHandle(const char* file, game::scriptInstance_t inst, const char* handle)
{
assert(game::gScrCompilePub[inst].scriptsPos);
assert(strlen(file) < 0x40);
unsigned int fileNameHash = game::Scr_CreateCanonicalFilename(inst, file);
int id = game::FindVariable(fileNameHash, game::gScrCompilePub[inst].scriptsPos, inst);
unsigned int fileNameHash = game::Scr_CreateCanonicalFilename(inst, file);
int id = game::FindVariable(fileNameHash, game::gScrCompilePub[inst].scriptsPos, inst);
game::SL_RemoveRefToString(fileNameHash, inst);
game::SL_RemoveRefToString(fileNameHash, inst);
if (!id)
{
return 0;
}
if (!id)
{
return 0;
}
unsigned int posId = game::FindObject(inst, id);
unsigned int str = game::SL_FindLowercaseString(handle, inst);
if (!str)
{
return 0;
}
unsigned int posId = game::FindObject(inst, id);
unsigned int str = game::SL_FindLowercaseString(handle, inst);
if (!str)
{
return 0;
}
unsigned int filePosId = game::FindVariable(str, posId, inst);
if (!filePosId)
{
return 0;
}
unsigned int filePosId = game::FindVariable(str, posId, inst);
if (!filePosId)
{
return 0;
}
game::VariableValue val = game::Scr_EvalVariable(inst, filePosId);
game::VariableValue val = game::Scr_EvalVariable(inst, filePosId);
assert(val.type == game::VAR_CODEPOS);
assert(val.type == game::VAR_CODEPOS);
const char* pos = val.u.codePosValue;
if (!game::Scr_IsInOpcodeMemory(inst, pos))
{
return 0;
}
const char* pos = val.u.codePosValue;
if (!game::Scr_IsInOpcodeMemory(inst, pos))
{
return 0;
}
assert(pos - game::gScrVarPub[inst].programBuffer);
assert(pos - game::gScrVarPub[inst].programBuffer);
assert(pos > game::gScrVarPub[inst].programBuffer);
assert(pos > game::gScrVarPub[inst].programBuffer);
return pos - game::gScrVarPub[inst].programBuffer;
}
return pos - game::gScrVarPub[inst].programBuffer;
}
// Decomp Status: Completed
unsigned int SL_TransferToCanonicalString(game::scriptInstance_t inst, unsigned int stringValue)
{
assert(stringValue);
// Decomp Status: Completed
unsigned int SL_TransferToCanonicalString(game::scriptInstance_t inst, unsigned int stringValue)
{
assert(stringValue);
game::SL_TransferRefToUser(stringValue, 2u, inst);
game::SL_TransferRefToUser(stringValue, 2u, inst);
if ( game::gScrCompilePub[inst].canonicalStrings[stringValue] )
{
return game::gScrCompilePub[inst].canonicalStrings[stringValue];
}
if ( game::gScrCompilePub[inst].canonicalStrings[stringValue] )
{
return game::gScrCompilePub[inst].canonicalStrings[stringValue];
}
game::gScrCompilePub[inst].canonicalStrings[stringValue] = ++game::gScrVarPub[inst].canonicalStrCount;
game::gScrCompilePub[inst].canonicalStrings[stringValue] = ++game::gScrVarPub[inst].canonicalStrCount;
return game::gScrVarPub[inst].canonicalStrCount;
}
return game::gScrVarPub[inst].canonicalStrCount;
}
// Decomp Status: Tested, Completed
unsigned int SL_GetCanonicalString(char* token, game::scriptInstance_t inst)
{
unsigned int str;
// Decomp Status: Tested, Completed
unsigned int SL_GetCanonicalString(char* token, game::scriptInstance_t inst)
{
unsigned int str;
str = game::SL_FindString(token, inst);
str = game::SL_FindString(token, inst);
if ( game::gScrCompilePub[inst].canonicalStrings[str] )
{
return game::gScrCompilePub[inst].canonicalStrings[str];
}
if ( game::gScrCompilePub[inst].canonicalStrings[str] )
{
return game::gScrCompilePub[inst].canonicalStrings[str];
}
str = game::SL_GetString_(token, inst, 0);
str = game::SL_GetString_(token, inst, 0);
return game::SL_TransferToCanonicalString(inst, str);
}
return game::SL_TransferToCanonicalString(inst, str);
}
// Restored
void SL_BeginLoadScripts(game::scriptInstance_t inst)
{
memset(game::gScrCompilePub[inst].canonicalStrings, 0, sizeof(game::gScrCompilePub[inst].canonicalStrings));
game::gScrVarPub[inst].canonicalStrCount = 0;
}
// Restored
void SL_BeginLoadScripts(game::scriptInstance_t inst)
{
memset(game::gScrCompilePub[inst].canonicalStrings, 0, sizeof(game::gScrCompilePub[inst].canonicalStrings));
game::gScrVarPub[inst].canonicalStrCount = 0;
}
// Restored
void Scr_SetLoadedImpureScript(bool loadedImpureScript)
{
*game::loadedImpureScript = loadedImpureScript;
}
// Restored
void Scr_SetLoadedImpureScript(bool loadedImpureScript)
{
*game::loadedImpureScript = loadedImpureScript;
}
// Decomp Status: Tested, Completed
void Scr_BeginLoadScripts(game::scriptInstance_t inst, int user)
{
assert(!game::gScrCompilePub[inst].script_loading);
// Decomp Status: Tested, Completed
void Scr_BeginLoadScripts(game::scriptInstance_t inst, int user)
{
assert(!game::gScrCompilePub[inst].script_loading);
game::gScrCompilePub[inst].script_loading = 1;
game::gScrCompilePub[inst].script_loading = 1;
game::Scr_InitOpcodeLookup(inst);
game::Scr_InitOpcodeLookup(inst);
assert(!game::gScrCompilePub[inst].loadedscripts);
assert(!game::gScrCompilePub[inst].loadedscripts);
game::gScrCompilePub[inst].loadedscripts = game::Scr_AllocArray(inst);
game::gScrCompilePub[inst].loadedscripts = game::Scr_AllocArray(inst);
assert(!game::gScrCompilePub[inst].scriptsPos);
assert(!game::gScrCompilePub[inst].scriptsPos);
game::gScrCompilePub[inst].scriptsPos = game::Scr_AllocArray(inst);
game::gScrCompilePub[inst].scriptsPos = game::Scr_AllocArray(inst);
assert(!game::gScrCompilePub[inst].scriptsCount);
game::gScrCompilePub[inst].scriptsCount = game::Scr_AllocArray(inst);
assert(!game::gScrCompilePub[inst].builtinFunc);
game::gScrCompilePub[inst].builtinFunc = game::Scr_AllocArray(inst);
assert(!game::gScrCompilePub[inst].builtinMeth);
game::gScrCompilePub[inst].builtinMeth = game::Scr_AllocArray(inst);
game::gScrVarPub[inst].programHunkUser = game::Hunk_UserCreate(0x100000, "Scr_BeginLoadScripts", 1, 0, 0, 7);
game::TempMemoryReset(game::gScrVarPub[inst].programHunkUser);
game::gScrVarPub[inst].programBuffer = game::TempMalloc(0);
assert(((int)game::gScrVarPub[inst].programBuffer & 0x1F) == 0);
assert(!game::gScrCompilePub[inst].scriptsCount);
game::gScrCompilePub[inst].scriptsCount = game::Scr_AllocArray(inst);
assert(!game::gScrCompilePub[inst].builtinFunc);
game::gScrCompilePub[inst].builtinFunc = game::Scr_AllocArray(inst);
assert(!game::gScrCompilePub[inst].builtinMeth);
game::gScrCompilePub[inst].builtinMeth = game::Scr_AllocArray(inst);
game::gScrVarPub[inst].programHunkUser = game::Hunk_UserCreate(0x100000, "Scr_BeginLoadScripts", 1, 0, 0, 7);
game::TempMemoryReset(game::gScrVarPub[inst].programHunkUser);
game::gScrVarPub[inst].programBuffer = game::TempMalloc(0);
assert(((int)game::gScrVarPub[inst].programBuffer & 0x1F) == 0);
game::gScrCompilePub[inst].programLen = 0;
game::gScrVarPub[inst].endScriptBuffer = 0;
game::SL_BeginLoadScripts(inst);
game::gScrVarPub[inst].fieldBuffer = 0;
game::gScrCompilePub[inst].value_count = 0;
game::gScrVarPub[inst].error_message = 0;
game::gScrVmGlob[inst].dialog_error_message = 0;
game::gScrVarPub[inst].error_index = 0;
game::gScrCompilePub[inst].func_table_size = 0;
game::Scr_SetLoadedImpureScript(false);
game::gScrAnimPub[inst].animTreeNames = 0;
game::Scr_BeginLoadAnimTrees(inst, user);
}
// Decomp Status: Completed
void Scr_BeginLoadAnimTrees(game::scriptInstance_t inst, int user)
{
assert(!game::gScrAnimPub[inst].animtree_loading);
game::gScrAnimPub[inst].animtree_loading = 1;
game::gScrAnimPub[inst].xanim_num[user] = 0;
game::gScrAnimPub[inst].xanim_lookup[user][0].anims = 0;
assert(!game::gScrAnimPub[inst].animtrees);
game::gScrAnimPub[inst].animtrees = game::Scr_AllocArray(inst);
game::gScrAnimPub[inst].animtree_node = 0;
game::gScrCompilePub[inst].developer_statement = 0;
}
// Decomp Status: Completed
int Scr_ScanFile(int max_size, char* buf)
{
char c;
int n;
game::scriptInstance_t inst;
inst = *game::gInst;
c = '*';
for ( n = 0;
n < max_size;
++n )
{
c = *game::gScrCompilePub[inst].in_ptr++;
if ( !c || c == '\n')
{
break;
}
buf[n] = c;
}
if ( c == '\n')
{
buf[n++] = c;
}
else if ( !c )
{
if ( game::gScrCompilePub[inst].parseBuf )
{
game::gScrCompilePub[inst].in_ptr = game::gScrCompilePub[inst].parseBuf;
game::gScrCompilePub[inst].parseBuf = 0;
}
else
{
--game::gScrCompilePub[inst].in_ptr;
}
}
return n;
}
// Decomp Status: Tested, Completed
unsigned int Scr_LoadScriptInternal(game::scriptInstance_t inst, const char* filename, game::PrecacheEntry* entries, int entriesCount)
{
unsigned int scriptPosVar;
unsigned int scriptCountVar;
const char *codepos;
char extFilename[64];
unsigned int fileCountId;
unsigned int filePosPtr;
char *sourceBuffer;
const char *oldFilename;
unsigned int name;
unsigned int oldAnimTreeNames;
const char *oldSourceBuf;
unsigned int scriptId;
unsigned int filePosId;
const char *formatExtString;
game::sval_u parseData;
assert(game::gScrCompilePub[inst].script_loading);
assert(strlen(filename) < 0x40);
name = game::Scr_CreateCanonicalFilename(inst, filename);
if ( game::FindVariable(name, game::gScrCompilePub[inst].loadedscripts, inst) )
{
game::SL_RemoveRefToString(name, inst);
filePosPtr = game::FindVariable(name, game::gScrCompilePub[inst].scriptsPos, inst);
if ( filePosPtr )
{
return game::FindObject(inst, filePosPtr);
}
return 0;
}
scriptId = game::GetNewVariable(inst, name, game::gScrCompilePub[inst].loadedscripts);
game::SL_RemoveRefToString(name, inst);
formatExtString = "%s.gsc";
if ( inst == game::SCRIPTINSTANCE_CLIENT && !strncmp(filename, "clientscripts", 13) )
{
formatExtString = "%s.csc";
}
snprintf(extFilename, 64, formatExtString, filename);
oldSourceBuf = game::gScrParserPub[inst].sourceBuf;
codepos = (const char *)game::TempMalloc(0);
sourceBuffer = game::Scr_AddSourceBuffer(inst, (int)filename, extFilename, codepos);
if (!sourceBuffer)
{
return 0;
}
oldAnimTreeNames = game::gScrAnimPub[inst].animTreeNames;
game::gScrAnimPub[inst].animTreeNames = 0;
game::gScrCompilePub[inst].far_function_count = 0;
game::Scr_InitAllocNode(inst);
oldFilename = game::gScrParserPub[inst].scriptfilename;
game::gScrParserPub[inst].scriptfilename = extFilename;
game:: gScrCompilePub[inst].in_ptr = "+";
game::gScrCompilePub[inst].parseBuf = sourceBuffer;
game::ScriptParse(inst, &parseData);
scriptPosVar = game::GetVariable(inst, game::gScrCompilePub[inst].scriptsPos, name);
filePosId = game::GetObject(inst, scriptPosVar);
scriptCountVar = game::GetVariable(inst, game::gScrCompilePub[inst].scriptsCount, name);
fileCountId = game::GetObject(inst, scriptCountVar);
game::ScriptCompile(inst, parseData, filePosId, fileCountId, scriptId, entries, entriesCount);
game::gScrParserPub[inst].scriptfilename = oldFilename;
game::gScrParserPub[inst].sourceBuf = oldSourceBuf;
game::gScrAnimPub[inst].animTreeNames = oldAnimTreeNames;
return filePosId;
}
// Decomp Status: Tested, Completed
unsigned int Scr_LoadScript(const char* file, game::scriptInstance_t inst)
{
game::PrecacheEntry entries[1024];
return game::Scr_LoadScriptInternal(inst, file, entries, 0);
}
// Decomp Status: Tested, Completed
void Scr_EndLoadScripts(game::scriptInstance_t inst)
{
// pluto
game::plutonium::load_custom_script_func(inst);
//
game::SL_ShutdownSystem(inst, 2u);
game::gScrCompilePub[inst].script_loading = 0;
assert(game::gScrCompilePub[inst].loadedscripts);
game::ClearObject(game::gScrCompilePub[inst].loadedscripts, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].loadedscripts, inst);
game::gScrCompilePub[inst].loadedscripts = 0;
assert(game::gScrCompilePub[inst].scriptsPos);
game::ClearObject(game::gScrCompilePub[inst].scriptsPos, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].scriptsPos, inst);
game::gScrCompilePub[inst].scriptsPos = 0;
assert(game::gScrCompilePub[inst].scriptsCount);
game::ClearObject(game::gScrCompilePub[inst].scriptsCount, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].scriptsCount, inst);
game::gScrCompilePub[inst].scriptsCount = 0;
assert(game::gScrCompilePub[inst].builtinFunc);
game::ClearObject(game::gScrCompilePub[inst].builtinFunc, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].builtinFunc, inst);
game::gScrCompilePub[inst].builtinFunc = 0;
assert(game::gScrCompilePub[inst].builtinMeth);
game::ClearObject(game::gScrCompilePub[inst].builtinMeth, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].builtinMeth, inst);
game::gScrCompilePub[inst].builtinMeth = 0;
}
// Decomp Status: Tested, Completed
void Scr_PrecacheAnimTrees(game::scriptInstance_t inst, void* (__cdecl *Alloc)(int), int user, int modChecksum)
{
unsigned int i;
for (i = 1; i <= game::gScrAnimPub[inst].xanim_num[user]; ++i)
{
game::Scr_LoadAnimTreeAtIndex(inst, user, i, Alloc, modChecksum);
}
}
// Decomp Status: Tested, Completed
void Scr_EndLoadAnimTrees(game::scriptInstance_t inst)
{
unsigned int animtreeNode;
assert(game::gScrAnimPub[inst].animtrees);
game::ClearObject(game::gScrAnimPub[inst].animtrees, inst);
game::RemoveRefToObject(game::gScrAnimPub[inst].animtrees, inst);
animtreeNode = game::gScrAnimPub[inst].animtree_node;
game::gScrAnimPub[inst].animtrees = 0;
if (animtreeNode)
{
game::RemoveRefToObject(animtreeNode, inst);
}
game::SL_ShutdownSystem(inst, 2u);
if (game::gScrVarPub[inst].programBuffer && !game::gScrVarPub[inst].endScriptBuffer)
{
game::gScrVarPub[inst].endScriptBuffer = game::TempMalloc(0);
}
game::gScrAnimPub[inst].animtree_loading = 0;
}
// Decomp Status: Tested, Completed
void Scr_FreeScripts(game::scriptInstance_t inst)
{
//char sys = 1;
//assert(sys == SCR_SYS_GAME);
if (game::gScrCompilePub[inst].script_loading)
{
game::gScrCompilePub[inst].script_loading = 0;
game::Scr_EndLoadScripts(inst);
}
if (game::gScrAnimPub[inst].animtree_loading)
{
game::gScrAnimPub[inst].animtree_loading = 0;
game::Scr_EndLoadAnimTrees(inst);
}
game::SL_ShutdownSystem(inst, 1u);
game::Scr_ShutdownOpcodeLookup(inst);
if (game::gScrVarPub[inst].programHunkUser)
{
game::Hunk_UserDestroy(game::gScrVarPub[inst].programHunkUser);
game::gScrVarPub[inst].programHunkUser = 0;
}
game::gScrVarPub[inst].programBuffer = 0;
game::gScrVarPub[inst].endScriptBuffer = 0;
game::gScrVarPub[inst].checksum = 0;
game::gScrCompilePub[inst].programLen = 0;
}
game::gScrCompilePub[inst].programLen = 0;
game::gScrVarPub[inst].endScriptBuffer = 0;
game::SL_BeginLoadScripts(inst);
game::gScrVarPub[inst].fieldBuffer = 0;
game::gScrCompilePub[inst].value_count = 0;
game::gScrVarPub[inst].error_message = 0;
game::gScrVmGlob[inst].dialog_error_message = 0;
game::gScrVarPub[inst].error_index = 0;
game::gScrCompilePub[inst].func_table_size = 0;
game::Scr_SetLoadedImpureScript(false);
game::gScrAnimPub[inst].animTreeNames = 0;
game::Scr_BeginLoadAnimTrees(inst, user);
}
// Decomp Status: Completed
void Scr_BeginLoadAnimTrees(game::scriptInstance_t inst, int user)
{
assert(!game::gScrAnimPub[inst].animtree_loading);
game::gScrAnimPub[inst].animtree_loading = 1;
game::gScrAnimPub[inst].xanim_num[user] = 0;
game::gScrAnimPub[inst].xanim_lookup[user][0].anims = 0;
assert(!game::gScrAnimPub[inst].animtrees);
game::gScrAnimPub[inst].animtrees = game::Scr_AllocArray(inst);
game::gScrAnimPub[inst].animtree_node = 0;
game::gScrCompilePub[inst].developer_statement = 0;
}
// Decomp Status: Completed
int Scr_ScanFile(int max_size, char* buf)
{
char c;
int n;
game::scriptInstance_t inst;
inst = *game::gInst;
c = '*';
for ( n = 0;
n < max_size;
++n )
{
c = *game::gScrCompilePub[inst].in_ptr++;
if ( !c || c == '\n')
{
break;
}
buf[n] = c;
}
if ( c == '\n')
{
buf[n++] = c;
}
else if ( !c )
{
if ( game::gScrCompilePub[inst].parseBuf )
{
game::gScrCompilePub[inst].in_ptr = game::gScrCompilePub[inst].parseBuf;
game::gScrCompilePub[inst].parseBuf = 0;
}
else
{
--game::gScrCompilePub[inst].in_ptr;
}
}
return n;
}
// Decomp Status: Tested, Completed
unsigned int Scr_LoadScriptInternal(game::scriptInstance_t inst, const char* filename, game::PrecacheEntry* entries, int entriesCount)
{
unsigned int scriptPosVar;
unsigned int scriptCountVar;
const char *codepos;
char extFilename[64];
unsigned int fileCountId;
unsigned int filePosPtr;
char *sourceBuffer;
const char *oldFilename;
unsigned int name;
unsigned int oldAnimTreeNames;
const char *oldSourceBuf;
unsigned int scriptId;
unsigned int filePosId;
const char *formatExtString;
game::sval_u parseData;
assert(game::gScrCompilePub[inst].script_loading);
assert(strlen(filename) < 0x40);
name = game::Scr_CreateCanonicalFilename(inst, filename);
if ( game::FindVariable(name, game::gScrCompilePub[inst].loadedscripts, inst) )
{
game::SL_RemoveRefToString(name, inst);
filePosPtr = game::FindVariable(name, game::gScrCompilePub[inst].scriptsPos, inst);
if ( filePosPtr )
{
return game::FindObject(inst, filePosPtr);
}
return 0;
}
scriptId = game::GetNewVariable(inst, name, game::gScrCompilePub[inst].loadedscripts);
game::SL_RemoveRefToString(name, inst);
formatExtString = "%s.gsc";
if ( inst == game::SCRIPTINSTANCE_CLIENT && !strncmp(filename, "clientscripts", 13) )
{
formatExtString = "%s.csc";
}
snprintf(extFilename, 64, formatExtString, filename);
oldSourceBuf = game::gScrParserPub[inst].sourceBuf;
codepos = (const char *)game::TempMalloc(0);
sourceBuffer = game::Scr_AddSourceBuffer(inst, (int)filename, extFilename, codepos);
if (!sourceBuffer)
{
return 0;
}
oldAnimTreeNames = game::gScrAnimPub[inst].animTreeNames;
game::gScrAnimPub[inst].animTreeNames = 0;
game::gScrCompilePub[inst].far_function_count = 0;
game::Scr_InitAllocNode(inst);
oldFilename = game::gScrParserPub[inst].scriptfilename;
game::gScrParserPub[inst].scriptfilename = extFilename;
game:: gScrCompilePub[inst].in_ptr = "+";
game::gScrCompilePub[inst].parseBuf = sourceBuffer;
// pluto
if (game::plutonium::script_preprocess != nullptr)
{
game::plutonium::script_preprocess(sourceBuffer, inst, &parseData); // the pluto hook will call ScriptParse, so we dont have to
}
//
else
{
game::ScriptParse(inst, &parseData);
}
scriptPosVar = game::GetVariable(inst, game::gScrCompilePub[inst].scriptsPos, name);
filePosId = game::GetObject(inst, scriptPosVar);
scriptCountVar = game::GetVariable(inst, game::gScrCompilePub[inst].scriptsCount, name);
fileCountId = game::GetObject(inst, scriptCountVar);
game::ScriptCompile(inst, parseData, filePosId, fileCountId, scriptId, entries, entriesCount);
game::gScrParserPub[inst].scriptfilename = oldFilename;
game::gScrParserPub[inst].sourceBuf = oldSourceBuf;
game::gScrAnimPub[inst].animTreeNames = oldAnimTreeNames;
return filePosId;
}
// Decomp Status: Tested, Completed
unsigned int Scr_LoadScript(const char* file, game::scriptInstance_t inst)
{
game::PrecacheEntry entries[1024];
return game::Scr_LoadScriptInternal(inst, file, entries, 0);
}
// Decomp Status: Tested, Completed
void Scr_EndLoadScripts(game::scriptInstance_t inst)
{
// pluto
if (game::plutonium::load_custom_script_func != nullptr)
{
game::plutonium::load_custom_script_func(inst);
}
//
game::SL_ShutdownSystem(inst, 2u);
game::gScrCompilePub[inst].script_loading = 0;
assert(game::gScrCompilePub[inst].loadedscripts);
game::ClearObject(game::gScrCompilePub[inst].loadedscripts, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].loadedscripts, inst);
game::gScrCompilePub[inst].loadedscripts = 0;
assert(game::gScrCompilePub[inst].scriptsPos);
game::ClearObject(game::gScrCompilePub[inst].scriptsPos, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].scriptsPos, inst);
game::gScrCompilePub[inst].scriptsPos = 0;
assert(game::gScrCompilePub[inst].scriptsCount);
game::ClearObject(game::gScrCompilePub[inst].scriptsCount, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].scriptsCount, inst);
game::gScrCompilePub[inst].scriptsCount = 0;
assert(game::gScrCompilePub[inst].builtinFunc);
game::ClearObject(game::gScrCompilePub[inst].builtinFunc, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].builtinFunc, inst);
game::gScrCompilePub[inst].builtinFunc = 0;
assert(game::gScrCompilePub[inst].builtinMeth);
game::ClearObject(game::gScrCompilePub[inst].builtinMeth, inst);
game::RemoveRefToObject(game::gScrCompilePub[inst].builtinMeth, inst);
game::gScrCompilePub[inst].builtinMeth = 0;
}
// Decomp Status: Tested, Completed
void Scr_PrecacheAnimTrees(game::scriptInstance_t inst, void* (__cdecl *Alloc)(int), int user, int modChecksum)
{
unsigned int i;
for (i = 1; i <= game::gScrAnimPub[inst].xanim_num[user]; ++i)
{
game::Scr_LoadAnimTreeAtIndex(inst, user, i, Alloc, modChecksum);
}
}
// Decomp Status: Tested, Completed
void Scr_EndLoadAnimTrees(game::scriptInstance_t inst)
{
unsigned int animtreeNode;
assert(game::gScrAnimPub[inst].animtrees);
game::ClearObject(game::gScrAnimPub[inst].animtrees, inst);
game::RemoveRefToObject(game::gScrAnimPub[inst].animtrees, inst);
animtreeNode = game::gScrAnimPub[inst].animtree_node;
game::gScrAnimPub[inst].animtrees = 0;
if (animtreeNode)
{
game::RemoveRefToObject(animtreeNode, inst);
}
game::SL_ShutdownSystem(inst, 2u);
if (game::gScrVarPub[inst].programBuffer && !game::gScrVarPub[inst].endScriptBuffer)
{
game::gScrVarPub[inst].endScriptBuffer = game::TempMalloc(0);
}
game::gScrAnimPub[inst].animtree_loading = 0;
}
// Decomp Status: Tested, Completed
void Scr_FreeScripts(game::scriptInstance_t inst)
{
//char sys = 1;
//assert(sys == SCR_SYS_GAME);
if (game::gScrCompilePub[inst].script_loading)
{
game::gScrCompilePub[inst].script_loading = 0;
game::Scr_EndLoadScripts(inst);
}
if (game::gScrAnimPub[inst].animtree_loading)
{
game::gScrAnimPub[inst].animtree_loading = 0;
game::Scr_EndLoadAnimTrees(inst);
}
game::SL_ShutdownSystem(inst, 1u);
game::Scr_ShutdownOpcodeLookup(inst);
if (game::gScrVarPub[inst].programHunkUser)
{
game::Hunk_UserDestroy(game::gScrVarPub[inst].programHunkUser);
game::gScrVarPub[inst].programHunkUser = 0;
}
game::gScrVarPub[inst].programBuffer = 0;
game::gScrVarPub[inst].endScriptBuffer = 0;
game::gScrVarPub[inst].checksum = 0;
game::gScrCompilePub[inst].programLen = 0;
}
}
File diff suppressed because it is too large Load Diff
+12 -12
View File
@@ -21,9 +21,9 @@ namespace codsrc
return game::FindVariableIndexInternal2(inst, name, (parentId + name) % 0xFFFD + 1);
}
// Decomp Status: Tested, Completed
unsigned int FindVariableIndexInternal2(game::scriptInstance_t inst, unsigned int name, unsigned int index)
{
// Decomp Status: Tested, Completed
unsigned int FindVariableIndexInternal2(game::scriptInstance_t inst, unsigned int name, unsigned int index)
{
unsigned int newIndex;
game::VariableValueInternal* newEntryValue;
game::VariableValueInternal* entryValue;
@@ -76,11 +76,11 @@ namespace codsrc
}
return 0;
}
}
// Decomp Status: Tested, Completed
unsigned int FindLastSibling(unsigned int parentId, game::scriptInstance_t inst)
{
// Decomp Status: Tested, Completed
unsigned int FindLastSibling(unsigned int parentId, game::scriptInstance_t inst)
{
game::VariableValueInternal* parentValue;
unsigned int nextParentVarIndex;
unsigned int id;
@@ -101,10 +101,10 @@ namespace codsrc
id = game::gScrVarGlob[inst].parentVariables[nextParentVarIndex].hash.u.prev;
if (!id)
{
return 0;
}
if (!id)
{
return 0;
}
childVarName = game::gScrVarGlob[inst].childVariables[id].w.status >> VAR_NAME_BIT_SHIFT;
@@ -113,5 +113,5 @@ namespace codsrc
assert(index);
return index;
}
}
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -38,5 +38,5 @@ namespace codsrc
int SL_ConvertFromString(game::scriptInstance_t inst, const char* str);
int SL_ConvertFromRefString(game::scriptInstance_t inst, game::RefString* refString);
game::RefString* GetRefString_0(game::scriptInstance_t inst, const char* str);
const char* SL_DebugConvertToString(unsigned int stringValue, game::scriptInstance_t inst);
const char* SL_ConvertToStringSafe(unsigned int id, game::scriptInstance_t inst);
}
+15 -15
View File
@@ -3,21 +3,21 @@
namespace codsrc
{
// Restored
char* TempMalloc(int len)
{
return (char *)game::Hunk_UserAlloc(*game::g_user, len, 1);
}
// Restored
char* TempMalloc(int len)
{
return (char *)game::Hunk_UserAlloc(*game::g_user, len, 1);
}
// Restored
void TempMemoryReset(game::HunkUser* user)
{
*game::g_user = user;
}
// Restored
void TempMemoryReset(game::HunkUser* user)
{
*game::g_user = user;
}
// Restored
void TempMemorySetPos(char* pos)
{
(*game::g_user)->pos = (int)pos;
}
// Restored
void TempMemorySetPos(char* pos)
{
(*game::g_user)->pos = (int)pos;
}
}
+147 -31
View File
@@ -1,5 +1,6 @@
#include <stdinc.hpp>
#include "clientscript_public.hpp"
#include <component/scheduler.hpp>
#pragma warning(push)
#pragma warning(disable: 4244)
@@ -47,6 +48,17 @@ namespace codsrc
game::DVAR_FLAG_NONE,
"Used to toggle systems in script on and off on the server.");
}
// our additions
if (!game::Cmd_FindCommand("dump_gsc_state"))
{
game::Cmd_AddCommand("dump_gsc_state", []()
{
game::scriptInstance_t inst = game::SCRIPTINSTANCE_SERVER;
utils::io::write_file("t4sp-server-plugin/gsc_state.json", build_gsc_dump(inst));
});
}
//
}
// Completed
@@ -98,8 +110,6 @@ namespace codsrc
}
}
jmp_buf g_script_error[2][33];
// Completed
void Scr_ErrorInternal(game::scriptInstance_t inst)
{
@@ -115,8 +125,9 @@ namespace codsrc
assert(game::g_script_error_level[inst] < 33);
//game::longjmp((int*)game::g_script_error.get() + 0x10 * (0x21 * inst + game::g_script_error_level[inst]), -1);
longjmp(g_script_error[inst][game::g_script_error_level[inst]], -1);
// use game's longjmp so we can enable c++ exceptions in our project without crashing due to stack unwinding a c++ object
auto jmp_bufs = reinterpret_cast<jmp_buf(*)[2][33]>(game::g_script_error.get());
game::longjmp((*jmp_bufs)[inst][game::g_script_error_level[inst]], -1);
}
game::Sys_Error("%s", game::gScrVarPub[inst].error_message);
@@ -1055,6 +1066,10 @@ namespace codsrc
gScrVmPub[inst].outparamcount = outparamcount;
}*/
// our addition
push_builtin_history(inst, builtinIndex);
//
assert(builtinIndex >= 0);
assert(builtinIndex < 1024);
@@ -1108,16 +1123,20 @@ namespace codsrc
game::gScrVmPub[inst].function_frame->fs.pos = game::gFs[inst].pos;
/*
if ( gScrVmGlob[inst].recordPlace )
Scr_GetFileAndLine(inst, localFs.pos, &gScrVmGlob[inst].lastFileName, &gScrVmGlob[inst].lastLine);
if ( gScrVmDebugPub[inst].func_table[builtinIndex].breakpointCount )
{
if ( gScrVmPub[inst].top != localFs.top - 1 && !Assert_MyHandler("C:\\projects_pc\\cod\\codsrc\\src\\clientscript\\cscr_vm.cpp", 1611, 0, "%s", "gScrVmPub[inst].top == localFs.top - 1") )
__debugbreak();
v104 = gScrVmPub[inst].outparamcount;
Scr_HitBuiltinBreakpoint(inst, localFs.top, debugpos, localFs.localId, gOpcode[inst], builtinIndex, v104 + 1);
gScrVmPub[inst].outparamcount = v104;
gScrVmPub[inst].top = localFs.top - 1;
}*/
Scr_GetFileAndLine(inst, localFs.pos, &gScrVmGlob[inst].lastFileName, &gScrVmGlob[inst].lastLine);
if ( gScrVmDebugPub[inst].func_table[builtinIndex].breakpointCount )
{
if ( gScrVmPub[inst].top != localFs.top - 1 && !Assert_MyHandler("C:\\projects_pc\\cod\\codsrc\\src\\clientscript\\cscr_vm.cpp", 1611, 0, "%s", "gScrVmPub[inst].top == localFs.top - 1") )
__debugbreak();
v104 = gScrVmPub[inst].outparamcount;
Scr_HitBuiltinBreakpoint(inst, localFs.top, debugpos, localFs.localId, gOpcode[inst], builtinIndex, v104 + 1);
gScrVmPub[inst].outparamcount = v104;
gScrVmPub[inst].top = localFs.top - 1;
}*/
// our addition
push_builtin_history(inst, builtinIndex);
//
assert(builtinIndex >= 0);
assert(builtinIndex < 1024);
@@ -1274,9 +1293,19 @@ namespace codsrc
++game::gScrVmPub[inst].function_frame;
game::gScrVmPub[inst].function_frame->fs.localId = game::gFs[inst].localId;
// pluto
if (game::plutonium::vm_execute_update_codepos != nullptr)
{
game::plutonium::vm_execute_update_codepos(inst);
}
//
// our addition
push_codepos_history(inst, game::gFs[inst].pos);
//
assert(game::gFs[inst].pos);
// replace func
}
void OP_ScriptFunctionCall(game::scriptInstance_t inst)
@@ -1672,7 +1701,20 @@ namespace codsrc
Com_Printf(game::CON_CHANNEL_PARSERSCRIPT, "EXCEED TIME: %d\n", v28);
}*/
if (!game::gScrVmGlob[inst].loading)
// pluto
static game::dvar_s* scr_kill_infinite_loops = nullptr;
if (!scr_kill_infinite_loops)
{
scr_kill_infinite_loops = game::Dvar_FindVar("scr_kill_infinite_loops");
}
bool kill_infinite_loops = scr_kill_infinite_loops && scr_kill_infinite_loops->current.enabled;
//
// if (!game::gScrVmGlob[inst].loading)
// pluto
if (kill_infinite_loops)
//
{
/*if (always_false())
{
@@ -1693,7 +1735,10 @@ namespace codsrc
Scr_Error(inst, "potential infinite loop in script", 0);
}*/
if (!game::gScrVmPub[inst].abort_on_error)
//if (!game::gScrVmPub[inst].abort_on_error)
// pluto
if (kill_infinite_loops)
//
{
// t5 added this extra string
const char* side = inst == game::SCRIPTINSTANCE_CLIENT ? "client" : "server";
@@ -2187,7 +2232,7 @@ namespace codsrc
void OP_endswitch(game::scriptInstance_t inst)
{
game::gCaseCount[inst] = game::Scr_ReadUnsignedShort(inst, &game::gFs[inst].pos);
game::Scr_ReadData(inst, &game::gFs[inst].pos, 2 * game::gCaseCount[inst]);
game::Scr_ReadData(inst, &game::gFs[inst].pos, sizeof(unsigned int) * 2 * game::gCaseCount[inst]); // Scr_ReadIntArray
}
void OP_vector(game::scriptInstance_t inst)
@@ -2346,8 +2391,9 @@ namespace codsrc
assert(game::g_script_error_level[inst] >= 0);
assert(game::g_script_error_level[inst] < 33);
assert(inst == 0 || inst == 1);
//if (game::_setjmp3((int *)game::g_script_error.get() + 0x10 * (0x21 * inst + game::g_script_error_level[inst]), 0))
if (!setjmp(g_script_error[inst][game::g_script_error_level[inst]]))
auto jmp_bufs = reinterpret_cast<jmp_buf(*)[2][33]>(game::g_script_error.get());
if (!game::_setjmp3((*jmp_bufs)[inst][game::g_script_error_level[inst]], 0))
{
break;
}
@@ -2649,7 +2695,7 @@ namespace codsrc
int currentCaseValue;
const char* currentCodePos;
do
do // Scr_ReadIntArray(2 * game::gCaseCount[inst])
{
currentCaseValue = game::Scr_ReadUnsignedInt(inst, &game::gFs[inst].pos);
currentCodePos = game::Scr_ReadCodePos(inst, &game::gFs[inst].pos);
@@ -2679,6 +2725,10 @@ namespace codsrc
{
game::gOpcode[inst] = (game::OpcodeVM)game::Scr_ReadUnsignedByte(inst, &game::gFs[inst].pos);
interrupt_return:
// our addition
push_opcode_history(inst, game::gOpcode[inst]);
//
switch ( game::gOpcode[inst] )
{
case game::OP_End:
@@ -2944,8 +2994,8 @@ namespace codsrc
case game::OP_CallBuiltin1:
VM::OP_CallBuiltin(inst, 1);
continue;
case game::OP_CallBuiltin2:
case game::OP_CallBuiltin2:
VM::OP_CallBuiltin(inst, 2);
continue;
@@ -3259,7 +3309,7 @@ namespace codsrc
goto interrupt_return;
default:
game::gScrVmPub[inst].terminal_error = 1;
// game::gScrVmPub[inst].terminal_error = 1;
game::RuntimeError(inst, game::gFs[inst].pos, 0, game::va("CODE ERROR: unknown opcode %d", game::gOpcode[inst]), nullptr);
continue;
}
@@ -4207,7 +4257,17 @@ namespace codsrc
game::Scr_ClearOutParams(inst);
startTop = &game::gScrVmPub[inst].top[-paramcount];
paramcounta = game::gScrVmPub[inst].inparamcount - paramcount;
id = game::FindEntityId(classnum, entnum, inst);
// pluto
if (classnum == -1)
{
id = entnum; // this is for level notify
}
//
else
{
id = game::FindEntityId(classnum, entnum, inst);
}
if ( id )
{
@@ -4496,6 +4556,13 @@ namespace codsrc
unsigned short threadId;
const char* pos;
// pluto
if (game::plutonium::scr_execthread_update_codepos_func != nullptr)
{
game::plutonium::scr_execthread_update_codepos_func(inst, inst, &handle, &handle);
}
//
pos = &game::gScrVarPub[inst].programBuffer[handle];
if ( !game::gScrVmPub[inst].function_count )
@@ -4537,6 +4604,13 @@ namespace codsrc
const char* pos;
game::classNum_e classnum = game::CLASS_NUM_ENTITY;
// pluto
if (game::plutonium::scr_execentthread_update_codepos_func != nullptr)
{
game::plutonium::scr_execentthread_update_codepos_func(inst, &handle);
}
//
pos = &game::gScrVarPub[inst].programBuffer[handle];
if ( !game::gScrVmPub[inst].function_count )
@@ -4576,6 +4650,13 @@ namespace codsrc
unsigned int thread;
unsigned int paramcount = 0;
// pluto
if (game::plutonium::scr_addexecthread_update_codepos_func != nullptr)
{
game::plutonium::scr_addexecthread_update_codepos_func(inst, &handle);
}
//
if ( !game::gScrVmPub[inst].function_count )
{
assert(game::gScrVmPub[inst].localVars == game::gScrVmGlob[inst].localVarsStack - 1);
@@ -4621,6 +4702,10 @@ namespace codsrc
// Decomp Status: Tested, Completed
void Scr_InitSystem(game::scriptInstance_t inst)
{
// our additions
scheduler::exec_pre_scr_init_funcs(inst);
//
assert(!game::gScrVarPub[inst].timeArrayId);
//assert(!game::gScrVarPub[inst].ext_threadcount);
@@ -4646,6 +4731,10 @@ namespace codsrc
assert(!game::gScrVarPub[inst].freeEntList);
game::g_script_error_level[inst] = -1;
// our additions
scheduler::exec_post_scr_init_funcs(inst);
//
}
//Restored function
@@ -4801,20 +4890,24 @@ namespace codsrc
return result;
}
result.u.linkPointer = (const char*)value->u.intValue;
result = value->u.anim;
if ( !animTreeInputForValidation )
{
return result;
}
animTreeAnimPtr = animTreeInputForValidation->anims;
animPtr = game::gScrAnimPub[inst].xanim_lookup[user][(unsigned int)result.u.linkPointer >> 16].anims;
assert(animTreeInputForValidation);
animTreeAnimPtr = animTreeInputForValidation->anims; // XAnimGetAnims(inst, animTreeInputForValidation);
assert(result.u.s.tree > 0 && result.u.s.tree < game::gScrAnimPub[inst].xanim_num[user]);
animPtr = game::gScrAnimPub[inst].xanim_lookup[user][result.u.s.tree].anims; // Scr_GetAnims(inst, user, result.u.s.tree);
if ( animPtr == animTreeAnimPtr )
{
return result;
}
debugMsg = game::XAnimGetAnimDebugName(value->u.intValue, animPtr);
debugMsg = game::XAnimGetAnimDebugName(result.u.s.index, animPtr);
game::gScrVarPub[inst].error_message = (char*)game::va("anim '%s' in animtree '%s' does not belong to the entity's animtree '%s'", debugMsg, animTreeAnimPtr->debugName, animTreeAnimPtr->debugName);
game::RemoveRefToValueInternal(game::SCRIPTINSTANCE_SERVER, value->type, value->u);
value->type = game::VAR_UNDEFINED;
@@ -5403,7 +5496,24 @@ namespace codsrc
{
game::Scr_SetErrorMessage(inst, error);
game::gScrVmPub[inst].terminal_error = is_terminal;
// pluto
if (is_terminal)
{
game::gScrVmPub[inst].terminal_error = is_terminal;
}
static game::dvar_s* all_gsc_errors_non_terminal = nullptr;
if (!all_gsc_errors_non_terminal)
{
all_gsc_errors_non_terminal = game::Dvar_FindVar("all_gsc_errors_non_terminal");
}
if (all_gsc_errors_non_terminal && all_gsc_errors_non_terminal->current.enabled)
{
game::gScrVmPub[inst].terminal_error = false;
}
//
game::Scr_ErrorInternal(inst);
}
@@ -5412,7 +5522,7 @@ namespace codsrc
{
game::Scr_DumpScriptThreads(inst);
game::gScrVmPub[inst].terminal_error = 1;
game::Scr_Error(error, inst, false);
game::Scr_Error(error, inst, false); // yes, this is a basegame bug, pluto fixes it above
}
// Decomp Status: Tested, Completed
@@ -5442,7 +5552,7 @@ namespace codsrc
}
else
{
return game::CScr_SetEntityField(offset, entnum, clientNum);
return game::CScr_SetEntityField(offset, entnum, clientNum);
}
}
@@ -5633,5 +5743,11 @@ namespace codsrc
{
game::Scr_NotifyNum_Internal(game::SCRIPTINSTANCE_SERVER, entnum, classnum, stringValue, paramcount);
}
// Restored
unsigned int Scr_GetNumParam(game::scriptInstance_t inst)
{
return game::gScrVmPub[inst].outparamcount;
}
}
#pragma warning(pop)
+1
View File
@@ -116,4 +116,5 @@ namespace codsrc
unsigned int GetInternalVariableIndex(game::scriptInstance_t inst, unsigned int unsignedValue);
const char* Scr_ReadData(game::scriptInstance_t inst, const char** pos, unsigned int count);
void Scr_NotifyNum(int entnum, game::classNum_e classnum, unsigned int stringValue, unsigned int paramcount);
unsigned int Scr_GetNumParam(game::scriptInstance_t inst);
}
File diff suppressed because it is too large Load Diff
+21
View File
@@ -0,0 +1,21 @@
#pragma once
namespace codsrc
{
unsigned int LowerCase(unsigned int strVal);
int yyparse();
int StringValue(int len, const char* str);
int yylex();
int yy_get_next_buffer();
int yy_get_previous_state();
int yy_try_NUL_trans(int yy_current_state);
void yyrestart();
game::yy_buffer_state* yy_create_buffer();
void yy_flush_buffer(game::yy_buffer_state* result);
void ScriptParse(game::scriptInstance_t a1, game::sval_u* parseData);
FILE* yy_load_buffer_state();
void yy_fatal_error(const char* err);
void* yy_flex_realloc(void* ptr, unsigned int size);
void yy_init_buffer(game::yy_buffer_state* b, FILE* file);
}
@@ -0,0 +1,405 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "utils/hook.hpp"
//#include "codsrc/clientscript/cscr_animtree.hpp"
#ifndef DISABLE_RE_CSCR_ANIMTREE
namespace re_cscr_animtree
{
utils::hook::detour AnimTreeCompileError_hook;
utils::hook::detour GetAnimTreeParseProperties_hook;
utils::hook::detour Scr_EmitAnimationInternal_hook;
utils::hook::detour AnimTreeParseInternal_hook;
utils::hook::detour Scr_AnimTreeParse_hook;
utils::hook::detour Scr_GetAnimTreeSize_hook;
utils::hook::detour ConnectScriptToAnim_hook;
utils::hook::detour Scr_GetAnimsIndex_hook;
utils::hook::detour Scr_CreateAnimationTree_hook;
utils::hook::detour Scr_CheckAnimsDefined_hook;
utils::hook::detour Scr_PrecacheAnimationTree_hook;
utils::hook::detour Scr_UsingTreeInternal_hook;
utils::hook::detour Scr_UsingTree_hook;
utils::hook::detour Scr_SetAnimTreeConfigstring_hook;
utils::hook::detour Scr_LoadAnimTreeInternal_hook;
utils::hook::detour Scr_LoadAnimTreeAtIndex_hook;
utils::hook::detour Scr_FindAnimTree_hook;
utils::hook::detour Scr_FindAnim_hook;
void* AnimTreeCompileError_original;
void* GetAnimTreeParseProperties_original;
void* Scr_EmitAnimationInternal_original;
void* AnimTreeParseInternal_original;
void* Scr_AnimTreeParse_original;
void* Scr_GetAnimTreeSize_original;
void* ConnectScriptToAnim_original;
void* Scr_GetAnimsIndex_original;
void* Scr_CreateAnimationTree_original;
void* Scr_CheckAnimsDefined_original;
void* Scr_PrecacheAnimationTree_original;
void* Scr_UsingTreeInternal_original;
void* Scr_UsingTree_original;
void* Scr_SetAnimTreeConfigstring_original;
void* Scr_LoadAnimTreeInternal_original;
void* Scr_LoadAnimTreeAtIndex_original;
void* Scr_FindAnimTree_original;
void* Scr_FindAnim_original;
namespace
{
void AnimTreeCompileError_stub(game::scriptInstance_t inst, const char * errorMsg)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
return AnimTreeCompileError_hook.invoke<void>(inst, errorMsg);
#else
return cscr_animtree::AnimTreeCompileError(inst, errorMsg);
#endif
}
int GetAnimTreeParseProperties_stub(game::scriptInstance_t inst)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
return GetAnimTreeParseProperties_hook.invoke<int>(inst);
#else
return cscr_animtree::GetAnimTreeParseProperties(inst);
#endif
}
void Scr_EmitAnimationInternal_call(game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr, const char * pos, unsigned int animName, unsigned int names)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
game::Scr_EmitAnimationInternal(inst, pos, animName, names, Scr_EmitAnimationInternal_original);
#else
cscr_animtree::Scr_EmitAnimationInternal(inst, pos, animName, names);
#endif
}
// void __usercall Scr_EmitAnimationInternal(game::scriptInstance_t inst@<edi>, const char *pos, unsigned int animName, unsigned int names)
NAKED void Scr_EmitAnimationInternal_stub()
{
_asm
{
push edi;
call Scr_EmitAnimationInternal_call;
add esp, 0x4;
ret;
}
}
char AnimTreeParseInternal_stub(game::scriptInstance_t inst, int parentId, int names, int bIncludeParent, int bLoop, int bComplete)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
return AnimTreeParseInternal_hook.invoke<char>(inst, parentId, names, bIncludeParent, bLoop, bComplete);
#else
return cscr_animtree::AnimTreeParseInternal(inst, parentId, names, bIncludeParent, bLoop, bComplete);
#endif
}
void Scr_AnimTreeParse_call(game::scriptInstance_t inst, const char * pos, [[maybe_unused]] void* caller_addr, unsigned int parentNode, unsigned int names)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
game::Scr_AnimTreeParse(inst, pos, parentNode, names, Scr_AnimTreeParse_original);
#else
cscr_animtree::Scr_AnimTreeParse(inst, pos, parentNode, names);
#endif
}
// void __usercall Scr_AnimTreeParse(game::scriptInstance_t inst@<eax>, const char *pos@<edi>, unsigned int parentNode, unsigned int names)
NAKED void Scr_AnimTreeParse_stub()
{
_asm
{
push edi;
push eax;
call Scr_AnimTreeParse_call;
add esp, 0x8;
ret;
}
}
int Scr_GetAnimTreeSize_stub(game::scriptInstance_t inst, unsigned int parentNode)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
return Scr_GetAnimTreeSize_hook.invoke<int>(inst, parentNode);
#else
return cscr_animtree::Scr_GetAnimTreeSize(inst, parentNode);
#endif
}
void ConnectScriptToAnim_call(unsigned int name, unsigned int names, [[maybe_unused]] void* caller_addr, game::scriptInstance_t inst, int index, unsigned int filename, int treeIndex)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
game::ConnectScriptToAnim(name, names, inst, index, filename, treeIndex, ConnectScriptToAnim_original);
#else
cscr_animtree::ConnectScriptToAnim(name, names, inst, index, filename, treeIndex);
#endif
}
// void __usercall ConnectScriptToAnim(unsigned int name@<eax>, unsigned int names@<edi>, game::scriptInstance_t inst, int index, unsigned int filename, int treeIndex)
NAKED void ConnectScriptToAnim_stub()
{
_asm
{
push edi;
push eax;
call ConnectScriptToAnim_call;
add esp, 0x8;
ret;
}
}
int Scr_GetAnimsIndex_call(game::XAnim_s * anim, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
return game::Scr_GetAnimsIndex(anim, Scr_GetAnimsIndex_original);
#else
return cscr_animtree::Scr_GetAnimsIndex(anim);
#endif
}
// int __usercall Scr_GetAnimsIndex@<eax>(game::XAnim_s *anim@<ecx>)
NAKED int Scr_GetAnimsIndex_stub()
{
_asm
{
push ecx;
call Scr_GetAnimsIndex_call;
add esp, 0x4;
ret;
}
}
int Scr_CreateAnimationTree_stub(game::scriptInstance_t inst, unsigned int parentNode, unsigned int rootData, game::XAnim_s* animtree, unsigned int childIndex, const char* name, unsigned int parentIndex, unsigned int filename, int treeIndex, int flags)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
return Scr_CreateAnimationTree_hook.invoke<int>(inst, parentNode, rootData, animtree, childIndex, name, parentIndex, filename, treeIndex, flags);
#else
return cscr_animtree::Scr_CreateAnimationTree(inst, parentNode, rootData, animtree, childIndex, name, parentIndex, filename, treeIndex, flags);
#endif
}
void Scr_CheckAnimsDefined_call(unsigned int names, game::scriptInstance_t a2, [[maybe_unused]] void* caller_addr, unsigned int filename)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
game::Scr_CheckAnimsDefined(names, a2, filename, Scr_CheckAnimsDefined_original);
#else
cscr_animtree::Scr_CheckAnimsDefined(names, a2, filename);
#endif
}
// void __usercall Scr_CheckAnimsDefined(unsigned int names@<eax>, game::scriptInstance_t a2@<ecx>, unsigned int filename)
NAKED void Scr_CheckAnimsDefined_stub()
{
_asm
{
push ecx;
push eax;
call Scr_CheckAnimsDefined_call;
add esp, 0x8;
ret;
}
}
void Scr_PrecacheAnimationTree_stub(game::scriptInstance_t inst, unsigned int parentNode)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
Scr_PrecacheAnimationTree_hook.invoke<void>(inst, parentNode);
#else
cscr_animtree::Scr_PrecacheAnimationTree(inst, parentNode);
#endif
}
unsigned int Scr_UsingTreeInternal_call(const char * filename, int user, [[maybe_unused]] void* caller_addr, game::scriptInstance_t inst, unsigned int * index)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
return game::Scr_UsingTreeInternal(filename, user, inst, index, Scr_UsingTreeInternal_original);
#else
return cscr_animtree::Scr_UsingTreeInternal(filename, user, inst, index);
#endif
}
// unsigned int __usercall Scr_UsingTreeInternal@<eax>(const char *filename@<eax>, int user@<ecx>, game::scriptInstance_t inst, unsigned int *index)
NAKED unsigned int Scr_UsingTreeInternal_stub()
{
_asm
{
push ecx;
push eax;
call Scr_UsingTreeInternal_call;
add esp, 0x8;
ret;
}
}
void Scr_UsingTree_call(game::scriptInstance_t a1, [[maybe_unused]] void* caller_addr, const char * filename, unsigned int sourcePos)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
game::Scr_UsingTree(a1, filename, sourcePos, Scr_UsingTree_original);
#else
cscr_animtree::Scr_UsingTree(a1, filename, sourcePos);
#endif
}
// void __usercall Scr_UsingTree(game::scriptInstance_t a1@<edi>, const char *filename, unsigned int sourcePos)
NAKED void Scr_UsingTree_stub()
{
_asm
{
push edi;
call Scr_UsingTree_call;
add esp, 0x4;
ret;
}
}
void Scr_SetAnimTreeConfigstring_stub(const char * animtreeName)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
Scr_SetAnimTreeConfigstring_hook.invoke<void>(animtreeName);
#else
cscr_animtree::Scr_SetAnimTreeConfigstring(animtreeName);
#endif
}
bool Scr_LoadAnimTreeInternal_call(const char * animtreeName, game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr, unsigned int parentNode, unsigned int names)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
return game::Scr_LoadAnimTreeInternal(animtreeName, inst, parentNode, names, Scr_LoadAnimTreeInternal_original);
#else
return cscr_animtree::Scr_LoadAnimTreeInternal(animtreeName, inst, parentNode, names);
#endif
}
// bool __usercall Scr_LoadAnimTreeInternal@<al>(const char *animtreeName@<eax>, game::scriptInstance_t inst@<ecx>, unsigned int parentNode, unsigned int names)
NAKED bool Scr_LoadAnimTreeInternal_stub()
{
_asm
{
push ecx;
push eax;
call Scr_LoadAnimTreeInternal_call;
add esp, 0x8;
ret;
}
}
void Scr_LoadAnimTreeAtIndex_call(game::scriptInstance_t inst, int user, [[maybe_unused]] void* caller_addr, unsigned int index, void *(__cdecl * Alloc)(int), int modCheckSum)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
return game::Scr_LoadAnimTreeAtIndex(inst, user, index, Alloc, modCheckSum, Scr_LoadAnimTreeAtIndex_original);
#else
return cscr_animtree::Scr_LoadAnimTreeAtIndex(inst, user, index, Alloc, modCheckSum);
#endif
}
// void __usercall Scr_LoadAnimTreeAtIndex(game::scriptInstance_t inst@<ecx>, int user@<eax>, unsigned int index, void *(__cdecl *Alloc)(int), int modCheckSum)
NAKED void Scr_LoadAnimTreeAtIndex_stub()
{
_asm
{
push eax;
push ecx;
call Scr_LoadAnimTreeAtIndex_call;
add esp, 0x8;
ret;
}
}
game::scr_animtree_t Scr_FindAnimTree_call(const char * filename, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
return game::Scr_FindAnimTree(filename, Scr_FindAnimTree_original);
#else
return cscr_animtree::Scr_FindAnimTree(filename);
#endif
}
// game::XAnim_s *__usercall Scr_FindAnimTree@<eax>(const char *filename@<eax>)
NAKED game::XAnim_s * Scr_FindAnimTree_stub()
{
_asm
{
push eax;
call Scr_FindAnimTree_call;
add esp, 0x4;
ret;
}
}
void Scr_FindAnim_call(const char * animName, [[maybe_unused]] void* caller_addr, game::scr_anim_s a2, int user)
{
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
game::Scr_FindAnim(animName, a2, user, Scr_FindAnim_original);
#else
cscr_animtree::Scr_FindAnim(animName, a2, user);
#endif
}
// void __usercall Scr_FindAnim(const char *animName@<edx>, game::scr_anim_s a2, int user)
NAKED void Scr_FindAnim_stub()
{
_asm
{
push edx;
call Scr_FindAnim_call;
add esp, 0x4;
ret;
}
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
bool quick = true;
#ifdef RE_CSCR_ANIMTREE_USE_WRAPPERS
quick = false;
#endif
AnimTreeCompileError_hook.create(game::AnimTreeCompileError.get(), AnimTreeCompileError_stub, quick);
GetAnimTreeParseProperties_hook.create(game::GetAnimTreeParseProperties.get(), GetAnimTreeParseProperties_stub, quick);
Scr_EmitAnimationInternal_hook.create(game::Scr_EmitAnimationInternal_ADDR(), Scr_EmitAnimationInternal_stub, quick);
AnimTreeParseInternal_hook.create(game::AnimTreeParseInternal.get(), AnimTreeParseInternal_stub, quick);
Scr_AnimTreeParse_hook.create(game::Scr_AnimTreeParse_ADDR(), Scr_AnimTreeParse_stub, quick);
Scr_GetAnimTreeSize_hook.create(game::Scr_GetAnimTreeSize.get(), Scr_GetAnimTreeSize_stub, quick);
ConnectScriptToAnim_hook.create(game::ConnectScriptToAnim_ADDR(), ConnectScriptToAnim_stub, quick);
Scr_GetAnimsIndex_hook.create(game::Scr_GetAnimsIndex_ADDR(), Scr_GetAnimsIndex_stub, quick);
Scr_CreateAnimationTree_hook.create(game::Scr_CreateAnimationTree.get(), Scr_CreateAnimationTree_stub, quick);
Scr_CheckAnimsDefined_hook.create(game::Scr_CheckAnimsDefined_ADDR(), Scr_CheckAnimsDefined_stub, quick);
Scr_PrecacheAnimationTree_hook.create(game::Scr_PrecacheAnimationTree.get(), Scr_PrecacheAnimationTree_stub, quick);
Scr_UsingTreeInternal_hook.create(game::Scr_UsingTreeInternal_ADDR(), Scr_UsingTreeInternal_stub, quick);
Scr_UsingTree_hook.create(game::Scr_UsingTree_ADDR(), Scr_UsingTree_stub, quick);
Scr_SetAnimTreeConfigstring_hook.create(game::Scr_SetAnimTreeConfigstring.get(), Scr_SetAnimTreeConfigstring_stub, quick);
Scr_LoadAnimTreeInternal_hook.create(game::Scr_LoadAnimTreeInternal_ADDR(), Scr_LoadAnimTreeInternal_stub, quick);
Scr_LoadAnimTreeAtIndex_hook.create(game::Scr_LoadAnimTreeAtIndex_ADDR(), Scr_LoadAnimTreeAtIndex_stub, quick);
Scr_FindAnimTree_hook.create(game::Scr_FindAnimTree_ADDR(), Scr_FindAnimTree_stub, quick);
Scr_FindAnim_hook.create(game::Scr_FindAnim_ADDR(), Scr_FindAnim_stub, quick);
//Original hook function addresses
AnimTreeCompileError_original = AnimTreeCompileError_hook.get_original();
GetAnimTreeParseProperties_original = GetAnimTreeParseProperties_hook.get_original();
Scr_EmitAnimationInternal_original = Scr_EmitAnimationInternal_hook.get_original();
AnimTreeParseInternal_original = AnimTreeParseInternal_hook.get_original();
Scr_AnimTreeParse_original = Scr_AnimTreeParse_hook.get_original();
Scr_GetAnimTreeSize_original = Scr_GetAnimTreeSize_hook.get_original();
ConnectScriptToAnim_original = ConnectScriptToAnim_hook.get_original();
Scr_GetAnimsIndex_original = Scr_GetAnimsIndex_hook.get_original();
Scr_CreateAnimationTree_original = Scr_CreateAnimationTree_hook.get_original();
Scr_CheckAnimsDefined_original = Scr_CheckAnimsDefined_hook.get_original();
Scr_PrecacheAnimationTree_original = Scr_PrecacheAnimationTree_hook.get_original();
Scr_UsingTreeInternal_original = Scr_UsingTreeInternal_hook.get_original();
Scr_UsingTree_original = Scr_UsingTree_hook.get_original();
Scr_SetAnimTreeConfigstring_original = Scr_SetAnimTreeConfigstring_hook.get_original();
Scr_LoadAnimTreeInternal_original = Scr_LoadAnimTreeInternal_hook.get_original();
Scr_LoadAnimTreeAtIndex_original = Scr_LoadAnimTreeAtIndex_hook.get_original();
Scr_FindAnimTree_original = Scr_FindAnimTree_hook.get_original();
Scr_FindAnim_original = Scr_FindAnim_hook.get_original();
}
private:
};
}
REGISTER_COMPONENT(re_cscr_animtree::component)
#endif
File diff suppressed because it is too large Load Diff
@@ -3,8 +3,7 @@
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_main.hpp"
//#define RE_CSCR_MAIN_USE_WRAPPERS
#ifndef DISABLE_RE_CSCR_MAIN
namespace re_cscr_main
{
utils::hook::detour Scr_IsIdentifier_hook;
@@ -273,19 +272,24 @@ namespace re_cscr_main
public:
void post_unpack() override
{
Scr_IsIdentifier_hook.create(game::Scr_IsIdentifier_ADDR(), Scr_IsIdentifier_stub);
Scr_GetFunctionHandle_hook.create(game::Scr_GetFunctionHandle_ADDR(), Scr_GetFunctionHandle_stub);
SL_TransferToCanonicalString_hook.create(game::SL_TransferToCanonicalString_ADDR(), SL_TransferToCanonicalString_stub);
SL_GetCanonicalString_hook.create(game::SL_GetCanonicalString_ADDR(), SL_GetCanonicalString_stub);
Scr_BeginLoadScripts_hook.create(game::Scr_BeginLoadScripts_ADDR(), Scr_BeginLoadScripts_stub);
Scr_BeginLoadAnimTrees_hook.create(game::Scr_BeginLoadAnimTrees_ADDR(), Scr_BeginLoadAnimTrees_stub);
Scr_ScanFile_hook.create(game::Scr_ScanFile_ADDR(), Scr_ScanFile_stub);
Scr_LoadScriptInternal_hook.create(game::Scr_LoadScriptInternal.get(), Scr_LoadScriptInternal_stub);
Scr_LoadScript_hook.create(game::Scr_LoadScript_ADDR(), Scr_LoadScript_stub);
Scr_EndLoadScripts_hook.create(game::Scr_EndLoadScripts.get(), Scr_EndLoadScripts_stub);
Scr_PrecacheAnimTrees_hook.create(game::Scr_PrecacheAnimTrees.get(), Scr_PrecacheAnimTrees_stub);
Scr_EndLoadAnimTrees_hook.create(game::Scr_EndLoadAnimTrees.get(), Scr_EndLoadAnimTrees_stub);
Scr_FreeScripts_hook.create(game::Scr_FreeScripts_ADDR(), Scr_FreeScripts_stub);
bool quick = true;
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
quick = false;
#endif
Scr_IsIdentifier_hook.create(game::Scr_IsIdentifier_ADDR(), Scr_IsIdentifier_stub, quick);
Scr_GetFunctionHandle_hook.create(game::Scr_GetFunctionHandle_ADDR(), Scr_GetFunctionHandle_stub, quick);
SL_TransferToCanonicalString_hook.create(game::SL_TransferToCanonicalString_ADDR(), SL_TransferToCanonicalString_stub, quick);
SL_GetCanonicalString_hook.create(game::SL_GetCanonicalString_ADDR(), SL_GetCanonicalString_stub, quick);
Scr_BeginLoadScripts_hook.create(game::Scr_BeginLoadScripts_ADDR(), Scr_BeginLoadScripts_stub, quick);
Scr_BeginLoadAnimTrees_hook.create(game::Scr_BeginLoadAnimTrees_ADDR(), Scr_BeginLoadAnimTrees_stub, quick);
Scr_ScanFile_hook.create(game::Scr_ScanFile_ADDR(), Scr_ScanFile_stub, quick);
Scr_LoadScriptInternal_hook.create(game::Scr_LoadScriptInternal.get(), Scr_LoadScriptInternal_stub, quick);
Scr_LoadScript_hook.create(game::Scr_LoadScript_ADDR(), Scr_LoadScript_stub, quick);
Scr_EndLoadScripts_hook.create(game::Scr_EndLoadScripts.get(), Scr_EndLoadScripts_stub, quick);
Scr_PrecacheAnimTrees_hook.create(game::Scr_PrecacheAnimTrees.get(), Scr_PrecacheAnimTrees_stub, quick);
Scr_EndLoadAnimTrees_hook.create(game::Scr_EndLoadAnimTrees.get(), Scr_EndLoadAnimTrees_stub, quick);
Scr_FreeScripts_hook.create(game::Scr_FreeScripts_ADDR(), Scr_FreeScripts_stub, quick);
//Original hook function addresses
Scr_IsIdentifier_original = Scr_IsIdentifier_hook.get_original();
@@ -306,4 +310,5 @@ namespace re_cscr_main
private:
};
}
REGISTER_COMPONENT(re_cscr_main::component)
REGISTER_COMPONENT(re_cscr_main::component)
#endif
@@ -3,8 +3,7 @@
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_memorytree.hpp"
//#define RE_CSCR_MEMORYTREE_USE_WRAPPERS
#ifndef DISABLE_RE_CSCR_MEMORYTREE
namespace re_cscr_memorytree
{
utils::hook::detour MT_GetSubTreeSize_hook;
@@ -270,20 +269,25 @@ namespace re_cscr_memorytree
public:
void post_unpack() override
{
MT_GetSubTreeSize_hook.create(game::MT_GetSubTreeSize.get(), MT_GetSubTreeSize_stub);
MT_DumpTree_hook.create(game::MT_DumpTree.get(), MT_DumpTree_stub);
MT_InitBits_hook.create(game::MT_InitBits_ADDR(), MT_InitBits_stub);
MT_GetScore_hook.create(game::MT_GetScore_ADDR(), MT_GetScore_stub);
MT_AddMemoryNode_hook.create(game::MT_AddMemoryNode.get(), MT_AddMemoryNode_stub);
MT_RemoveMemoryNode_hook.create(game::MT_RemoveMemoryNode.get(), MT_RemoveMemoryNode_stub);
MT_RemoveHeadMemoryNode_hook.create(game::MT_RemoveHeadMemoryNode.get(), MT_RemoveHeadMemoryNode_stub);
MT_Init_hook.create(game::MT_Init_ADDR(), MT_Init_stub);
MT_Error_hook.create(game::MT_Error_ADDR(), MT_Error_stub);
MT_GetSize_hook.create(game::MT_GetSize_ADDR(), MT_GetSize_stub);
MT_AllocIndex_hook.create(game::MT_AllocIndex_ADDR(), MT_AllocIndex_stub);
MT_FreeIndex_hook.create(game::MT_FreeIndex_ADDR(), MT_FreeIndex_stub);
MT_Alloc_hook.create(game::MT_Alloc_ADDR(), MT_Alloc_stub);
MT_Free_hook.create(game::MT_Free.get(), MT_Free_stub);
bool quick = true;
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
quick = false;
#endif
MT_GetSubTreeSize_hook.create(game::MT_GetSubTreeSize.get(), MT_GetSubTreeSize_stub, quick);
MT_DumpTree_hook.create(game::MT_DumpTree.get(), MT_DumpTree_stub, quick);
MT_InitBits_hook.create(game::MT_InitBits_ADDR(), MT_InitBits_stub, quick);
MT_GetScore_hook.create(game::MT_GetScore_ADDR(), MT_GetScore_stub, quick);
MT_AddMemoryNode_hook.create(game::MT_AddMemoryNode.get(), MT_AddMemoryNode_stub, quick);
MT_RemoveMemoryNode_hook.create(game::MT_RemoveMemoryNode.get(), MT_RemoveMemoryNode_stub, quick);
MT_RemoveHeadMemoryNode_hook.create(game::MT_RemoveHeadMemoryNode.get(), MT_RemoveHeadMemoryNode_stub, quick);
MT_Init_hook.create(game::MT_Init_ADDR(), MT_Init_stub, quick);
MT_Error_hook.create(game::MT_Error_ADDR(), MT_Error_stub, quick);
MT_GetSize_hook.create(game::MT_GetSize_ADDR(), MT_GetSize_stub, quick);
MT_AllocIndex_hook.create(game::MT_AllocIndex_ADDR(), MT_AllocIndex_stub, quick);
MT_FreeIndex_hook.create(game::MT_FreeIndex_ADDR(), MT_FreeIndex_stub, quick);
MT_Alloc_hook.create(game::MT_Alloc_ADDR(), MT_Alloc_stub, quick);
MT_Free_hook.create(game::MT_Free.get(), MT_Free_stub, quick);
//Original hook function addresses
MT_GetSubTreeSize_original = MT_GetSubTreeSize_hook.get_original();
@@ -305,4 +309,5 @@ namespace re_cscr_memorytree
private:
};
}
REGISTER_COMPONENT(re_cscr_memorytree::component)
REGISTER_COMPONENT(re_cscr_memorytree::component)
#endif
@@ -3,8 +3,7 @@
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_parser.hpp"
//#define RE_CSCR_PARSER_USE_WRAPPERS
#ifndef DISABLE_RE_CSCR_PARSER
namespace re_cscr_parser
{
utils::hook::detour Scr_InitOpcodeLookup_hook;
@@ -534,29 +533,34 @@ namespace re_cscr_parser
public:
void post_unpack() override
{
Scr_InitOpcodeLookup_hook.create(game::Scr_InitOpcodeLookup_ADDR(), Scr_InitOpcodeLookup_stub);
Scr_ShutdownOpcodeLookup_hook.create(game::Scr_ShutdownOpcodeLookup_ADDR(), Scr_ShutdownOpcodeLookup_stub);
AddOpcodePos_hook.create(game::AddOpcodePos_ADDR(), AddOpcodePos_stub);
RemoveOpcodePos_hook.create(game::RemoveOpcodePos_ADDR(), RemoveOpcodePos_stub);
AddThreadStartOpcodePos_hook.create(game::AddThreadStartOpcodePos_ADDR(), AddThreadStartOpcodePos_stub);
Scr_GetSourceBuffer_hook.create(game::Scr_GetSourceBuffer_ADDR(), Scr_GetSourceBuffer_stub);
Scr_GetLineNumInternal_hook.create(game::Scr_GetLineNumInternal_ADDR(), Scr_GetLineNumInternal_stub);
Scr_GetNewSourceBuffer_hook.create(game::Scr_GetNewSourceBuffer_ADDR(), Scr_GetNewSourceBuffer_stub);
Scr_AddSourceBufferInternal_hook.create(game::Scr_AddSourceBufferInternal_ADDR(), Scr_AddSourceBufferInternal_stub);
Scr_ReadFile_FastFile_hook.create(game::Scr_ReadFile_FastFile.get(), Scr_ReadFile_FastFile_stub);
Scr_ReadFile_LoadObj_hook.create(game::Scr_ReadFile_LoadObj.get(), Scr_ReadFile_LoadObj_stub);
Scr_ReadFile_hook.create(game::Scr_ReadFile_ADDR(), Scr_ReadFile_stub);
Scr_AddSourceBuffer_hook.create(game::Scr_AddSourceBuffer_ADDR(), Scr_AddSourceBuffer_stub);
Scr_CopyFormattedLine_hook.create(game::Scr_CopyFormattedLine_ADDR(), Scr_CopyFormattedLine_stub);
Scr_GetLineInfo_hook.create(game::Scr_GetLineInfo_ADDR(), Scr_GetLineInfo_stub);
Scr_PrintSourcePos_hook.create(game::Scr_PrintSourcePos_ADDR(), Scr_PrintSourcePos_stub);
Scr_GetPrevSourcePosOpcodeLookup_hook.create(game::Scr_GetPrevSourcePosOpcodeLookup_ADDR(), Scr_GetPrevSourcePosOpcodeLookup_stub);
Scr_GetTextSourcePos_hook.create(game::Scr_GetTextSourcePos_ADDR(), Scr_GetTextSourcePos_stub);
Scr_PrintPrevCodePos_hook.create(game::Scr_PrintPrevCodePos_ADDR(), Scr_PrintPrevCodePos_stub);
CompileError_hook.create(game::CompileError.get(), CompileError_stub);
CompileError2_hook.create(game::CompileError2_ADDR(), CompileError2_stub);
RuntimeErrorInternal_hook.create(game::RuntimeErrorInternal_ADDR(), RuntimeErrorInternal_stub);
RuntimeError_hook.create(game::RuntimeError_ADDR(), RuntimeError_stub);
bool quick = true;
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
quick = false;
#endif
Scr_InitOpcodeLookup_hook.create(game::Scr_InitOpcodeLookup_ADDR(), Scr_InitOpcodeLookup_stub, quick);
Scr_ShutdownOpcodeLookup_hook.create(game::Scr_ShutdownOpcodeLookup_ADDR(), Scr_ShutdownOpcodeLookup_stub, quick);
AddOpcodePos_hook.create(game::AddOpcodePos_ADDR(), AddOpcodePos_stub, quick);
RemoveOpcodePos_hook.create(game::RemoveOpcodePos_ADDR(), RemoveOpcodePos_stub, quick);
AddThreadStartOpcodePos_hook.create(game::AddThreadStartOpcodePos_ADDR(), AddThreadStartOpcodePos_stub, quick);
Scr_GetSourceBuffer_hook.create(game::Scr_GetSourceBuffer_ADDR(), Scr_GetSourceBuffer_stub, quick);
Scr_GetLineNumInternal_hook.create(game::Scr_GetLineNumInternal_ADDR(), Scr_GetLineNumInternal_stub, quick);
Scr_GetNewSourceBuffer_hook.create(game::Scr_GetNewSourceBuffer_ADDR(), Scr_GetNewSourceBuffer_stub, quick);
Scr_AddSourceBufferInternal_hook.create(game::Scr_AddSourceBufferInternal_ADDR(), Scr_AddSourceBufferInternal_stub, quick);
Scr_ReadFile_FastFile_hook.create(game::Scr_ReadFile_FastFile.get(), Scr_ReadFile_FastFile_stub, quick);
Scr_ReadFile_LoadObj_hook.create(game::Scr_ReadFile_LoadObj.get(), Scr_ReadFile_LoadObj_stub, quick);
Scr_ReadFile_hook.create(game::Scr_ReadFile_ADDR(), Scr_ReadFile_stub, quick);
Scr_AddSourceBuffer_hook.create(game::Scr_AddSourceBuffer_ADDR(), Scr_AddSourceBuffer_stub, quick);
Scr_CopyFormattedLine_hook.create(game::Scr_CopyFormattedLine_ADDR(), Scr_CopyFormattedLine_stub, quick);
Scr_GetLineInfo_hook.create(game::Scr_GetLineInfo_ADDR(), Scr_GetLineInfo_stub, quick);
Scr_PrintSourcePos_hook.create(game::Scr_PrintSourcePos_ADDR(), Scr_PrintSourcePos_stub, quick);
Scr_GetPrevSourcePosOpcodeLookup_hook.create(game::Scr_GetPrevSourcePosOpcodeLookup_ADDR(), Scr_GetPrevSourcePosOpcodeLookup_stub, quick);
Scr_GetTextSourcePos_hook.create(game::Scr_GetTextSourcePos_ADDR(), Scr_GetTextSourcePos_stub, quick);
Scr_PrintPrevCodePos_hook.create(game::Scr_PrintPrevCodePos_ADDR(), Scr_PrintPrevCodePos_stub, quick);
CompileError_hook.create(game::CompileError.get(), CompileError_stub, quick);
CompileError2_hook.create(game::CompileError2_ADDR(), CompileError2_stub, quick);
RuntimeErrorInternal_hook.create(game::RuntimeErrorInternal_ADDR(), RuntimeErrorInternal_stub, quick);
RuntimeError_hook.create(game::RuntimeError_ADDR(), RuntimeError_stub, quick);
//Original hook function addresses
Scr_InitOpcodeLookup_original = Scr_InitOpcodeLookup_hook.get_original();
@@ -587,4 +591,5 @@ namespace re_cscr_parser
private:
};
}
REGISTER_COMPONENT(re_cscr_parser::component)
REGISTER_COMPONENT(re_cscr_parser::component)
#endif
@@ -3,8 +3,7 @@
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_parsetree.hpp"
//#define RE_CSCR_PARSETREE_USE_WRAPPERS
#ifndef DISABLE_RE_CSCR_PARSETREE
namespace re_cscr_parsetree
{
utils::hook::detour Scr_InitAllocNode_hook;
@@ -161,19 +160,24 @@ namespace re_cscr_parsetree
public:
void post_unpack() override
{
Scr_InitAllocNode_hook.create(game::Scr_InitAllocNode.get(), Scr_InitAllocNode_stub);
node0_hook.create(game::node0.get(), node0_stub);
node1_hook.create(game::node1.get(), node1_stub);
node2_hook.create(game::node2.get(), node2_stub);
node3_hook.create(game::node3.get(), node3_stub);
node4_hook.create(game::node4.get(), node4_stub);
node5_hook.create(game::node5.get(), node5_stub);
node6_hook.create(game::node6.get(), node6_stub);
node7_hook.create(game::node7.get(), node7_stub);
node8_hook.create(game::node8.get(), node8_stub);
linked_list_end_hook.create(game::linked_list_end.get(), linked_list_end_stub);
prepend_node_hook.create(game::prepend_node.get(), prepend_node_stub);
append_node_hook.create(game::append_node.get(), append_node_stub);
bool quick = true;
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
quick = false;
#endif
Scr_InitAllocNode_hook.create(game::Scr_InitAllocNode.get(), Scr_InitAllocNode_stub, quick);
node0_hook.create(game::node0.get(), node0_stub, quick);
node1_hook.create(game::node1.get(), node1_stub, quick);
node2_hook.create(game::node2.get(), node2_stub, quick);
node3_hook.create(game::node3.get(), node3_stub, quick);
node4_hook.create(game::node4.get(), node4_stub, quick);
node5_hook.create(game::node5.get(), node5_stub, quick);
node6_hook.create(game::node6.get(), node6_stub, quick);
node7_hook.create(game::node7.get(), node7_stub, quick);
node8_hook.create(game::node8.get(), node8_stub, quick);
linked_list_end_hook.create(game::linked_list_end.get(), linked_list_end_stub, quick);
prepend_node_hook.create(game::prepend_node.get(), prepend_node_stub, quick);
append_node_hook.create(game::append_node.get(), append_node_stub, quick);
//Original hook function addresses
Scr_InitAllocNode_original = Scr_InitAllocNode_hook.get_original();
@@ -194,4 +198,5 @@ namespace re_cscr_parsetree
private:
};
}
REGISTER_COMPONENT(re_cscr_parsetree::component)
REGISTER_COMPONENT(re_cscr_parsetree::component)
#endif
@@ -3,8 +3,7 @@
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_readwrite.hpp"
//#define RE_CSCR_READWRITE_USE_WRAPPERS
#ifndef DISABLE_RE_CSCR_READWRITE
namespace re_cscr_readwrite
{
utils::hook::detour FindVariableIndexInternal2_hook;
@@ -65,8 +64,13 @@ namespace re_cscr_readwrite
public:
void post_unpack() override
{
FindVariableIndexInternal2_hook.create(game::FindVariableIndexInternal2_ADDR(), FindVariableIndexInternal2_stub);
FindLastSibling_hook.create(game::FindLastSibling_ADDR(), FindLastSibling_stub);
bool quick = true;
#ifdef RE_CSCR_READWRITE_USE_WRAPPERS
quick = false;
#endif
FindVariableIndexInternal2_hook.create(game::FindVariableIndexInternal2_ADDR(), FindVariableIndexInternal2_stub, quick);
FindLastSibling_hook.create(game::FindLastSibling_ADDR(), FindLastSibling_stub, quick);
//Original hook function addresses
FindVariableIndexInternal2_original = FindVariableIndexInternal2_hook.get_original();
@@ -76,4 +80,5 @@ namespace re_cscr_readwrite
private:
};
}
REGISTER_COMPONENT(re_cscr_readwrite::component)
REGISTER_COMPONENT(re_cscr_readwrite::component)
#endif
@@ -3,8 +3,7 @@
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_stringlist.hpp"
//#define RE_CSCR_STRINGLIST_USE_WRAPPERS
#ifndef DISABLE_RE_CSCR_STRINGLIST
namespace re_cscr_stringlist
{
utils::hook::detour SL_ConvertToString_hook;
@@ -586,34 +585,39 @@ namespace re_cscr_stringlist
public:
void post_unpack() override
{
SL_ConvertToString_hook.create(game::SL_ConvertToString_ADDR(), SL_ConvertToString_stub);
SL_GetStringLen_hook.create(game::SL_GetStringLen_ADDR(), SL_GetStringLen_stub);
GetHashCode_hook.create(game::GetHashCode_ADDR(), GetHashCode_stub);
SL_Init_hook.create(game::SL_Init_ADDR(), SL_Init_stub);
SL_FindStringOfSize_hook.create(game::SL_FindStringOfSize_ADDR(), SL_FindStringOfSize_stub);
SL_FindString_hook.create(game::SL_FindString_ADDR(), SL_FindString_stub);
SL_FindLowercaseString_hook.create(game::SL_FindLowercaseString.get(), SL_FindLowercaseString_stub);
SL_AddUserInternal_hook.create(game::SL_AddUserInternal_ADDR(), SL_AddUserInternal_stub);
Mark_ScriptStringCustom_hook.create(game::Mark_ScriptStringCustom_ADDR(), Mark_ScriptStringCustom_stub);
SL_GetStringOfSize_hook.create(game::SL_GetStringOfSize.get(), SL_GetStringOfSize_stub);
SL_GetString__hook.create(game::SL_GetString__ADDR(), SL_GetString__stub);
SL_GetString__0_hook.create(game::SL_GetString__0_ADDR(), SL_GetString__0_stub);
SL_GetLowercaseStringOfLen_hook.create(game::SL_GetLowercaseStringOfLen.get(), SL_GetLowercaseStringOfLen_stub);
SL_GetLowercaseString_hook.create(game::SL_GetLowercaseString_ADDR(), SL_GetLowercaseString_stub);
SL_ConvertToLowercase_hook.create(game::SL_ConvertToLowercase.get(), SL_ConvertToLowercase_stub);
SL_TransferRefToUser_hook.create(game::SL_TransferRefToUser_ADDR(), SL_TransferRefToUser_stub);
SL_FreeString_hook.create(game::SL_FreeString.get(), SL_FreeString_stub);
SL_RemoveRefToString_hook.create(game::SL_RemoveRefToString_ADDR(), SL_RemoveRefToString_stub);
Scr_SetString_hook.create(game::Scr_SetString_ADDR(), Scr_SetString_stub);
Scr_SetStringFromCharString_hook.create(game::Scr_SetStringFromCharString_ADDR(), Scr_SetStringFromCharString_stub);
GScr_AllocString_hook.create(game::GScr_AllocString_ADDR(), GScr_AllocString_stub);
SL_GetStringForFloat_hook.create(game::SL_GetStringForFloat_ADDR(), SL_GetStringForFloat_stub);
SL_GetStringForInt_hook.create(game::SL_GetStringForInt_ADDR(), SL_GetStringForInt_stub);
SL_GetStringForVector_hook.create(game::SL_GetStringForVector_ADDR(), SL_GetStringForVector_stub);
SL_ShutdownSystem_hook.create(game::SL_ShutdownSystem_ADDR(), SL_ShutdownSystem_stub);
SL_TransferSystem_hook.create(game::SL_TransferSystem.get(), SL_TransferSystem_stub);
SL_CreateCanonicalFilename_hook.create(game::SL_CreateCanonicalFilename_ADDR(), SL_CreateCanonicalFilename_stub);
Scr_CreateCanonicalFilename_hook.create(game::Scr_CreateCanonicalFilename.get(), Scr_CreateCanonicalFilename_stub);
bool quick = true;
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
quick = false;
#endif
SL_ConvertToString_hook.create(game::SL_ConvertToString_ADDR(), SL_ConvertToString_stub, quick);
SL_GetStringLen_hook.create(game::SL_GetStringLen_ADDR(), SL_GetStringLen_stub, quick);
GetHashCode_hook.create(game::GetHashCode_ADDR(), GetHashCode_stub, quick);
SL_Init_hook.create(game::SL_Init_ADDR(), SL_Init_stub, quick);
SL_FindStringOfSize_hook.create(game::SL_FindStringOfSize_ADDR(), SL_FindStringOfSize_stub, quick);
SL_FindString_hook.create(game::SL_FindString_ADDR(), SL_FindString_stub, quick);
SL_FindLowercaseString_hook.create(game::SL_FindLowercaseString.get(), SL_FindLowercaseString_stub, quick);
SL_AddUserInternal_hook.create(game::SL_AddUserInternal_ADDR(), SL_AddUserInternal_stub, quick);
Mark_ScriptStringCustom_hook.create(game::Mark_ScriptStringCustom_ADDR(), Mark_ScriptStringCustom_stub, quick);
SL_GetStringOfSize_hook.create(game::SL_GetStringOfSize.get(), SL_GetStringOfSize_stub, quick);
SL_GetString__hook.create(game::SL_GetString__ADDR(), SL_GetString__stub, quick);
SL_GetString__0_hook.create(game::SL_GetString__0_ADDR(), SL_GetString__0_stub, quick);
SL_GetLowercaseStringOfLen_hook.create(game::SL_GetLowercaseStringOfLen.get(), SL_GetLowercaseStringOfLen_stub, quick);
SL_GetLowercaseString_hook.create(game::SL_GetLowercaseString_ADDR(), SL_GetLowercaseString_stub, quick);
SL_ConvertToLowercase_hook.create(game::SL_ConvertToLowercase.get(), SL_ConvertToLowercase_stub, quick);
SL_TransferRefToUser_hook.create(game::SL_TransferRefToUser_ADDR(), SL_TransferRefToUser_stub, quick);
SL_FreeString_hook.create(game::SL_FreeString.get(), SL_FreeString_stub, quick);
SL_RemoveRefToString_hook.create(game::SL_RemoveRefToString_ADDR(), SL_RemoveRefToString_stub, quick);
Scr_SetString_hook.create(game::Scr_SetString_ADDR(), Scr_SetString_stub, quick);
Scr_SetStringFromCharString_hook.create(game::Scr_SetStringFromCharString_ADDR(), Scr_SetStringFromCharString_stub, quick);
GScr_AllocString_hook.create(game::GScr_AllocString_ADDR(), GScr_AllocString_stub, quick);
SL_GetStringForFloat_hook.create(game::SL_GetStringForFloat_ADDR(), SL_GetStringForFloat_stub, quick);
SL_GetStringForInt_hook.create(game::SL_GetStringForInt_ADDR(), SL_GetStringForInt_stub, quick);
SL_GetStringForVector_hook.create(game::SL_GetStringForVector_ADDR(), SL_GetStringForVector_stub, quick);
SL_ShutdownSystem_hook.create(game::SL_ShutdownSystem_ADDR(), SL_ShutdownSystem_stub, quick);
SL_TransferSystem_hook.create(game::SL_TransferSystem.get(), SL_TransferSystem_stub, quick);
SL_CreateCanonicalFilename_hook.create(game::SL_CreateCanonicalFilename_ADDR(), SL_CreateCanonicalFilename_stub, quick);
Scr_CreateCanonicalFilename_hook.create(game::Scr_CreateCanonicalFilename.get(), Scr_CreateCanonicalFilename_stub, quick);
//Original hook function addresses
SL_ConvertToString_original = SL_ConvertToString_hook.get_original();
@@ -649,4 +653,5 @@ namespace re_cscr_stringlist
private:
};
}
REGISTER_COMPONENT(re_cscr_stringlist::component)
REGISTER_COMPONENT(re_cscr_stringlist::component)
#endif
@@ -3,8 +3,7 @@
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_variable.hpp"
//#define RE_CSCR_VARIABLE_USE_WRAPPERS
#ifndef DISABLE_RE_CSCR_VARIABLE
namespace re_cscr_variable
{
utils::hook::detour ThreadInfoCompare_hook;
@@ -2289,111 +2288,116 @@ namespace re_cscr_variable
public:
void post_unpack() override
{
ThreadInfoCompare_hook.create(game::ThreadInfoCompare.get(), ThreadInfoCompare_stub);
Scr_DumpScriptThreads_hook.create(game::Scr_DumpScriptThreads.get(), Scr_DumpScriptThreads_stub);
Scr_InitVariableRange_hook.create(game::Scr_InitVariableRange_ADDR(), Scr_InitVariableRange_stub);
Scr_InitClassMap_hook.create(game::Scr_InitClassMap_ADDR(), Scr_InitClassMap_stub);
GetNewVariableIndexInternal3_hook.create(game::GetNewVariableIndexInternal3.get(), GetNewVariableIndexInternal3_stub);
GetNewVariableIndexInternal2_hook.create(game::GetNewVariableIndexInternal2_ADDR(), GetNewVariableIndexInternal2_stub);
GetNewVariableIndexReverseInternal2_hook.create(game::GetNewVariableIndexReverseInternal2_ADDR(), GetNewVariableIndexReverseInternal2_stub);
MakeVariableExternal_hook.create(game::MakeVariableExternal_ADDR(), MakeVariableExternal_stub);
FreeChildValue_hook.create(game::FreeChildValue_ADDR(), FreeChildValue_stub);
ClearObjectInternal_hook.create(game::ClearObjectInternal.get(), ClearObjectInternal_stub);
ClearObject_hook.create(game::ClearObject_ADDR(), ClearObject_stub);
Scr_StopThread_hook.create(game::Scr_StopThread_ADDR(), Scr_StopThread_stub);
GetSafeParentLocalId_hook.create(game::GetSafeParentLocalId_ADDR(), GetSafeParentLocalId_stub);
GetStartLocalId_hook.create(game::GetStartLocalId_ADDR(), GetStartLocalId_stub);
Scr_KillThread_hook.create(game::Scr_KillThread_ADDR(), Scr_KillThread_stub);
AllocVariable_hook.create(game::AllocVariable_ADDR(), AllocVariable_stub);
FreeVariable_hook.create(game::FreeVariable_ADDR(), FreeVariable_stub);
AllocValue_hook.create(game::AllocValue_ADDR(), AllocValue_stub);
AllocEntity_hook.create(game::AllocEntity_ADDR(), AllocEntity_stub);
Scr_AllocArray_hook.create(game::Scr_AllocArray_ADDR(), Scr_AllocArray_stub);
AllocChildThread_hook.create(game::AllocChildThread_ADDR(), AllocChildThread_stub);
FreeValue_hook.create(game::FreeValue_ADDR(), FreeValue_stub);
RemoveRefToObject_hook.create(game::RemoveRefToObject_ADDR(), RemoveRefToObject_stub);
Scr_AllocVector_hook.create(game::Scr_AllocVector_ADDR(), Scr_AllocVector_stub);
RemoveRefToVector_hook.create(game::RemoveRefToVector_ADDR(), RemoveRefToVector_stub);
AddRefToValue_hook.create(game::AddRefToValue_ADDR(), AddRefToValue_stub);
RemoveRefToValueInternal_hook.create(game::RemoveRefToValueInternal.get(), RemoveRefToValueInternal_stub);
FindArrayVariable_hook.create(game::FindArrayVariable_ADDR(), FindArrayVariable_stub);
FindVariable_hook.create(game::FindVariable_ADDR(), FindVariable_stub);
GetArrayVariableIndex_hook.create(game::GetArrayVariableIndex_ADDR(), GetArrayVariableIndex_stub);
Scr_GetVariableFieldIndex_hook.create(game::Scr_GetVariableFieldIndex_ADDR(), Scr_GetVariableFieldIndex_stub);
Scr_FindVariableField_hook.create(game::Scr_FindVariableField_ADDR(), Scr_FindVariableField_stub);
ClearVariableField_hook.create(game::ClearVariableField_ADDR(), ClearVariableField_stub);
GetVariable_hook.create(game::GetVariable_ADDR(), GetVariable_stub);
GetNewVariable_hook.create(game::GetNewVariable_ADDR(), GetNewVariable_stub);
GetObjectVariable_hook.create(game::GetObjectVariable_ADDR(), GetObjectVariable_stub);
GetNewObjectVariable_hook.create(game::GetNewObjectVariable_ADDR(), GetNewObjectVariable_stub);
RemoveVariable_hook.create(game::RemoveVariable_ADDR(), RemoveVariable_stub);
RemoveNextVariable_hook.create(game::RemoveNextVariable_ADDR(), RemoveNextVariable_stub);
SafeRemoveVariable_hook.create(game::SafeRemoveVariable_ADDR(), SafeRemoveVariable_stub);
CopyArray_hook.create(game::CopyArray.get(), CopyArray_stub);
SetVariableValue_hook.create(game::SetVariableValue_ADDR(), SetVariableValue_stub);
SetVariableEntityFieldValue_hook.create(game::SetVariableEntityFieldValue.get(), SetVariableEntityFieldValue_stub);
Scr_EvalVariable_hook.create(game::Scr_EvalVariable_ADDR(), Scr_EvalVariable_stub);
Scr_EvalVariableObject_hook.create(game::Scr_EvalVariableObject_ADDR(), Scr_EvalVariableObject_stub);
Scr_EvalVariableEntityField_hook.create(game::Scr_EvalVariableEntityField_ADDR(), Scr_EvalVariableEntityField_stub);
Scr_EvalVariableField_hook.create(game::Scr_EvalVariableField_ADDR(), Scr_EvalVariableField_stub);
Scr_EvalSizeValue_hook.create(game::Scr_EvalSizeValue_ADDR(), Scr_EvalSizeValue_stub);
GetObject_hook.create(game::GetObject_ADDR(), GetObject_stub);
GetArray_hook.create(game::GetArray_ADDR(), GetArray_stub);
Scr_EvalBoolComplement_hook.create(game::Scr_EvalBoolComplement_ADDR(), Scr_EvalBoolComplement_stub);
Scr_CastBool_hook.create(game::Scr_CastBool_ADDR(), Scr_CastBool_stub);
Scr_CastString_hook.create(game::Scr_CastString_ADDR(), Scr_CastString_stub);
Scr_CastDebugString_hook.create(game::Scr_CastDebugString_ADDR(), Scr_CastDebugString_stub);
Scr_ClearVector_hook.create(game::Scr_ClearVector.get(), Scr_ClearVector_stub);
Scr_CastVector_hook.create(game::Scr_CastVector_ADDR(), Scr_CastVector_stub);
Scr_EvalFieldObject_hook.create(game::Scr_EvalFieldObject_ADDR(), Scr_EvalFieldObject_stub);
Scr_UnmatchingTypesError_hook.create(game::Scr_UnmatchingTypesError_ADDR(), Scr_UnmatchingTypesError_stub);
Scr_CastWeakerPair_hook.create(game::Scr_CastWeakerPair_ADDR(), Scr_CastWeakerPair_stub);
Scr_CastWeakerStringPair_hook.create(game::Scr_CastWeakerStringPair_ADDR(), Scr_CastWeakerStringPair_stub);
Scr_EvalOr_hook.create(game::Scr_EvalOr_ADDR(), Scr_EvalOr_stub);
Scr_EvalExOr_hook.create(game::Scr_EvalExOr_ADDR(), Scr_EvalExOr_stub);
Scr_EvalAnd_hook.create(game::Scr_EvalAnd_ADDR(), Scr_EvalAnd_stub);
Scr_EvalEquality_hook.create(game::Scr_EvalEquality_ADDR(), Scr_EvalEquality_stub);
Scr_EvalLess_hook.create(game::Scr_EvalLess_ADDR(), Scr_EvalLess_stub);
Scr_EvalGreaterEqual_hook.create(game::Scr_EvalGreaterEqual_ADDR(), Scr_EvalGreaterEqual_stub);
Scr_EvalGreater_hook.create(game::Scr_EvalGreater_ADDR(), Scr_EvalGreater_stub);
Scr_EvalLessEqual_hook.create(game::Scr_EvalLessEqual_ADDR(), Scr_EvalLessEqual_stub);
Scr_EvalShiftLeft_hook.create(game::Scr_EvalShiftLeft_ADDR(), Scr_EvalShiftLeft_stub);
Scr_EvalShiftRight_hook.create(game::Scr_EvalShiftRight_ADDR(), Scr_EvalShiftRight_stub);
Scr_EvalPlus_hook.create(game::Scr_EvalPlus_ADDR(), Scr_EvalPlus_stub);
Scr_EvalMinus_hook.create(game::Scr_EvalMinus_ADDR(), Scr_EvalMinus_stub);
Scr_EvalMultiply_hook.create(game::Scr_EvalMultiply_ADDR(), Scr_EvalMultiply_stub);
Scr_EvalDivide_hook.create(game::Scr_EvalDivide_ADDR(), Scr_EvalDivide_stub);
Scr_EvalMod_hook.create(game::Scr_EvalMod_ADDR(), Scr_EvalMod_stub);
Scr_EvalBinaryOperator_hook.create(game::Scr_EvalBinaryOperator_ADDR(), Scr_EvalBinaryOperator_stub);
Scr_FreeEntityNum_hook.create(game::Scr_FreeEntityNum_ADDR(), Scr_FreeEntityNum_stub);
Scr_FreeEntityList_hook.create(game::Scr_FreeEntityList.get(), Scr_FreeEntityList_stub);
Scr_FreeObjects_hook.create(game::Scr_FreeObjects.get(), Scr_FreeObjects_stub);
Scr_SetClassMap_hook.create(game::Scr_SetClassMap_ADDR(), Scr_SetClassMap_stub);
Scr_RemoveClassMap_hook.create(game::Scr_RemoveClassMap_ADDR(), Scr_RemoveClassMap_stub);
Scr_AddClassField_hook.create(game::Scr_AddClassField_ADDR(), Scr_AddClassField_stub);
Scr_GetOffset_hook.create(game::Scr_GetOffset_ADDR(), Scr_GetOffset_stub);
FindEntityId_hook.create(game::FindEntityId_ADDR(), FindEntityId_stub);
Scr_GetEntityId_hook.create(game::Scr_GetEntityId_ADDR(), Scr_GetEntityId_stub);
Scr_FindArrayIndex_hook.create(game::Scr_FindArrayIndex_ADDR(), Scr_FindArrayIndex_stub);
Scr_EvalArray_hook.create(game::Scr_EvalArray_ADDR(), Scr_EvalArray_stub);
Scr_EvalArrayRef_hook.create(game::Scr_EvalArrayRef_ADDR(), Scr_EvalArrayRef_stub);
ClearArray_hook.create(game::ClearArray_ADDR(), ClearArray_stub);
SetEmptyArray_hook.create(game::SetEmptyArray_ADDR(), SetEmptyArray_stub);
Scr_AddArrayKeys_hook.create(game::Scr_AddArrayKeys.get(), Scr_AddArrayKeys_stub);
Scr_GetEntityIdRef_hook.create(game::Scr_GetEntityIdRef_ADDR(), Scr_GetEntityIdRef_stub);
CopyEntity_hook.create(game::CopyEntity_ADDR(), CopyEntity_stub);
Scr_GetEndonUsage_hook.create(game::Scr_GetEndonUsage_ADDR(), Scr_GetEndonUsage_stub);
Scr_GetObjectUsage_hook.create(game::Scr_GetObjectUsage.get(), Scr_GetObjectUsage_stub);
Scr_GetThreadUsage_hook.create(game::Scr_GetThreadUsage_ADDR(), Scr_GetThreadUsage_stub);
Scr_FindField_hook.create(game::Scr_FindField_ADDR(), Scr_FindField_stub);
Scr_GetSourceFile_LoadObj_hook.create(game::Scr_GetSourceFile_LoadObj.get(), Scr_GetSourceFile_LoadObj_stub);
Scr_GetSourceFile_FastFile_hook.create(game::Scr_GetSourceFile_FastFile.get(), Scr_GetSourceFile_FastFile_stub);
Scr_AddFieldsForFile_hook.create(game::Scr_AddFieldsForFile.get(), Scr_AddFieldsForFile_stub);
Scr_AddFields_LoadObj_hook.create(game::Scr_AddFields_LoadObj.get(), Scr_AddFields_LoadObj_stub);
Scr_AddFields_FastFile_hook.create(game::Scr_AddFields_FastFile.get(), Scr_AddFields_FastFile_stub);
Scr_MakeValuePrimitive_hook.create(game::Scr_MakeValuePrimitive.get(), Scr_MakeValuePrimitive_stub);
Scr_FreeGameVariable_hook.create(game::Scr_FreeGameVariable_ADDR(), Scr_FreeGameVariable_stub);
Scr_SLHasLowercaseString_hook.create(game::Scr_SLHasLowercaseString_ADDR(), Scr_SLHasLowercaseString_stub);
bool quick = true;
#ifdef RE_CSCR_VARIABLE_USE_WRAPPERS
quick = false;
#endif
ThreadInfoCompare_hook.create(game::ThreadInfoCompare.get(), ThreadInfoCompare_stub, quick);
Scr_DumpScriptThreads_hook.create(game::Scr_DumpScriptThreads.get(), Scr_DumpScriptThreads_stub, quick);
Scr_InitVariableRange_hook.create(game::Scr_InitVariableRange_ADDR(), Scr_InitVariableRange_stub, quick);
Scr_InitClassMap_hook.create(game::Scr_InitClassMap_ADDR(), Scr_InitClassMap_stub, quick);
GetNewVariableIndexInternal3_hook.create(game::GetNewVariableIndexInternal3.get(), GetNewVariableIndexInternal3_stub, quick);
GetNewVariableIndexInternal2_hook.create(game::GetNewVariableIndexInternal2_ADDR(), GetNewVariableIndexInternal2_stub, quick);
GetNewVariableIndexReverseInternal2_hook.create(game::GetNewVariableIndexReverseInternal2_ADDR(), GetNewVariableIndexReverseInternal2_stub, quick);
MakeVariableExternal_hook.create(game::MakeVariableExternal_ADDR(), MakeVariableExternal_stub, quick);
FreeChildValue_hook.create(game::FreeChildValue_ADDR(), FreeChildValue_stub, quick);
ClearObjectInternal_hook.create(game::ClearObjectInternal.get(), ClearObjectInternal_stub, quick);
ClearObject_hook.create(game::ClearObject_ADDR(), ClearObject_stub, quick);
Scr_StopThread_hook.create(game::Scr_StopThread_ADDR(), Scr_StopThread_stub, quick);
GetSafeParentLocalId_hook.create(game::GetSafeParentLocalId_ADDR(), GetSafeParentLocalId_stub, quick);
GetStartLocalId_hook.create(game::GetStartLocalId_ADDR(), GetStartLocalId_stub, quick);
Scr_KillThread_hook.create(game::Scr_KillThread_ADDR(), Scr_KillThread_stub, quick);
AllocVariable_hook.create(game::AllocVariable_ADDR(), AllocVariable_stub, quick);
FreeVariable_hook.create(game::FreeVariable_ADDR(), FreeVariable_stub, quick);
AllocValue_hook.create(game::AllocValue_ADDR(), AllocValue_stub, quick);
AllocEntity_hook.create(game::AllocEntity_ADDR(), AllocEntity_stub, quick);
Scr_AllocArray_hook.create(game::Scr_AllocArray_ADDR(), Scr_AllocArray_stub, quick);
AllocChildThread_hook.create(game::AllocChildThread_ADDR(), AllocChildThread_stub, quick);
FreeValue_hook.create(game::FreeValue_ADDR(), FreeValue_stub, quick);
RemoveRefToObject_hook.create(game::RemoveRefToObject_ADDR(), RemoveRefToObject_stub, quick);
Scr_AllocVector_hook.create(game::Scr_AllocVector_ADDR(), Scr_AllocVector_stub, quick);
RemoveRefToVector_hook.create(game::RemoveRefToVector_ADDR(), RemoveRefToVector_stub, quick);
AddRefToValue_hook.create(game::AddRefToValue_ADDR(), AddRefToValue_stub, quick);
RemoveRefToValueInternal_hook.create(game::RemoveRefToValueInternal.get(), RemoveRefToValueInternal_stub, quick);
FindArrayVariable_hook.create(game::FindArrayVariable_ADDR(), FindArrayVariable_stub, quick);
FindVariable_hook.create(game::FindVariable_ADDR(), FindVariable_stub, quick);
GetArrayVariableIndex_hook.create(game::GetArrayVariableIndex_ADDR(), GetArrayVariableIndex_stub, quick);
Scr_GetVariableFieldIndex_hook.create(game::Scr_GetVariableFieldIndex_ADDR(), Scr_GetVariableFieldIndex_stub, quick);
Scr_FindVariableField_hook.create(game::Scr_FindVariableField_ADDR(), Scr_FindVariableField_stub, quick);
ClearVariableField_hook.create(game::ClearVariableField_ADDR(), ClearVariableField_stub, quick);
GetVariable_hook.create(game::GetVariable_ADDR(), GetVariable_stub, quick);
GetNewVariable_hook.create(game::GetNewVariable_ADDR(), GetNewVariable_stub, quick);
GetObjectVariable_hook.create(game::GetObjectVariable_ADDR(), GetObjectVariable_stub, quick);
GetNewObjectVariable_hook.create(game::GetNewObjectVariable_ADDR(), GetNewObjectVariable_stub, quick);
RemoveVariable_hook.create(game::RemoveVariable_ADDR(), RemoveVariable_stub, quick);
RemoveNextVariable_hook.create(game::RemoveNextVariable_ADDR(), RemoveNextVariable_stub, quick);
SafeRemoveVariable_hook.create(game::SafeRemoveVariable_ADDR(), SafeRemoveVariable_stub, quick);
CopyArray_hook.create(game::CopyArray.get(), CopyArray_stub, quick);
SetVariableValue_hook.create(game::SetVariableValue_ADDR(), SetVariableValue_stub, quick);
SetVariableEntityFieldValue_hook.create(game::SetVariableEntityFieldValue.get(), SetVariableEntityFieldValue_stub, quick);
Scr_EvalVariable_hook.create(game::Scr_EvalVariable_ADDR(), Scr_EvalVariable_stub, quick);
Scr_EvalVariableObject_hook.create(game::Scr_EvalVariableObject_ADDR(), Scr_EvalVariableObject_stub, quick);
Scr_EvalVariableEntityField_hook.create(game::Scr_EvalVariableEntityField_ADDR(), Scr_EvalVariableEntityField_stub, quick);
Scr_EvalVariableField_hook.create(game::Scr_EvalVariableField_ADDR(), Scr_EvalVariableField_stub, quick);
Scr_EvalSizeValue_hook.create(game::Scr_EvalSizeValue_ADDR(), Scr_EvalSizeValue_stub, quick);
GetObject_hook.create(game::GetObject_ADDR(), GetObject_stub, quick);
GetArray_hook.create(game::GetArray_ADDR(), GetArray_stub, quick);
Scr_EvalBoolComplement_hook.create(game::Scr_EvalBoolComplement_ADDR(), Scr_EvalBoolComplement_stub, quick);
Scr_CastBool_hook.create(game::Scr_CastBool_ADDR(), Scr_CastBool_stub, quick);
Scr_CastString_hook.create(game::Scr_CastString_ADDR(), Scr_CastString_stub, quick);
Scr_CastDebugString_hook.create(game::Scr_CastDebugString_ADDR(), Scr_CastDebugString_stub, quick);
Scr_ClearVector_hook.create(game::Scr_ClearVector.get(), Scr_ClearVector_stub, quick);
Scr_CastVector_hook.create(game::Scr_CastVector_ADDR(), Scr_CastVector_stub, quick);
Scr_EvalFieldObject_hook.create(game::Scr_EvalFieldObject_ADDR(), Scr_EvalFieldObject_stub, quick);
Scr_UnmatchingTypesError_hook.create(game::Scr_UnmatchingTypesError_ADDR(), Scr_UnmatchingTypesError_stub, quick);
Scr_CastWeakerPair_hook.create(game::Scr_CastWeakerPair_ADDR(), Scr_CastWeakerPair_stub, quick);
Scr_CastWeakerStringPair_hook.create(game::Scr_CastWeakerStringPair_ADDR(), Scr_CastWeakerStringPair_stub, quick);
Scr_EvalOr_hook.create(game::Scr_EvalOr_ADDR(), Scr_EvalOr_stub, quick);
Scr_EvalExOr_hook.create(game::Scr_EvalExOr_ADDR(), Scr_EvalExOr_stub, quick);
Scr_EvalAnd_hook.create(game::Scr_EvalAnd_ADDR(), Scr_EvalAnd_stub, quick);
Scr_EvalEquality_hook.create(game::Scr_EvalEquality_ADDR(), Scr_EvalEquality_stub, quick);
Scr_EvalLess_hook.create(game::Scr_EvalLess_ADDR(), Scr_EvalLess_stub, quick);
Scr_EvalGreaterEqual_hook.create(game::Scr_EvalGreaterEqual_ADDR(), Scr_EvalGreaterEqual_stub, quick);
Scr_EvalGreater_hook.create(game::Scr_EvalGreater_ADDR(), Scr_EvalGreater_stub, quick);
Scr_EvalLessEqual_hook.create(game::Scr_EvalLessEqual_ADDR(), Scr_EvalLessEqual_stub, quick);
Scr_EvalShiftLeft_hook.create(game::Scr_EvalShiftLeft_ADDR(), Scr_EvalShiftLeft_stub, quick);
Scr_EvalShiftRight_hook.create(game::Scr_EvalShiftRight_ADDR(), Scr_EvalShiftRight_stub, quick);
Scr_EvalPlus_hook.create(game::Scr_EvalPlus_ADDR(), Scr_EvalPlus_stub, quick);
Scr_EvalMinus_hook.create(game::Scr_EvalMinus_ADDR(), Scr_EvalMinus_stub, quick);
Scr_EvalMultiply_hook.create(game::Scr_EvalMultiply_ADDR(), Scr_EvalMultiply_stub, quick);
Scr_EvalDivide_hook.create(game::Scr_EvalDivide_ADDR(), Scr_EvalDivide_stub, quick);
Scr_EvalMod_hook.create(game::Scr_EvalMod_ADDR(), Scr_EvalMod_stub, quick);
Scr_EvalBinaryOperator_hook.create(game::Scr_EvalBinaryOperator_ADDR(), Scr_EvalBinaryOperator_stub, quick);
Scr_FreeEntityNum_hook.create(game::Scr_FreeEntityNum_ADDR(), Scr_FreeEntityNum_stub, quick);
Scr_FreeEntityList_hook.create(game::Scr_FreeEntityList.get(), Scr_FreeEntityList_stub, quick);
Scr_FreeObjects_hook.create(game::Scr_FreeObjects.get(), Scr_FreeObjects_stub, quick);
Scr_SetClassMap_hook.create(game::Scr_SetClassMap_ADDR(), Scr_SetClassMap_stub, quick);
Scr_RemoveClassMap_hook.create(game::Scr_RemoveClassMap_ADDR(), Scr_RemoveClassMap_stub, quick);
Scr_AddClassField_hook.create(game::Scr_AddClassField_ADDR(), Scr_AddClassField_stub, quick);
Scr_GetOffset_hook.create(game::Scr_GetOffset_ADDR(), Scr_GetOffset_stub, quick);
FindEntityId_hook.create(game::FindEntityId_ADDR(), FindEntityId_stub, quick);
Scr_GetEntityId_hook.create(game::Scr_GetEntityId_ADDR(), Scr_GetEntityId_stub, quick);
Scr_FindArrayIndex_hook.create(game::Scr_FindArrayIndex_ADDR(), Scr_FindArrayIndex_stub, quick);
Scr_EvalArray_hook.create(game::Scr_EvalArray_ADDR(), Scr_EvalArray_stub, quick);
Scr_EvalArrayRef_hook.create(game::Scr_EvalArrayRef_ADDR(), Scr_EvalArrayRef_stub, quick);
ClearArray_hook.create(game::ClearArray_ADDR(), ClearArray_stub, quick);
SetEmptyArray_hook.create(game::SetEmptyArray_ADDR(), SetEmptyArray_stub, quick);
Scr_AddArrayKeys_hook.create(game::Scr_AddArrayKeys.get(), Scr_AddArrayKeys_stub, quick);
Scr_GetEntityIdRef_hook.create(game::Scr_GetEntityIdRef_ADDR(), Scr_GetEntityIdRef_stub, quick);
CopyEntity_hook.create(game::CopyEntity_ADDR(), CopyEntity_stub, quick);
Scr_GetEndonUsage_hook.create(game::Scr_GetEndonUsage_ADDR(), Scr_GetEndonUsage_stub, quick);
Scr_GetObjectUsage_hook.create(game::Scr_GetObjectUsage.get(), Scr_GetObjectUsage_stub, quick);
Scr_GetThreadUsage_hook.create(game::Scr_GetThreadUsage_ADDR(), Scr_GetThreadUsage_stub, quick);
Scr_FindField_hook.create(game::Scr_FindField_ADDR(), Scr_FindField_stub, quick);
Scr_GetSourceFile_LoadObj_hook.create(game::Scr_GetSourceFile_LoadObj.get(), Scr_GetSourceFile_LoadObj_stub, quick);
Scr_GetSourceFile_FastFile_hook.create(game::Scr_GetSourceFile_FastFile.get(), Scr_GetSourceFile_FastFile_stub, quick);
Scr_AddFieldsForFile_hook.create(game::Scr_AddFieldsForFile.get(), Scr_AddFieldsForFile_stub, quick);
Scr_AddFields_LoadObj_hook.create(game::Scr_AddFields_LoadObj.get(), Scr_AddFields_LoadObj_stub, quick);
Scr_AddFields_FastFile_hook.create(game::Scr_AddFields_FastFile.get(), Scr_AddFields_FastFile_stub, quick);
Scr_MakeValuePrimitive_hook.create(game::Scr_MakeValuePrimitive.get(), Scr_MakeValuePrimitive_stub, quick);
Scr_FreeGameVariable_hook.create(game::Scr_FreeGameVariable_ADDR(), Scr_FreeGameVariable_stub, quick);
Scr_SLHasLowercaseString_hook.create(game::Scr_SLHasLowercaseString_ADDR(), Scr_SLHasLowercaseString_stub, quick);
//Original hook function addresses
ThreadInfoCompare_original = ThreadInfoCompare_hook.get_original();
@@ -2506,4 +2510,5 @@ namespace re_cscr_variable
private:
};
}
REGISTER_COMPONENT(re_cscr_variable::component)
REGISTER_COMPONENT(re_cscr_variable::component)
#endif
@@ -3,8 +3,7 @@
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_vm.hpp"
//#define RE_CSCR_VM_USE_WRAPPERS
#ifndef DISABLE_RE_CSCR_VM
namespace re_cscr_vm
{
utils::hook::detour Scr_VM_Init_hook;
@@ -1397,10 +1396,6 @@ namespace re_cscr_vm
bool SetEntityFieldValue_call(game::scriptInstance_t inst, int offset_, int entnum, [[maybe_unused]] void* caller_addr, game::classNum_e classnum, int clientNum, game::VariableValue* value)
{
#if CSCR_VARIABLE_EXTRA_CLASSMAPS
return script::SetEntityFieldValue_Override(inst, offset_, entnum, classnum, clientNum, value);
#endif
#ifdef RE_CSCR_VM_USE_WRAPPERS
return game::SetEntityFieldValue(inst, offset_, entnum, classnum, clientNum, value, SetEntityFieldValue_original);
#else
@@ -1529,78 +1524,83 @@ namespace re_cscr_vm
public:
void post_unpack() override
{
Scr_VM_Init_hook.create(game::Scr_VM_Init.get(), Scr_VM_Init_stub);
Scr_Init_hook.create(game::Scr_Init_ADDR(), Scr_Init_stub);
Scr_Shutdown_hook.create(game::Scr_Shutdown_ADDR(), Scr_Shutdown_stub);
Scr_ErrorInternal_hook.create(game::Scr_ErrorInternal_ADDR(), Scr_ErrorInternal_stub);
Scr_ClearOutParams_hook.create(game::Scr_ClearOutParams_ADDR(), Scr_ClearOutParams_stub);
GetDummyObject_hook.create(game::GetDummyObject_ADDR(), GetDummyObject_stub);
GetDummyFieldValue_hook.create(game::GetDummyFieldValue_ADDR(), GetDummyFieldValue_stub);
VM_ExecuteInternal_hook.create(game::VM_ExecuteInternal.get(), VM_ExecuteInternal_stub);
VM_CancelNotifyInternal_hook.create(game::VM_CancelNotifyInternal_ADDR(), VM_CancelNotifyInternal_stub);
VM_CancelNotify_hook.create(game::VM_CancelNotify_ADDR(), VM_CancelNotify_stub);
VM_ArchiveStack_hook.create(game::VM_ArchiveStack_ADDR(), VM_ArchiveStack_stub);
Scr_AddLocalVars_hook.create(game::Scr_AddLocalVars_ADDR(), Scr_AddLocalVars_stub);
VM_UnarchiveStack_hook.create(game::VM_UnarchiveStack.get(), VM_UnarchiveStack_stub);
VM_TerminateStack_hook.create(game::VM_TerminateStack_ADDR(), VM_TerminateStack_stub);
VM_TrimStack_hook.create(game::VM_TrimStack_ADDR(), VM_TrimStack_stub);
Scr_TerminateRunningThread_hook.create(game::Scr_TerminateRunningThread_ADDR(), Scr_TerminateRunningThread_stub);
Scr_TerminateWaitThread_hook.create(game::Scr_TerminateWaitThread_ADDR(), Scr_TerminateWaitThread_stub);
Scr_CancelWaittill_hook.create(game::Scr_CancelWaittill_ADDR(), Scr_CancelWaittill_stub);
Scr_TerminateWaittillThread_hook.create(game::Scr_TerminateWaittillThread_ADDR(), Scr_TerminateWaittillThread_stub);
Scr_TerminateThread_hook.create(game::Scr_TerminateThread_ADDR(), Scr_TerminateThread_stub);
VM_Notify_hook.create(game::VM_Notify_ADDR(), VM_Notify_stub);
Scr_NotifyNum_Internal_hook.create(game::Scr_NotifyNum_Internal_ADDR(), Scr_NotifyNum_Internal_stub);
Scr_CancelNotifyList_hook.create(game::Scr_CancelNotifyList_ADDR(), Scr_CancelNotifyList_stub);
VM_TerminateTime_hook.create(game::VM_TerminateTime_ADDR(), VM_TerminateTime_stub);
VM_Resume_hook.create(game::VM_Resume_ADDR(), VM_Resume_stub);
VM_Execute_hook.create(game::VM_Execute.get(), VM_Execute_stub);
Scr_ExecThread_hook.create(game::Scr_ExecThread_ADDR(), Scr_ExecThread_stub);
Scr_ExecEntThread_hook.create(game::Scr_ExecEntThread_ADDR(), Scr_ExecEntThread_stub);
Scr_AddExecThread_hook.create(game::Scr_AddExecThread_ADDR(), Scr_AddExecThread_stub);
VM_SetTime_hook.create(game::VM_SetTime_ADDR(), VM_SetTime_stub);
Scr_InitSystem_hook.create(game::Scr_InitSystem_ADDR(), Scr_InitSystem_stub);
Scr_ShutdownSystem_hook.create(game::Scr_ShutdownSystem.get(), Scr_ShutdownSystem_stub);
Scr_IsSystemActive_hook.create(game::Scr_IsSystemActive.get(), Scr_IsSystemActive_stub);
Scr_GetInt_hook.create(game::Scr_GetInt_ADDR(), Scr_GetInt_stub);
Scr_GetAnim_hook.create(game::Scr_GetAnim_ADDR(), Scr_GetAnim_stub);
Scr_GetAnimTree_hook.create(game::Scr_GetAnimTree.get(), Scr_GetAnimTree_stub);
Scr_GetFloat_hook.create(game::Scr_GetFloat_ADDR(), Scr_GetFloat_stub);
Scr_GetConstString_hook.create(game::Scr_GetConstString_ADDR(), Scr_GetConstString_stub);
Scr_GetConstLowercaseString_hook.create(game::Scr_GetConstLowercaseString_ADDR(), Scr_GetConstLowercaseString_stub);
Scr_GetString_hook.create(game::Scr_GetString_ADDR(), Scr_GetString_stub);
Scr_GetConstStringIncludeNull_hook.create(game::Scr_GetConstStringIncludeNull_ADDR(), Scr_GetConstStringIncludeNull_stub);
Scr_GetDebugString_hook.create(game::Scr_GetDebugString_ADDR(), Scr_GetDebugString_stub);
Scr_GetConstIString_hook.create(game::Scr_GetConstIString_ADDR(), Scr_GetConstIString_stub);
Scr_GetVector_hook.create(game::Scr_GetVector_ADDR(), Scr_GetVector_stub);
Scr_GetFunc_hook.create(game::Scr_GetFunc.get(), Scr_GetFunc_stub);
Scr_GetEntityRef_hook.create(game::Scr_GetEntityRef_ADDR(), Scr_GetEntityRef_stub);
Scr_GetObject_hook.create(game::Scr_GetObject_ADDR(), Scr_GetObject_stub);
Scr_GetType_hook.create(game::Scr_GetType_ADDR(), Scr_GetType_stub);
Scr_GetTypeName_hook.create(game::Scr_GetTypeName_ADDR(), Scr_GetTypeName_stub);
Scr_GetPointerType_hook.create(game::Scr_GetPointerType_ADDR(), Scr_GetPointerType_stub);
Scr_AddInt_hook.create(game::Scr_AddInt_ADDR(), Scr_AddInt_stub);
Scr_AddFloat_hook.create(game::Scr_AddFloat_ADDR(), Scr_AddFloat_stub);
Scr_AddAnim_hook.create(game::Scr_AddAnim.get(), Scr_AddAnim_stub);
Scr_AddUndefined_hook.create(game::Scr_AddUndefined_ADDR(), Scr_AddUndefined_stub);
Scr_AddObject_hook.create(game::Scr_AddObject_ADDR(), Scr_AddObject_stub);
Scr_AddString_hook.create(game::Scr_AddString_ADDR(), Scr_AddString_stub);
Scr_AddIString_hook.create(game::Scr_AddIString_ADDR(), Scr_AddIString_stub);
Scr_AddConstString_hook.create(game::Scr_AddConstString_ADDR(), Scr_AddConstString_stub);
Scr_AddVector_hook.create(game::Scr_AddVector_ADDR(), Scr_AddVector_stub);
Scr_MakeArray_hook.create(game::Scr_MakeArray_ADDR(), Scr_MakeArray_stub);
Scr_AddArray_hook.create(game::Scr_AddArray.get(), Scr_AddArray_stub);
Scr_AddArrayStringIndexed_hook.create(game::Scr_AddArrayStringIndexed_ADDR(), Scr_AddArrayStringIndexed_stub);
Scr_Error_hook.create(game::Scr_Error_ADDR(), Scr_Error_stub);
Scr_TerminalError_hook.create(game::Scr_TerminalError_ADDR(), Scr_TerminalError_stub);
Scr_ParamError_hook.create(game::Scr_ParamError_ADDR(), Scr_ParamError_stub);
Scr_ObjectError_hook.create(game::Scr_ObjectError_ADDR(), Scr_ObjectError_stub);
SetEntityFieldValue_hook.create(game::SetEntityFieldValue_ADDR(), SetEntityFieldValue_stub);
GetEntityFieldValue_hook.create(game::GetEntityFieldValue_ADDR(), GetEntityFieldValue_stub);
Scr_SetStructField_hook.create(game::Scr_SetStructField_ADDR(), Scr_SetStructField_stub);
Scr_IncTime_hook.create(game::Scr_IncTime_ADDR(), Scr_IncTime_stub);
Scr_RunCurrentThreads_hook.create(game::Scr_RunCurrentThreads_ADDR(), Scr_RunCurrentThreads_stub);
Scr_ResetTimeout_hook.create(game::Scr_ResetTimeout_ADDR(), Scr_ResetTimeout_stub);
bool quick = true;
#ifdef RE_CSCR_VM_USE_WRAPPERS
quick = false;
#endif
Scr_VM_Init_hook.create(game::Scr_VM_Init.get(), Scr_VM_Init_stub, quick);
Scr_Init_hook.create(game::Scr_Init_ADDR(), Scr_Init_stub, quick);
Scr_Shutdown_hook.create(game::Scr_Shutdown_ADDR(), Scr_Shutdown_stub, quick);
Scr_ErrorInternal_hook.create(game::Scr_ErrorInternal_ADDR(), Scr_ErrorInternal_stub, quick);
Scr_ClearOutParams_hook.create(game::Scr_ClearOutParams_ADDR(), Scr_ClearOutParams_stub, quick);
GetDummyObject_hook.create(game::GetDummyObject_ADDR(), GetDummyObject_stub, quick);
GetDummyFieldValue_hook.create(game::GetDummyFieldValue_ADDR(), GetDummyFieldValue_stub, quick);
VM_ExecuteInternal_hook.create(game::VM_ExecuteInternal.get(), VM_ExecuteInternal_stub, quick);
VM_CancelNotifyInternal_hook.create(game::VM_CancelNotifyInternal_ADDR(), VM_CancelNotifyInternal_stub, quick);
VM_CancelNotify_hook.create(game::VM_CancelNotify_ADDR(), VM_CancelNotify_stub, quick);
VM_ArchiveStack_hook.create(game::VM_ArchiveStack_ADDR(), VM_ArchiveStack_stub, quick);
Scr_AddLocalVars_hook.create(game::Scr_AddLocalVars_ADDR(), Scr_AddLocalVars_stub, quick);
VM_UnarchiveStack_hook.create(game::VM_UnarchiveStack.get(), VM_UnarchiveStack_stub, quick);
VM_TerminateStack_hook.create(game::VM_TerminateStack_ADDR(), VM_TerminateStack_stub, quick);
VM_TrimStack_hook.create(game::VM_TrimStack_ADDR(), VM_TrimStack_stub, quick);
Scr_TerminateRunningThread_hook.create(game::Scr_TerminateRunningThread_ADDR(), Scr_TerminateRunningThread_stub, quick);
Scr_TerminateWaitThread_hook.create(game::Scr_TerminateWaitThread_ADDR(), Scr_TerminateWaitThread_stub, quick);
Scr_CancelWaittill_hook.create(game::Scr_CancelWaittill_ADDR(), Scr_CancelWaittill_stub, quick);
Scr_TerminateWaittillThread_hook.create(game::Scr_TerminateWaittillThread_ADDR(), Scr_TerminateWaittillThread_stub, quick);
Scr_TerminateThread_hook.create(game::Scr_TerminateThread_ADDR(), Scr_TerminateThread_stub, quick);
VM_Notify_hook.create(game::VM_Notify_ADDR(), VM_Notify_stub, quick);
Scr_NotifyNum_Internal_hook.create(game::Scr_NotifyNum_Internal_ADDR(), Scr_NotifyNum_Internal_stub, quick);
Scr_CancelNotifyList_hook.create(game::Scr_CancelNotifyList_ADDR(), Scr_CancelNotifyList_stub, quick);
VM_TerminateTime_hook.create(game::VM_TerminateTime_ADDR(), VM_TerminateTime_stub, quick);
VM_Resume_hook.create(game::VM_Resume_ADDR(), VM_Resume_stub, quick);
VM_Execute_hook.create(game::VM_Execute.get(), VM_Execute_stub, quick);
Scr_ExecThread_hook.create(game::Scr_ExecThread_ADDR(), Scr_ExecThread_stub, quick);
Scr_ExecEntThread_hook.create(game::Scr_ExecEntThread_ADDR(), Scr_ExecEntThread_stub, quick);
Scr_AddExecThread_hook.create(game::Scr_AddExecThread_ADDR(), Scr_AddExecThread_stub, quick);
VM_SetTime_hook.create(game::VM_SetTime_ADDR(), VM_SetTime_stub, quick);
Scr_InitSystem_hook.create(game::Scr_InitSystem_ADDR(), Scr_InitSystem_stub, quick);
Scr_ShutdownSystem_hook.create(game::Scr_ShutdownSystem.get(), Scr_ShutdownSystem_stub, quick);
Scr_IsSystemActive_hook.create(game::Scr_IsSystemActive.get(), Scr_IsSystemActive_stub, quick);
Scr_GetInt_hook.create(game::Scr_GetInt_ADDR(), Scr_GetInt_stub, quick);
Scr_GetAnim_hook.create(game::Scr_GetAnim_ADDR(), Scr_GetAnim_stub, quick);
Scr_GetAnimTree_hook.create(game::Scr_GetAnimTree.get(), Scr_GetAnimTree_stub, quick);
Scr_GetFloat_hook.create(game::Scr_GetFloat_ADDR(), Scr_GetFloat_stub, quick);
Scr_GetConstString_hook.create(game::Scr_GetConstString_ADDR(), Scr_GetConstString_stub, quick);
Scr_GetConstLowercaseString_hook.create(game::Scr_GetConstLowercaseString_ADDR(), Scr_GetConstLowercaseString_stub, quick);
Scr_GetString_hook.create(game::Scr_GetString_ADDR(), Scr_GetString_stub, quick);
Scr_GetConstStringIncludeNull_hook.create(game::Scr_GetConstStringIncludeNull_ADDR(), Scr_GetConstStringIncludeNull_stub, quick);
Scr_GetDebugString_hook.create(game::Scr_GetDebugString_ADDR(), Scr_GetDebugString_stub, quick);
Scr_GetConstIString_hook.create(game::Scr_GetConstIString_ADDR(), Scr_GetConstIString_stub, quick);
Scr_GetVector_hook.create(game::Scr_GetVector_ADDR(), Scr_GetVector_stub, quick);
Scr_GetFunc_hook.create(game::Scr_GetFunc.get(), Scr_GetFunc_stub, quick);
Scr_GetEntityRef_hook.create(game::Scr_GetEntityRef_ADDR(), Scr_GetEntityRef_stub, quick);
Scr_GetObject_hook.create(game::Scr_GetObject_ADDR(), Scr_GetObject_stub, quick);
Scr_GetType_hook.create(game::Scr_GetType_ADDR(), Scr_GetType_stub, quick);
Scr_GetTypeName_hook.create(game::Scr_GetTypeName_ADDR(), Scr_GetTypeName_stub, quick);
Scr_GetPointerType_hook.create(game::Scr_GetPointerType_ADDR(), Scr_GetPointerType_stub, quick);
Scr_AddInt_hook.create(game::Scr_AddInt_ADDR(), Scr_AddInt_stub, quick);
Scr_AddFloat_hook.create(game::Scr_AddFloat_ADDR(), Scr_AddFloat_stub, quick);
Scr_AddAnim_hook.create(game::Scr_AddAnim.get(), Scr_AddAnim_stub, quick);
Scr_AddUndefined_hook.create(game::Scr_AddUndefined_ADDR(), Scr_AddUndefined_stub, quick);
Scr_AddObject_hook.create(game::Scr_AddObject_ADDR(), Scr_AddObject_stub, quick);
Scr_AddString_hook.create(game::Scr_AddString_ADDR(), Scr_AddString_stub, quick);
Scr_AddIString_hook.create(game::Scr_AddIString_ADDR(), Scr_AddIString_stub, quick);
Scr_AddConstString_hook.create(game::Scr_AddConstString_ADDR(), Scr_AddConstString_stub, quick);
Scr_AddVector_hook.create(game::Scr_AddVector_ADDR(), Scr_AddVector_stub, quick);
Scr_MakeArray_hook.create(game::Scr_MakeArray_ADDR(), Scr_MakeArray_stub, quick);
Scr_AddArray_hook.create(game::Scr_AddArray.get(), Scr_AddArray_stub, quick);
Scr_AddArrayStringIndexed_hook.create(game::Scr_AddArrayStringIndexed_ADDR(), Scr_AddArrayStringIndexed_stub, quick);
Scr_Error_hook.create(game::Scr_Error_ADDR(), Scr_Error_stub, quick);
Scr_TerminalError_hook.create(game::Scr_TerminalError_ADDR(), Scr_TerminalError_stub, quick);
Scr_ParamError_hook.create(game::Scr_ParamError_ADDR(), Scr_ParamError_stub, quick);
Scr_ObjectError_hook.create(game::Scr_ObjectError_ADDR(), Scr_ObjectError_stub, quick);
SetEntityFieldValue_hook.create(game::SetEntityFieldValue_ADDR(), SetEntityFieldValue_stub, quick);
GetEntityFieldValue_hook.create(game::GetEntityFieldValue_ADDR(), GetEntityFieldValue_stub, quick);
Scr_SetStructField_hook.create(game::Scr_SetStructField_ADDR(), Scr_SetStructField_stub, quick);
Scr_IncTime_hook.create(game::Scr_IncTime_ADDR(), Scr_IncTime_stub, quick);
Scr_RunCurrentThreads_hook.create(game::Scr_RunCurrentThreads_ADDR(), Scr_RunCurrentThreads_stub, quick);
Scr_ResetTimeout_hook.create(game::Scr_ResetTimeout_ADDR(), Scr_ResetTimeout_stub, quick);
//Original hook function addresses
Scr_VM_Init_original = Scr_VM_Init_hook.get_original();
@@ -1680,4 +1680,5 @@ namespace re_cscr_vm
private:
};
}
REGISTER_COMPONENT(re_cscr_vm::component)
REGISTER_COMPONENT(re_cscr_vm::component)
#endif
@@ -0,0 +1,237 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_yacc.hpp"
#ifndef DISABLE_RE_CSCR_YACC
namespace re_cscr_yacc
{
utils::hook::detour LowerCase_hook;
utils::hook::detour yyparse_hook;
utils::hook::detour StringValue_hook;
utils::hook::detour yylex_hook;
utils::hook::detour yy_get_next_buffer_hook;
utils::hook::detour yy_get_previous_state_hook;
utils::hook::detour yy_try_NUL_trans_hook;
utils::hook::detour yyrestart_hook;
utils::hook::detour yy_create_buffer_hook;
utils::hook::detour yy_flush_buffer_hook;
utils::hook::detour ScriptParse_hook;
void* LowerCase_original;
void* yyparse_original;
void* StringValue_original;
void* yylex_original;
void* yy_get_next_buffer_original;
void* yy_get_previous_state_original;
void* yy_try_NUL_trans_original;
void* yyrestart_original;
void* yy_create_buffer_original;
void* yy_flush_buffer_original;
void* ScriptParse_original;
namespace
{
unsigned int LowerCase_call(unsigned int strVal, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_YACC_USE_WRAPPERS
return game::LowerCase(strVal, LowerCase_original);
#else
return codsrc::LowerCase(strVal);
#endif
}
// unsigned int __usercall LowerCase@<eax>(unsigned int strVal@<ecx>)
NAKED unsigned int LowerCase_stub()
{
_asm
{
push ecx;
call LowerCase_call;
add esp, 0x4;
ret;
}
}
int yyparse_stub()
{
#ifdef RE_CSCR_YACC_USE_WRAPPERS
return yyparse_hook.invoke<int>();
#else
return codsrc::yyparse();
#endif
}
int StringValue_call(int len, const char * str_, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_YACC_USE_WRAPPERS
return game::StringValue(len, str_, StringValue_original);
#else
return codsrc::StringValue(len, str_);
#endif
}
// int __usercall StringValue@<eax>(int len@<ecx>, const char *str@<edx>)
NAKED int StringValue_stub()
{
_asm
{
push edx;
push ecx;
call StringValue_call;
add esp, 0x8;
ret;
}
}
int yylex_stub()
{
#ifdef RE_CSCR_YACC_USE_WRAPPERS
return yylex_hook.invoke<int>();
#else
return codsrc::yylex();
#endif
}
int yy_get_next_buffer_stub()
{
#ifdef RE_CSCR_YACC_USE_WRAPPERS
return yy_get_next_buffer_hook.invoke<int>();
#else
return codsrc::yy_get_next_buffer();
#endif
}
int yy_get_previous_state_stub()
{
#ifdef RE_CSCR_YACC_USE_WRAPPERS
return yy_get_previous_state_hook.invoke<int>();
#else
return codsrc::yy_get_previous_state();
#endif
}
int yy_try_NUL_trans_call(int yy_current_state, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_YACC_USE_WRAPPERS
return game::yy_try_NUL_trans(yy_current_state, yy_try_NUL_trans_original);
#else
return codsrc::yy_try_NUL_trans(yy_current_state);
#endif
}
// int __usercall yy_try_NUL_trans@<eax>(int yy_current_state@<eax>)
NAKED int yy_try_NUL_trans_stub()
{
_asm
{
push eax;
call yy_try_NUL_trans_call;
add esp, 0x4;
ret;
}
}
void yyrestart_stub()
{
#ifdef RE_CSCR_YACC_USE_WRAPPERS
yyrestart_hook.invoke<void>();
#else
codsrc::yyrestart();
#endif
}
game::yy_buffer_state * yy_create_buffer_stub()
{
#ifdef RE_CSCR_YACC_USE_WRAPPERS
return yy_create_buffer_hook.invoke<game::yy_buffer_state *>();
#else
return codsrc::yy_create_buffer();
#endif
}
void yy_flush_buffer_call(game::yy_buffer_state * result, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_YACC_USE_WRAPPERS
game::yy_flush_buffer(result, yy_flush_buffer_original);
#else
codsrc::yy_flush_buffer(result);
#endif
}
// void __usercall yy_flush_buffer(game::yy_buffer_state *result@<eax>)
NAKED void yy_flush_buffer_stub()
{
_asm
{
push eax;
call yy_flush_buffer_call;
add esp, 0x4;
ret;
}
}
void ScriptParse_call(game::scriptInstance_t a1, [[maybe_unused]] void* caller_addr, game::sval_u * parseData)
{
#ifdef RE_CSCR_YACC_USE_WRAPPERS
game::ScriptParse(a1, parseData, ScriptParse_original);
#else
codsrc::ScriptParse(a1, parseData);
#endif
}
// void __usercall ScriptParse(game::scriptInstance_t a1@<eax>, game::sval_u *parseData)
NAKED void ScriptParse_stub()
{
_asm
{
push eax;
call ScriptParse_call;
add esp, 0x4;
ret;
}
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
bool quick = true;
#ifdef RE_CSCR_YACC_USE_WRAPPERS
quick = false;
#endif
LowerCase_hook.create(game::LowerCase_ADDR(), LowerCase_stub, quick);
yyparse_hook.create(game::yyparse.get(), yyparse_stub, quick);
StringValue_hook.create(game::StringValue_ADDR(), StringValue_stub, quick);
yylex_hook.create(game::yylex.get(), yylex_stub, quick);
yy_get_next_buffer_hook.create(game::yy_get_next_buffer.get(), yy_get_next_buffer_stub, quick);
yy_get_previous_state_hook.create(game::yy_get_previous_state.get(), yy_get_previous_state_stub, quick);
yy_try_NUL_trans_hook.create(game::yy_try_NUL_trans_ADDR(), yy_try_NUL_trans_stub, quick);
yyrestart_hook.create(game::yyrestart.get(), yyrestart_stub, quick);
yy_create_buffer_hook.create(game::yy_create_buffer.get(), yy_create_buffer_stub, quick);
yy_flush_buffer_hook.create(game::yy_flush_buffer_ADDR(), yy_flush_buffer_stub, quick);
ScriptParse_hook.create(game::ScriptParse_ADDR(), ScriptParse_stub, quick);
//Original hook function addresses
LowerCase_original = LowerCase_hook.get_original();
yyparse_original = yyparse_hook.get_original();
StringValue_original = StringValue_hook.get_original();
yylex_original = yylex_hook.get_original();
yy_get_next_buffer_original = yy_get_next_buffer_hook.get_original();
yy_get_previous_state_original = yy_get_previous_state_hook.get_original();
yy_try_NUL_trans_original = yy_try_NUL_trans_hook.get_original();
yyrestart_original = yyrestart_hook.get_original();
yy_create_buffer_original = yy_create_buffer_hook.get_original();
yy_flush_buffer_original = yy_flush_buffer_hook.get_original();
ScriptParse_original = ScriptParse_hook.get_original();
}
private:
};
}
REGISTER_COMPONENT(re_cscr_yacc::component)
#endif
+141 -137
View File
@@ -1,137 +1,141 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include <utils/hook.hpp>
#include <utils/io.hpp>
#include <utils/string.hpp>
#include <utils/thread.hpp>
#include <utils/compression.hpp>
#include <exception/minidump.hpp>
namespace exception
{
namespace
{
thread_local struct
{
DWORD code = 0;
PVOID address = nullptr;
} exception_data;
void show_mouse_cursor()
{
while (ShowCursor(TRUE) < 0);
}
void display_error_dialog()
{
std::string error_str = utils::string::va("Fatal error (0x%08X) at 0x%p.\n"
"A minidump has been written.\n\n",
exception_data.code, exception_data.address);
error_str += "Make sure to update your graphics card drivers and install operating system updates!";
utils::thread::suspend_other_threads();
show_mouse_cursor();
MessageBoxA(nullptr, error_str.data(), "Plutonium T4 ERROR", MB_ICONERROR);
TerminateProcess(GetCurrentProcess(), exception_data.code);
}
void reset_state()
{
display_error_dialog();
}
size_t get_reset_state_stub()
{
static auto* stub = utils::hook::assemble([](utils::hook::assembler& a)
{
a.sub(esp, 0x10);
a.or_(esp, 0x8);
a.jmp(reset_state);
});
return reinterpret_cast<size_t>(stub);
}
std::string generate_crash_info(const LPEXCEPTION_POINTERS exceptioninfo)
{
std::string info{};
const auto line = [&info](const std::string& text)
{
info.append(text);
info.append("\r\n");
};
line("Plutonium T4 Crash Dump");
line("");
line("Timestamp: "s + utils::string::get_timestamp());
line(utils::string::va("Exception: 0x%08X", exceptioninfo->ExceptionRecord->ExceptionCode));
line(utils::string::va("Address: 0x%lX", exceptioninfo->ExceptionRecord->ExceptionAddress));
#pragma warning(push)
#pragma warning(disable: 4996)
OSVERSIONINFOEXA version_info;
ZeroMemory(&version_info, sizeof(version_info));
version_info.dwOSVersionInfoSize = sizeof(version_info);
GetVersionExA(reinterpret_cast<LPOSVERSIONINFOA>(&version_info));
#pragma warning(pop)
line(utils::string::va("OS Version: %u.%u", version_info.dwMajorVersion, version_info.dwMinorVersion));
return info;
}
void write_minidump(const LPEXCEPTION_POINTERS exceptioninfo)
{
const std::string crash_name = utils::string::va("minidumps/plutonium-t4-crash-%s.zip",
utils::string::get_timestamp().data());
utils::compression::zip::archive zip_file{};
zip_file.add("crash.dmp", create_minidump(exceptioninfo));
zip_file.add("info.txt", generate_crash_info(exceptioninfo));
zip_file.write(crash_name, "Plutonium T4 Crash Dump");
}
bool is_harmless_error(const LPEXCEPTION_POINTERS exceptioninfo)
{
const auto code = exceptioninfo->ExceptionRecord->ExceptionCode;
return code == STATUS_INTEGER_OVERFLOW || code == STATUS_FLOAT_OVERFLOW || code == STATUS_SINGLE_STEP;
}
LONG WINAPI exception_filter(const LPEXCEPTION_POINTERS exceptioninfo)
{
if (is_harmless_error(exceptioninfo))
{
return EXCEPTION_CONTINUE_EXECUTION;
}
write_minidump(exceptioninfo);
exception_data.code = exceptioninfo->ExceptionRecord->ExceptionCode;
exception_data.address = exceptioninfo->ExceptionRecord->ExceptionAddress;
exceptioninfo->ContextRecord->Eip = get_reset_state_stub();
return EXCEPTION_CONTINUE_EXECUTION;
}
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI set_unhandled_exception_filter_stub(LPTOP_LEVEL_EXCEPTION_FILTER)
{
// Don't register anything here...
return &exception_filter;
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
SetUnhandledExceptionFilter(exception_filter);
utils::hook::jump(reinterpret_cast<uintptr_t>(&SetUnhandledExceptionFilter), set_unhandled_exception_filter_stub);
}
};
}
REGISTER_COMPONENT(exception::component)
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include <utils/hook.hpp>
#include <utils/io.hpp>
#include <utils/string.hpp>
#include <utils/thread.hpp>
#include <utils/compression.hpp>
#include <exception/minidump.hpp>
namespace exception
{
namespace
{
thread_local struct
{
DWORD code = 0;
PVOID address = nullptr;
} exception_data;
void show_mouse_cursor()
{
while (ShowCursor(TRUE) < 0);
}
void display_error_dialog()
{
std::string error_str = utils::string::va("Fatal error (0x%08X) at 0x%p.\n"
"A minidump has been written.\n\n",
exception_data.code, exception_data.address);
error_str += "Make sure to update your graphics card drivers and install operating system updates!";
utils::thread::suspend_other_threads();
show_mouse_cursor();
MessageBoxA(nullptr, error_str.data(), "Plutonium T4 ERROR", MB_ICONERROR);
TerminateProcess(GetCurrentProcess(), exception_data.code);
}
void reset_state()
{
display_error_dialog();
}
size_t get_reset_state_stub()
{
static auto* stub = utils::hook::assemble([](utils::hook::assembler& a)
{
a.sub(esp, 0x10);
a.or_(esp, 0x8);
a.jmp(reset_state);
});
return reinterpret_cast<size_t>(stub);
}
std::string generate_crash_info(const LPEXCEPTION_POINTERS exceptioninfo)
{
std::string info{};
const auto line = [&info](const std::string& text)
{
info.append(text);
info.append("\r\n");
};
line("Plutonium T4 Crash Dump");
line("");
line("Timestamp: "s + utils::string::get_timestamp());
line(utils::string::va("Exception: 0x%08X", exceptioninfo->ExceptionRecord->ExceptionCode));
line(utils::string::va("Address: 0x%lX", exceptioninfo->ExceptionRecord->ExceptionAddress));
line("");
line(build_gsc_dump(game::SCRIPTINSTANCE_SERVER));
line("");
#pragma warning(push)
#pragma warning(disable: 4996)
OSVERSIONINFOEXA version_info;
ZeroMemory(&version_info, sizeof(version_info));
version_info.dwOSVersionInfoSize = sizeof(version_info);
GetVersionExA(reinterpret_cast<LPOSVERSIONINFOA>(&version_info));
#pragma warning(pop)
line(utils::string::va("OS Version: %u.%u", version_info.dwMajorVersion, version_info.dwMinorVersion));
return info;
}
void write_minidump(const LPEXCEPTION_POINTERS exceptioninfo)
{
const std::string crash_name = utils::string::va("t4sp-server-plugin/minidumps/plutonium-t4-crash-%s.zip",
utils::string::get_timestamp().data());
utils::compression::zip::archive zip_file{};
zip_file.add("crash.dmp", create_minidump(exceptioninfo));
zip_file.add("info.txt", generate_crash_info(exceptioninfo));
zip_file.write(crash_name, "Plutonium T4 Crash Dump");
}
bool is_harmless_error(const LPEXCEPTION_POINTERS exceptioninfo)
{
const auto code = exceptioninfo->ExceptionRecord->ExceptionCode;
return code == STATUS_INTEGER_OVERFLOW || code == STATUS_FLOAT_OVERFLOW || code == STATUS_SINGLE_STEP;
}
LONG WINAPI exception_filter(const LPEXCEPTION_POINTERS exceptioninfo)
{
if (is_harmless_error(exceptioninfo))
{
return EXCEPTION_CONTINUE_EXECUTION;
}
write_minidump(exceptioninfo);
exception_data.code = exceptioninfo->ExceptionRecord->ExceptionCode;
exception_data.address = exceptioninfo->ExceptionRecord->ExceptionAddress;
exceptioninfo->ContextRecord->Eip = get_reset_state_stub();
return EXCEPTION_CONTINUE_EXECUTION;
}
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI set_unhandled_exception_filter_stub(LPTOP_LEVEL_EXCEPTION_FILTER)
{
// Don't register anything here...
return &exception_filter;
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
SetUnhandledExceptionFilter(exception_filter);
utils::hook::jump(reinterpret_cast<uintptr_t>(&SetUnhandledExceptionFilter), set_unhandled_exception_filter_stub);
}
};
}
REGISTER_COMPONENT(exception::component)
+437
View File
@@ -0,0 +1,437 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "gsc.hpp"
#include "scheduler.hpp"
#include <utils/memory.hpp>
#include <utils/string.hpp>
namespace fileio
{
namespace
{
static constexpr size_t max_fhs = 10;
static constexpr size_t max_gsc_string = 0x10000 - 1;
enum class scr_fh_type_e
{
UNUSED,
READ,
WRITE,
APPEND
};
struct scr_fh_t
{
scr_fh_type_e type;
std::unique_ptr<char[]> file_buff;
int file_length;
int seek;
std::filesystem::path full_path;
std::string base_path;
};
std::array<scr_fh_t, max_fhs> scr_fhs = {};
bool validate_scr_path(const std::string& fpath)
{
if (fpath.empty())
{
return true;
}
constexpr static std::array bad_strings { R"(..)", R"(../)", R"(..\)" };
for (auto i = 0u; i < bad_strings.size(); i++)
{
if (fpath.find(bad_strings[i]) != std::string::npos)
{
return false;
}
}
return true;
}
std::string build_base_path(const std::string& path)
{
if (!validate_scr_path(path))
{
game::Scr_Error(utils::string::va("Invalid path: %s", path.c_str()), game::SCRIPTINSTANCE_SERVER, false);
}
return path.starts_with("scriptdata/") ? path : "scriptdata/" + path;
}
std::filesystem::path build_full_path(const std::string& path)
{
static game::dvar_s* fs_localAppData = nullptr;
static game::dvar_s* fs_gamedir = nullptr;
if (!fs_localAppData)
{
fs_localAppData = game::Dvar_FindVar("fs_localAppData");
}
if (!fs_gamedir)
{
fs_gamedir = game::Dvar_FindVar("fs_game");
}
return std::filesystem::path(fs_localAppData->current.string) / (*fs_gamedir->current.string ? fs_gamedir->current.string : "raw") / path;
}
void free_scr_fh(scr_fh_t& scr_fh)
{
#ifdef DEBUG
printf("free_scr_fh: closing %s\n", scr_fh.base_path.c_str());
#endif
scr_fh = {};
scr_fh.type = scr_fh_type_e::UNUSED;
}
void close_all_scr_fh()
{
for (auto& fh : scr_fhs)
{
if (fh.type == scr_fh_type_e::UNUSED)
{
continue;
}
free_scr_fh(fh);
}
}
void fwrite_to_file(bool append_newline)
{
auto fh = game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 0) - 1;
if (fh < 0 || fh >= max_fhs)
{
game::Scr_Error("fs_fwrite: invalid filehandle", game::SCRIPTINSTANCE_SERVER, false);
}
if (scr_fhs[fh].type != scr_fh_type_e::WRITE && scr_fhs[fh].type != scr_fh_type_e::APPEND)
{
game::Scr_Error("File not opened for writing", game::SCRIPTINSTANCE_SERVER, false);
}
std::string to_write = game::Scr_GetString(1, game::SCRIPTINSTANCE_SERVER);
if (append_newline)
{
to_write += '\n';
}
if (!utils::io::write_file(scr_fhs[fh].full_path.string(), to_write, true))
{
game::Com_PrintWarning(game::CON_CHANNEL_SCRIPT, "Failed to write file: %s\n", scr_fhs[fh].base_path.c_str());
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 0);
return;
}
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 1);
}
void add_file_io()
{
scheduler::on_pre_scr_init_system([]([[maybe_unused]] game::scriptInstance_t inst)
{
if (inst != game::SCRIPTINSTANCE_SERVER)
{
return;
}
close_all_scr_fh();
});
gsc::function::add("fs_testfile", []()
{
auto fpath = build_base_path(game::Scr_GetString(0, game::SCRIPTINSTANCE_SERVER));
auto fd = 0;
auto file_length = game::FS_FOpenFileRead(fpath.c_str(), &fd);
if (!fd || file_length < 0)
{
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 0);
return;
}
game::FS_FCloseFile(fd);
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 1);
});
gsc::function::add("fs_fopen", []()
{
auto fpath = build_base_path(game::Scr_GetString(0, game::SCRIPTINSTANCE_SERVER));
// check for dupes
for (const auto& scr_fd : scr_fhs)
{
if (scr_fd.type != scr_fh_type_e::UNUSED && scr_fd.base_path == fpath)
{
game::Scr_Error("File already opened", game::SCRIPTINSTANCE_SERVER, false);
}
}
// check for avail slot
auto i = 0;
for (; i < max_fhs; i++)
{
if (scr_fhs[i].type == scr_fh_type_e::UNUSED)
{
break;
}
}
if (i >= max_fhs)
{
game::Scr_Error("Too many files opened", game::SCRIPTINSTANCE_SERVER, false);
}
// check mode
auto mode = game::Scr_GetString(1, game::SCRIPTINSTANCE_SERVER);
if (mode == "read"s)
{
auto fd = 0;
auto file_length = game::FS_FOpenFileRead(fpath.c_str(), &fd);
if (!fd || file_length < 0)
{
game::Com_PrintWarning(game::CON_CHANNEL_SCRIPT, "Failed to open file for reading: %s\n", fpath.c_str());
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 0);
return;
}
scr_fhs[i].file_buff = std::make_unique<char[]>(file_length + 1);
auto bytes_read = game::FS_Read(scr_fhs[i].file_buff.get(), file_length, fd);
scr_fhs[i].file_buff[file_length] = '\0';
game::FS_FCloseFile(fd);
assert(bytes_read == file_length);
if (bytes_read < 0)
{
scr_fhs[i].file_buff = {};
game::Com_PrintWarning(game::CON_CHANNEL_SCRIPT, "Failed to read file: %s\n", fpath.c_str());
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 0);
return;
}
scr_fhs[i].type = scr_fh_type_e::READ;
scr_fhs[i].file_length = bytes_read;
scr_fhs[i].seek = 0;
scr_fhs[i].base_path = fpath;
}
else if (mode == "write"s || mode == "append"s)
{
auto full_path = build_full_path(fpath);
if (!utils::io::write_file(full_path.string(), "", (mode == "append"s)))
{
game::Com_PrintWarning(game::CON_CHANNEL_SCRIPT, "Failed to open file for writing: %s\n", fpath.c_str());
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 0);
return;
}
scr_fhs[i].type = scr_fh_type_e::WRITE;
scr_fhs[i].base_path = fpath;
scr_fhs[i].full_path = full_path;
}
else
{
game::Scr_Error(utils::string::va("Invalid mode: %s", mode), game::SCRIPTINSTANCE_SERVER, false);
}
#ifdef DEBUG
printf("gscr_fs_fopen: opening %s, mode %s\n", fpath.c_str(), mode);
#endif
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, i + 1);
});
gsc::function::add("fs_write", []()
{
fwrite_to_file(false);
});
gsc::function::add("fs_writeline", []()
{
fwrite_to_file(true);
});
gsc::function::add("fs_readline", []()
{
auto fh = game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 0) - 1;
if (fh < 0 || fh >= max_fhs)
{
game::Scr_Error("Invalid filehandle", game::SCRIPTINSTANCE_SERVER, false);
}
if (scr_fhs[fh].type != scr_fh_type_e::READ)
{
game::Scr_Error("File not opened for reading", game::SCRIPTINSTANCE_SERVER, false);
}
// file is completed being read
if (scr_fhs[fh].seek >= scr_fhs[fh].file_length)
{
game::Scr_AddUndefined(game::SCRIPTINSTANCE_SERVER);
return;
}
// count how many bytes until the newline
auto bytes_to_read = 0;
auto found_nl = false;
for (auto i = scr_fhs[fh].seek; i < scr_fhs[fh].file_length; bytes_to_read++, i++)
{
if (scr_fhs[fh].file_buff[i] == '\n')
{
bytes_to_read++;
found_nl = true;
break;
}
}
if (bytes_to_read > max_gsc_string)
{
found_nl = false;
bytes_to_read = max_gsc_string;
game::Com_PrintWarning(game::CON_CHANNEL_SCRIPT, "Line was too long in file %s, truncating\n", scr_fhs[fh].base_path.c_str());
}
auto scr_str = std::string(&scr_fhs[fh].file_buff[scr_fhs[fh].seek], bytes_to_read);
scr_fhs[fh].seek += bytes_to_read;
// remove all '\r'
scr_str.erase(std::remove(scr_str.begin(), scr_str.end(), '\r'), scr_str.end());
// chop the newline char off
if (found_nl)
{
scr_str.pop_back();
}
game::Scr_AddString(game::SCRIPTINSTANCE_SERVER, scr_str.c_str());
});
gsc::function::add("fs_read", []()
{
auto fh = game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 0) - 1;
if (fh < 0 || fh >= max_fhs)
{
game::Scr_Error("Invalid filehandle", game::SCRIPTINSTANCE_SERVER, false);
}
if (scr_fhs[fh].type != scr_fh_type_e::READ)
{
game::Scr_Error("File not opened for reading", game::SCRIPTINSTANCE_SERVER, false);
}
// file is completed being read
if (scr_fhs[fh].seek >= scr_fhs[fh].file_length)
{
game::Scr_AddUndefined(game::SCRIPTINSTANCE_SERVER);
return;
}
auto bytes_to_read = scr_fhs[fh].file_length - scr_fhs[fh].seek;
if (game::Scr_GetNumParam(game::SCRIPTINSTANCE_SERVER) >= 2)
{
bytes_to_read = std::clamp(game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 1), 0, bytes_to_read);
if (bytes_to_read <= 0)
{
game::Scr_Error("Trying to read <1 bytes", game::SCRIPTINSTANCE_SERVER, false);
}
}
if (bytes_to_read > max_gsc_string)
{
bytes_to_read = max_gsc_string;
game::Com_PrintWarning(game::CON_CHANNEL_SCRIPT, "Line was too long in file %s, truncating\n", scr_fhs[fh].base_path.c_str());
}
auto scr_str = std::string(&scr_fhs[fh].file_buff[scr_fhs[fh].seek], bytes_to_read);
scr_fhs[fh].seek += bytes_to_read;
game::Scr_AddString(game::SCRIPTINSTANCE_SERVER, scr_str.c_str());
});
gsc::function::add("fs_fcloseall", []()
{
close_all_scr_fh();
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 1);
});
gsc::function::add("fs_fclose", []()
{
auto fh = game::Scr_GetInt(game::SCRIPTINSTANCE_SERVER, 0) - 1;
if (fh < 0 || fh >= max_fhs)
{
game::Scr_Error("Invalid filehandle", game::SCRIPTINSTANCE_SERVER, false);
}
if (scr_fhs[fh].type == scr_fh_type_e::UNUSED)
{
game::Scr_Error("File not opened", game::SCRIPTINSTANCE_SERVER, false);
}
free_scr_fh(scr_fhs[fh]);
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 1);
});
gsc::function::add("fs_remove", []()
{
auto fpath = build_base_path(game::Scr_GetString(0, game::SCRIPTINSTANCE_SERVER));
auto full_path = build_full_path(fpath);
if (!utils::io::remove_file(full_path.string()))
{
game::Com_PrintWarning(game::CON_CHANNEL_SCRIPT, "Failed to delete file: %s\n", fpath.c_str());
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 0);
return;
}
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 1);
});
gsc::function::add("fs_listfiles", []()
{
auto fpath = build_base_path(game::Scr_GetString(0, game::SCRIPTINSTANCE_SERVER));
int numfiles;
auto* files = game::FS_ListFiles(fpath.c_str(), "", game::FS_LIST_ALL, &numfiles);
game::Scr_MakeArray(game::SCRIPTINSTANCE_SERVER);
for (int i = 0; i < numfiles; i++)
{
game::Scr_AddString(game::SCRIPTINSTANCE_SERVER, files[i]);
game::Scr_AddArray(game::SCRIPTINSTANCE_SERVER);
}
game::FS_FreeFileList(files);
});
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
add_file_io();
}
private:
};
}
REGISTER_COMPONENT(fileio::component)
+37 -3
View File
@@ -1,5 +1,6 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "gsc.hpp"
#include "scheduler.hpp"
@@ -107,6 +108,19 @@ namespace gsc
{
functions.insert_or_assign(name, function);
}
game::BuiltinFunction get(const char** name, int* type)
{
auto got = functions.find(*name);
if (got == functions.end())
{
return nullptr;
}
*type = 0;
return got->second;
}
}
namespace method
@@ -115,6 +129,19 @@ namespace gsc
{
methods.insert_or_assign(name, method);
}
game::BuiltinMethod get(const char** name, int* type)
{
auto got = methods.find(*name);
if (got == methods.end())
{
return nullptr;
}
*type = 0;
return got->second;
}
}
class component final : public component_interface
@@ -122,12 +149,19 @@ namespace gsc
public:
void post_unpack() override
{
// for when we dont use the decomp
// custom gsc methods
scr_getmethod_hook.create(utils::hook::get_displacement_addr(SELECT(0x0, 0x683043)), scr_getmethod_stub);
if (game::plutonium::scr_get_method_stub != nullptr)
{
scr_getmethod_hook.create(game::plutonium::scr_get_method_stub.get(), scr_getmethod_stub);
}
// custom gsc funcs
scr_getfunction_stub_ret_loc = utils::hook::get_displacement_addr(SELECT(0x0, 0x682D99));
utils::hook::jump(SELECT(0x0, 0x682D99), scr_getfunction_stub);
if (game::plutonium::scr_get_function_stub != nullptr)
{
scr_getfunction_stub_ret_loc = game::plutonium::scr_get_function_stub.get();
utils::hook::jump(SELECT(0x0, 0x682D99), scr_getfunction_stub);
}
}
private:
+2
View File
@@ -5,10 +5,12 @@ namespace gsc
namespace function
{
void add(const std::string& name, const game::BuiltinFunction function);
game::BuiltinFunction get(const char** name, int* type);
}
namespace method
{
void add(const std::string& name, const game::BuiltinMethod method);
game::BuiltinMethod get(const char** name, int* type);
}
}
+266 -195
View File
@@ -1,195 +1,266 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "scheduler.hpp"
#include <utils/concurrency.hpp>
#include <utils/hook.hpp>
namespace scheduler
{
namespace
{
struct task
{
std::function<bool()> handler{};
std::chrono::milliseconds interval{};
std::chrono::high_resolution_clock::time_point last_call{};
};
using task_list = std::vector<task>;
class task_pipeline
{
public:
void add(task&& task)
{
new_callbacks_.access([&task](task_list& tasks)
{
tasks.emplace_back(std::move(task));
});
}
void execute()
{
callbacks_.access([&](task_list& tasks)
{
this->merge_callbacks();
for (auto i = tasks.begin(); i != tasks.end();)
{
const auto now = std::chrono::high_resolution_clock::now();
const auto diff = now - i->last_call;
if (diff < i->interval)
{
++i;
continue;
}
i->last_call = now;
const auto res = i->handler();
if (res == cond_end)
{
i = tasks.erase(i);
}
else
{
++i;
}
}
});
}
private:
utils::concurrency::container<task_list> new_callbacks_;
utils::concurrency::container<task_list, std::recursive_mutex> callbacks_;
void merge_callbacks()
{
callbacks_.access([&](task_list& tasks)
{
new_callbacks_.access([&](task_list& new_tasks)
{
tasks.insert(tasks.end(), std::move_iterator<task_list::iterator>(new_tasks.begin()), std::move_iterator<task_list::iterator>(new_tasks.end()));
new_tasks = {};
});
});
}
};
std::thread thread;
task_pipeline pipelines[pipeline::count];
void execute(const pipeline type)
{
assert(type >= 0 && type < pipeline::count);
pipelines[type].execute();
}
void execute_server()
{
execute(pipeline::server);
}
void execute_main()
{
execute(pipeline::main);
}
utils::hook::detour com_init_hook;
utils::hook::detour gscr_postloadscripts_hook;
std::vector<std::function<void()>> post_init_funcs;
bool com_inited = false;
void on_post_init_hook()
{
if (com_inited)
{
return;
}
com_inited = true;
for (const auto& func : post_init_funcs)
{
func();
}
post_init_funcs.clear();
}
void com_init_stub()
{
com_init_hook.invoke<void>();
on_post_init_hook();
}
}
void schedule(const std::function<bool()>& callback, const pipeline type,
const std::chrono::milliseconds delay)
{
assert(type >= 0 && type < pipeline::count);
task task;
task.handler = callback;
task.interval = delay;
task.last_call = std::chrono::high_resolution_clock::now();
pipelines[type].add(std::move(task));
}
void loop(const std::function<void()>& callback, const pipeline type,
const std::chrono::milliseconds delay)
{
schedule([callback]()
{
callback();
return cond_continue;
}, type, delay);
}
void once(const std::function<void()>& callback, const pipeline type,
const std::chrono::milliseconds delay)
{
schedule([callback]()
{
callback();
return cond_end;
}, type, delay);
}
void on_init(const std::function<void()>& callback)
{
if (com_inited)
{
once(callback, pipeline::main);
}
else
{
post_init_funcs.push_back(callback);
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
thread = std::thread([]()
{
while (true)
{
execute(pipeline::async);
std::this_thread::sleep_for(10ms);
}
});
com_init_hook.create(SELECT(0x0, 0x59D710), com_init_stub);
utils::hook::call(SELECT(0x0, 0x503B5D), execute_server);
utils::hook::call(SELECT(0x0, 0x59DCFD), execute_main);
}
};
}
REGISTER_COMPONENT(scheduler::component)
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "scheduler.hpp"
#include <utils/concurrency.hpp>
#include <utils/hook.hpp>
namespace scheduler
{
namespace
{
struct task
{
std::function<bool()> handler{};
std::chrono::milliseconds interval{};
std::chrono::high_resolution_clock::time_point last_call{};
};
using task_list = std::vector<task>;
class task_pipeline
{
public:
void add(task&& task)
{
new_callbacks_.access([&task](task_list& tasks)
{
tasks.emplace_back(std::move(task));
});
}
void execute()
{
callbacks_.access([&](task_list& tasks)
{
this->merge_callbacks();
for (auto i = tasks.begin(); i != tasks.end();)
{
const auto now = std::chrono::high_resolution_clock::now();
const auto diff = now - i->last_call;
if (diff < i->interval)
{
++i;
continue;
}
i->last_call = now;
const auto res = i->handler();
if (res == cond_end)
{
i = tasks.erase(i);
}
else
{
++i;
}
}
});
}
private:
utils::concurrency::container<task_list> new_callbacks_;
utils::concurrency::container<task_list, std::recursive_mutex> callbacks_;
void merge_callbacks()
{
callbacks_.access([&](task_list& tasks)
{
new_callbacks_.access([&](task_list& new_tasks)
{
tasks.insert(tasks.end(), std::move_iterator<task_list::iterator>(new_tasks.begin()), std::move_iterator<task_list::iterator>(new_tasks.end()));
new_tasks = {};
});
});
}
};
std::thread thread;
task_pipeline pipelines[pipeline::count];
void execute(const pipeline type)
{
assert(type >= 0 && type < pipeline::count);
pipelines[type].execute();
}
void execute_server()
{
execute(pipeline::server);
}
void execute_main()
{
execute(pipeline::main);
}
utils::hook::detour com_init_hook;
utils::hook::detour gscr_postloadscripts_hook;
std::vector<std::function<void()>> post_init_funcs;
bool com_inited = false;
void on_post_init_hook()
{
if (com_inited)
{
return;
}
com_inited = true;
for (const auto& func : post_init_funcs)
{
func();
}
post_init_funcs.clear();
}
void com_init_stub()
{
com_init_hook.invoke<void>();
on_post_init_hook();
}
std::vector<std::function<void(game::scriptInstance_t)>> pre_scr_init_funcs;
std::vector<std::function<void(game::scriptInstance_t)>> post_scr_init_funcs;
utils::hook::detour pre_scr_init_system_hook;
utils::hook::detour post_scr_init_system_hook;
void* pre_scr_init_system_original;
void* post_scr_init_system_original;
NAKED void pre_scr_init_system_stub()
{
__asm
{
pushad;
push eax;
call exec_pre_scr_init_funcs;
add esp, 4;
popad;
push pre_scr_init_system_original;
ret;
}
}
NAKED void post_scr_init_system_stub()
{
__asm
{
pushad;
push eax;
call exec_post_scr_init_funcs;
add esp, 4;
popad;
push post_scr_init_system_original;
ret;
}
}
}
void schedule(const std::function<bool()>& callback, const pipeline type,
const std::chrono::milliseconds delay)
{
assert(type >= 0 && type < pipeline::count);
task task;
task.handler = callback;
task.interval = delay;
task.last_call = std::chrono::high_resolution_clock::now();
pipelines[type].add(std::move(task));
}
void loop(const std::function<void()>& callback, const pipeline type,
const std::chrono::milliseconds delay)
{
schedule([callback]()
{
callback();
return cond_continue;
}, type, delay);
}
void once(const std::function<void()>& callback, const pipeline type,
const std::chrono::milliseconds delay)
{
schedule([callback]()
{
callback();
return cond_end;
}, type, delay);
}
void on_init(const std::function<void()>& callback)
{
if (com_inited)
{
once(callback, pipeline::main);
}
else
{
post_init_funcs.push_back(callback);
}
}
void on_pre_scr_init_system(const std::function<void(game::scriptInstance_t)>& callback)
{
pre_scr_init_funcs.push_back(callback);
}
void on_post_scr_init_system(const std::function<void(game::scriptInstance_t)>& callback)
{
post_scr_init_funcs.push_back(callback);
}
void exec_pre_scr_init_funcs(game::scriptInstance_t inst)
{
for (const auto& func : pre_scr_init_funcs)
{
func(inst);
}
}
void exec_post_scr_init_funcs(game::scriptInstance_t inst)
{
for (const auto& func : post_scr_init_funcs)
{
func(inst);
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
thread = std::thread([]()
{
while (true)
{
execute(pipeline::async);
std::this_thread::sleep_for(10ms);
}
});
com_init_hook.create(SELECT(0x0, 0x59D710), com_init_stub);
utils::hook::call(SELECT(0x0, 0x503B5D), execute_server);
utils::hook::call(SELECT(0x0, 0x59DCFD), execute_main);
// for when we dont use decomp
pre_scr_init_system_hook.create(0x699865, pre_scr_init_system_stub);
pre_scr_init_system_original = pre_scr_init_system_hook.get_original();
post_scr_init_system_hook.create(0x699924, post_scr_init_system_stub);
post_scr_init_system_original = post_scr_init_system_hook.get_original();
}
};
}
REGISTER_COMPONENT(scheduler::component)
+29 -24
View File
@@ -1,24 +1,29 @@
#pragma once
namespace scheduler
{
enum pipeline
{
server,
async,
main,
count,
};
static const bool cond_continue = false;
static const bool cond_end = true;
void schedule(const std::function<bool()>& callback, pipeline type = pipeline::main,
std::chrono::milliseconds delay = 0ms);
void loop(const std::function<void()>& callback, pipeline type = pipeline::main,
std::chrono::milliseconds delay = 0ms);
void once(const std::function<void()>& callback, pipeline type = pipeline::main,
std::chrono::milliseconds delay = 0ms);
void on_init(const std::function<void()>& callback);
}
#pragma once
namespace scheduler
{
enum pipeline
{
server,
async,
main,
count,
};
static const bool cond_continue = false;
static const bool cond_end = true;
void schedule(const std::function<bool()>& callback, pipeline type = pipeline::main,
std::chrono::milliseconds delay = 0ms);
void loop(const std::function<void()>& callback, pipeline type = pipeline::main,
std::chrono::milliseconds delay = 0ms);
void once(const std::function<void()>& callback, pipeline type = pipeline::main,
std::chrono::milliseconds delay = 0ms);
void on_init(const std::function<void()>& callback);
void on_pre_scr_init_system(const std::function<void(game::scriptInstance_t)>& callback);
void on_post_scr_init_system(const std::function<void(game::scriptInstance_t)>& callback);
void exec_pre_scr_init_funcs(game::scriptInstance_t inst);
void exec_post_scr_init_funcs(game::scriptInstance_t inst);
}
+83 -9
View File
@@ -86,11 +86,29 @@ namespace signatures
return image_size;
}
size_t load_iamge_base()
{
return reinterpret_cast<size_t>(GetModuleHandle("plutonium-bootstrapper-win32.exe"));
}
size_t get_image_base()
{
static const auto image_base = load_iamge_base();
return image_base;
}
bool addr_is_in_image_space(size_t wheree)
{
static const auto image_base = load_iamge_base();
return wheree >= image_base && wheree < image_base + get_image_size();
}
size_t find_string_ptr(const std::string& string)
{
const char* string_ptr = nullptr;
std::string mask(string.size(), 'x');
const auto base = reinterpret_cast<size_t>(GetModuleHandle("plutonium-bootstrapper-win32.exe"));
const auto base = get_image_base();
utils::hook::signature signature(base, get_image_size() - base);
signature.add({
@@ -119,10 +137,15 @@ namespace signatures
return find_string_ptr({bytes, 4});
}
bool process_printf()
{
auto cache_info = get_cache_info_for_our_version();
std::string err_reason;
const std::string& get_err_reason()
{
return err_reason;
}
bool process_printf(std::unordered_map<std::string, std::string> &cache_info)
{
if (cache_info.contains("printf"))
{
game::plutonium::printf.set(std::atoi(cache_info.at("printf").c_str()));
@@ -132,6 +155,7 @@ namespace signatures
const auto string_ref = find_string_ref("A critical exception occured!\n");
if (!string_ref)
{
err_reason = "printf";
return false;
}
@@ -139,14 +163,66 @@ namespace signatures
game::plutonium::printf.set(string_ref + 4 + 5 + offset);
cache_info.insert_or_assign("printf", std::to_string(string_ref + 4 + 5 + offset));
save_cache_info_for_our_version(cache_info);
return true;
}
#define SAFE_SET_PLUTO_SYMBOL_DOUBLE(name, addr, off) \
addr2 = reinterpret_cast<size_t>(utils::hook::get_displacement_addr(addr)); \
if (!addr_is_in_image_space(addr2)) \
{ \
err_reason = #name " 1"; \
return false; \
} \
addr1 = reinterpret_cast<size_t>(utils::hook::get_displacement_addr(addr2 + off)); \
if (!addr_is_in_image_space(addr1)) \
{ \
err_reason = #name " 2"; \
return false; \
} \
game::plutonium::name.set(addr1)
#define SAFE_SET_PLUTO_SYMBOL(name, addr) \
addr1 = reinterpret_cast<size_t>(utils::hook::get_displacement_addr(addr)); \
if (!addr_is_in_image_space(addr1)) \
{ \
err_reason = #name; \
return false; \
} \
game::plutonium::name.set(addr1)
bool handle_funcs()
{
game::plutonium::load_custom_script_func.set(reinterpret_cast<size_t>(utils::hook::get_displacement_addr(reinterpret_cast<size_t>(utils::hook::get_displacement_addr(0x689C80)) + 0x6)));
size_t addr1;
size_t addr2;
auto cache_info = get_cache_info_for_our_version();
if (!process_printf(cache_info))
{
return false;
}
SAFE_SET_PLUTO_SYMBOL_DOUBLE(load_custom_script_func, 0x689C80, 0x6);
SAFE_SET_PLUTO_SYMBOL_DOUBLE(script_preprocess, 0x689BCF, 0x2);
SAFE_SET_PLUTO_SYMBOL_DOUBLE(vm_execute_update_codepos, 0x69608C, 0x2);
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_execthread_update_codepos_func, 0x699560, 0x11);
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_execentthread_update_codepos_func, 0x699640, 0x7);
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_addexecthread_update_codepos_func, 0x699730, 0x7);
SAFE_SET_PLUTO_SYMBOL_DOUBLE(at_codepose_va, 0x68B3A5, 0xA);
SAFE_SET_PLUTO_SYMBOL_DOUBLE(store_func_codepos, 0x688909, 0x3);
SAFE_SET_PLUTO_SYMBOL(cscr_get_function_hook, 0x682DC0);
SAFE_SET_PLUTO_SYMBOL(scr_get_function_stub, 0x682D99);
SAFE_SET_PLUTO_SYMBOL(scr_get_method_stub, 0x683043);
SAFE_SET_PLUTO_SYMBOL(cscr_get_method_hook, 0x68305C);
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_get_method_hook, 0x683043, 0x4);
SAFE_SET_PLUTO_SYMBOL_DOUBLE(scr_get_function_hook, 0x682D99, 0x8);
save_cache_info_for_our_version(cache_info);
return true;
}
@@ -155,8 +231,6 @@ namespace signatures
{
utils::cryptography::des::set_key("694201337");
handle_funcs();
return process_printf();
return handle_funcs();
}
}
+1
View File
@@ -2,5 +2,6 @@
namespace signatures
{
const std::string& get_err_reason();
bool process();
}
+32 -39
View File
@@ -1,39 +1,32 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "scheduler.hpp"
#include "gsc.hpp"
#include <utils/io.hpp>
#include <utils/hook.hpp>
#include <utils/string.hpp>
#include <utils/http.hpp>
#include <json.hpp>
namespace test
{
namespace
{
}
class component final : public component_interface
{
public:
void post_unpack() override
{
//Disable AI print spam
utils::hook::nop(0x4BAB7D, 5);
utils::hook::nop(0x4BAAFA, 5);
//Disable asset loading print spam
utils::hook::nop(0x48D9D9, 5);
//Disable unknown dvar spam
utils::hook::nop(0x5F04AF, 5);
}
private:
};
}
REGISTER_COMPONENT(test::component)
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include <utils/hook.hpp>
namespace test
{
namespace
{
}
class component final : public component_interface
{
public:
void post_unpack() override
{
//Disable AI print spam
utils::hook::nop(0x4BAB7D, 5);
utils::hook::nop(0x4BAAFA, 5);
//Disable asset loading print spam
utils::hook::nop(0x48D9D9, 5);
//Disable unknown dvar spam
utils::hook::nop(0x5F04AF, 5);
}
private:
};
}
REGISTER_COMPONENT(test::component)
+39 -38
View File
@@ -1,39 +1,40 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "component/signatures.hpp"
#include <utils/hook.hpp>
BOOL APIENTRY DllMain(HMODULE /*module_*/, DWORD ul_reason_for_call, LPVOID /*reserved_*/)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
if (game::environment::t4sp())
{
if (!signatures::process())
{
MessageBoxA(NULL,
"This version of t4sp-server-plugin is outdated.\n" \
"Download the latest dll from here: https://github.com/JezuzLizard/T4SP-Server-Plugin/releases",
"ERROR", MB_ICONERROR);
return FALSE;
}
if (game::plutonium::printf.get() != nullptr)
{
utils::hook::jump(reinterpret_cast<uintptr_t>(&printf), game::plutonium::printf);
}
component_loader::post_unpack();
}
else
{
MessageBoxA(nullptr, "Unsupported game executable. (t4sp is only supported)", "ERROR, BRO!", 0);
return FALSE;
}
}
return TRUE;
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "component/signatures.hpp"
#include <utils/hook.hpp>
BOOL APIENTRY DllMain(HMODULE /*module_*/, DWORD ul_reason_for_call, LPVOID /*reserved_*/)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
if (game::environment::t4sp())
{
if (!signatures::process())
{
MessageBoxA(NULL,
std::format("This version of t4sp-server-plugin is outdated.\n" \
"Download the latest dll from here: https://github.com/JezuzLizard/T4SP-Server-Plugin/releases\n" \
"'{}' failed", signatures::get_err_reason()).c_str(),
"ERROR", MB_ICONERROR);
return FALSE;
}
if (game::plutonium::printf.get() != nullptr)
{
utils::hook::jump(reinterpret_cast<uintptr_t>(&printf), game::plutonium::printf);
}
component_loader::post_unpack();
}
else
{
MessageBoxA(nullptr, "Unsupported game executable. (t4sp is only supported)", "ERROR, BRO!", 0);
return FALSE;
}
}
return TRUE;
}
+94 -94
View File
@@ -1,94 +1,94 @@
#include <stdinc.hpp>
#include "minidump.hpp"
#include <DbgHelp.h>
#pragma comment(lib, "dbghelp.lib")
#include <gsl/gsl>
namespace exception
{
namespace
{
constexpr MINIDUMP_TYPE get_minidump_type()
{
const auto type = MiniDumpIgnoreInaccessibleMemory //
| MiniDumpWithHandleData //
| MiniDumpScanMemory //
| MiniDumpWithProcessThreadData //
| MiniDumpWithFullMemoryInfo //
| MiniDumpWithThreadInfo //
| MiniDumpWithUnloadedModules;
return static_cast<MINIDUMP_TYPE>(type);
}
std::string get_temp_filename()
{
char filename[MAX_PATH] = {0};
char pathname[MAX_PATH] = {0};
GetTempPathA(sizeof(pathname), pathname);
GetTempFileNameA(pathname, "Plutonium T4 -", 0, filename);
return filename;
}
HANDLE write_dump_to_temp_file(const LPEXCEPTION_POINTERS exceptioninfo)
{
MINIDUMP_EXCEPTION_INFORMATION minidump_exception_info = {GetCurrentThreadId(), exceptioninfo, FALSE};
auto* const file_handle = CreateFileA(get_temp_filename().data(), GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS,
FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE,
nullptr);
if (!MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), file_handle, get_minidump_type(),
&minidump_exception_info,
nullptr,
nullptr))
{
MessageBoxA(nullptr, "There was an error creating the minidump! Hit OK to close the program.",
"Minidump Error", MB_OK | MB_ICONERROR);
TerminateProcess(GetCurrentProcess(), 123);
}
return file_handle;
}
std::string read_file(HANDLE file_handle)
{
FlushFileBuffers(file_handle);
SetFilePointer(file_handle, 0, nullptr, FILE_BEGIN);
std::string buffer{};
DWORD bytes_read = 0;
char temp_bytes[0x2000];
do
{
if (!ReadFile(file_handle, temp_bytes, sizeof(temp_bytes), &bytes_read, nullptr))
{
return {};
}
buffer.append(temp_bytes, bytes_read);
}
while (bytes_read == sizeof(temp_bytes));
return buffer;
}
}
std::string create_minidump(const LPEXCEPTION_POINTERS exceptioninfo)
{
auto* const file_handle = write_dump_to_temp_file(exceptioninfo);
const auto _ = gsl::finally([file_handle]()
{
CloseHandle(file_handle);
});
return read_file(file_handle);
}
}
#include <stdinc.hpp>
#include "minidump.hpp"
#include <DbgHelp.h>
#pragma comment(lib, "dbghelp.lib")
#include <gsl/gsl>
namespace exception
{
namespace
{
constexpr MINIDUMP_TYPE get_minidump_type()
{
const auto type = MiniDumpIgnoreInaccessibleMemory //
| MiniDumpWithHandleData //
| MiniDumpScanMemory //
| MiniDumpWithProcessThreadData //
| MiniDumpWithFullMemoryInfo //
| MiniDumpWithThreadInfo //
| MiniDumpWithUnloadedModules;
return static_cast<MINIDUMP_TYPE>(type);
}
std::string get_temp_filename()
{
char filename[MAX_PATH] = {0};
char pathname[MAX_PATH] = {0};
GetTempPathA(sizeof(pathname), pathname);
GetTempFileNameA(pathname, "Plutonium T4 -", 0, filename);
return filename;
}
HANDLE write_dump_to_temp_file(const LPEXCEPTION_POINTERS exceptioninfo)
{
MINIDUMP_EXCEPTION_INFORMATION minidump_exception_info = {GetCurrentThreadId(), exceptioninfo, FALSE};
auto* const file_handle = CreateFileA(get_temp_filename().data(), GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_ALWAYS,
FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE,
nullptr);
if (!MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), file_handle, get_minidump_type(),
&minidump_exception_info,
nullptr,
nullptr))
{
MessageBoxA(nullptr, "There was an error creating the minidump! Hit OK to close the program.",
"Minidump Error", MB_OK | MB_ICONERROR);
TerminateProcess(GetCurrentProcess(), 123);
}
return file_handle;
}
std::string read_file(HANDLE file_handle)
{
FlushFileBuffers(file_handle);
SetFilePointer(file_handle, 0, nullptr, FILE_BEGIN);
std::string buffer{};
DWORD bytes_read = 0;
char temp_bytes[0x2000];
do
{
if (!ReadFile(file_handle, temp_bytes, sizeof(temp_bytes), &bytes_read, nullptr))
{
return {};
}
buffer.append(temp_bytes, bytes_read);
}
while (bytes_read == sizeof(temp_bytes));
return buffer;
}
}
std::string create_minidump(const LPEXCEPTION_POINTERS exceptioninfo)
{
auto* const file_handle = write_dump_to_temp_file(exceptioninfo);
const auto _ = gsl::finally([file_handle]()
{
CloseHandle(file_handle);
});
return read_file(file_handle);
}
}
+6 -6
View File
@@ -1,6 +1,6 @@
#pragma once
namespace exception
{
std::string create_minidump(LPEXCEPTION_POINTERS exceptioninfo);
}
#pragma once
namespace exception
{
std::string create_minidump(LPEXCEPTION_POINTERS exceptioninfo);
}
+58 -25
View File
@@ -4,7 +4,7 @@
#define VAR_STAT_MASK 0x60
#define VAR_STAT_MOVABLE 0x20
#define VAR_STAT_HEAD 0x40
#define VAR_STAT_EXTERNAL VAR_STAT_MASK
#define VAR_STAT_EXTERNAL 0x60
#define VAR_MASK 0x1F
#define VAR_ENT_MASK 0x3FFF
@@ -14,7 +14,7 @@
#define VAR_NAME_BIT_SHIFT 8
#define VAR_PARENTID_BIT_SHIFT 8
#define OBJECT_STACK 0x15FFE
#define OBJECT_NOTIFY_LIST OBJECT_STACK
#define OBJECT_NOTIFY_LIST 0x15FFE
#define VARIABLELIST_CHILD_SIZE 0x10000
#define VARIABLELIST_CHILD_BEGIN 0x6000
@@ -384,6 +384,44 @@ namespace game
VAR_ENDON_LIST = 0x18,
};
enum scr_builtin_type_t
{
BUILTIN_ANY = 0x0,
BUILTIN_DEVELOPER_ONLY = 0x1,
};
enum Scr_SourceType_t
{
SOURCE_TYPE_NONE = 0x0,
SOURCE_TYPE_BREAKPOINT = 0x1,
SOURCE_TYPE_CALL = 0x2,
};
enum scr_abort_t
{
SCR_ABORT_NONE = 0x0,
SCR_ABORT_CONTINUE = 0x1,
SCR_ABORT_BREAK = 0x2,
SCR_ABORT_RETURN = 0x3,
SCR_ABORT_MAX = 0x3,
};
enum scr_call_type_t
{
CALL_NONE = 0x0,
CALL_BUILTIN = 0x1,
CALL_THREAD = 0x2,
CALL_FUNCTION = 0x3,
};
enum sl_user_type_e
{
SL_USER_GAME = 0x1,
SL_USER_TEMP = 0x2,
SL_USER_XZONE = 0x4,
SL_USER_XZONE_TEMP = 0x8,
};
#pragma endregion
#pragma region "structs"
@@ -739,15 +777,13 @@ namespace game
ASSERT_STRUCT_OFFSET(MemoryNode, next, 0x2);
ASSERT_STRUCT_OFFSET(MemoryNode, padding, 0x4);
struct scrMemTreeGlob_t
struct __declspec(align(128)) scrMemTreeGlob_t
{
MemoryNode nodes[65536]; //OFS: 0x0 SIZE: 0xC0000
unsigned __int8 leftBits[256]; //OFS: 0xC0000 SIZE: 0x100
unsigned __int8 numBits[256]; //OFS: 0xC0100 SIZE: 0x100
unsigned __int8 logBits[256]; //OFS: 0xC0200 SIZE: 0x100
unsigned __int16 head[17]; //OFS: 0xC0300 SIZE: 0x22
_BYTE gap_C0322[93]; //OFS: 0xC0322 SIZE: 0x5D
char field_C037F; //OFS: 0xC037F SIZE: 0x1
MemoryNode nodes[MT_NODE_COUNT];
unsigned __int8 leftBits[MT_NUM_BUCKETS];
unsigned __int8 numBits[MT_NUM_BUCKETS];
unsigned __int8 logBits[MT_NUM_BUCKETS];
unsigned __int16 head[MT_NODE_BITS + 1];
};
ASSERT_STRUCT_SIZE(scrMemTreeGlob_t, 0xC0380);
ASSERT_STRUCT_OFFSET(scrMemTreeGlob_t, nodes, 0x0);
@@ -755,8 +791,6 @@ namespace game
ASSERT_STRUCT_OFFSET(scrMemTreeGlob_t, numBits, 0xC0100);
ASSERT_STRUCT_OFFSET(scrMemTreeGlob_t, logBits, 0xC0200);
ASSERT_STRUCT_OFFSET(scrMemTreeGlob_t, head, 0xC0300);
ASSERT_STRUCT_OFFSET(scrMemTreeGlob_t, gap_C0322, 0xC0322);
ASSERT_STRUCT_OFFSET(scrMemTreeGlob_t, field_C037F, 0xC037F);
struct OpcodeLookup
{
@@ -2192,7 +2226,7 @@ namespace game
struct yy_buffer_state
{
_iobuf * yy_input_file; //OFS: 0x0 SIZE: 0x4
FILE * yy_input_file; //OFS: 0x0 SIZE: 0x4
char * yy_ch_buf; //OFS: 0x4 SIZE: 0x4
char * yy_buf_pos; //OFS: 0x8 SIZE: 0x4
unsigned int yy_buf_size; //OFS: 0xC SIZE: 0x4
@@ -2253,6 +2287,8 @@ namespace game
WEAK symbol<bool> loadedImpureScript{ 0x0, 0x22C1352 };
WEAK symbol<dvar_s*> sv_clientside{ 0x0, 0x3882B6C };
WEAK symbol<char> error_message_buff{ 0x0, 0x3BE1E30 };
WEAK symbol<scrCompileGlob_t> gScrCompileGlob{ 0x0, 0x3701FE0 };
WEAK symbol<scrAnimGlob_t> gScrAnimGlob{ 0x0, 0x36BF320 };
WEAK symbol<unsigned char> g_parse_user{ 0x0, 0x234F72E };
WEAK symbol<scriptInstance_t> gInst{ 0x0, 0x3BE624C };
@@ -2264,12 +2300,12 @@ namespace game
WEAK symbol<sval_u> g_dummyVal{ 0x0, 0x3BE6254 };
WEAK symbol<int> yy_init{ 0x0, 0x8CF4A0 };
WEAK symbol<int> yy_start{ 0x0, 0x46E54D4 };
WEAK symbol<_iobuf*> yyin{ 0x0, 0x46E54D8 };
WEAK symbol<_iobuf*> yyout{ 0x0, 0x46E54DC };
WEAK symbol<FILE*> yyin{ 0x0, 0x46E54D8 };
WEAK symbol<FILE*> yyout{ 0x0, 0x46E54DC };
WEAK symbol<yy_buffer_state*> yy_current_buffer{ 0x0, 0x46E54CC };
WEAK symbol<int> yy_n_chars{ 0x0, 0x3BE6250 };
WEAK symbol<char> yy_hold_char{ 0x0, 0x22C1353 };
WEAK symbol<int> yy_c_buf_p{ 0x0, 0x46E54D0 };
WEAK symbol<char*> yy_c_buf_p{ 0x0, 0x46E54D0 };
WEAK symbol<int> yy_last_accepting_state{ 0x0, 0x3BE626C };
WEAK symbol<char*> yy_last_accepting_cpos{ 0x0, 0x3BE2230 };
WEAK symbol<size_t> yyleng{ 0x0, 0x3BE6248 };
@@ -2290,21 +2326,15 @@ namespace game
WEAK symbol<short> yy_base{ 0x0, 0x831120 };
WEAK symbol<short> yy_def{ 0x0, 0x831338 };
WEAK symbol<short> yy_nxt{ 0x0, 0x831550 };
WEAK symbol<unsigned char> yy_meta{ 0x0, 0x831030 };
WEAK symbol<int> yy_meta{ 0x0, 0x831030 };
WEAK symbol<short> yypgoto{ 0x0, 0x82F426 };
WEAK symbol<short> yydefgoto{ 0x0, 0x82F1DE };
#pragma endregion
#pragma region "functions"
WEAK symbol<void(scriptInstance_t inst, VariableValue* value)>RemoveRefToValue{ 0x0, 0x67EB70 };
WEAK symbol<int(jmp_buf buf, int count)>_setjmp3{ 0x0, 0x7E1894 };
WEAK symbol<void(jmp_buf Buf, int Value)>longjmp{ 0x0, 0x7AD57C };
inline void* ScriptParse_ADDR() { return CALL_ADDR(0x0, 0x69D710); }
void ScriptParse(scriptInstance_t inst, sval_u* parseData, void* call_addr = ScriptParse_ADDR());
inline void* ScriptCompile_ADDR() { return CALL_ADDR(0x0, 0x688E70); }
void ScriptCompile(scriptInstance_t inst, sval_u val, unsigned int filePosId, unsigned int fileCountId, unsigned int scriptId, PrecacheEntry * entries, int entriesCount, void* call_addr = ScriptCompile_ADDR());
inline void* Scr_LoadAnimTreeAtIndex_ADDR() { return CALL_ADDR(0x0, 0x67E7D0); }
void Scr_LoadAnimTreeAtIndex(scriptInstance_t inst, int user, unsigned int index, void* (__cdecl* Alloc)(int), int modCheckSum, void* call_addr = Scr_LoadAnimTreeAtIndex_ADDR());
inline void* CScr_SetEntityField_ADDR() { return CALL_ADDR(0x0, 0x671470); }
int CScr_SetEntityField(int ofs, int entnum, unsigned int clientnum, void* call_addr = CScr_SetEntityField_ADDR());
inline void* Scr_SetObjectField_ADDR() { return CALL_ADDR(0x0, 0x5469C0); }
@@ -2325,4 +2355,7 @@ namespace game
#include "cscr_tempmemory.hpp"
#include "cscr_variable.hpp"
#include "cscr_vm.hpp"
#include "cscr_compiler.hpp"
#include "cscr_yacc.hpp"
#include "cscr_animtree.hpp"
#endif
@@ -2,50 +2,6 @@
namespace game
{
// void __usercall ScriptParse(scriptInstance_t a1@<eax>, sval_u *parseData)
void ScriptParse(scriptInstance_t inst, sval_u* parseData, void* call_addr)
{
__asm
{
push parseData;
mov eax, inst;
call call_addr;
add esp, 0x4;
}
}
// void __usercall ScriptCompile(scriptInstance_t inst@<eax>, sval_u a2, unsigned int filePosId, unsigned int fileCountId, unsigned int scriptId, PrecacheEntry *entries, int entriesCount)
void ScriptCompile(scriptInstance_t inst, sval_u val, unsigned int filePosId, unsigned int fileCountId, unsigned int scriptId, PrecacheEntry * entries, int entriesCount, void* call_addr)
{
__asm
{
push entriesCount;
push entries;
push scriptId;
push fileCountId;
push filePosId;
push val;
mov eax, inst;
call call_addr;
add esp, 0x18;
}
}
// void __usercall Scr_LoadAnimTreeAtIndex(scriptInstance_t inst@<ecx>, int a2@<eax>, int a3, int (__cdecl *a4)(int), int a5)
void Scr_LoadAnimTreeAtIndex(scriptInstance_t inst, int user, unsigned int index, void* (__cdecl* Alloc)(int), int modCheckSum, void* call_addr)
{
__asm
{
push modCheckSum;
push Alloc;
push index;
mov eax, user;
mov ecx, inst;
call call_addr;
add esp, 0xC;
}
}
int CScr_SetEntityField/*@<eax>*/(int ofs/*@<edx>*/, int entnum/*@<ecx>*/, unsigned int clientnum, void* call_addr)
{
int answer;
+35
View File
@@ -0,0 +1,35 @@
#pragma once
namespace game
{
WEAK symbol<void(scriptInstance_t inst, const char * errorMsg)>AnimTreeCompileError{ 0x0, 0x67D4B0};
WEAK symbol<int(scriptInstance_t inst)>GetAnimTreeParseProperties{ 0x0, 0x67D510};
WEAK symbol<char(scriptInstance_t inst, int parentId, int names, int bIncludeParent, int bLoop, int bComplete)>AnimTreeParseInternal{ 0x0, 0x67D770};
WEAK symbol<int(scriptInstance_t inst, unsigned int parentNode)>Scr_GetAnimTreeSize{ 0x0, 0x67DE20};
WEAK symbol<int(scriptInstance_t inst, unsigned int parentNode, unsigned int rootData, XAnim_s* animtree, unsigned int childIndex, const char* name, unsigned int parentIndex, unsigned int filename, int treeIndex, int flags)>Scr_CreateAnimationTree{ 0x0, 0x67DFB0};
WEAK symbol<void(scriptInstance_t inst, unsigned int parentNode)>Scr_PrecacheAnimationTree{ 0x0, 0x67E360};
WEAK symbol<void(const char * animtreeName)>Scr_SetAnimTreeConfigstring{ 0x0, 0x67E670};
inline void* Scr_EmitAnimationInternal_ADDR() { return CALL_ADDR(0x0, 0x67D6B0); }
void Scr_EmitAnimationInternal(scriptInstance_t inst, const char * pos, unsigned int animName, unsigned int names, void* call_addr = Scr_EmitAnimationInternal_ADDR());
inline void* Scr_AnimTreeParse_ADDR() { return CALL_ADDR(0x0, 0x67DDA0); }
void Scr_AnimTreeParse(scriptInstance_t inst, const char * pos, unsigned int parentNode, unsigned int names, void* call_addr = Scr_AnimTreeParse_ADDR());
inline void* ConnectScriptToAnim_ADDR() { return CALL_ADDR(0x0, 0x67DEC0); }
void ConnectScriptToAnim(unsigned int name, unsigned int names, scriptInstance_t inst, int index, unsigned int filename, int treeIndex, void* call_addr = ConnectScriptToAnim_ADDR());
inline void* Scr_GetAnimsIndex_ADDR() { return CALL_ADDR(0x0, 0x67DF90); }
int Scr_GetAnimsIndex(XAnim_s * anim, void* call_addr = Scr_GetAnimsIndex_ADDR());
inline void* Scr_CheckAnimsDefined_ADDR() { return CALL_ADDR(0x0, 0x67E260); }
void Scr_CheckAnimsDefined(unsigned int names, scriptInstance_t a2, unsigned int filename, void* call_addr = Scr_CheckAnimsDefined_ADDR());
inline void* Scr_UsingTreeInternal_ADDR() { return CALL_ADDR(0x0, 0x67E420); }
unsigned int Scr_UsingTreeInternal(const char * filename, int user, scriptInstance_t inst, unsigned int * index, void* call_addr = Scr_UsingTreeInternal_ADDR());
inline void* Scr_UsingTree_ADDR() { return CALL_ADDR(0x0, 0x67E5F0); }
void Scr_UsingTree(scriptInstance_t a1, const char * filename, unsigned int sourcePos, void* call_addr = Scr_UsingTree_ADDR());
inline void* Scr_LoadAnimTreeInternal_ADDR() { return CALL_ADDR(0x0, 0x67E710); }
bool Scr_LoadAnimTreeInternal(const char * animtreeName, scriptInstance_t inst, unsigned int parentNode, unsigned int names, void* call_addr = Scr_LoadAnimTreeInternal_ADDR());
inline void* Scr_LoadAnimTreeAtIndex_ADDR() { return CALL_ADDR(0x0, 0x67E7D0); }
void Scr_LoadAnimTreeAtIndex(scriptInstance_t inst, int user, unsigned int index, void *(__cdecl * Alloc)(int), int modCheckSum, void* call_addr = Scr_LoadAnimTreeAtIndex_ADDR());
inline void* Scr_FindAnimTree_ADDR() { return CALL_ADDR(0x0, 0x67EA70); }
scr_animtree_t Scr_FindAnimTree(const char * filename, void* call_addr = Scr_FindAnimTree_ADDR());
inline void* Scr_FindAnim_ADDR() { return CALL_ADDR(0x0, 0x67EB10); }
void Scr_FindAnim(const char * animName, scr_anim_s a2, int user, void* call_addr = Scr_FindAnim_ADDR());
}
+172
View File
@@ -0,0 +1,172 @@
#include <stdinc.hpp>
//#include "codsrc/clientscript/cscr_animtree.hpp"
namespace game
{
// void __usercall Scr_EmitAnimationInternal(scriptInstance_t inst@<edi>, const char *pos, unsigned int animName, unsigned int names)
void Scr_EmitAnimationInternal(scriptInstance_t inst, const char * pos, unsigned int animName, unsigned int names, void* call_addr)
{
__asm
{
push names;
push animName;
push pos;
mov edi, inst;
call call_addr;
add esp, 0xC;
}
}
// void __usercall Scr_AnimTreeParse(scriptInstance_t inst@<eax>, const char *pos@<edi>, unsigned int parentNode, unsigned int names)
void Scr_AnimTreeParse(scriptInstance_t inst, const char * pos, unsigned int parentNode, unsigned int names, void* call_addr)
{
__asm
{
push names;
push parentNode;
mov eax, inst;
mov edi, pos;
call call_addr;
add esp, 0x8;
}
}
// void __usercall ConnectScriptToAnim(unsigned int name@<eax>, unsigned int names@<edi>, scriptInstance_t inst, int index, unsigned int filename, int treeIndex)
void ConnectScriptToAnim(unsigned int name, unsigned int names, scriptInstance_t inst, int index, unsigned int filename, int treeIndex, void* call_addr)
{
__asm
{
push treeIndex;
push filename;
push index;
push inst;
mov eax, name;
mov edi, names;
call call_addr;
add esp, 0x10;
}
}
// int __usercall Scr_GetAnimsIndex@<eax>(XAnim_s *anim@<ecx>)
int Scr_GetAnimsIndex(XAnim_s * anim, void* call_addr)
{
int answer;
__asm
{
mov ecx, anim;
call call_addr;
mov answer, eax;
}
return answer;
}
// void __usercall Scr_CheckAnimsDefined(unsigned int names@<eax>, scriptInstance_t a2@<ecx>, unsigned int filename)
void Scr_CheckAnimsDefined(unsigned int names, scriptInstance_t a2, unsigned int filename, void* call_addr)
{
__asm
{
push filename;
mov eax, names;
mov ecx, a2;
call call_addr;
add esp, 0x4;
}
}
// unsigned int __usercall Scr_UsingTreeInternal@<eax>(const char *filename@<eax>, int user@<ecx>, scriptInstance_t inst, unsigned int *index)
unsigned int Scr_UsingTreeInternal(const char * filename, int user, scriptInstance_t inst, unsigned int * index, void* call_addr)
{
unsigned int answer;
__asm
{
push index;
push inst;
mov eax, filename;
mov ecx, user;
call call_addr;
mov answer, eax;
add esp, 0x8;
}
return answer;
}
// void __usercall Scr_UsingTree(scriptInstance_t a1@<edi>, const char *filename, unsigned int sourcePos)
void Scr_UsingTree(scriptInstance_t a1, const char * filename, unsigned int sourcePos, void* call_addr)
{
__asm
{
push sourcePos;
push filename;
mov edi, a1;
call call_addr;
add esp, 0x8;
}
}
// bool __usercall Scr_LoadAnimTreeInternal@<al>(const char *animtreeName@<eax>, scriptInstance_t inst@<ecx>, unsigned int parentNode, unsigned int names)
bool Scr_LoadAnimTreeInternal(const char * animtreeName, scriptInstance_t inst, unsigned int parentNode, unsigned int names, void* call_addr)
{
bool answer;
__asm
{
push names;
push parentNode;
mov eax, animtreeName;
mov ecx, inst;
call call_addr;
mov answer, al;
add esp, 0x8;
}
return answer;
}
// void __usercall Scr_LoadAnimTreeAtIndex(scriptInstance_t inst@<ecx>, int a2@<eax>, int a3, int (__cdecl *a4)(int), int a5)
void Scr_LoadAnimTreeAtIndex(scriptInstance_t inst, int user, unsigned int index, void* (__cdecl* Alloc)(int), int modCheckSum, void* call_addr)
{
__asm
{
push modCheckSum;
push Alloc;
push index;
mov eax, user;
mov ecx, inst;
call call_addr;
add esp, 0xC;
}
}
// XAnim_s *__usercall Scr_FindAnimTree@<eax>(const char *filename@<eax>)
scr_animtree_t Scr_FindAnimTree(const char * filename, void* call_addr)
{
scr_animtree_t answer;
__asm
{
mov eax, filename;
call call_addr;
mov answer, eax;
}
return answer;
}
// void __usercall Scr_FindAnim(const char *animName@<edx>, scr_anim_s a2, int user)
void Scr_FindAnim(const char * animName, scr_anim_s a2, int user, void* call_addr)
{
__asm
{
push user;
push a2;
mov edx, animName;
call call_addr;
add esp, 0x8;
}
}
}
+312
View File
@@ -0,0 +1,312 @@
#pragma once
namespace game
{
WEAK symbol<void(scriptInstance_t inst, VariableValue* value)>RemoveRefToValue{ 0x0, 0x67EB70 };
WEAK symbol<void(scriptInstance_t inst, OpcodeVM op, int offset, int callType)>EmitOpcode{ 0x0, 0x67ECA0 };
WEAK symbol<int(scriptInstance_t inst, unsigned int name, sval_u sourcePos, int create, scr_block_s* block)>Scr_FindLocalVarIndex{ 0x0, 0x67F500 };
WEAK symbol<void(scriptInstance_t inst, scr_block_s* block)>EmitCreateLocalVars{ 0x0, 0x67F730 };
WEAK symbol<void(scr_block_s** childBlocks, int childCount, scr_block_s* block)>Scr_InitFromChildBlocks{ 0x0, 0x67FA00 };
WEAK symbol<void(scr_block_s** childBlocks, int childCount, scr_block_s* block)>Scr_MergeChildBlocks{ 0x0, 0x67FB80 };
WEAK symbol<void(scriptInstance_t inst, VariableCompileValue* constValue)>EmitValue{ 0x0, 0x680050 };
WEAK symbol<void(unsigned int name, sval_u sourcePos, scr_block_s* block)>Scr_RegisterLocalVar{ 0x0, 0x680D10 };
WEAK symbol<void(scriptInstance_t inst, sval_u sourcePos)>EmitCastFieldObject{ 0x0, 0x681720 };
WEAK symbol<void(scriptInstance_t inst, sval_u expr, scr_block_s* block)>EmitVariableExpression{ 0x0, 0x681990 };
WEAK symbol<int(scriptInstance_t inst, sval_u exprlist, scr_block_s* block)>EmitExpressionList{ 0x0, 0x681AD0 };
WEAK symbol<int(scriptInstance_t inst, int func)>AddFunction{ 0x0, 0x682040 };
WEAK symbol<void(scriptInstance_t inst, sval_u func, int param_count, int bMethod, sval_u nameSourcePos)>EmitPostScriptFunction{ 0x0, 0x6820B0 };
WEAK symbol<void(scriptInstance_t inst, sval_u expr, sval_u func_name, sval_u params, sval_u methodSourcePos, int bStatement, scr_block_s* block)>EmitMethod{ 0x0, 0x682F40 };
WEAK symbol<void(scriptInstance_t inst, unsigned int posId, unsigned int name, unsigned int sourcePos)>CheckThreadPosition{ 0x0, 0x683580 };
WEAK symbol<bool(scriptInstance_t inst, sval_u exprlist, sval_u sourcePos, VariableCompileValue* constValue)>EvalPrimitiveExpressionList{ 0x0, 0x6837C0 };
WEAK symbol<bool(scriptInstance_t inst, sval_u expr, VariableCompileValue* constValue)>EvalPrimitiveExpression{ 0x0, 0x683B50 };
WEAK symbol<bool(scriptInstance_t inst, sval_u expr, VariableCompileValue* constValue, scr_block_s* block)>EmitOrEvalPrimitiveExpression{ 0x0, 0x683CF0 };
WEAK symbol<bool(scriptInstance_t inst, sval_u expr1, sval_u expr2, sval_u opcode, sval_u sourcePos, VariableCompileValue* constValue)>EvalBinaryOperatorExpression{ 0x0, 0x684220 };
WEAK symbol<bool(scriptInstance_t inst, sval_u expr, VariableCompileValue* constValue, scr_block_s* block)>EmitOrEvalExpression{ 0x0, 0x684590 };
WEAK symbol<void(scriptInstance_t inst, sval_u expr, scr_block_s* block)>EmitExpression{ 0x0, 0x684750 };
WEAK symbol<void(sval_u expr, scr_block_s* block)>Scr_CalcLocalVarsArrayVariableRef{ 0x0, 0x684950 };
WEAK symbol<void(scriptInstance_t inst, sval_u expr, sval_u sourcePos, scr_block_s* block)>EmitPrimitiveExpressionFieldObject{ 0x0, 0x6849A0 };
WEAK symbol<void(scriptInstance_t inst, sval_u stmt, scr_block_s* block, sval_u* ifStatBlock)>Scr_CalcLocalVarsIfStatement{ 0x0, 0x685170 };
WEAK symbol<void(scriptInstance_t inst, sval_u expr, sval_u stmt1, sval_u stmt2, sval_u sourcePos, sval_u elseSourcePos, int lastStatement, unsigned int endSourcePos, scr_block_s* block, sval_u* ifStatBlock, sval_u* elseStatBlock)>EmitIfElseStatement{ 0x0, 0x6851D0 };
WEAK symbol<void(scriptInstance_t inst, sval_u stmt1, sval_u stmt2, scr_block_s* block, sval_u* ifStatBlock, sval_u* elseStatBlock)>Scr_CalcLocalVarsIfElseStatement{ 0x0, 0x685590 };
WEAK symbol<void(scriptInstance_t inst, sval_u expr, sval_u stmt, sval_u sourcePos, sval_u whileSourcePos, scr_block_s* block, sval_u* whileStatBlock)>EmitWhileStatement{ 0x0, 0x685760 };
WEAK symbol<void(scriptInstance_t inst, sval_u expr, sval_u stmt, scr_block_s* block, sval_u* whileStatBlock)>Scr_CalcLocalVarsWhileStatement{ 0x0, 0x685C30 };
WEAK symbol<void(scriptInstance_t inst, sval_u stmt1, sval_u expr, sval_u stmt2, sval_u stmt, sval_u sourcePos, sval_u forSourcePos, scr_block_s* block, sval_u* forStatBlock, sval_u* forStatPostBlock)>EmitForStatement{ 0x0, 0x685DF0 };
WEAK symbol<void(scriptInstance_t inst, sval_u stmt1, sval_u expr, sval_u stmt2, sval_u stmt, scr_block_s* block, sval_u* forStatBlock, sval_u* forStatPostBlock)>Scr_CalcLocalVarsForStatement{ 0x0, 0x686330 };
WEAK symbol<int(const void* elem1, const void* elem2)>CompareCaseInfo{ 0x0, 0x6870E0 };
WEAK symbol<void(scriptInstance_t inst, sval_u val, int lastStatement, unsigned int endSourcePos, scr_block_s* block)>EmitSwitchStatementList{ 0x0, 0x6871A0 };
WEAK symbol<void(scriptInstance_t inst, sval_u stmtlist, scr_block_s* block)>Scr_CalcLocalVarsSwitchStatement{ 0x0, 0x6873D0 };
WEAK symbol<void(scriptInstance_t inst, sval_u expr, sval_u stmtlist, sval_u sourcePos, int lastStatement, unsigned int endSourcePos, scr_block_s* block)>EmitSwitchStatement{ 0x0, 0x6875F0 };
WEAK symbol<void(scriptInstance_t inst, sval_u val, int lastStatement, unsigned int endSourcePos, scr_block_s* block)>EmitStatement{ 0x0, 0x687DB0 };
WEAK symbol<void(scriptInstance_t inst, sval_u val, scr_block_s* block)>Scr_CalcLocalVarsStatement{ 0x0, 0x688210 };
WEAK symbol<void(scriptInstance_t inst, sval_u val, int lastStatement, unsigned int endSourcePos, scr_block_s* block)>EmitStatementList{ 0x0, 0x688470 };
WEAK symbol<void(scriptInstance_t inst, sval_u val, scr_block_s* block, sval_u* devStatBlock)>Scr_CalcLocalVarsDeveloperStatementList{ 0x0, 0x688530 };
WEAK symbol<void(scriptInstance_t inst, sval_u val, sval_u sourcePos, scr_block_s* block, sval_u* devStatBlock)>EmitDeveloperStatementList{ 0x0, 0x6885A0 };
WEAK symbol<void(scriptInstance_t inst, sval_u val)>EmitThreadList{ 0x0, 0x688D40 };
WEAK symbol<void(scriptInstance_t inst, sval_u expr, scr_block_s* block)>EmitVariableExpressionRef{ 0x0, 0x684790 };
inline void* Scr_CompileRemoveRefToString_ADDR() { return CALL_ADDR(0x0, 0x67EB90); }
void Scr_CompileRemoveRefToString(scriptInstance_t inst, unsigned int stringVal, void* call_addr = Scr_CompileRemoveRefToString_ADDR());
inline void* EmitCanonicalString_ADDR() { return CALL_ADDR(0x0, 0x67EBB0); }
void EmitCanonicalString(scriptInstance_t inst, unsigned int stringVal, void* call_addr = EmitCanonicalString_ADDR());
inline void* CompileTransferRefToString_ADDR() { return CALL_ADDR(0x0, 0x67EC30); }
void CompileTransferRefToString(unsigned int stringValue, scriptInstance_t inst, unsigned int user, void* call_addr = CompileTransferRefToString_ADDR());
inline void* EmitEnd_ADDR() { return CALL_ADDR(0x0, 0x67F0C0); }
void EmitEnd(scriptInstance_t inst, void* call_addr = EmitEnd_ADDR());
inline void* EmitReturn_ADDR() { return CALL_ADDR(0x0, 0x67F1A0); }
void EmitReturn(scriptInstance_t inst, void* call_addr = EmitReturn_ADDR());
inline void* EmitCodepos_ADDR() { return CALL_ADDR(0x0, 0x67F290); }
void EmitCodepos(scriptInstance_t inst, int codepos, void* call_addr = EmitCodepos_ADDR());
inline void* EmitShort_ADDR() { return CALL_ADDR(0x0, 0x67F2C0); }
void EmitShort(scriptInstance_t inst, int value, void* call_addr = EmitShort_ADDR());
inline void* EmitByte_ADDR() { return CALL_ADDR(0x0, 0x67F2F0); }
void EmitByte(scriptInstance_t inst, int value, void* call_addr = EmitByte_ADDR());
inline void* EmitGetInteger_ADDR() { return CALL_ADDR(0x0, 0x67F320); }
void EmitGetInteger(scriptInstance_t inst, int value, sval_u sourcePos, void* call_addr = EmitGetInteger_ADDR());
inline void* EmitGetFloat_ADDR() { return CALL_ADDR(0x0, 0x67F470); }
void EmitGetFloat(scriptInstance_t inst, float value, sval_u sourcePos, void* call_addr = EmitGetFloat_ADDR());
inline void* EmitAnimTree_ADDR() { return CALL_ADDR(0x0, 0x67F4C0); }
void EmitAnimTree(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitAnimTree_ADDR());
inline void* EmitRemoveLocalVars_ADDR() { return CALL_ADDR(0x0, 0x67F880); }
void EmitRemoveLocalVars(scriptInstance_t inst, scr_block_s* outerBlock, scr_block_s* block, void* call_addr = EmitRemoveLocalVars_ADDR());
inline void* EmitNOP2_ADDR() { return CALL_ADDR(0x0, 0x67F9A0); }
void EmitNOP2(scr_block_s* block, scriptInstance_t inst, int lastStatement, unsigned int endSourcePos, void* call_addr = EmitNOP2_ADDR());
inline void* Scr_AppendChildBlocks_ADDR() { return CALL_ADDR(0x0, 0x67FAA0); }
void Scr_AppendChildBlocks(scr_block_s* block, scr_block_s** childBlocks, int childCount, void* call_addr = Scr_AppendChildBlocks_ADDR());
inline void* Scr_TransferBlock_ADDR() { return CALL_ADDR(0x0, 0x67FC60); }
void Scr_TransferBlock(scr_block_s* to, scr_block_s* from, void* call_addr = Scr_TransferBlock_ADDR());
inline void* EmitSafeSetVariableField_ADDR() { return CALL_ADDR(0x0, 0x67FD50); }
void EmitSafeSetVariableField(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u sourcePos, void* call_addr = EmitSafeSetVariableField_ADDR());
inline void* EmitSafeSetWaittillVariableField_ADDR() { return CALL_ADDR(0x0, 0x67FDC0); }
void EmitSafeSetWaittillVariableField(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u sourcePos, void* call_addr = EmitSafeSetWaittillVariableField_ADDR());
inline void* EmitGetString_ADDR() { return CALL_ADDR(0x0, 0x67FEE0); }
void EmitGetString(unsigned int value, scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitGetString_ADDR());
inline void* EmitGetIString_ADDR() { return CALL_ADDR(0x0, 0x67FF30); }
void EmitGetIString(unsigned int value, scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitGetIString_ADDR());
inline void* EmitGetVector_ADDR() { return CALL_ADDR(0x0, 0x67FF80); }
void EmitGetVector(const float* value, scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitGetVector_ADDR());
inline void* Scr_PushValue_ADDR() { return CALL_ADDR(0x0, 0x680120); }
void Scr_PushValue(scriptInstance_t inst, VariableCompileValue* constValue, void* call_addr = Scr_PushValue_ADDR());
inline void* EmitCastBool_ADDR() { return CALL_ADDR(0x0, 0x680180); }
void EmitCastBool(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitCastBool_ADDR());
inline void* EmitBoolNot_ADDR() { return CALL_ADDR(0x0, 0x680270); }
void EmitBoolNot(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitBoolNot_ADDR());
inline void* EmitBoolComplement_ADDR() { return CALL_ADDR(0x0, 0x680360); }
void EmitBoolComplement(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitBoolComplement_ADDR());
inline void* EmitSize_ADDR() { return CALL_ADDR(0x0, 0x680450); }
void EmitSize(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u sourcePos, void* call_addr = EmitSize_ADDR());
inline void* EmitSelf_ADDR() { return CALL_ADDR(0x0, 0x680560); }
void EmitSelf(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitSelf_ADDR());
inline void* EmitLevel_ADDR() { return CALL_ADDR(0x0, 0x680660); }
void EmitLevel(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitLevel_ADDR());
inline void* EmitGame_ADDR() { return CALL_ADDR(0x0, 0x680760); }
void EmitGame(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitGame_ADDR());
inline void* EmitAnim_ADDR() { return CALL_ADDR(0x0, 0x680860); }
void EmitAnim(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitAnim_ADDR());
inline void* EmitSelfObject_ADDR() { return CALL_ADDR(0x0, 0x680960); }
void EmitSelfObject(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitSelfObject_ADDR());
inline void* EmitLevelObject_ADDR() { return CALL_ADDR(0x0, 0x680A50); }
void EmitLevelObject(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitLevelObject_ADDR());
inline void* EmitAnimObject_ADDR() { return CALL_ADDR(0x0, 0x680B40); }
void EmitAnimObject(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitAnimObject_ADDR());
inline void* EmitLocalVariable_ADDR() { return CALL_ADDR(0x0, 0x680C30); }
void EmitLocalVariable(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u sourcePos, void* call_addr = EmitLocalVariable_ADDR());
inline void* EmitLocalVariableRef_ADDR() { return CALL_ADDR(0x0, 0x680CA0); }
void EmitLocalVariableRef(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u sourcePos, void* call_addr = EmitLocalVariableRef_ADDR());
inline void* EmitGameRef_ADDR() { return CALL_ADDR(0x0, 0x680D60); }
void EmitGameRef(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitGameRef_ADDR());
inline void* EmitClearArray_ADDR() { return CALL_ADDR(0x0, 0x680E50); }
void EmitClearArray(scriptInstance_t inst, sval_u sourcePos, sval_u indexSourcePos, void* call_addr = EmitClearArray_ADDR());
inline void* EmitEmptyArray_ADDR() { return CALL_ADDR(0x0, 0x680F50); }
void EmitEmptyArray(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitEmptyArray_ADDR());
inline void* EmitAnimation_ADDR() { return CALL_ADDR(0x0, 0x681050); }
void EmitAnimation(scriptInstance_t inst, sval_u anim, sval_u sourcePos, void* call_addr = EmitAnimation_ADDR());
inline void* EmitFieldVariable_ADDR() { return CALL_ADDR(0x0, 0x6811C0); }
void EmitFieldVariable(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u field, sval_u sourcePos, void* call_addr = EmitFieldVariable_ADDR());
inline void* EmitClearFieldVariable_ADDR() { return CALL_ADDR(0x0, 0x681200); }
void EmitClearFieldVariable(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u field, sval_u sourcePos, sval_u rhsSourcePos, void* call_addr = EmitClearFieldVariable_ADDR());
inline void* EmitObject_ADDR() { return CALL_ADDR(0x0, 0x681310); }
void EmitObject(scriptInstance_t inst, sval_u expr, sval_u sourcePos, void* call_addr = EmitObject_ADDR());
inline void* EmitDecTop_ADDR() { return CALL_ADDR(0x0, 0x681630); }
void EmitDecTop(scriptInstance_t inst, void* call_addr = EmitDecTop_ADDR());
inline void* EmitArrayVariable_ADDR() { return CALL_ADDR(0x0, 0x681840); }
void EmitArrayVariable(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u index, sval_u sourcePos, sval_u indexSourcePos, void* call_addr = EmitArrayVariable_ADDR());
inline void* EmitArrayVariableRef_ADDR() { return CALL_ADDR(0x0, 0x6818C0); }
void EmitArrayVariableRef(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u index, sval_u sourcePos, sval_u indexSourcePos, void* call_addr = EmitArrayVariableRef_ADDR());
inline void* EmitClearArrayVariable_ADDR() { return CALL_ADDR(0x0, 0x681930); }
void EmitClearArrayVariable(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u index, sval_u sourcePos, sval_u indexSourcePos, void* call_addr = EmitClearArrayVariable_ADDR());
inline void* AddExpressionListOpcodePos_ADDR() { return CALL_ADDR(0x0, 0x681B30); }
void AddExpressionListOpcodePos(scriptInstance_t inst, sval_u exprlist, void* call_addr = AddExpressionListOpcodePos_ADDR());
inline void* AddFilePrecache_ADDR() { return CALL_ADDR(0x0, 0x681B70); }
void AddFilePrecache(scriptInstance_t inst, unsigned int filename, unsigned int sourcePos, int include, unsigned int* filePosId, unsigned int* fileCountId, void* call_addr = AddFilePrecache_ADDR());
inline void* EmitFunction_ADDR() { return CALL_ADDR(0x0, 0x681C30); }
void EmitFunction(scriptInstance_t inst, sval_u func, sval_u sourcePos, void* call_addr = EmitFunction_ADDR());
inline void* EmitGetFunction_ADDR() { return CALL_ADDR(0x0, 0x681F30); }
void EmitGetFunction(scriptInstance_t inst, sval_u func, sval_u sourcePos, void* call_addr = EmitGetFunction_ADDR());
inline void* EmitPostScriptFunctionPointer_ADDR() { return CALL_ADDR(0x0, 0x6822F0); }
void EmitPostScriptFunctionPointer(scr_block_s* block, scriptInstance_t inst, sval_u expr, int param_count, int bMethod, sval_u nameSourcePos, sval_u sourcePos, void* call_addr = EmitPostScriptFunctionPointer_ADDR());
inline void* EmitPostScriptThread_ADDR() { return CALL_ADDR(0x0, 0x682500); }
void EmitPostScriptThread(scriptInstance_t inst, sval_u func, int param_count, int bMethod, sval_u sourcePos, void* call_addr = EmitPostScriptThread_ADDR());
inline void* EmitPostScriptThreadPointer_ADDR() { return CALL_ADDR(0x0, 0x682730); }
void EmitPostScriptThreadPointer(scr_block_s* block, scriptInstance_t inst, sval_u expr, int param_count, int bMethod, sval_u sourcePos, void* call_addr = EmitPostScriptThreadPointer_ADDR());
inline void* EmitPostScriptFunctionCall_ADDR() { return CALL_ADDR(0x0, 0x682950); }
void EmitPostScriptFunctionCall(scriptInstance_t inst, int bMethod, int param_count, sval_u func_name, sval_u nameSourcePos, scr_block_s* block, void* call_addr = EmitPostScriptFunctionCall_ADDR());
inline void* EmitPostScriptThreadCall_ADDR() { return CALL_ADDR(0x0, 0x6829A0); }
void EmitPostScriptThreadCall(scriptInstance_t inst, int isMethod, int param_count, sval_u func_name, sval_u sourcePos, sval_u nameSourcePos, scr_block_s* block, void* call_addr = EmitPostScriptThreadCall_ADDR());
inline void* EmitPreFunctionCall_ADDR() { return CALL_ADDR(0x0, 0x6829F0); }
void EmitPreFunctionCall(scriptInstance_t inst, void* call_addr = EmitPreFunctionCall_ADDR());
inline void* EmitPostFunctionCall_ADDR() { return CALL_ADDR(0x0, 0x682AE0); }
void EmitPostFunctionCall(scriptInstance_t inst, int bMethod, sval_u func_name, int param_count, scr_block_s* block, void* call_addr = EmitPostFunctionCall_ADDR());
inline void* Scr_BeginDevScript_ADDR() { return CALL_ADDR(0x0, 0x682B30); }
void Scr_BeginDevScript(scriptInstance_t isnt, int* type_, char** savedPos, void* call_addr = Scr_BeginDevScript_ADDR());
inline void* Scr_EndDevScript_ADDR() { return CALL_ADDR(0x0, 0x682BA0); }
void Scr_EndDevScript(scriptInstance_t inst, char** savedPos, void* call_addr = Scr_EndDevScript_ADDR());
inline void* EmitCallBuiltinOpcode_ADDR() { return CALL_ADDR(0x0, 0x682BD0); }
void EmitCallBuiltinOpcode(scriptInstance_t inst, int param_count, sval_u sourcePos, void* call_addr = EmitCallBuiltinOpcode_ADDR());
inline void* EmitCallBuiltinMethodOpcode_ADDR() { return CALL_ADDR(0x0, 0x682C40); }
void EmitCallBuiltinMethodOpcode(scriptInstance_t inst, int param_count, sval_u sourcePos, void* call_addr = EmitCallBuiltinMethodOpcode_ADDR());
inline void* EmitCall_ADDR() { return CALL_ADDR(0x0, 0x682CA0); }
void EmitCall(scriptInstance_t inst, sval_u func_name, sval_u params, int bStatement, scr_block_s* block, void* call_addr = EmitCall_ADDR());
inline void* LinkThread_ADDR() { return CALL_ADDR(0x0, 0x683250); }
void LinkThread(scriptInstance_t inst, unsigned int threadCountId, VariableValue* pos, int allowFarCall, void* call_addr = LinkThread_ADDR());
inline void* LinkFile_ADDR() { return CALL_ADDR(0x0, 0x6833F0); }
void LinkFile(scriptInstance_t inst, unsigned int filePosId, unsigned int fileCountId, void* call_addr = LinkFile_ADDR());
inline void* EmitCallExpression_ADDR() { return CALL_ADDR(0x0, 0x683640); }
void EmitCallExpression(scriptInstance_t inst, scr_block_s* block, sval_u expr, int bStatement, void* call_addr = EmitCallExpression_ADDR());
inline void* EmitCallExpressionFieldObject_ADDR() { return CALL_ADDR(0x0, 0x683690); }
void EmitCallExpressionFieldObject(scr_block_s* block, scriptInstance_t inst, sval_u expr, void* call_addr = EmitCallExpressionFieldObject_ADDR());
inline void* Scr_CreateVector_ADDR() { return CALL_ADDR(0x0, 0x6836F0); }
void Scr_CreateVector(scriptInstance_t inst, VariableCompileValue* constValue, VariableValue* value, void* call_addr = Scr_CreateVector_ADDR());
inline void* EmitOrEvalPrimitiveExpressionList_ADDR() { return CALL_ADDR(0x0, 0x6838D0); }
bool EmitOrEvalPrimitiveExpressionList(scriptInstance_t inst, sval_u exprlist, sval_u sourcePos, VariableCompileValue* constValue, scr_block_s* a5, void* call_addr = EmitOrEvalPrimitiveExpressionList_ADDR());
inline void* EmitExpressionListFieldObject_ADDR() { return CALL_ADDR(0x0, 0x683AF0); }
void EmitExpressionListFieldObject(scriptInstance_t inst, sval_u exprlist, sval_u sourcePos, scr_block_s* block, void* call_addr = EmitExpressionListFieldObject_ADDR());
inline void* EmitBoolOrExpression_ADDR() { return CALL_ADDR(0x0, 0x683F00); }
void EmitBoolOrExpression(scriptInstance_t inst, sval_u expr1, sval_u expr2, sval_u expr1sourcePos, sval_u expr2sourcePos, scr_block_s* block, void* call_addr = EmitBoolOrExpression_ADDR());
inline void* EmitBoolAndExpression_ADDR() { return CALL_ADDR(0x0, 0x684090); }
void EmitBoolAndExpression(scriptInstance_t inst, sval_u expr1, sval_u expr2, sval_u expr1sourcePos, sval_u expr2sourcePos, scr_block_s* a6, void* call_addr = EmitBoolAndExpression_ADDR());
inline void* EmitOrEvalBinaryOperatorExpression_ADDR() { return CALL_ADDR(0x0, 0x684350); }
bool EmitOrEvalBinaryOperatorExpression(scriptInstance_t inst, sval_u expr1, sval_u expr2, sval_u opcode, sval_u sourcePos, VariableCompileValue* constValue, scr_block_s* a8, void* call_addr = EmitOrEvalBinaryOperatorExpression_ADDR());
inline void* EmitBinaryEqualsOperatorExpression_ADDR() { return CALL_ADDR(0x0, 0x684460); }
void EmitBinaryEqualsOperatorExpression(scr_block_s* block, scriptInstance_t inst, sval_u lhs, sval_u rhs, sval_u opcode, sval_u sourcePos, void* call_addr = EmitBinaryEqualsOperatorExpression_ADDR());
inline void* Scr_CalcLocalVarsVariableExpressionRef_ADDR() { return CALL_ADDR(0x0, 0x684500); }
void Scr_CalcLocalVarsVariableExpressionRef(scr_block_s* block, sval_u expr, void* call_addr = Scr_CalcLocalVarsVariableExpressionRef_ADDR());
inline void* EvalExpression_ADDR() { return CALL_ADDR(0x0, 0x684540); }
bool EvalExpression(VariableCompileValue* constValue, scriptInstance_t inst, sval_u expr, void* call_addr = EvalExpression_ADDR());
inline void* EmitArrayPrimitiveExpressionRef_ADDR() { return CALL_ADDR(0x0, 0x684900); }
void EmitArrayPrimitiveExpressionRef(scriptInstance_t inst, sval_u expr, sval_u sourcePos, scr_block_s* block, void* call_addr = EmitArrayPrimitiveExpressionRef_ADDR());
inline void* ConnectBreakStatements_ADDR() { return CALL_ADDR(0x0, 0x684AC0); }
void ConnectBreakStatements(scriptInstance_t inst, void* call_addr = ConnectBreakStatements_ADDR());
inline void* ConnectContinueStatements_ADDR() { return CALL_ADDR(0x0, 0x684B00); }
void ConnectContinueStatements(scriptInstance_t inst, void* call_addr = ConnectContinueStatements_ADDR());
inline void* EmitClearVariableExpression_ADDR() { return CALL_ADDR(0x0, 0x684B40); }
bool EmitClearVariableExpression(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u rhsSourcePos, void* call_addr = EmitClearVariableExpression_ADDR());
inline void* EmitAssignmentStatement_ADDR() { return CALL_ADDR(0x0, 0x684C40); }
void EmitAssignmentStatement(scriptInstance_t inst, sval_u lhs, sval_u rhs, sval_u sourcePos, sval_u rhsSourcePos, scr_block_s* block, void* call_addr = EmitAssignmentStatement_ADDR());
inline void* EmitCallExpressionStatement_ADDR() { return CALL_ADDR(0x0, 0x684CD0); }
void EmitCallExpressionStatement(scriptInstance_t inst, scr_block_s* block, sval_u expr, void* call_addr = EmitCallExpressionStatement_ADDR());
inline void* EmitReturnStatement_ADDR() { return CALL_ADDR(0x0, 0x684D20); }
void EmitReturnStatement(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u sourcePos, void* call_addr = EmitReturnStatement_ADDR());
inline void* EmitWaitStatement_ADDR() { return CALL_ADDR(0x0, 0x684D80); }
void EmitWaitStatement(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u sourcePos, sval_u waitSourcePos, void* call_addr = EmitWaitStatement_ADDR());
inline void* EmitWaittillFrameEnd_ADDR() { return CALL_ADDR(0x0, 0x684EB0); }
void EmitWaittillFrameEnd(scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitWaittillFrameEnd_ADDR());
inline void* EmitIfStatement_ADDR() { return CALL_ADDR(0x0, 0x684FB0); }
void EmitIfStatement(scriptInstance_t inst, sval_u expr, sval_u stmt, sval_u sourcePos, int lastStatement, unsigned int endSourcePos, scr_block_s* block, sval_u* ifStatBlock, void* call_addr = EmitIfStatement_ADDR());
inline void* Scr_AddBreakBlock_ADDR() { return CALL_ADDR(0x0, 0x6856A0); }
void Scr_AddBreakBlock(scriptInstance_t inst, scr_block_s* block, void* call_addr = Scr_AddBreakBlock_ADDR());
inline void* Scr_AddContinueBlock_ADDR() { return CALL_ADDR(0x0, 0x685700); }
void Scr_AddContinueBlock(scriptInstance_t inst, scr_block_s* block, void* call_addr = Scr_AddContinueBlock_ADDR());
inline void* EmitIncStatement_ADDR() { return CALL_ADDR(0x0, 0x686570); }
void EmitIncStatement(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u sourcePos, void* call_addr = EmitIncStatement_ADDR());
inline void* EmitDecStatement_ADDR() { return CALL_ADDR(0x0, 0x686690); }
void EmitDecStatement(scr_block_s* block, scriptInstance_t inst, sval_u expr, sval_u sourcePos, void* call_addr = EmitDecStatement_ADDR());
inline void* Scr_CalcLocalVarsFormalParameterListInternal_ADDR() { return CALL_ADDR(0x0, 0x6867B0); }
void Scr_CalcLocalVarsFormalParameterListInternal(sval_u* node, scr_block_s* block, void* call_addr = Scr_CalcLocalVarsFormalParameterListInternal_ADDR());
inline void* EmitWaittillStatement_ADDR() { return CALL_ADDR(0x0, 0x686810); }
void EmitWaittillStatement(scriptInstance_t inst, sval_u obj, sval_u exprlist, sval_u sourcePos, sval_u waitSourcePos, scr_block_s* block, void* call_addr = EmitWaittillStatement_ADDR());
inline void* EmitWaittillmatchStatement_ADDR() { return CALL_ADDR(0x0, 0x686A60); }
void EmitWaittillmatchStatement(scriptInstance_t inst, sval_u obj, sval_u exprlist, sval_u sourcePos, sval_u waitSourcePos, scr_block_s* block, void* call_addr = EmitWaittillmatchStatement_ADDR());
inline void* EmitNotifyStatement_ADDR() { return CALL_ADDR(0x0, 0x686D30); }
void EmitNotifyStatement(scriptInstance_t inst, sval_u obj, sval_u exprlist, sval_u sourcePos, sval_u notifySourcePos, scr_block_s* block, void* call_addr = EmitNotifyStatement_ADDR());
inline void* EmitEndOnStatement_ADDR() { return CALL_ADDR(0x0, 0x686F90); }
void EmitEndOnStatement(scr_block_s* block, scriptInstance_t inst, sval_u obj, sval_u expr, sval_u sourcePos, sval_u exprSourcePos, void* call_addr = EmitEndOnStatement_ADDR());
inline void* EmitCaseStatement_ADDR() { return CALL_ADDR(0x0, 0x687100); }
void EmitCaseStatement(scriptInstance_t inst, sval_u expr, sval_u sourcePos, void* call_addr = EmitCaseStatement_ADDR());
inline void* EmitCaseStatementInfo_ADDR() { return CALL_ADDR(0x0, 0x687990); }
void EmitCaseStatementInfo(scriptInstance_t inst, unsigned int name, sval_u sourcePos, void* call_addr = EmitCaseStatementInfo_ADDR());
inline void* EmitBreakStatement_ADDR() { return CALL_ADDR(0x0, 0x6879F0); }
void EmitBreakStatement(scr_block_s* block, scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitBreakStatement_ADDR());
inline void* EmitContinueStatement_ADDR() { return CALL_ADDR(0x0, 0x687B90); }
void EmitContinueStatement(scr_block_s* block, scriptInstance_t inst, sval_u sourcePos, void* call_addr = EmitContinueStatement_ADDR());
inline void* EmitProfStatement_ADDR() { return CALL_ADDR(0x0, 0x687D30); }
void EmitProfStatement(scriptInstance_t inst, sval_u profileName, sval_u sourcePos, OpcodeVM op, void* call_addr = EmitProfStatement_ADDR());
inline void* Scr_CalcLocalVarsStatementList_ADDR() { return CALL_ADDR(0x0, 0x6884F0); }
void Scr_CalcLocalVarsStatementList(scr_block_s* block, scriptInstance_t inst, sval_u val, void* call_addr = Scr_CalcLocalVarsStatementList_ADDR());
inline void* EmitFormalParameterList_ADDR() { return CALL_ADDR(0x0, 0x6886A0); }
void EmitFormalParameterList(scriptInstance_t inst, sval_u exprlist, sval_u sourcePos, scr_block_s* block, void* call_addr = EmitFormalParameterList_ADDR());
inline void* SpecifyThread_ADDR() { return CALL_ADDR(0x0, 0x6887C0); }
void SpecifyThread(scriptInstance_t inst, sval_u val, void* call_addr = SpecifyThread_ADDR());
inline void* EmitThreadInternal_ADDR() { return CALL_ADDR(0x0, 0x6888D0); }
void EmitThreadInternal(scriptInstance_t inst, sval_u val, sval_u sourcePos, sval_u endSourcePos, scr_block_s* block, void* call_addr = EmitThreadInternal_ADDR());
inline void* Scr_CalcLocalVarsThread_ADDR() { return CALL_ADDR(0x0, 0x688990); }
void Scr_CalcLocalVarsThread(sval_u* stmttblock, scriptInstance_t inst, sval_u exprlist, sval_u stmtlist, void* call_addr = Scr_CalcLocalVarsThread_ADDR());
inline void* InitThread_ADDR() { return CALL_ADDR(0x0, 0x688A00); }
void InitThread(int type_, scriptInstance_t inst, void* call_addr = InitThread_ADDR());
inline void* EmitNormalThread_ADDR() { return CALL_ADDR(0x0, 0x688A70); }
void EmitNormalThread(scriptInstance_t inst, sval_u val, sval_u* stmttblock, void* call_addr = EmitNormalThread_ADDR());
inline void* EmitDeveloperThread_ADDR() { return CALL_ADDR(0x0, 0x688B00); }
void EmitDeveloperThread(scriptInstance_t inst, sval_u val, sval_u* stmttblock, void* call_addr = EmitDeveloperThread_ADDR());
inline void* EmitThread_ADDR() { return CALL_ADDR(0x0, 0x688C40); }
void EmitThread(scriptInstance_t inst, sval_u val, void* call_addr = EmitThread_ADDR());
inline void* EmitInclude_ADDR() { return CALL_ADDR(0x0, 0x688DD0); }
void EmitInclude(scriptInstance_t inst, sval_u val, void* call_addr = EmitInclude_ADDR());
inline void* ScriptCompile_ADDR() { return CALL_ADDR(0x0, 0x688E70); }
void ScriptCompile(scriptInstance_t inst, sval_u val, unsigned int filePosId, unsigned int fileCountId, unsigned int scriptId, PrecacheEntry* entries, int entriesCount, void* call_addr = ScriptCompile_ADDR());
void EmitFloat(scriptInstance_t inst, float value);
void EmitCanonicalStringConst(scriptInstance_t inst, unsigned int stringValue);
int Scr_FindLocalVar(scr_block_s* block, int startIndex, unsigned int name);
void Scr_CheckLocalVarsCount(int localVarsCount);
void EmitGetUndefined(scriptInstance_t inst, sval_u sourcePos);
void EmitPrimitiveExpression(scriptInstance_t inst, sval_u expr, scr_block_s* block);
void Scr_EmitAnimation(scriptInstance_t inst, char* pos, unsigned int animName, unsigned int sourcePos);
void EmitEvalArray(scriptInstance_t inst, sval_u sourcePos, sval_u indexSourcePos);
void EmitEvalArrayRef(scriptInstance_t inst, sval_u sourcePos, sval_u indexSourcePos);
unsigned int Scr_GetBuiltin(scriptInstance_t inst, sval_u func_name);
int Scr_GetUncacheType(int type);
int Scr_GetCacheType(int type);
BuiltinFunction Scr_GetFunction(const char** pName, int* type);
BuiltinFunction GetFunction(scriptInstance_t inst, const char** pName, int* type);
BuiltinMethod GetMethod(scriptInstance_t inst, const char** pName, int* type);
unsigned int GetVariableName(scriptInstance_t inst, unsigned int id);
int GetExpressionCount(sval_u exprlist);
sval_u* GetSingleParameter(sval_u exprlist);
void EmitExpressionFieldObject(scriptInstance_t inst, sval_u expr, sval_u sourcePos, scr_block_s* block);
void EvalInteger(int value, sval_u sourcePos, VariableCompileValue* constValue);
void EvalFloat(float value, sval_u sourcePos, VariableCompileValue* constValue);
void EvalString(unsigned int value, sval_u sourcePos, VariableCompileValue* constValue);
void EvalIString(unsigned int value, sval_u sourcePos, VariableCompileValue* constValue);
void EvalUndefined(sval_u sourcePos, VariableCompileValue* constValue);
void Scr_PopValue(scriptInstance_t inst);
void EmitSetVariableField(scriptInstance_t inst, sval_u sourcePos);
void EmitFieldVariableRef(scriptInstance_t inst, sval_u expr, sval_u field, sval_u sourcePos, scr_block_s* block);
void Scr_CalcLocalVarsArrayPrimitiveExpressionRef(sval_u expr, scr_block_s* block);
BOOL IsUndefinedPrimitiveExpression(sval_u expr);
bool IsUndefinedExpression(sval_u expr);
void Scr_CopyBlock(scr_block_s* from, scr_block_s** to);
void Scr_CheckMaxSwitchCases(int count);
void Scr_CalcLocalVarsSafeSetVariableField(sval_u expr, sval_u sourcePos, scr_block_s* block);
void EmitFormalWaittillParameterListRefInternal(scriptInstance_t inst, sval_u* node, scr_block_s* block);
void EmitDefaultStatement(scriptInstance_t inst, sval_u sourcePos);
char Scr_IsLastStatement(scriptInstance_t inst, sval_u* node);
void EmitEndStatement(scriptInstance_t inst, sval_u sourcePos, scr_block_s* block);
void EmitProfBeginStatement(scriptInstance_t inst, sval_u profileName, sval_u sourcePos);
void EmitProfEndStatement(scriptInstance_t inst, sval_u profileName, sval_u sourcePos);
void Scr_CalcLocalVarsIncStatement(sval_u expr, scr_block_s *block);
void Scr_CalcLocalVarsWaittillStatement(sval_u exprlist, scr_block_s* block);
void EmitFormalParameterListInternal(scriptInstance_t inst, sval_u* node, scr_block_s* block);
unsigned int SpecifyThreadPosition(scriptInstance_t inst, unsigned int posId, unsigned int name, unsigned int sourcePos, int type);
void Scr_CalcLocalVarsFormalParameterList(sval_u exprlist, scr_block_s* block);
void SetThreadPosition(scriptInstance_t inst, unsigned int posId);
void EmitIncludeList(scriptInstance_t inst, sval_u val);
}
File diff suppressed because it is too large Load Diff
@@ -61,4 +61,5 @@ namespace game
int SL_ConvertFromString(scriptInstance_t inst, const char* str);
int SL_ConvertFromRefString(scriptInstance_t inst, RefString* refString);
RefString* GetRefString_0(scriptInstance_t inst, const char* str);
const char* SL_ConvertToStringSafe(unsigned int id, game::scriptInstance_t inst);
}
@@ -362,4 +362,9 @@ namespace game
{
return codsrc::GetRefString_0(inst, str);
}
const char* SL_ConvertToStringSafe(unsigned int id, game::scriptInstance_t inst)
{
return codsrc::SL_ConvertToStringSafe(id, inst);
}
}
+1
View File
@@ -178,4 +178,5 @@ namespace game
void Scr_EvalBoolNot(scriptInstance_t inst, VariableValue* value);
unsigned int GetInternalVariableIndex(scriptInstance_t inst, unsigned int unsignedValue);
const char* Scr_ReadData(scriptInstance_t inst, const char** pos, unsigned int count);
unsigned int Scr_GetNumParam(game::scriptInstance_t inst);
}
+5
View File
@@ -981,4 +981,9 @@ namespace game
{
return codsrc::Scr_ReadData(inst, pos, count);
}
unsigned int Scr_GetNumParam(game::scriptInstance_t inst)
{
return codsrc::Scr_GetNumParam(inst);
}
}
+27
View File
@@ -0,0 +1,27 @@
#pragma once
namespace game
{
WEAK symbol<int()>yyparse{ 0x0, 0x69AEC0 };
WEAK symbol<int()>yylex{ 0x0, 0x69C0D0 };
WEAK symbol<int()>yy_get_next_buffer{ 0x0, 0x69D300 };
WEAK symbol<int()>yy_get_previous_state{ 0x0, 0x69D450 };
WEAK symbol<void()>yyrestart{ 0x0, 0x69D5C0 };
WEAK symbol<yy_buffer_state* ()>yy_create_buffer{ 0x0, 0x69D620 };
inline void* LowerCase_ADDR() { return CALL_ADDR(0x0, 0x69AEA0); }
unsigned int LowerCase(unsigned int strVal, void* call_addr = LowerCase_ADDR());
inline void* StringValue_ADDR() { return CALL_ADDR(0x0, 0x69BFF0); }
int StringValue(int len, const char* str_, void* call_addr = StringValue_ADDR());
inline void* yy_try_NUL_trans_ADDR() { return CALL_ADDR(0x0, 0x69D520); }
int yy_try_NUL_trans(int yy_current_state, void* call_addr = yy_try_NUL_trans_ADDR());
inline void* yy_flush_buffer_ADDR() { return CALL_ADDR(0x0, 0x69D690); }
void yy_flush_buffer(yy_buffer_state* result, void* call_addr = yy_flush_buffer_ADDR());
inline void* ScriptParse_ADDR() { return CALL_ADDR(0x0, 0x69D710); }
void ScriptParse(scriptInstance_t a1, sval_u* parseData, void* call_addr = ScriptParse_ADDR());
FILE* yy_load_buffer_state();
void yy_fatal_error(const char* err);
void* yy_flex_realloc(void* ptr, unsigned int size);
void yy_init_buffer(yy_buffer_state* b, FILE* file);
}
+93
View File
@@ -0,0 +1,93 @@
#include <stdinc.hpp>
#include "codsrc/clientscript/cscr_yacc.hpp"
namespace game
{
// unsigned int __usercall LowerCase@<eax>(unsigned int strVal@<ecx>)
unsigned int LowerCase(unsigned int strVal, void* call_addr)
{
unsigned int answer;
__asm
{
mov ecx, strVal;
call call_addr;
mov answer, eax;
}
return answer;
}
// int __usercall StringValue@<eax>(int len@<ecx>, const char *str@<edx>)
int StringValue(int len, const char* str_, void* call_addr)
{
int answer;
__asm
{
mov ecx, len;
mov edx, str_;
call call_addr;
mov answer, eax;
}
return answer;
}
// int __usercall yy_try_NUL_trans@<eax>(int yy_current_state@<eax>)
int yy_try_NUL_trans(int yy_current_state, void* call_addr)
{
int answer;
__asm
{
mov eax, yy_current_state;
call call_addr;
mov answer, eax;
}
return answer;
}
// void __usercall yy_flush_buffer(yy_buffer_state *result@<eax>)
void yy_flush_buffer(yy_buffer_state* result, void* call_addr)
{
__asm
{
mov eax, result;
call call_addr;
}
}
// void __usercall ScriptParse(scriptInstance_t a1@<eax>, sval_u *parseData)
void ScriptParse(scriptInstance_t a1, sval_u* parseData, void* call_addr)
{
__asm
{
push parseData;
mov eax, a1;
call call_addr;
add esp, 0x4;
}
}
FILE* yy_load_buffer_state()
{
return codsrc::yy_load_buffer_state();
}
void yy_fatal_error(const char* err)
{
codsrc::yy_fatal_error(err);
}
void* yy_flex_realloc(void* ptr, unsigned int size)
{
return codsrc::yy_flex_realloc(ptr, size);
}
void yy_init_buffer(yy_buffer_state* b, FILE* file)
{
codsrc::yy_init_buffer(b, file);
}
}
+3959 -3913
View File
File diff suppressed because it is too large Load Diff
+264 -206
View File
@@ -1,206 +1,264 @@
#include <stdinc.hpp>
#include <utils/hook.hpp>
#include <utils/memory.hpp>
#include <utils/string.hpp>
namespace game
{
gamemode current = reinterpret_cast<const char*>(0x88A5DC) != "CoDWaW.exe"s
? gamemode::multiplayer
: gamemode::singleplayer;
namespace environment
{
bool t4mp()
{
return current == gamemode::multiplayer;
}
bool t4sp()
{
return current == gamemode::singleplayer;
}
}
// HunkUser* __usercall Hunk_UserCreate@<eax>(signed int maxSize@<edi>, char* name, char fixed, char tempMem, char debugMem, int type);
HunkUser* Hunk_UserCreate(signed int maxSize, const char* name, int fixed, int tempMem, int debugMem, int typ, void* call_addr)
{
HunkUser* answer;
__asm
{
push typ;
push debugMem;
push tempMem;
push fixed;
push name;
mov edi, maxSize;
call call_addr;
add esp, 0x14;
mov answer, eax;
}
return answer;
}
// unsigned int __usercall Hunk_AllocateTempMemoryHigh@<eax>(int a1@<eax>)
unsigned int Hunk_AllocateTempMemoryHigh(int size_, void* call_addr)
{
unsigned int answer;
__asm
{
mov eax, size_;
call call_addr;
mov answer, eax;
}
return answer;
}
// void __usercall FS_FCloseFile(int h@<eax>)
void FS_FCloseFile(int h, void* call_addr)
{
__asm
{
mov eax, h;
call call_addr;
}
}
// void *__usercall Z_TryVirtualAlloc@<eax>(signed int a1@<edi>)
void* Z_TryVirtualAlloc(signed int size_, void* call_addr)
{
void* answer;
__asm
{
mov edi, size_;
call call_addr;
mov answer, eax;
}
return answer;
}
// int __usercall I_stricmp@<eax>(int a1@<eax>, CHAR *a2@<edx>, const char *a3)
int I_stricmp(int len, const char* s0, const char* s1, void* call_addr)
{
int answer;
__asm
{
push s1;
mov eax, len;
mov edx, s0;
call call_addr;
mov answer, eax;
add esp, 0x4;
}
return answer;
}
//parseInfo_t* __usercall Com_Parse@<eax>(const char** a1@<esi>)
parseInfo_t* Com_Parse(const char** buffer, void* call_addr)
{
parseInfo_t* answer;
__asm
{
mov esi, buffer;
call call_addr;
mov answer, eax;
}
return answer;
}
//int __usercall I_strncmp@<eax>(char *str1@<edx>, char *str2@<ecx>, int len)
int I_strncmp(const char* str1, const char* str2, int len, void* call_addr)
{
int answer;
__asm
{
push len;
mov ecx, str2;
mov edx, str1;
call call_addr;
mov answer, eax;
}
return answer;
}
// const char **__usercall FS_ListFilteredFiles@<eax>(searchpath_s *searchPath@<eax>, const char *path@<edx>, const char *extension, const char *filter, FsListBehavior_e behavior, int *numFiles)
const char** FS_ListFilteredFiles(searchpath_s* searchPath, const char* path, const char* extension, const char* filter, FsListBehavior_e behavior, int* numFiles, void* call_addr)
{
const char** answer;
__asm
{
push numFiles;
push behavior;
push filter;
push extension;
mov eax, searchPath;
mov edx, path;
call call_addr;
mov answer, eax;
add esp, 0x10;
}
return answer;
}
dvar_s * Dvar_RegisterBool/*@<eax>*/(unsigned __int8 val/*@<al>*/, const char * name/*@<edi>*/, int flags, const char * desc, void* call_addr)
{
dvar_s * answer;
__asm
{
push desc;
push flags;
mov al, val;
mov edi, name;
call call_addr;
mov answer, eax;
add esp, 0x8;
}
return answer;
}
const char * XAnimGetAnimDebugName/*@<eax>*/(unsigned int animIndex/*@<ecx>*/, XAnim_s * anims/*@<edx>*/, void* call_addr)
{
const char * answer;
__asm
{
mov ecx, animIndex;
mov edx, anims;
call call_addr;
mov answer, eax;
}
return answer;
}
// restored
void Sys_EnterCriticalSection(CriticalSection critSect)
{
EnterCriticalSection(&s_criticalSection[critSect]);
}
// restored
void Sys_LeaveCriticalSection(CriticalSection critSect)
{
LeaveCriticalSection(&s_criticalSection[critSect]);
}
namespace plutonium
{
}
}
#include <stdinc.hpp>
#include <utils/hook.hpp>
#include <utils/memory.hpp>
#include <utils/string.hpp>
namespace game
{
gamemode current = reinterpret_cast<const char*>(0x88A5DC) != "CoDWaW.exe"s
? gamemode::multiplayer
: gamemode::singleplayer;
namespace environment
{
bool t4mp()
{
return current == gamemode::multiplayer;
}
bool t4sp()
{
return current == gamemode::singleplayer;
}
}
// HunkUser* __usercall Hunk_UserCreate@<eax>(signed int maxSize@<edi>, char* name, char fixed, char tempMem, char debugMem, int type);
HunkUser* Hunk_UserCreate(signed int maxSize, const char* name, int fixed, int tempMem, int debugMem, int typ, void* call_addr)
{
HunkUser* answer;
__asm
{
push typ;
push debugMem;
push tempMem;
push fixed;
push name;
mov edi, maxSize;
call call_addr;
add esp, 0x14;
mov answer, eax;
}
return answer;
}
// unsigned int __usercall Hunk_AllocateTempMemoryHigh@<eax>(int a1@<eax>)
unsigned int Hunk_AllocateTempMemoryHigh(int size_, void* call_addr)
{
unsigned int answer;
__asm
{
mov eax, size_;
call call_addr;
mov answer, eax;
}
return answer;
}
// void __usercall FS_FCloseFile(int h@<eax>)
void FS_FCloseFile(int h, void* call_addr)
{
__asm
{
mov eax, h;
call call_addr;
}
}
// void *__usercall Z_TryVirtualAlloc@<eax>(signed int a1@<edi>)
void* Z_TryVirtualAlloc(signed int size_, void* call_addr)
{
void* answer;
__asm
{
mov edi, size_;
call call_addr;
mov answer, eax;
}
return answer;
}
// int __usercall I_stricmp@<eax>(int a1@<eax>, CHAR *a2@<edx>, const char *a3)
int I_stricmp(int len, const char* s0, const char* s1, void* call_addr)
{
int answer;
__asm
{
push s1;
mov eax, len;
mov edx, s0;
call call_addr;
mov answer, eax;
add esp, 0x4;
}
return answer;
}
//parseInfo_t* __usercall Com_Parse@<eax>(const char** a1@<esi>)
parseInfo_t* Com_Parse(const char** buffer, void* call_addr)
{
parseInfo_t* answer;
__asm
{
mov esi, buffer;
call call_addr;
mov answer, eax;
}
return answer;
}
//int __usercall I_strncmp@<eax>(char *str1@<edx>, char *str2@<ecx>, int len)
int I_strncmp(const char* str1, const char* str2, int len, void* call_addr)
{
int answer;
__asm
{
push len;
mov ecx, str2;
mov edx, str1;
call call_addr;
mov answer, eax;
}
return answer;
}
// const char **__usercall FS_ListFilteredFiles@<eax>(searchpath_s *searchPath@<eax>, const char *path@<edx>, const char *extension, const char *filter, FsListBehavior_e behavior, int *numFiles)
const char** FS_ListFilteredFiles(searchpath_s* searchPath, const char* path, const char* extension, const char* filter, FsListBehavior_e behavior, int* numFiles, void* call_addr)
{
const char** answer;
__asm
{
push numFiles;
push behavior;
push filter;
push extension;
mov eax, searchPath;
mov edx, path;
call call_addr;
mov answer, eax;
add esp, 0x10;
}
return answer;
}
dvar_s * Dvar_RegisterBool/*@<eax>*/(unsigned __int8 val/*@<al>*/, const char * name/*@<edi>*/, int flags, const char * desc, void* call_addr)
{
dvar_s * answer;
__asm
{
push desc;
push flags;
mov al, val;
mov edi, name;
call call_addr;
mov answer, eax;
add esp, 0x8;
}
return answer;
}
const char * XAnimGetAnimDebugName/*@<eax>*/(unsigned int animIndex/*@<ecx>*/, XAnim_s * anims/*@<edx>*/, void* call_addr)
{
const char * answer;
__asm
{
mov ecx, animIndex;
mov edx, anims;
call call_addr;
mov answer, eax;
}
return answer;
}
// cmd_function_s *__usercall Cmd_FindCommand@<eax>(const char *cmdName@<esi>)
cmd_function_s* Cmd_FindCommand(const char* cmdName, void* call_addr)
{
cmd_function_s* answer;
__asm
{
mov esi, cmdName;
call call_addr;
mov answer, eax;
}
return answer;
}
// BuiltinMethod __usercall Scr_GetMethod@<eax>(int *type@<edi>, const char **pName@<esi>)
BuiltinMethod Scr_GetMethod(int* type_, const char** pName, void* call_addr)
{
BuiltinMethod answer;
__asm
{
mov edi, type_;
mov esi, pName;
call call_addr;
mov answer, eax;
}
return answer;
}
void Cmd_AddCommand(const char* name, void (__cdecl *function)())
{
cmd_function_s* newCmd = utils::memory::allocate<cmd_function_s>();
*newCmd = {};
newCmd->next = *cmd_functions;
newCmd->function = function;
newCmd->name = utils::memory::duplicate_string(name);
*cmd_functions = newCmd;
}
// restored
const char** FS_ListFiles(const char* path, const char* extension, FsListBehavior_e behavior, int* numfiles)
{
return FS_ListFilteredFiles(*fs_searchpaths, path, extension, nullptr, behavior, numfiles);
}
// restored
void FS_FreeFileList(const char** list)
{
if ( list )
{
Hunk_UserDestroy((HunkUser*)*(list - 1));
}
}
// restored
void Sys_EnterCriticalSection(CriticalSection critSect)
{
EnterCriticalSection(&s_criticalSection[critSect]);
}
// restored
void Sys_LeaveCriticalSection(CriticalSection critSect)
{
LeaveCriticalSection(&s_criticalSection[critSect]);
}
namespace plutonium
{
}
}
+106 -70
View File
@@ -1,70 +1,106 @@
#pragma once
#define WEAK __declspec(selectany)
#define NAKED __declspec(naked)
#define SELECT(mp, sp) (game::environment::t4mp() ? mp : sp)
#define ASSIGN(type, mp, sp) reinterpret_cast<type>(SELECT(mp, sp))
#define CALL_ADDR(mp, sp) ASSIGN(void*, mp, sp)
#define ARRAY_COUNT(arrayn) \
((sizeof(arrayn)) / (sizeof(arrayn[0])))
namespace game
{
enum gamemode
{
multiplayer,
singleplayer,
none
};
extern gamemode current;
namespace environment
{
bool t4mp();
bool t4sp();
}
template <typename T>
class symbol
{
public:
symbol(const size_t t4mp, const size_t t4sp)
: t4mp_(reinterpret_cast<T*>(t4mp))
, t4sp_(reinterpret_cast<T*>(t4sp))
{
}
T* get() const
{
if (environment::t4mp())
{
return t4mp_;
}
return t4sp_;
}
void set(const size_t ptr)
{
this->t4mp_ = reinterpret_cast<T*>(ptr);
this->t4sp_ = reinterpret_cast<T*>(ptr);
}
operator T* () const
{
return this->get();
}
T* operator->() const
{
return this->get();
}
private:
T* t4mp_;
T* t4sp_;
};
}
#pragma once
#define WEAK __declspec(selectany)
#define NAKED __declspec(naked)
#define SELECT(mp, sp) (game::environment::t4mp() ? mp : sp)
#define ASSIGN(type, mp, sp) reinterpret_cast<type>(SELECT(mp, sp))
#define CALL_ADDR(mp, sp) ASSIGN(void*, mp, sp)
#define ARRAY_COUNT(arrayn) \
((sizeof(arrayn)) / (sizeof(arrayn[0])))
#ifndef NDEBUG
#undef assert
#define assert(expr) \
if (!!!(expr)) \
{ \
utils::io::write_file("t4sp-server-plugin/gsc_state_assert.json", build_gsc_dump(game::SCRIPTINSTANCE_SERVER)); \
_wassert(_CRT_WIDE(#expr), _CRT_WIDE(__FILE__), (unsigned)(__LINE__)); \
}
#endif
#define RE_CSCR_ANIMTREE_USE_WRAPPERS
//#define RE_CSCR_COMPILER_USE_WRAPPERS
//#define RE_CSCR_MAIN_USE_WRAPPERS
//#define RE_CSCR_MEMORYTREE_USE_WRAPPERS
//#define RE_CSCR_PARSER_USE_WRAPPERS
//#define RE_CSCR_PARSETREE_USE_WRAPPERS
//#define RE_CSCR_READWRITE_USE_WRAPPERS
//#define RE_CSCR_STRINGLIST_USE_WRAPPERS
//#define RE_CSCR_VARIABLE_USE_WRAPPERS
//#define RE_CSCR_VM_USE_WRAPPERS
//#define RE_CSCR_YACC_USE_WRAPPERS
//#define DISABLE_RE_CSCR_ANIMTREE
//#define DISABLE_RE_CSCR_COMPILER
//#define DISABLE_RE_CSCR_MAIN
//#define DISABLE_RE_CSCR_MEMORYTREE
//#define DISABLE_RE_CSCR_PARSER
//#define DISABLE_RE_CSCR_PARSETREE
//#define DISABLE_RE_CSCR_READWRITE
//#define DISABLE_RE_CSCR_STRINGLIST
//#define DISABLE_RE_CSCR_VARIABLE
//#define DISABLE_RE_CSCR_VM
//#define DISABLE_RE_CSCR_YACC
namespace game
{
enum gamemode
{
multiplayer,
singleplayer,
none
};
extern gamemode current;
namespace environment
{
bool t4mp();
bool t4sp();
}
template <typename T>
class symbol
{
public:
symbol(const size_t t4mp, const size_t t4sp)
: t4mp_(reinterpret_cast<T*>(t4mp))
, t4sp_(reinterpret_cast<T*>(t4sp))
{
}
T* get() const
{
if (environment::t4mp())
{
return t4mp_;
}
return t4sp_;
}
void set(const size_t ptr)
{
this->t4mp_ = reinterpret_cast<T*>(ptr);
this->t4sp_ = reinterpret_cast<T*>(ptr);
}
operator T* () const
{
return this->get();
}
T* operator->() const
{
return this->get();
}
private:
T* t4mp_;
T* t4sp_;
};
}
+13350 -13214
View File
File diff suppressed because it is too large Load Diff
+120 -77
View File
@@ -1,77 +1,120 @@
#pragma once
namespace game
{
// Functions
WEAK symbol<void(con_channel_e channel, const char* fmt, ...)> Com_Printf{ 0x0, 0x59A2C0 };
WEAK symbol<void(con_channel_e a1, const char* Source, int a3)>Com_PrintMessage{ 0x0, 0x59A170 };
WEAK symbol<void(con_channel_e a1, const char* Format, ...)>Com_PrintWarning{ 0x0, 0x59A440 };
WEAK symbol<void(con_channel_e a1, const char* Format, ...)>Com_PrintError{ 0x0, 0x59A380 };
WEAK symbol<void(errorParm_t a1, const char* Format, ...)>Com_Error{ 0x0, 0x59AC50 };
WEAK symbol<void(const char* Format, ...)>Sys_Error{ 0x0, 0x5FE8C0 };
WEAK symbol<void(HunkUser *user)>Hunk_UserDestroy{ 0x0, 0x5E4940 };
WEAK symbol<void *(HunkUser *user, int size, int alignment)> Hunk_UserAlloc{ 0x0, 0x5E47B0 };
WEAK symbol<void()> Hunk_ClearTempMemoryHigh{ 0x0, 0x5E4300 };
WEAK symbol<int(const char* filename, int* file)>FS_FOpenFileRead{ 0x0, 0x5DBD20 };
WEAK symbol<int(char* Buffer, size_t ElementCount, int a3)>FS_Read{ 0x0, 0x5DBDF0 };
WEAK symbol<int(const char* filename, int* file, fsMode_t mode)>FS_FOpenFileByMode{ 0x0, 0x5DB630 };
WEAK symbol<const char*(const char* Format, ...)>va{ 0x0, 0x5F6D80 };
WEAK symbol<parseInfo_t* (const char* ArgList)>Com_BeginParseSession{ 0x0, 0x5F5830 };
WEAK symbol<void()> Com_EndParseSession{ 0x0, 0x5F5910 };
WEAK symbol<int()> Sys_Milliseconds{ 0x0, 0x603D40 };
WEAK symbol<void(char* Destination, const char* Source, size_t Count)>I_strncpyz{ 0x0, 0x7AA9C0 };
inline void* I_strncmp_ADDR() { return CALL_ADDR(0x0, 0x5F6A40); }
int I_strncmp(const char* str1, const char* str2, int len, void* call_addr = I_strncmp_ADDR());
inline void* Hunk_UserCreate_ADDR() { return CALL_ADDR(0x0, 0x5E46E0); }
HunkUser* Hunk_UserCreate(signed int maxSize, const char* name, int fixed, int tempMem, int debugMem, int type, void* call_addr = Hunk_UserCreate_ADDR());
inline void* Hunk_AllocateTempMemoryHigh_ADDR() { return CALL_ADDR(0x0, 0x5E4220); }
unsigned int Hunk_AllocateTempMemoryHigh(int size_, void* call_addr = Hunk_AllocateTempMemoryHigh_ADDR());
inline void* FS_FCloseFile_ADDR() { return CALL_ADDR(0x0, 0x5DB060); }
void FS_FCloseFile(int h, void* call_addr = FS_FCloseFile_ADDR());
inline void* FS_ListFilteredFiles_ADDR() { return CALL_ADDR(0x0, 0x5DC720); }
const char** FS_ListFilteredFiles(searchpath_s* searchPath, const char* path, const char* extension, const char* filter, FsListBehavior_e behavior, int* numFiles, void* call_addr = FS_ListFilteredFiles_ADDR());
inline void* Z_TryVirtualAlloc_ADDR() { return CALL_ADDR(0x0, 0x5E39D0); }
void* Z_TryVirtualAlloc(signed int size_, void* call_addr = Z_TryVirtualAlloc_ADDR());
inline void* I_stricmp_ADDR() { return CALL_ADDR(0x0, 0x5F69E0); }
int I_stricmp(int len, const char* s0, const char* s1, void* call_addr = I_stricmp_ADDR());
inline void* Com_Parse_ADDR() { return CALL_ADDR(0x0, 0x5F61B0); }
parseInfo_t* Com_Parse(const char** buffer, void* call_addr = Com_Parse_ADDR());
inline void* Dvar_RegisterBool_ADDR() { return CALL_ADDR(0x0, 0x5EEE20); }
dvar_s * Dvar_RegisterBool(unsigned __int8 val, const char * name, int flags, const char * desc, void* call_addr = Dvar_RegisterBool_ADDR());
inline void* XAnimGetAnimDebugName_ADDR() { return CALL_ADDR(0x0, 0x60F850); }
const char * XAnimGetAnimDebugName(unsigned int animIndex, XAnim_s * anims, void* call_addr = XAnimGetAnimDebugName_ADDR());
void Sys_EnterCriticalSection(CriticalSection critSect);
void Sys_LeaveCriticalSection(CriticalSection critSect);
// Variables
WEAK symbol<CRITICAL_SECTION> s_criticalSection{ 0x0, 0x2298D08 };
WEAK symbol<HunkUser*> g_DebugHunkUser{ 0x0, 0x212B2EC };
WEAK symbol<dvar_s*> useFastFile{ 0x0, 0x1F552FC };
WEAK symbol<fileHandleData_t> fsh{ 0x0, 0x2126E20 };
WEAK symbol<dvar_s*> fs_game{ 0x0, 0x2122B00 };
WEAK symbol<dvar_s*> com_developer{ 0x0, 0x1F55288 };
WEAK symbol<int> statmon_related_bool{ 0x0, 0x2122B04 };
WEAK symbol<HunkUser*> g_allocNodeUser{ 0x0, 0x3882B20 };
WEAK symbol<struct HunkUser *> g_user{ 0x0, 0x3882B48 };
WEAK symbol<searchpath_s*> fs_searchpaths{ 0x0, 0x46E5044 };
namespace plutonium
{
WEAK symbol<int(const char* fmt, ...)> printf{0x0, 0x0};
WEAK symbol<void(scriptInstance_t)> load_custom_script_func{0x0, 0x0};
}
}
#pragma once
namespace game
{
// Functions
WEAK symbol<void(con_channel_e channel, const char* fmt, ...)> Com_Printf{ 0x0, 0x59A2C0 };
WEAK symbol<void(con_channel_e a1, const char* Source, int a3)>Com_PrintMessage{ 0x0, 0x59A170 };
WEAK symbol<void(con_channel_e a1, const char* Format, ...)>Com_PrintWarning{ 0x0, 0x59A440 };
WEAK symbol<void(con_channel_e a1, const char* Format, ...)>Com_PrintError{ 0x0, 0x59A380 };
WEAK symbol<void(errorParm_t a1, const char* Format, ...)>Com_Error{ 0x0, 0x59AC50 };
WEAK symbol<void(const char* Format, ...)>Sys_Error{ 0x0, 0x5FE8C0 };
WEAK symbol<void(HunkUser *user)>Hunk_UserDestroy{ 0x0, 0x5E4940 };
WEAK symbol<void *(HunkUser *user, int size, int alignment)> Hunk_UserAlloc{ 0x0, 0x5E47B0 };
WEAK symbol<void()> Hunk_ClearTempMemoryHigh{ 0x0, 0x5E4300 };
WEAK symbol<int(const char* filename, int* file)>FS_FOpenFileRead{ 0x0, 0x5DBD20 };
WEAK symbol<int(char* Buffer, size_t ElementCount, int a3)>FS_Read{ 0x0, 0x5DBDF0 };
WEAK symbol<int(const char* filename, int* file, fsMode_t mode)>FS_FOpenFileByMode{ 0x0, 0x5DB630 };
WEAK symbol<const char*(const char* Format, ...)>va{ 0x0, 0x5F6D80 };
WEAK symbol<dvar_s*(const char* dvarName)>Dvar_FindVar{ 0x0, 0x5EDE30 };
WEAK symbol<parseInfo_t* (const char* ArgList)>Com_BeginParseSession{ 0x0, 0x5F5830 };
WEAK symbol<void()> Com_EndParseSession{ 0x0, 0x5F5910 };
WEAK symbol<int()> Sys_Milliseconds{ 0x0, 0x603D40 };
WEAK symbol<void(char* Destination, const char* Source, size_t Count)>I_strncpyz{ 0x0, 0x7AA9C0 };
WEAK symbol<_iobuf* ()>__iob_func{ 0x0, 0x7AE0DE };
WEAK symbol<size_t(const void* Buffer, size_t ElementSize, size_t ElementCount, FILE* Stream)>_fwrite{ 0x0, 0x7ACBDA };
WEAK symbol<int(const char* const Buffer, const char* const Format, ...)>_sscanf{ 0x0, 0x7AB559 };
WEAK symbol<int(FILE* const Stream, const char* const Format, ...)>_fprintf{ 0x0, 0x7AE406 };
WEAK symbol<void(int Code)>_exit{ 0x0, 0x7AC431 };
WEAK symbol<void* (void* Block, size_t Size)>_realloc{ 0x0, 0x7AECAC };
WEAK symbol<void* (size_t Size)>Z_TryMalloc{ 0x0, 0x7AAD36 };
WEAK symbol<BuiltinFunction(const char** pName)>Sentient_GetFunction{ 0x0, 0x5676F0 };
WEAK symbol<BuiltinFunction(const char** pName, int* type_1)>BuiltIn_GetFunction{ 0x0, 0x52F0B0 };
WEAK symbol<BuiltinFunction(const char** pName, int* type)>CScr_GetFunction{ 0x0, 0x66EA30 };
WEAK symbol<BuiltinMethod(const char** pName, int* type)>CScr_GetMethod{ 0x0, 0x671110 };
inline void* I_strncmp_ADDR() { return CALL_ADDR(0x0, 0x5F6A40); }
int I_strncmp(const char* str1, const char* str2, int len, void* call_addr = I_strncmp_ADDR());
inline void* Hunk_UserCreate_ADDR() { return CALL_ADDR(0x0, 0x5E46E0); }
HunkUser* Hunk_UserCreate(signed int maxSize, const char* name, int fixed, int tempMem, int debugMem, int type, void* call_addr = Hunk_UserCreate_ADDR());
inline void* Hunk_AllocateTempMemoryHigh_ADDR() { return CALL_ADDR(0x0, 0x5E4220); }
unsigned int Hunk_AllocateTempMemoryHigh(int size_, void* call_addr = Hunk_AllocateTempMemoryHigh_ADDR());
inline void* FS_FCloseFile_ADDR() { return CALL_ADDR(0x0, 0x5DB060); }
void FS_FCloseFile(int h, void* call_addr = FS_FCloseFile_ADDR());
inline void* FS_ListFilteredFiles_ADDR() { return CALL_ADDR(0x0, 0x5DC720); }
const char** FS_ListFilteredFiles(searchpath_s* searchPath, const char* path, const char* extension, const char* filter, FsListBehavior_e behavior, int* numFiles, void* call_addr = FS_ListFilteredFiles_ADDR());
inline void* Z_TryVirtualAlloc_ADDR() { return CALL_ADDR(0x0, 0x5E39D0); }
void* Z_TryVirtualAlloc(signed int size_, void* call_addr = Z_TryVirtualAlloc_ADDR());
inline void* I_stricmp_ADDR() { return CALL_ADDR(0x0, 0x5F69E0); }
int I_stricmp(int len, const char* s0, const char* s1, void* call_addr = I_stricmp_ADDR());
inline void* Com_Parse_ADDR() { return CALL_ADDR(0x0, 0x5F61B0); }
parseInfo_t* Com_Parse(const char** buffer, void* call_addr = Com_Parse_ADDR());
inline void* Dvar_RegisterBool_ADDR() { return CALL_ADDR(0x0, 0x5EEE20); }
dvar_s * Dvar_RegisterBool(unsigned __int8 val, const char * name, int flags, const char * desc, void* call_addr = Dvar_RegisterBool_ADDR());
inline void* XAnimGetAnimDebugName_ADDR() { return CALL_ADDR(0x0, 0x60F850); }
const char * XAnimGetAnimDebugName(unsigned int animIndex, XAnim_s * anims, void* call_addr = XAnimGetAnimDebugName_ADDR());
inline void* Cmd_FindCommand_ADDR() { return CALL_ADDR(0x0, 0x594DB0); }
cmd_function_s* Cmd_FindCommand(const char* cmdName, void* call_addr = Cmd_FindCommand_ADDR());
void Cmd_AddCommand(const char* name, void(__cdecl* function)());
inline void* Scr_GetMethod_ADDR() { return CALL_ADDR(0x0, 0x530630); }
BuiltinMethod Scr_GetMethod(int* type_, const char** pName, void* call_addr = Scr_GetMethod_ADDR());
void Sys_EnterCriticalSection(CriticalSection critSect);
void Sys_LeaveCriticalSection(CriticalSection critSect);
const char** FS_ListFiles(const char* path, const char* extension, FsListBehavior_e behavior, int* numfiles);
void FS_FreeFileList(const char** list);
// Variables
WEAK symbol<CRITICAL_SECTION> s_criticalSection{ 0x0, 0x2298D08 };
WEAK symbol<HunkUser*> g_DebugHunkUser{ 0x0, 0x212B2EC };
WEAK symbol<dvar_s*> useFastFile{ 0x0, 0x1F552FC };
WEAK symbol<fileHandleData_t> fsh{ 0x0, 0x2126E20 };
WEAK symbol<dvar_s*> fs_game{ 0x0, 0x2122B00 };
WEAK symbol<dvar_s*> com_developer{ 0x0, 0x1F55288 };
WEAK symbol<int> statmon_related_bool{ 0x0, 0x2122B04 };
WEAK symbol<HunkUser*> g_allocNodeUser{ 0x0, 0x3882B20 };
WEAK symbol<struct HunkUser *> g_user{ 0x0, 0x3882B48 };
WEAK symbol<searchpath_s*> fs_searchpaths{ 0x0, 0x46E5044 };
WEAK symbol<cmd_function_s*> cmd_functions{ 0x0, 0x1F416F4 };
namespace plutonium
{
WEAK symbol<int(const char* fmt, ...)> printf{0x0, 0x0};
WEAK symbol<void(scriptInstance_t)> load_custom_script_func{0x0, 0x0};
WEAK symbol<void(char*, game::scriptInstance_t, sval_u*)> script_preprocess{0x0, 0x0};
WEAK symbol<void(game::scriptInstance_t)> vm_execute_update_codepos{0x0, 0x0};
WEAK symbol<void(game::scriptInstance_t, game::scriptInstance_t, unsigned int*, unsigned int*)> scr_execthread_update_codepos_func{0x0, 0x0};
WEAK symbol<void(game::scriptInstance_t, unsigned int*)> scr_execentthread_update_codepos_func{ 0x0, 0x0 };
WEAK symbol<void(game::scriptInstance_t, unsigned int*)> scr_addexecthread_update_codepos_func{ 0x0, 0x0 };
WEAK symbol<const char*(game::scriptInstance_t, unsigned int)> at_codepose_va{ 0x0, 0x0 };
WEAK symbol<void()> scr_get_method_stub{ 0x0, 0x0 };
WEAK symbol<void()> scr_get_function_stub{ 0x0, 0x0 };
WEAK symbol<game::BuiltinMethod(const char** name, int* type)> scr_get_method_hook{ 0x0, 0x0 };
WEAK symbol<game::BuiltinFunction(const char** name, int* type)> scr_get_function_hook{ 0x0, 0x0 };
WEAK symbol<game::BuiltinMethod(const char** name, int* type)> cscr_get_method_hook{ 0x0, 0x0 };
WEAK symbol<game::BuiltinFunction(const char** name, int* type)> cscr_get_function_hook{ 0x0, 0x0 };
WEAK symbol<void(int scrInstance, int str_num)> store_func_codepos{ 0x0, 0x0 };
}
}
+24 -1
View File
@@ -5318,7 +5318,8 @@ namespace game
RawFile* rawfile; //OFS: 0x1A SIZE: 0x4
StringTable* stringTable; //OFS: 0x1B SIZE: 0x4
PackIndex* packIndex; //OFS: 0x1C SIZE: 0x4
void* data; //OFS: 0x1D SIZE: 0x4
snd_alias_list_t* sound; //OFS: 0x1D SIZE: 0x4
void* data; //OFS: 0x1E SIZE: 0x4
};
struct XAsset
@@ -5417,6 +5418,28 @@ namespace game
ASSERT_STRUCT_OFFSET(XZone, allocType, 0x8);
ASSERT_STRUCT_OFFSET(XZone, blocks, 0xC);
struct XFile
{
unsigned int size; //OFS: 0x0 SIZE: 0x4
unsigned int externalSize; //OFS: 0x4 SIZE: 0x4
unsigned int blockSize[7]; //OFS: 0x8 SIZE: 0x1C
};
ASSERT_STRUCT_SIZE(XFile, 0x24);
ASSERT_STRUCT_OFFSET(XFile, size, 0x0);
ASSERT_STRUCT_OFFSET(XFile, externalSize, 0x4);
ASSERT_STRUCT_OFFSET(XFile, blockSize, 0x8);
struct XZoneInfo
{
char * name; //OFS: 0x0 SIZE: 0x4
int allocFlags; //OFS: 0x4 SIZE: 0x4
int freeFlags; //OFS: 0x8 SIZE: 0x4
};
ASSERT_STRUCT_SIZE(XZoneInfo, 0xC);
ASSERT_STRUCT_OFFSET(XZoneInfo, name, 0x0);
ASSERT_STRUCT_OFFSET(XZoneInfo, allocFlags, 0x4);
ASSERT_STRUCT_OFFSET(XZoneInfo, freeFlags, 0x8);
#ifdef __cplusplus
WEAK symbol<XAssetHeader(XAssetType type, const char* name, bool errorIfMissing, int waitTime)>DB_FindXAssetHeader{ 0x0, 0x48DA30 };
}
+35 -35
View File
@@ -1,35 +1,35 @@
#pragma once
class component_interface
{
public:
virtual ~component_interface()
{
}
virtual void post_start()
{
}
virtual void post_load()
{
}
virtual void pre_destroy()
{
}
virtual void post_unpack()
{
}
virtual void* load_import([[maybe_unused]] const std::string& library, [[maybe_unused]] const std::string& function)
{
return nullptr;
}
virtual bool is_supported()
{
return true;
}
};
#pragma once
class component_interface
{
public:
virtual ~component_interface()
{
}
virtual void post_start()
{
}
virtual void post_load()
{
}
virtual void pre_destroy()
{
}
virtual void post_unpack()
{
}
virtual void* load_import([[maybe_unused]] const std::string& library, [[maybe_unused]] const std::string& function)
{
return nullptr;
}
virtual bool is_supported()
{
return true;
}
};
+110 -110
View File
@@ -1,110 +1,110 @@
#include <stdinc.hpp>
#include "component_loader.hpp"
void component_loader::register_component(std::unique_ptr<component_interface>&& component_)
{
get_components().push_back(std::move(component_));
}
bool component_loader::post_start()
{
static auto handled = false;
if (handled) return true;
handled = true;
for (const auto& component_ : get_components())
{
component_->post_start();
}
return true;
}
bool component_loader::post_load()
{
static auto handled = false;
if (handled) return true;
handled = true;
clean();
for (const auto& component_ : get_components())
{
component_->post_load();
}
return true;
}
void component_loader::post_unpack()
{
static auto handled = false;
if (handled) return;
handled = true;
for (const auto& component_ : get_components())
{
component_->post_unpack();
}
}
void component_loader::pre_destroy()
{
static auto handled = false;
if (handled) return;
handled = true;
for (const auto& component_ : get_components())
{
component_->pre_destroy();
}
}
void component_loader::clean()
{
auto& components = get_components();
for (auto i = components.begin(); i != components.end();)
{
if (!(*i)->is_supported())
{
(*i)->pre_destroy();
i = components.erase(i);
}
else
{
++i;
}
}
}
void* component_loader::load_import(const std::string& library, const std::string& function)
{
void* function_ptr = nullptr;
for (const auto& component_ : get_components())
{
auto* const component_function_ptr = component_->load_import(library, function);
if (component_function_ptr)
{
function_ptr = component_function_ptr;
}
}
return function_ptr;
}
std::vector<std::unique_ptr<component_interface>>& component_loader::get_components()
{
using component_vector = std::vector<std::unique_ptr<component_interface>>;
using component_vector_container = std::unique_ptr<component_vector, std::function<void(component_vector*)>>;
static component_vector_container components(new component_vector, [](component_vector* component_vector)
{
pre_destroy();
delete component_vector;
});
return *components;
}
#include <stdinc.hpp>
#include "component_loader.hpp"
void component_loader::register_component(std::unique_ptr<component_interface>&& component_)
{
get_components().push_back(std::move(component_));
}
bool component_loader::post_start()
{
static auto handled = false;
if (handled) return true;
handled = true;
for (const auto& component_ : get_components())
{
component_->post_start();
}
return true;
}
bool component_loader::post_load()
{
static auto handled = false;
if (handled) return true;
handled = true;
clean();
for (const auto& component_ : get_components())
{
component_->post_load();
}
return true;
}
void component_loader::post_unpack()
{
static auto handled = false;
if (handled) return;
handled = true;
for (const auto& component_ : get_components())
{
component_->post_unpack();
}
}
void component_loader::pre_destroy()
{
static auto handled = false;
if (handled) return;
handled = true;
for (const auto& component_ : get_components())
{
component_->pre_destroy();
}
}
void component_loader::clean()
{
auto& components = get_components();
for (auto i = components.begin(); i != components.end();)
{
if (!(*i)->is_supported())
{
(*i)->pre_destroy();
i = components.erase(i);
}
else
{
++i;
}
}
}
void* component_loader::load_import(const std::string& library, const std::string& function)
{
void* function_ptr = nullptr;
for (const auto& component_ : get_components())
{
auto* const component_function_ptr = component_->load_import(library, function);
if (component_function_ptr)
{
function_ptr = component_function_ptr;
}
}
return function_ptr;
}
std::vector<std::unique_ptr<component_interface>>& component_loader::get_components()
{
using component_vector = std::vector<std::unique_ptr<component_interface>>;
using component_vector_container = std::unique_ptr<component_vector, std::function<void(component_vector*)>>;
static component_vector_container components(new component_vector, [](component_vector* component_vector)
{
pre_destroy();
delete component_vector;
});
return *components;
}
+51 -51
View File
@@ -1,51 +1,51 @@
#pragma once
#include "component_interface.hpp"
class component_loader final
{
public:
template <typename T>
class installer final
{
static_assert(std::is_base_of<component_interface, T>::value, "component has invalid base class");
public:
installer()
{
register_component(std::make_unique<T>());
}
};
template <typename T>
static T* get()
{
for (const auto& component_ : get_components())
{
if (typeid(*component_.get()) == typeid(T))
{
return reinterpret_cast<T*>(component_.get());
}
}
return nullptr;
}
static void register_component(std::unique_ptr<component_interface>&& component);
static bool post_start();
static bool post_load();
static void post_unpack();
static void pre_destroy();
static void clean();
static void* load_import(const std::string& library, const std::string& function);
private:
static std::vector<std::unique_ptr<component_interface>>& get_components();
};
#define REGISTER_COMPONENT(name) \
namespace \
{ \
static component_loader::installer<name> __component; \
}
#pragma once
#include "component_interface.hpp"
class component_loader final
{
public:
template <typename T>
class installer final
{
static_assert(std::is_base_of<component_interface, T>::value, "component has invalid base class");
public:
installer()
{
register_component(std::make_unique<T>());
}
};
template <typename T>
static T* get()
{
for (const auto& component_ : get_components())
{
if (typeid(*component_.get()) == typeid(T))
{
return reinterpret_cast<T*>(component_.get());
}
}
return nullptr;
}
static void register_component(std::unique_ptr<component_interface>&& component);
static bool post_start();
static bool post_load();
static void post_unpack();
static void pre_destroy();
static void clean();
static void* load_import(const std::string& library, const std::string& function);
private:
static std::vector<std::unique_ptr<component_interface>>& get_components();
};
#define REGISTER_COMPONENT(name) \
namespace \
{ \
static component_loader::installer<name> __component; \
}
+80 -72
View File
@@ -1,72 +1,80 @@
#pragma once
#pragma warning(disable: 6011)
#pragma warning(disable: 6054)
#pragma warning(disable: 6387)
#pragma warning(disable: 26451)
#pragma warning(disable: 26812)
#pragma warning(disable: 28182)
#pragma warning(disable: 4324)
#pragma warning(disable: 4459)
#pragma warning(disable: 4611)
#pragma warning(error: 4409)
#define DLL_EXPORT extern "C" __declspec(dllexport)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <vector>
#include <cassert>
#include <mutex>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <regex>
#include <queue>
#include <unordered_set>
#include <filesystem>
#include <map>
#include <csetjmp>
#include <atlcomcli.h>
#include <variant>
#include <optional>
#include <Psapi.h>
#include <timeapi.h>
#ifdef max
#undef max
#endif
#ifdef min
#undef min
#endif
#include <MinHook.h>
#include <gsl/gsl>
#include <json.hpp>
#include <asmjit/core/jitruntime.h>
#include <asmjit/x86/x86assembler.h>
#pragma comment(lib, "ntdll.lib")
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "urlmon.lib" )
#pragma comment(lib, "iphlpapi.lib")
#pragma comment(lib, "Crypt32.lib")
#pragma comment(lib, "Winmm.lib")
#include "utils/hexrays_defs.h"
#undef GetObject
#include "game/game.hpp"
#include "game/enums.hpp"
#include "game/structs.hpp"
#include "game/symbols.hpp"
using namespace std::literals;
#pragma once
#pragma warning(disable: 6011)
#pragma warning(disable: 6054)
#pragma warning(disable: 6387)
#pragma warning(disable: 26451)
#pragma warning(disable: 26812)
#pragma warning(disable: 28182)
#pragma warning(disable: 4324)
#pragma warning(disable: 4459)
#pragma warning(disable: 4611)
#pragma warning(disable: 4359)
#pragma warning(error: 4409)
#define DLL_EXPORT extern "C" __declspec(dllexport)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <vector>
#include <cassert>
#include <mutex>
#include <string>
#include <iostream>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <functional>
#include <regex>
#include <queue>
#include <unordered_set>
#include <filesystem>
#include <map>
#include <csetjmp>
#include <atlcomcli.h>
#include <variant>
#include <optional>
#include <Psapi.h>
#include <timeapi.h>
#ifdef max
#undef max
#endif
#ifdef min
#undef min
#endif
#include <MinHook.h>
#include <gsl/gsl>
#include <json.hpp>
#include <asmjit/core/jitruntime.h>
#include <asmjit/x86/x86assembler.h>
#pragma comment(lib, "ntdll.lib")
#pragma comment(lib, "ws2_32.lib")
#pragma comment(lib, "urlmon.lib" )
#pragma comment(lib, "iphlpapi.lib")
#pragma comment(lib, "Crypt32.lib")
#pragma comment(lib, "Winmm.lib")
#include "utils/hexrays_defs.h"
#include "utils/io.hpp"
#undef GetObject
#include "game/game.hpp"
#include "game/enums.hpp"
#include "game/structs.hpp"
#include "game/symbols.hpp"
std::string build_gsc_dump(game::scriptInstance_t inst);
void push_opcode_history(game::scriptInstance_t inst, game::OpcodeVM op);
void push_builtin_history(game::scriptInstance_t inst, int idx);
void push_codepos_history(game::scriptInstance_t inst, const char* pos);
void print_ast(game::scriptInstance_t inst, game::sval_u node);
using namespace std::literals;
+170 -170
View File
@@ -1,170 +1,170 @@
#include <stdinc.hpp>
#include "memory.hpp"
#include "compression.hpp"
#include <zlib.h>
#include <zip.h>
#include <gsl/gsl>
#include "io.hpp"
namespace utils::compression
{
namespace zlib
{
namespace
{
class zlib_stream
{
public:
zlib_stream()
{
memset(&stream_, 0, sizeof(stream_));
valid_ = inflateInit(&stream_) == Z_OK;
}
zlib_stream(zlib_stream&&) = delete;
zlib_stream(const zlib_stream&) = delete;
zlib_stream& operator=(zlib_stream&&) = delete;
zlib_stream& operator=(const zlib_stream&) = delete;
~zlib_stream()
{
if (valid_)
{
inflateEnd(&stream_);
}
}
z_stream& get()
{
return stream_; //
}
bool is_valid() const
{
return valid_;
}
private:
bool valid_{false};
z_stream stream_{};
};
}
std::string decompress(const std::string& data)
{
std::string buffer{};
zlib_stream stream_container{};
if (!stream_container.is_valid())
{
return {};
}
int ret{};
size_t offset = 0;
static thread_local uint8_t dest[CHUNK] = {0};
auto& stream = stream_container.get();
do
{
const auto input_size = std::min(sizeof(dest), data.size() - offset);
stream.avail_in = static_cast<uInt>(input_size);
stream.next_in = reinterpret_cast<const Bytef*>(data.data()) + offset;
offset += stream.avail_in;
do
{
stream.avail_out = sizeof(dest);
stream.next_out = dest;
ret = inflate(&stream, Z_NO_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END)
{
return {};
}
buffer.insert(buffer.end(), dest, dest + sizeof(dest) - stream.avail_out);
}
while (stream.avail_out == 0);
}
while (ret != Z_STREAM_END);
return buffer;
}
std::string compress(const std::string& data)
{
std::string result{};
auto length = compressBound(static_cast<uLong>(data.size()));
result.resize(length);
if (compress2(reinterpret_cast<Bytef*>(result.data()), &length,
reinterpret_cast<const Bytef*>(data.data()), static_cast<uLong>(data.size()),
Z_BEST_COMPRESSION) != Z_OK)
{
return {};
}
result.resize(length);
return result;
}
}
namespace zip
{
namespace
{
bool add_file(zipFile& zip_file, const std::string& filename, const std::string& data)
{
const auto zip_64 = data.size() > 0xffffffff ? 1 : 0;
if (ZIP_OK != zipOpenNewFileInZip64(zip_file, filename.data(), nullptr, nullptr, 0, nullptr, 0, nullptr,
Z_DEFLATED, Z_BEST_COMPRESSION, zip_64))
{
return false;
}
const auto _ = gsl::finally([&zip_file]()
{
zipCloseFileInZip(zip_file);
});
return ZIP_OK == zipWriteInFileInZip(zip_file, data.data(), static_cast<unsigned>(data.size()));
}
}
void archive::add(std::string filename, std::string data)
{
this->files_[std::move(filename)] = std::move(data);
}
bool archive::write(const std::string& filename, const std::string& comment)
{
// Hack to create the directory :3
io::write_file(filename, {});
io::remove_file(filename);
auto* zip_file = zipOpen64(filename.data(), 0);
if (!zip_file)
{
return false;
}
const auto _ = gsl::finally([&zip_file, &comment]()
{
zipClose(zip_file, comment.empty() ? nullptr : comment.data());
});
for (const auto& file : this->files_)
{
if (!add_file(zip_file, file.first, file.second))
{
return false;
}
}
return true;
}
}
}
#include <stdinc.hpp>
#include "memory.hpp"
#include "compression.hpp"
#include <zlib.h>
#include <zip.h>
#include <gsl/gsl>
#include "io.hpp"
namespace utils::compression
{
namespace zlib
{
namespace
{
class zlib_stream
{
public:
zlib_stream()
{
memset(&stream_, 0, sizeof(stream_));
valid_ = inflateInit(&stream_) == Z_OK;
}
zlib_stream(zlib_stream&&) = delete;
zlib_stream(const zlib_stream&) = delete;
zlib_stream& operator=(zlib_stream&&) = delete;
zlib_stream& operator=(const zlib_stream&) = delete;
~zlib_stream()
{
if (valid_)
{
inflateEnd(&stream_);
}
}
z_stream& get()
{
return stream_; //
}
bool is_valid() const
{
return valid_;
}
private:
bool valid_{false};
z_stream stream_{};
};
}
std::string decompress(const std::string& data)
{
std::string buffer{};
zlib_stream stream_container{};
if (!stream_container.is_valid())
{
return {};
}
int ret{};
size_t offset = 0;
static thread_local uint8_t dest[CHUNK] = {0};
auto& stream = stream_container.get();
do
{
const auto input_size = std::min(sizeof(dest), data.size() - offset);
stream.avail_in = static_cast<uInt>(input_size);
stream.next_in = reinterpret_cast<const Bytef*>(data.data()) + offset;
offset += stream.avail_in;
do
{
stream.avail_out = sizeof(dest);
stream.next_out = dest;
ret = inflate(&stream, Z_NO_FLUSH);
if (ret != Z_OK && ret != Z_STREAM_END)
{
return {};
}
buffer.insert(buffer.end(), dest, dest + sizeof(dest) - stream.avail_out);
}
while (stream.avail_out == 0);
}
while (ret != Z_STREAM_END);
return buffer;
}
std::string compress(const std::string& data)
{
std::string result{};
auto length = compressBound(static_cast<uLong>(data.size()));
result.resize(length);
if (compress2(reinterpret_cast<Bytef*>(result.data()), &length,
reinterpret_cast<const Bytef*>(data.data()), static_cast<uLong>(data.size()),
Z_BEST_COMPRESSION) != Z_OK)
{
return {};
}
result.resize(length);
return result;
}
}
namespace zip
{
namespace
{
bool add_file(zipFile& zip_file, const std::string& filename, const std::string& data)
{
const auto zip_64 = data.size() > 0xffffffff ? 1 : 0;
if (ZIP_OK != zipOpenNewFileInZip64(zip_file, filename.data(), nullptr, nullptr, 0, nullptr, 0, nullptr,
Z_DEFLATED, Z_BEST_COMPRESSION, zip_64))
{
return false;
}
const auto _ = gsl::finally([&zip_file]()
{
zipCloseFileInZip(zip_file);
});
return ZIP_OK == zipWriteInFileInZip(zip_file, data.data(), static_cast<unsigned>(data.size()));
}
}
void archive::add(std::string filename, std::string data)
{
this->files_[std::move(filename)] = std::move(data);
}
bool archive::write(const std::string& filename, const std::string& comment)
{
// Hack to create the directory :3
io::write_file(filename, {});
io::remove_file(filename);
auto* zip_file = zipOpen64(filename.data(), 0);
if (!zip_file)
{
return false;
}
const auto _ = gsl::finally([&zip_file, &comment]()
{
zipClose(zip_file, comment.empty() ? nullptr : comment.data());
});
for (const auto& file : this->files_)
{
if (!add_file(zip_file, file.first, file.second))
{
return false;
}
}
return true;
}
}
}
+28 -28
View File
@@ -1,28 +1,28 @@
#pragma once
#include <string>
#include <unordered_map>
#define CHUNK 16384u
namespace utils::compression
{
namespace zlib
{
std::string compress(const std::string& data);
std::string decompress(const std::string& data);
}
namespace zip
{
class archive
{
public:
void add(std::string filename, std::string data);
bool write(const std::string& filename, const std::string& comment = {});
private:
std::unordered_map<std::string, std::string> files_;
};
}
};
#pragma once
#include <string>
#include <unordered_map>
#define CHUNK 16384u
namespace utils::compression
{
namespace zlib
{
std::string compress(const std::string& data);
std::string decompress(const std::string& data);
}
namespace zip
{
class archive
{
public:
void add(std::string filename, std::string data);
bool write(const std::string& filename, const std::string& comment = {});
private:
std::unordered_map<std::string, std::string> files_;
};
}
};
+46 -46
View File
@@ -1,46 +1,46 @@
#pragma once
#include <mutex>
namespace utils::concurrency
{
template <typename T, typename MutexType = std::mutex>
class container
{
public:
template <typename R = void, typename F>
R access(F&& accessor) const
{
std::lock_guard<MutexType> _{mutex_};
return accessor(object_);
}
template <typename R = void, typename F>
R access(F&& accessor)
{
std::lock_guard<MutexType> _{mutex_};
return accessor(object_);
}
template <typename R = void, typename F>
R access_with_lock(F&& accessor) const
{
std::unique_lock<MutexType> lock{mutex_};
return accessor(object_, lock);
}
template <typename R = void, typename F>
R access_with_lock(F&& accessor)
{
std::unique_lock<MutexType> lock{mutex_};
return accessor(object_, lock);
}
T& get_raw() { return object_; }
const T& get_raw() const { return object_; }
private:
mutable MutexType mutex_{};
T object_{};
};
}
#pragma once
#include <mutex>
namespace utils::concurrency
{
template <typename T, typename MutexType = std::mutex>
class container
{
public:
template <typename R = void, typename F>
R access(F&& accessor) const
{
std::lock_guard<MutexType> _{mutex_};
return accessor(object_);
}
template <typename R = void, typename F>
R access(F&& accessor)
{
std::lock_guard<MutexType> _{mutex_};
return accessor(object_);
}
template <typename R = void, typename F>
R access_with_lock(F&& accessor) const
{
std::unique_lock<MutexType> lock{mutex_};
return accessor(object_, lock);
}
template <typename R = void, typename F>
R access_with_lock(F&& accessor)
{
std::unique_lock<MutexType> lock{mutex_};
return accessor(object_, lock);
}
T& get_raw() { return object_; }
const T& get_raw() const { return object_; }
private:
mutable MutexType mutex_{};
T object_{};
};
}
+54 -54
View File
@@ -1,54 +1,54 @@
#include <stdinc.hpp>
#include "flags.hpp"
#include "string.hpp"
#include <shellapi.h>
namespace utils::flags
{
void parse_flags(std::vector<std::string>& flags)
{
int num_args;
auto* const argv = CommandLineToArgvW(GetCommandLineW(), &num_args);
flags.clear();
if (argv)
{
for (auto i = 0; i < num_args; ++i)
{
std::wstring wide_flag(argv[i]);
if (wide_flag[0] == L'-')
{
wide_flag.erase(wide_flag.begin());
flags.emplace_back(string::convert(wide_flag));
}
}
LocalFree(argv);
}
}
bool has_flag(const std::string& flag)
{
static auto parsed = false;
static std::vector<std::string> enabled_flags;
if (!parsed)
{
parse_flags(enabled_flags);
parsed = true;
}
for (const auto& entry : enabled_flags)
{
if (string::to_lower(entry) == string::to_lower(flag))
{
return true;
}
}
return false;
}
}
#include <stdinc.hpp>
#include "flags.hpp"
#include "string.hpp"
#include <shellapi.h>
namespace utils::flags
{
void parse_flags(std::vector<std::string>& flags)
{
int num_args;
auto* const argv = CommandLineToArgvW(GetCommandLineW(), &num_args);
flags.clear();
if (argv)
{
for (auto i = 0; i < num_args; ++i)
{
std::wstring wide_flag(argv[i]);
if (wide_flag[0] == L'-')
{
wide_flag.erase(wide_flag.begin());
flags.emplace_back(string::convert(wide_flag));
}
}
LocalFree(argv);
}
}
bool has_flag(const std::string& flag)
{
static auto parsed = false;
static std::vector<std::string> enabled_flags;
if (!parsed)
{
parse_flags(enabled_flags);
parsed = true;
}
for (const auto& entry : enabled_flags)
{
if (string::to_lower(entry) == string::to_lower(flag))
{
return true;
}
}
return false;
}
}
+6 -6
View File
@@ -1,6 +1,6 @@
#pragma once
namespace utils::flags
{
bool has_flag(const std::string& flag);
}
#pragma once
namespace utils::flags
{
bool has_flag(const std::string& flag);
}
+83 -83
View File
@@ -10,26 +10,26 @@
*/
#if defined(__GNUC__)
typedef long long ll;
typedef unsigned long long ull;
#define __int64 long long
#define __int32 int
#define __int16 short
#define __int8 char
#define MAKELL(num) num ## LL
#define FMT_64 "ll"
typedef long long ll;
typedef unsigned long long ull;
#define __int64 long long
#define __int32 int
#define __int16 short
#define __int8 char
#define MAKELL(num) num ## LL
#define FMT_64 "ll"
#elif defined(_MSC_VER)
typedef __int64 ll;
typedef unsigned __int64 ull;
#define MAKELL(num) num ## i64
#define FMT_64 "I64"
typedef __int64 ll;
typedef unsigned __int64 ull;
#define MAKELL(num) num ## i64
#define FMT_64 "I64"
#elif defined (__BORLANDC__)
typedef __int64 ll;
typedef unsigned __int64 ull;
#define MAKELL(num) num ## i64
#define FMT_64 "L"
typedef __int64 ll;
typedef unsigned __int64 ull;
#define MAKELL(num) num ## i64
#define FMT_64 "L"
#else
#error "unknown compiler"
#error "unknown compiler"
#endif
typedef unsigned int uint;
typedef unsigned char uchar;
@@ -152,9 +152,9 @@ typedef int bool; // we want to use bool in our C programs
// Fill memory block with an integer value
inline void memset32(void *ptr, uint32 value, int count)
{
uint32 *p = (uint32 *)ptr;
for ( int i=0; i < count; i++ )
*p++ = value;
uint32 *p = (uint32 *)ptr;
for ( int i=0; i < count; i++ )
*p++ = value;
}
// Generate a reference to pair of operands
@@ -168,112 +168,112 @@ template<class T> uint64 __PAIR__(uint32 high, T low) { return (((uint64)high) <
// rotate left
template<class T> T __ROL__(T value, uint count)
{
const uint nbits = sizeof(T) * 8;
count %= nbits;
const uint nbits = sizeof(T) * 8;
count %= nbits;
T high = value >> (nbits - count);
value <<= count;
value |= high;
return value;
T high = value >> (nbits - count);
value <<= count;
value |= high;
return value;
}
// rotate right
template<class T> T __ROR__(T value, uint count)
{
const uint nbits = sizeof(T) * 8;
count %= nbits;
const uint nbits = sizeof(T) * 8;
count %= nbits;
T low = value << (nbits - count);
value >>= count;
value |= low;
return value;
T low = value << (nbits - count);
value >>= count;
value |= low;
return value;
}
// carry flag of left shift
template<class T> int8 __MKCSHL__(T value, uint count)
{
const uint nbits = sizeof(T) * 8;
count %= nbits;
const uint nbits = sizeof(T) * 8;
count %= nbits;
return (value >> (nbits-count)) & 1;
return (value >> (nbits-count)) & 1;
}
// carry flag of right shift
template<class T> int8 __MKCSHR__(T value, uint count)
{
return (value >> (count-1)) & 1;
return (value >> (count-1)) & 1;
}
// sign flag
template<class T> int8 __SETS__(T x)
{
if ( sizeof(T) == 1 )
return int8(x) < 0;
if ( sizeof(T) == 2 )
return int16(x) < 0;
if ( sizeof(T) == 4 )
return int32(x) < 0;
return int64(x) < 0;
if ( sizeof(T) == 1 )
return int8(x) < 0;
if ( sizeof(T) == 2 )
return int16(x) < 0;
if ( sizeof(T) == 4 )
return int32(x) < 0;
return int64(x) < 0;
}
// overflow flag of subtraction (x-y)
template<class T, class U> int8 __OFSUB__(T x, U y)
{
if ( sizeof(T) < sizeof(U) )
{
U x2 = x;
int8 sx = __SETS__(x2);
return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2-y));
}
else
{
T y2 = y;
int8 sx = __SETS__(x);
return (sx ^ __SETS__(y2)) & (sx ^ __SETS__(x-y2));
}
if ( sizeof(T) < sizeof(U) )
{
U x2 = x;
int8 sx = __SETS__(x2);
return (sx ^ __SETS__(y)) & (sx ^ __SETS__(x2-y));
}
else
{
T y2 = y;
int8 sx = __SETS__(x);
return (sx ^ __SETS__(y2)) & (sx ^ __SETS__(x-y2));
}
}
// overflow flag of addition (x+y)
template<class T, class U> int8 __OFADD__(T x, U y)
{
if ( sizeof(T) < sizeof(U) )
{
U x2 = x;
int8 sx = __SETS__(x2);
return ((1 ^ sx) ^ __SETS__(y)) & (sx ^ __SETS__(x2+y));
}
else
{
T y2 = y;
int8 sx = __SETS__(x);
return ((1 ^ sx) ^ __SETS__(y2)) & (sx ^ __SETS__(x+y2));
}
if ( sizeof(T) < sizeof(U) )
{
U x2 = x;
int8 sx = __SETS__(x2);
return ((1 ^ sx) ^ __SETS__(y)) & (sx ^ __SETS__(x2+y));
}
else
{
T y2 = y;
int8 sx = __SETS__(x);
return ((1 ^ sx) ^ __SETS__(y2)) & (sx ^ __SETS__(x+y2));
}
}
// carry flag of subtraction (x-y)
template<class T, class U> int8 __CFSUB__(T x, U y)
{
int size = sizeof(T) > sizeof(U) ? sizeof(T) : sizeof(U);
if ( size == 1 )
return uint8(x) < uint8(y);
if ( size == 2 )
return uint16(x) < uint16(y);
if ( size == 4 )
return uint32(x) < uint32(y);
return uint64(x) < uint64(y);
int size = sizeof(T) > sizeof(U) ? sizeof(T) : sizeof(U);
if ( size == 1 )
return uint8(x) < uint8(y);
if ( size == 2 )
return uint16(x) < uint16(y);
if ( size == 4 )
return uint32(x) < uint32(y);
return uint64(x) < uint64(y);
}
// carry flag of addition (x+y)
template<class T, class U> int8 __CFADD__(T x, U y)
{
int size = sizeof(T) > sizeof(U) ? sizeof(T) : sizeof(U);
if ( size == 1 )
return uint8(x) > uint8(x+y);
if ( size == 2 )
return uint16(x) > uint16(x+y);
if ( size == 4 )
return uint32(x) > uint32(x+y);
return uint64(x) > uint64(x+y);
int size = sizeof(T) > sizeof(U) ? sizeof(T) : sizeof(U);
if ( size == 1 )
return uint8(x) > uint8(x+y);
if ( size == 2 )
return uint16(x) > uint16(x+y);
if ( size == 4 )
return uint32(x) > uint32(x+y);
return uint64(x) > uint64(x+y);
}
#else
+257 -251
View File
@@ -1,252 +1,258 @@
#include <stdinc.hpp>
#include "hook.hpp"
#include "string.hpp"
// iw6x-client
namespace utils::hook
{
void signature::process()
{
if (this->signatures_.empty()) return;
const auto start = static_cast<char*>(this->start_);
const unsigned int sig_count = this->signatures_.size();
const auto containers = this->signatures_.data();
for (size_t i = 0; i < this->length_; ++i)
{
const auto address = start + i;
for (unsigned int k = 0; k < sig_count; ++k)
{
const auto container = &containers[k];
unsigned int j;
for (j = 0; j < static_cast<unsigned int>(container->mask.size()); ++j)
{
if (container->mask[j] != '?' && container->signature[j] != address[j])
{
break;
}
}
if (j == container->mask.size())
{
container->callback(address);
}
}
}
}
void signature::add(const container& container)
{
signatures_.push_back(container);
}
namespace
{
[[maybe_unused]] class _
{
public:
_()
{
if (MH_Initialize() != MH_OK)
{
throw std::runtime_error("Failed to initialize MinHook");
}
}
~_()
{
MH_Uninitialize();
}
} __;
}
asmjit::Error assembler::call(void* target)
{
return Assembler::call(size_t(target));
}
asmjit::Error assembler::jmp(void* target)
{
return Assembler::jmp(size_t(target));
}
detour::detour(const size_t place, void* target) : detour(reinterpret_cast<void*>(place), target)
{
}
detour::detour(void* place, void* target)
{
this->create(place, target);
}
detour::~detour()
{
this->clear();
}
void detour::enable() const
{
MH_EnableHook(this->place_);
}
void detour::disable() const
{
MH_DisableHook(this->place_);
}
void detour::create(void* place, void* target)
{
this->clear();
this->place_ = place;
if (MH_CreateHook(this->place_, target, &this->original_) != MH_OK)
{
throw std::runtime_error(string::va("Unable to create hook at location: %p", this->place_));
}
this->enable();
}
void detour::create(const size_t place, void* target)
{
this->create(reinterpret_cast<void*>(place), target);
}
void detour::clear()
{
if (this->place_)
{
MH_RemoveHook(this->place_);
}
this->place_ = nullptr;
this->original_ = nullptr;
}
void* detour::get_original() const
{
return this->original_;
}
void nop(void* place, const size_t length)
{
DWORD old_protect{};
VirtualProtect(place, length, PAGE_EXECUTE_READWRITE, &old_protect);
std::memset(place, 0x90, length);
VirtualProtect(place, length, old_protect, &old_protect);
FlushInstructionCache(GetCurrentProcess(), place, length);
}
void nop(const size_t place, const size_t length)
{
nop(reinterpret_cast<void*>(place), length);
}
void copy(void* place, const void* data, const size_t length)
{
DWORD old_protect{};
VirtualProtect(place, length, PAGE_EXECUTE_READWRITE, &old_protect);
std::memmove(place, data, length);
VirtualProtect(place, length, old_protect, &old_protect);
FlushInstructionCache(GetCurrentProcess(), place, length);
}
void copy(const size_t place, const void* data, const size_t length)
{
copy(reinterpret_cast<void*>(place), data, length);
}
bool is_relatively_far(const void* pointer, const void* data, int offset)
{
const int64_t diff = size_t(data) - (size_t(pointer) + offset);
const auto small_diff = int32_t(diff);
return diff != int64_t(small_diff);
}
void call(void* pointer, void* data)
{
if (is_relatively_far(pointer, data))
{
throw std::runtime_error("Too far away to create 32bit relative branch");
}
auto* patch_pointer = PBYTE(pointer);
set<uint8_t>(patch_pointer, 0xE8);
set<int32_t>(patch_pointer + 1, int32_t(size_t(data) - (size_t(pointer) + 5)));
}
void call(const size_t pointer, void* data)
{
return call(reinterpret_cast<void*>(pointer), data);
}
void call(const size_t pointer, const size_t data)
{
return call(pointer, reinterpret_cast<void*>(data));
}
void set(std::uintptr_t address, std::vector<std::uint8_t>&& bytes)
{
DWORD oldProtect = 0;
auto* place = reinterpret_cast<void*>(address);
VirtualProtect(place, bytes.size(), PAGE_EXECUTE_READWRITE, &oldProtect);
memcpy(place, bytes.data(), bytes.size());
VirtualProtect(place, bytes.size(), oldProtect, &oldProtect);
FlushInstructionCache(GetCurrentProcess(), place, bytes.size());
}
void set(std::uintptr_t address, void* buffer, size_t size)
{
DWORD oldProtect = 0;
auto* place = reinterpret_cast<void*>(address);
VirtualProtect(place, size, PAGE_EXECUTE_READWRITE, &oldProtect);
memcpy(place, buffer, size);
VirtualProtect(place, size, oldProtect, &oldProtect);
FlushInstructionCache(GetCurrentProcess(), place, size);
}
void jump(std::uintptr_t address, void* destination)
{
if (!address) return;
std::uint8_t* bytes = new std::uint8_t[5];
*bytes = 0xE9;
*reinterpret_cast<std::uint32_t*>(bytes + 1) = CalculateRelativeJMPAddress(address, destination);
set(address, bytes, 5);
delete[] bytes;
}
void* assemble(const std::function<void(assembler&)>& asm_function)
{
static asmjit::JitRuntime runtime;
asmjit::CodeHolder code;
code.init(runtime.environment());
assembler a(&code);
asm_function(a);
void* result = nullptr;
runtime.add(&result, &code);
return result;
}
void* get_displacement_addr(int original)
{
return reinterpret_cast<void*>(*reinterpret_cast<int*>(original + 1) + original + 5);
}
#include <stdinc.hpp>
#include "hook.hpp"
#include "string.hpp"
namespace utils::hook
{
void signature::process()
{
if (this->signatures_.empty()) return;
const auto start = static_cast<char*>(this->start_);
const unsigned int sig_count = this->signatures_.size();
const auto containers = this->signatures_.data();
for (size_t i = 0; i < this->length_; ++i)
{
const auto address = start + i;
for (unsigned int k = 0; k < sig_count; ++k)
{
const auto container = &containers[k];
unsigned int j;
for (j = 0; j < static_cast<unsigned int>(container->mask.size()); ++j)
{
if (container->mask[j] != '?' && container->signature[j] != address[j])
{
break;
}
}
if (j == container->mask.size())
{
container->callback(address);
}
}
}
}
void signature::add(const container& container)
{
signatures_.push_back(container);
}
namespace
{
[[maybe_unused]] class _
{
public:
_()
{
if (MH_Initialize() != MH_OK)
{
throw std::runtime_error("Failed to initialize MinHook");
}
}
~_()
{
MH_Uninitialize();
}
} __;
}
asmjit::Error assembler::call(void* target)
{
return Assembler::call(size_t(target));
}
asmjit::Error assembler::jmp(void* target)
{
return Assembler::jmp(size_t(target));
}
detour::detour(const size_t place, void* target) : detour(reinterpret_cast<void*>(place), target)
{
}
detour::detour(void* place, void* target)
{
this->create(place, target);
}
detour::~detour()
{
this->clear();
}
void detour::enable() const
{
MH_EnableHook(this->place_);
}
void detour::disable() const
{
MH_DisableHook(this->place_);
}
void detour::create(void* place, void* target, bool quick)
{
// each detour is ~30ms to install, quick is for instances where we will NEVER need to invoke the original
if (quick)
{
jump(reinterpret_cast<std::uintptr_t>(place), target);
return;
}
this->clear();
this->place_ = place;
if (MH_CreateHook(this->place_, target, &this->original_) != MH_OK)
{
throw std::runtime_error(string::va("Unable to create hook at location: %p", this->place_));
}
this->enable();
}
void detour::create(const size_t place, void* target, bool quick)
{
this->create(reinterpret_cast<void*>(place), target, quick);
}
void detour::clear()
{
if (this->place_)
{
MH_RemoveHook(this->place_);
}
this->place_ = nullptr;
this->original_ = nullptr;
}
void* detour::get_original() const
{
return this->original_;
}
void nop(void* place, const size_t length)
{
DWORD old_protect{};
VirtualProtect(place, length, PAGE_EXECUTE_READWRITE, &old_protect);
std::memset(place, 0x90, length);
VirtualProtect(place, length, old_protect, &old_protect);
FlushInstructionCache(GetCurrentProcess(), place, length);
}
void nop(const size_t place, const size_t length)
{
nop(reinterpret_cast<void*>(place), length);
}
void copy(void* place, const void* data, const size_t length)
{
DWORD old_protect{};
VirtualProtect(place, length, PAGE_EXECUTE_READWRITE, &old_protect);
std::memmove(place, data, length);
VirtualProtect(place, length, old_protect, &old_protect);
FlushInstructionCache(GetCurrentProcess(), place, length);
}
void copy(const size_t place, const void* data, const size_t length)
{
copy(reinterpret_cast<void*>(place), data, length);
}
bool is_relatively_far(const void* pointer, const void* data, int offset)
{
const int64_t diff = size_t(data) - (size_t(pointer) + offset);
const auto small_diff = int32_t(diff);
return diff != int64_t(small_diff);
}
void call(void* pointer, void* data)
{
if (is_relatively_far(pointer, data))
{
throw std::runtime_error("Too far away to create 32bit relative branch");
}
auto* patch_pointer = PBYTE(pointer);
set<uint8_t>(patch_pointer, 0xE8);
set<int32_t>(patch_pointer + 1, int32_t(size_t(data) - (size_t(pointer) + 5)));
}
void call(const size_t pointer, void* data)
{
return call(reinterpret_cast<void*>(pointer), data);
}
void call(const size_t pointer, const size_t data)
{
return call(pointer, reinterpret_cast<void*>(data));
}
void set(std::uintptr_t address, std::vector<std::uint8_t>&& bytes)
{
DWORD oldProtect = 0;
auto* place = reinterpret_cast<void*>(address);
VirtualProtect(place, bytes.size(), PAGE_EXECUTE_READWRITE, &oldProtect);
memcpy(place, bytes.data(), bytes.size());
VirtualProtect(place, bytes.size(), oldProtect, &oldProtect);
FlushInstructionCache(GetCurrentProcess(), place, bytes.size());
}
void set(std::uintptr_t address, void* buffer, size_t size)
{
DWORD oldProtect = 0;
auto* place = reinterpret_cast<void*>(address);
VirtualProtect(place, size, PAGE_EXECUTE_READWRITE, &oldProtect);
memcpy(place, buffer, size);
VirtualProtect(place, size, oldProtect, &oldProtect);
FlushInstructionCache(GetCurrentProcess(), place, size);
}
void jump(std::uintptr_t address, void* destination)
{
if (!address) return;
std::uint8_t* bytes = new std::uint8_t[5];
*bytes = 0xE9;
*reinterpret_cast<std::uint32_t*>(bytes + 1) = CalculateRelativeJMPAddress(address, destination);
set(address, bytes, 5);
delete[] bytes;
}
void* assemble(const std::function<void(assembler&)>& asm_function)
{
static asmjit::JitRuntime runtime;
asmjit::CodeHolder code;
code.init(runtime.environment());
assembler a(&code);
asm_function(a);
void* result = nullptr;
runtime.add(&result, &code);
return result;
}
void* get_displacement_addr(int original)
{
return reinterpret_cast<void*>(*reinterpret_cast<int*>(original + 1) + original + 5);
}
}
+232 -166
View File
@@ -1,167 +1,233 @@
#pragma once
#define CalculateRelativeJMPAddress(X, Y) (((std::uintptr_t)Y - (std::uintptr_t)X) - 5)
#include <asmjit/core/jitruntime.h>
#include <asmjit/x86/x86assembler.h>
using namespace asmjit::x86;
namespace utils::hook
{
class signature final
{
public:
struct container final
{
std::string signature;
std::string mask;
std::function<void(char*)> callback;
};
signature(void* start, const size_t length) : start_(start), length_(length)
{
}
signature(const DWORD start, const size_t length) : signature(reinterpret_cast<void*>(start), length)
{
}
signature() : signature(0x400000, 0x800000)
{
}
void process();
void add(const container& container);
private:
void* start_;
size_t length_;
std::vector<container> signatures_;
};
class assembler : public Assembler
{
public:
using Assembler::Assembler;
using Assembler::call;
using Assembler::jmp;
asmjit::Error call(void* target);
asmjit::Error jmp(void* target);
};
class detour
{
public:
detour() = default;
detour(void* place, void* target);
detour(size_t place, void* target);
~detour();
detour(detour&& other) noexcept
{
this->operator=(std::move(other));
}
detour& operator= (detour&& other) noexcept
{
if (this != &other)
{
this->~detour();
this->place_ = other.place_;
this->original_ = other.original_;
other.place_ = nullptr;
other.original_ = nullptr;
}
return *this;
}
detour(const detour&) = delete;
detour& operator= (const detour&) = delete;
void enable() const;
void disable() const;
void create(void* place, void* target);
void create(size_t place, void* target);
void clear();
template <typename T>
T* get() const
{
return static_cast<T*>(this->get_original());
}
template <typename T, typename... Args>
T invoke(Args... args)
{
return static_cast<T(*)(Args ...)>(this->get_original())(args...);
}
[[nodiscard]] void* get_original() const;
private:
void* place_{};
void* original_{};
};
void nop(void* place, size_t length);
void nop(size_t place, size_t length);
void copy(void* place, const void* data, size_t length);
void copy(size_t place, const void* data, size_t length);
bool is_relatively_far(const void* pointer, const void* data, int offset = 5);
void call(void* pointer, void* data);
void call(size_t pointer, void* data);
void call(size_t pointer, size_t data);
void jump(std::uintptr_t address, void* destination);
void* assemble(const std::function<void(assembler&)>& asm_function);
void* get_displacement_addr(int original);
template <typename T>
T extract(void* address)
{
const auto data = static_cast<uint8_t*>(address);
const auto offset = *reinterpret_cast<int32_t*>(data);
return reinterpret_cast<T>(data + offset + 4);
}
template <typename T>
static void set(void* place, T value)
{
DWORD old_protect;
VirtualProtect(place, sizeof(T), PAGE_EXECUTE_READWRITE, &old_protect);
*static_cast<T*>(place) = value;
VirtualProtect(place, sizeof(T), old_protect, &old_protect);
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
}
template <typename T>
static void set(const size_t place, T value)
{
return set<T>(reinterpret_cast<void*>(place), value);
}
template <typename T, typename... Args>
static T invoke(size_t func, Args... args)
{
return reinterpret_cast<T(*)(Args ...)>(func)(args...);
}
template <typename T, typename... Args>
static T invoke(void* func, Args... args)
{
return static_cast<T(*)(Args ...)>(func)(args...);
}
#pragma once
#define CalculateRelativeJMPAddress(X, Y) (((std::uintptr_t)Y - (std::uintptr_t)X) - 5)
#include <asmjit/core/jitruntime.h>
#include <asmjit/x86/x86assembler.h>
using namespace asmjit::x86;
namespace utils::hook
{
class signature final
{
public:
struct container final
{
std::string signature;
std::string mask;
std::function<void(char*)> callback;
};
signature(void* start, const size_t length) : start_(start), length_(length)
{
}
signature(const DWORD start, const size_t length) : signature(reinterpret_cast<void*>(start), length)
{
}
signature() : signature(0x400000, 0x800000)
{
}
void process();
void add(const container& container);
private:
void* start_;
size_t length_;
std::vector<container> signatures_;
};
class assembler : public Assembler
{
public:
using Assembler::Assembler;
using Assembler::call;
using Assembler::jmp;
asmjit::Error call(void* target);
asmjit::Error jmp(void* target);
};
class detour
{
public:
detour() = default;
detour(void* place, void* target);
detour(size_t place, void* target);
~detour();
detour(detour&& other) noexcept
{
this->operator=(std::move(other));
}
detour& operator= (detour&& other) noexcept
{
if (this != &other)
{
this->~detour();
this->place_ = other.place_;
this->original_ = other.original_;
other.place_ = nullptr;
other.original_ = nullptr;
}
return *this;
}
detour(const detour&) = delete;
detour& operator= (const detour&) = delete;
void enable() const;
void disable() const;
void create(void* place, void* target, bool quick = false);
void create(size_t place, void* target, bool quick = false);
void clear();
template <typename T>
T* get() const
{
return static_cast<T*>(this->get_original());
}
template <typename T, typename... Args>
T invoke(Args... args)
{
return static_cast<T(__cdecl*)(Args ...)>(this->get_original())(args...);
}
template <typename T, typename... Args>
T invoke_pascal(Args... args)
{
return static_cast<T(__stdcall*)(Args ...)>(this->get_original())(args...);
}
template <typename T, typename... Args>
T invoke_this(Args... args)
{
return static_cast<T(__thiscall*)(Args ...)>(this->get_original())(args...);
}
template <typename T, typename... Args>
T invoke_fast(Args... args)
{
return static_cast<T(__fastcall*)(Args ...)>(this->get_original())(args...);
}
[[nodiscard]] void* get_original() const;
private:
void* place_{};
void* original_{};
};
void nop(void* place, size_t length);
void nop(size_t place, size_t length);
void copy(void* place, const void* data, size_t length);
void copy(size_t place, const void* data, size_t length);
bool is_relatively_far(const void* pointer, const void* data, int offset = 5);
void call(void* pointer, void* data);
void call(size_t pointer, void* data);
void call(size_t pointer, size_t data);
void jump(std::uintptr_t address, void* destination);
void* assemble(const std::function<void(assembler&)>& asm_function);
void* get_displacement_addr(int original);
template <typename T>
T extract(void* address)
{
const auto data = static_cast<uint8_t*>(address);
const auto offset = *reinterpret_cast<int32_t*>(data);
return reinterpret_cast<T>(data + offset + 4);
}
template <typename T>
static void set(void* place, T value)
{
DWORD old_protect;
VirtualProtect(place, sizeof(T), PAGE_EXECUTE_READWRITE, &old_protect);
*static_cast<T*>(place) = value;
VirtualProtect(place, sizeof(T), old_protect, &old_protect);
FlushInstructionCache(GetCurrentProcess(), place, sizeof(T));
}
template <typename T>
static void set(const size_t place, T value)
{
return set<T>(reinterpret_cast<void*>(place), value);
}
template <typename T>
static T get(void* place)
{
return *static_cast<T*>(place);
}
template <typename T>
static T get(const size_t place)
{
return get<T>(reinterpret_cast<void*>(place));
}
template <typename T, typename... Args>
static T invoke(size_t func, Args... args)
{
return reinterpret_cast<T(__cdecl*)(Args ...)>(func)(args...);
}
template <typename T, typename... Args>
static T invoke(void* func, Args... args)
{
return static_cast<T(__cdecl*)(Args ...)>(func)(args...);
}
template <typename T, typename... Args>
static T invoke_pascal(size_t func, Args... args)
{
return reinterpret_cast<T(__stdcall*)(Args ...)>(func)(args...);
}
template <typename T, typename... Args>
static T invoke_pascal(void* func, Args... args)
{
return static_cast<T(__stdcall*)(Args ...)>(func)(args...);
}
template <typename T, typename... Args>
static T invoke_this(size_t func, Args... args)
{
return reinterpret_cast<T(__thiscall*)(Args ...)>(func)(args...);
}
template <typename T, typename... Args>
static T invoke_this(void* func, Args... args)
{
return static_cast<T(__thiscall*)(Args ...)>(func)(args...);
}
template <typename T, typename... Args>
static T invoke_fast(size_t func, Args... args)
{
return reinterpret_cast<T(__fastcall*)(Args ...)>(func)(args...);
}
template <typename T, typename... Args>
static T invoke_fast(void* func, Args... args)
{
return static_cast<T(__fastcall*)(Args ...)>(func)(args...);
}
}
+90 -90
View File
@@ -1,91 +1,91 @@
#include <stdinc.hpp>
#include "http.hpp"
#include <curl/curl.h>
#include <gsl/gsl>
#pragma comment(lib, "ws2_32.lib")
namespace utils::http
{
namespace
{
struct progress_helper
{
const std::function<bool(size_t)>* callback{};
};
#pragma warning(push)
#pragma warning(disable: 4244)
int progress_callback(void* clientp, const curl_off_t /*dltotal*/, const curl_off_t dlnow, const curl_off_t /*ultotal*/, const curl_off_t /*ulnow*/)
{
auto* helper = static_cast<progress_helper*>(clientp);
if (*helper->callback && !(*helper->callback)(dlnow))
{
return -1;
}
return 0;
}
#pragma warning(pop)
size_t write_callback(void* contents, const size_t size, const size_t nmemb, void* userp)
{
auto* buffer = static_cast<std::string*>(userp);
const auto total_size = size * nmemb;
buffer->append(static_cast<char*>(contents), total_size);
return total_size;
}
}
std::optional<std::string> get_data(const std::string& url, const headers& headers, const std::function<bool(size_t)>& callback)
{
curl_slist* header_list = nullptr;
auto* curl = curl_easy_init();
if (!curl)
{
return {};
}
auto _ = gsl::finally([&]()
{
curl_slist_free_all(header_list);
curl_easy_cleanup(curl);
});
for (const auto& header : headers)
{
auto data = header.first + ": " + header.second;
header_list = curl_slist_append(header_list, data.data());
}
std::string buffer{};
progress_helper helper{};
helper.callback = &callback;
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header_list);
curl_easy_setopt(curl, CURLOPT_URL, url.data());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback);
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &helper);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
if (curl_easy_perform(curl) == CURLE_OK)
{
return {std::move(buffer)};
}
return {};
}
std::future<std::optional<std::string>> get_data_async(const std::string& url, const headers& headers)
{
return std::async(std::launch::async, [url, headers]()
{
return get_data(url, headers);
});
}
#include <stdinc.hpp>
#include "http.hpp"
#include <curl/curl.h>
#include <gsl/gsl>
#pragma comment(lib, "ws2_32.lib")
namespace utils::http
{
namespace
{
struct progress_helper
{
const std::function<bool(size_t)>* callback{};
};
#pragma warning(push)
#pragma warning(disable: 4244)
int progress_callback(void* clientp, const curl_off_t /*dltotal*/, const curl_off_t dlnow, const curl_off_t /*ultotal*/, const curl_off_t /*ulnow*/)
{
auto* helper = static_cast<progress_helper*>(clientp);
if (*helper->callback && !(*helper->callback)(dlnow))
{
return -1;
}
return 0;
}
#pragma warning(pop)
size_t write_callback(void* contents, const size_t size, const size_t nmemb, void* userp)
{
auto* buffer = static_cast<std::string*>(userp);
const auto total_size = size * nmemb;
buffer->append(static_cast<char*>(contents), total_size);
return total_size;
}
}
std::optional<std::string> get_data(const std::string& url, const headers& headers, const std::function<bool(size_t)>& callback)
{
curl_slist* header_list = nullptr;
auto* curl = curl_easy_init();
if (!curl)
{
return {};
}
auto _ = gsl::finally([&]()
{
curl_slist_free_all(header_list);
curl_easy_cleanup(curl);
});
for (const auto& header : headers)
{
auto data = header.first + ": " + header.second;
header_list = curl_slist_append(header_list, data.data());
}
std::string buffer{};
progress_helper helper{};
helper.callback = &callback;
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, header_list);
curl_easy_setopt(curl, CURLOPT_URL, url.data());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, progress_callback);
curl_easy_setopt(curl, CURLOPT_XFERINFODATA, &helper);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0);
if (curl_easy_perform(curl) == CURLE_OK)
{
return {std::move(buffer)};
}
return {};
}
std::future<std::optional<std::string>> get_data_async(const std::string& url, const headers& headers)
{
return std::async(std::launch::async, [url, headers]()
{
return get_data(url, headers);
});
}
}
+12 -12
View File
@@ -1,13 +1,13 @@
#pragma once
#include <string>
#include <optional>
#include <future>
namespace utils::http
{
using headers = std::unordered_map<std::string, std::string>;
std::optional<std::string> get_data(const std::string& url, const headers& headers = {}, const std::function<bool(size_t)>& callback = {});
std::future<std::optional<std::string>> get_data_async(const std::string& url, const headers& headers = {});
#pragma once
#include <string>
#include <optional>
#include <future>
namespace utils::http
{
using headers = std::unordered_map<std::string, std::string>;
std::optional<std::string> get_data(const std::string& url, const headers& headers = {}, const std::function<bool(size_t)>& callback = {});
std::future<std::optional<std::string>> get_data_async(const std::string& url, const headers& headers = {});
}
+117 -117
View File
@@ -1,118 +1,118 @@
#include <stdinc.hpp>
#include <fstream>
#include "io.hpp"
namespace utils::io
{
bool remove_file(const std::string& file)
{
return DeleteFileA(file.data()) == TRUE;
}
bool file_exists(const std::string& file)
{
return std::ifstream(file).good();
}
bool write_file(const std::string& file, const std::string& data, const bool append)
{
const auto pos = file.find_last_of("/\\");
if (pos != std::string::npos)
{
create_directory(file.substr(0, pos));
}
std::ofstream stream(
file, std::ios::binary | std::ofstream::out | (append ? std::ofstream::app : 0));
if (stream.is_open())
{
stream.write(data.data(), data.size());
stream.close();
return true;
}
return false;
}
std::string read_file(const std::string& file)
{
std::string data;
read_file(file, &data);
return data;
}
bool read_file(const std::string& file, std::string* data)
{
if (!data) return false;
data->clear();
if (file_exists(file))
{
std::ifstream stream(file, std::ios::binary);
if (!stream.is_open()) return false;
stream.seekg(0, std::ios::end);
const std::streamsize size = stream.tellg();
stream.seekg(0, std::ios::beg);
if (size > -1)
{
data->resize(static_cast<uint32_t>(size));
stream.read(const_cast<char*>(data->data()), size);
stream.close();
return true;
}
}
return false;
}
size_t file_size(const std::string& file)
{
if (file_exists(file))
{
std::ifstream stream(file, std::ios::binary);
if (stream.good())
{
stream.seekg(0, std::ios::end);
return static_cast<size_t>(stream.tellg());
}
}
return 0;
}
bool create_directory(const std::string& directory)
{
return std::filesystem::create_directories(directory);
}
bool directory_exists(const std::string& directory)
{
return std::filesystem::is_directory(directory);
}
bool directory_is_empty(const std::string& directory)
{
return std::filesystem::is_empty(directory);
}
std::vector<std::string> list_files(const std::string& directory)
{
std::vector<std::string> files;
for (auto& file : std::filesystem::directory_iterator(directory))
{
files.push_back(file.path().generic_string());
}
return files;
}
void copy_folder(const std::filesystem::path& src, const std::filesystem::path& target)
{
std::filesystem::copy(src, target, std::filesystem::copy_options::overwrite_existing | std::filesystem::copy_options::recursive);
}
#include <stdinc.hpp>
#include <fstream>
#include "io.hpp"
namespace utils::io
{
bool remove_file(const std::string& file)
{
return DeleteFileA(file.data()) == TRUE;
}
bool file_exists(const std::string& file)
{
return std::ifstream(file).good();
}
bool write_file(const std::string& file, const std::string& data, const bool append)
{
const auto pos = file.find_last_of("/\\");
if (pos != std::string::npos)
{
create_directory(file.substr(0, pos));
}
std::ofstream stream(
file, std::ios::binary | std::ofstream::out | (append ? std::ofstream::app : 0));
if (stream.is_open())
{
stream.write(data.data(), data.size());
stream.close();
return true;
}
return false;
}
std::string read_file(const std::string& file)
{
std::string data;
read_file(file, &data);
return data;
}
bool read_file(const std::string& file, std::string* data)
{
if (!data) return false;
data->clear();
if (file_exists(file))
{
std::ifstream stream(file, std::ios::binary);
if (!stream.is_open()) return false;
stream.seekg(0, std::ios::end);
const std::streamsize size = stream.tellg();
stream.seekg(0, std::ios::beg);
if (size > -1)
{
data->resize(static_cast<uint32_t>(size));
stream.read(const_cast<char*>(data->data()), size);
stream.close();
return true;
}
}
return false;
}
size_t file_size(const std::string& file)
{
if (file_exists(file))
{
std::ifstream stream(file, std::ios::binary);
if (stream.good())
{
stream.seekg(0, std::ios::end);
return static_cast<size_t>(stream.tellg());
}
}
return 0;
}
bool create_directory(const std::string& directory)
{
return std::filesystem::create_directories(directory);
}
bool directory_exists(const std::string& directory)
{
return std::filesystem::is_directory(directory);
}
bool directory_is_empty(const std::string& directory)
{
return std::filesystem::is_empty(directory);
}
std::vector<std::string> list_files(const std::string& directory)
{
std::vector<std::string> files;
for (auto& file : std::filesystem::directory_iterator(directory))
{
files.push_back(file.path().generic_string());
}
return files;
}
void copy_folder(const std::filesystem::path& src, const std::filesystem::path& target)
{
std::filesystem::copy(src, target, std::filesystem::copy_options::overwrite_existing | std::filesystem::copy_options::recursive);
}
}
+20 -20
View File
@@ -1,20 +1,20 @@
#pragma once
#include <string>
#include <vector>
#include <filesystem>
namespace utils::io
{
bool remove_file(const std::string& file);
bool file_exists(const std::string& file);
bool write_file(const std::string& file, const std::string& data, bool append = false);
bool read_file(const std::string& file, std::string* data);
std::string read_file(const std::string& file);
size_t file_size(const std::string& file);
bool create_directory(const std::string& directory);
bool directory_exists(const std::string& directory);
bool directory_is_empty(const std::string& directory);
std::vector<std::string> list_files(const std::string& directory);
void copy_folder(const std::filesystem::path& src, const std::filesystem::path& target);
}
#pragma once
#include <string>
#include <vector>
#include <filesystem>
namespace utils::io
{
bool remove_file(const std::string& file);
bool file_exists(const std::string& file);
bool write_file(const std::string& file, const std::string& data, bool append = false);
bool read_file(const std::string& file, std::string* data);
std::string read_file(const std::string& file);
size_t file_size(const std::string& file);
bool create_directory(const std::string& directory);
bool directory_exists(const std::string& directory);
bool directory_is_empty(const std::string& directory);
std::vector<std::string> list_files(const std::string& directory);
void copy_folder(const std::filesystem::path& src, const std::filesystem::path& target);
}
+108 -108
View File
@@ -1,109 +1,109 @@
#include <stdinc.hpp>
#include "memory.hpp"
namespace utils
{
memory::allocator memory::mem_allocator_;
memory::allocator::~allocator()
{
this->clear();
}
void memory::allocator::clear()
{
std::lock_guard _(this->mutex_);
for (auto& data : this->pool_)
{
memory::free(data);
}
this->pool_.clear();
}
void memory::allocator::free(void* data)
{
std::lock_guard _(this->mutex_);
const auto j = std::find(this->pool_.begin(), this->pool_.end(), data);
if (j != this->pool_.end())
{
memory::free(data);
this->pool_.erase(j);
}
}
void memory::allocator::free(const void* data)
{
this->free(const_cast<void*>(data));
}
void* memory::allocator::allocate(const size_t length)
{
std::lock_guard _(this->mutex_);
const auto data = memory::allocate(length);
this->pool_.push_back(data);
return data;
}
bool memory::allocator::empty() const
{
return this->pool_.empty();
}
char* memory::allocator::duplicate_string(const std::string& string)
{
std::lock_guard _(this->mutex_);
const auto data = memory::duplicate_string(string);
this->pool_.push_back(data);
return data;
}
void* memory::allocate(const size_t length)
{
return calloc(length, 1);
}
char* memory::duplicate_string(const std::string& string)
{
const auto new_string = allocate_array<char>(string.size() + 1);
std::memcpy(new_string, string.data(), string.size());
return new_string;
}
void memory::free(void* data)
{
if (data)
{
::free(data);
}
}
void memory::free(const void* data)
{
free(const_cast<void*>(data));
}
bool memory::is_set(const void* mem, const char chr, const size_t length)
{
const auto mem_arr = static_cast<const char*>(mem);
for (size_t i = 0; i < length; ++i)
{
if (mem_arr[i] != chr)
{
return false;
}
}
return true;
}
memory::allocator* memory::get_allocator()
{
return &memory::mem_allocator_;
}
#include <stdinc.hpp>
#include "memory.hpp"
namespace utils
{
memory::allocator memory::mem_allocator_;
memory::allocator::~allocator()
{
this->clear();
}
void memory::allocator::clear()
{
std::lock_guard _(this->mutex_);
for (auto& data : this->pool_)
{
memory::free(data);
}
this->pool_.clear();
}
void memory::allocator::free(void* data)
{
std::lock_guard _(this->mutex_);
const auto j = std::find(this->pool_.begin(), this->pool_.end(), data);
if (j != this->pool_.end())
{
memory::free(data);
this->pool_.erase(j);
}
}
void memory::allocator::free(const void* data)
{
this->free(const_cast<void*>(data));
}
void* memory::allocator::allocate(const size_t length)
{
std::lock_guard _(this->mutex_);
const auto data = memory::allocate(length);
this->pool_.push_back(data);
return data;
}
bool memory::allocator::empty() const
{
return this->pool_.empty();
}
char* memory::allocator::duplicate_string(const std::string& string)
{
std::lock_guard _(this->mutex_);
const auto data = memory::duplicate_string(string);
this->pool_.push_back(data);
return data;
}
void* memory::allocate(const size_t length)
{
return calloc(length, 1);
}
char* memory::duplicate_string(const std::string& string)
{
const auto new_string = allocate_array<char>(string.size() + 1);
std::memcpy(new_string, string.data(), string.size());
return new_string;
}
void memory::free(void* data)
{
if (data)
{
::free(data);
}
}
void memory::free(const void* data)
{
free(const_cast<void*>(data));
}
bool memory::is_set(const void* mem, const char chr, const size_t length)
{
const auto mem_arr = static_cast<const char*>(mem);
for (size_t i = 0; i < length; ++i)
{
if (mem_arr[i] != chr)
{
return false;
}
}
return true;
}
memory::allocator* memory::get_allocator()
{
return &memory::mem_allocator_;
}
}
+74 -74
View File
@@ -1,75 +1,75 @@
#pragma once
#include <mutex>
#include <vector>
namespace utils
{
class memory final
{
public:
class allocator final
{
public:
~allocator();
void clear();
void free(void* data);
void free(const void* data);
void* allocate(size_t length);
template <typename T>
inline T* allocate()
{
return this->allocate_array<T>(1);
}
template <typename T>
inline T* allocate_array(const size_t count = 1)
{
return static_cast<T*>(this->allocate(count * sizeof(T)));
}
bool empty() const;
char* duplicate_string(const std::string& string);
private:
std::mutex mutex_;
std::vector<void*> pool_;
};
static void* allocate(size_t length);
template <typename T>
static inline T* allocate()
{
return allocate_array<T>(1);
}
template <typename T>
static inline T* allocate_array(const size_t count = 1)
{
return static_cast<T*>(allocate(count * sizeof(T)));
}
static char* duplicate_string(const std::string& string);
static void free(void* data);
static void free(const void* data);
static bool is_set(const void* mem, char chr, size_t length);
static bool is_bad_read_ptr(const void* ptr);
static bool is_bad_code_ptr(const void* ptr);
static bool is_rdata_ptr(void* ptr);
static allocator* get_allocator();
private:
static allocator mem_allocator_;
};
#pragma once
#include <mutex>
#include <vector>
namespace utils
{
class memory final
{
public:
class allocator final
{
public:
~allocator();
void clear();
void free(void* data);
void free(const void* data);
void* allocate(size_t length);
template <typename T>
inline T* allocate()
{
return this->allocate_array<T>(1);
}
template <typename T>
inline T* allocate_array(const size_t count = 1)
{
return static_cast<T*>(this->allocate(count * sizeof(T)));
}
bool empty() const;
char* duplicate_string(const std::string& string);
private:
std::mutex mutex_;
std::vector<void*> pool_;
};
static void* allocate(size_t length);
template <typename T>
static inline T* allocate()
{
return allocate_array<T>(1);
}
template <typename T>
static inline T* allocate_array(const size_t count = 1)
{
return static_cast<T*>(allocate(count * sizeof(T)));
}
static char* duplicate_string(const std::string& string);
static void free(void* data);
static void free(const void* data);
static bool is_set(const void* mem, char chr, size_t length);
static bool is_bad_read_ptr(const void* ptr);
static bool is_bad_code_ptr(const void* ptr);
static bool is_rdata_ptr(void* ptr);
static allocator* get_allocator();
private:
static allocator mem_allocator_;
};
}
+986
View File
@@ -0,0 +1,986 @@
#include <stdinc.hpp>
#include "codsrc/clientscript/clientscript_public.hpp"
#include <dbghelp.h>
#define QUICK_TO_JSON_FIELD(j, v, membername) j[#membername] = v.membername
#define QUICK_TO_JSON_FIELD_SAFE_CSTR(j, v, membername) \
if (v.membername) \
j[#membername] = v.membername; \
else \
j[#membername] = "(NULL)"
#define QUICK_TO_JSON_FIELD_PTR_ADDR(j, v, membername) j[#membername] = reinterpret_cast<size_t>(&v.membername)
#define QUICK_TO_JSON_FIELD_ARRAY(j, v, membername) \
for (auto i = 0; i < ARRAY_COUNT(v.membername); i++) \
{ \
j[#membername][i] = v.membername[i]; \
}
#define QUICK_TO_JSON_FIELD_SL_STRING(j, v, membername) j[#membername "Str"] = SL_ConvertToStringSafe(v.membername, *gInst)
namespace game
{
void to_json(nlohmann::json& j, const scrVarPub_t& v)
{
QUICK_TO_JSON_FIELD_SAFE_CSTR(j, v, fieldBuffer);
QUICK_TO_JSON_FIELD(j, v, canonicalStrCount);
QUICK_TO_JSON_FIELD(j, v, developer);
QUICK_TO_JSON_FIELD(j, v, developer_script);
QUICK_TO_JSON_FIELD(j, v, evaluate);
QUICK_TO_JSON_FIELD_SAFE_CSTR(j, v, error_message);
QUICK_TO_JSON_FIELD(j, v, error_index);
QUICK_TO_JSON_FIELD(j, v, time);
QUICK_TO_JSON_FIELD(j, v, timeArrayId);
QUICK_TO_JSON_FIELD(j, v, pauseArrayId);
QUICK_TO_JSON_FIELD(j, v, levelId);
QUICK_TO_JSON_FIELD(j, v, gameId);
QUICK_TO_JSON_FIELD(j, v, animId);
QUICK_TO_JSON_FIELD(j, v, freeEntList);
QUICK_TO_JSON_FIELD(j, v, tempVariable);
QUICK_TO_JSON_FIELD(j, v, bInited);
QUICK_TO_JSON_FIELD(j, v, savecount);
QUICK_TO_JSON_FIELD(j, v, checksum);
QUICK_TO_JSON_FIELD(j, v, entId);
QUICK_TO_JSON_FIELD(j, v, entFieldName);
QUICK_TO_JSON_FIELD_SL_STRING(j, v, entFieldName);
QUICK_TO_JSON_FIELD_PTR_ADDR(j, v, programHunkUser);
QUICK_TO_JSON_FIELD_PTR_ADDR(j, v, programBuffer);
QUICK_TO_JSON_FIELD_PTR_ADDR(j, v, endScriptBuffer);
QUICK_TO_JSON_FIELD_ARRAY(j, v, saveIdMap);
QUICK_TO_JSON_FIELD_ARRAY(j, v, saveIdMapRev);
}
}
int op_idx[game::SCRIPT_INSTANCE_MAX] = { 0, 0 };
bool op_idx_rolled_over[game::SCRIPT_INSTANCE_MAX] = { false, false };
game::OpcodeVM op_history[game::SCRIPT_INSTANCE_MAX][128] = {};
int builtin_idx[game::SCRIPT_INSTANCE_MAX] = { 0, 0 };
bool builtin_idx_rolled_over[game::SCRIPT_INSTANCE_MAX] = { false, false };
int builtin_history[game::SCRIPT_INSTANCE_MAX][128] = {};
int codepos_idx[game::SCRIPT_INSTANCE_MAX] = { 0, 0 };
bool codepos_idx_rolled_over[game::SCRIPT_INSTANCE_MAX] = { false, false };
const char* codepos_history[game::SCRIPT_INSTANCE_MAX][128] = {};
const char* scr_enum_t_to_string[] =
{
"ENUM_NOP",
"ENUM_program",
"ENUM_assignment",
"ENUM_unknown_variable",
"ENUM_duplicate_variable",
"ENUM_local_variable",
"ENUM_local_variable_frozen",
"ENUM_duplicate_expression",
"ENUM_primitive_expression",
"ENUM_integer",
"ENUM_float",
"ENUM_minus_integer",
"ENUM_minus_float",
"ENUM_string",
"ENUM_istring",
"ENUM_array_variable",
"ENUM_unknown_field",
"ENUM_field_variable",
"ENUM_field_variable_frozen",
"ENUM_variable",
"ENUM_function",
"ENUM_call_expression",
"ENUM_local_function",
"ENUM_far_function",
"ENUM_function_pointer",
"ENUM_call",
"ENUM_method",
"ENUM_call_expression_statement",
"ENUM_script_call",
"ENUM_return",
"ENUM_return2",
"ENUM_wait",
"ENUM_script_thread_call",
"ENUM_undefined",
"ENUM_self",
"ENUM_self_frozen",
"ENUM_level",
"ENUM_game",
"ENUM_anim",
"ENUM_if",
"ENUM_if_else",
"ENUM_while",
"ENUM_for",
"ENUM_inc",
"ENUM_dec",
"ENUM_binary_equals",
"ENUM_statement_list",
"ENUM_developer_statement_list",
"ENUM_expression_list",
"ENUM_bool_or",
"ENUM_bool_and",
"ENUM_binary",
"ENUM_bool_not",
"ENUM_bool_complement",
"ENUM_size_field",
"ENUM_self_field",
"ENUM_precachetree",
"ENUM_waittill",
"ENUM_waittillmatch",
"ENUM_waittillFrameEnd",
"ENUM_notify",
"ENUM_endon",
"ENUM_switch",
"ENUM_case",
"ENUM_default",
"ENUM_break",
"ENUM_continue",
"ENUM_expression",
"ENUM_empty_array",
"ENUM_animation",
"ENUM_thread",
"ENUM_begin_developer_thread",
"ENUM_end_developer_thread",
"ENUM_usingtree",
"ENUM_false",
"ENUM_true",
"ENUM_animtree",
"ENUM_breakon",
"ENUM_breakpoint",
"ENUM_prof_begin",
"ENUM_prof_end",
"ENUM_vector",
"ENUM_object",
"ENUM_thread_object",
"ENUM_local",
"ENUM_statement",
"ENUM_bad_expression",
"ENUM_bad_statement",
"ENUM_include",
"ENUM_argument"
};
const char* OpcodeVMToString[] = {
"OP_End",
"OP_Return",
"OP_GetUndefined",
"OP_GetZero",
"OP_GetByte",
"OP_GetNegByte",
"OP_GetUnsignedShort",
"OP_GetNegUnsignedShort",
"OP_GetInteger",
"OP_GetFloat",
"OP_GetString",
"OP_GetIString",
"OP_GetVector",
"OP_GetLevelObject",
"OP_GetAnimObject",
"OP_GetSelf",
"OP_GetLevel",
"OP_GetGame",
"OP_GetAnim",
"OP_GetAnimation",
"OP_GetGameRef",
"OP_GetFunction",
"OP_CreateLocalVariable",
"OP_RemoveLocalVariables",
"OP_EvalLocalVariableCached0",
"OP_EvalLocalVariableCached1",
"OP_EvalLocalVariableCached2",
"OP_EvalLocalVariableCached3",
"OP_EvalLocalVariableCached4",
"OP_EvalLocalVariableCached5",
"OP_EvalLocalVariableCached",
"OP_EvalLocalArrayCached",
"OP_EvalArray",
"OP_EvalLocalArrayRefCached0",
"OP_EvalLocalArrayRefCached",
"OP_EvalArrayRef",
"OP_ClearArray",
"OP_EmptyArray",
"OP_GetSelfObject",
"OP_EvalLevelFieldVariable",
"OP_EvalAnimFieldVariable",
"OP_EvalSelfFieldVariable",
"OP_EvalFieldVariable",
"OP_EvalLevelFieldVariableRef",
"OP_EvalAnimFieldVariableRef",
"OP_EvalSelfFieldVariableRef",
"OP_EvalFieldVariableRef",
"OP_ClearFieldVariable",
"OP_SafeCreateVariableFieldCached",
"OP_SafeSetVariableFieldCached0",
"OP_SafeSetVariableFieldCached",
"OP_SafeSetWaittillVariableFieldCached",
"OP_clearparams",
"OP_checkclearparams",
"OP_EvalLocalVariableRefCached0",
"OP_EvalLocalVariableRefCached",
"OP_SetLevelFieldVariableField",
"OP_SetVariableField",
"OP_SetAnimFieldVariableField",
"OP_SetSelfFieldVariableField",
"OP_SetLocalVariableFieldCached0",
"OP_SetLocalVariableFieldCached",
"OP_CallBuiltin0",
"OP_CallBuiltin1",
"OP_CallBuiltin2",
"OP_CallBuiltin3",
"OP_CallBuiltin4",
"OP_CallBuiltin5",
"OP_CallBuiltin",
"OP_CallBuiltinMethod0",
"OP_CallBuiltinMethod1",
"OP_CallBuiltinMethod2",
"OP_CallBuiltinMethod3",
"OP_CallBuiltinMethod4",
"OP_CallBuiltinMethod5",
"OP_CallBuiltinMethod",
"OP_wait",
"OP_waittillFrameEnd",
"OP_PreScriptCall",
"OP_ScriptFunctionCall2",
"OP_ScriptFunctionCall",
"OP_ScriptFunctionCallPointer",
"OP_ScriptMethodCall",
"OP_ScriptMethodCallPointer",
"OP_ScriptThreadCall",
"OP_ScriptThreadCallPointer",
"OP_ScriptMethodThreadCall",
"OP_ScriptMethodThreadCallPointer",
"OP_DecTop",
"OP_CastFieldObject",
"OP_EvalLocalVariableObjectCached",
"OP_CastBool",
"OP_BoolNot",
"OP_BoolComplement",
"OP_JumpOnFalse",
"OP_JumpOnTrue",
"OP_JumpOnFalseExpr",
"OP_JumpOnTrueExpr",
"OP_jump",
"OP_jumpback",
"OP_inc",
"OP_dec",
"OP_bit_or",
"OP_bit_ex_or",
"OP_bit_and",
"OP_equality",
"OP_inequality",
"OP_less",
"OP_greater",
"OP_less_equal",
"OP_greater_equal",
"OP_shift_left",
"OP_shift_right",
"OP_plus",
"OP_minus",
"OP_multiply",
"OP_divide",
"OP_mod",
"OP_size",
"OP_waittillmatch",
"OP_waittill",
"OP_notify",
"OP_endon",
"OP_voidCodepos",
"OP_switch",
"OP_endswitch",
"OP_vector",
"OP_NOP",
"OP_abort",
"OP_object",
"OP_thread_object",
"OP_EvalLocalVariable",
"OP_EvalLocalVariableRef",
"OP_prof_begin",
"OP_prof_end",
"OP_breakpoint",
"OP_assignmentBreakpoint",
"OP_manualAndAssignmentBreakpoint",
"OP_count"
};
nlohmann::json print_statement_ast(game::scriptInstance_t inst, game::sval_u val)
{
nlohmann::json answer{};
game::sval_u *node;
game::sval_u *start_node;
int i;
answer["type"] = scr_enum_t_to_string[val.node[0].type];
switch (val.node[0].type)
{
case game::ENUM_array_variable:
answer["expr"] = print_statement_ast(inst, val.node[1]);
answer["index"] = print_statement_ast(inst, val.node[2]);
answer["sourcePos"] = val.node[3].sourcePosValue;
answer["indexSourcePos"] = val.node[4].sourcePosValue;
break;
case game::ENUM_field_variable:
answer["expr"] = print_statement_ast(inst, val.node[1]);
answer["field"] = game::SL_ConvertToString(val.node[2].stringValue, inst);
answer["sourcePos"] = val.node[3].sourcePosValue;
break;
case game::ENUM_assignment:
answer["lhs"] = print_statement_ast(inst, val.node[1]);
answer["rhs"] = print_statement_ast(inst, val.node[2]);
answer["sourcePos"] = val.node[3].sourcePosValue;
answer["rhsSourcePos"] = val.node[4].sourcePosValue;
break;
case game::ENUM_far_function:
answer["filename"] = game::SL_ConvertToString(val.node[1].stringValue, inst);
answer["threadName"] = game::SL_ConvertToString(val.node[2].stringValue, inst);
answer["sourcePos"] = val.node[3].sourcePosValue;
break;
case game::ENUM_local_function:
answer["threadName"] = game::SL_ConvertToString(val.node[1].stringValue, inst);
answer["sourcePos"] = val.node[2].sourcePosValue;
break;
case game::ENUM_function:
case game::ENUM_function_pointer:
answer["func"] = print_statement_ast(inst, val.node[1]);
answer["sourcePos"] = val.node[2].sourcePosValue;
break;
case game::ENUM_script_call:
answer["func_name"] = print_statement_ast(inst, val.node[1]);
answer["nameSourcePos"] = val.node[2].sourcePosValue;
break;
case game::ENUM_script_thread_call:
answer["func_name"] = print_statement_ast(inst, val.node[1]);
answer["sourcePos"] = val.node[2].sourcePosValue;
answer["nameSourcePos"] = val.node[3].sourcePosValue;
break;
case game::ENUM_call:
answer["func_name"] = print_statement_ast(inst, val.node[1]);
answer["params"] = nlohmann::json::array();
for (i = 0, node = val.node[2].node[0].node;
node;
node = node[1].node, i++)
{
answer["params"][i] = print_statement_ast(inst, node->node[0]);
}
answer["sourcePos"] = val.node[3].sourcePosValue;
break;
case game::ENUM_method:
answer["expr"] = print_statement_ast(inst, val.node[1]);
answer["func_name"] = print_statement_ast(inst, val.node[2]);
answer["params"] = nlohmann::json::array();
for (i = 0, node = val.node[3].node[0].node;
node;
node = node[1].node, i++)
{
answer["params"][i] = print_statement_ast(inst, node->node[0]);
}
answer["sourcePos"] = val.node[4].sourcePosValue;
answer["methodSourcePos"] = val.node[5].sourcePosValue;
break;
case game::ENUM_integer:
case game::ENUM_minus_integer:
answer["value"] = val.node[1].intValue;
answer["sourcePos"] = val.node[2].sourcePosValue;
break;
case game::ENUM_float:
case game::ENUM_minus_float:
answer["value"] = val.node[1].floatValue;
answer["sourcePos"] = val.node[2].sourcePosValue;
break;
case game::ENUM_string:
case game::ENUM_istring:
answer["value"] = game::SL_ConvertToString(val.node[1].stringValue, inst);
answer["sourcePos"] = val.node[2].sourcePosValue;
break;
case game::ENUM_expression_list:
answer["exprlist"] = nlohmann::json::array();
for (i = 0, node = val.node[1].node->node;
node;
node = node[1].node, i++)
{
answer["exprlist"][i] = print_statement_ast(inst, *node->node);
}
answer["sourcePos"] = val.node[2].sourcePosValue;
break;
case game::ENUM_thread:
answer["threadName"] = game::SL_ConvertToString(val.node[1].stringValue, inst);
answer["formalParams"] = nlohmann::json::array();
for (i = 0, node = val.node[2].node->node[1].node;
node;
node = node[1].node, i++)
{
answer["formalParams"][i]["expr_name"] = game::SL_ConvertToString(node->node[0].stringValue, inst);
answer["formalParams"][i]["sourcePos"] = node->node[1].sourcePosValue;
}
answer["statements"] = nlohmann::json::array();
for (i = 0, node = val.node[3].node->node[1].node;
node;
node = node[1].node, i++)
{
answer["statements"][i] = print_statement_ast(inst, *node);
}
answer["sourcePos"] = val.node[4].sourcePosValue;
answer["endSourcePos"] = val.node[5].sourcePosValue;
{
auto stmtblock = &val.node[6].block;
stmtblock = stmtblock;
}
break;
case game::ENUM_usingtree:
answer["string"] = game::SL_ConvertToString(val.node[1].stringValue, inst);
answer["sourcePos"] = val.node[2].sourcePosValue;
answer["sourcePos2"] = val.node[3].sourcePosValue;
break;
case game::ENUM_wait:
answer["expr"] = print_statement_ast(inst, val.node[1]);
answer["sourcePos"] = val.node[2].sourcePosValue;
answer["waitSourcePos"] = val.node[3].sourcePosValue;
break;
case game::ENUM_developer_statement_list:
answer["list"] = nlohmann::json::array();
for (i = 0, node = val.node[1].node->node[1].node;
node;
node = node[1].node, i++)
{
answer["list"][i] = print_statement_ast(inst, *node);
}
answer["sourcePos"] = val.node[2].sourcePosValue;
{
auto devStatBlock = val.node[3].block;
devStatBlock = devStatBlock;
}
break;
case game::ENUM_statement_list:
answer["list"] = nlohmann::json::array();
for (i = 0, node = val.node[1].node->node[1].node;
node;
node = node[1].node, i++)
{
answer["list"][i] = print_statement_ast(inst, *node);
}
answer["sourcePos"] = val.node[2].sourcePosValue;
answer["sourcePos2"] = val.node[3].sourcePosValue;
break;
case game::ENUM_if:
answer["expr"] = print_statement_ast(inst, val.node[1]);
answer["stmt"] = print_statement_ast(inst, val.node[2]);
answer["sourcePos"] = val.node[3].sourcePosValue;
{
auto ifStatBlock = val.node[4].block;
ifStatBlock = ifStatBlock;
}
break;
case game::ENUM_if_else:
answer["expr"] = print_statement_ast(inst, val.node[1]);
answer["stmt1"] = print_statement_ast(inst, val.node[2]);
answer["stmt2"] = print_statement_ast(inst, val.node[3]);
answer["sourcePos"] = val.node[4].sourcePosValue;
answer["elseSourcePos"] = val.node[5].sourcePosValue;
{
auto ifBlock = val.node[6].block;
auto elseBlock = val.node[7].block;
ifBlock = ifBlock;
elseBlock = elseBlock;
}
break;
case game::ENUM_while:
answer["expr"] = print_statement_ast(inst, val.node[1]);
answer["stmt"] = print_statement_ast(inst, val.node[2]);
answer["sourcePos"] = val.node[3].sourcePosValue;
answer["whileSourcePos"] = val.node[4].sourcePosValue;
{
auto whileStatBlock = val.node[5].block;
whileStatBlock = whileStatBlock;
}
break;
case game::ENUM_for:
answer["stmt1"] = print_statement_ast(inst, val.node[1]);
answer["expr"] = print_statement_ast(inst, val.node[2]);
answer["stmt2"] = print_statement_ast(inst, val.node[3]);
answer["stmt"] = print_statement_ast(inst, val.node[4]);
answer["sourcePos"] = val.node[5].sourcePosValue;
answer["forSourcePos"] = val.node[6].sourcePosValue;
{
auto forStatBlock = val.node[7].block;
auto forStatPostBlock = val.node[8].block;
forStatBlock = forStatBlock;
forStatPostBlock = forStatPostBlock;
}
break;
case game::ENUM_bool_or:
case game::ENUM_bool_and:
answer["expr1"] = print_statement_ast(inst, val.node[1]);
answer["expr2"] = print_statement_ast(inst, val.node[2]);
answer["expr1SourcePos"] = val.node[3].sourcePosValue;
answer["expr2SourcePos"] = val.node[4].sourcePosValue;
answer["sourcePos"] = val.node[5].sourcePosValue;
break;
case game::ENUM_binary:
{
auto expr1 = val.node[1];
auto expr2 = val.node[2];
auto opcode = val.node[3].type;
auto sourcePos = val.node[4].sourcePosValue;
answer["opcode"] = OpcodeVMToString[opcode];
answer["sourcePos"] = sourcePos;
answer["expr1"] = print_statement_ast(inst, expr1);
answer["expr2"] = print_statement_ast(inst, expr2);
break;
}
case game::ENUM_binary_equals:
answer["lhs"] = print_statement_ast(inst, val.node[1]);
answer["rhs"] = print_statement_ast(inst, val.node[2]);
answer["opcode"] = OpcodeVMToString[val.node[3].type];
answer["sourcePos"] = val.node[4].sourcePosValue;
break;
case game::ENUM_endon:
answer["obj"] = print_statement_ast(inst, val.node[1]);
answer["expr"] = print_statement_ast(inst, val.node[2]);
answer["sourcePos"] = val.node[3].sourcePosValue;
answer["exprSourcePos"] = val.node[4].sourcePosValue;
break;
case game::ENUM_notify:
answer["obj"] = print_statement_ast(inst, val.node[1]);
answer["exprlist"] = nlohmann::json::array();
start_node = nullptr;
for (i = 0, node = val.node[2].node->node;
node;
node = node[1].node, i++)
{
start_node = node;
answer["exprlist"][i] = print_statement_ast(inst, *node->node);
}
answer["startNodeSourcePos"] = start_node->node[1].sourcePosValue;
answer["sourcePos"] = val.node[3].sourcePosValue;
answer["notifySourcePos"] = val.node[4].sourcePosValue;
break;
case game::ENUM_waittill:
answer["obj"] = print_statement_ast(inst, val.node[1]);
node = val.node[2].node->node[1].node;
answer["expr"]["expr"] = print_statement_ast(inst, *node->node);
answer["expr"]["sourcePos"] = node->node[1].sourcePosValue;
answer["exprlist"] = nlohmann::json::array();
for (i = 0, node = node[1].node;
node;
node = node[1].node, i++)
{
answer["exprlist"][i]["expr"] = game::SL_ConvertToString(node[0].node->stringValue, inst);
answer["exprlist"][i]["sourcePos"] = node->node[1].sourcePosValue;
}
answer["sourcePos"] = val.node[3].sourcePosValue;
answer["waitSourcePos"] = val.node[4].sourcePosValue;
break;
case game::ENUM_switch:
answer["expr"] = print_statement_ast(inst, val.node[1]);
answer["stmtlist"] = nlohmann::json::array();
for (i = 0, node = val.node[2].node->node[1].node;
node;
node = node[1].node, i++)
{
answer["stmtlist"][i] = print_statement_ast(inst, *node);
}
answer["sourcePos"] = val.node[3].sourcePosValue;
break;
case game::ENUM_default:
answer["sourcePos"] = val.node[1].sourcePosValue;
{
auto breakBlock = val.node[2].block;
breakBlock = breakBlock;
}
break;
case game::ENUM_case:
answer["expr"] = print_statement_ast(inst, val.node[1]);
answer["sourcePos"] = val.node[2].sourcePosValue;
{
auto caseBlock = val.node[3].block;
caseBlock = caseBlock;
}
break;
case game::ENUM_waittillmatch:
answer["obj"] = print_statement_ast(inst, val.node[1]);
answer["exprlist"] = nlohmann::json::array();
for (i = 0, node = val.node[2].node->node[1].node;
node;
node = node[1].node, i++)
{
answer["exprlist"][i]["expr"] = print_statement_ast(inst, *node->node);
answer["exprlist"][i]["sourcePos"] = node->node[1].sourcePosValue;
}
answer["sourcePos"] = val.node[3].sourcePosValue;
answer["waitSourcePos"] = val.node[4].sourcePosValue;
break;
case game::ENUM_local_variable:
case game::ENUM_prof_begin:
case game::ENUM_prof_end:
case game::ENUM_animation:
answer["name"] = game::SL_ConvertToString(val.node[1].stringValue, inst);
answer["sourcePos"] = val.node[2].sourcePosValue;
break;
case game::ENUM_begin_developer_thread:
case game::ENUM_end_developer_thread:
case game::ENUM_undefined:
case game::ENUM_false:
case game::ENUM_true:
case game::ENUM_return2:
case game::ENUM_self:
case game::ENUM_level:
case game::ENUM_game:
case game::ENUM_anim:
case game::ENUM_empty_array:
case game::ENUM_waittillFrameEnd:
case game::ENUM_break:
case game::ENUM_continue:
case game::ENUM_animtree:
case game::ENUM_breakpoint:
answer["sourcePos"] = val.node[1].sourcePosValue;
break;
case game::ENUM_duplicate_variable:
case game::ENUM_duplicate_expression:
case game::ENUM_call_expression:
case game::ENUM_call_expression_statement:
case game::ENUM_expression:
case game::ENUM_statement:
answer["expr"] = print_statement_ast(inst, val.node[1]);
break;
case game::ENUM_variable:
case game::ENUM_primitive_expression:
case game::ENUM_return:
case game::ENUM_inc:
case game::ENUM_dec:
case game::ENUM_bool_not:
case game::ENUM_bool_complement:
case game::ENUM_size_field:
answer["expr"] = print_statement_ast(inst, val.node[1]);
answer["sourcePos"] = val.node[2].sourcePosValue;
break;
case game::ENUM_NOP:
case game::ENUM_program: // unk
case game::ENUM_unknown_variable: // unk
case game::ENUM_local_variable_frozen: // unk, debugger?
case game::ENUM_unknown_field: // unk
case game::ENUM_field_variable_frozen: // unk, debugger?
case game::ENUM_self_frozen: // unk, debugger?
case game::ENUM_include: // handled
case game::ENUM_self_field: // debugger
case game::ENUM_object: // debugger
case game::ENUM_precachetree: // unk
case game::ENUM_local: // unk
case game::ENUM_bad_expression: // unk
case game::ENUM_bad_statement: // unk
case game::ENUM_argument: // unk
case game::ENUM_thread_object: // unk
case game::ENUM_vector: // unk
case game::ENUM_breakon: // debugger unk 2 vals 1 pos
default:
break;
}
return answer;
}
void print_ast(game::scriptInstance_t inst, game::sval_u val)
{
nlohmann::json answer{};
game::sval_u* node;
int i;
answer["filename"] = game::gScrParserPub[inst].scriptfilename;
// this is the include list
answer["includes"] = nlohmann::json::array();
for ( i = 0, node = val.node[0].node->node[1].node;
node;
node = node[1].node, i++ )
{
answer["includes"][i]["type"] = scr_enum_t_to_string[node->node[0].type];
answer["includes"][i]["filename"] = game::SL_ConvertToString(node->node[1].stringValue, inst);
answer["includes"][i]["sourcePos"] = node->node[2].sourcePosValue;
}
// this is the thread list
answer["threads"] = nlohmann::json::array();
for ( i = 0, node = val.node[1].node->node[1].node;
node;
node = node[1].node, i++ )
{
answer["threads"][i] = print_statement_ast(inst, *node);
}
utils::io::write_file(std::format("t4sp-server-plugin/ast-{}.json", game::gScrParserPub[inst].scriptfilename), answer.dump(2));
}
// https://stackoverflow.com/questions/5693192/win32-backtrace-from-c-code
std::string build_code_stack()
{
unsigned int i;
void * stack[ 100 ];
unsigned short frames;
SYMBOL_INFO * symbol;
HANDLE process;
std::string answer{};
process = GetCurrentProcess();
SymInitialize( process, NULL, TRUE );
frames = CaptureStackBackTrace( 0, 100, stack, NULL );
symbol = ( SYMBOL_INFO * )calloc( sizeof( SYMBOL_INFO ) + 256 * sizeof( char ), 1 );
symbol->MaxNameLen = 255;
symbol->SizeOfStruct = sizeof( SYMBOL_INFO );
for( i = 0; i < frames; i++ )
{
SymFromAddr( process, ( DWORD64 )( stack[ i ] ), 0, symbol );
answer += std::format("{}: {} - 0x{:06x}\n", frames - i - 1, symbol->Name, symbol->Address);
}
free( symbol );
return answer;
}
std::string build_builtin_history(game::scriptInstance_t inst)
{
std::string answer{};
int count = builtin_idx_rolled_over[inst] ? ARRAY_COUNT(builtin_history[inst]) : builtin_idx[inst];
for (auto i = 0; i < count; i++)
{
auto idx = builtin_idx[inst] - 1 - i;
if (idx < 0)
{
idx += ARRAY_COUNT(builtin_history[inst]);
}
// todo, convert to builtin name
answer += std::format("{}\n", builtin_history[inst][idx]);
}
return answer;
}
std::string build_codepos_history(game::scriptInstance_t inst)
{
std::string answer{};
int bufferIndex;
int prevSourcePos;
int col;
char line[1024];
int lineNum;
const char* fileName;
int count = codepos_idx_rolled_over[inst] ? ARRAY_COUNT(codepos_history[inst]) : codepos_idx[inst];
for (auto i = 0; i < count; i++)
{
auto idx = codepos_idx[inst] - 1 - i;
if (idx < 0)
{
idx += ARRAY_COUNT(codepos_history[inst]);
}
bufferIndex = game::Scr_GetSourceBuffer(inst, codepos_history[inst][idx]);
prevSourcePos = game::Scr_GetPrevSourcePos(inst, codepos_history[inst][idx], 0);
lineNum = game::Scr_GetLineInfo(&col, game::gScrParserPub[inst].sourceBufferLookup[bufferIndex].sourceBuf, prevSourcePos, line);
fileName = game::gScrParserPub[inst].sourceBufferLookup[bufferIndex].buf;
answer += std::format("{}({}, {}): '{}'\n", fileName, lineNum, col, line);
}
return answer;
}
std::string build_op_history(game::scriptInstance_t inst)
{
std::string answer{};
int count = op_idx_rolled_over[inst] ? ARRAY_COUNT(op_history[inst]) : op_idx[inst];
for (auto i = 0; i < count; i++)
{
auto idx = op_idx[inst] - 1 - i;
if (idx < 0)
{
idx += ARRAY_COUNT(op_history[inst]);
}
if ((int)op_history[inst][idx] >= 0 && op_history[inst][idx] < game::OP_count)
{
answer += std::format("{}\n", OpcodeVMToString[op_history[inst][idx]]);
}
else
{
answer += std::format("0x{:02x}\n", (int)op_history[inst][idx]);
}
}
return answer;
}
std::string build_gsc_stack(game::scriptInstance_t inst)
{
std::string answer{};
int bufferIndex;
int prevSourcePos;
int col;
char line[1024];
int lineNum;
const char* fileName;
if (!game::gFs[inst].pos || !game::Scr_IsInOpcodeMemory(inst, game::gFs[inst].pos))
{
return answer;
}
for (auto frame = game::gScrVmPub[inst].function_frame_start;; frame++)
{
if (!frame->fs.pos || !game::Scr_IsInOpcodeMemory(inst, frame->fs.pos))
{
break;
}
bufferIndex = game::Scr_GetSourceBuffer(inst, frame->fs.pos - 1);
prevSourcePos = game::Scr_GetPrevSourcePos(inst, frame->fs.pos - 1, 0);
lineNum = game::Scr_GetLineInfo(&col, game::gScrParserPub[inst].sourceBufferLookup[bufferIndex].sourceBuf, prevSourcePos, line);
fileName = game::gScrParserPub[inst].sourceBufferLookup[bufferIndex].buf;
answer += std::format("{}({}, {}): '{}'\n", fileName, lineNum, col, line);
if (frame == game::gScrVmPub[inst].function_frame)
{
break;
}
}
return answer;
}
std::string build_gsc_dump(game::scriptInstance_t inst)
{
nlohmann::json answer{};
auto t = *game::gInst;
*game::gInst = inst;
answer["inst"] = inst;
answer["gScrVarPub"] = game::gScrVarPub[inst];
answer["codeCallStack"] = build_code_stack();
answer["gscCallStack"] = build_gsc_stack(inst);
answer["opHistory"] = build_op_history(inst);
answer["builtinHistory"] = build_builtin_history(inst);
answer["codeposHistory"] = build_codepos_history(inst);
*game::gInst = t;
return answer.dump(2);
}
void push_opcode_history(game::scriptInstance_t inst, game::OpcodeVM op)
{
assert(inst == 0 || inst == 1);
//assert((int)op >= 0 && op < game::OP_count);
op_history[inst][op_idx[inst]++] = op;
if (op_idx[inst] >= ARRAY_COUNT(op_history[inst]))
{
op_idx_rolled_over[inst] = true;
op_idx[inst] = 0;
}
}
void push_builtin_history(game::scriptInstance_t inst, int idx)
{
assert(inst == 0 || inst == 1);
assert(idx >= 0 && idx < 1024);
builtin_history[inst][builtin_idx[inst]++] = idx;
if (builtin_idx[inst] >= ARRAY_COUNT(builtin_history[inst]))
{
builtin_idx_rolled_over[inst] = true;
builtin_idx[inst] = 0;
}
}
void push_codepos_history(game::scriptInstance_t inst, const char* pos)
{
assert(inst == 0 || inst == 1);
assert(game::Scr_IsInOpcodeMemory(inst, pos));
codepos_history[inst][codepos_idx[inst]++] = pos;
if (codepos_idx[inst] >= ARRAY_COUNT(codepos_history[inst]))
{
codepos_idx_rolled_over[inst] = true;
codepos_idx[inst] = 0;
}
}
+171 -171
View File
@@ -1,172 +1,172 @@
#include <stdinc.hpp>
#include "string.hpp"
#include <sstream>
#include <cstdarg>
#include <algorithm>
namespace utils::string
{
const char* va(const char* fmt, ...)
{
static thread_local va_provider<8, 256> provider;
va_list ap;
va_start(ap, fmt);
const char* result = provider.get(fmt, ap);
va_end(ap);
return result;
}
std::vector<std::string> split(const std::string& s, const char delim)
{
std::stringstream ss(s);
std::string item;
std::vector<std::string> elems;
while (std::getline(ss, item, delim))
{
elems.push_back(item); // elems.push_back(std::move(item)); // if C++11 (based on comment from @mchiasson)
}
return elems;
}
std::string to_lower(std::string text)
{
std::transform(text.begin(), text.end(), text.begin(), [](const char input)
{
return static_cast<char>(tolower(input));
});
return text;
}
std::string to_upper(std::string text)
{
std::transform(text.begin(), text.end(), text.begin(), [](const char input)
{
return static_cast<char>(toupper(input));
});
return text;
}
bool starts_with(const std::string& text, const std::string& substring)
{
return text.find(substring) == 0;
}
bool ends_with(const std::string& text, const std::string& substring)
{
if (substring.size() > text.size()) return false;
return std::equal(substring.rbegin(), substring.rend(), text.rbegin());
}
bool is_numeric(const std::string& text)
{
return std::to_string(atoi(text.data())) == text;
}
std::string dump_hex(const std::string& data, const std::string& separator)
{
std::string result;
for (unsigned int i = 0; i < data.size(); ++i)
{
if (i > 0)
{
result.append(separator);
}
result.append(va("%02X", data[i] & 0xFF));
}
return result;
}
void strip(const char* in, char* out, int max)
{
if (!in || !out) return;
max--;
auto current = 0;
while (*in != 0 && current < max)
{
const auto color_index = (*(in + 1) - 48) >= 0xC ? 7 : (*(in + 1) - 48);
if (*in == '^' && (color_index != 7 || *(in + 1) == '7'))
{
++in;
}
else
{
*out = *in;
++out;
++current;
}
++in;
}
*out = '\0';
}
#pragma warning(push)
#pragma warning(disable: 4100)
std::string convert(const std::wstring& wstr)
{
std::string result;
result.reserve(wstr.size());
for (const auto& chr : wstr)
{
result.push_back(static_cast<char>(chr));
}
return result;
}
std::wstring convert(const std::string& str)
{
std::wstring result;
result.reserve(str.size());
for (const auto& chr : str)
{
result.push_back(static_cast<wchar_t>(chr));
}
return result;
}
#pragma warning(pop)
std::string replace(std::string str, const std::string& from, const std::string& to)
{
if (from.empty())
{
return str;
}
size_t start_pos = 0;
while ((start_pos = str.find(from, start_pos)) != std::string::npos)
{
str.replace(start_pos, from.length(), to);
start_pos += to.length();
}
return str;
}
std::string get_timestamp()
{
tm ltime{};
char timestamp[MAX_PATH] = { 0 };
const auto time = _time64(nullptr);
_localtime64_s(&ltime, &time);
strftime(timestamp, sizeof(timestamp) - 1, "%Y-%m-%d-%H-%M-%S", &ltime);
return timestamp;
}
#include <stdinc.hpp>
#include "string.hpp"
#include <sstream>
#include <cstdarg>
#include <algorithm>
namespace utils::string
{
const char* va(const char* fmt, ...)
{
static thread_local va_provider<8, 256> provider;
va_list ap;
va_start(ap, fmt);
const char* result = provider.get(fmt, ap);
va_end(ap);
return result;
}
std::vector<std::string> split(const std::string& s, const char delim)
{
std::stringstream ss(s);
std::string item;
std::vector<std::string> elems;
while (std::getline(ss, item, delim))
{
elems.push_back(item); // elems.push_back(std::move(item)); // if C++11 (based on comment from @mchiasson)
}
return elems;
}
std::string to_lower(std::string text)
{
std::transform(text.begin(), text.end(), text.begin(), [](const char input)
{
return static_cast<char>(tolower(input));
});
return text;
}
std::string to_upper(std::string text)
{
std::transform(text.begin(), text.end(), text.begin(), [](const char input)
{
return static_cast<char>(toupper(input));
});
return text;
}
bool starts_with(const std::string& text, const std::string& substring)
{
return text.find(substring) == 0;
}
bool ends_with(const std::string& text, const std::string& substring)
{
if (substring.size() > text.size()) return false;
return std::equal(substring.rbegin(), substring.rend(), text.rbegin());
}
bool is_numeric(const std::string& text)
{
return std::to_string(atoi(text.data())) == text;
}
std::string dump_hex(const std::string& data, const std::string& separator)
{
std::string result;
for (unsigned int i = 0; i < data.size(); ++i)
{
if (i > 0)
{
result.append(separator);
}
result.append(va("%02X", data[i] & 0xFF));
}
return result;
}
void strip(const char* in, char* out, int max)
{
if (!in || !out) return;
max--;
auto current = 0;
while (*in != 0 && current < max)
{
const auto color_index = (*(in + 1) - 48) >= 0xC ? 7 : (*(in + 1) - 48);
if (*in == '^' && (color_index != 7 || *(in + 1) == '7'))
{
++in;
}
else
{
*out = *in;
++out;
++current;
}
++in;
}
*out = '\0';
}
#pragma warning(push)
#pragma warning(disable: 4100)
std::string convert(const std::wstring& wstr)
{
std::string result;
result.reserve(wstr.size());
for (const auto& chr : wstr)
{
result.push_back(static_cast<char>(chr));
}
return result;
}
std::wstring convert(const std::string& str)
{
std::wstring result;
result.reserve(str.size());
for (const auto& chr : str)
{
result.push_back(static_cast<wchar_t>(chr));
}
return result;
}
#pragma warning(pop)
std::string replace(std::string str, const std::string& from, const std::string& to)
{
if (from.empty())
{
return str;
}
size_t start_pos = 0;
while ((start_pos = str.find(from, start_pos)) != std::string::npos)
{
str.replace(start_pos, from.length(), to);
start_pos += to.length();
}
return str;
}
std::string get_timestamp()
{
tm ltime{};
char timestamp[MAX_PATH] = { 0 };
const auto time = _time64(nullptr);
_localtime64_s(&ltime, &time);
strftime(timestamp, sizeof(timestamp) - 1, "%Y-%m-%d-%H-%M-%S", &ltime);
return timestamp;
}
}

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