Skip to content

Commit efb0444

Browse files
committed
feat(scripting/server): IsMapValid
1 parent 3765437 commit efb0444

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

plugin_files/scripting/includes/swiftly/server.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ class Server
3838
this->ExecuteCommand("changelevel %s", map);
3939
}
4040

41+
bool IsMapValid(const char *map)
42+
{
43+
void *IsMapValidFunc = FetchFunctionPtr(nullptr, "scripting_Server_IsMapValid");
44+
if (IsMapValidFunc)
45+
return reinterpret_cast<Server_IsMapValid>(IsMapValidFunc)(map);
46+
else
47+
return false;
48+
}
49+
4150
const char *GetMap()
4251
{
4352
void *GetMapFunc = FetchFunctionPtr(nullptr, "scripting_Server_GetMapName");

plugin_files/scripting/includes/swiftly/swiftly_memory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ typedef void (*Logger_WriteLog)(const char *, ELogType, const char *);
5454
typedef void (*Server_ExecuteCommand)(const char *);
5555
typedef const char *(*Server_GetMap)();
5656
typedef uint16_t (*Server_GetMaxPlayers)();
57+
typedef bool (*Server_IsMapValid)(const char *);
5758

5859
void *FetchFunctionPtr(const char *filePath, const char *function_name);
5960

src/components/Plugins/src/scripting/Server.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,12 @@ SMM_API const char *scripting_Server_GetMapName()
2020
char *res = new char[strlen(mapname) + 1];
2121
strcpy(res, mapname);
2222
return res;
23+
}
24+
25+
SMM_API bool scripting_Server_IsMapValid(const char *map)
26+
{
27+
if (map == nullptr)
28+
return false;
29+
30+
return (engine->IsMapValid(map) == 1);
2331
}

0 commit comments

Comments
 (0)