Skip to content

Commit

Permalink
Merge branch 'set-export' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
odorajbotoj committed Oct 12, 2024
2 parents 95fc109 + 7cd7341 commit c1d9367
Show file tree
Hide file tree
Showing 30 changed files with 3,039 additions and 2,295 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

+ Move CoralFans SimulatedPlayer System from [CoralFans](https://github.com/CoralFans-Dev/CoralFans) to here
+ Added Script Arg

[1.0.0]: https://github.com/CoralFans-Dev/CFSP/releases/tag/v1.0.0
11 changes: 9 additions & 2 deletions src/cfsp/CFSP.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "cfsp/CFSP.h"
#include "cfsp/base/Mod.h"
#include "cfsp/commands/Command.h"
#include "cfsp/simplayer/CFSP.h"
#include "cfsp/simplayer/Hooks.h"
#include "ll/api/Config.h"
#include "ll/api/i18n/I18n.h"
#include "ll/api/mod/RegisterHelper.h"
Expand Down Expand Up @@ -42,6 +44,8 @@ bool CFSP::load() {
bool CFSP::enable() {
auto& mod = coral_fans::cfsp::mod();

hookSimPlayer(true);

// get DefaultDataLoadHelper
mod.getDefaultDataLoadHelper() =
static_cast<DefaultDataLoadHelper*>(ll::memory::resolveSymbol("??_7DefaultDataLoadHelper@@6B@"));
Expand All @@ -53,12 +57,15 @@ bool CFSP::enable() {
if (mod.getConfig().command.sp.enabled) commands::registerSpCommand(mod.getConfig().command.sp.permission);

// load simplayer data
mod.getSimPlayerManager().load();
SimPlayerManager::getInstance().load();

return true;
}

bool CFSP::disable() { return true; }
bool CFSP::disable() {
hookSimPlayer(false);
return true;
}

} // namespace coral_fans::cfsp

Expand Down
12 changes: 9 additions & 3 deletions src/cfsp/base/Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@
break; \
}

#ifdef CFSPEXP
#define CFSP_API __declspec(dllexport)
#else
#define CFSP_API __declspec(dllimport)
#endif

// SimPlayer reg def
#define SP_REG_DEF(NAME, ...) \
std::pair<std::string, bool> simPlayer##NAME(Player*, std::string const&, bool, __VA_ARGS__); \
std::pair<std::string, bool> group##NAME(Player*, std::string const&, __VA_ARGS__);
CFSP_API std::pair<std::string, bool> simPlayer##NAME(Player*, std::string const&, bool, __VA_ARGS__); \
CFSP_API std::pair<std::string, bool> group##NAME(Player*, std::string const&, __VA_ARGS__);

// SimPlayer def with arg
#define SP_DEF_WA(NAME, ACTION, ARG_TYPE) \
Expand Down Expand Up @@ -192,7 +198,7 @@
return {"translate.simplayer.success"_tr(), true}; \
}

#define LUAAPI(name) static int lua_api_##name(lua_State* L)
#define LUAAPI(name) int lua_api_##name(lua_State* L)

#define LUA_ARG_COUNT_CHECK_C(i) \
if (lua_gettop(L) != (i)) return luaL_error(L, "%d args expected", (i));
Expand Down
9 changes: 0 additions & 9 deletions src/cfsp/base/Mod.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include "cfsp/Config.h"
#include "cfsp/simplayer/CFSP.h"
#include "mc/dataloadhelper/DefaultDataLoadHelper.h"


Expand All @@ -10,19 +9,11 @@ namespace coral_fans::cfsp {
class CFSPMod {
private:
config::Config mConfig;
SimPlayerManager mSimPlayerManager;
DefaultDataLoadHelper* mDefaultDataLoadHelper;

public:
inline config::Config& getConfig() { return this->mConfig; }
inline SimPlayerManager& getSimPlayerManager() { return this->mSimPlayerManager; }
inline DefaultDataLoadHelper*& getDefaultDataLoadHelper() { return this->mDefaultDataLoadHelper; }

public:
inline void tick() { mSimPlayerManager.tick(); }

public:
const std::string VERSION = "1.0.0";
};

CFSPMod& mod();
Expand Down
193 changes: 90 additions & 103 deletions src/cfsp/commands/Sp.cpp

Large diffs are not rendered by default.

Loading

0 comments on commit c1d9367

Please sign in to comment.