Skip to content

Commit a49f60f

Browse files
committed
Add ModLoader::getVersion
1 parent 36004c4 commit a49f60f

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ project(server_modloader)
44
set(CMAKE_CXX_STANDARD 11)
55
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
66

7+
set(MODLOADER_VERSION "Preview 1")
8+
79
add_subdirectory(dep/funchook)
810

911
include_directories(include/)
1012
add_library(server_modloader SHARED include/modloader/hook.h include/modloader/statichook.h include/modloader/log.h
1113
include/modloader/loader.h
1214
src/hook.cpp src/log.cpp src/loader.h src/loader.cpp src/elf_helper.cpp src/elf_helper.h src/main.cpp)
13-
target_link_libraries(server_modloader funchook)
15+
target_link_libraries(server_modloader funchook)
16+
target_compile_definitions(server_modloader PRIVATE MODLOADER_VERSION="${MODLOADER_VERSION}")

include/modloader/loader.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
extern "C" {
66
#endif
77

8+
const char *modloader_version();
9+
810
typedef void (*modloader_foreach_fn)(void *handle, void *userdata);
911

1012
void modloader_add_lib_search_path(const char* path);
@@ -31,6 +33,8 @@ namespace modloader {
3133
class ModLoader {
3234

3335
public:
36+
static const char *getVersion();
37+
3438
static void addLibSearchDir(std::string const& path);
3539

3640
static void *loadMod(std::string const& path);

src/loader.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ static ModLoaderImpl loaderImpl;
1414

1515
extern "C" {
1616

17+
const char *modloader_version() {
18+
return ModLoader::getVersion();
19+
}
20+
1721
void modloader_add_lib_search_path(const char* path) {
1822
loaderImpl.addLibSearchDir(path);
1923
}
@@ -33,6 +37,10 @@ void modloader_iterate_mods(modloader_foreach_fn cb, void* userdata) {
3337

3438
}
3539

40+
const char *ModLoader::getVersion() {
41+
return MODLOADER_VERSION;
42+
}
43+
3644
void ModLoader::addLibSearchDir(std::string const &path) {
3745
loaderImpl.addLibSearchDir(path);
3846
}

0 commit comments

Comments
 (0)