40 Commits

Author SHA1 Message Date
3bf55873ed Bump deps/json from a259ecc to 0457de2
Bumps [deps/json](https://github.com/nlohmann/json) from `a259ecc` to `0457de2`.
- [Release notes](https://github.com/nlohmann/json/releases)
- [Commits](a259ecc51e...0457de21cf)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-29 07:42:25 +00:00
38a860e4ce Merge branch 'main' of https://github.com/JezuzLizard/T4SP-Server-Plugin 2023-12-15 15:05:41 -06:00
3995bed200 update 2023-12-15 15:05:36 -06:00
3502a70933 Update README.md 2023-12-15 15:03:41 -06:00
1a33de617d Copy fix from cod2rev 2023-12-15 12:40:46 -06:00
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
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
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](1e4cd51935...78a1814b33)

---
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
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](3780b41dd0...a259ecc51e)

---
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
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
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
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](02d81c5a68...1e4cd51935)

---
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
bafc637be8 Bump deps/asmjit from 1a81158 to 416f735
Bumps [deps/asmjit](https://github.com/asmjit/asmjit) from `1a81158` to `416f735`.
- [Commits](1a81158e8b...416f735696)

---
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
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
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
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](f899e91431...02d81c5a68)

---
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
944bab5e5c Bump deps/asmjit from 6a13a93 to 1a81158
Bumps [deps/asmjit](https://github.com/asmjit/asmjit) from `6a13a93` to `1a81158`.
- [Commits](6a13a935d1...1a81158e8b)

---
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
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
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
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
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
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
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
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
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
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](4528690cd5...f899e91431)

---
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
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](546370c9e7...3780b41dd0)

---
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
df9ef00a64 Bump deps/asmjit from f1ea8a4 to 6a13a93
Bumps [deps/asmjit](https://github.com/asmjit/asmjit) from `f1ea8a4` to `6a13a93`.
- [Commits](f1ea8a46c3...6a13a935d1)

---
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
1f0717edef fix double slashes 2023-12-03 18:13:22 -06:00
7a82be782d update count 2023-12-03 17:53:21 -06:00
f0c95340bf Fixed up the builtin 2023-12-03 17:43:40 -06:00
4843c61e2e Merge branch 'main' of https://github.com/JezuzLizard/T4SP-Server-Plugin 2023-12-03 17:19:00 -06:00
b79b776f63 add fs_listfiles 2023-12-03 17:18:54 -06:00
d1a0277861 Update README.md 2023-12-03 15:35:03 -06:00
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
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](49d03ad118...f5485b8454)

---
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
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](04f42ceca4...643e17b749)

---
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
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](43d60c5e38...e64c97fc2c)

---
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
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](b96e96cf8b...7e863d2142)

---
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
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](7f96509df1...8314bde5e5)

---
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
13 changed files with 76 additions and 19 deletions

View File

@ -58,8 +58,8 @@ All files will be closed upon GSC restart (map_restart or fast_restart or missio
``` ```
* `<string> FS_ReadLine(<filehandle int>)` Reads a line from the file pointed by the filehandle, removes the newline char. Returns `undefined` when nothing is left to read. Will not read more than 8192 characters at once. Filehandle must be opened for reading. * `<string> FS_ReadLine(<filehandle int>)` Reads a line from the file pointed by the filehandle, removes the newline char. Returns `undefined` when nothing is left to read. Will not read more than 65536 characters at once. Filehandle must be opened for reading.
* `<string> FS_Read(<filehandle int>, <bytes int>(optional))` Reads number of bytes from the file. If bytes is `undefined`, reads the entire file. No more than 8192 characters will be read at once. Returns `undefined` if there are nothing left to read. * `<string> FS_Read(<filehandle int>, <bytes int>(optional))` Reads number of bytes from the file. If bytes is `undefined`, reads the entire file. No more than 65536 characters will be read at once. Returns `undefined` if there are nothing left to read.
```gsc ```gsc
// open the file for reading // open the file for reading
@ -89,6 +89,20 @@ All files will be closed upon GSC restart (map_restart or fast_restart or missio
// close the file // close the file
``` ```
* `<array of strings> FS_ListFiles(<folder string>)` Returns a list of files inside of the folder given.
```gsc
folder = "testfolder/";
files = FS_ListFiles(folder);
for (i = 0; i < files.size; i++)
{
filename = files[i];
// do something with the filename
filepath = folder + filename;
}
```
# Installation # 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\storage\t4\plugins\`, the plugin will be loaded when you start up a dedicated server for Plutonium T4SP.

2
deps/GSL vendored

Submodule deps/GSL updated: 43d60c5e38...e64c97fc2c

2
deps/asmjit vendored

2
deps/curl vendored

Submodule deps/curl updated: 4528690cd5...78a1814b33

2
deps/json vendored

Submodule deps/json updated: 546370c9e7...0457de21cf

2
deps/minhook vendored

2
deps/zlib vendored

Submodule deps/zlib updated: 04f42ceca4...643e17b749

View File

@ -67,11 +67,18 @@ namespace codsrc
{ {
int len; int len;
for ( len = refString->u.s.byteLen - 1; if (!refString->u.s.byteLen)
refString->str[len];
len += 256 )
{ {
; 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; return len;

View File

@ -10,6 +10,7 @@ namespace fileio
namespace namespace
{ {
static constexpr size_t max_fhs = 10; static constexpr size_t max_fhs = 10;
static constexpr size_t max_gsc_string = 0x10000 - 1;
enum class scr_fh_type_e enum class scr_fh_type_e
{ {
@ -35,7 +36,7 @@ namespace fileio
{ {
if (fpath.empty()) if (fpath.empty())
{ {
return false; return true;
} }
constexpr static std::array bad_strings { R"(..)", R"(../)", R"(..\)" }; constexpr static std::array bad_strings { R"(..)", R"(../)", R"(..\)" };
@ -293,10 +294,10 @@ namespace fileio
} }
} }
if (bytes_to_read > 8191) if (bytes_to_read > max_gsc_string)
{ {
found_nl = false; found_nl = false;
bytes_to_read = 8191; bytes_to_read = max_gsc_string;
game::Com_PrintWarning(game::CON_CHANNEL_SCRIPT, "Line was too long in file %s, truncating\n", scr_fhs[fh].base_path.c_str()); game::Com_PrintWarning(game::CON_CHANNEL_SCRIPT, "Line was too long in file %s, truncating\n", scr_fhs[fh].base_path.c_str());
} }
@ -348,9 +349,9 @@ namespace fileio
} }
} }
if (bytes_to_read > 8191) if (bytes_to_read > max_gsc_string)
{ {
bytes_to_read = 8191; bytes_to_read = max_gsc_string;
game::Com_PrintWarning(game::CON_CHANNEL_SCRIPT, "Line was too long in file %s, truncating\n", scr_fhs[fh].base_path.c_str()); game::Com_PrintWarning(game::CON_CHANNEL_SCRIPT, "Line was too long in file %s, truncating\n", scr_fhs[fh].base_path.c_str());
} }
@ -400,6 +401,23 @@ namespace fileio
game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 1); game::Scr_AddInt(game::SCRIPTINSTANCE_SERVER, 1);
}); });
gsc::function::add("fs_listfiles", []()
{
auto fpath = build_base_path(game::Scr_GetString(0, game::SCRIPTINSTANCE_SERVER));
int numfiles;
auto* files = game::FS_ListFiles(fpath.c_str(), "", game::FS_LIST_ALL, &numfiles);
game::Scr_MakeArray(game::SCRIPTINSTANCE_SERVER);
for (int i = 0; i < numfiles; i++)
{
game::Scr_AddString(game::SCRIPTINSTANCE_SERVER, files[i]);
game::Scr_AddArray(game::SCRIPTINSTANCE_SERVER);
}
game::FS_FreeFileList(files);
});
} }
} }

View File

@ -231,6 +231,21 @@ namespace game
*cmd_functions = newCmd; *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 // restored
void Sys_EnterCriticalSection(CriticalSection critSect) void Sys_EnterCriticalSection(CriticalSection critSect)
{ {

View File

@ -78,6 +78,9 @@ namespace game
void Sys_EnterCriticalSection(CriticalSection critSect); void Sys_EnterCriticalSection(CriticalSection critSect);
void Sys_LeaveCriticalSection(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 // Variables
WEAK symbol<CRITICAL_SECTION> s_criticalSection{ 0x0, 0x2298D08 }; WEAK symbol<CRITICAL_SECTION> s_criticalSection{ 0x0, 0x2298D08 };
WEAK symbol<HunkUser*> g_DebugHunkUser{ 0x0, 0x212B2EC }; WEAK symbol<HunkUser*> g_DebugHunkUser{ 0x0, 0x212B2EC };