130 Commits

Author SHA1 Message Date
ineed bots 25f827da0d add sample 2025-09-20 20:53:00 -06:00
ineed bots afbbdd2d11 fix wanrings 2025-09-20 20:50:37 -06:00
ineed bots d417f41992 new workflow 2025-09-20 20:41:58 -06:00
ineed bots 812a7424fe cleanup for no plutonium release 2025-09-20 20:36:55 -06:00
ineed bots bf1632f4ec fix 2024-08-03 15:26:05 -06:00
ineed bots 4bd1ff9a66 update 2024-08-03 15:07:12 -06:00
ineed bots 9b8680b7bd Merge branch 'main' of https://github.com/JezuzLizard/T4SP-Server-Plugin 2024-08-03 15:02:54 -06:00
ineed bots 646b5a3264 no more printf 2024-08-03 15:02:46 -06:00
ineed bots 3e9fcc5fda cleanup 2024-08-03 14:59:34 -06:00
ineed bots 83ffa1c324 remove scheduler hooks (use plugin sdk) 2024-08-03 14:41:16 -06:00
INeedGames fd80b4c55a Update README.md 2024-08-03 14:22:53 -06:00
INeedGames 348bf99bd6 Update README.md 2024-08-03 14:22:17 -06:00
INeedGames 0c128ca259 Update README.md 2024-08-03 14:21:21 -06:00
ineed bots 232ce3bcaa use plugin gsc register 2024-08-03 14:20:06 -06:00
ineed bots 483c7126c8 fix warning 2024-08-03 13:59:20 -06:00
ineed bots 0cd113b33f New install 2024-07-31 22:53:48 -06:00
ineed bots 4c77045add Add pluto sdk 2024-07-31 22:49:19 -06:00
ineed bots b0ccd678d3 fmt 2024-07-31 22:11:27 -06:00
ineed bots f4ac726a1e Add use_global for fs_remove and opening for writing 2024-07-31 22:07:00 -06:00
ineed bots 3a4595a641 add pluto sdk 2024-07-31 21:38:17 -06:00
ineed bots a3a7b8847c note 2024-05-12 11:43:16 -06:00
ineed bots 7fccea636f update to io 2024-05-12 11:41:57 -06:00
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
88 changed files with 4664 additions and 20953 deletions
-7
View File
@@ -1,7 +0,0 @@
version: 2
updates:
- package-ecosystem: gitsubmodule
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
+4 -2
View File
@@ -53,11 +53,12 @@ jobs:
run: msbuild /m /v:minimal /p:Configuration=${{matrix.configuration}} /p:PlatformTarget=x86 build/t4sp-server-plugin.sln
- name: Upload ${{matrix.configuration}} binaries
uses: actions/upload-artifact@v3.1.0
uses: actions/upload-artifact@v4.6.2
with:
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
@@ -70,7 +71,7 @@ jobs:
uses: actions/checkout@v3.5.3
- name: Download Binaries
uses: actions/download-artifact@v3.0.2
uses: actions/download-artifact@v4.3.0
with:
name: Release binaries
@@ -82,3 +83,4 @@ jobs:
draft: true
files: |
t4sp-server-plugin.dll
t4sp-server-plugin.pdb
+9
View File
@@ -23,3 +23,12 @@
[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
[submodule "deps/plutonium-sdk"]
path = deps/plutonium-sdk
url = https://github.com/plutoniummod/plutonium-sdk.git
+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/>.
+7 -5
View File
@@ -1,13 +1,15 @@
# T4SP-Server-Plugin
A plugin that has code that hopefully compiles and the game will load it to do things. Stability not guaranteed.
A plugin that has no code that hopefully compiles and the game will load it to do nothing. Stability not guaranteed.
Requires Git (https://git-scm.com/), Premake5 (https://premake.github.io/), and MSVC 2022 (https://visualstudio.microsoft.com/vs/features/cplusplus/) to build.
# What does it do?
Nothing really right now, just detours and reimplements the entire GSC VM, for research purposes.
# Installation
Move the `t4sp-server-plugin.dll` to `%LOCALAPPDATA%\Plutonium\storage\t4\plugins\`, the plugin will be loaded when you start up a dedicated server for Plutonium T4SP.
Move the `t4sp-server-plugin.dll` to `%LOCALAPPDATA%\Plutonium\plugins\`, the plugin will be loaded when you start up a dedicated server for Plutonium T4SP.
# Features
Nothing.
# Credits
- momo5502 (https://github.com/momo5502)
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
Vendored Submodule
+1
Submodule deps/plutonium-sdk added at 17e9a0a4d5
+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)
+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)
+18
View File
@@ -0,0 +1,18 @@
plutonium_sdk = {
source = path.join(dependencies.basePath, "plutonium-sdk"),
}
function plutonium_sdk.import()
plutonium_sdk.includes()
end
function plutonium_sdk.includes()
includedirs {
plutonium_sdk.source,
}
end
function plutonium_sdk.project()
end
table.insert(dependencies, plutonium_sdk)
Vendored
+1 -1
Submodule deps/zlib updated: 04f42ceca4...643e17b749
+2 -4
View File
@@ -103,20 +103,18 @@ workspace "t4sp-server-plugin"
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\\\" )"
"if \"%COMPUTERNAME%\" == \"\" ( copy /y \"$(TargetPath)\" \"$(LOCALAPPDATA)\\Plutonium\\plugins\\\" )"
}
filter {}
filter "configurations:Debug"
postbuildcommands {
"if \"%COMPUTERNAME%\" == \"NEW-BUILT\" ( copy /y \"$(TargetPath)\" \"$(CODWAW_PATH)\\t4staging\\plugins\\\" )"
"if \"%COMPUTERNAME%\" == \"\" ( copy /y \"$(TargetPath)\" \"$(LOCALAPPDATA)\\Plutonium-staging\\plugins\\\" )"
}
filter {}
end
@@ -1,2 +0,0 @@
#include <stdinc.hpp>
#include "clientscript_public.hpp"
@@ -1,11 +0,0 @@
#pragma once
#include "cscr_main.hpp"
#include "cscr_memorytree.hpp"
#include "cscr_parser.hpp"
#include "cscr_parsetree.hpp"
#include "cscr_readwrite.hpp"
#include "cscr_stringlist.hpp"
#include "cscr_tempmemory.hpp"
#include "cscr_variable.hpp"
#include "cscr_vm.hpp"
-451
View File
@@ -1,451 +0,0 @@
#include <stdinc.hpp>
#include "clientscript_public.hpp"
namespace codsrc
{
// 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;
}
// Decomp Status: Completed
bool Scr_IsIdentifier(char* token)
{
while ( *token )
{
if (!iscsym(*token))
{
return false;
}
++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);
unsigned int fileNameHash = game::Scr_CreateCanonicalFilename(inst, file);
int id = game::FindVariable(fileNameHash, game::gScrCompilePub[inst].scriptsPos, inst);
game::SL_RemoveRefToString(fileNameHash, inst);
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 filePosId = game::FindVariable(str, posId, inst);
if (!filePosId)
{
return 0;
}
game::VariableValue val = game::Scr_EvalVariable(inst, filePosId);
assert(val.type == game::VAR_CODEPOS);
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);
return pos - game::gScrVarPub[inst].programBuffer;
}
// Decomp Status: Completed
unsigned int SL_TransferToCanonicalString(game::scriptInstance_t inst, unsigned int stringValue)
{
assert(stringValue);
game::SL_TransferRefToUser(stringValue, 2u, inst);
if ( game::gScrCompilePub[inst].canonicalStrings[stringValue] )
{
return game::gScrCompilePub[inst].canonicalStrings[stringValue];
}
game::gScrCompilePub[inst].canonicalStrings[stringValue] = ++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;
str = game::SL_FindString(token, inst);
if ( game::gScrCompilePub[inst].canonicalStrings[str] )
{
return game::gScrCompilePub[inst].canonicalStrings[str];
}
str = game::SL_GetString_(token, inst, 0);
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 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);
game::gScrCompilePub[inst].script_loading = 1;
game::Scr_InitOpcodeLookup(inst);
assert(!game::gScrCompilePub[inst].loadedscripts);
game::gScrCompilePub[inst].loadedscripts = game::Scr_AllocArray(inst);
assert(!game::gScrCompilePub[inst].scriptsPos);
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);
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;
}
}
-21
View File
@@ -1,21 +0,0 @@
#pragma once
namespace codsrc
{
int Scr_IsInOpcodeMemory(game::scriptInstance_t inst, const char* pos);
bool Scr_IsIdentifier(char * token);
unsigned int Scr_GetFunctionHandle(const char * file, game::scriptInstance_t inst, const char * handle);
unsigned int SL_TransferToCanonicalString(game::scriptInstance_t inst, unsigned int stringValue);
unsigned int SL_GetCanonicalString(char * token, game::scriptInstance_t inst);
void Scr_BeginLoadScripts(game::scriptInstance_t inst, int user);
void Scr_BeginLoadAnimTrees(game::scriptInstance_t inst, int user);
int Scr_ScanFile(int max_size, char * buf);
unsigned int Scr_LoadScriptInternal(game::scriptInstance_t inst, const char * file, game::PrecacheEntry * entries, int entriesCount);
unsigned int Scr_LoadScript(const char * file, game::scriptInstance_t inst);
void Scr_EndLoadScripts(game::scriptInstance_t inst);
void Scr_EndLoadAnimTrees(game::scriptInstance_t inst);
void Scr_FreeScripts(game::scriptInstance_t inst);
void Scr_PrecacheAnimTrees(game::scriptInstance_t inst, void* (__cdecl* Alloc)(int), int user, int modChecksum);
void Scr_SetLoadedImpureScript(bool loadedImpureScript);
void SL_BeginLoadScripts(game::scriptInstance_t inst);
}
-525
View File
@@ -1,525 +0,0 @@
#include <stdinc.hpp>
#include "clientscript_public.hpp"
namespace codsrc
{
// Restored
game::RefVector* GetRefVector(game::scriptInstance_t inst, unsigned int id)
{
assert(id);
assert((id * MT_NODE_SIZE) < MT_SIZE);
return (game::RefVector*)&game::gScrMemTreePub[inst].mt_buffer->nodes[id];
}
// Decomp Status: Tested, Completed
int MT_GetSubTreeSize(game::scriptInstance_t inst, int nodeNum)
{
int treeSize;
if (nodeNum)
{
treeSize = game::MT_GetSubTreeSize(inst, game::gScrMemTreeGlob[inst].nodes[nodeNum].next);
return treeSize + game::MT_GetSubTreeSize(inst, game::gScrMemTreeGlob[inst].nodes[nodeNum].prev) + 1;
}
else
{
return 0;
}
}
// Decomp Status: Tested, Completed
void MT_DumpTree(game::scriptInstance_t inst)
{
int size;
//assert(game::gScrMemTreeGlob[inst].totalAlloc == totalAlloc);
//assert(game::gScrMemTreeGlob[inst].totalAllocBuckets == totalAllocBuckets);
game::Com_Printf(game::CON_CHANNEL_PARSERSCRIPT, "********************************\n");
for (int i = 0; i <= MT_NODE_BITS; ++i)
{
size = game::MT_GetSubTreeSize(inst, game::gScrMemTreeGlob[inst].head[i]);
game::Com_Printf(game::CON_CHANNEL_PARSERSCRIPT, "%d subtree has %d * %d = %d free buckets\n", i, size, 1 << i, size << i);
}
game::Com_Printf(game::CON_CHANNEL_PARSERSCRIPT, "********************************\n");
game::Com_Printf(game::CON_CHANNEL_PARSERSCRIPT, "********************************\n");
game::Com_Printf(game::CON_CHANNEL_PARSERSCRIPT, "********************************\n");
//assert(totalBuckets == (1 << MEMORY_NODE_BITS) - 1);
}
// Decomp Status: Tested, Completed
void MT_InitBits(game::scriptInstance_t inst)
{
char bits;
int temp;
int i;
for (i = 0; i < MT_NUM_BUCKETS; ++i)
{
bits = 0;
for (temp = i; temp; temp >>= 1)
{
if (temp & 1)
{
++bits;
}
}
game::gScrMemTreeGlob[inst].numBits[i] = bits;
for (bits = 8; i & ((1 << bits) - 1); --bits);
game::gScrMemTreeGlob[inst].leftBits[i] = bits;
bits = 0;
for (temp = i; temp; temp >>= 1)
{
++bits;
}
game::gScrMemTreeGlob[inst].logBits[i] = bits;
}
}
// Decomp Status: Tested, Completed
int MT_GetScore(game::scriptInstance_t inst, int num)
{
char bits;
union MTnum_t
{
int i;
uint8_t b[4];
};
assert(num);
assert(MT_NODE_COUNT - num);
MTnum_t mtnum;
mtnum.i = MT_NODE_COUNT - num;
bits = game::gScrMemTreeGlob[inst].leftBits[mtnum.b[0]];
if (!mtnum.b[0])
{
bits += game::gScrMemTreeGlob[inst].leftBits[mtnum.b[1]];
}
return mtnum.i - (game::gScrMemTreeGlob[inst].numBits[mtnum.b[1]] + game::gScrMemTreeGlob[inst].numBits[mtnum.b[0]]) + (1 << bits);
}
// Decomp Status: Tested, Completed
void MT_AddMemoryNode(game::scriptInstance_t inst, int newNode, int size)
{
int node;
int nodeNum;
int newScore;
uint16_t* parentNode;
int level;
int score;
assert(size >= 0 && size <= MT_NODE_BITS);
parentNode = &game::gScrMemTreeGlob[inst].head[size];
node = game::gScrMemTreeGlob[inst].head[size];
if (game::gScrMemTreeGlob[inst].head[size])
{
newScore = game::MT_GetScore(inst, newNode);
nodeNum = 0;
level = MT_NODE_COUNT;
do
{
assert(newNode != node);
score = game::MT_GetScore(inst, node);
assert(score != newScore);
if (score < newScore)
{
while (1)
{
*parentNode = (short)newNode;
game::gScrMemTreeGlob[inst].nodes[newNode] = game::gScrMemTreeGlob[inst].nodes[node];
if (!node)
{
break;
}
level >>= 1;
assert(node != nodeNum);
if (node >= nodeNum)
{
parentNode = &game::gScrMemTreeGlob[inst].nodes[newNode].next;
nodeNum += level;
}
else
{
parentNode = &game::gScrMemTreeGlob[inst].nodes[newNode].prev;
nodeNum -= level;
}
newNode = node;
node = *parentNode;
}
return;
}
level >>= 1;
assert(newNode != nodeNum);
if (newNode >= nodeNum)
{
parentNode = &game::gScrMemTreeGlob[inst].nodes[node].next;
nodeNum += level;
}
else
{
parentNode = &game::gScrMemTreeGlob[inst].nodes[node].prev;
nodeNum -= level;
}
node = *parentNode;
} while (node);
}
*parentNode = (short)newNode;
game::gScrMemTreeGlob[inst].nodes[newNode].prev = 0;
game::gScrMemTreeGlob[inst].nodes[newNode].next = 0;
}
// Decomp Status: Tested, Completed
char MT_RemoveMemoryNode(game::scriptInstance_t inst, int oldNode, int size)
{
game::MemoryNode tempNodeValue;
int node;
game::MemoryNode oldNodeValue;
int nodeNum;
uint16_t* parentNode;
int prevScore;
int nextScore;
int level;
assert(size >= 0 && size <= MT_NODE_BITS);
nodeNum = 0;
level = MT_NODE_COUNT;
parentNode = &game::gScrMemTreeGlob[inst].head[size];
for (node = *parentNode; node; node = *parentNode)
{
if (oldNode == node)
{
oldNodeValue = game::gScrMemTreeGlob[inst].nodes[oldNode];
while (1)
{
if (oldNodeValue.prev)
{
if (oldNodeValue.next)
{
prevScore = game::MT_GetScore(inst, oldNodeValue.prev);
nextScore = game::MT_GetScore(inst, oldNodeValue.next);
assert(prevScore != nextScore);
if (prevScore >= nextScore)
{
oldNode = oldNodeValue.prev;
*parentNode = oldNodeValue.prev;
parentNode = &game::gScrMemTreeGlob[inst].nodes[oldNodeValue.prev].prev;
}
else
{
oldNode = oldNodeValue.next;
*parentNode = oldNodeValue.next;
parentNode = &game::gScrMemTreeGlob[inst].nodes[oldNodeValue.next].next;
}
}
else
{
oldNode = oldNodeValue.prev;
*parentNode = oldNodeValue.prev;
parentNode = &game::gScrMemTreeGlob[inst].nodes[oldNodeValue.prev].prev;
}
}
else
{
oldNode = oldNodeValue.next;
*parentNode = oldNodeValue.next;
if (!oldNodeValue.next)
{
return true;
}
parentNode = &game::gScrMemTreeGlob[inst].nodes[oldNodeValue.next].next;
}
assert(oldNode);
tempNodeValue = oldNodeValue;
oldNodeValue = game::gScrMemTreeGlob[inst].nodes[oldNode];
game::gScrMemTreeGlob[inst].nodes[oldNode] = tempNodeValue;
}
}
if (oldNode == nodeNum)
{
return false;
}
level >>= 1;
if (oldNode >= nodeNum)
{
parentNode = &game::gScrMemTreeGlob[inst].nodes[node].next;
nodeNum += level;
}
else
{
parentNode = &game::gScrMemTreeGlob[inst].nodes[node].prev;
nodeNum -= level;
}
}
return false;
}
// Decomp Status: Tested, Completed
void MT_RemoveHeadMemoryNode(game::scriptInstance_t inst, int size)
{
game::MemoryNode tempNodeValue;
int oldNode;
game::MemoryNode oldNodeValue;
uint16_t* parentNode;
int prevScore;
int nextScore;
assert(size >= 0 && size <= MT_NODE_BITS);
parentNode = &game::gScrMemTreeGlob[inst].head[size];
oldNodeValue = game::gScrMemTreeGlob[inst].nodes[*parentNode];
while (1)
{
if (!oldNodeValue.prev)
{
oldNode = oldNodeValue.next;
*parentNode = oldNodeValue.next;
if (!oldNode)
{
break;
}
parentNode = &game::gScrMemTreeGlob[inst].nodes[oldNode].next;
}
else
{
if (oldNodeValue.next)
{
prevScore = game::MT_GetScore(inst, oldNodeValue.prev);
nextScore = game::MT_GetScore(inst, oldNodeValue.next);
assert(prevScore != nextScore);
if (prevScore >= nextScore)
{
oldNode = oldNodeValue.prev;
*parentNode = (short)oldNode;
parentNode = &game::gScrMemTreeGlob[inst].nodes[oldNode].prev;
}
else
{
oldNode = oldNodeValue.next;
*parentNode = (short)oldNode;
parentNode = &game::gScrMemTreeGlob[inst].nodes[oldNode].next;
}
}
else
{
oldNode = oldNodeValue.prev;
*parentNode = (short)oldNode;
parentNode = &game::gScrMemTreeGlob[inst].nodes[oldNode].prev;
}
}
assert(oldNode != 0);
tempNodeValue = oldNodeValue;
oldNodeValue = game::gScrMemTreeGlob[inst].nodes[oldNode];
game::gScrMemTreeGlob[inst].nodes[oldNode] = tempNodeValue;
}
}
// Decomp Status: Tested, Completed
void MT_Init(game::scriptInstance_t inst)
{
game::Sys_EnterCriticalSection(game::CRITSECT_MEMORY_TREE);
game::scrMemTreeGlob_t* memTreeBuffer = &game::gScrMemTreeGlob[inst];
game::gScrMemTreePub[inst].mt_buffer = memTreeBuffer;
game::MT_InitBits(inst);
for (int i = 0; i <= MT_NODE_BITS; ++i)
{
memTreeBuffer->head[i] = 0;
}
memTreeBuffer->nodes[0].next = 0;
memTreeBuffer->nodes[0].prev = 0;
for (int i = 0; i < MT_NODE_BITS; ++i)
{
game::MT_AddMemoryNode(inst, 1 << i, i);
}
game::Sys_LeaveCriticalSection(game::CRITSECT_MEMORY_TREE);
}
// Decomp Status: Tested, Completed
void MT_Error(game::scriptInstance_t inst, const char* funcName, int numBytes)
{
game::MT_DumpTree(inst);
game::Com_Printf(game::CON_CHANNEL_PARSERSCRIPT, "%s: failed memory allocation of %d bytes for script usage\n", funcName, numBytes);
game::Scr_DumpScriptThreads(inst);
game::gScrVmPub[inst].terminal_error = 1;
game::Scr_Error("failed memory allocation for script usage", inst, 0);
}
// Decomp Status: Tested, Completed
int MT_GetSize(int numBytes, game::scriptInstance_t inst)
{
int numBuckets;
int result;
assert(numBytes > 0);
if (numBytes >= MT_NODE_COUNT)
{
game::MT_Error(inst, "MT_GetSize: max allocation exceeded", numBytes);
result = 0;
}
else
{
numBuckets = (numBytes + MT_NODE_SIZE - 1) / MT_NODE_SIZE - 1;
if (numBuckets > MT_NUM_BUCKETS - 1)
{
result = game::gScrMemTreeGlob[inst].logBits[numBuckets >> 8] + 8;
}
else
{
result = game::gScrMemTreeGlob[inst].logBits[numBuckets];
}
}
return result;
}
// Decomp Status: Tested, Completed
unsigned __int16 MT_AllocIndex(game::scriptInstance_t inst, int numBytes)
{
int nodeNum;
int size = game::MT_GetSize(numBytes, inst);
int newSize;
assert(size >= 0 && size <= MT_NODE_BITS);
game::Sys_EnterCriticalSection(game::CRITSECT_MEMORY_TREE);
for (newSize = size; ; ++newSize)
{
if (newSize > MT_NODE_BITS)
{
game::Sys_LeaveCriticalSection(game::CRITSECT_MEMORY_TREE);
game::MT_Error(inst, "MT_AllocIndex", numBytes);
return 0;
}
nodeNum = game::gScrMemTreeGlob[inst].head[newSize];
if (game::gScrMemTreeGlob[inst].head[newSize])
{
break;
}
}
game::MT_RemoveHeadMemoryNode(inst, newSize);
while (newSize != size)
{
--newSize;
game::MT_AddMemoryNode(inst, nodeNum + (1 << newSize), newSize);
}
//assert(type);
//assert(!game::gScrMemTreeDebugGlob[inst].mt_usage[nodeNum]);
//assert(!game::gScrMemTreeDebugGlob[inst].mt_usage_size[nodeNum]);
game::Sys_LeaveCriticalSection(game::CRITSECT_MEMORY_TREE);
return (short)nodeNum;
}
// Decomp Status: Tested, Completed
void MT_FreeIndex(int numBytes, game::scriptInstance_t inst, int nodeNum)
{
int size = game::MT_GetSize(numBytes, inst);
assert(size >= 0 && size <= MT_NODE_BITS);
assert(nodeNum > 0 && nodeNum < MT_NODE_COUNT);
game::Sys_EnterCriticalSection(game::CRITSECT_MEMORY_TREE);
//assert(game::gScrMemTreeDebugGlob[inst].mt_usage[nodeNum]);
//assert(game::gScrMemTreeDebugGlob[inst].mt_usage_size[nodeNum] == size);
for (int i = 1 << size; size != MT_NODE_BITS; i = 1 << ++size)
{
assert(size <= MT_NODE_BITS);
assert(nodeNum == (nodeNum & ~((1 << size) - 1)));
if (!game::MT_RemoveMemoryNode(inst, nodeNum ^ i, size))
{
break;
}
nodeNum &= ~i;
}
game::MT_AddMemoryNode(inst, nodeNum, size);
game::Sys_LeaveCriticalSection(game::CRITSECT_MEMORY_TREE);
}
// Decomp Status: Tested, Completed
char* MT_Alloc(int numBytes, game::scriptInstance_t inst)
{
return (char*)(game::gScrMemTreeGlob[inst].nodes + game::MT_AllocIndex(inst, numBytes));
}
// Decomp Status: Tested, Completed
void MT_Free(void* p, int numBytes, game::scriptInstance_t inst)
{
assert((game::MemoryNode*)p - game::gScrMemTreeGlob[inst].nodes >= 0 && (game::MemoryNode*)p - game::gScrMemTreeGlob[inst].nodes < MT_NODE_COUNT);
game::MT_FreeIndex(numBytes, inst, (game::MemoryNode*)p - game::gScrMemTreeGlob[inst].nodes);
}
// Restored inlined function
char* MT_GetRefByIndex(game::scriptInstance_t inst, int index)
{
if (index > MT_NODE_COUNT)
{
game::MT_Error(inst, "MT_GetRefByIndex: out of bounds index", index);
return NULL;
}
return (char*)&game::gScrMemTreeGlob[inst].nodes[index];
}
}
@@ -1,21 +0,0 @@
#pragma once
namespace codsrc
{
game::RefVector* GetRefVector(game::scriptInstance_t inst, unsigned int id);
int MT_GetSubTreeSize(game::scriptInstance_t inst, int nodeNum);
void MT_DumpTree(game::scriptInstance_t inst);
void MT_InitBits(game::scriptInstance_t inst);
int MT_GetScore(game::scriptInstance_t inst, int num);
void MT_AddMemoryNode(game::scriptInstance_t inst, int newNode, int size);
char MT_RemoveMemoryNode(game::scriptInstance_t inst, int oldNode, int size);
void MT_RemoveHeadMemoryNode(game::scriptInstance_t inst, int size);
void MT_Init(game::scriptInstance_t inst);
void MT_Error(game::scriptInstance_t inst, const char* funcName, int numBytes);
int MT_GetSize(int numBytes, game::scriptInstance_t inst);
unsigned __int16 MT_AllocIndex(game::scriptInstance_t inst, int numBytes);
void MT_FreeIndex(int numBytes, game::scriptInstance_t inst, int nodeNum);
char* MT_Alloc(int numBytes, game::scriptInstance_t inst);
void MT_Free(void* p, int numBytes, game::scriptInstance_t inst);
const char* MT_NodeInfoString(game::scriptInstance_t inst, unsigned int nodeNum);
}
-939
View File
@@ -1,939 +0,0 @@
#include <stdinc.hpp>
#include "clientscript_public.hpp"
namespace codsrc
{
// Decomp Status: Tested, Completed
void Scr_InitOpcodeLookup(game::scriptInstance_t inst)
{
unsigned int opcodeLookupMaxLen;
game::OpcodeLookup* opcodeLookup;
unsigned int sourcePosLookupMaxLen;
game::HunkUser* debugHunkUser;
unsigned int sourceBufferLookupMaxLen;
assert(!game::gScrParserGlob[inst].opcodeLookup);
assert(!game::gScrParserGlob[inst].sourcePosLookup);
assert(!game::gScrParserPub[inst].sourceBufferLookup);
if (game::gScrVarPub[inst].developer)
{
debugHunkUser = (game::HunkUser*)game::g_DebugHunkUser.get();
opcodeLookupMaxLen = inst != game::SCRIPTINSTANCE_CLIENT ? 0x40000 : 0x4000;
game::gScrParserGlob[inst].opcodeLookupMaxLen = opcodeLookupMaxLen;
game::gScrParserGlob[inst].delayedSourceIndex = -1;
game::gScrParserGlob[inst].opcodeLookupLen = 0;
opcodeLookup = (game::OpcodeLookup*)game::Hunk_UserAlloc(debugHunkUser, 24 * opcodeLookupMaxLen, 4);
game::gScrParserGlob[inst].opcodeLookup = opcodeLookup;
memset(opcodeLookup, 0, sizeof(game::OpcodeLookup) * game::gScrParserGlob[inst].opcodeLookupMaxLen);
sourcePosLookupMaxLen = inst != game::SCRIPTINSTANCE_CLIENT ? 0x60000 : 0x10;
game::gScrParserGlob[inst].sourcePosLookupMaxLen = sourcePosLookupMaxLen;
game::gScrParserGlob[inst].sourcePosLookupLen = 0;
game::gScrParserGlob[inst].sourcePosLookup = (game::SourceLookup*)game::Hunk_UserAlloc(debugHunkUser, 8 * sourcePosLookupMaxLen, 4);
sourceBufferLookupMaxLen = inst != game::SCRIPTINSTANCE_CLIENT ? 0x100 : 0x10;
game::gScrParserGlob[inst].sourceBufferLookupMaxLen = sourceBufferLookupMaxLen;
game::gScrParserGlob[inst].currentCodePos = 0;
game::gScrParserGlob[inst].currentSourcePosCount = 0;
game::gScrParserPub[inst].sourceBufferLookupLen = 0;
game::gScrParserPub[inst].sourceBufferLookup = (game::SourceBufferInfo*)game::Hunk_UserAlloc(debugHunkUser, 24 * sourceBufferLookupMaxLen, 4);
}
}
// Decomp Status: Tested, Completed
void Scr_ShutdownOpcodeLookup(game::scriptInstance_t inst)
{
if (game::gScrParserGlob[inst].opcodeLookup)
{
game::gScrParserGlob[inst].opcodeLookup = 0;
}
if (game::gScrParserGlob[inst].sourcePosLookup)
{
game::gScrParserGlob[inst].sourcePosLookup = 0;
}
if (game::gScrParserPub[inst].sourceBufferLookup != 0)
{
game::gScrParserPub[inst].sourceBufferLookup = 0;
}
if (game::gScrParserGlob[inst].saveSourceBufferLookup)
{
game::gScrParserGlob[inst].saveSourceBufferLookup = 0;
}
}
// Decomp Status: Completed
void AddOpcodePos(game::scriptInstance_t inst, unsigned int sourcePos, int type)
{
game::OpcodeLookup* newOpcodeLookup;
game::SourceLookup* newSourcePosLookup;
char* compilerOpcodePos;
game::OpcodeLookup* opcodeLookup;
int posIndex;
game::SourceLookup* sourcePosLookup;
int delayedSourceIndex;
int allocSize;
if (game::gScrVarPub[inst].developer)
{
if (game::gScrCompilePub[inst].developer_statement != 2)
{
if (!game::gScrCompilePub[inst].allowedBreakpoint)
{
type &= ~1u;
}
assert(game::gScrParserGlob[inst].opcodeLookup);
assert(game::gScrParserGlob[inst].opcodeLookupMaxLen);
assert(game::gScrParserGlob[inst].sourcePosLookup);
assert(game::gScrCompilePub[inst].opcodePos);
if (game::gScrParserGlob[inst].opcodeLookupLen >= game::gScrParserGlob[inst].opcodeLookupMaxLen)
{
allocSize = (sizeof(game::OpcodeLookup) * 2) * game::gScrParserGlob[inst].opcodeLookupMaxLen;
game::gScrParserGlob[inst].opcodeLookupMaxLen *= 2;
assert(game::gScrParserGlob[inst].opcodeLookupLen < game::gScrParserGlob[inst].opcodeLookupMaxLen);
newOpcodeLookup = (game::OpcodeLookup*)game::Hunk_UserAlloc((game::HunkUser*)game::g_DebugHunkUser.get(), allocSize, 4);
memcpy(newOpcodeLookup, game::gScrParserGlob[inst].opcodeLookup, sizeof(game::OpcodeLookup) * game::gScrParserGlob[inst].opcodeLookupLen);
game::gScrParserGlob[inst].opcodeLookup = newOpcodeLookup;
}
if (game::gScrParserGlob[inst].sourcePosLookupLen >= game::gScrParserGlob[inst].sourcePosLookupMaxLen)
{
allocSize = (sizeof(game::SourceLookup) * 2) * game::gScrParserGlob[inst].sourcePosLookupMaxLen;
game::gScrParserGlob[inst].sourcePosLookupMaxLen *= 2;
assert(game::gScrParserGlob[inst].sourcePosLookupLen < game::gScrParserGlob[inst].sourcePosLookupMaxLen);
newSourcePosLookup = (game::SourceLookup*)game::Hunk_UserAlloc((game::HunkUser*)game::g_DebugHunkUser.get(), allocSize, 4);
memcpy(newSourcePosLookup, game::gScrParserGlob[inst].sourcePosLookup, sizeof(game::SourceLookup) * game::gScrParserGlob[inst].sourcePosLookupLen);
game::gScrParserGlob[inst].sourcePosLookup = newSourcePosLookup;
}
compilerOpcodePos = game::gScrCompilePub[inst].opcodePos;
if ((char*)game::gScrParserGlob[inst].currentCodePos == compilerOpcodePos)
{
//assert(game::gScrParserGlob[inst].currentSourcePosCount);
opcodeLookup = &game::gScrParserGlob[inst].opcodeLookup[--game::gScrParserGlob[inst].opcodeLookupLen];
//assert(opcodeLookup->sourcePosIndex + game::gScrParserGlob[inst].currentSourcePosCount == game::gScrParserGlob[inst].sourcePosLookupLen);
//assert(opcodeLookup->codePos == (char*)game::gScrParserGlob[inst].currentCodePos);
}
else
{
game::gScrParserGlob[inst].currentCodePos = (const unsigned char*)compilerOpcodePos;
opcodeLookup = &game::gScrParserGlob[inst].opcodeLookup[game::gScrParserGlob[inst].opcodeLookupLen];
game::gScrParserGlob[inst].currentSourcePosCount = 0;
opcodeLookup->sourcePosIndex = game::gScrParserGlob[inst].sourcePosLookupLen;
opcodeLookup->codePos = (const char*)game::gScrParserGlob[inst].currentCodePos;
}
posIndex = game::gScrParserGlob[inst].currentSourcePosCount + opcodeLookup->sourcePosIndex;
sourcePosLookup = &game::gScrParserGlob[inst].sourcePosLookup[posIndex];
sourcePosLookup->sourcePos = sourcePos;
if (sourcePos == -1)
{
assert(game::gScrParserGlob[inst].delayedSourceIndex == -1);
assert(type & game::SOURCE_TYPE_BREAKPOINT);
game::gScrParserGlob[inst].delayedSourceIndex = posIndex;
}
else if (sourcePos == -2)
{
game::gScrParserGlob[inst].threadStartSourceIndex = posIndex;
}
else
{
delayedSourceIndex = game::gScrParserGlob[inst].delayedSourceIndex;
if (delayedSourceIndex >= 0 && (type & 1) != 0)
{
game::gScrParserGlob[inst].sourcePosLookup[delayedSourceIndex].sourcePos = sourcePos;
game::gScrParserGlob[inst].delayedSourceIndex = -1;
}
}
sourcePosLookup->type |= type;
opcodeLookup->sourcePosCount = ++game::gScrParserGlob[inst].currentSourcePosCount;
++game::gScrParserGlob[inst].opcodeLookupLen;
++game::gScrParserGlob[inst].sourcePosLookupLen;
}
else
{
assert(!game::gScrVarPub[inst].developer_script);
}
}
}
// Decomp Status: Tested, Completed
void RemoveOpcodePos(game::scriptInstance_t inst)
{
game::OpcodeLookup* opcodeLookup;
if (game::gScrVarPub[inst].developer)
{
if (game::gScrCompilePub[inst].developer_statement == 2)
{
assert(!game::gScrVarPub[inst].developer_script);
}
else
{
assert(game::gScrParserGlob[inst].opcodeLookup);
assert(game::gScrParserGlob[inst].opcodeLookupMaxLen);
assert(game::gScrParserGlob[inst].sourcePosLookup);
assert(game::gScrCompilePub[inst].opcodePos);
assert(game::gScrParserGlob[inst].sourcePosLookupLen);
--game::gScrParserGlob[inst].sourcePosLookupLen;
assert(game::gScrParserGlob[inst].opcodeLookupLen);
--game::gScrParserGlob[inst].opcodeLookupLen;
assert(game::gScrParserGlob[inst].currentSourcePosCount);
--game::gScrParserGlob[inst].currentSourcePosCount;
opcodeLookup = &game::gScrParserGlob[inst].opcodeLookup[game::gScrParserGlob[inst].opcodeLookupLen];
assert((char*)game::gScrParserGlob[inst].currentCodePos == game::gScrCompilePub[inst].opcodePos);
assert(opcodeLookup->sourcePosIndex + game::gScrParserGlob[inst].currentSourcePosCount == game::gScrParserGlob[inst].sourcePosLookupLen);
assert(opcodeLookup->codePos == (char*)game::gScrParserGlob[inst].currentCodePos);
if (game::gScrParserGlob[inst].currentSourcePosCount == 1)
{
game::gScrParserGlob[inst].currentCodePos = 0;
}
game::gScrParserGlob[inst].opcodeLookup[game::gScrParserGlob[inst].opcodeLookupLen].sourcePosCount = game::gScrParserGlob[inst].currentSourcePosCount;
}
}
}
// Decomp Status: Tested, Completed
void AddThreadStartOpcodePos(game::scriptInstance_t inst, unsigned int sourcePos)
{
game::SourceLookup* sourcePosLookup;
if (game::gScrVarPub[inst].developer)
{
if (game::gScrCompilePub[inst].developer_statement == 2)
{
assert(!game::gScrVarPub[inst].developer_script);
}
else
{
assert(game::gScrParserGlob[inst].threadStartSourceIndex >= 0);
sourcePosLookup = &game::gScrParserGlob[inst].sourcePosLookup[game::gScrParserGlob[inst].threadStartSourceIndex];
sourcePosLookup->sourcePos = sourcePos;
assert(!sourcePosLookup->type);
sourcePosLookup->type = 4;
game::gScrParserGlob[inst].threadStartSourceIndex = -1;
}
}
}
// Decomp Status: Completed
unsigned int Scr_GetSourceBuffer(game::scriptInstance_t inst, const char* codePos)
{
unsigned int bufferIndex;
assert(game::Scr_IsInOpcodeMemory(inst, codePos));
assert(game::gScrParserPub[inst].sourceBufferLookupLen > 0);
for ( bufferIndex = game::gScrParserPub[inst].sourceBufferLookupLen - 1;
bufferIndex && (!game::gScrParserPub[inst].sourceBufferLookup[bufferIndex].codePos || game::gScrParserPub[inst].sourceBufferLookup[bufferIndex].codePos > codePos);
--bufferIndex )
{
;
}
return bufferIndex;
}
// Decomp Status: Tested, Completed
unsigned int Scr_GetLineNumInternal(const char** startLine, const char* buf, const char* sourcePos, int* col)
{
unsigned int lineNum;
assert(buf);
lineNum = 0;
for (*startLine = buf; sourcePos; --sourcePos)
{
if (!*buf)
{
*startLine = buf + 1;
++lineNum;
}
++buf;
}
*col = buf - *startLine;
return lineNum;
}
// Decomp Status: Tested, Completed
game::SourceBufferInfo* Scr_GetNewSourceBuffer(game::scriptInstance_t inst)
{
unsigned int* sourceBufferLookupMaxLen;
int allocSize;
game::SourceBufferInfo* newSourceBufferInfo;
assert(game::gScrParserPub[inst].sourceBufferLookup);
assert(game::gScrParserGlob[inst].sourceBufferLookupMaxLen);
if (game::gScrParserPub[inst].sourceBufferLookupLen < game::gScrParserGlob[inst].sourceBufferLookupMaxLen)
{
return &game::gScrParserPub[inst].sourceBufferLookup[game::gScrParserPub[inst].sourceBufferLookupLen++];
}
//assert(gScrParserPub[inst].sourceBufferLookupLen >= gScrParserGlob[inst].sourceBufferLookupMaxLen);
sourceBufferLookupMaxLen = &game::gScrParserGlob[inst].sourceBufferLookupMaxLen;
allocSize = 2 * *sourceBufferLookupMaxLen;
*sourceBufferLookupMaxLen = allocSize;
newSourceBufferInfo = (game::SourceBufferInfo*)game::Hunk_UserAlloc((game::HunkUser*)game::g_DebugHunkUser.get(), sizeof(game::OpcodeLookup) * allocSize, 4);
memcpy(newSourceBufferInfo, game::gScrParserPub[inst].sourceBufferLookup, sizeof(game::OpcodeLookup) * game::gScrParserPub[inst].sourceBufferLookupLen);
game::gScrParserPub[inst].sourceBufferLookup = newSourceBufferInfo;
return &game::gScrParserPub[inst].sourceBufferLookup[game::gScrParserPub[inst].sourceBufferLookupLen++];
}
// Decomp Status: Tested, Completed
void Scr_AddSourceBufferInternal(const char* filename, game::scriptInstance_t inst, const char* codepos, char* buffer, int len, int archive)
{
game::SourceBufferInfo* newBuffer;
const char* source;
char* buf;
char c;
int i;
char* tmp;
size_t size;
char* dest;
if (game::gScrParserPub[inst].sourceBufferLookup)
{
size = strlen(filename);
dest = (char*)game::Hunk_UserAlloc((struct game::HunkUser*)game::g_DebugHunkUser.get(), size + len + 3, 4);
memcpy(dest, filename, size + 1);
if (buffer)
{
source = &dest[size + 1];
}
else
{
source = 0;
}
buf = buffer;
tmp = (char*)source;
if (len >= 0)
{
for (i = 0; i <= len; ++i)
{
c = *buf++;
if (c == '\n' || c == '\r' && *buf != '\n')
*tmp = 0;
else
*tmp = c;
++tmp;
}
}
newBuffer = game::Scr_GetNewSourceBuffer(inst);
newBuffer->codePos = codepos;
newBuffer->buf = dest;
newBuffer->sourceBuf = source;
newBuffer->len = len;
newBuffer->sortedIndex = -1;
newBuffer->archive = archive;
if (source)
{
game::gScrParserPub[inst].sourceBuf = source;
}
}
else
{
game::gScrParserPub[inst].sourceBuf = 0;
}
}
// Decomp Status: Tested, Completed
char* Scr_ReadFile_FastFile(game::scriptInstance_t inst, [[maybe_unused]] int unused, char* filename, const char* codepos, int archive)
{
char* buffer;
game::RawFile* scriptFile;
scriptFile = game::DB_FindXAssetHeader(game::ASSET_TYPE_RAWFILE, filename, 1, -1).rawfile;
if ((*game::useFastFile)->current.enabled && scriptFile != 0)
{
game::Scr_AddSourceBufferInternal(filename, inst, codepos, scriptFile->buffer, strlen(scriptFile->buffer), archive);
buffer = scriptFile->buffer;
}
else
{
game::Scr_AddSourceBufferInternal(filename, inst, codepos, 0, -1, archive);
buffer = 0;
}
return buffer;
}
// Decomp Status: Tested, Completed
char* Scr_ReadFile_LoadObj(game::scriptInstance_t inst, [[maybe_unused]] int unused_arg1, const char* filename, const char* codepos, int archive)
{
int fileLen;
int fh;
char* buffer;
fileLen = game::FS_FOpenFileRead(filename, &fh);
if (fh)
{
game::fsh[fh].fileSize = fileLen;
game::fsh[fh].streamed = 0;
}
game::fsh[fh].handleSync = 0;
if (fileLen >= 0)
{
if (!(*game::fs_game)->current.string)
{
game::Scr_SetLoadedImpureScript(true);
}
buffer = (char*)game::Hunk_AllocateTempMemoryHigh(fileLen + 1);
game::FS_Read(buffer, fileLen, fh);
buffer[fileLen] = 0;
game::FS_FCloseFile(fh);
game::Scr_AddSourceBufferInternal(filename, inst, codepos, buffer, fileLen, archive);
}
else
{
game::Scr_AddSourceBufferInternal(filename, inst, codepos, 0, -1, archive);
buffer = 0;
}
return buffer;
}
// Decomp Status: Tested, Completed
char* Scr_ReadFile(const char* codepos, char* filename, game::scriptInstance_t inst, int unused)
{
char* buffer;
int fh;
// pluto
if (true)
// if (*(*game::fs_game)->current.string || (*game::com_developer)->current.enabled)
//
{
*game::statmon_related_bool = 1;
if (game::FS_FOpenFileByMode(filename, &fh, game::FS_READ) < 0)
{
buffer = game::Scr_ReadFile_FastFile(inst, unused, filename, codepos, 1);
}
else
{
game::FS_FCloseFile(fh);
buffer = game::Scr_ReadFile_LoadObj(inst, unused, filename, codepos, 1);
}
}
else
{
if (!(*game::useFastFile)->current.enabled)
{
buffer = game::Scr_ReadFile_LoadObj(inst, unused, filename, codepos, 1);
}
else
{
buffer = game::Scr_ReadFile_FastFile(inst, unused, filename, codepos, 1);
}
}
return buffer;
}
// Decomp Status: Completed
char* Scr_AddSourceBuffer(game::scriptInstance_t inst, int unused_arg1, char* filename, const char* codepos)
{
unsigned int saveSourceBufferLookupLen;
int len;
game::SaveSourceBufferInfo* saveSourceBuffer;
char* dest;
char* sourceBuf;
char* source;
int len2;
char c;
if (!game::gScrParserGlob[inst].saveSourceBufferLookup)
{
return game::Scr_ReadFile(codepos, filename, inst, unused_arg1);
}
assert(game::gScrParserGlob[inst].saveSourceBufferLookupLen > 0);
saveSourceBufferLookupLen = --game::gScrParserGlob[inst].saveSourceBufferLookupLen;
len = game::gScrParserGlob[inst].saveSourceBufferLookup[saveSourceBufferLookupLen].len;
saveSourceBuffer = &game::gScrParserGlob[inst].saveSourceBufferLookup[saveSourceBufferLookupLen];
assert(len >= -1);
if (len >= 0)
{
sourceBuf = (char*)game::Hunk_AllocateTempMemoryHigh(len + 1);
source = (char*)saveSourceBuffer->sourceBuf;
dest = sourceBuf;
if (len > 0)
{
len2 = len;
do
{
c = *source++;
if (!c)
{
c = '\n';
}
*dest++ = c;
--len2;
} while (len2);
}
*dest = 0;
}
else
{
dest = 0;
}
game::Scr_AddSourceBufferInternal(filename, inst, codepos, dest, len, 1);
return dest;
}
// Decomp Status: Completed
void Scr_CopyFormattedLine(const char* rawLine, char* line)
{
char cleanChar;
int len;
int i;
len = strlen(rawLine);
if ( len >= 1024 )
{
len = 1023;
}
for ( i = 0;
i < len;
++i )
{
if ( rawLine[i] == '\t' )
{
cleanChar = ' ';
}
else
{
cleanChar = rawLine[i];
}
line[i] = cleanChar;
}
if ( line[len - 1] == '\r' )
{
line[len - 1] = 0;
}
line[len] = 0;
}
// Decomp Status: Completed
unsigned int Scr_GetLineInfo(int* col, const char* buf, unsigned int sourcePos, char* line)
{
const char *startLine;
unsigned int lineNum;
if ( buf )
{
lineNum = game::Scr_GetLineNumInternal(&startLine, buf, (const char*)sourcePos, col);
}
else
{
lineNum = 0;
startLine = "";
*col = 0;
}
game::Scr_CopyFormattedLine(startLine, line);
return lineNum;
}
// Decomp Status: Completed
void Scr_PrintSourcePos(unsigned int sourcePos, const char* buf, game::con_channel_e channel, game::scriptInstance_t inst, const char* file)
{
const char *fileVaLine;
const char *lineStr;
const char *savegameStr;
unsigned int lineNum;
char line[1024];
int i;
int col;
assert(file);
lineNum = game::Scr_GetLineInfo(&col, buf, sourcePos, line);
if ( game::gScrParserGlob[inst].saveSourceBufferLookup )
{
savegameStr = " (savegame)";
}
else
{
savegameStr = "";
}
fileVaLine = game::va("(file '%s'%s, line %d)\n", file, savegameStr, lineNum + 1);
game::Com_PrintMessage(channel, fileVaLine, 0);
lineStr = game::va("%s\n", line);
game::Com_PrintMessage(channel, lineStr, 0);
for ( i = 0;
i < col;
++i )
{
game::Com_PrintMessage(channel, " ", 0);
}
game::Com_PrintMessage(channel, "*\n", 0);
}
// Decomp Status: Completed
game::OpcodeLookup* Scr_GetPrevSourcePosOpcodeLookup(game::scriptInstance_t inst, const char* codePos)
{
unsigned int low;
unsigned int middle;
unsigned int high;
assert(game::Scr_IsInOpcodeMemory(inst, codePos));
assert(game::gScrParserGlob[inst].opcodeLookup);
low = 0;
high = game::gScrParserGlob[inst].opcodeLookupLen - 1;
while ( low <= high )
{
middle = (high + low) >> 1;
if ( codePos < game::gScrParserGlob[inst].opcodeLookup[middle].codePos )
{
high = middle - 1;
}
else
{
low = middle + 1;
if ( middle + 1 == game::gScrParserGlob[inst].opcodeLookupLen || codePos < game::gScrParserGlob[inst].opcodeLookup[low].codePos )
{
return &game::gScrParserGlob[inst].opcodeLookup[middle];
}
}
}
assert(false);
return 0;
}
// Restored
unsigned int Scr_GetPrevSourcePos(game::scriptInstance_t inst, const char *codePos, unsigned int index)
{
return game::gScrParserGlob[inst].sourcePosLookup[index + game::Scr_GetPrevSourcePosOpcodeLookup(inst, codePos)->sourcePosIndex].sourcePos;
}
// Decomp Status: Completed
void Scr_GetTextSourcePos(char* line, const char* codePos, game::scriptInstance_t inst)
{
unsigned int prevsourcePos;
unsigned int bufferIndex;
int col;
if ( game::gScrVarPub[inst].developer
&& codePos
&& codePos != game::g_EndPos.get()
&& game::gScrVarPub[inst].programBuffer
&& game::Scr_IsInOpcodeMemory(inst, codePos) )
{
bufferIndex = game::Scr_GetSourceBuffer(inst, codePos - 1);
prevsourcePos = game::Scr_GetPrevSourcePos(inst, codePos - 1, 0);
game::Scr_GetLineInfo(&col, game::gScrParserPub[inst].sourceBufferLookup[bufferIndex].sourceBuf, prevsourcePos, line);
}
else
{
*line = 0;
}
}
// Decomp Status: Completed
void Scr_PrintPrevCodePos(const char* codepos, game::scriptInstance_t scriptInstance, game::con_channel_e channel, unsigned int index)
{
unsigned int bufferIndex; // esi
unsigned int prevSourcepos; // eax
if (!codepos)
{
game::Com_PrintMessage(channel, "<frozen thread>\n", 0);
return;
}
if (codepos == game::g_EndPos.get())
{
game::Com_PrintMessage(channel, "<removed thread>\n", 0);
}
else
{
if (game::gScrVarPub[scriptInstance].developer)
{
if (game::gScrVarPub[scriptInstance].programBuffer && game::Scr_IsInOpcodeMemory(scriptInstance, codepos))
{
bufferIndex = game::Scr_GetSourceBuffer(scriptInstance, codepos - 1);
prevSourcepos = game::Scr_GetPrevSourcePos(scriptInstance, codepos - 1, index);
game::Scr_PrintSourcePos(
prevSourcepos,
game::gScrParserPub[scriptInstance].sourceBufferLookup[bufferIndex].sourceBuf,
channel,
scriptInstance,
game::gScrParserPub[scriptInstance].sourceBufferLookup[bufferIndex].buf);
return;
}
}
else
{
if (game::Scr_IsInOpcodeMemory(scriptInstance, codepos - 1))
{
// pluto
const char* s;
if (game::plutonium::at_codepose_va != nullptr)
{
s = game::plutonium::at_codepose_va(scriptInstance, codepos - game::gScrVarPub[scriptInstance].programBuffer);
}
else
{
s = game::va("@ %d\n", codepos - game::gScrVarPub[scriptInstance].programBuffer);
}
game::Com_PrintMessage(channel, s, 0);
//
return;
}
}
game::Com_PrintMessage(channel, game::va("%s\n\n", codepos), 0);
}
}
// Restored
void Scr_ShutdownAllocNode(game::scriptInstance_t inst)
{
if (game::g_allocNodeUser[inst])
{
game::Hunk_UserDestroy(game::g_allocNodeUser[inst]);
game::g_allocNodeUser[inst] = 0;
}
}
// Decomp Status: Completed
void CompileError(game::scriptInstance_t inst, unsigned int codePos, const char* msg, ...)
{
const char* instStr;
int col;
int lineNumber;
char text[1024];
char line[1024];
va_list va;
va_start(va, msg);
vsnprintf(text, 0x400u, msg, va);
va_end(va);
instStr = "Server";
if (inst)
{
instStr = "Client";
}
if (game::gScrVarPub[inst].evaluate)
{
if (!game::gScrVarPub[inst].error_message)
{
game::gScrVarPub[inst].error_message = (char*)game::va("%s", text);
}
}
else
{
game::Scr_ShutdownAllocNode(inst);
game::Com_PrintError(game::CON_CHANNEL_PARSERSCRIPT, "\n");
game::Com_PrintError(game::CON_CHANNEL_PARSERSCRIPT, "******* %s script compile error *******\n", instStr);
if (game::gScrVarPub[inst].developer && game::gScrParserPub[inst].sourceBuf)
{
game::Com_PrintError(game::CON_CHANNEL_PARSERSCRIPT, "%s: ", text);
game::Scr_PrintSourcePos(
codePos,
game::gScrParserPub[inst].sourceBuf,
game::CON_CHANNEL_PARSERSCRIPT,
inst,
game::gScrParserPub[inst].scriptfilename);
lineNumber = game::Scr_GetLineInfo(&col, game::gScrParserPub[inst].sourceBuf, codePos, line);
}
else
{
game::Com_PrintError(game::CON_CHANNEL_PARSERSCRIPT, "%s\n", text);
line[0] = 0;
lineNumber = 0;
}
game::Com_Printf(game::CON_CHANNEL_PARSERSCRIPT, "************************************\n");
game::Com_Error(game::ERR_SCRIPT_DROP, "\x15" "%s script compile error\n%s\n%s\n(see console for details)\n", instStr, text, line);
}
}
// Decomp Status: Completed
void CompileError2(const char* codePos, game::scriptInstance_t inst, const char* msg, ...)
{
const char* instStr;
char text[1024];
char line[1024];
va_list va;
va_start(va, msg);
assert(!game::gScrVarPub[inst].evaluate);
assert(game::Scr_IsInOpcodeMemory(inst, codePos));
vsnprintf(text, 0x400u, msg, va);
va_end(va);
instStr = "Server";
if (inst)
{
instStr = "Client";
}
game::Com_PrintError(game::CON_CHANNEL_PARSERSCRIPT, "\n");
game::Com_PrintError(game::CON_CHANNEL_PARSERSCRIPT, "******* %s script compile error *******\n", instStr);
game::Com_PrintError(game::CON_CHANNEL_PARSERSCRIPT, "%s: ", text);
game::Scr_PrintPrevCodePos(codePos, inst, game::CON_CHANNEL_PARSERSCRIPT, 0);
game::Com_Printf(game::CON_CHANNEL_PARSERSCRIPT, "************************************\n");
game::Scr_GetTextSourcePos(line, codePos, inst);
game::Com_Error(game::ERR_SCRIPT_DROP, "\x15" "%s script compile error\n%s\n%s\n(see console for details)\n", instStr, text, line);
}
// Decomp Status: Completed
void RuntimeErrorInternal(const char* msg, game::scriptInstance_t inst, game::con_channel_e channel, const char* codepos, int index)
{
int functionCount;
int i;
assert(game::Scr_IsInOpcodeMemory(inst, codepos));
game::Com_PrintError(channel, "\n******* script runtime error *******\n%s: ", msg);
game::Scr_PrintPrevCodePos(codepos, inst, channel, index);
functionCount = game::gScrVmPub[inst].function_count;
if (functionCount)
{
for (i = game::gScrVmPub[inst].function_count - 1;
i >= 1;
--i)
{
game::Com_PrintError(channel, "called from:\n");
game::Scr_PrintPrevCodePos(game::gScrVmPub[inst].function_frame_start[i].fs.pos, inst, game::CON_CHANNEL_DONT_FILTER, game::gScrVmPub[inst].function_frame_start[i].fs.localId == 0);
}
game::Com_PrintError(channel, "started from:\n");
game::Scr_PrintPrevCodePos(game::gScrVmPub[inst].function_frame_start[0].fs.pos, inst, game::CON_CHANNEL_DONT_FILTER, 1u);
}
game::Com_PrintError(channel, "************************************\n");
}
// Decomp Status: Completed
void RuntimeError(game::scriptInstance_t inst, const char* codePos, int index, const char* msg, const char* dialogMessage)
{
bool abort_or_terminal;
const char* errNewline;
const char* errNewline2;
if (!game::gScrVarPub[inst].developer)
{
assert(game::Scr_IsInOpcodeMemory(inst, codePos));
if (!game::gScrVmPub[inst].terminal_error)
{
return;
}
}
if (game::gScrVmPub[inst].debugCode)
{
game::Com_Printf(game::CON_CHANNEL_PARSERSCRIPT, "%s\n", msg);
if (!game::gScrVmPub[inst].terminal_error)
{
return;
}
}
else
{
abort_or_terminal = game::gScrVmPub[inst].abort_on_error || game::gScrVmPub[inst].terminal_error;
game::RuntimeErrorInternal(
msg,
inst,
abort_or_terminal ? game::CON_CHANNEL_PARSERSCRIPT : game::CON_CHANNEL_LOGFILEONLY,
codePos,
index);
if (!abort_or_terminal)
{
return;
}
}
// pluto
if (!game::gScrVmPub[inst].terminal_error)
{
return;
}
//
errNewline = dialogMessage;
if (dialogMessage)
{
errNewline2 = "\n";
}
else
{
errNewline = "";
errNewline2 = "";
}
game::Com_Error(
game::gScrVmPub[inst].terminal_error ? game::ERR_FATAL : game::ERR_SCRIPT,
"\x15" "script runtime error\n(see console for details)\n%s%s%s",
msg,
errNewline2,
errNewline);
}
}
-31
View File
@@ -1,31 +0,0 @@
#pragma once
namespace codsrc
{
void Scr_InitOpcodeLookup(game::scriptInstance_t a1);
void Scr_ShutdownOpcodeLookup(game::scriptInstance_t a1);
void AddOpcodePos(game::scriptInstance_t a1, unsigned int sourcePos, int type);
void RemoveOpcodePos(game::scriptInstance_t result);
void AddThreadStartOpcodePos(game::scriptInstance_t result, unsigned int sourcePos);
unsigned int Scr_GetSourceBuffer(game::scriptInstance_t a1, const char* codePos);
unsigned int Scr_GetLineNumInternal(const char** startLine, const char* buf, const char* sourcePos, int* col);
game::SourceBufferInfo* Scr_GetNewSourceBuffer(game::scriptInstance_t a1);
void Scr_AddSourceBufferInternal(const char* filename, game::scriptInstance_t inst, const char* codepos, char* buffer, int len, int archive);
char* Scr_ReadFile_FastFile(game::scriptInstance_t inst, int unused, char* filename, const char* codepos, int archive);
char* Scr_ReadFile_LoadObj(game::scriptInstance_t inst, int unused_arg1, const char* filename, const char* codepos, int archive);
char* Scr_ReadFile(const char* codepos, char* filename, game::scriptInstance_t inst, int unused);
char* Scr_AddSourceBuffer(game::scriptInstance_t inst, int unused_arg1, char* filename, const char* codepos);
void Scr_CopyFormattedLine(const char* rawLine, char* line);
unsigned int Scr_GetLineInfo(int* col, const char* buf, unsigned int sourcePos, char* line);
void Scr_PrintSourcePos(unsigned int sourcePos, const char* buf, game::con_channel_e channel, game::scriptInstance_t a4, const char* file);
game::OpcodeLookup * Scr_GetPrevSourcePosOpcodeLookup(game::scriptInstance_t a1, const char* codePos);
void Scr_GetTextSourcePos(char* line, const char* codePos, game::scriptInstance_t a3);
void Scr_PrintPrevCodePos(const char* codepos, game::scriptInstance_t scriptInstance, game::con_channel_e channel, unsigned int index);
void CompileError(game::scriptInstance_t a1, unsigned int codePos, const char* msg, ...);
void CompileError2(const char* codePos, game::scriptInstance_t a2, const char* msg, ...);
void RuntimeErrorInternal(const char* msg, game::scriptInstance_t inst, game::con_channel_e channel, const char* codepos, int index);
void RuntimeError(game::scriptInstance_t inst, const char* pos, int error_index, const char* err, const char* err2);
unsigned int Scr_GetPrevSourcePos(game::scriptInstance_t inst, const char* codePos, unsigned int index);
void Scr_ShutdownAllocNode(game::scriptInstance_t inst);
}
-191
View File
@@ -1,191 +0,0 @@
#include <stdinc.hpp>
#include "clientscript_public.hpp"
namespace codsrc
{
// Decomp Status: Tested, Completed
void Scr_InitAllocNode(game::scriptInstance_t inst)
{
game::HunkUser* nodeUser;
assert(!game::g_allocNodeUser[inst]);
nodeUser = game::Hunk_UserCreate(0x10000, "Scr_InitAllocNode", false, true, false, 7);
game::g_allocNodeUser[inst] = nodeUser;
}
// Restored function
game::sval_u* Scr_AllocNode(game::scriptInstance_t inst, int size)
{
assert(game::g_allocNodeUser[inst]);
return (game::sval_u*)game::Hunk_UserAlloc(game::g_allocNodeUser[inst], 4 * size, 4);
}
// Decomp Status: Tested, Completed
game::sval_u node0()
{
game::sval_u result;
result.node = game::Scr_AllocNode(*game::gInst, 1);
result.node[0].intValue = game::ENUM_NOP;
return result;
}
// Decomp Status: Tested, Completed
game::sval_u node1(game::scr_enum_t type, game::sval_u val1)
{
game::sval_u result;
result.node = game::Scr_AllocNode(*game::gInst, 2);
result.node[0].intValue = type;
result.node[1].node = val1.node;
return result;
}
// Decomp Status: Tested, Completed
game::sval_u node2(game::scr_enum_t type, game::sval_u val1, game::sval_u val2)
{
game::sval_u result;
result.node = game::Scr_AllocNode(*game::gInst, 3);
result.node[0].intValue = type;
result.node[1].node = val1.node;
result.node[2].node = val2.node;
return result;
}
// Decomp Status: Tested, Completed
game::sval_u node3(game::scr_enum_t type, game::sval_u val1, game::sval_u val2, game::sval_u val3)
{
game::sval_u result;
result.node = game::Scr_AllocNode(*game::gInst,4);
result.node[0].intValue = type;
result.node[1].node = val1.node;
result.node[2].node = val2.node;
result.node[3].node = val3.node;
return result;
}
// Decomp Status: Tested, Completed
game::sval_u node4(game::scr_enum_t type, game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4)
{
game::sval_u result;
result.node = game::Scr_AllocNode(*game::gInst, 5);
result.node[0].intValue = type;
result.node[1].node = val1.node;
result.node[2].node = val2.node;
result.node[3].node = val3.node;
result.node[4].node = val4.node;
return result;
}
// Decomp Status: Tested, Completed
game::sval_u node5(game::scr_enum_t type, game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4, game::sval_u val5)
{
game::sval_u result;
result.node = game::Scr_AllocNode(*game::gInst, 6);
result.node[0].intValue = type;
result.node[1].node = val1.node;
result.node[2].node = val2.node;
result.node[3].node = val3.node;
result.node[4].node = val4.node;
result.node[5].node = val5.node;
return result;
}
// Decomp Status: Tested, Completed
game::sval_u node6(game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4, game::sval_u val5, game::sval_u val6)
{
game::sval_u result;
result.node = game::Scr_AllocNode(*game::gInst, 7);
result.node[0].intValue = game::ENUM_thread;
result.node[1].node = val1.node;
result.node[2].node = val2.node;
result.node[3].node = val3.node;
result.node[4].node = val4.node;
result.node[5].node = val5.node;
result.node[6].node = val6.node;
return result;
}
// Decomp Status: Tested, Completed
game::sval_u node7(game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4, game::sval_u val5, game::sval_u val6, game::sval_u val7)
{
game::sval_u result;
result.node = game::Scr_AllocNode(*game::gInst, 8);
result.node[0].intValue = game::ENUM_if_else;
result.node[1].node = val1.node;
result.node[2].node = val2.node;
result.node[3].node = val3.node;
result.node[4].node = val4.node;
result.node[5].node = val5.node;
result.node[6].node = val6.node;
result.node[7].node = val7.node;
return result;
}
// Decomp Status: Tested, Completed
game::sval_u node8(game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4, game::sval_u val5, game::sval_u val6, game::sval_u val7, game::sval_u val8)
{
game::sval_u result;
result.node = game::Scr_AllocNode(*game::gInst, 9);
result.node[0].intValue = game::ENUM_for;
result.node[1].node = val1.node;
result.node[2].node = val2.node;
result.node[3].node = val3.node;
result.node[4].node = val4.node;
result.node[5].node = val5.node;
result.node[6].node = val6.node;
result.node[7].node = val7.node;
result.node[8].node = val8.node;
return result;
}
// Decomp Status: Tested, Completed
game::sval_u linked_list_end(game::sval_u val1)
{
game::sval_u* node;
game::sval_u result;
node = game::Scr_AllocNode(*game::gInst, 2);
node[0].node = val1.node;
node[1].stringValue = 0;
result.node = game::Scr_AllocNode(*game::gInst, 2);
result.node[0].node = node;
result.node[1].node = node;
return result;
}
// Decomp Status: Tested, Completed
game::sval_u prepend_node(game::sval_u val1, game::sval_u val2)
{
game::sval_u* node;
node = game::Scr_AllocNode(*game::gInst, 2);
node[0] = val1;
node[1] = *val2.node;
val2.node->node = node;
return val2;
}
// Decomp Status: Tested, Completed
game::sval_u append_node(game::sval_u val1, game::sval_u val2)
{
game::sval_u* node;
node = game::Scr_AllocNode(*game::gInst, 2);
node[0] = val2;
node[1].stringValue = 0;
val1.node[1].node[1].stringValue = (unsigned int)node;
val1.node[1].node = node;
return val1;
}
}
@@ -1,19 +0,0 @@
#pragma once
namespace codsrc
{
void Scr_InitAllocNode(game::scriptInstance_t inst);
game::sval_u* Scr_AllocNode(game::scriptInstance_t inst, int size);
game::sval_u node0();
game::sval_u node1(game::scr_enum_t type, game::sval_u val1);
game::sval_u node2(game::scr_enum_t type, game::sval_u val1, game::sval_u val2);
game::sval_u node3(game::scr_enum_t type, game::sval_u val1, game::sval_u val2, game::sval_u val3);
game::sval_u node4(game::scr_enum_t type, game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4);
game::sval_u node5(game::scr_enum_t type, game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4, game::sval_u val5);
game::sval_u node6(game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4, game::sval_u val5, game::sval_u val6);
game::sval_u node7(game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4, game::sval_u val5, game::sval_u val6, game::sval_u val7);
game::sval_u node8(game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4, game::sval_u val5, game::sval_u val6, game::sval_u val7, game::sval_u val8);
game::sval_u linked_list_end(game::sval_u val1);
game::sval_u prepend_node(game::sval_u val1, game::sval_u val2);
game::sval_u append_node(game::sval_u val1, game::sval_u val2);
}
-117
View File
@@ -1,117 +0,0 @@
#include <stdinc.hpp>
#include "clientscript_public.hpp"
namespace codsrc
{
// Restored
unsigned int FindVariableIndexInternal(game::scriptInstance_t inst, unsigned int parentId, unsigned int name)
{
game::VariableValueInternal* parentValue;
assert(parentId);
parentValue = &game::gScrVarGlob[inst].parentVariables[parentId + 1];
assert((parentValue->w.status & VAR_STAT_MASK) == VAR_STAT_EXTERNAL);
assert((parentValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(IsObject(parentValue));
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)
{
unsigned int newIndex;
game::VariableValueInternal* newEntryValue;
game::VariableValueInternal* entryValue;
game::Variable* entry;
entry = &game::gScrVarGlob[inst].childVariables[index].hash;
entryValue = &game::gScrVarGlob[inst].childVariables[entry->id];
assert((name & VAR_NAME_LOW_MASK) == 0);
assert(index < VARIABLELIST_CHILD_SIZE);
assert(entry->id < VARIABLELIST_CHILD_SIZE);
if ((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_HEAD)
{
return 0;
}
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(!IsObject(entryValue));
if (entryValue->w.status >> VAR_NAME_BIT_SHIFT == name)
{
return index;
}
newIndex = entryValue->v.next;
for (entryValue = &game::gScrVarGlob[inst].childVariables[newIndex];
entryValue != &game::gScrVarGlob[inst].childVariables[index];
entryValue = &game::gScrVarGlob[inst].childVariables[newIndex])
{
newEntryValue = &game::gScrVarGlob[inst].childVariables[entryValue->hash.id];
assert((newEntryValue->w.status & VAR_STAT_MASK) == VAR_STAT_MOVABLE);
assert((newEntryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(!IsObject(newEntryValue));
if (newEntryValue->w.status >> VAR_NAME_BIT_SHIFT == name)
{
return newIndex;
}
newIndex = newEntryValue->v.next;
}
return 0;
}
// Decomp Status: Tested, Completed
unsigned int FindLastSibling(unsigned int parentId, game::scriptInstance_t inst)
{
game::VariableValueInternal* parentValue;
unsigned int nextParentVarIndex;
unsigned int id;
unsigned int childVarName;
unsigned int index;
assert(parentId);
parentValue = &game::gScrVarGlob[inst].parentVariables[parentId + 1];
assert((parentValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(IsObject(parentValue));
assert(((parentValue->w.status & VAR_STAT_MASK) == VAR_STAT_EXTERNAL));
nextParentVarIndex = parentValue->v.next + 1;
id = game::gScrVarGlob[inst].parentVariables[nextParentVarIndex].hash.u.prev;
if (!id)
{
return 0;
}
childVarName = game::gScrVarGlob[inst].childVariables[id].w.status >> VAR_NAME_BIT_SHIFT;
index = game::FindVariableIndexInternal(inst, parentId, childVarName);
assert(index);
return index;
}
}
@@ -1,8 +0,0 @@
#pragma once
namespace codsrc
{
unsigned int FindVariableIndexInternal2(game::scriptInstance_t inst, unsigned int name, unsigned int index);
unsigned int FindLastSibling(unsigned int parentId, game::scriptInstance_t inst);
unsigned int FindVariableIndexInternal(game::scriptInstance_t inst, unsigned int parentId, unsigned int name);
}
-821
View File
@@ -1,821 +0,0 @@
#include <stdinc.hpp>
#include "clientscript_public.hpp"
namespace codsrc
{
// Restored
game::RefString* GetRefString(game::scriptInstance_t inst, unsigned int id)
{
assert(id);
assert((id * MT_NODE_SIZE) < MT_SIZE);
return (game::RefString*)&game::gScrMemTreePub[inst].mt_buffer->nodes[id];
}
// Restored
game::RefString * GetRefString_0([[maybe_unused]] game::scriptInstance_t inst, const char *str)
{
assert(str >= (char*)game::gScrMemTreePub[inst].mt_buffer && str < (char*)(game::gScrMemTreePub[inst].mt_buffer + MT_SIZE));
return (game::RefString *)(str - 4);
}
// Restored
int SL_ConvertFromRefString(game::scriptInstance_t inst, game::RefString *refString)
{
return ((char *)refString - (char *)game::gScrMemTreePub[inst].mt_buffer) / MT_NODE_SIZE;
}
// Restored
int SL_ConvertFromString(game::scriptInstance_t inst, const char *str)
{
game::RefString *v2;
assert(str);
v2 = game::GetRefString_0(inst, str);
return game::SL_ConvertFromRefString(inst, v2);
}
// Restored
const char* SL_ConvertToStringSafe(unsigned int id, game::scriptInstance_t inst)
{
if (!id)
{
return "(NULL)";
}
return game::GetRefString(inst, id)->str;
}
// Decomp Status: Completed
char* SL_ConvertToString(unsigned int id, game::scriptInstance_t inst)
{
//assert((!id || !game::gScrStringDebugGlob[inst] || game::gScrStringDebugGlob[inst]->refCount[id]));
if (!id)
{
return nullptr;
}
return game::GetRefString(inst, id)->str;
}
// Restored
int SL_GetRefStringLen(game::RefString* refString)
{
int len;
for ( len = refString->u.s.byteLen - 1;
refString->str[len];
len += 256 )
{
;
}
return len;
}
// Decomp Status: Completed
int SL_GetStringLen(unsigned int stringValue, game::scriptInstance_t inst)
{
game::RefString *refString;
assert(stringValue);
refString = game::GetRefString(inst, stringValue);
return game::SL_GetRefStringLen(refString);
}
// Decomp Status: Completed
unsigned int GetHashCode(unsigned int len, const char* str)
{
unsigned int i;
if (len >= 0x100)
{
return (len >> 2) % 0x61A7 + 1;
}
for (i = 0; len; --len)
{
i = 31 * i + *str++;
}
return i % 0x61A7 + 1;
}
// Decomp Status: Completed
void SL_Init(game::scriptInstance_t inst)
{
unsigned int hash;
game::HashEntry *entry;
unsigned int prev;
assert(!game::gScrStringGlob[inst].inited);
game::MT_Init(inst);
game::Sys_EnterCriticalSection(game::CRITSECT_SCRIPT_STRING);
game::gScrStringGlob[inst].hashTable[0].status_next = 0;
prev = 0;
for (hash = 1;
hash < HASH_MAX_HASHES;
++hash)
{
assert(!(hash & HASH_STAT_MASK));
entry = &game::gScrStringGlob[inst].hashTable[hash];
entry->status_next = 0;
game::gScrStringGlob[inst].hashTable[prev].status_next |= hash;
entry->u.prev = prev;
prev = hash;
}
assert(!(game::gScrStringGlob[inst].hashTable[prev].status_next));
game::gScrStringGlob[inst].hashTable[0].u.prev = prev;
game::gScrStringGlob[inst].inited = 1;
game::Sys_LeaveCriticalSection(game::CRITSECT_SCRIPT_STRING);
}
// Decomp Status: Completed
unsigned int SL_FindStringOfSize(game::scriptInstance_t inst, const char* str, unsigned int len)
{
unsigned int stringValue;
game::HashEntry *entry;
int hash;
unsigned int newIndex;
game::RefString *refStr;
game::RefString *refStra;
unsigned int prev;
game::HashEntry *newEntry;
assert(str);
hash = game::GetHashCode(len, str);
game::Sys_EnterCriticalSection(game::CRITSECT_SCRIPT_STRING);
entry = &game::gScrStringGlob[inst].hashTable[hash];
if ( (entry->status_next & HASH_STAT_MASK) != HASH_STAT_HEAD )
{
game::Sys_LeaveCriticalSection(game::CRITSECT_SCRIPT_STRING);
return 0;
}
refStr = game::GetRefString(inst, entry->u.prev);
if ( (unsigned char)refStr->u.s.byteLen != (unsigned char)len || memcmp(refStr->str, str, len) )
{
prev = hash;
newIndex = (unsigned short)entry->status_next;
for ( newEntry = &game::gScrStringGlob[inst].hashTable[newIndex];
newEntry != entry;
newEntry = &game::gScrStringGlob[inst].hashTable[newIndex] )
{
assert((newEntry->status_next & HASH_STAT_MASK) == HASH_STAT_MOVABLE);
refStra = game::GetRefString(inst, newEntry->u.prev);
if ( (unsigned char)refStra->u.s.byteLen == (unsigned char)len && !memcmp(refStra->str, str, len) )
{
game::gScrStringGlob[inst].hashTable[prev].status_next = (unsigned short)newEntry->status_next | game::gScrStringGlob[inst].hashTable[prev].status_next & HASH_STAT_MASK;
newEntry->status_next = (unsigned short)entry->status_next | newEntry->status_next & HASH_STAT_MASK;
entry->status_next = newIndex | entry->status_next & HASH_STAT_MASK;
stringValue = newEntry->u.prev;
newEntry->u.prev = entry->u.prev;
entry->u.prev = stringValue;
assert((newEntry->status_next & HASH_STAT_MASK) != HASH_STAT_FREE);
assert((entry->status_next & HASH_STAT_MASK) != HASH_STAT_FREE);
assert(refStra->str == game::SL_ConvertToString(stringValue, inst));
game::Sys_LeaveCriticalSection(game::CRITSECT_SCRIPT_STRING);
return stringValue;
}
prev = newIndex;
newIndex = (unsigned short)newEntry->status_next;
}
game::Sys_LeaveCriticalSection(game::CRITSECT_SCRIPT_STRING);
return 0;
}
assert((entry->status_next & HASH_STAT_MASK) != HASH_STAT_FREE);
stringValue = entry->u.prev;
assert(refStr->str == game::SL_ConvertToString(stringValue, inst));
game::Sys_LeaveCriticalSection(game::CRITSECT_SCRIPT_STRING);
return stringValue;
}
// Decomp Status: Completed
unsigned int SL_FindString(const char* str, game::scriptInstance_t inst)
{
return game::SL_FindStringOfSize(inst, str, strlen(str) + 1);
}
// Decomp Status: Completed
unsigned int SL_FindLowercaseString(const char* str, game::scriptInstance_t inst)
{
char stra[8196];
unsigned int len;
int i;
len = strlen(str) + 1;
if ( (int)len > 0x2000 )
return 0;
for ( i = 0;
i < (int)len;
++i )
{
stra[i] = (char)tolower(str[i]);
}
return game::SL_FindStringOfSize(inst, stra, len);
}
// Decomp Status: Completed
void SL_AddUserInternal(unsigned int user, game::RefString* refStr)
{
unsigned __int32 data;
if ( ((unsigned __int8)user & (unsigned __int8)refStr->u.s.user) == 0 )
{
do
data = refStr->u.data;
while ( InterlockedCompareExchange((volatile unsigned int*)&refStr->u.data, data | (user << 16), data) != data);
InterlockedExchangeAdd((volatile unsigned int*)&refStr->u.data, 1u);
}
}
// Restored
void SL_AddUser(unsigned int stringValue, unsigned int user, game::scriptInstance_t inst)
{
game::RefString *refStr;
refStr = game::GetRefString(inst, stringValue);
game::SL_AddUserInternal(user, refStr);
}
// Decomp Status: Untested unknown how to test, completed
void Mark_ScriptStringCustom(unsigned int var)
{
game::SL_AddUser(var, 4u, game::SCRIPTINSTANCE_SERVER);
}
// Decomp Status: Completed
unsigned int SL_GetStringOfSize(game::scriptInstance_t inst, const char* str, unsigned int user, unsigned int len)
{
unsigned int stringValue;
game::HashEntry* entry;
unsigned int newNext;
unsigned int newNexta;
int hash;
unsigned int newIndex;
unsigned int newIndexa;
unsigned int newIndexb;
game::RefString *refStr;
game::RefString *refStra;
game::RefString *refStrb;
unsigned int nexta;
unsigned int next;
unsigned int prev;
unsigned int prevb;
unsigned int preva;
game::HashEntry *newEntry;
game::HashEntry *newEntrya;
game::HashEntry *newEntryb;
assert(str);
hash = game::GetHashCode(len, str);
game::Sys_EnterCriticalSection(game::CRITSECT_SCRIPT_STRING);
entry = &game::gScrStringGlob[inst].hashTable[hash];
if ( (entry->status_next & HASH_STAT_MASK) == HASH_STAT_HEAD )
{
refStr = game::GetRefString(inst, entry->u.prev);
if ( (unsigned char)refStr->u.s.byteLen == (unsigned char)len && !memcmp(refStr->str, str, len) )
{
game::SL_AddUserInternal(user, refStr);
assert((entry->status_next & HASH_STAT_MASK) != HASH_STAT_FREE);
stringValue = entry->u.prev;
assert(refStr->str == game::SL_ConvertToString(stringValue, inst));
game::Sys_LeaveCriticalSection(game::CRITSECT_SCRIPT_STRING);
return stringValue;
}
prev = hash;
newIndex = (unsigned short)entry->status_next;
for ( newEntry = &game::gScrStringGlob[inst].hashTable[newIndex];
newEntry != entry;
newEntry = &game::gScrStringGlob[inst].hashTable[newIndex] )
{
assert((newEntry->status_next & HASH_STAT_MASK) == HASH_STAT_MOVABLE);
refStra = game::GetRefString(inst, newEntry->u.prev);
if ( (unsigned char)refStra->u.s.byteLen == (unsigned char)len && !memcmp(refStra->str, str, len) )
{
game::gScrStringGlob[inst].hashTable[prev].status_next = (unsigned short)newEntry->status_next | game::gScrStringGlob[inst].hashTable[prev].status_next & HASH_STAT_MASK;
newEntry->status_next = (unsigned short)entry->status_next | newEntry->status_next & HASH_STAT_MASK;
entry->status_next = newIndex | entry->status_next & HASH_STAT_MASK;
stringValue = newEntry->u.prev;
newEntry->u.prev = entry->u.prev;
entry->u.prev = stringValue;
game::SL_AddUserInternal(user, refStra);
assert((newEntry->status_next & HASH_STAT_MASK) != HASH_STAT_FREE);
assert((entry->status_next & HASH_STAT_MASK) != HASH_STAT_FREE);
assert(refStra->str == game::SL_ConvertToString(stringValue, inst));
game::Sys_LeaveCriticalSection(game::CRITSECT_SCRIPT_STRING);
return stringValue;
}
prev = newIndex;
newIndex = (unsigned short)newEntry->status_next;
}
newIndexa = game::gScrStringGlob[inst].hashTable->status_next;
if ( !newIndexa )
{
game::Scr_DumpScriptThreads(inst);
game::Com_Error(game::ERR_DROP, "\x15" "exceeded maximum number of script strings\n");
}
stringValue = game::MT_AllocIndex(inst, len + 4);
newEntrya = &game::gScrStringGlob[inst].hashTable[newIndexa];
assert((newEntrya->status_next & HASH_STAT_MASK) == HASH_STAT_FREE);
newNext = (unsigned short)newEntrya->status_next;
game::gScrStringGlob[inst].hashTable->status_next = newNext;
game::gScrStringGlob[inst].hashTable[newNext].u.prev = 0;
newEntrya->status_next = (unsigned short)entry->status_next | HASH_STAT_MOVABLE;
entry->status_next = (unsigned short)newIndexa | entry->status_next & HASH_STAT_MASK;
newEntrya->u.prev = entry->u.prev;
}
else
{
if ( (entry->status_next & HASH_STAT_MASK) != HASH_STAT_FREE )
{
assert((entry->status_next & HASH_STAT_MASK) == HASH_STAT_MOVABLE);
next = (unsigned short)entry->status_next;
for ( preva = next;
(unsigned short)game::gScrStringGlob[inst].hashTable[preva].status_next != hash;
preva = (unsigned short)game::gScrStringGlob[inst].hashTable[preva].status_next )
{
;
}
assert(preva);
newIndexb = game::gScrStringGlob[inst].hashTable->status_next;
if ( !newIndexb )
{
game::Scr_DumpScriptThreads(inst);
game::Com_Error(game::ERR_DROP, "\x15" "exceeded maximum number of script strings\n");
}
stringValue = game::MT_AllocIndex(inst, len + 4);
newEntryb = &game::gScrStringGlob[inst].hashTable[newIndexb];
assert((newEntryb->status_next & HASH_STAT_MASK) == HASH_STAT_FREE);
newNexta = (unsigned short)newEntryb->status_next;
game::gScrStringGlob[inst].hashTable->status_next = newNexta;
game::gScrStringGlob[inst].hashTable[newNexta].u.prev = 0;
game::gScrStringGlob[inst].hashTable[preva].status_next = newIndexb | game::gScrStringGlob[inst].hashTable[preva].status_next & HASH_STAT_MASK;
newEntryb->status_next = next | HASH_STAT_MOVABLE;
newEntryb->u.prev = entry->u.prev;
}
else
{
stringValue = game::MT_AllocIndex(inst, len + 4);
prevb = entry->u.prev;
nexta = (unsigned short)entry->status_next;
game::gScrStringGlob[inst].hashTable[prevb].status_next = nexta | game::gScrStringGlob[inst].hashTable[prevb].status_next & HASH_STAT_MASK;
game::gScrStringGlob[inst].hashTable[nexta].u.prev = prevb;
}
assert((hash & HASH_STAT_MASK) == 0);
entry->status_next = hash | HASH_STAT_HEAD;
}
assert(stringValue);
entry->u.prev = stringValue;
refStrb = game::GetRefString(inst, stringValue);
memcpy(refStrb->str, str, len);
refStrb->u.s.user = user;
assert(refStrb->u.s.user == user);
refStrb->u.s.refCount = 1;
refStrb->u.s.byteLen = len;
assert((entry->status_next & HASH_STAT_MASK) != HASH_STAT_FREE);
assert(refStrb->str == game::SL_ConvertToString(stringValue, inst));
game::Sys_LeaveCriticalSection(game::CRITSECT_SCRIPT_STRING);
return stringValue;
}
// Decomp Status: Untested unknown how to test, Completed
unsigned int SL_GetString_(const char* str, game::scriptInstance_t inst, unsigned int user)
{
return game::SL_GetStringOfSize(inst, str, user, strlen(str) + 1);
}
// Decomp Status: Completed
unsigned int SL_GetString__0(const char* str, unsigned int user, game::scriptInstance_t inst)
{
return game::SL_GetStringOfSize(inst, str, user, strlen(str) + 1);
}
// Decomp Status: Completed
unsigned int SL_GetLowercaseStringOfLen(game::scriptInstance_t inst, const char* str, unsigned int user, unsigned int len)
{
char stra[SL_MAX_STRING_LEN];
unsigned int i;
if (len > SL_MAX_STRING_LEN)
{
game::Com_Error(game::ERR_DROP, "max string length exceeded: \"%s\"", str);
}
for ( i = 0;
i < len;
++i )
{
stra[i] = (char)tolower(str[i]);
}
return game::SL_GetStringOfSize(inst, stra, user, len);
}
// Decomp Status: Completed
unsigned int SL_GetLowercaseString(const char* str)
{
return game::SL_GetLowercaseStringOfLen(game::SCRIPTINSTANCE_SERVER, str, 0, strlen(str) + 1);
}
// Decomp Status: Completed
unsigned int SL_ConvertToLowercase(game::scriptInstance_t inst, unsigned int stringVal, unsigned int user)
{
char *strCopy;
char str[SL_MAX_STRING_LEN];
unsigned int answer;
unsigned int len;
unsigned int i;
len = game::SL_GetStringLen(stringVal, inst) + 1;
if ( len > SL_MAX_STRING_LEN)
{
return stringVal;
}
strCopy = game::SL_ConvertToString(stringVal, inst);
for ( i = 0;
i < len;
++i )
{
str[i] = (char)tolower(strCopy[i]);
}
answer = game::SL_GetStringOfSize(inst, str, user, len);
game::SL_RemoveRefToString(stringVal, inst);
return answer;
}
// Decomp Status: Completed
void SL_TransferRefToUser(unsigned int stringValue, unsigned int user, game::scriptInstance_t inst)
{
unsigned int data;
game::RefString *refStr;
refStr = game::GetRefString(inst, stringValue);
if ( ((unsigned char)user & (unsigned char)refStr->u.s.user) != 0 )
{
InterlockedExchangeAdd((volatile unsigned int*)&refStr->u.data, 0xFFFFFFFF);
}
else
{
do
data = refStr->u.data;
while ( InterlockedCompareExchange((volatile unsigned int*)&refStr->u.data, data | (user << 16), data) != data );
}
}
// Decomp Status: Completed
void SL_FreeString(game::scriptInstance_t inst, unsigned int stringValue, game::RefString* refStr, unsigned int len)
{
game::HashEntry *entry;
unsigned int newIndex;
unsigned int newNext;
int index;
unsigned int prev;
game::HashEntry *newEntry;
index = game::GetHashCode(len, refStr->str);
game::Sys_EnterCriticalSection(game::CRITSECT_SCRIPT_STRING);
if ( !(unsigned short)refStr->u.s.refCount )
{
entry = &game::gScrStringGlob[inst].hashTable[index];
game::MT_FreeIndex(len + 4, inst, stringValue);
assert(((entry->status_next & HASH_STAT_MASK) == HASH_STAT_HEAD));
newIndex = (unsigned short)entry->status_next;
newEntry = &game::gScrStringGlob[inst].hashTable[newIndex];
if ( entry->u.prev == stringValue )
{
if ( newEntry == entry )
{
newEntry = entry;
newIndex = index;
}
else
{
entry->status_next = (unsigned short)newEntry->status_next | HASH_STAT_HEAD;
entry->u.prev = newEntry->u.prev;
game::gScrStringGlob[inst].nextFreeEntry = entry;
}
}
else
{
prev = index;
while ( 1 )
{
assert(newEntry != entry);
assert((newEntry->status_next & HASH_STAT_MASK) == HASH_STAT_MOVABLE);
if ( newEntry->u.prev == stringValue )
{
break;
}
prev = newIndex;
newIndex = (unsigned short)newEntry->status_next;
newEntry = &game::gScrStringGlob[inst].hashTable[newIndex];
}
game::gScrStringGlob[inst].hashTable[prev].status_next = (unsigned short)newEntry->status_next | game::gScrStringGlob[inst].hashTable[prev].status_next & HASH_STAT_MASK;
}
assert((newEntry->status_next & HASH_STAT_MASK) != HASH_STAT_FREE);
newNext = game::gScrStringGlob[inst].hashTable->status_next;
assert((newNext & HASH_STAT_MASK) == HASH_STAT_FREE);
newEntry->status_next = newNext;
newEntry->u.prev = 0;
game::gScrStringGlob[inst].hashTable[newNext].u.prev = newIndex;
game::gScrStringGlob[inst].hashTable->status_next = newIndex;
}
game::Sys_LeaveCriticalSection(game::CRITSECT_SCRIPT_STRING);
}
// Restored
void SL_RemoveRefToStringOfSize(game::scriptInstance_t inst, unsigned int stringValue, unsigned int len)
{
game::RefString *refStr;
refStr = game::GetRefString(inst, stringValue);
if ( !(unsigned __int16)InterlockedDecrement((volatile unsigned int*)&refStr->u.data))
{
game::SL_FreeString(inst, stringValue, refStr, len);
}
}
// Decomp Status: Tested, Completed
void SL_RemoveRefToString(unsigned int stringVal, game::scriptInstance_t inst)
{
game::RefString *refStr;
int len;
refStr = game::GetRefString(inst, stringVal);
len = game::SL_GetRefStringLen(refStr) + 1;
game::SL_RemoveRefToStringOfSize(inst, stringVal, len);
}
// Restored
void SL_AddRefToString(game::scriptInstance_t inst, unsigned int stringValue)
{
game::RefString* refStr = game::GetRefString(inst, stringValue);
InterlockedExchangeAdd((volatile unsigned int*)&refStr->u.data, 1u);
}
// Decomp Status: Tested, Completed
void Scr_SetString(game::scriptInstance_t inst, unsigned int from, unsigned __int16* to)
{
if (from)
{
game::SL_AddRefToString(inst, from);
}
if (*to)
{
game::SL_RemoveRefToString(*to, inst);
}
*to = (unsigned short)from;
}
// Decomp Status: Tested, Completed
void Scr_SetStringFromCharString(const char* from, unsigned __int16* to)
{
if (*to)
{
game::SL_RemoveRefToString(*to, game::SCRIPTINSTANCE_SERVER);
}
*to = (unsigned short)game::SL_GetString_(from, game::SCRIPTINSTANCE_SERVER, 0);
}
// Decomp Status: Tested, Completed
unsigned int GScr_AllocString(const char* str, game::scriptInstance_t inst)
{
return game::SL_GetString_(str, inst, 1);
}
// Decomp Status: Tested, Completed
unsigned int SL_GetStringForFloat(float floatVal, game::scriptInstance_t inst)
{
char Buffer[128];
sprintf_s(Buffer, "%g", floatVal);
return game::SL_GetString_(Buffer, inst, 0);
}
// Decomp Status: Tested, Completed
unsigned int SL_GetStringForInt(int intVal, game::scriptInstance_t inst)
{
char Buffer[128];
sprintf_s(Buffer, "%i", intVal);
return game::SL_GetString_(Buffer, inst, 0);
}
// Decomp Status: Tested, Completed
unsigned int SL_GetStringForVector(float* vector, game::scriptInstance_t inst)
{
char Buffer[128];
sprintf_s(Buffer, "(%g, %g, %g)", vector[0], vector[1], vector[2]);
return game::SL_GetString_(Buffer, inst, 0);
}
// Decomp Status: Tested, Completed
void SL_ShutdownSystem(game::scriptInstance_t inst, unsigned int user)
{
unsigned int hash;
game::HashEntry *entry;
game::RefString *refStr;
assert(user);
game::Sys_EnterCriticalSection(game::CRITSECT_SCRIPT_STRING);
for ( hash = 1;
hash < HASH_MAX_HASHES;
++hash )
{
do
{
entry = &game::gScrStringGlob[inst].hashTable[hash];
if ( (entry->status_next & HASH_STAT_MASK) == HASH_STAT_FREE )
{
break;
}
refStr = game::GetRefString(inst, entry->u.prev);
if ( ((unsigned char)user & (unsigned char)refStr->u.s.user) == 0 )
{
break;
}
refStr->u.s.user &= ~user;
game::gScrStringGlob[inst].nextFreeEntry = 0;
game::SL_RemoveRefToString(entry->u.prev, inst);
}
while ( game::gScrStringGlob[inst].nextFreeEntry );
}
game::Sys_LeaveCriticalSection(game::CRITSECT_SCRIPT_STRING);
}
// Decomp Status: Tested, Completed, Optimized args
void SL_TransferSystem()
{
unsigned int hash;
game::HashEntry *entry;
game::RefString* refStr;
// args
int from = 4;
int to = 8;
game::scriptInstance_t inst = game::SCRIPTINSTANCE_SERVER;
assert(from);
assert(to);
game::Sys_EnterCriticalSection(game::CRITSECT_SCRIPT_STRING);
for (hash = 1; hash < HASH_MAX_HASHES; hash++)
{
entry = &game::gScrStringGlob[inst].hashTable[hash];
if ((entry->status_next & HASH_STAT_MASK) != HASH_STAT_FREE)
{
refStr = game::GetRefString(inst, entry->u.prev);
if ( ((unsigned __int8)from & (unsigned __int8)refStr->u.s.user) != 0 )
{
refStr->u.s.user &= ~from;
refStr->u.s.user |= to;
}
}
}
game::Sys_LeaveCriticalSection(game::CRITSECT_SCRIPT_STRING);
}
// Decomp Status: Tested, Completed
void SL_CreateCanonicalFilename(const char* filename, char* newFilename)
{
int count;
unsigned int c;
count = 1024;
do
{
do
{
do
{
c = *filename++;
} while (c == '\\');
} while (c == '/');
if (c >= ' ')
{
while (1)
{
*newFilename++ = (char)tolower(c);
if (!--count)
{
game::Com_Error(game::ERR_DROP, "\x15" "Filename '%s' exceeds maximum length of %d", filename, 0);
}
if (c == '/')
{
break;
}
c = *filename++;
if (c == '\\')
{
c = '/';
}
else if (c < ' ')
{
break;
}
}
}
} while (c);
*newFilename = 0;
}
// Decomp Status: Tested, Completed
unsigned int Scr_CreateCanonicalFilename(game::scriptInstance_t inst, const char* filename)
{
char newFileName[1024];
game::SL_CreateCanonicalFilename(filename, newFileName);
return game::SL_GetString_(newFileName, inst, 0);
}
}
@@ -1,42 +0,0 @@
#pragma once
namespace codsrc
{
char* SL_ConvertToString(unsigned int id, game::scriptInstance_t inst);
int SL_GetStringLen(unsigned int a1, game::scriptInstance_t a2);
unsigned int GetHashCode(unsigned int a1, const char* a2);
void SL_Init(game::scriptInstance_t a1);
unsigned int SL_FindStringOfSize(game::scriptInstance_t inst, const char* str, unsigned int len);
unsigned int SL_FindString(const char* a1, game::scriptInstance_t a2);
unsigned int SL_FindLowercaseString(const char* str, game::scriptInstance_t inst);
void SL_AddUserInternal(unsigned int user, game::RefString* refStr);
void Mark_ScriptStringCustom(unsigned int a1);
unsigned int SL_GetStringOfSize(game::scriptInstance_t inst, const char* string, unsigned int user, unsigned int len);
unsigned int SL_GetString_(const char* a1, game::scriptInstance_t a2, unsigned int user);
unsigned int SL_GetString__0(const char* a1, unsigned int user, game::scriptInstance_t a3);
unsigned int SL_GetLowercaseStringOfLen(game::scriptInstance_t a1, const char* ArgList, unsigned int user, unsigned int len);
unsigned int SL_GetLowercaseString(const char* a2);
unsigned int SL_ConvertToLowercase(game::scriptInstance_t inst, unsigned int stringVal, unsigned int user);
void SL_TransferRefToUser(unsigned int stringValue, unsigned int user, game::scriptInstance_t inst);
void SL_FreeString(game::scriptInstance_t inst, unsigned int stringValue, game::RefString* refStr, unsigned int len);
void SL_RemoveRefToString(unsigned int stringVal, game::scriptInstance_t inst);
void SL_AddRefToString(game::scriptInstance_t inst, unsigned int stringValue);
void Scr_SetString(game::scriptInstance_t inst, unsigned int from, unsigned __int16* to);
void Scr_SetStringFromCharString(const char* from, unsigned __int16* to);
unsigned int GScr_AllocString(const char* a1, game::scriptInstance_t inst);
unsigned int SL_GetStringForFloat(float floatVal, game::scriptInstance_t inst);
unsigned int SL_GetStringForInt(int intVal, game::scriptInstance_t inst);
unsigned int SL_GetStringForVector(float* vector, game::scriptInstance_t inst);
void SL_ShutdownSystem(game::scriptInstance_t inst, unsigned int user);
void SL_TransferSystem();
void SL_CreateCanonicalFilename(const char* filename, char* newFilename);
unsigned int Scr_CreateCanonicalFilename(game::scriptInstance_t inst, const char* filename);
game::RefString* GetRefString(game::scriptInstance_t inst, unsigned int id);
void SL_RemoveRefToStringOfSize(game::scriptInstance_t inst, unsigned int stringValue, unsigned int len);
int SL_GetRefStringLen(game::RefString* refString);
void SL_AddUser(unsigned int stringValue, unsigned int user, game::scriptInstance_t inst);
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);
}
@@ -1,23 +0,0 @@
#include <stdinc.hpp>
#include "clientscript_public.hpp"
namespace codsrc
{
// 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 TempMemorySetPos(char* pos)
{
(*game::g_user)->pos = (int)pos;
}
}
@@ -1,8 +0,0 @@
#pragma once
namespace codsrc
{
char* TempMalloc(int len);
void TempMemoryReset(game::HunkUser* user);
void TempMemorySetPos(char* pos);
}
File diff suppressed because it is too large Load Diff
-141
View File
@@ -1,141 +0,0 @@
#pragma once
namespace codsrc
{
int ThreadInfoCompare(const void* a1, const void* a2);
void Scr_DumpScriptThreads(game::scriptInstance_t scriptInstance);
void Scr_InitVariableRange(unsigned int a1, unsigned int a2, game::scriptInstance_t inst);
void Scr_InitClassMap(game::scriptInstance_t inst);
unsigned int GetNewVariableIndexInternal3(game::scriptInstance_t inst, unsigned int parentId, unsigned int name, unsigned int index);
unsigned int GetNewVariableIndexInternal2(unsigned int name, game::scriptInstance_t inst, unsigned int parentId, unsigned int index);
unsigned int GetNewVariableIndexReverseInternal2(unsigned int name, game::scriptInstance_t inst, unsigned int parentId, unsigned int index);
void MakeVariableExternal(game::VariableValueInternal* parentValue, game::scriptInstance_t inst, unsigned int index);
void FreeChildValue(unsigned int id, game::scriptInstance_t inst, unsigned int parentId);
void ClearObjectInternal(game::scriptInstance_t inst, unsigned int parentId);
void ClearObject(unsigned int a1, game::scriptInstance_t inst);
void Scr_StopThread(game::scriptInstance_t inst, unsigned int a2);
unsigned int GetSafeParentLocalId(game::scriptInstance_t inst, unsigned int a2);
unsigned int GetStartLocalId(unsigned int result, game::scriptInstance_t inst);
void Scr_KillThread(game::scriptInstance_t inst, unsigned int parentId_1);
unsigned __int16 AllocVariable(game::scriptInstance_t inst);
void FreeVariable(unsigned int a1, game::scriptInstance_t inst);
unsigned int AllocValue(game::scriptInstance_t inst);
unsigned int AllocEntity(game::classNum_e classnum, game::scriptInstance_t inst, int entnum, int clientnum);
unsigned int Scr_AllocArray(game::scriptInstance_t a1);
unsigned int AllocChildThread(game::scriptInstance_t inst, unsigned int a2, unsigned int a3);
void FreeValue(unsigned int id, game::scriptInstance_t inst);
void RemoveRefToObject(unsigned int id, game::scriptInstance_t inst);
float* Scr_AllocVector(game::scriptInstance_t a1);
void RemoveRefToVector(const float* vectorValue, game::scriptInstance_t inst);
void AddRefToValue(game::scriptInstance_t inst, game::VariableType type, game::VariableUnion u);
void RemoveRefToValueInternal(game::scriptInstance_t inst, game::VariableType type, game::VariableUnion a3);
unsigned int FindArrayVariable(unsigned int id, unsigned int intvalue, game::scriptInstance_t inst);
unsigned int FindVariable(unsigned int name, unsigned int a2, game::scriptInstance_t inst);
unsigned int GetArrayVariableIndex(unsigned int unsignedValue, game::scriptInstance_t inst, unsigned int parentId);
unsigned int Scr_GetVariableFieldIndex(game::scriptInstance_t inst, unsigned int name, unsigned int parentId);
game::VariableValue Scr_FindVariableField(game::scriptInstance_t inst, unsigned int parentId, unsigned int name);
void ClearVariableField(game::scriptInstance_t inst, unsigned int id, unsigned int name, game::VariableValue* value);
unsigned int GetVariable(game::scriptInstance_t inst, unsigned int parentId, unsigned int name);
unsigned int GetNewVariable(game::scriptInstance_t inst, unsigned int a2, unsigned int a3);
unsigned int GetObjectVariable(unsigned int a1, game::scriptInstance_t inst, unsigned int parentId);
unsigned int GetNewObjectVariable(game::scriptInstance_t inst, unsigned int name, unsigned int parentId);
void RemoveVariable(unsigned int name, unsigned int parentId, game::scriptInstance_t inst);
void RemoveNextVariable(game::scriptInstance_t inst, unsigned int parentId);
void SafeRemoveVariable(unsigned int unsignedValue, unsigned int parentId, game::scriptInstance_t inst);
void CopyArray(game::scriptInstance_t inst, unsigned int parentId, unsigned int newParentId);
void SetVariableValue(game::scriptInstance_t inst, game::VariableValue* a2, unsigned int a3);
void SetVariableEntityFieldValue(game::scriptInstance_t inst, unsigned int parentId, unsigned int name, game::VariableValue* a4);
game::VariableValue Scr_EvalVariable(game::scriptInstance_t inst, unsigned int a2);
unsigned int Scr_EvalVariableObject(game::scriptInstance_t inst, unsigned int a2);
game::VariableValue Scr_EvalVariableEntityField(unsigned int entId, game::scriptInstance_t inst, unsigned int name);
game::VariableValue Scr_EvalVariableField(game::scriptInstance_t inst, unsigned int id);
void Scr_EvalSizeValue(game::scriptInstance_t inst, game::VariableValue* value);
unsigned int GetObject(game::scriptInstance_t inst, unsigned int a2);
unsigned int GetArray(game::scriptInstance_t inst, unsigned int a2);
void Scr_EvalBoolComplement(game::scriptInstance_t inst, game::VariableValue* a2);
void Scr_CastBool(game::scriptInstance_t inst, game::VariableValue* a2);
char Scr_CastString(game::scriptInstance_t inst, game::VariableValue* a2);
void Scr_CastDebugString(game::scriptInstance_t inst, game::VariableValue* a2);
void Scr_ClearVector(game::scriptInstance_t inst, game::VariableValue* a2);
void Scr_CastVector(game::scriptInstance_t inst, game::VariableValue* a2);
game::VariableUnion Scr_EvalFieldObject(game::VariableValue* a1, game::scriptInstance_t inst, unsigned int a3);
void Scr_UnmatchingTypesError(game::scriptInstance_t inst, game::VariableValue* a2, game::VariableValue* value);
void Scr_CastWeakerPair(game::VariableValue* a1, game::VariableValue* a2, game::scriptInstance_t inst);
void Scr_CastWeakerStringPair(game::VariableValue* a1, game::VariableValue* a2, game::scriptInstance_t inst);
void Scr_EvalOr(game::VariableValue* result, game::VariableValue* a2, game::scriptInstance_t inst);
void Scr_EvalExOr(game::VariableValue* result, game::VariableValue* a2, game::scriptInstance_t inst);
void Scr_EvalAnd(game::VariableValue* result, game::VariableValue* a2, game::scriptInstance_t inst);
void Scr_EvalEquality(game::VariableValue* a1, game::scriptInstance_t inst, game::VariableValue* a4);
void Scr_EvalLess(game::VariableValue* a1, game::VariableValue* a2, game::scriptInstance_t inst);
void Scr_EvalGreaterEqual(game::scriptInstance_t inst, game::VariableValue* a2, game::VariableValue* a3);
void Scr_EvalGreater(game::VariableValue* a1, game::VariableValue* a2, game::scriptInstance_t inst);
void Scr_EvalLessEqual(game::scriptInstance_t inst, game::VariableValue* a2, game::VariableValue* a3);
void Scr_EvalShiftLeft(game::VariableValue* result, game::VariableValue* a2, game::scriptInstance_t inst);
void Scr_EvalShiftRight(game::VariableValue* result, game::VariableValue* a2, game::scriptInstance_t inst);
void Scr_EvalPlus(game::scriptInstance_t inst, game::VariableValue* a1, game::VariableValue* a2);
void Scr_EvalMinus(game::VariableValue* a1, game::scriptInstance_t inst, game::VariableValue* a3);
void Scr_EvalMultiply(game::VariableValue* a1, game::scriptInstance_t inst, game::VariableValue* a3);
void Scr_EvalDivide(game::VariableValue* a1, game::scriptInstance_t inst, game::VariableValue* a3);
void Scr_EvalMod(game::scriptInstance_t inst, game::VariableValue* a2, game::VariableValue* a3);
void Scr_EvalBinaryOperator(game::scriptInstance_t inst, game::VariableValue* a2, game::OpcodeVM a4, game::VariableValue* a5);
void Scr_FreeEntityNum(game::scriptInstance_t inst, game::classNum_e classnum, unsigned int entnum);
void Scr_FreeEntityList(game::scriptInstance_t inst);
void Scr_FreeObjects(game::scriptInstance_t inst);
void Scr_SetClassMap(game::scriptInstance_t inst, game::classNum_e classnum);
void Scr_RemoveClassMap(game::classNum_e classnum, game::scriptInstance_t inst);
void Scr_AddClassField(game::scriptInstance_t inst, game::classNum_e classnum, const char* name, unsigned int offset);
game::VariableUnion Scr_GetOffset(const char* name, game::scriptInstance_t inst, game::classNum_e classNum);
unsigned int FindEntityId(unsigned int entClass, int entNum, game::scriptInstance_t inst);
unsigned int Scr_GetEntityId(int entNum, game::scriptInstance_t inst, game::classNum_e classnum, int clientnum);
unsigned int Scr_FindArrayIndex(game::scriptInstance_t inst, game::VariableValue* a2, unsigned int a3);
void Scr_EvalArray(game::scriptInstance_t inst, game::VariableValue* eax0, game::VariableValue* a3);
unsigned int Scr_EvalArrayRef(game::scriptInstance_t inst, unsigned int eax0);
void ClearArray(unsigned int parentId, game::scriptInstance_t inst, game::VariableValue* value);
void SetEmptyArray(game::scriptInstance_t inst, unsigned int parentId);
void Scr_AddArrayKeys(unsigned int array, game::scriptInstance_t inst);
game::scr_entref_t* Scr_GetEntityIdRef(game::scr_entref_t* result, game::scriptInstance_t inst, unsigned int a3);
void CopyEntity(unsigned int parentId, unsigned int newParentId);
float Scr_GetEndonUsage(unsigned int a1, game::scriptInstance_t inst);
float Scr_GetEntryUsageInternal(game::scriptInstance_t inst, unsigned int type, game::VariableUnion u);
float Scr_GetEntryUsage(game::scriptInstance_t inst, game::VariableValueInternal* entryValue);
float Scr_GetObjectUsage(game::scriptInstance_t inst, unsigned int parentId);
float Scr_GetThreadUsage(game::VariableStackBuffer* inst, game::scriptInstance_t a2, float* endonUsage);
unsigned int Scr_FindField(game::scriptInstance_t inst, const char* name, int* type);
char* Scr_GetSourceFile_LoadObj(const char* a1);
char* Scr_GetSourceFile_FastFile(const char* a3);
void Scr_AddFieldsForFile(game::scriptInstance_t inst, const char* filename);
void Scr_AddFields_LoadObj(game::scriptInstance_t inst, const char* path, const char* extension);
void Scr_AddFields_FastFile(game::scriptInstance_t inst, const char* path, const char* extension);
int Scr_MakeValuePrimitive(game::scriptInstance_t inst, unsigned int parentId);
void Scr_FreeGameVariable(game::scriptInstance_t inst, int bComplete);
bool Scr_SLHasLowercaseString(unsigned int a1, const char* a2);
unsigned int FindObject(game::scriptInstance_t inst, unsigned int id);
unsigned int FindFirstSibling(game::scriptInstance_t inst, unsigned int id);
unsigned int FindNextSibling(game::scriptInstance_t inst, unsigned int id);
game::VariableValue Scr_GetArrayIndexValue(game::scriptInstance_t inst, unsigned int name);
void AddRefToObject(game::scriptInstance_t inst, unsigned int id);
void RemoveRefToEmptyObject(game::scriptInstance_t inst, unsigned int id);
void Scr_ClearThread(game::scriptInstance_t inst, unsigned int parentId);
unsigned int FindObjectVariable(game::scriptInstance_t inst, unsigned int parentId, unsigned int id);
void RemoveObjectVariable(game::scriptInstance_t inst, unsigned int parentId, unsigned int id);
game::VariableValueInternal_u* GetVariableValueAddress(game::scriptInstance_t inst, unsigned int id);
void Scr_KillEndonThread(game::scriptInstance_t inst, unsigned int threadId);
BOOL IsValidArrayIndex(game::scriptInstance_t inst, unsigned int unsignedValue);
void RemoveArrayVariable(game::scriptInstance_t inst, unsigned int parentId, unsigned int unsignedValue);
void SafeRemoveArrayVariable(game::scriptInstance_t inst, unsigned int parentId, unsigned int unsignedValue);
void AddRefToVector(game::scriptInstance_t inst, const float* vecVal);
unsigned int FindArrayVariableIndex(game::scriptInstance_t inst, unsigned int parentId, unsigned int unsignedValue);
unsigned int GetVariableIndexInternal(game::scriptInstance_t inst, unsigned int parentId, unsigned int name);
unsigned int GetNewVariableIndexInternal(game::scriptInstance_t inst, unsigned int parentId, unsigned int name);
unsigned int AllocObject(game::scriptInstance_t inst);
game::VariableType GetValueType(game::scriptInstance_t inst, unsigned int id);
game::VariableType GetObjectType(game::scriptInstance_t inst, unsigned int id);
float* Scr_AllocVector_(game::scriptInstance_t inst, const float* v);
void Scr_EvalInequality(game::scriptInstance_t inst, game::VariableValue* value1, game::VariableValue* value2);
unsigned int Scr_EvalArrayRefInternal(game::scriptInstance_t inst, game::VariableValue* varValue, game::VariableValueInternal* parentValue);
unsigned int GetNewArrayVariableIndex(game::scriptInstance_t inst, unsigned int parentId, unsigned int unsignedValue);
unsigned int GetNewArrayVariable(game::scriptInstance_t inst, unsigned int parentId, unsigned int unsignedValue);
unsigned int GetArrayVariable(game::scriptInstance_t inst, unsigned int parentId, unsigned int unsignedValue);
unsigned int AllocThread(game::scriptInstance_t inst, unsigned int self);
}
File diff suppressed because it is too large Load Diff
-119
View File
@@ -1,119 +0,0 @@
#pragma once
namespace codsrc
{
void Scr_VM_Init(game::scriptInstance_t inst);
void Scr_Init(game::scriptInstance_t inst);
void Scr_Shutdown(game::scriptInstance_t inst);
void Scr_ErrorInternal(game::scriptInstance_t inst);
void Scr_ClearOutParams(game::scriptInstance_t inst);
unsigned int GetDummyObject(game::scriptInstance_t inst);
unsigned int GetDummyFieldValue(game::scriptInstance_t inst);
unsigned int VM_ExecuteInternal(game::scriptInstance_t inst);
void VM_CancelNotifyInternal(game::scriptInstance_t inst, unsigned int notifyListOwnerId, unsigned int startLocalId, unsigned int notifyListId, unsigned int notifyNameListId, unsigned int stringValue);
void VM_CancelNotify(game::scriptInstance_t inst, unsigned int a2, unsigned int a3);
game::VariableStackBuffer* VM_ArchiveStack(game::scriptInstance_t inst);
int Scr_AddLocalVars(game::scriptInstance_t inst, unsigned int a2);
void VM_UnarchiveStack(game::scriptInstance_t inst, unsigned int startLocalId, game::VariableStackBuffer* stackValue);
void VM_TerminateStack(game::scriptInstance_t inst, unsigned int a2, unsigned int a3, game::VariableStackBuffer* name);
void VM_TrimStack(game::scriptInstance_t inst, unsigned int parentId, game::VariableStackBuffer* a3, int fromEndon);
void Scr_TerminateRunningThread(game::scriptInstance_t inst, unsigned int a2);
void Scr_TerminateWaitThread(game::scriptInstance_t inst, unsigned int a2, unsigned int a3);
void Scr_CancelWaittill(game::scriptInstance_t inst, unsigned int startLocalId);
void Scr_TerminateWaittillThread(game::scriptInstance_t inst, unsigned int a2, unsigned int a3);
void Scr_TerminateThread(unsigned int a2, game::scriptInstance_t inst);
void VM_Notify(game::scriptInstance_t inst, int notifyListOwnerId, unsigned int stringValue, game::VariableValue* top);
void Scr_NotifyNum_Internal(game::scriptInstance_t inst, int entNum, unsigned int entClass, unsigned int notifStr, unsigned int numParams);
void Scr_CancelNotifyList(unsigned int notifyListOwnerId, game::scriptInstance_t inst);
void VM_TerminateTime(game::scriptInstance_t inst, unsigned int parentId);
void VM_Resume(game::scriptInstance_t inst, unsigned int timeId);
unsigned int VM_Execute(game::scriptInstance_t inst, unsigned int localId, const char* pos, unsigned int paramcount);
unsigned short Scr_ExecThread(game::scriptInstance_t inst, unsigned int handle, unsigned int paramCount);
unsigned short Scr_ExecEntThreadNum(game::scriptInstance_t inst, int entNum, unsigned int handle, int numParams, unsigned int entClass);
void Scr_AddExecThread(game::scriptInstance_t inst, unsigned int handle);
void VM_SetTime(game::scriptInstance_t inst);
void Scr_InitSystem(game::scriptInstance_t inst);
void Scr_ShutdownSystem(game::scriptInstance_t inst, int bComplete);
bool Scr_IsSystemActive();
int Scr_GetInt(game::scriptInstance_t inst, unsigned int index);
game::scr_anim_s Scr_GetAnim(unsigned int index, game::XAnimTree_s* anims);
game::scr_animtree_t Scr_GetAnimTree();
float Scr_GetFloat(game::scriptInstance_t inst, unsigned int index);
unsigned int Scr_GetConstString(game::scriptInstance_t inst, unsigned int index);
unsigned int Scr_GetConstLowercaseString(game::scriptInstance_t inst, unsigned int index);
const char* Scr_GetString(unsigned int index, game::scriptInstance_t inst);
unsigned int Scr_GetConstStringIncludeNull(game::scriptInstance_t inst);
char* Scr_GetDebugString(game::scriptInstance_t inst, unsigned int index);
unsigned int Scr_GetConstIString(unsigned int index);
void Scr_GetVector(game::scriptInstance_t inst, float* vectorValue, unsigned int index);
unsigned int Scr_GetFunc();
game::scr_entref_t* Scr_GetEntityRef(game::scriptInstance_t inst, game::scr_entref_t* retstr, unsigned int index);
game::VariableUnion Scr_GetObject(game::scriptInstance_t inst);
game::VariableType Scr_GetType(game::scriptInstance_t inst, unsigned int index);
const char* Scr_GetTypeName(game::scriptInstance_t inst);
game::VariableType Scr_GetPointerType(game::scriptInstance_t inst, unsigned int index);
void Scr_AddInt(game::scriptInstance_t inst, int value);
void Scr_AddFloat(game::scriptInstance_t inst, float value);
void Scr_AddAnim(game::scr_anim_s value);
void Scr_AddUndefined(game::scriptInstance_t inst);
void Scr_AddObject(game::scriptInstance_t inst, unsigned int entid);
void Scr_AddString(game::scriptInstance_t inst, const char* string);
void Scr_AddIString(const char* string);
void Scr_AddConstString(game::scriptInstance_t inst, unsigned int id);
void Scr_AddVector(game::scriptInstance_t inst, float* value);
void Scr_MakeArray(game::scriptInstance_t inst);
void Scr_AddArray(game::scriptInstance_t inst);
void Scr_AddArrayStringIndexed(unsigned int id, game::scriptInstance_t inst);
void Scr_Error(const char* error, game::scriptInstance_t inst, int is_terminal);
void Scr_TerminalError(game::scriptInstance_t inst, const char* error);
void Scr_ParamError(unsigned int index, game::scriptInstance_t inst, const char* error);
void Scr_ObjectError(game::scriptInstance_t inst, const char* error);
bool SetEntityFieldValue(game::scriptInstance_t inst, int offset, int entnum, game::classNum_e classnum, int clientNum, game::VariableValue* value);
game::VariableValue GetEntityFieldValue(int offset, int entnum, game::scriptInstance_t inst, game::classNum_e classnum, int clientNum);
void Scr_SetStructField(unsigned int structId, unsigned int index, game::scriptInstance_t inst);
void Scr_IncTime(game::scriptInstance_t inst);
void Scr_RunCurrentThreads(game::scriptInstance_t inst);
void Scr_ResetTimeout(game::scriptInstance_t inst);
void SetVariableFieldValue(game::scriptInstance_t inst, unsigned int id, game::VariableValue* value);
void SetNewVariableValue(game::scriptInstance_t inst, unsigned int id, game::VariableValue* value);
void Scr_ClearErrorMessage(game::scriptInstance_t inst);
void VM_Shutdown(game::scriptInstance_t inst);
void Scr_ShutdownVariables(game::scriptInstance_t inst);
void ClearVariableValue(game::scriptInstance_t inst, unsigned int id);
unsigned int Scr_GetThreadNotifyName(game::scriptInstance_t inst, unsigned int startLocalId);
void Scr_RemoveThreadNotifyName(game::scriptInstance_t inst, unsigned int startLocalId);
unsigned int GetArraySize(game::scriptInstance_t inst, unsigned int id);
void IncInParam(game::scriptInstance_t inst);
unsigned int GetParentLocalId(game::scriptInstance_t inst, unsigned int threadId);
void Scr_ClearWaitTime(game::scriptInstance_t inst, unsigned int startLocalId);
void Scr_SetThreadWaitTime(game::scriptInstance_t inst, unsigned int startLocalId, unsigned int waitTime);
void Scr_SetThreadNotifyName(game::scriptInstance_t inst, unsigned int startLocalId, unsigned int stringValue);
void Scr_DebugTerminateThread(game::scriptInstance_t inst, int topThread);
unsigned int Scr_GetThreadWaitTime(game::scriptInstance_t inst, unsigned int startLocalId);
const char* Scr_GetStackThreadPos(game::scriptInstance_t inst, unsigned int endLocalId, game::VariableStackBuffer* stackValue, bool killThread);
unsigned int Scr_GetSelf(game::scriptInstance_t inst, unsigned int threadId);
unsigned int GetVariableKeyObject(game::scriptInstance_t inst, unsigned int id);
int MT_Realloc(game::scriptInstance_t inst, int oldNumBytes, int newNumbytes);
void CScr_GetObjectField(game::classNum_e classnum, int entnum, int clientNum, int offset);
int CScr_SetObjectField(game::classNum_e classnum, int entnum, int clientNum, int offset);
void Scr_SetErrorMessage(game::scriptInstance_t inst, const char* error);
bool Scr_IsStackClear(game::scriptInstance_t inst);
void SL_CheckExists(game::scriptInstance_t inst, unsigned int stringValue);
const char* Scr_ReadCodePos(game::scriptInstance_t inst, const char** pos);
unsigned int Scr_ReadUnsignedInt(game::scriptInstance_t inst, const char** pos);
unsigned short Scr_ReadUnsignedShort(game::scriptInstance_t inst, const char** pos);
unsigned char Scr_ReadUnsignedByte(game::scriptInstance_t inst, const char** pos);
float Scr_ReadFloat(game::scriptInstance_t inst, const char** pos);
const float* Scr_ReadVector(game::scriptInstance_t inst, const char** pos);
BOOL IsFieldObject(game::scriptInstance_t inst, unsigned int id);
void RemoveVariableValue(game::scriptInstance_t inst, unsigned int parentId, unsigned int index);
game::VariableStackBuffer* GetRefVariableStackBuffer(game::scriptInstance_t inst, int id);
unsigned int GetNewObjectVariableReverse(game::scriptInstance_t inst, unsigned int parentId, unsigned int id);
unsigned int GetNewVariableIndexReverseInternal(game::scriptInstance_t inst, unsigned int parentId, unsigned int name);
unsigned int Scr_GetLocalVar(game::scriptInstance_t inst, int pos);
void Scr_EvalBoolNot(game::scriptInstance_t inst, game::VariableValue* value);
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);
}
@@ -1,309 +0,0 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_main.hpp"
//#define RE_CSCR_MAIN_USE_WRAPPERS
namespace re_cscr_main
{
utils::hook::detour Scr_IsIdentifier_hook;
utils::hook::detour Scr_GetFunctionHandle_hook;
utils::hook::detour SL_TransferToCanonicalString_hook;
utils::hook::detour SL_GetCanonicalString_hook;
utils::hook::detour Scr_BeginLoadScripts_hook;
utils::hook::detour Scr_BeginLoadAnimTrees_hook;
utils::hook::detour Scr_ScanFile_hook;
utils::hook::detour Scr_LoadScriptInternal_hook;
utils::hook::detour Scr_LoadScript_hook;
utils::hook::detour Scr_EndLoadScripts_hook;
utils::hook::detour Scr_PrecacheAnimTrees_hook;
utils::hook::detour Scr_EndLoadAnimTrees_hook;
utils::hook::detour Scr_FreeScripts_hook;
void* Scr_IsIdentifier_original;
void* Scr_GetFunctionHandle_original;
void* SL_TransferToCanonicalString_original;
void* SL_GetCanonicalString_original;
void* Scr_BeginLoadScripts_original;
void* Scr_BeginLoadAnimTrees_original;
void* Scr_ScanFile_original;
void* Scr_LoadScriptInternal_original;
void* Scr_LoadScript_original;
void* Scr_EndLoadScripts_original;
void* Scr_PrecacheAnimTrees_original;
void* Scr_EndLoadAnimTrees_original;
void* Scr_FreeScripts_original;
namespace
{
bool Scr_IsIdentifier_call(char * token, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
return game::Scr_IsIdentifier(token, Scr_IsIdentifier_original);
#else
return codsrc::Scr_IsIdentifier(token);
#endif
}
// bool __usercall Scr_IsIdentifier@<al>(char *token@<ecx>)
NAKED bool Scr_IsIdentifier_stub()
{
_asm
{
push ecx;
call Scr_IsIdentifier_call;
add esp, 0x4;
ret;
}
}
unsigned int Scr_GetFunctionHandle_call(const char * file, game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr, const char * handle)
{
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
return game::Scr_GetFunctionHandle(file, inst, handle, Scr_GetFunctionHandle_original);
#else
return codsrc::Scr_GetFunctionHandle(file, inst, handle);
#endif
}
// unsigned int __usercall Scr_GetFunctionHandle@<eax>(const char *file@<eax>, scriptInstance_t inst@<ecx>, const char *handle)
NAKED unsigned int Scr_GetFunctionHandle_stub()
{
_asm
{
push ecx;
push eax;
call Scr_GetFunctionHandle_call;
add esp, 0x8;
ret;
}
}
unsigned int SL_TransferToCanonicalString_call(game::scriptInstance_t inst, unsigned int stringValue, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
return game::SL_TransferToCanonicalString(inst, stringValue, SL_TransferToCanonicalString_original);
#else
return codsrc::SL_TransferToCanonicalString(inst, stringValue);
#endif
}
// unsigned int __usercall SL_TransferToCanonicalString@<eax>(scriptInstance_t inst@<eax>, unsigned int stringValue@<edi>)
NAKED unsigned int SL_TransferToCanonicalString_stub()
{
_asm
{
push edi;
push eax;
call SL_TransferToCanonicalString_call;
add esp, 0x8;
ret;
}
}
unsigned int SL_GetCanonicalString_call(char * token, game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
return game::SL_GetCanonicalString(token, inst, SL_GetCanonicalString_original);
#else
return codsrc::SL_GetCanonicalString(token, inst);
#endif
}
// unsigned int __usercall SL_GetCanonicalString@<eax>(char *token@<eax>, scriptInstance_t inst@<esi>)
NAKED unsigned int SL_GetCanonicalString_stub()
{
_asm
{
push esi;
push eax;
call SL_GetCanonicalString_call;
add esp, 0x8;
ret;
}
}
void Scr_BeginLoadScripts_call(game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr, int user)
{
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
game::Scr_BeginLoadScripts(inst, user, Scr_BeginLoadScripts_original);
#else
codsrc::Scr_BeginLoadScripts(inst, user);
#endif
}
// void __usercall Scr_BeginLoadScripts(scriptInstance_t inst@<edi>, int user)
NAKED void Scr_BeginLoadScripts_stub()
{
_asm
{
push edi;
call Scr_BeginLoadScripts_call;
add esp, 0x4;
ret;
}
}
void Scr_BeginLoadAnimTrees_call(game::scriptInstance_t inst, int user, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
game::Scr_BeginLoadAnimTrees(inst, user, Scr_BeginLoadAnimTrees_original);
#else
codsrc::Scr_BeginLoadAnimTrees(inst, user);
#endif
}
// void __usercall Scr_BeginLoadAnimTrees(scriptInstance_t inst@<ecx>, int user@<eax>)
NAKED void Scr_BeginLoadAnimTrees_stub()
{
_asm
{
push eax;
push ecx;
call Scr_BeginLoadAnimTrees_call;
add esp, 0x8;
ret;
}
}
int Scr_ScanFile_call(int max_size, [[maybe_unused]] void* caller_addr, char * buf)
{
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
return game::Scr_ScanFile(max_size, buf, Scr_ScanFile_original);
#else
return codsrc::Scr_ScanFile(max_size, buf);
#endif
}
// int __usercall Scr_ScanFile@<eax>(int max_size@<edi>, char *buf)
NAKED int Scr_ScanFile_stub()
{
_asm
{
push edi;
call Scr_ScanFile_call;
add esp, 0x4;
ret;
}
}
unsigned int Scr_LoadScriptInternal_stub(game::scriptInstance_t inst, const char * file, game::PrecacheEntry * entries, int entriesCount)
{
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
return Scr_LoadScriptInternal_hook.invoke<unsigned int>(inst, file, entries, entriesCount);
#else
return codsrc::Scr_LoadScriptInternal(inst, file, entries, entriesCount);
#endif
}
unsigned int Scr_LoadScript_call(const char * file, game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
return game::Scr_LoadScript(file, inst, Scr_LoadScript_original);
#else
return codsrc::Scr_LoadScript(file, inst);
#endif
}
// unsigned int __usercall Scr_LoadScript@<eax>(const char *file@<ecx>, scriptInstance_t inst@<edx>)
NAKED unsigned int Scr_LoadScript_stub()
{
_asm
{
push edx;
push ecx;
call Scr_LoadScript_call;
add esp, 0x8;
ret;
}
}
void Scr_EndLoadScripts_stub(game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
Scr_EndLoadScripts_hook.invoke<void>(inst);
#else
codsrc::Scr_EndLoadScripts(inst);
#endif
}
void Scr_PrecacheAnimTrees_stub(game::scriptInstance_t inst, void *(__cdecl *Alloc)(int), int user, int modChecksum, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
return Scr_PrecacheAnimTrees_hook.invoke<void>(inst, Alloc, user, modChecksum);
#else
return codsrc::Scr_PrecacheAnimTrees(inst, Alloc, user, modChecksum);
#endif
}
void Scr_EndLoadAnimTrees_stub(game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
Scr_EndLoadAnimTrees_hook.invoke<void>(inst);
#else
codsrc::Scr_EndLoadAnimTrees(inst);
#endif
}
void Scr_FreeScripts_call(game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MAIN_USE_WRAPPERS
game::Scr_FreeScripts(inst, Scr_FreeScripts_original);
#else
codsrc::Scr_FreeScripts(inst);
#endif
}
// void __usercall Scr_FreeScripts(scriptInstance_t a1@<eax>)
NAKED void Scr_FreeScripts_stub()
{
_asm
{
push eax;
call Scr_FreeScripts_call;
add esp, 0x4;
ret;
}
}
}
class component final : public component_interface
{
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);
//Original hook function addresses
Scr_IsIdentifier_original = Scr_IsIdentifier_hook.get_original();
Scr_GetFunctionHandle_original = Scr_GetFunctionHandle_hook.get_original();
SL_TransferToCanonicalString_original = SL_TransferToCanonicalString_hook.get_original();
SL_GetCanonicalString_original = SL_GetCanonicalString_hook.get_original();
Scr_BeginLoadScripts_original = Scr_BeginLoadScripts_hook.get_original();
Scr_BeginLoadAnimTrees_original = Scr_BeginLoadAnimTrees_hook.get_original();
Scr_ScanFile_original = Scr_ScanFile_hook.get_original();
Scr_LoadScriptInternal_original = Scr_LoadScriptInternal_hook.get_original();
Scr_LoadScript_original = Scr_LoadScript_hook.get_original();
Scr_EndLoadScripts_original = Scr_EndLoadScripts_hook.get_original();
Scr_PrecacheAnimTrees_original = Scr_PrecacheAnimTrees_hook.get_original();
Scr_EndLoadAnimTrees_original = Scr_EndLoadAnimTrees_hook.get_original();
Scr_FreeScripts_original = Scr_FreeScripts_hook.get_original();
}
private:
};
}
REGISTER_COMPONENT(re_cscr_main::component)
@@ -1,308 +0,0 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_memorytree.hpp"
//#define RE_CSCR_MEMORYTREE_USE_WRAPPERS
namespace re_cscr_memorytree
{
utils::hook::detour MT_GetSubTreeSize_hook;
utils::hook::detour MT_DumpTree_hook;
utils::hook::detour MT_InitBits_hook;
utils::hook::detour MT_GetScore_hook;
utils::hook::detour MT_AddMemoryNode_hook;
utils::hook::detour MT_RemoveMemoryNode_hook;
utils::hook::detour MT_RemoveHeadMemoryNode_hook;
utils::hook::detour MT_Init_hook;
utils::hook::detour MT_Error_hook;
utils::hook::detour MT_GetSize_hook;
utils::hook::detour MT_AllocIndex_hook;
utils::hook::detour MT_FreeIndex_hook;
utils::hook::detour MT_Alloc_hook;
utils::hook::detour MT_Free_hook;
void* MT_GetSubTreeSize_original;
void* MT_DumpTree_original;
void* MT_InitBits_original;
void* MT_GetScore_original;
void* MT_AddMemoryNode_original;
void* MT_RemoveMemoryNode_original;
void* MT_RemoveHeadMemoryNode_original;
void* MT_Init_original;
void* MT_Error_original;
void* MT_GetSize_original;
void* MT_AllocIndex_original;
void* MT_FreeIndex_original;
void* MT_Alloc_original;
void* MT_Free_original;
namespace
{
int MT_GetSubTreeSize_stub(game::scriptInstance_t inst, int nodeNum, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
return MT_GetSubTreeSize_hook.invoke<int>(inst, nodeNum);
#else
return codsrc::MT_GetSubTreeSize(inst, nodeNum);
#endif
}
void MT_DumpTree_stub(game::scriptInstance_t a1, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
MT_DumpTree_hook.invoke<void>(a1);
#else
codsrc::MT_DumpTree(a1);
#endif
}
void MT_InitBits_call(game::scriptInstance_t a1, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
game::MT_InitBits(a1, MT_InitBits_original);
#else
codsrc::MT_InitBits(a1);
#endif
}
// void __usercall MT_InitBits(scriptInstance_t a1@<ecx>)
NAKED void MT_InitBits_stub()
{
_asm
{
push ecx;
call MT_InitBits_call;
add esp, 0x4;
ret;
}
}
int MT_GetScore_call(game::scriptInstance_t a1, [[maybe_unused]] void* caller_addr, int num)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
return game::MT_GetScore(a1, num, MT_GetScore_original);
#else
return codsrc::MT_GetScore(a1, num);
#endif
}
// int __usercall MT_GetScore@<eax>(scriptInstance_t a1@<edx>, int num)
NAKED int MT_GetScore_stub()
{
_asm
{
push edx;
call MT_GetScore_call;
add esp, 0x4;
ret;
}
}
void MT_AddMemoryNode_stub(game::scriptInstance_t inst, int newNode, int size, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
MT_AddMemoryNode_hook.invoke<void>(inst, newNode, size);
#else
codsrc::MT_AddMemoryNode(inst, newNode, size);
#endif
}
char MT_RemoveMemoryNode_stub(game::scriptInstance_t inst, int oldNode, int size, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
return MT_RemoveMemoryNode_hook.invoke<char>(inst, oldNode, size);
#else
return codsrc::MT_RemoveMemoryNode(inst, oldNode, size);
#endif
}
void MT_RemoveHeadMemoryNode_stub(game::scriptInstance_t inst, int size, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
MT_RemoveHeadMemoryNode_hook.invoke<void>(inst, size);
#else
codsrc::MT_RemoveHeadMemoryNode(inst, size);
#endif
}
void MT_Init_call(game::scriptInstance_t a1, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
game::MT_Init(a1, MT_Init_original);
#else
codsrc::MT_Init(a1);
#endif
}
// void __usercall MT_Init(scriptInstance_t a1@<edi>)
NAKED void MT_Init_stub()
{
_asm
{
push edi;
call MT_Init_call;
add esp, 0x4;
ret;
}
}
void MT_Error_call(game::scriptInstance_t a1, [[maybe_unused]] void* caller_addr, const char* funcName, int numBytes)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
game::MT_Error(a1, funcName, numBytes, MT_Error_original);
#else
codsrc::MT_Error(a1, funcName, numBytes);
#endif
}
// void __usercall MT_Error(scriptInstance_t a1@<eax>, const char *funcName, int numBytes)
NAKED void MT_Error_stub()
{
_asm
{
push eax;
call MT_Error_call;
add esp, 0x4;
ret;
}
}
int MT_GetSize_call(int numBytes, game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
return game::MT_GetSize(numBytes, inst, MT_GetSize_original);
#else
return codsrc::MT_GetSize(numBytes, inst);
#endif
}
// int __usercall MT_GetSize@<eax>(int numBytes@<eax>, scriptInstance_t inst@<ecx>)
NAKED int MT_GetSize_stub()
{
_asm
{
push ecx;
push eax;
call MT_GetSize_call;
add esp, 0x8;
ret;
}
}
unsigned __int16 MT_AllocIndex_call(game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr, int size_)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
return game::MT_AllocIndex(inst, size_, MT_AllocIndex_original);
#else
return codsrc::MT_AllocIndex(inst, size_);
#endif
}
// unsigned __int16 __usercall MT_AllocIndex@<ax>(scriptInstance_t inst@<edi>, int size)
NAKED unsigned __int16 MT_AllocIndex_stub()
{
_asm
{
push edi;
call MT_AllocIndex_call;
add esp, 0x4;
ret;
}
}
void MT_FreeIndex_call(int numBytes, [[maybe_unused]] void* caller_addr, game::scriptInstance_t a1, int nodeNum)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
game::MT_FreeIndex(numBytes, a1, nodeNum, MT_FreeIndex_original);
#else
codsrc::MT_FreeIndex(numBytes, a1, nodeNum);
#endif
}
// void __usercall MT_FreeIndex(int numBytes@<eax>, scriptInstance_t a1, int nodeNum)
NAKED void MT_FreeIndex_stub()
{
_asm
{
push eax;
call MT_FreeIndex_call;
add esp, 0x4;
ret;
}
}
char* MT_Alloc_call(int numBytes, game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
return game::MT_Alloc(numBytes, inst, MT_Alloc_original);
#else
return codsrc::MT_Alloc(numBytes, inst);
#endif
}
// char *__usercall MT_Alloc@<eax>(int numBytes@<eax>, scriptInstance_t a2@<ecx>)
NAKED char * MT_Alloc_stub()
{
_asm
{
push ecx;
push eax;
call MT_Alloc_call;
add esp, 0x8;
ret;
}
}
void MT_Free_stub(void* p, int numBytes, game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_MEMORYTREE_USE_WRAPPERS
MT_Free_hook.invoke<void>(p, numBytes, inst);
#else
codsrc::MT_Free(p, numBytes, inst);
#endif
}
}
class component final : public component_interface
{
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);
//Original hook function addresses
MT_GetSubTreeSize_original = MT_GetSubTreeSize_hook.get_original();
MT_DumpTree_original = MT_DumpTree_hook.get_original();
MT_InitBits_original = MT_InitBits_hook.get_original();
MT_GetScore_original = MT_GetScore_hook.get_original();
MT_AddMemoryNode_original = MT_AddMemoryNode_hook.get_original();
MT_RemoveMemoryNode_original = MT_RemoveMemoryNode_hook.get_original();
MT_RemoveHeadMemoryNode_original = MT_RemoveHeadMemoryNode_hook.get_original();
MT_Init_original = MT_Init_hook.get_original();
MT_Error_original = MT_Error_hook.get_original();
MT_GetSize_original = MT_GetSize_hook.get_original();
MT_AllocIndex_original = MT_AllocIndex_hook.get_original();
MT_FreeIndex_original = MT_FreeIndex_hook.get_original();
MT_Alloc_original = MT_Alloc_hook.get_original();
MT_Free_original = MT_Free_hook.get_original();
}
private:
};
}
REGISTER_COMPONENT(re_cscr_memorytree::component)
@@ -1,590 +0,0 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_parser.hpp"
//#define RE_CSCR_PARSER_USE_WRAPPERS
namespace re_cscr_parser
{
utils::hook::detour Scr_InitOpcodeLookup_hook;
utils::hook::detour Scr_ShutdownOpcodeLookup_hook;
utils::hook::detour AddOpcodePos_hook;
utils::hook::detour RemoveOpcodePos_hook;
utils::hook::detour AddThreadStartOpcodePos_hook;
utils::hook::detour Scr_GetSourceBuffer_hook;
utils::hook::detour Scr_GetLineNumInternal_hook;
utils::hook::detour Scr_GetNewSourceBuffer_hook;
utils::hook::detour Scr_AddSourceBufferInternal_hook;
utils::hook::detour Scr_ReadFile_FastFile_hook;
utils::hook::detour Scr_ReadFile_LoadObj_hook;
utils::hook::detour Scr_ReadFile_hook;
utils::hook::detour Scr_AddSourceBuffer_hook;
utils::hook::detour Scr_CopyFormattedLine_hook;
utils::hook::detour Scr_GetLineInfo_hook;
utils::hook::detour Scr_PrintSourcePos_hook;
utils::hook::detour Scr_GetPrevSourcePosOpcodeLookup_hook;
utils::hook::detour Scr_GetTextSourcePos_hook;
utils::hook::detour Scr_PrintPrevCodePos_hook;
utils::hook::detour CompileError_hook;
utils::hook::detour CompileError2_hook;
utils::hook::detour RuntimeErrorInternal_hook;
utils::hook::detour RuntimeError_hook;
void* Scr_InitOpcodeLookup_original;
void* Scr_ShutdownOpcodeLookup_original;
void* AddOpcodePos_original;
void* RemoveOpcodePos_original;
void* AddThreadStartOpcodePos_original;
void* Scr_GetSourceBuffer_original;
void* Scr_GetLineNumInternal_original;
void* Scr_GetNewSourceBuffer_original;
void* Scr_AddSourceBufferInternal_original;
void* Scr_ReadFile_FastFile_original;
void* Scr_ReadFile_LoadObj_original;
void* Scr_ReadFile_original;
void* Scr_AddSourceBuffer_original;
void* Scr_CopyFormattedLine_original;
void* Scr_GetLineInfo_original;
void* Scr_PrintSourcePos_original;
void* Scr_GetPrevSourcePosOpcodeLookup_original;
void* Scr_GetTextSourcePos_original;
void* Scr_PrintPrevCodePos_original;
void* CompileError_original;
void* CompileError2_original;
void* RuntimeErrorInternal_original;
void* RuntimeError_original;
namespace
{
void Scr_InitOpcodeLookup_call(game::scriptInstance_t a1, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
game::Scr_InitOpcodeLookup(a1, Scr_InitOpcodeLookup_original);
#else
codsrc::Scr_InitOpcodeLookup(a1);
#endif
}
// void __usercall Scr_InitOpcodeLookup(game::scriptInstance_t a1@<eax>)
NAKED void Scr_InitOpcodeLookup_stub()
{
_asm
{
push eax;
call Scr_InitOpcodeLookup_call;
add esp, 0x4;
ret;
}
}
void Scr_ShutdownOpcodeLookup_call(game::scriptInstance_t a1, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
game::Scr_ShutdownOpcodeLookup(a1, Scr_ShutdownOpcodeLookup_original);
#else
codsrc::Scr_ShutdownOpcodeLookup(a1);
#endif
}
// void __usercall Scr_ShutdownOpcodeLookup(game::scriptInstance_t a1@<ecx>)
NAKED void Scr_ShutdownOpcodeLookup_stub()
{
_asm
{
push ecx;
call Scr_ShutdownOpcodeLookup_call;
add esp, 0x4;
ret;
}
}
void AddOpcodePos_call(game::scriptInstance_t a1, [[maybe_unused]] void* caller_addr, unsigned int sourcePos, int type_)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
game::AddOpcodePos(a1, sourcePos, type_, AddOpcodePos_original);
#else
codsrc::AddOpcodePos(a1, sourcePos, type_);
#endif
}
// void __usercall AddOpcodePos(game::scriptInstance_t a1@<eax>, unsigned int sourcePos, int type)
NAKED void AddOpcodePos_stub()
{
_asm
{
push eax;
call AddOpcodePos_call;
add esp, 0x4;
ret;
}
}
void RemoveOpcodePos_call(game::scriptInstance_t result, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
game::RemoveOpcodePos(result, RemoveOpcodePos_original);
#else
codsrc::RemoveOpcodePos(result);
#endif
}
// void __usercall RemoveOpcodePos(game::scriptInstance_t result@<eax>)
NAKED void RemoveOpcodePos_stub()
{
_asm
{
push eax;
call RemoveOpcodePos_call;
add esp, 0x4;
ret;
}
}
void AddThreadStartOpcodePos_call(game::scriptInstance_t result, [[maybe_unused]] void* caller_addr, unsigned int sourcePos)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
game::AddThreadStartOpcodePos(result, sourcePos, AddThreadStartOpcodePos_original);
#else
codsrc::AddThreadStartOpcodePos(result, sourcePos);
#endif
}
// void __usercall AddThreadStartOpcodePos(game::scriptInstance_t result@<eax>, unsigned int sourcePos)
NAKED void AddThreadStartOpcodePos_stub()
{
_asm
{
push eax;
call AddThreadStartOpcodePos_call;
add esp, 0x4;
ret;
}
}
unsigned int Scr_GetSourceBuffer_call(game::scriptInstance_t a1, const char * codePos, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
return game::Scr_GetSourceBuffer(a1, codePos, Scr_GetSourceBuffer_original);
#else
return codsrc::Scr_GetSourceBuffer(a1, codePos);
#endif
}
// unsigned int __usercall Scr_GetSourceBuffer@<eax>(game::scriptInstance_t inst@<eax>, const char *codePos@<esi>)
NAKED unsigned int Scr_GetSourceBuffer_stub()
{
_asm
{
push esi;
push eax;
call Scr_GetSourceBuffer_call;
add esp, 0x8;
ret;
}
}
unsigned int Scr_GetLineNumInternal_call(const char ** startLine, const char * buf, [[maybe_unused]] void* caller_addr, const char * sourcePos, int * col)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
return game::Scr_GetLineNumInternal(startLine, buf, sourcePos, col, Scr_GetLineNumInternal_original);
#else
return codsrc::Scr_GetLineNumInternal(startLine, buf, sourcePos, col);
#endif
}
// unsigned int __usercall Scr_GetLineNumInternal@<eax>(const char **startLine@<edx>, const char *buf@<ecx>, const char *sourcePos, int *col)
NAKED unsigned int Scr_GetLineNumInternal_stub()
{
_asm
{
push ecx;
push edx;
call Scr_GetLineNumInternal_call;
add esp, 0x8;
ret;
}
}
game::SourceBufferInfo * Scr_GetNewSourceBuffer_call(game::scriptInstance_t a1, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
return game::Scr_GetNewSourceBuffer(a1, Scr_GetNewSourceBuffer_original);
#else
return codsrc::Scr_GetNewSourceBuffer(a1);
#endif
}
// SourceBufferInfo *__usercall Scr_GetNewSourceBuffer@<eax>(game::scriptInstance_t a1@<eax>)
NAKED game::SourceBufferInfo * Scr_GetNewSourceBuffer_stub()
{
_asm
{
push eax;
call Scr_GetNewSourceBuffer_call;
add esp, 0x4;
ret;
}
}
void Scr_AddSourceBufferInternal_call(const char * filename, [[maybe_unused]] void* caller_addr, game::scriptInstance_t inst, const char * codepos, char * buffer, int len, int archive)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
game::Scr_AddSourceBufferInternal(filename, inst, codepos, buffer, len, archive, Scr_AddSourceBufferInternal_original);
#else
codsrc::Scr_AddSourceBufferInternal(filename, inst, codepos, buffer, len, archive);
#endif
}
// void __usercall Scr_AddSourceBufferInternal(const char *filename@<eax>, game::scriptInstance_t inst, const char *codepos, char *buffer, int len, int archive)
NAKED void Scr_AddSourceBufferInternal_stub()
{
_asm
{
push eax;
call Scr_AddSourceBufferInternal_call;
add esp, 0x4;
ret;
}
}
char * Scr_ReadFile_FastFile_stub(game::scriptInstance_t inst, int unused, char * filename, const char * codepos, int archive)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
return Scr_ReadFile_FastFile_hook.invoke<char *>(inst, unused, filename, codepos, archive);
#else
return codsrc::Scr_ReadFile_FastFile(inst, unused, filename, codepos, archive);
#endif
}
char * Scr_ReadFile_LoadObj_stub(game::scriptInstance_t inst, int unused_arg1, const char * filename, const char * codepos, int archive)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
return Scr_ReadFile_LoadObj_hook.invoke<char *>(inst, unused_arg1, filename, codepos, archive);
#else
return codsrc::Scr_ReadFile_LoadObj(inst, unused_arg1, filename, codepos, archive);
#endif
}
char * Scr_ReadFile_call(const char * codepos, char * filename, [[maybe_unused]] void* caller_addr, game::scriptInstance_t inst, int unused)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
return game::Scr_ReadFile(codepos, filename, inst, unused, Scr_ReadFile_original);
#else
return codsrc::Scr_ReadFile(codepos, filename, inst, unused);
#endif
}
// char *__usercall Scr_ReadFile@<eax>(const char *codepos@<edi>, char *filename@<esi>, game::scriptInstance_t inst, int unused)
NAKED char * Scr_ReadFile_stub()
{
_asm
{
push esi;
push edi;
call Scr_ReadFile_call;
add esp, 0x8;
ret;
}
}
char * Scr_AddSourceBuffer_call(game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr, int unused_arg1, char * filename, const char * codepos)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
return game::Scr_AddSourceBuffer(inst, unused_arg1, filename, codepos, Scr_AddSourceBuffer_original);
#else
return codsrc::Scr_AddSourceBuffer(inst, unused_arg1, filename, codepos);
#endif
}
// char *__usercall Scr_AddSourceBuffer@<eax>(game::scriptInstance_t inst@<eax>, int unused_arg1, char *filename, const char *codepos)
NAKED char * Scr_AddSourceBuffer_stub()
{
_asm
{
push eax;
call Scr_AddSourceBuffer_call;
add esp, 0x4;
ret;
}
}
void Scr_CopyFormattedLine_call(const char * rawLine, [[maybe_unused]] void* caller_addr, char * line)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
game::Scr_CopyFormattedLine(rawLine, line, Scr_CopyFormattedLine_original);
#else
codsrc::Scr_CopyFormattedLine(rawLine, line);
#endif
}
// void __usercall Scr_CopyFormattedLine(const char *rawLine@<eax>, char *line)
NAKED void Scr_CopyFormattedLine_stub()
{
_asm
{
push eax;
call Scr_CopyFormattedLine_call;
add esp, 0x4;
ret;
}
}
unsigned int Scr_GetLineInfo_call(int * col, const char * buf, [[maybe_unused]] void* caller_addr, unsigned int sourcePos, char * line)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
return game::Scr_GetLineInfo(col, buf, sourcePos, line, Scr_GetLineInfo_original);
#else
return codsrc::Scr_GetLineInfo(col, buf, sourcePos, line);
#endif
}
// unsigned int __usercall Scr_GetLineInfo@<eax>(int *col@<edx>, _BYTE *buf@<ecx>, unsigned int sourcePos, char *line)
NAKED unsigned int Scr_GetLineInfo_stub()
{
_asm
{
push ecx;
push edx;
call Scr_GetLineInfo_call;
add esp, 0x8;
ret;
}
}
void Scr_PrintSourcePos_call(unsigned int sourcePos, const char * buf, game::con_channel_e channel, [[maybe_unused]] void* caller_addr, game::scriptInstance_t a4, const char * file)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
game::Scr_PrintSourcePos(sourcePos, buf, channel, a4, file, Scr_PrintSourcePos_original);
#else
codsrc::Scr_PrintSourcePos(sourcePos, buf, channel, a4, file);
#endif
}
// void __usercall Scr_PrintSourcePos(unsigned int sourcePos@<edx>, const char *buf@<ecx>, con_channel_e channel@<esi>, game::scriptInstance_t a4, const char *file)
NAKED void Scr_PrintSourcePos_stub()
{
_asm
{
push esi;
push ecx;
push edx;
call Scr_PrintSourcePos_call;
add esp, 0xC;
ret;
}
}
game::OpcodeLookup * Scr_GetPrevSourcePosOpcodeLookup_call(game::scriptInstance_t a1, const char * codePos, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
return game::Scr_GetPrevSourcePosOpcodeLookup(a1, codePos, Scr_GetPrevSourcePosOpcodeLookup_original);
#else
return codsrc::Scr_GetPrevSourcePosOpcodeLookup(a1, codePos);
#endif
}
// OpcodeLookup *__usercall Scr_GetPrevSourcePosOpcodeLookup@<eax>(game::scriptInstance_t a1@<eax>, const char *codePos@<edi>)
NAKED game::OpcodeLookup * Scr_GetPrevSourcePosOpcodeLookup_stub()
{
_asm
{
push edi;
push eax;
call Scr_GetPrevSourcePosOpcodeLookup_call;
add esp, 0x8;
ret;
}
}
void Scr_GetTextSourcePos_call(char * line, const char * codePos, [[maybe_unused]] void* caller_addr, game::scriptInstance_t a3)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
game::Scr_GetTextSourcePos(line, codePos, a3, Scr_GetTextSourcePos_original);
#else
codsrc::Scr_GetTextSourcePos(line, codePos, a3);
#endif
}
// void __usercall Scr_GetTextSourcePos(char *line@<edx>, const char *codePos@<ecx>, game::scriptInstance_t a3)
NAKED void Scr_GetTextSourcePos_stub()
{
_asm
{
push ecx;
push edx;
call Scr_GetTextSourcePos_call;
add esp, 0x8;
ret;
}
}
void Scr_PrintPrevCodePos_call(const char * codepos, [[maybe_unused]] void* caller_addr, game::scriptInstance_t scriptInstance, game::con_channel_e channel, unsigned int index)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
game::Scr_PrintPrevCodePos(codepos, scriptInstance, channel, index, Scr_PrintPrevCodePos_original);
#else
codsrc::Scr_PrintPrevCodePos(codepos, scriptInstance, channel, index);
#endif
}
// void __usercall Scr_PrintPrevCodePos(const char *codepos@<eax>, game::scriptInstance_t scriptInstance, con_channel_e channel, unsigned int index)
NAKED void Scr_PrintPrevCodePos_stub()
{
_asm
{
push eax;
call Scr_PrintPrevCodePos_call;
add esp, 0x4;
ret;
}
}
void CompileError_stub(game::scriptInstance_t a1, unsigned int codePos, const char * msg, ...)
{
char Buffer[1024];
va_list ArgList;
va_start(ArgList, msg);
_vsnprintf(Buffer, 0x400u, msg, ArgList);
va_end(ArgList);
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
CompileError_hook.invoke<void>(a1, codePos, "%s", Buffer);
#else
codsrc::CompileError(a1, codePos, "%s", Buffer);
#endif
}
void CompileError2_call(const char * codePos, game::scriptInstance_t a2, [[maybe_unused]] void* caller_addr, const char * msg, ...)
{
char Buffer[1024];
va_list ArgList;
va_start(ArgList, msg);
_vsnprintf(Buffer, 0x400u, msg, ArgList);
va_end(ArgList);
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
game::CompileError2(codePos, a2, CompileError2_original, "%s", Buffer);
#else
codsrc::CompileError2(codePos, a2, "%s", Buffer);
#endif
}
// void __usercall CompileError2(const char *codePos@<edi>, game::scriptInstance_t a2@<esi>, char *msg, ...)
NAKED void CompileError2_stub()
{
_asm
{
push esi;
push edi;
call CompileError2_call;
add esp, 0x8;
ret;
}
}
void RuntimeErrorInternal_call(const char * msg, game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr, game::con_channel_e channel, const char * codepos, int index)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
game::RuntimeErrorInternal(msg, inst, channel, codepos, index, RuntimeErrorInternal_original);
#else
codsrc::RuntimeErrorInternal(msg, inst, channel, codepos, index);
#endif
}
// void __usercall RuntimeErrorInternal(const char *msg@<eax>, game::scriptInstance_t inst@<edi>, con_channel_e channel, const char *codepos, int index)
NAKED void RuntimeErrorInternal_stub()
{
_asm
{
push edi;
push eax;
call RuntimeErrorInternal_call;
add esp, 0x8;
ret;
}
}
void RuntimeError_call(game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr, const char * pos, int error_index, const char * err, const char * err2)
{
#ifdef RE_CSCR_PARSER_USE_WRAPPERS
game::RuntimeError(inst, pos, error_index, err, err2, RuntimeError_original);
#else
codsrc::RuntimeError(inst, pos, error_index, err, err2);
#endif
}
// void __usercall RuntimeError(game::scriptInstance_t inst@<eax>, const char *pos, int error_index, const char *err, const char *err2)
NAKED void RuntimeError_stub()
{
_asm
{
push eax;
call RuntimeError_call;
add esp, 0x4;
ret;
}
}
}
class component final : public component_interface
{
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);
//Original hook function addresses
Scr_InitOpcodeLookup_original = Scr_InitOpcodeLookup_hook.get_original();
Scr_ShutdownOpcodeLookup_original = Scr_ShutdownOpcodeLookup_hook.get_original();
AddOpcodePos_original = AddOpcodePos_hook.get_original();
RemoveOpcodePos_original = RemoveOpcodePos_hook.get_original();
AddThreadStartOpcodePos_original = AddThreadStartOpcodePos_hook.get_original();
Scr_GetSourceBuffer_original = Scr_GetSourceBuffer_hook.get_original();
Scr_GetLineNumInternal_original = Scr_GetLineNumInternal_hook.get_original();
Scr_GetNewSourceBuffer_original = Scr_GetNewSourceBuffer_hook.get_original();
Scr_AddSourceBufferInternal_original = Scr_AddSourceBufferInternal_hook.get_original();
Scr_ReadFile_FastFile_original = Scr_ReadFile_FastFile_hook.get_original();
Scr_ReadFile_LoadObj_original = Scr_ReadFile_LoadObj_hook.get_original();
Scr_ReadFile_original = Scr_ReadFile_hook.get_original();
Scr_AddSourceBuffer_original = Scr_AddSourceBuffer_hook.get_original();
Scr_CopyFormattedLine_original = Scr_CopyFormattedLine_hook.get_original();
Scr_GetLineInfo_original = Scr_GetLineInfo_hook.get_original();
Scr_PrintSourcePos_original = Scr_PrintSourcePos_hook.get_original();
Scr_GetPrevSourcePosOpcodeLookup_original = Scr_GetPrevSourcePosOpcodeLookup_hook.get_original();
Scr_GetTextSourcePos_original = Scr_GetTextSourcePos_hook.get_original();
Scr_PrintPrevCodePos_original = Scr_PrintPrevCodePos_hook.get_original();
CompileError_original = CompileError_hook.get_original();
CompileError2_original = CompileError2_hook.get_original();
RuntimeErrorInternal_original = RuntimeErrorInternal_hook.get_original();
RuntimeError_original = RuntimeError_hook.get_original();
}
private:
};
}
REGISTER_COMPONENT(re_cscr_parser::component)
@@ -1,197 +0,0 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_parsetree.hpp"
//#define RE_CSCR_PARSETREE_USE_WRAPPERS
namespace re_cscr_parsetree
{
utils::hook::detour Scr_InitAllocNode_hook;
utils::hook::detour node0_hook;
utils::hook::detour node1_hook;
utils::hook::detour node2_hook;
utils::hook::detour node3_hook;
utils::hook::detour node4_hook;
utils::hook::detour node5_hook;
utils::hook::detour node6_hook;
utils::hook::detour node7_hook;
utils::hook::detour node8_hook;
utils::hook::detour linked_list_end_hook;
utils::hook::detour prepend_node_hook;
utils::hook::detour append_node_hook;
void* Scr_InitAllocNode_original;
void* node0_original;
void* node1_original;
void* node2_original;
void* node3_original;
void* node4_original;
void* node5_original;
void* node6_original;
void* node7_original;
void* node8_original;
void* linked_list_end_original;
void* prepend_node_original;
void* append_node_original;
namespace
{
void Scr_InitAllocNode_stub(game::scriptInstance_t inst)
{
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
Scr_InitAllocNode_hook.invoke<void>(inst);
#else
codsrc::Scr_InitAllocNode(inst);
#endif
}
game::sval_u node0_stub()
{
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
return node0_hook.invoke<game::sval_u>();
#else
return codsrc::node0();
#endif
}
game::sval_u node1_stub(game::scr_enum_t type, game::sval_u val1)
{
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
return node1_hook.invoke<game::sval_u>(type, val1);
#else
return codsrc::node1(type, val1);
#endif
}
game::sval_u node2_stub(game::scr_enum_t type, game::sval_u val1, game::sval_u val2)
{
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
return node2_hook.invoke<game::sval_u>(type, val1, val2);
#else
return codsrc::node2(type, val1, val2);
#endif
}
game::sval_u node3_stub(game::scr_enum_t type, game::sval_u val1, game::sval_u val2, game::sval_u val3)
{
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
return node3_hook.invoke<game::sval_u>(type, val1, val2, val3);
#else
return codsrc::node3(type, val1, val2, val3);
#endif
}
game::sval_u node4_stub(game::scr_enum_t type, game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4)
{
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
return node4_hook.invoke<game::sval_u>(type, val1, val2, val3, val4);
#else
return codsrc::node4(type, val1, val2, val3, val4);
#endif
}
game::sval_u node5_stub(game::scr_enum_t type, game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4, game::sval_u val5)
{
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
return node5_hook.invoke<game::sval_u>(type, val1, val2, val3, val4, val5);
#else
return codsrc::node5(type, val1, val2, val3, val4, val5);
#endif
}
game::sval_u node6_stub(game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4, game::sval_u val5, game::sval_u val6)
{
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
return node6_hook.invoke<game::sval_u>(val1, val2, val3, val4, val5, val6);
#else
return codsrc::node6(val1, val2, val3, val4, val5, val6);
#endif
}
game::sval_u node7_stub(game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4, game::sval_u val5, game::sval_u val6, game::sval_u val7)
{
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
return node7_hook.invoke<game::sval_u>(val1, val2, val3, val4, val5, val6, val7);
#else
return codsrc::node7(val1, val2, val3, val4, val5, val6, val7);
#endif
}
game::sval_u node8_stub(game::sval_u val1, game::sval_u val2, game::sval_u val3, game::sval_u val4, game::sval_u val5, game::sval_u val6, game::sval_u val7, game::sval_u val8)
{
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
return node8_hook.invoke<game::sval_u>(val1, val2, val3, val4, val5, val6, val7, val8);
#else
return codsrc::node8(val1, val2, val3, val4, val5, val6, val7, val8);
#endif
}
game::sval_u linked_list_end_stub(game::sval_u val1)
{
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
return linked_list_end_hook.invoke<game::sval_u>(val1);
#else
return codsrc::linked_list_end(val1);
#endif
}
game::sval_u prepend_node_stub(game::sval_u val1, game::sval_u val2)
{
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
return prepend_node_hook.invoke<game::sval_u>(val1, val2);
#else
return codsrc::prepend_node(val1, val2);
#endif
}
game::sval_u append_node_stub(game::sval_u val1, game::sval_u val2)
{
#ifdef RE_CSCR_PARSETREE_USE_WRAPPERS
return append_node_hook.invoke<game::sval_u>(val1, val2);
#else
return codsrc::append_node(val1, val2);
#endif
}
}
class component final : public component_interface
{
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);
//Original hook function addresses
Scr_InitAllocNode_original = Scr_InitAllocNode_hook.get_original();
node0_original = node0_hook.get_original();
node1_original = node1_hook.get_original();
node2_original = node2_hook.get_original();
node3_original = node3_hook.get_original();
node4_original = node4_hook.get_original();
node5_original = node5_hook.get_original();
node6_original = node6_hook.get_original();
node7_original = node7_hook.get_original();
node8_original = node8_hook.get_original();
linked_list_end_original = linked_list_end_hook.get_original();
prepend_node_original = prepend_node_hook.get_original();
append_node_original = append_node_hook.get_original();
}
private:
};
}
REGISTER_COMPONENT(re_cscr_parsetree::component)
@@ -1,79 +0,0 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_readwrite.hpp"
//#define RE_CSCR_READWRITE_USE_WRAPPERS
namespace re_cscr_readwrite
{
utils::hook::detour FindVariableIndexInternal2_hook;
utils::hook::detour FindLastSibling_hook;
void* FindVariableIndexInternal2_original;
void* FindLastSibling_original;
namespace
{
unsigned int FindVariableIndexInternal2_call(game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr, unsigned int name, unsigned int index)
{
#ifdef RE_CSCR_READWRITE_USE_WRAPPERS
return game::FindVariableIndexInternal2(inst, name, index, FindVariableIndexInternal2_original);
#else
return codsrc::FindVariableIndexInternal2(inst, name, index);
#endif
}
// unsigned int __usercall FindVariableIndexInternal2@<eax>(scriptInstance_t inst@<eax>, unsigned int name, unsigned int index)
NAKED unsigned int FindVariableIndexInternal2_stub()
{
_asm
{
push eax;
call FindVariableIndexInternal2_call;
add esp, 0x4;
ret;
}
}
unsigned int FindLastSibling_call(unsigned int parentId, game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_READWRITE_USE_WRAPPERS
return game::FindLastSibling(parentId, inst, FindLastSibling_original);
#else
return codsrc::FindLastSibling(parentId, inst);
#endif
}
// unsigned int __usercall FindLastSibling@<eax>(unsigned int parentId@<edx>, scriptInstance_t inst@<esi>)
NAKED unsigned int FindLastSibling_stub()
{
_asm
{
push esi;
push edx;
call FindLastSibling_call;
add esp, 0x8;
ret;
}
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
FindVariableIndexInternal2_hook.create(game::FindVariableIndexInternal2_ADDR(), FindVariableIndexInternal2_stub);
FindLastSibling_hook.create(game::FindLastSibling_ADDR(), FindLastSibling_stub);
//Original hook function addresses
FindVariableIndexInternal2_original = FindVariableIndexInternal2_hook.get_original();
FindLastSibling_original = FindLastSibling_hook.get_original();
}
private:
};
}
REGISTER_COMPONENT(re_cscr_readwrite::component)
@@ -1,652 +0,0 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "utils/hook.hpp"
#include "codsrc/clientscript/cscr_stringlist.hpp"
//#define RE_CSCR_STRINGLIST_USE_WRAPPERS
namespace re_cscr_stringlist
{
utils::hook::detour SL_ConvertToString_hook;
utils::hook::detour SL_GetStringLen_hook;
utils::hook::detour GetHashCode_hook;
utils::hook::detour SL_Init_hook;
utils::hook::detour SL_FindStringOfSize_hook;
utils::hook::detour SL_FindString_hook;
utils::hook::detour SL_FindLowercaseString_hook;
utils::hook::detour SL_AddUserInternal_hook;
utils::hook::detour Mark_ScriptStringCustom_hook;
utils::hook::detour SL_GetStringOfSize_hook;
utils::hook::detour SL_GetString__hook;
utils::hook::detour SL_GetString__0_hook;
utils::hook::detour SL_GetLowercaseStringOfLen_hook;
utils::hook::detour SL_GetLowercaseString_hook;
utils::hook::detour SL_ConvertToLowercase_hook;
utils::hook::detour SL_TransferRefToUser_hook;
utils::hook::detour SL_FreeString_hook;
utils::hook::detour SL_RemoveRefToString_hook;
utils::hook::detour Scr_SetString_hook;
utils::hook::detour Scr_SetStringFromCharString_hook;
utils::hook::detour GScr_AllocString_hook;
utils::hook::detour SL_GetStringForFloat_hook;
utils::hook::detour SL_GetStringForInt_hook;
utils::hook::detour SL_GetStringForVector_hook;
utils::hook::detour SL_ShutdownSystem_hook;
utils::hook::detour SL_TransferSystem_hook;
utils::hook::detour SL_CreateCanonicalFilename_hook;
utils::hook::detour Scr_CreateCanonicalFilename_hook;
void* SL_ConvertToString_original;
void* SL_GetStringLen_original;
void* GetHashCode_original;
void* SL_Init_original;
void* SL_FindStringOfSize_original;
void* SL_FindString_original;
void* SL_FindLowercaseString_original;
void* SL_AddUserInternal_original;
void* Mark_ScriptStringCustom_original;
void* SL_GetStringOfSize_original;
void* SL_GetString__original;
void* SL_GetString__0_original;
void* SL_GetLowercaseStringOfLen_original;
void* SL_GetLowercaseString_original;
void* SL_ConvertToLowercase_original;
void* SL_TransferRefToUser_original;
void* SL_FreeString_original;
void* SL_RemoveRefToString_original;
void* Scr_SetString_original;
void* Scr_SetStringFromCharString_original;
void* GScr_AllocString_original;
void* SL_GetStringForFloat_original;
void* SL_GetStringForInt_original;
void* SL_GetStringForVector_original;
void* SL_ShutdownSystem_original;
void* SL_TransferSystem_original;
void* SL_CreateCanonicalFilename_original;
void* Scr_CreateCanonicalFilename_original;
namespace
{
char* SL_ConvertToString_call(unsigned int id, game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return game::SL_ConvertToString(id, inst, SL_ConvertToString_original);
#else
return codsrc::SL_ConvertToString(id, inst);
#endif
}
// char *__usercall SL_ConvertToString@<eax>(unsigned int id@<eax>, game::scriptInstance_t inst@<ecx>)
NAKED char* SL_ConvertToString_stub()
{
_asm
{
push ecx;
push eax;
call SL_ConvertToString_call;
add esp, 0x8;
ret;
}
}
int SL_GetStringLen_call(unsigned int a1, game::scriptInstance_t a2, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return game::SL_GetStringLen(a1, a2, SL_GetStringLen_original);
#else
return codsrc::SL_GetStringLen(a1, a2);
#endif
}
// int __usercall SL_GetStringLen@<eax>(unsigned int a1@<eax>, game::scriptInstance_t a2@<ecx>)
NAKED int SL_GetStringLen_stub()
{
_asm
{
push ecx;
push eax;
call SL_GetStringLen_call;
add esp, 0x8;
ret;
}
}
unsigned int GetHashCode_call(unsigned int a1, const char* a2, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return game::GetHashCode(a1, a2, GetHashCode_original);
#else
return codsrc::GetHashCode(a1, a2);
#endif
}
// unsigned int __usercall GetHashCode@<eax>(unsigned int a1@<eax>, const char *a2@<edx>)
NAKED unsigned int GetHashCode_stub()
{
_asm
{
push edx;
push eax;
call GetHashCode_call;
add esp, 0x8;
ret;
}
}
void SL_Init_call(game::scriptInstance_t a1, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
game::SL_Init(a1, SL_Init_original);
#else
codsrc::SL_Init(a1);
#endif
}
// void __usercall SL_Init(game::scriptInstance_t a1@<eax>)
NAKED void SL_Init_stub()
{
_asm
{
push eax;
call SL_Init_call;
add esp, 0x4;
ret;
}
}
unsigned int SL_FindStringOfSize_call(game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr, const char* str_, unsigned int len)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return game::SL_FindStringOfSize(inst, str_, len, SL_FindStringOfSize_original);
#else
return codsrc::SL_FindStringOfSize(inst, str_, len);
#endif
}
// unsigned int __usercall SL_FindStringOfSize@<eax>(game::scriptInstance_t inst@<eax>, const char *str, unsigned int len)
NAKED unsigned int SL_FindStringOfSize_stub()
{
_asm
{
push eax;
call SL_FindStringOfSize_call;
add esp, 0x4;
ret;
}
}
unsigned int SL_FindString_call(const char* a1, [[maybe_unused]] void* caller_addr, game::scriptInstance_t a2)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return game::SL_FindString(a1, a2, SL_FindString_original);
#else
return codsrc::SL_FindString(a1, a2);
#endif
}
// unsigned int __usercall SL_FindString@<eax>(const char *a1@<edx>, game::scriptInstance_t a2)
NAKED unsigned int SL_FindString_stub()
{
_asm
{
push edx;
call SL_FindString_call;
add esp, 0x4;
ret;
}
}
unsigned int SL_FindLowercaseString_stub(const char* str, game::scriptInstance_t inst)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return SL_FindLowercaseString_hook.invoke<unsigned int>(str, inst);
#else
return codsrc::SL_FindLowercaseString(str, inst);
#endif
}
void SL_AddUserInternal_call(unsigned int user, game::RefString* refStr, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
game::SL_AddUserInternal(user, refStr, SL_AddUserInternal_original);
#else
codsrc::SL_AddUserInternal(user, refStr);
#endif
}
// void __usercall SL_AddUserInternal(unsigned int user@<eax>, RefString *refStr@<edx>)
NAKED void SL_AddUserInternal_stub()
{
_asm
{
push edx;
push eax;
call SL_AddUserInternal_call;
add esp, 0x8;
ret;
}
}
void Mark_ScriptStringCustom_call(unsigned int a1, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
game::Mark_ScriptStringCustom(a1, Mark_ScriptStringCustom_original);
#else
codsrc::Mark_ScriptStringCustom(a1);
#endif
}
// void __usercall Mark_ScriptStringCustom(unsigned __int16 *a1@<eax>)
NAKED void Mark_ScriptStringCustom_stub()
{
_asm
{
push eax;
call Mark_ScriptStringCustom_call;
add esp, 0x4;
ret;
}
}
unsigned int SL_GetStringOfSize_stub(game::scriptInstance_t inst, const char* string, unsigned int user, unsigned int len)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return SL_GetStringOfSize_hook.invoke<unsigned int>(inst, string, user, len);
#else
return codsrc::SL_GetStringOfSize(inst, string, user, len);
#endif
}
unsigned int SL_GetString__call(const char* a1, [[maybe_unused]] void* caller_addr, game::scriptInstance_t a2, unsigned int user)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return game::SL_GetString_(a1, a2, user, SL_GetString__original);
#else
return codsrc::SL_GetString_(a1, a2, user);
#endif
}
// unsigned int __usercall SL_GetString_@<eax>(const char *a1@<edx>, game::scriptInstance_t a2, unsigned int user)
NAKED unsigned int SL_GetString__stub()
{
_asm
{
push edx;
call SL_GetString__call;
add esp, 0x4;
ret;
}
}
unsigned int SL_GetString__0_call(const char* a1, [[maybe_unused]] void* caller_addr, unsigned int user, game::scriptInstance_t a3)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return game::SL_GetString__0(a1, user, a3, SL_GetString__0_original);
#else
return codsrc::SL_GetString__0(a1, user, a3);
#endif
}
// unsigned int __usercall SL_GetString__0@<eax>(const char *a1@<edx>, unsigned int user, game::scriptInstance_t a3)
NAKED unsigned int SL_GetString__0_stub()
{
_asm
{
push edx;
call SL_GetString__0_call;
add esp, 0x4;
ret;
}
}
unsigned int SL_GetLowercaseStringOfLen_stub(game::scriptInstance_t a1, const char* ArgList, unsigned int user, unsigned int len)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return SL_GetLowercaseStringOfLen_hook.invoke<unsigned int>(a1, ArgList, user, len);
#else
return codsrc::SL_GetLowercaseStringOfLen(a1, ArgList, user, len);
#endif
}
unsigned int SL_GetLowercaseString_call(const char* a2, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return game::SL_GetLowercaseString(a2, SL_GetLowercaseString_original);
#else
return codsrc::SL_GetLowercaseString(a2);
#endif
}
// unsigned int __usercall SL_GetLowercaseString@<eax>(const char *a2@<edx>)
NAKED unsigned int SL_GetLowercaseString_stub()
{
_asm
{
push edx;
call SL_GetLowercaseString_call;
add esp, 0x4;
ret;
}
}
unsigned int SL_ConvertToLowercase_stub(game::scriptInstance_t inst, unsigned int stringVal, unsigned int user)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return SL_ConvertToLowercase_hook.invoke<unsigned int>(inst, stringVal, user);
#else
return codsrc::SL_ConvertToLowercase(inst, stringVal, user);
#endif
}
void SL_TransferRefToUser_call(unsigned int stringValue, unsigned int user, [[maybe_unused]] void* caller_addr, game::scriptInstance_t inst)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
game::SL_TransferRefToUser(stringValue, user, inst, SL_TransferRefToUser_original);
#else
codsrc::SL_TransferRefToUser(stringValue, user, inst);
#endif
}
// void __usercall SL_TransferRefToUser(unsigned int stringValue@<eax>, unsigned int user@<ecx>, game::scriptInstance_t inst)
NAKED void SL_TransferRefToUser_stub()
{
_asm
{
push ecx;
push eax;
call SL_TransferRefToUser_call;
add esp, 0x8;
ret;
}
}
void SL_FreeString_stub(game::scriptInstance_t a1, unsigned int a2, game::RefString* a3, unsigned int a4)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
SL_FreeString_hook.invoke<void>(a1, a2, a3, a4);
#else
codsrc::SL_FreeString(a1, a2, a3, a4);
#endif
}
void SL_RemoveRefToString_call(unsigned int stringVal, game::scriptInstance_t inst, [[maybe_unused]] void* caller_addr)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
game::SL_RemoveRefToString(stringVal, inst, SL_RemoveRefToString_original);
#else
codsrc::SL_RemoveRefToString(stringVal, inst);
#endif
}
// void __usercall SL_RemoveRefToString(unsigned int stringVal@<edx>, game::scriptInstance_t inst@<esi>)
NAKED void SL_RemoveRefToString_stub()
{
_asm
{
push esi;
push edx;
call SL_RemoveRefToString_call;
add esp, 0x8;
ret;
}
}
void Scr_SetString_call(game::scriptInstance_t inst, unsigned int from, [[maybe_unused]] void* caller_addr, unsigned __int16* to)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
game::Scr_SetString(inst, from, to, Scr_SetString_original);
#else
codsrc::Scr_SetString(inst, from, to);
#endif
}
// void __usercall Scr_SetString(game::scriptInstance_t inst@<eax>, unsigned int from@<edi>, unsigned __int16 *to)
NAKED void Scr_SetString_stub()
{
_asm
{
push edi;
push eax;
call Scr_SetString_call;
add esp, 0x8;
ret;
}
}
void Scr_SetStringFromCharString_call(const char* a1, [[maybe_unused]] void* caller_addr, unsigned __int16* a2)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
game::Scr_SetStringFromCharString(a1, a2, Scr_SetStringFromCharString_original);
#else
codsrc::Scr_SetStringFromCharString(a1, a2);
#endif
}
// unsigned int __usercall Scr_SetStringFromCharString@<eax>(const char *a1@<edi>, unsigned __int16 *a2)
NAKED void Scr_SetStringFromCharString_stub()
{
_asm
{
push edi;
call Scr_SetStringFromCharString_call;
add esp, 0x4;
ret;
}
}
unsigned int GScr_AllocString_call(const char* a1, [[maybe_unused]] void* caller_addr, game::scriptInstance_t inst)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return game::GScr_AllocString(a1, inst, GScr_AllocString_original);
#else
return codsrc::GScr_AllocString(a1, inst);
#endif
}
// unsigned int __usercall GScr_AllocString@<eax>(const char *a1@<edx>, game::scriptInstance_t inst)
NAKED unsigned int GScr_AllocString_stub()
{
_asm
{
push edx;
call GScr_AllocString_call;
add esp, 0x4;
ret;
}
}
unsigned int SL_GetStringForFloat_call(float a1, [[maybe_unused]] void* caller_addr, game::scriptInstance_t a2)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return game::SL_GetStringForFloat(a1, a2, SL_GetStringForFloat_original);
#else
return codsrc::SL_GetStringForFloat(a1, a2);
#endif
}
// unsigned int __usercall SL_GetStringForFloat@<eax>(float a1@<xmm0>, game::scriptInstance_t a2)
NAKED unsigned int SL_GetStringForFloat_stub()
{
_asm
{
movd eax, xmm0;
push eax;
call SL_GetStringForFloat_call;
add esp, 0x4;
ret;
}
}
unsigned int SL_GetStringForInt_call(int a1, [[maybe_unused]] void* caller_addr, game::scriptInstance_t a2)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return game::SL_GetStringForInt(a1, a2, SL_GetStringForInt_original);
#else
return codsrc::SL_GetStringForInt(a1, a2);
#endif
}
// unsigned int __usercall SL_GetStringForInt@<eax>(int a1@<eax>, game::scriptInstance_t a2)
NAKED unsigned int SL_GetStringForInt_stub()
{
_asm
{
push eax;
call SL_GetStringForInt_call;
add esp, 0x4;
ret;
}
}
unsigned int SL_GetStringForVector_call(float* a1, [[maybe_unused]] void* caller_addr, game::scriptInstance_t a2)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return game::SL_GetStringForVector(a1, a2, SL_GetStringForVector_original);
#else
return codsrc::SL_GetStringForVector(a1, a2);
#endif
}
// unsigned int __usercall SL_GetStringForVector@<eax>(float *a1@<eax>, game::scriptInstance_t a2)
NAKED unsigned int SL_GetStringForVector_stub()
{
_asm
{
push eax;
call SL_GetStringForVector_call;
add esp, 0x4;
ret;
}
}
void SL_ShutdownSystem_call(game::scriptInstance_t a1, [[maybe_unused]] void* caller_addr, unsigned int a2)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
game::SL_ShutdownSystem(a1, a2, SL_ShutdownSystem_original);
#else
codsrc::SL_ShutdownSystem(a1, a2);
#endif
}
// void __usercall SL_ShutdownSystem(game::scriptInstance_t a1@<edi>, unsigned int a2)
NAKED void SL_ShutdownSystem_stub()
{
_asm
{
push edi;
call SL_ShutdownSystem_call;
add esp, 0x4;
ret;
}
}
void SL_TransferSystem_stub()
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
SL_TransferSystem_hook.invoke<void>();
#else
codsrc::SL_TransferSystem();
#endif
}
void SL_CreateCanonicalFilename_call(const char* filename, [[maybe_unused]] void* caller_addr, char* newFilename)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
game::SL_CreateCanonicalFilename(filename, newFilename, SL_CreateCanonicalFilename_original);
#else
codsrc::SL_CreateCanonicalFilename(filename, newFilename);
#endif
}
// void __usercall SL_CreateCanonicalFilename(const char *filename@<eax>, char *newFilename)
NAKED void SL_CreateCanonicalFilename_stub()
{
_asm
{
push eax;
call SL_CreateCanonicalFilename_call;
add esp, 0x4;
ret;
}
}
unsigned int Scr_CreateCanonicalFilename_stub(game::scriptInstance_t a1, const char* a2)
{
#ifdef RE_CSCR_STRINGLIST_USE_WRAPPERS
return Scr_CreateCanonicalFilename_hook.invoke<unsigned int>(a1, a2);
#else
return codsrc::Scr_CreateCanonicalFilename(a1, a2);
#endif
}
}
class component final : public component_interface
{
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);
//Original hook function addresses
SL_ConvertToString_original = SL_ConvertToString_hook.get_original();
SL_GetStringLen_original = SL_GetStringLen_hook.get_original();
GetHashCode_original = GetHashCode_hook.get_original();
SL_Init_original = SL_Init_hook.get_original();
SL_FindStringOfSize_original = SL_FindStringOfSize_hook.get_original();
SL_FindString_original = SL_FindString_hook.get_original();
SL_FindLowercaseString_original = SL_FindLowercaseString_hook.get_original();
SL_AddUserInternal_original = SL_AddUserInternal_hook.get_original();
Mark_ScriptStringCustom_original = Mark_ScriptStringCustom_hook.get_original();
SL_GetStringOfSize_original = SL_GetStringOfSize_hook.get_original();
SL_GetString__original = SL_GetString__hook.get_original();
SL_GetString__0_original = SL_GetString__0_hook.get_original();
SL_GetLowercaseStringOfLen_original = SL_GetLowercaseStringOfLen_hook.get_original();
SL_GetLowercaseString_original = SL_GetLowercaseString_hook.get_original();
SL_ConvertToLowercase_original = SL_ConvertToLowercase_hook.get_original();
SL_TransferRefToUser_original = SL_TransferRefToUser_hook.get_original();
SL_FreeString_original = SL_FreeString_hook.get_original();
SL_RemoveRefToString_original = SL_RemoveRefToString_hook.get_original();
Scr_SetString_original = Scr_SetString_hook.get_original();
Scr_SetStringFromCharString_original = Scr_SetStringFromCharString_hook.get_original();
GScr_AllocString_original = GScr_AllocString_hook.get_original();
SL_GetStringForFloat_original = SL_GetStringForFloat_hook.get_original();
SL_GetStringForInt_original = SL_GetStringForInt_hook.get_original();
SL_GetStringForVector_original = SL_GetStringForVector_hook.get_original();
SL_ShutdownSystem_original = SL_ShutdownSystem_hook.get_original();
SL_TransferSystem_original = SL_TransferSystem_hook.get_original();
SL_CreateCanonicalFilename_original = SL_CreateCanonicalFilename_hook.get_original();
Scr_CreateCanonicalFilename_original = Scr_CreateCanonicalFilename_hook.get_original();
}
private:
};
}
REGISTER_COMPONENT(re_cscr_stringlist::component)
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-137
View File
@@ -1,137 +0,0 @@
#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)
+4 -125
View File
@@ -1,111 +1,14 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "scheduler.hpp"
#include <json.hpp>
#include <utils/io.hpp>
#include <utils/hook.hpp>
#include <utils/string.hpp>
#include "gsc.hpp"
namespace gsc
{
std::unordered_map<std::string, game::BuiltinFunction> functions;
std::unordered_map<std::string, game::BuiltinMethod> methods;
utils::hook::detour scr_getmethod_hook;
void* scr_getfunction_stub_ret_loc;
namespace
{
game::BuiltinFunction scr_getfunction_call(const char** pName, int* pType)
{
auto itr = functions.find(*pName);
if (itr == functions.end())
{
return nullptr;
}
*pType = 0;
return itr->second;
}
game::BuiltinFunction NAKED scr_getfunction_stub()
{
__asm
{
push eax;
pushad;
lea eax, [esp + 0x24 + 0x2C - 0x1C];
push eax;
push edx;
call scr_getfunction_call;
add esp, 8;
mov [esp + 0x20], eax;
popad;
pop eax;
test eax, eax;
jnz just_ret;
// go do original code
push scr_getfunction_stub_ret_loc;
ret;
just_ret:
add esp, 4;
push 0x682DC8;
ret;
}
}
game::BuiltinMethod scr_getmethod_call(const char** pName, int* pType)
{
auto itr = methods.find(*pName);
if (itr == methods.end())
{
// call og
const auto og_addr = scr_getmethod_hook.get_original();
game::BuiltinMethod answer;
__asm
{
mov edi, pType;
mov esi, pName;
call og_addr;
mov answer, eax;
}
return answer;
}
*pType = 0;
return itr->second;
}
game::BuiltinMethod NAKED scr_getmethod_stub()
{
__asm
{
push edi;
push esi;
call scr_getmethod_call;
add esp, 8;
ret;
}
}
}
namespace function
{
void add(const std::string& name, const game::BuiltinFunction function)
{
functions.insert_or_assign(name, function);
plugin::get()->get_interface()->gsc()->register_function(name, function);
}
}
@@ -113,32 +16,8 @@ namespace gsc
{
void add(const std::string& name, const game::BuiltinMethod method)
{
methods.insert_or_assign(name, method);
plugin::get()->get_interface()->gsc()->register_method(name, (plutonium::sdk::v1::interfaces::gsc::method_callback)method);
}
}
}
class component final : public component_interface
{
public:
void post_unpack() override
{
// custom gsc methods
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
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:
};
}
REGISTER_COMPONENT(gsc::component)
+2 -186
View File
@@ -1,195 +1,11 @@
#include <stdinc.hpp>
#include "loader/component_loader.hpp"
#include "scheduler.hpp"
#include <utils/concurrency.hpp>
#include <utils/hook.hpp>
namespace scheduler
{
namespace
void on_scr_execute(void(*callback)())
{
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;
plugin::get()->get_interface()->callbacks()->on_scripts_execute(callback);
}
}
});
}
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)
+1 -19
View File
@@ -2,23 +2,5 @@
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_scr_execute(void(*callback)());
}
-226
View File
@@ -1,226 +0,0 @@
#include <stdinc.hpp>
#include "signatures.hpp"
#include <utils/hook.hpp>
#include <utils/io.hpp>
#include <utils/string.hpp>
#include <utils/cryptography.hpp>
#include <utils/compression.hpp>
#include <json.hpp>
namespace signatures
{
std::string read_sigs_file()
{
return utils::compression::zlib::decompress(utils::cryptography::des::decrypt(utils::io::read_file("t4sp-server-plugin/sigs")));
}
bool write_sigs_file(const std::string& f)
{
return utils::io::write_file("t4sp-server-plugin/sigs", utils::cryptography::des::encrypt(utils::compression::zlib::compress(f)));
}
const char* get_current_version()
{
return *reinterpret_cast<const char**>(0x4FF72D + 4);
}
std::unordered_map<std::string, std::string> get_cache_info_for_our_version()
{
std::unordered_map<std::string, std::string> answer;
auto* version = get_current_version();
nlohmann::json cache_json = nlohmann::json::parse(read_sigs_file(), nullptr, false, true);
if (!cache_json.is_discarded() && cache_json.is_object())
{
for (const auto& [key, value] : cache_json.items())
{
if (key != version)
{
continue;
}
if (!value.is_object())
{
continue;
}
answer = value.get<std::unordered_map<std::string, std::string>>();
break;
}
}
return answer;
}
bool save_cache_info_for_our_version(const std::unordered_map<std::string, std::string>& cache_info)
{
auto* version = get_current_version();
nlohmann::json cache_json = nlohmann::json::parse(read_sigs_file(), nullptr, false, true);
if (cache_json.is_discarded() || !cache_json.is_object())
{
cache_json = nlohmann::json::parse("{}", nullptr, false, true);
if (cache_json.is_discarded() || !cache_json.is_object())
{
return false; // can't happen?
}
}
cache_json[version] = cache_info;
return write_sigs_file(cache_json.dump());
}
size_t load_image_size()
{
MODULEINFO info{};
GetModuleInformation(GetCurrentProcess(),
GetModuleHandle("plutonium-bootstrapper-win32.exe"), &info, sizeof(MODULEINFO));
return info.SizeOfImage;
}
size_t get_image_size()
{
static const auto image_size = load_image_size();
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 = get_image_base();
utils::hook::signature signature(base, get_image_size() - base);
signature.add({
string,
mask,
[&](char* address)
{
string_ptr = address;
}
});
signature.process();
return reinterpret_cast<size_t>(string_ptr);
}
size_t find_string_ref(const std::string& string)
{
char bytes[4] = {0};
const auto string_ptr = find_string_ptr(string);
if (!string_ptr)
{
return 0;
}
std::memcpy(bytes, &string_ptr, sizeof(bytes));
return find_string_ptr({bytes, 4});
}
std::string err_reason;
std::string get_err_reason()
{
return err_reason;
}
bool process_printf()
{
auto cache_info = get_cache_info_for_our_version();
if (cache_info.contains("printf"))
{
game::plutonium::printf.set(std::atoi(cache_info.at("printf").c_str()));
return true;
}
const auto string_ref = find_string_ref("A critical exception occured!\n");
if (!string_ref)
{
err_reason = "printf";
return false;
}
const auto offset = *reinterpret_cast<size_t*>(string_ref + 5);
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()
{
size_t addr1;
size_t addr2;
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(scr_get_function_stub, 0x682D99);
SAFE_SET_PLUTO_SYMBOL(scr_get_method_stub, 0x683043);
return true;
}
bool process()
{
utils::cryptography::des::set_key("694201337");
return handle_funcs() && process_printf();
}
}
-7
View File
@@ -1,7 +0,0 @@
#pragma once
namespace signatures
{
std::string get_err_reason();
bool process();
}
+9 -15
View File
@@ -1,14 +1,8 @@
#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>
#include "gsc.hpp"
namespace test
{
@@ -21,15 +15,15 @@ namespace test
public:
void post_unpack() override
{
//Disable AI print spam
utils::hook::nop(0x4BAB7D, 5);
utils::hook::nop(0x4BAAFA, 5);
gsc::function::add("testfunc", []()
{
game::Com_Printf(game::CON_CHANNEL_DONT_FILTER, "this is a test builtin\n");
});
//Disable asset loading print spam
utils::hook::nop(0x48D9D9, 5);
//Disable unknown dvar spam
utils::hook::nop(0x5F04AF, 5);
gsc::method::add("testmeth", [](game::scr_entref_t ref)
{
game::Com_Printf(game::CON_CHANNEL_DONT_FILTER, "this is a test builtin on ent %d\n", ref.entnum);
});
}
private:
+3 -32
View File
@@ -1,40 +1,11 @@
#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_*/)
PLUTONIUM_API plutonium::sdk::plugin* PLUTONIUM_CALLBACK on_initialize()
{
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;
return plugin::get();
}
if (game::plutonium::printf.get() != nullptr)
BOOL APIENTRY DllMain(HMODULE /*module_*/, DWORD /*ul_reason_for_call*/, LPVOID /*reserved_*/)
{
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
View File
@@ -1,94 +0,0 @@
#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
View File
@@ -1,6 +0,0 @@
#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
+7 -4
View File
@@ -1,5 +1,4 @@
#include <stdinc.hpp>
#include "codsrc/clientscript/cscr_main.hpp"
namespace game
{
@@ -136,16 +135,20 @@ namespace game
int Scr_IsInOpcodeMemory(scriptInstance_t inst, const char* pos)
{
return codsrc::Scr_IsInOpcodeMemory(inst, pos);
assert(game::gScrVarPub[inst].programBuffer);
assert(pos);
return (unsigned int)(pos - game::gScrVarPub[inst].programBuffer) < game::gScrCompilePub[inst].programLen;
}
void SL_BeginLoadScripts(scriptInstance_t inst)
{
codsrc::SL_BeginLoadScripts(inst);
memset(game::gScrCompilePub[inst].canonicalStrings, 0, sizeof(game::gScrCompilePub[inst].canonicalStrings));
game::gScrVarPub[inst].canonicalStrCount = 0;
}
void Scr_SetLoadedImpureScript(bool loadedImpureScript)
{
codsrc::Scr_SetLoadedImpureScript(loadedImpureScript);
*game::loadedImpureScript = loadedImpureScript;
}
}
+5 -2
View File
@@ -1,5 +1,4 @@
#include <stdinc.hpp>
#include "codsrc/clientscript/cscr_memorytree.hpp"
namespace game
{
@@ -117,6 +116,10 @@ namespace game
RefVector* GetRefVector(scriptInstance_t inst, unsigned int id)
{
return codsrc::GetRefVector(inst, id);
assert(id);
assert((id * MT_NODE_SIZE) < MT_SIZE);
return (game::RefVector*)&game::gScrMemTreePub[inst].mt_buffer->nodes[id];
}
}
+6 -3
View File
@@ -1,5 +1,4 @@
#include <stdinc.hpp>
#include "codsrc/clientscript/cscr_parser.hpp"
namespace game
{
@@ -306,11 +305,15 @@ namespace game
unsigned int Scr_GetPrevSourcePos(scriptInstance_t inst, const char* codePos, unsigned int index)
{
return codsrc::Scr_GetPrevSourcePos(inst, codePos, index);
return game::gScrParserGlob[inst].sourcePosLookup[index + game::Scr_GetPrevSourcePosOpcodeLookup(inst, codePos)->sourcePosIndex].sourcePos;
}
void Scr_ShutdownAllocNode(scriptInstance_t inst)
{
codsrc::Scr_ShutdownAllocNode(inst);
if (game::g_allocNodeUser[inst])
{
game::Hunk_UserDestroy(game::g_allocNodeUser[inst]);
game::g_allocNodeUser[inst] = 0;
}
}
}
+3 -2
View File
@@ -1,10 +1,11 @@
#include <stdinc.hpp>
#include "codsrc/clientscript/cscr_parsetree.hpp"
namespace game
{
sval_u* Scr_AllocNode(scriptInstance_t inst, int size)
{
return codsrc::Scr_AllocNode(inst, size);
assert(game::g_allocNodeUser[inst]);
return (game::sval_u*)game::Hunk_UserAlloc(game::g_allocNodeUser[inst], 4 * size, 4);
}
}
+13 -2
View File
@@ -1,5 +1,4 @@
#include <stdinc.hpp>
#include "codsrc/clientscript/cscr_readwrite.hpp"
namespace game
{
@@ -39,6 +38,18 @@ namespace game
unsigned int FindVariableIndexInternal(scriptInstance_t inst, unsigned int parentId, unsigned int name)
{
return codsrc::FindVariableIndexInternal(inst, parentId, name);
game::VariableValueInternal* parentValue;
assert(parentId);
parentValue = &game::gScrVarGlob[inst].parentVariables[parentId + 1];
assert((parentValue->w.status & VAR_STAT_MASK) == VAR_STAT_EXTERNAL);
assert((parentValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(IsObject(parentValue));
return game::FindVariableIndexInternal2(inst, name, (parentId + name) % 0xFFFD + 1);
}
}
@@ -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);
}
+56 -10
View File
@@ -1,5 +1,4 @@
#include <stdinc.hpp>
#include "codsrc/clientscript/cscr_stringlist.hpp"
namespace game
{
@@ -325,41 +324,88 @@ namespace game
RefString* GetRefString(scriptInstance_t inst, unsigned int id)
{
return codsrc::GetRefString(inst, id);
assert(id);
assert((id * MT_NODE_SIZE) < MT_SIZE);
return (game::RefString*)&game::gScrMemTreePub[inst].mt_buffer->nodes[id];
}
void SL_AddRefToString(scriptInstance_t inst, unsigned int stringValue)
{
codsrc::SL_AddRefToString(inst, stringValue);
game::RefString* refStr = game::GetRefString(inst, stringValue);
InterlockedExchangeAdd((volatile unsigned int*)&refStr->u.data, 1u);
}
void SL_RemoveRefToStringOfSize(scriptInstance_t inst, unsigned int stringValue, unsigned int len)
{
codsrc::SL_RemoveRefToStringOfSize(inst, stringValue, len);
game::RefString* refStr;
refStr = game::GetRefString(inst, stringValue);
if (!(unsigned __int16)InterlockedDecrement((volatile unsigned int*)&refStr->u.data))
{
game::SL_FreeString(inst, stringValue, refStr, len);
}
}
int SL_GetRefStringLen(RefString* refString)
{
return codsrc::SL_GetRefStringLen(refString);
int len;
if (!refString->u.s.byteLen)
{
len = 256 - 1; //Bugfix for 256 % 256 = 0 or 512 % 256 = 0 or... Just promote it to 256
}
else
{
len = refString->u.s.byteLen - 1;
}
while (refString->str[len])
{
len += 256;
}
return len;
}
void SL_AddUser(unsigned int stringValue, unsigned int user, scriptInstance_t inst)
{
codsrc::SL_AddUser(stringValue, user, inst);
game::RefString* refStr;
refStr = game::GetRefString(inst, stringValue);
game::SL_AddUserInternal(user, refStr);
}
int SL_ConvertFromString(scriptInstance_t inst, const char* str)
{
return codsrc::SL_ConvertFromString(inst, str);
game::RefString* v2;
assert(str);
v2 = game::GetRefString_0(inst, str);
return game::SL_ConvertFromRefString(inst, v2);
}
int SL_ConvertFromRefString(scriptInstance_t inst, RefString* refString)
{
return codsrc::SL_ConvertFromRefString(inst, refString);
return ((char*)refString - (char*)game::gScrMemTreePub[inst].mt_buffer) / MT_NODE_SIZE;
}
RefString* GetRefString_0(scriptInstance_t inst, const char* str)
RefString* GetRefString_0([[maybe_unused]]scriptInstance_t inst, const char* str)
{
return codsrc::GetRefString_0(inst, str);
assert(str >= (char*)game::gScrMemTreePub[inst].mt_buffer && str < (char*)(game::gScrMemTreePub[inst].mt_buffer + MT_SIZE));
return (game::RefString*)(str - 4);
}
const char* SL_ConvertToStringSafe(unsigned int id, game::scriptInstance_t inst)
{
if (!id)
{
return "(NULL)";
}
return game::GetRefString(inst, id)->str;
}
}
+3 -4
View File
@@ -1,20 +1,19 @@
#include <stdinc.hpp>
#include "codsrc/clientscript/cscr_tempmemory.hpp"
namespace game
{
void TempMemorySetPos(char* pos)
{
codsrc::TempMemorySetPos(pos);
(*game::g_user)->pos = (int)pos;
}
void TempMemoryReset(HunkUser* user)
{
codsrc::TempMemoryReset(user);
*game::g_user = user;
}
char* TempMalloc(int len)
{
return codsrc::TempMalloc(len);
return (char*)game::Hunk_UserAlloc(*game::g_user, len, 1);
}
}
+334 -34
View File
@@ -1,5 +1,4 @@
#include <stdinc.hpp>
#include "codsrc/clientscript/cscr_variable.hpp"
namespace game
{
@@ -1287,151 +1286,452 @@ namespace game
unsigned int FindObject(scriptInstance_t inst, unsigned int id)
{
return codsrc::FindObject(inst, id);
game::VariableValueInternal* entryValue;
assert(id);
entryValue = &game::gScrVarGlob[inst].childVariables[id];
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert((entryValue->w.type & VAR_MASK) == game::VAR_POINTER);
return entryValue->u.u.pointerValue;
}
float Scr_GetEntryUsageInternal(scriptInstance_t inst, unsigned int type, VariableUnion u)
{
return codsrc::Scr_GetEntryUsageInternal(inst, type, u);
float result;
game::VariableValueInternal* parentValue;
if (type != game::VAR_POINTER)
{
return 0.0f;
}
parentValue = &game::gScrVarGlob[inst].parentVariables[u.intValue + 1];
assert((parentValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(IsObject(parentValue));
if ((parentValue->w.status & VAR_MASK) == game::VAR_ARRAY)
{
result = game::Scr_GetObjectUsage(inst, u.stringValue) / ((float)parentValue->u.o.refCount + 1.0f);
}
else
{
result = 0.0f;
}
return result;
}
float Scr_GetEntryUsage(scriptInstance_t inst, VariableValueInternal* entryValue)
{
return codsrc::Scr_GetEntryUsage(inst, entryValue);
return game::Scr_GetEntryUsageInternal(inst, entryValue->w.status & 0x1F, entryValue->u.u) + 1.0f;
}
unsigned int FindFirstSibling(scriptInstance_t inst, unsigned int id)
{
return codsrc::FindFirstSibling(inst, id);
game::VariableValueInternal* entryValue;
entryValue = &game::gScrVarGlob[inst].parentVariables[id + 1];
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(IsObject(entryValue));
return entryValue->nextSibling;
}
unsigned int FindNextSibling(scriptInstance_t inst, unsigned int id)
{
return codsrc::FindNextSibling(inst, id);
unsigned int nextSibling;
game::VariableValueInternal* list;
unsigned int childId;
game::VariableValueInternal* entryValue;
game::VariableValueInternal* childValue;
list = game::gScrVarGlob[inst].childVariables;
entryValue = &list[id];
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(!IsObject(entryValue));
nextSibling = entryValue->nextSibling;
if (!nextSibling)
{
return 0;
}
VariableValue Scr_GetArrayIndexValue(scriptInstance_t inst, unsigned int name)
childId = list[nextSibling].hash.id;
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
childValue = &list[childId];
assert(!IsObject(childValue));
return childId;
}
VariableValue Scr_GetArrayIndexValue(scriptInstance_t, unsigned int name)
{
return codsrc::Scr_GetArrayIndexValue(inst, name);
game::VariableValue value;
assert(name);
if (name >= SL_MAX_STRING_INDEX)
{
if (name >= OBJECT_STACK)
{
value.type = game::VAR_INTEGER;
value.u.intValue = name - 0x800000;
}
else
{
value.type = game::VAR_POINTER;
value.u.intValue = name - SL_MAX_STRING_INDEX;
}
}
else
{
value.type = game::VAR_STRING;
value.u.intValue = (unsigned short)name;
}
return value;
}
void AddRefToObject(scriptInstance_t inst, unsigned int id)
{
codsrc::AddRefToObject(inst, id);
game::VariableValueInternal* entryValue;
assert(id >= 1 && id < VARIABLELIST_CHILD_BEGIN);
assert((game::gScrVarGlob[inst].parentVariables[id + 1].w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
entryValue = &game::gScrVarGlob[inst].parentVariables[id + 1];
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(IsObject(entryValue));
++entryValue->u.o.refCount;
assert(entryValue->u.o.refCount);
}
void RemoveRefToEmptyObject(scriptInstance_t inst, unsigned int id)
{
codsrc::RemoveRefToEmptyObject(inst, id);
game::VariableValueInternal* entryValue;
entryValue = &game::gScrVarGlob[inst].parentVariables[id + 1];
assert(((entryValue->w.status & VAR_STAT_MASK) == VAR_STAT_EXTERNAL));
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(IsObject(entryValue));
assert(!entryValue->nextSibling);
if (entryValue->u.o.refCount)
{
assert(id >= 1 && id < VARIABLELIST_CHILD_BEGIN);
--entryValue->u.o.refCount;
}
else
{
game::FreeVariable(id, inst);
}
}
void Scr_ClearThread(scriptInstance_t inst, unsigned int parentId)
{
codsrc::Scr_ClearThread(inst, parentId);
game::VariableValueInternal* parentValue;
assert(parentId);
parentValue = &game::gScrVarGlob[inst].parentVariables[parentId + 1];
assert((parentValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(((parentValue->w.type & VAR_MASK) >= game::VAR_THREAD) && ((parentValue->w.type & VAR_MASK) <= game::VAR_CHILD_THREAD));
assert(!game::FindVariable(OBJECT_STACK, parentId, inst));
if (parentValue->nextSibling)
{
game::ClearObjectInternal(inst, parentId);
}
game::RemoveRefToObject(parentValue->u.o.u.nextEntId, inst);
}
unsigned int FindObjectVariable(scriptInstance_t inst, unsigned int parentId, unsigned int id)
{
return codsrc::FindObjectVariable(inst, parentId, id);
return game::gScrVarGlob[inst].childVariables[game::FindVariableIndexInternal(inst, parentId, id + SL_MAX_STRING_INDEX)].hash.id;
}
void RemoveObjectVariable(scriptInstance_t inst, unsigned int parentId, unsigned int id)
{
codsrc::RemoveObjectVariable(inst, parentId, id);
assert((game::gScrVarGlob[inst].parentVariables[parentId + 1].w.type & VAR_MASK) == game::VAR_ARRAY);
game::RemoveVariable(id + SL_MAX_STRING_INDEX, parentId, inst);
}
VariableValueInternal_u* GetVariableValueAddress(scriptInstance_t inst, unsigned int id)
{
return codsrc::GetVariableValueAddress(inst, id);
game::VariableValueInternal* entryValue;
assert(id);
entryValue = &game::gScrVarGlob[inst].childVariables[id];
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert((entryValue->w.type & VAR_MASK) != game::VAR_UNDEFINED);
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(!IsObject(entryValue));
return &entryValue->u;
}
void Scr_KillEndonThread(scriptInstance_t inst, unsigned int threadId)
{
codsrc::Scr_KillEndonThread(inst, threadId);
game::VariableValueInternal* parentValue;
parentValue = &game::gScrVarGlob[inst].parentVariables[threadId + 1];
assert((parentValue->w.status & VAR_STAT_MASK) == VAR_STAT_EXTERNAL);
assert((parentValue->w.type & VAR_MASK) == game::VAR_THREAD);
assert(!parentValue->nextSibling);
game::RemoveRefToObject(parentValue->u.o.u.nextEntId, inst);
assert(!game::FindObjectVariable(inst, game::gScrVarPub[inst].pauseArrayId, threadId));
parentValue->w.status &= ~0xAu;
parentValue->w.status |= game::VAR_DEAD_THREAD;
}
BOOL IsValidArrayIndex(scriptInstance_t inst, unsigned int unsignedValue)
BOOL IsValidArrayIndex(scriptInstance_t, unsigned int unsignedValue)
{
return codsrc::IsValidArrayIndex(inst, unsignedValue);
return (unsignedValue + 0x7EA002) <= 0xFEA001;
}
void RemoveArrayVariable(scriptInstance_t inst, unsigned int parentId, unsigned int unsignedValue)
{
codsrc::RemoveArrayVariable(inst, parentId, unsignedValue);
assert(game::IsValidArrayIndex(inst, unsignedValue));
game::RemoveVariable((unsignedValue + 0x800000) & 0xFFFFFF, parentId, inst);
}
void SafeRemoveArrayVariable(scriptInstance_t inst, unsigned int parentId, unsigned int unsignedValue)
{
codsrc::SafeRemoveArrayVariable(inst, parentId, unsignedValue);
assert(game::IsValidArrayIndex(inst, unsignedValue));
game::SafeRemoveVariable((unsignedValue + 0x800000) & 0xFFFFFF, parentId, inst);
}
void AddRefToVector(scriptInstance_t inst, const float* floatVal)
void AddRefToVector(scriptInstance_t, const float* floatVal)
{
codsrc::AddRefToVector(inst, floatVal);
game::RefVector* rf = (game::RefVector*)(floatVal - 1);
if (!rf->u.s.length)
{
++rf->u.s.refCount;
assert(rf->u.s.refCount);
}
}
unsigned int FindArrayVariableIndex(scriptInstance_t inst, unsigned int parentId, unsigned int unsignedValue)
{
return codsrc::FindArrayVariableIndex(inst, parentId, unsignedValue);
assert(game::IsValidArrayIndex(inst, unsignedValue));
return game::FindVariableIndexInternal(inst, parentId, (unsignedValue + 0x800000) & 0xFFFFFF); // - ??
}
unsigned int GetVariableIndexInternal(scriptInstance_t inst, unsigned int parentId, unsigned int name)
{
return codsrc::GetVariableIndexInternal(inst, parentId, name);
unsigned int newIndex;
game::VariableValueInternal* parentValue;
assert(parentId);
parentValue = &game::gScrVarGlob[inst].parentVariables[parentId + 1];
assert((parentValue->w.status & VAR_STAT_MASK) == VAR_STAT_EXTERNAL);
assert((parentValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(IsObject(parentValue));
newIndex = game::FindVariableIndexInternal2(inst, name, (parentId + name) % 0xFFFD + 1);
if (newIndex)
{
return newIndex;
}
return game::GetNewVariableIndexInternal2(name, inst, parentId, (parentId + name) % 0xFFFD + 1);
}
unsigned int GetNewVariableIndexInternal(scriptInstance_t inst, unsigned int parentId, unsigned int name)
{
return codsrc::GetNewVariableIndexInternal(inst, parentId, name);
assert(!game::FindVariableIndexInternal(inst, parentId, name));
return game::GetNewVariableIndexInternal2(name, inst, parentId, (parentId + name) % 0xFFFD + 1);
}
unsigned int AllocObject(scriptInstance_t inst)
{
return codsrc::AllocObject(inst);
game::VariableValueInternal* entryValue;
unsigned int id;
id = game::AllocVariable(inst);
entryValue = &game::gScrVarGlob[inst].parentVariables[id + 1];
entryValue->w.status = VAR_STAT_EXTERNAL;
assert((entryValue->w.type & VAR_MASK) == game::VAR_UNDEFINED);
entryValue->w.status |= game::VAR_OBJECT;
entryValue->u.o.refCount = 0;
return id;
}
VariableType GetValueType(scriptInstance_t inst, unsigned int id)
{
return codsrc::GetValueType(inst, id);
assert((game::gScrVarGlob[inst].childVariables[id].w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
return (game::VariableType)(game::gScrVarGlob[inst].childVariables[id].w.status & VAR_MASK);
}
VariableType GetObjectType(scriptInstance_t inst, unsigned int id)
{
return codsrc::GetObjectType(inst, id);
assert((game::gScrVarGlob[inst].parentVariables[id + 1].w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
return (game::VariableType)(game::gScrVarGlob[inst].parentVariables[id + 1].w.status & VAR_MASK);
}
float* Scr_AllocVector_(scriptInstance_t inst, const float* v)
{
return codsrc::Scr_AllocVector_(inst, v);
float* vectorValue;
vectorValue = game::Scr_AllocVector(inst);
vectorValue[0] = v[0];
vectorValue[1] = v[1];
vectorValue[2] = v[2];
return vectorValue;
}
void Scr_EvalInequality(scriptInstance_t inst, VariableValue* value1, VariableValue* value2)
{
codsrc::Scr_EvalInequality(inst, value1, value2);
game::Scr_EvalEquality(value1, inst, value2);
assert((value1->type == game::VAR_INTEGER) || (value1->type == game::VAR_UNDEFINED));
value1->u.intValue = value1->u.intValue == 0;
}
unsigned int Scr_EvalArrayRefInternal(scriptInstance_t inst, VariableValue* varValue, VariableValueInternal* parentValue)
{
return codsrc::Scr_EvalArrayRefInternal(inst, varValue, parentValue);
game::VariableValueInternal* entryValue;
unsigned int result;
unsigned int id;
if (varValue->type == game::VAR_POINTER)
{
entryValue = &game::gScrVarGlob[inst].parentVariables[varValue->u.intValue + 1];
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(IsObject(entryValue));
if ((entryValue->w.status & VAR_MASK) == game::VAR_ARRAY)
{
if (entryValue->u.o.refCount)
{
id = varValue->u.intValue;
game::RemoveRefToObject(varValue->u.stringValue, inst);
varValue->u.intValue = game::Scr_AllocArray(inst);
game::CopyArray(inst, id, varValue->u.stringValue);
parentValue->u.u.intValue = varValue->u.intValue;
}
result = varValue->u.intValue;
}
else
{
game::gScrVarPub[inst].error_index = 1;
game::Scr_Error(game::va("%s is not an array", game::var_typename[entryValue->w.status & VAR_MASK]), inst, 0);
result = 0;
}
}
else
{
assert(varValue->type != game::VAR_STACK);
game::gScrVarPub[inst].error_index = 1;
if (varValue->type == game::VAR_STRING)
{
game::Scr_Error("string characters cannot be individually changed", inst, 0);
result = 0;
}
else
{
if (varValue->type == game::VAR_VECTOR)
{
game::Scr_Error("vector components cannot be individually changed", inst, 0);
}
else
{
game::Scr_Error(game::va("%s is not an array", game::var_typename[varValue->type]), inst, 0);
}
result = 0;
}
}
return result;
}
unsigned int GetNewArrayVariableIndex(scriptInstance_t inst, unsigned int parentId, unsigned int unsignedValue)
{
return codsrc::GetNewArrayVariableIndex(inst, parentId, unsignedValue);
assert(game::IsValidArrayIndex(inst, unsignedValue));
return game::GetNewVariableIndexInternal(inst, parentId, (unsignedValue + 0x800000) & 0xFFFFFF);
}
unsigned int GetNewArrayVariable(scriptInstance_t inst, unsigned int parentId, unsigned int unsignedValue)
{
return codsrc::GetNewArrayVariable(inst, parentId, unsignedValue);
return game::gScrVarGlob[inst].childVariables[game::GetNewArrayVariableIndex(inst, parentId, unsignedValue)].hash.id;
}
unsigned int GetArrayVariable(scriptInstance_t inst, unsigned int parentId, unsigned int unsignedValue)
{
return codsrc::GetArrayVariable(inst, parentId, unsignedValue);
return game::gScrVarGlob[inst].childVariables[game::GetArrayVariableIndex(unsignedValue, inst, parentId)].hash.id;
}
unsigned int AllocThread(scriptInstance_t inst, unsigned int self)
{
return codsrc::AllocThread(inst, self);
game::VariableValueInternal* entryValue;
unsigned int id;
id = game::AllocVariable(inst);
entryValue = &game::gScrVarGlob[inst].parentVariables[id + 1];
entryValue->w.status = VAR_STAT_EXTERNAL;
assert((entryValue->w.type & VAR_MASK) == game::VAR_UNDEFINED);
entryValue->w.status |= game::VAR_THREAD;
entryValue->u.o.refCount = 0;
entryValue->u.o.u.self = (unsigned short)self;
return id;
}
}
+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);
}
+287 -51
View File
@@ -1,5 +1,4 @@
#include <stdinc.hpp>
#include "codsrc/clientscript/cscr_vm.hpp"
namespace game
{
@@ -784,201 +783,438 @@ namespace game
void SetVariableFieldValue(scriptInstance_t inst, unsigned int id, VariableValue* value)
{
codsrc::SetVariableFieldValue(inst, id, value);
if (id)
{
game::SetVariableValue(inst, value, id);
}
else
{
game::SetVariableEntityFieldValue(inst, game::gScrVarPub[inst].entId, game::gScrVarPub[inst].entFieldName, value);
}
}
void SetNewVariableValue(scriptInstance_t inst, unsigned int id, VariableValue* value)
{
codsrc::SetNewVariableValue(inst, id, value);
game::VariableValueInternal* entryValue;
assert(value->type < game::VAR_THREAD);
entryValue = &game::gScrVarGlob[inst].childVariables[id];
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(!IsObject(entryValue));
assert(value->type >= game::VAR_UNDEFINED && value->type < game::VAR_COUNT);
assert((entryValue->w.type & VAR_MASK) == game::VAR_UNDEFINED);
assert((value->type != game::VAR_POINTER) || ((entryValue->w.type & VAR_MASK) < game::FIRST_DEAD_OBJECT));
entryValue->w.status |= value->type;
entryValue->u.u.intValue = value->u.intValue;
}
void Scr_ClearErrorMessage(scriptInstance_t inst)
{
codsrc::Scr_ClearErrorMessage(inst);
game::gScrVarPub[inst].error_message = 0;
game::gScrVmGlob[inst].dialog_error_message = 0;
game::gScrVarPub[inst].error_index = 0;
}
void VM_Shutdown(scriptInstance_t inst)
{
codsrc::VM_Shutdown(inst);
if (game::gScrVarPub[inst].tempVariable)
{
game::FreeValue(game::gScrVarPub[inst].tempVariable, inst);
game::gScrVarPub[inst].tempVariable = 0;
}
}
void Scr_ShutdownVariables(scriptInstance_t inst)
{
codsrc::Scr_ShutdownVariables(inst);
if (game::gScrVarPub[inst].gameId)
{
game::FreeValue(game::gScrVarPub[inst].gameId, inst);
game::gScrVarPub[inst].gameId = 0;
}
}
void ClearVariableValue(scriptInstance_t inst, unsigned int id)
{
codsrc::ClearVariableValue(inst, id);
game::VariableValueInternal* entryValue;
assert(id);
entryValue = &game::gScrVarGlob[inst].childVariables[id];
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(!IsObject(entryValue));
assert((entryValue->w.type & VAR_MASK) != game::VAR_STACK);
game::RemoveRefToValueInternal(inst, (game::VariableType)(entryValue->w.status & VAR_MASK), entryValue->u.u);
entryValue->w.status &= ~VAR_MASK;
assert((entryValue->w.type & VAR_MASK) == game::VAR_UNDEFINED);
}
unsigned int Scr_GetThreadNotifyName(scriptInstance_t inst, unsigned int startLocalId)
{
return codsrc::Scr_GetThreadNotifyName(inst, startLocalId);
assert((game::gScrVarGlob[inst].parentVariables[startLocalId + 1].w.type & VAR_STAT_MASK) == VAR_STAT_EXTERNAL);
assert((game::gScrVarGlob[inst].parentVariables[startLocalId + 1].w.type & VAR_MASK) == game::VAR_NOTIFY_THREAD);
assert((game::gScrVarGlob[inst].parentVariables[startLocalId + 1].w.notifyName >> VAR_NAME_BIT_SHIFT) < VARIABLELIST_CHILD_SIZE);
return game::gScrVarGlob[inst].parentVariables[startLocalId + 1].w.status >> VAR_NAME_BIT_SHIFT;
}
void Scr_RemoveThreadNotifyName(scriptInstance_t inst, unsigned int startLocalId)
{
codsrc::Scr_RemoveThreadNotifyName(inst, startLocalId);
unsigned __int16 stringValue;
game::VariableValueInternal* entryValue;
entryValue = &game::gScrVarGlob[inst].parentVariables[startLocalId + 1];
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert((entryValue->w.type & VAR_MASK) == game::VAR_NOTIFY_THREAD);
stringValue = (unsigned short)game::Scr_GetThreadNotifyName(inst, startLocalId);
assert(stringValue);
game::SL_RemoveRefToString(stringValue, inst);
entryValue->w.status &= ~VAR_MASK;
entryValue->w.status |= game::VAR_THREAD;
}
unsigned int GetArraySize(scriptInstance_t inst, unsigned int id)
{
return codsrc::GetArraySize(inst, id);
game::VariableValueInternal* entryValue;
assert(id);
entryValue = &game::gScrVarGlob[inst].parentVariables[id + 1];
assert((entryValue->w.type & VAR_MASK) == game::VAR_ARRAY);
return entryValue->u.o.u.entnum;
}
void IncInParam(scriptInstance_t inst)
{
codsrc::IncInParam(inst);
assert(((game::gScrVmPub[inst].top >= game::gScrVmGlob[inst].eval_stack - 1) && (game::gScrVmPub[inst].top <= game::gScrVmGlob[inst].eval_stack)) ||
((game::gScrVmPub[inst].top >= game::gScrVmPub[inst].stack) && (game::gScrVmPub[inst].top <= game::gScrVmPub[inst].maxstack)));
game::Scr_ClearOutParams(inst);
if (game::gScrVmPub[inst].top == game::gScrVmPub[inst].maxstack)
{
game::Sys_Error("Internal script stack overflow");
}
++game::gScrVmPub[inst].top;
++game::gScrVmPub[inst].inparamcount;
assert(((game::gScrVmPub[inst].top >= game::gScrVmGlob[inst].eval_stack) && (game::gScrVmPub[inst].top <= game::gScrVmGlob[inst].eval_stack + 1)) ||
((game::gScrVmPub[inst].top >= game::gScrVmPub[inst].stack) && (game::gScrVmPub[inst].top <= game::gScrVmPub[inst].maxstack)));
}
unsigned int GetParentLocalId(scriptInstance_t inst, unsigned int threadId)
{
return codsrc::GetParentLocalId(inst, threadId);
assert((game::gScrVarGlob[inst].parentVariables[threadId + 1].w.status & VAR_STAT_MASK) == VAR_STAT_EXTERNAL);
assert((game::gScrVarGlob[inst].parentVariables[threadId + 1].w.type & VAR_MASK) == game::VAR_CHILD_THREAD);
return game::gScrVarGlob[inst].parentVariables[threadId + 1].w.status >> VAR_NAME_BIT_SHIFT;
}
void Scr_ClearWaitTime(scriptInstance_t inst, unsigned int startLocalId)
{
codsrc::Scr_ClearWaitTime(inst, startLocalId);
game::VariableValueInternal* entryValue;
entryValue = &game::gScrVarGlob[inst].parentVariables[startLocalId + 1];
assert(((entryValue->w.status & VAR_STAT_MASK) == VAR_STAT_EXTERNAL));
assert((entryValue->w.type & VAR_MASK) == game::VAR_TIME_THREAD);
entryValue->w.status &= ~VAR_MASK;
entryValue->w.status |= game::VAR_THREAD;
}
void Scr_SetThreadWaitTime(scriptInstance_t inst, unsigned int startLocalId, unsigned int waitTime)
{
codsrc::Scr_SetThreadWaitTime(inst, startLocalId, waitTime);
game::VariableValueInternal* entryValue;
entryValue = &game::gScrVarGlob[inst].parentVariables[startLocalId + 1];
assert(((entryValue->w.status & VAR_STAT_MASK) == VAR_STAT_EXTERNAL));
assert(((entryValue->w.type & VAR_MASK) == game::VAR_THREAD) || !game::Scr_GetThreadNotifyName(inst, startLocalId));
entryValue->w.status &= ~VAR_MASK;
entryValue->w.status = (unsigned __int8)entryValue->w.status;
entryValue->w.status |= game::VAR_TIME_THREAD;
game::gScrVarGlob[inst].parentVariables[startLocalId + 1].w.status |= waitTime << 8;
}
void Scr_SetThreadNotifyName(scriptInstance_t inst, unsigned int startLocalId, unsigned int stringValue)
{
codsrc::Scr_SetThreadNotifyName(inst, startLocalId, stringValue);
game::VariableValueInternal* entryValue;
entryValue = &game::gScrVarGlob[inst].parentVariables[startLocalId + 1];
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(((entryValue->w.type & VAR_MASK) == game::VAR_THREAD));
entryValue->w.status &= ~VAR_MASK;
entryValue->w.status = (unsigned __int8)entryValue->w.status;
entryValue->w.status |= game::VAR_NOTIFY_THREAD;
entryValue->w.status |= stringValue << 8;
}
void Scr_DebugTerminateThread(scriptInstance_t inst, int topThread)
{
codsrc::Scr_DebugTerminateThread(inst, topThread);
// if ( topThread != game::gScrVmPub[inst].function_count )
{
game::gScrVmPub[inst].function_frame_start[topThread].fs.pos = game::g_EndPos.get();
}
}
unsigned int Scr_GetThreadWaitTime(scriptInstance_t inst, unsigned int startLocalId)
{
return codsrc::Scr_GetThreadWaitTime(inst, startLocalId);
assert((game::gScrVarGlob[inst].parentVariables[startLocalId + 1].w.status & VAR_STAT_MASK) == VAR_STAT_EXTERNAL);
assert((game::gScrVarGlob[inst].parentVariables[startLocalId + 1].w.type & VAR_MASK) == game::VAR_TIME_THREAD);
return game::gScrVarGlob[inst].parentVariables[startLocalId + 1].w.status >> 8;
}
const char* Scr_GetStackThreadPos(scriptInstance_t inst, unsigned int endLocalId, VariableStackBuffer* stackValue, bool killThread)
const char* Scr_GetStackThreadPos([[maybe_unused]]scriptInstance_t inst, unsigned int, VariableStackBuffer*, bool)
{
return codsrc::Scr_GetStackThreadPos(inst, endLocalId, stackValue, killThread);
assert(game::gScrVarPub[inst].developer);
return 0;
}
unsigned int Scr_GetSelf(scriptInstance_t inst, unsigned int threadId)
{
return codsrc::Scr_GetSelf(inst, threadId);
assert((game::gScrVarGlob[inst].parentVariables[threadId + 1].w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(((game::gScrVarGlob[inst].parentVariables[threadId + 1].w.type & VAR_MASK) >= game::VAR_THREAD) &&
((game::gScrVarGlob[inst].parentVariables[threadId + 1].w.type & VAR_MASK) <= game::VAR_CHILD_THREAD));
return game::gScrVarGlob[inst].parentVariables[threadId + 1].u.o.u.self;
}
unsigned int GetVariableKeyObject(scriptInstance_t inst, unsigned int id)
{
return codsrc::GetVariableKeyObject(inst, id);
game::VariableValueInternal* entryValue;
entryValue = &game::gScrVarGlob[inst].childVariables[id];
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(!IsObject(entryValue));
return (game::gScrVarGlob[inst].childVariables[id].w.status >> 8) - 0x10000;
}
int MT_Realloc(scriptInstance_t inst, int oldNumBytes, int newNumbytes)
{
return codsrc::MT_Realloc(inst, oldNumBytes, newNumbytes);
int size;
size = game::MT_GetSize(oldNumBytes, inst);
return size >= game::MT_GetSize(newNumbytes, inst);
}
void CScr_GetObjectField(classNum_e classnum, int entnum, int clientNum, int offset)
{
codsrc::CScr_GetObjectField(classnum, entnum, clientNum, offset);
if (classnum > game::CLASS_NUM_ENTITY)
{
//assertMsg("bad classnum");
assert(false);
}
else
{
game::CScr_GetEntityField(offset, entnum, clientNum);
}
}
int CScr_SetObjectField(classNum_e classnum, int entnum, int clientNum, int offset)
{
return codsrc::CScr_SetObjectField(classnum, entnum, clientNum, offset);
if (classnum > game::CLASS_NUM_ENTITY)
{
//assertMsg("bad classnum");
assert(false);
return 1;
}
else
{
return game::CScr_SetEntityField(offset, entnum, clientNum);
}
}
void Scr_SetErrorMessage(scriptInstance_t inst, const char* error)
{
codsrc::Scr_SetErrorMessage(inst, error);
if (!game::gScrVarPub[inst].error_message)
{
game::I_strncpyz(game::error_message_buff.get(), error, 1023u);
game::error_message_buff[1023] = '\0';
game::gScrVarPub[inst].error_message = game::error_message_buff.get();
}
}
bool Scr_IsStackClear(scriptInstance_t inst)
{
return codsrc::Scr_IsStackClear(inst);
return game::gScrVmPub[inst].top == game::gScrVmPub[inst].stack;
}
void SL_CheckExists(scriptInstance_t inst, unsigned int stringValue)
void SL_CheckExists(scriptInstance_t, unsigned int)
{
codsrc::SL_CheckExists(inst, stringValue);
}
const char* Scr_ReadCodePos(scriptInstance_t inst, const char** pos)
const char* Scr_ReadCodePos(scriptInstance_t, const char** pos)
{
return codsrc::Scr_ReadCodePos(inst, pos);
int ans;
ans = *(int*)*pos;
*pos += 4;
return (const char*)ans;
}
unsigned int Scr_ReadUnsignedInt(scriptInstance_t inst, const char** pos)
unsigned int Scr_ReadUnsignedInt(scriptInstance_t, const char** pos)
{
return codsrc::Scr_ReadUnsignedInt(inst, pos);
unsigned int ans;
ans = *(unsigned int*)*pos;
*pos += 4;
return ans;
}
unsigned short Scr_ReadUnsignedShort(scriptInstance_t inst, const char** pos)
unsigned short Scr_ReadUnsignedShort(scriptInstance_t, const char** pos)
{
return codsrc::Scr_ReadUnsignedShort(inst, pos);
unsigned short ans;
ans = *(unsigned short*)*pos;
*pos += 2;
return ans;
}
unsigned char Scr_ReadUnsignedByte(scriptInstance_t inst, const char** pos)
unsigned char Scr_ReadUnsignedByte(scriptInstance_t, const char** pos)
{
return codsrc::Scr_ReadUnsignedByte(inst, pos);
unsigned char ans;
ans = *(unsigned char*)*pos;
*pos += 1;
return ans;
}
float Scr_ReadFloat(scriptInstance_t inst, const char** pos)
float Scr_ReadFloat(scriptInstance_t, const char** pos)
{
return codsrc::Scr_ReadFloat(inst, pos);
float ans;
ans = *(float*)*pos;
*pos += 4;
return ans;
}
const float* Scr_ReadVector(scriptInstance_t inst, const char** pos)
const float* Scr_ReadVector(scriptInstance_t, const char** pos)
{
return codsrc::Scr_ReadVector(inst, pos);
float* ans;
ans = (float*)*pos;
*pos += 12;
return ans;
}
BOOL IsFieldObject(scriptInstance_t inst, unsigned int id)
{
return codsrc::IsFieldObject(inst, id);
game::VariableValueInternal* entryValue;
assert(id);
entryValue = &game::gScrVarGlob[inst].parentVariables[id + 1];
assert((entryValue->w.status & VAR_STAT_MASK) != VAR_STAT_FREE);
assert(IsObject(entryValue));
return (game::VariableType)(entryValue->w.status & VAR_MASK) < game::VAR_ARRAY;
}
void RemoveVariableValue(scriptInstance_t inst, unsigned int parentId, unsigned int index)
{
codsrc::RemoveVariableValue(inst, parentId, index);
unsigned int id;
assert(index);
id = game::gScrVarGlob[inst].childVariables[index].hash.id;
assert(id);
game::MakeVariableExternal(&game::gScrVarGlob[inst].parentVariables[parentId + 1], inst, index);
game::FreeChildValue(id, inst, parentId);
}
VariableStackBuffer* GetRefVariableStackBuffer(scriptInstance_t inst, int id)
{
return codsrc::GetRefVariableStackBuffer(inst, id);
assert(id);
assert((id * MT_NODE_SIZE) < MT_SIZE);
return (game::VariableStackBuffer*)&game::gScrMemTreePub[inst].mt_buffer->nodes[id];
}
unsigned int GetNewVariableIndexReverseInternal(scriptInstance_t inst, unsigned int parentId, unsigned int name)
{
return codsrc::GetNewVariableIndexReverseInternal(inst, parentId, name);
assert(!game::FindVariableIndexInternal(inst, parentId, name));
return game::GetNewVariableIndexReverseInternal2(name, inst, parentId, (parentId + name) % 0xFFFD + 1);
}
unsigned int GetNewObjectVariableReverse(scriptInstance_t inst, unsigned int parentId, unsigned int id)
{
return codsrc::GetNewObjectVariableReverse(inst, parentId, id);
assert((game::gScrVarGlob[inst].parentVariables[parentId + 1].w.status & VAR_MASK) == game::VAR_ARRAY);
return game::gScrVarGlob[inst].childVariables[game::GetNewVariableIndexReverseInternal(inst, parentId, id + 0x10000)].hash.id;
}
unsigned int Scr_GetLocalVar(scriptInstance_t inst, int pos)
{
return codsrc::Scr_GetLocalVar(inst, pos);
return game::gScrVmPub[inst].localVars[-pos];
}
void Scr_EvalBoolNot(scriptInstance_t inst, VariableValue* value)
{
codsrc::Scr_EvalBoolNot(inst, value);
game::Scr_CastBool(inst, value);
if (value->type == game::VAR_INTEGER)
{
value->u.intValue = value->u.intValue == 0;
}
}
unsigned int GetInternalVariableIndex(scriptInstance_t inst, unsigned int unsignedValue)
unsigned int GetInternalVariableIndex([[maybe_unused]]scriptInstance_t inst, unsigned int unsignedValue)
{
return codsrc::GetInternalVariableIndex(inst, unsignedValue);
assert(game::IsValidArrayIndex(inst, unsignedValue));
return (unsignedValue + 0x800000) & 0xFFFFFF;
}
const char* Scr_ReadData(scriptInstance_t inst, const char** pos, unsigned int count)
const char* Scr_ReadData(scriptInstance_t, const char** pos, unsigned int count)
{
return codsrc::Scr_ReadData(inst, pos, count);
const char* result;
result = *pos;
*pos += count;
return result;
}
unsigned int Scr_GetNumParam(game::scriptInstance_t inst)
{
return game::gScrVmPub[inst].outparamcount;
}
}
+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);
}
+104
View File
@@ -0,0 +1,104 @@
#include <stdinc.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()
{
FILE* result;
*game::yy_n_chars = (*game::yy_current_buffer)->yy_n_chars;
*game::yy_c_buf_p = (*game::yy_current_buffer)->yy_buf_pos;
*game::yytext = *game::yy_c_buf_p;
result = (*game::yy_current_buffer)->yy_input_file;
*game::yyin = (*game::yy_current_buffer)->yy_input_file;
*game::yy_hold_char = *(*game::yy_c_buf_p);
return result;
}
void yy_fatal_error(const char* err)
{
game::_fprintf(game::__iob_func() + 2, "%s\n", err);
game::_exit(2);
}
void* yy_flex_realloc(void* ptr, unsigned int size)
{
return game::_realloc(ptr, size);
}
void yy_init_buffer(yy_buffer_state* b, FILE* file)
{
game::yy_flush_buffer(b);
b->yy_input_file = file;
b->yy_fill_buffer = 1;
b->yy_is_interactive = 0;
}
}
+72 -26
View File
@@ -1288,6 +1288,14 @@ namespace game
LOC_SEL_INPUT_CANCEL = 0x5,
};
enum KeyCatcherFlag_t : __int32
{
KEY_CATCHER_FLAG_CONSOLE = 0x1,
KEY_CATCHER_FLAG_LOCATION_SELECTION = 0x8,
KEY_CATCHER_FLAG_IN_POPUP = 0x10,
KEY_CATCHER_FLAG_CHAT = 0x20,
};
enum GamepadPhysicalAxis
{
GPAD_PHYSAXIS_RSTICK_X = 0x0,
@@ -1878,26 +1886,25 @@ namespace game
SPHERE_MAY_HIT_V1 = 0x3,
};
enum GamePadButton : __int32
enum GamePadButton
{
GPAD_NONE = 0x0,
GPAD_UP = 0x10000008,
GPAD_DOWN = 0x10000004,
GPAD_LEFT = 0x10000001,
GPAD_RIGHT = 0x10000002,
GPAD_UP = 0x10000001,
GPAD_DOWN = 0x10000002,
GPAD_LEFT = 0x10000004,
GPAD_RIGHT = 0x10000008,
GPAD_START = 0x10000010,
GPAD_BACK = 0x10004800,
GPAD_L3 = 0x10005000,
GPAD_R3 = 0x10004000,
GPAD_A = 0x10000800,
GPAD_B = 0x10001000,
GPAD_X = 0x10000100,
GPAD_Y = 0x10000200,
GPAD_L_SHLDR = 0x10006000,
GPAD_R_SHLDR = 0x10004400,
GPAD_L_TRIG = 0x10002000,
GPAD_R_TRIG = 0x10000400,
GPAD_HOME = 0x10008000,
GPAD_BACK = 0x10000020,
GPAD_L3 = 0x10000040,
GPAD_R3 = 0x10000080,
GPAD_A = 0x10001000,
GPAD_B = 0x10002000,
GPAD_X = 0x10004000,
GPAD_Y = 0x10008000,
GPAD_L_SHLDR = 0x10000100,
GPAD_R_SHLDR = 0x10000200,
GPAD_L_TRIG = 0x20000000,
GPAD_R_TRIG = 0x20000001,
};
enum sysEventType_t
@@ -3756,6 +3763,9 @@ namespace game
CRITSECT_SCRIPT_STRING = 0xB,
CRITSECT_MEMORY_TREE = 0xC,
CRITSECT_SYS_EVENT_QUEUE = 0xE,
CRITSECT_DXDEVICE = 0x11,
CRITSECT_DXDEVICE_GLOB = 0x12,
CRITSECT_MISSING_ASSET = 0x13,
CRITSECT_PHYSICS_UPDATE = 0x15,
CRITSECT_CINEMATIC = 0x19,
CRITSECT_CINEMATIC_TARGET_CHANGE = 0x1A,
@@ -3890,15 +3900,6 @@ namespace game
HUDELEM_UPDATE_ARCHIVAL_AND_CURRENT = 0x3,
};
enum sourceType_e
{
SOURCE_TYPE_BREAKPOINT = 0x1,
SOURCE_TYPE_CALL = 0x2,
SOURCE_TYPE_THREAD_START = 0x4,
SOURCE_TYPE_BUILTIN_CALL = 0x8,
SOURCE_TYPE_NOTIFY = 0x10,
};
enum animBodyPart_t
{
ANIM_BP_UNUSED = 0x0,
@@ -3908,6 +3909,51 @@ namespace game
NUM_ANIM_BODYPARTS = 0x4,
};
enum zone_flags_e
{
ZONE_FLAG_none = 0x0,
DB_ZONE_COMMON_LOC = 0x1,
DB_ZONE_LEVEL_LOC = 0x2,
DB_ZONE_CODE = 0x4,
DB_ZONE_COMMON = 0x8,
DB_ZONE_LEVEL = 0x10,
DB_ZONE_LOAD = 0x20,
DB_ZONE_MYCHANGES = 0x40,
ZONE_FLAG_unk3 = 0x80,
DB_ZONE_LEVELOVERLAY = 0x100, // patch, not 'so'
DB_ZONE_PATCH = 0x200,
ZONE_FLAG_unk5 = 0x400,
DB_ZONE_MOD = 0x800,
};
enum xfile_block_type_e
{
XFILE_BLOCK_TEMP = 0x0,
XFILE_BLOCK_RUNTIME = 0x1,
XFILE_BLOCK_RUNTIME_BEGIN = 0x1,
XFILE_BLOCK_LARGE_RUNTIME = 0x2,
XFILE_BLOCK_PHYSICAL_RUNTIME = 0x3,
XFILE_BLOCK_VIRTUAL = 0x4,
XFILE_BLOCK_RUNTIME_END = 0x4,
XFILE_BLOCK_LARGE = 0x5,
XFILE_BLOCK_PHYSICAL = 0x6,
MAX_XFILE_COUNT = 0x7,
};
enum dm_memory_tyep_e
{
DM_MEMORY_TEMP = 0x0,
DM_MEMORY_VIRTUAL = 0x1,
DM_MEMORY_PHYSICAL = 0x2,
};
enum phys_alloc_type_e
{
PHYS_ALLOC_LOW = 0x0,
PHYS_ALLOC_HIGH = 0x1,
PHYS_ALLOC_COUNT = 0x2,
};
#ifdef __cplusplus
}
#endif
+58
View File
@@ -188,6 +188,64 @@ namespace game
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)
{
+1
View File
@@ -10,6 +10,7 @@
#define ARRAY_COUNT(arrayn) \
((sizeof(arrayn)) / (sizeof(arrayn[0])))
namespace game
{
enum gamemode
+218 -82
View File
@@ -3604,17 +3604,6 @@ namespace game
ASSERT_STRUCT_OFFSET(TLSData_t, field_38, 0x38);
ASSERT_STRUCT_OFFSET(TLSData_t, field_3C, 0x3C);
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);
union DvarValue
{
bool enabled; //OFS: 0x0 SIZE: 0x1
@@ -6962,25 +6951,6 @@ namespace game
ASSERT_STRUCT_OFFSET(pointtrace_t, bLocational, 0x38);
ASSERT_STRUCT_OFFSET(pointtrace_t, priorityMap, 0x3C);
struct field_t
{
int cursor; //OFS: 0x0 SIZE: 0x4
int scroll; //OFS: 0x4 SIZE: 0x4
int drawWidth; //OFS: 0x8 SIZE: 0x4
int widthInPixels; //OFS: 0xC SIZE: 0x4
float charHeight; //OFS: 0x10 SIZE: 0x4
int fixedSize; //OFS: 0x14 SIZE: 0x4
char buffer[256]; //OFS: 0x18 SIZE: 0x100
};
ASSERT_STRUCT_SIZE(field_t, 0x118);
ASSERT_STRUCT_OFFSET(field_t, cursor, 0x0);
ASSERT_STRUCT_OFFSET(field_t, scroll, 0x4);
ASSERT_STRUCT_OFFSET(field_t, drawWidth, 0x8);
ASSERT_STRUCT_OFFSET(field_t, widthInPixels, 0xC);
ASSERT_STRUCT_OFFSET(field_t, charHeight, 0x10);
ASSERT_STRUCT_OFFSET(field_t, fixedSize, 0x14);
ASSERT_STRUCT_OFFSET(field_t, buffer, 0x18);
struct entityHandler_t
{
void (__cdecl *think)(gentity_s *); //OFS: 0x0 SIZE: 0x4
@@ -7122,19 +7092,6 @@ namespace game
ASSERT_STRUCT_OFFSET(CmdText, maxsize, 0x4);
ASSERT_STRUCT_OFFSET(CmdText, cmdsize, 0x8);
struct Console
{
_BYTE gap_0[66120]; //OFS: 0x0 SIZE: 0x10248
char outputVisible; //OFS: 0x10248 SIZE: 0x1
_BYTE gap_10249[18563]; //OFS: 0x10249 SIZE: 0x4883
int field_14ACC; //OFS: 0x14ACC SIZE: 0x4
};
ASSERT_STRUCT_SIZE(Console, 0x14AD0);
ASSERT_STRUCT_OFFSET(Console, gap_0, 0x0);
ASSERT_STRUCT_OFFSET(Console, outputVisible, 0x10248);
ASSERT_STRUCT_OFFSET(Console, gap_10249, 0x10249);
ASSERT_STRUCT_OFFSET(Console, field_14ACC, 0x14ACC);
struct vehicle_field_s
{
const char * name; //OFS: 0x0 SIZE: 0x4
@@ -7192,24 +7149,172 @@ namespace game
ASSERT_STRUCT_OFFSET(KeyState, binding, 0x8);
ASSERT_STRUCT_OFFSET(KeyState, binding_2, 0xC);
struct field_t
{
int cursor; //OFS: 0x0 SIZE: 0x4
int scroll; //OFS: 0x4 SIZE: 0x4
int drawWidth; //OFS: 0x8 SIZE: 0x4
int widthInPixels; //OFS: 0xC SIZE: 0x4
float charHeight; //OFS: 0x10 SIZE: 0x4
int fixedSize; //OFS: 0x14 SIZE: 0x4
char buffer[256]; //OFS: 0x18 SIZE: 0x100
};
ASSERT_STRUCT_SIZE(field_t, 0x118);
ASSERT_STRUCT_OFFSET(field_t, cursor, 0x0);
ASSERT_STRUCT_OFFSET(field_t, scroll, 0x4);
ASSERT_STRUCT_OFFSET(field_t, drawWidth, 0x8);
ASSERT_STRUCT_OFFSET(field_t, widthInPixels, 0xC);
ASSERT_STRUCT_OFFSET(field_t, charHeight, 0x10);
ASSERT_STRUCT_OFFSET(field_t, fixedSize, 0x14);
ASSERT_STRUCT_OFFSET(field_t, buffer, 0x18);
struct PlayerKeyState
{
int chat_team; //OFS: 0x0 SIZE: 0x4
_BYTE gap_4[4]; //OFS: 0x4 SIZE: 0x4
int anyKeyDown; //OFS: 0x8 SIZE: 0x4
KeyState keys[256]; //OFS: 0xC SIZE: 0x1000
LocSelInputState locSelInputState; //OFS: 0x100C SIZE: 0x4
field_t chatField; //OFS: 0x0 SIZE: 0x118
int chat_team; //OFS: 0x118 SIZE: 0x4
int overstrikeMode; //OFS: 0x11C SIZE: 0x4
int anyKeyDown; //OFS: 0x120 SIZE: 0x4
KeyState keys[256]; //OFS: 0x124 SIZE: 0x1000
LocSelInputState locSelInputState; //OFS: 0x1124 SIZE: 0x4
};
ASSERT_STRUCT_SIZE(PlayerKeyState, 0x1010);
ASSERT_STRUCT_OFFSET(PlayerKeyState, chat_team, 0x0);
ASSERT_STRUCT_OFFSET(PlayerKeyState, gap_4, 0x4);
ASSERT_STRUCT_OFFSET(PlayerKeyState, anyKeyDown, 0x8);
ASSERT_STRUCT_OFFSET(PlayerKeyState, keys, 0xC);
ASSERT_STRUCT_OFFSET(PlayerKeyState, locSelInputState, 0x100C);
ASSERT_STRUCT_SIZE(PlayerKeyState, 0x1128);
ASSERT_STRUCT_OFFSET(PlayerKeyState, chatField, 0x0);
ASSERT_STRUCT_OFFSET(PlayerKeyState, chat_team, 0x118);
ASSERT_STRUCT_OFFSET(PlayerKeyState, overstrikeMode, 0x11C);
ASSERT_STRUCT_OFFSET(PlayerKeyState, anyKeyDown, 0x120);
ASSERT_STRUCT_OFFSET(PlayerKeyState, keys, 0x124);
ASSERT_STRUCT_OFFSET(PlayerKeyState, locSelInputState, 0x1124);
struct MessageLine
{
int messageIndex; //OFS: 0x0 SIZE: 0x4
int textBufPos; //OFS: 0x4 SIZE: 0x4
int textBufSize; //OFS: 0x8 SIZE: 0x4
int typingStartTime; //OFS: 0xC SIZE: 0x4
int lastTypingSoundTime; //OFS: 0x10 SIZE: 0x4
int flags; //OFS: 0x14 SIZE: 0x4
};
ASSERT_STRUCT_SIZE(MessageLine, 0x18);
ASSERT_STRUCT_OFFSET(MessageLine, messageIndex, 0x0);
ASSERT_STRUCT_OFFSET(MessageLine, textBufPos, 0x4);
ASSERT_STRUCT_OFFSET(MessageLine, textBufSize, 0x8);
ASSERT_STRUCT_OFFSET(MessageLine, typingStartTime, 0xC);
ASSERT_STRUCT_OFFSET(MessageLine, lastTypingSoundTime, 0x10);
ASSERT_STRUCT_OFFSET(MessageLine, flags, 0x14);
struct Message
{
int startTime; //OFS: 0x0 SIZE: 0x4
int endTime; //OFS: 0x4 SIZE: 0x4
};
ASSERT_STRUCT_SIZE(Message, 0x8);
ASSERT_STRUCT_OFFSET(Message, startTime, 0x0);
ASSERT_STRUCT_OFFSET(Message, endTime, 0x4);
struct MessageWindow
{
MessageLine* lines; //OFS: 0x0 SIZE: 0x4
Message* messages; //OFS: 0x4 SIZE: 0x4
char* circularTextBuffer; //OFS: 0x8 SIZE: 0x4
int textBufSize; //OFS: 0xC SIZE: 0x4
int lineCount; //OFS: 0x10 SIZE: 0x4
int padding; //OFS: 0x14 SIZE: 0x4
int scrollTime; //OFS: 0x18 SIZE: 0x4
int fadeIn; //OFS: 0x1C SIZE: 0x4
int fadeOut; //OFS: 0x20 SIZE: 0x4
int textBufPos; //OFS: 0x24 SIZE: 0x4
int firstLineIndex; //OFS: 0x28 SIZE: 0x4
int activeLineCount; //OFS: 0x2C SIZE: 0x4
int messageIndex; //OFS: 0x30 SIZE: 0x4
};
ASSERT_STRUCT_SIZE(MessageWindow, 0x34);
ASSERT_STRUCT_OFFSET(MessageWindow, lines, 0x0);
ASSERT_STRUCT_OFFSET(MessageWindow, messages, 0x4);
ASSERT_STRUCT_OFFSET(MessageWindow, circularTextBuffer, 0x8);
ASSERT_STRUCT_OFFSET(MessageWindow, textBufSize, 0xC);
ASSERT_STRUCT_OFFSET(MessageWindow, lineCount, 0x10);
ASSERT_STRUCT_OFFSET(MessageWindow, padding, 0x14);
ASSERT_STRUCT_OFFSET(MessageWindow, scrollTime, 0x18);
ASSERT_STRUCT_OFFSET(MessageWindow, fadeIn, 0x1C);
ASSERT_STRUCT_OFFSET(MessageWindow, fadeOut, 0x20);
ASSERT_STRUCT_OFFSET(MessageWindow, textBufPos, 0x24);
ASSERT_STRUCT_OFFSET(MessageWindow, firstLineIndex, 0x28);
ASSERT_STRUCT_OFFSET(MessageWindow, activeLineCount, 0x2C);
ASSERT_STRUCT_OFFSET(MessageWindow, messageIndex, 0x30);
struct MessageBuffer
{
char gamemsgText[4][2048]; //OFS: 0x0 SIZE: 0x2000
MessageWindow gamemsgWindows[4]; //OFS: 0x2000 SIZE: 0xD0
MessageLine gamemsgLines[4][12]; //OFS: 0x20D0 SIZE: 0x480
Message gamemsgMessages[4][12]; //OFS: 0x2550 SIZE: 0x180
char miniconText[4096]; //OFS: 0x26D0 SIZE: 0x1000
MessageWindow miniconWindow; //OFS: 0x36D0 SIZE: 0x34
MessageLine miniconLines[100]; //OFS: 0x3704 SIZE: 0x960
Message miniconMessages[100]; //OFS: 0x4064 SIZE: 0x320
char errorText[1024]; //OFS: 0x4384 SIZE: 0x400
MessageWindow errorWindow; //OFS: 0x4784 SIZE: 0x34
MessageLine errorLines[5]; //OFS: 0x47B8 SIZE: 0x78
Message errorMessages[5]; //OFS: 0x4830 SIZE: 0x28
};
ASSERT_STRUCT_SIZE(MessageBuffer, 0x4858);
ASSERT_STRUCT_OFFSET(MessageBuffer, gamemsgText, 0x0);
ASSERT_STRUCT_OFFSET(MessageBuffer, gamemsgWindows, 0x2000);
ASSERT_STRUCT_OFFSET(MessageBuffer, gamemsgLines, 0x20D0);
ASSERT_STRUCT_OFFSET(MessageBuffer, gamemsgMessages, 0x2550);
ASSERT_STRUCT_OFFSET(MessageBuffer, miniconText, 0x26D0);
ASSERT_STRUCT_OFFSET(MessageBuffer, miniconWindow, 0x36D0);
ASSERT_STRUCT_OFFSET(MessageBuffer, miniconLines, 0x3704);
ASSERT_STRUCT_OFFSET(MessageBuffer, miniconMessages, 0x4064);
ASSERT_STRUCT_OFFSET(MessageBuffer, errorText, 0x4384);
ASSERT_STRUCT_OFFSET(MessageBuffer, errorWindow, 0x4784);
ASSERT_STRUCT_OFFSET(MessageBuffer, errorLines, 0x47B8);
ASSERT_STRUCT_OFFSET(MessageBuffer, errorMessages, 0x4830);
struct Console
{
dvar_s* outputWindowColor; //OFS: 0x0 SIZE: 0x4
int initialized; //OFS: 0x4 SIZE: 0x4
MessageWindow consoleWindow; //OFS: 0x8 SIZE: 0x34
MessageLine consoleLines[1024]; //OFS: 0x3C SIZE: 0x6000
Message consoleMessages[1024]; //OFS: 0x603C SIZE: 0x2000
char consoleText[32768]; //OFS: 0x803C SIZE: 0x8000
char textTempLine[512]; //OFS: 0x1003C SIZE: 0x200
unsigned int lineOffset; //OFS: 0x1023C SIZE: 0x4
int displayLineOffset; //OFS: 0x10240 SIZE: 0x4
int prevChannel; //OFS: 0x10244 SIZE: 0x4
char outputVisible; //OFS: 0x10248 SIZE: 0x1
int fontHeight; //OFS: 0x1024C SIZE: 0x4
int visibleLineCount; //OFS: 0x10250 SIZE: 0x4
int visiblePixelWidth; //OFS: 0x10254 SIZE: 0x4
float screenMin[2]; //OFS: 0x10258 SIZE: 0x8
float screenMax[2]; //OFS: 0x10260 SIZE: 0x8
MessageBuffer messageBuffer[1]; //OFS: 0x10268 SIZE: 0x4858
float color[4]; //OFS: 0x14AC0 SIZE: 0x10
};
ASSERT_STRUCT_SIZE(Console, 0x14AD0);
ASSERT_STRUCT_OFFSET(Console, outputWindowColor, 0x0);
ASSERT_STRUCT_OFFSET(Console, initialized, 0x4);
ASSERT_STRUCT_OFFSET(Console, consoleWindow, 0x8);
ASSERT_STRUCT_OFFSET(Console, consoleLines, 0x3C);
ASSERT_STRUCT_OFFSET(Console, consoleMessages, 0x603C);
ASSERT_STRUCT_OFFSET(Console, consoleText, 0x803C);
ASSERT_STRUCT_OFFSET(Console, textTempLine, 0x1003C);
ASSERT_STRUCT_OFFSET(Console, lineOffset, 0x1023C);
ASSERT_STRUCT_OFFSET(Console, displayLineOffset, 0x10240);
ASSERT_STRUCT_OFFSET(Console, prevChannel, 0x10244);
ASSERT_STRUCT_OFFSET(Console, outputVisible, 0x10248);
ASSERT_STRUCT_OFFSET(Console, fontHeight, 0x1024C);
ASSERT_STRUCT_OFFSET(Console, visibleLineCount, 0x10250);
ASSERT_STRUCT_OFFSET(Console, visiblePixelWidth, 0x10254);
ASSERT_STRUCT_OFFSET(Console, screenMin, 0x10258);
ASSERT_STRUCT_OFFSET(Console, screenMax, 0x10260);
ASSERT_STRUCT_OFFSET(Console, messageBuffer, 0x10268);
ASSERT_STRUCT_OFFSET(Console, color, 0x14AC0);
union qfile_gus
{
_iobuf * o; //OFS: 0x0 SIZE: 0x4
FILE * o; //OFS: 0x0 SIZE: 0x4
char * z; //OFS: 0x1 SIZE: 0x4
};
ASSERT_STRUCT_SIZE(qfile_gus, 0x4);
@@ -11291,17 +11396,6 @@ namespace game
ASSERT_STRUCT_OFFSET(LargeLocal, startPos, 0x0);
ASSERT_STRUCT_OFFSET(LargeLocal, size, 0x4);
struct XFile
{
unsigned int size; //OFS: 0x0 SIZE: 0x4
unsigned int externalSize; //OFS: 0x4 SIZE: 0x4
unsigned int blockSize[8]; //OFS: 0x8 SIZE: 0x20
};
ASSERT_STRUCT_SIZE(XFile, 0x28);
ASSERT_STRUCT_OFFSET(XFile, size, 0x0);
ASSERT_STRUCT_OFFSET(XFile, externalSize, 0x4);
ASSERT_STRUCT_OFFSET(XFile, blockSize, 0x8);
union pointtrace_or_moveclip_u
{
pointtrace_t point; //OFS: 0x0 SIZE: 0x40
@@ -12661,21 +12755,6 @@ namespace game
ASSERT_STRUCT_OFFSET(GfxCmdStretchPicRotateXY, color, 0x28);
ASSERT_STRUCT_OFFSET(GfxCmdStretchPicRotateXY, rotation, 0x2C);
struct XZoneMemory
{
XBlock blocks[9]; //OFS: 0x0 SIZE: 0x48
char * lockedVertexData; //OFS: 0x48 SIZE: 0x4
char * lockedIndexData; //OFS: 0x4C SIZE: 0x4
void * vertexBuffer; //OFS: 0x50 SIZE: 0x4
void * indexBuffer; //OFS: 0x54 SIZE: 0x4
};
ASSERT_STRUCT_SIZE(XZoneMemory, 0x58);
ASSERT_STRUCT_OFFSET(XZoneMemory, blocks, 0x0);
ASSERT_STRUCT_OFFSET(XZoneMemory, lockedVertexData, 0x48);
ASSERT_STRUCT_OFFSET(XZoneMemory, lockedIndexData, 0x4C);
ASSERT_STRUCT_OFFSET(XZoneMemory, vertexBuffer, 0x50);
ASSERT_STRUCT_OFFSET(XZoneMemory, indexBuffer, 0x54);
struct SaveMemoryGlob
{
SaveGame * committedGameSave; //OFS: 0x0 SIZE: 0x4
@@ -12712,7 +12791,7 @@ namespace game
unsigned int pos_local_extrafield; //OFS: 0x48 SIZE: 0x4
unsigned int rest_read_compressed; //OFS: 0x4C SIZE: 0x4
unsigned int rest_read_uncompressed; //OFS: 0x50 SIZE: 0x4
_iobuf * file; //OFS: 0x54 SIZE: 0x4
FILE * file; //OFS: 0x54 SIZE: 0x4
unsigned int compression_method; //OFS: 0x58 SIZE: 0x4
unsigned int byte_before_the_zipfile; //OFS: 0x5C SIZE: 0x4
};
@@ -13208,7 +13287,64 @@ namespace game
ASSERT_STRUCT_OFFSET(DynEnt_FadeData, id, 0x0);
ASSERT_STRUCT_OFFSET(DynEnt_FadeData, startTime, 0x4);
struct __declspec(align(2)) GfxMetrics
{
unsigned __int16 cubemapShotRes;
unsigned __int16 cubemapShotPixelBorder;
bool hasAnisotropicMinFilter;
bool hasAnisotropicMagFilter;
int maxAnisotropy;
int maxClipPlanes;
unsigned __int8 shadowmapSamplerState;
bool slopeScaleDepthBias;
bool canMipCubemaps;
};
// cCurve
struct CommonFastFileLoad
{
int code_post_gfx_flags;
int patch_flags;
int ui_flags;
int common_flags;
int flags5;
int localized_common_flags;
const char *code_post_gfx;
const char *patch;
const char *ui;
const char *common;
int filename4;
const char *localized_common;
const char *mod;
};
struct GfxWindowParms
{
HWND__ *hwnd;
int hz;
bool fullscreen;
int x;
int y;
int sceneWidth;
int sceneHeight;
int displayWidth;
int displayHeight;
int aaSamples;
};
struct stream_source_info_t
{
char Stream;
char Offset;
char Type;
};
struct stream_dest_info_t
{
char Usage;
char UsageIndex;
};
#ifdef __cplusplus
}
+30 -4
View File
@@ -28,6 +28,19 @@ namespace game
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());
@@ -55,9 +68,19 @@ namespace game
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 };
@@ -69,11 +92,10 @@ namespace game
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};
@@ -83,7 +105,11 @@ namespace game
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 };
}
+56
View File
@@ -0,0 +1,56 @@
#include <stdinc.hpp>
#include <utils/hook.hpp>
#include "loader/component_loader.hpp"
namespace plugin
{
std::uint32_t plugin::plugin_version()
{
return 1;
}
const char* plugin::plugin_name()
{
return "t4sp-server-plugin";
}
bool plugin::is_game_supported(plutonium::sdk::game game)
{
return game == plutonium::sdk::game::t4;
}
void plugin::on_startup(plutonium::sdk::iinterface* interface_ptr, plutonium::sdk::game game)
{
this->interface_ = interface_ptr;
this->game_ = game;
if (!game::environment::t4sp())
{
MessageBoxA(nullptr, "Unsupported game executable. (t4sp is only supported)", "ERROR, BRO!", 0);
return;
}
component_loader::post_unpack();
}
void plugin::on_shutdown()
{
}
plutonium::sdk::iinterface* plugin::get_interface()
{
return this->interface_;
}
plutonium::sdk::game plugin::get_game()
{
return this->game_;
}
plugin* get()
{
static plugin instance;
return &instance;
}
}
+30
View File
@@ -0,0 +1,30 @@
#pragma once
#include <plutonium_sdk.hpp>
namespace plugin
{
class plugin : public plutonium::sdk::plugin
{
public:
~plugin() = default;
std::uint32_t plugin_version() override;
const char* plugin_name() override;
bool is_game_supported(plutonium::sdk::game game) override;
void on_startup(plutonium::sdk::iinterface* interface_ptr, plutonium::sdk::game game) override;
void on_shutdown() override;
plutonium::sdk::iinterface* get_interface();
plutonium::sdk::game get_game();
private:
plutonium::sdk::iinterface* interface_{};
plutonium::sdk::game game_{};
};
plugin* get();
}
+10
View File
@@ -10,6 +10,7 @@
#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)
@@ -61,6 +62,7 @@
#pragma comment(lib, "Winmm.lib")
#include "utils/hexrays_defs.h"
#include "utils/io.hpp"
#undef GetObject
@@ -69,4 +71,12 @@
#include "game/structs.hpp"
#include "game/symbols.hpp"
#include "plugin.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;
+10 -3
View File
@@ -97,8 +97,15 @@ namespace utils::hook
MH_DisableHook(this->place_);
}
void detour::create(void* place, void* target)
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;
@@ -110,9 +117,9 @@ namespace utils::hook
this->enable();
}
void detour::create(const size_t place, void* target)
void detour::create(const size_t place, void* target, bool quick)
{
this->create(reinterpret_cast<void*>(place), target);
this->create(reinterpret_cast<void*>(place), target, quick);
}
void detour::clear()
+2 -2
View File
@@ -86,8 +86,8 @@ namespace utils::hook
void enable() const;
void disable() const;
void create(void* place, void* target);
void create(size_t place, void* target);
void create(void* place, void* target, bool quick = false);
void create(size_t place, void* target, bool quick = false);
void clear();
template <typename T>