Skip to content

Commit

Permalink
Refactor: namespace LL -> ll (LiteLDev#804)
Browse files Browse the repository at this point in the history
* Refactor: namespace LL -> ll

* Update .gitignore

* Refactor: namespace PERM -> ll::perm

* Update CHANGELOG.md
  • Loading branch information
RimuruChan authored Sep 16, 2022
1 parent ef9f4f7 commit 72e3336
Show file tree
Hide file tree
Showing 65 changed files with 713 additions and 365 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

# Build related
/build
/.cache/
/out/
/cmake-build-*

**/bedrock_server_api.lib
**/bedrock_server_var.lib

# Misc
LiteLoaderSDK/
/output/
/.cache/
/out/
20 changes: 15 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
## [LiteLoader Release Note]
LiteLoaderBDS-2.6.2 update has been released, adapted to BDS-1.19.21,BDS-1.19.22, ProtocolVersion 545
<!-- Version: 2.6.3 in progress -->
# LiteLoader Release Note

## [Bug Fixes]
- Fix LLSE `NetworkAPI`
- Add Random Number Generator (#755) by @OEOTYAN
## Bug Fixes

## APIs Changed list (for developer)
**Note that APIs marked as deprecated will be removed in the next few releases.**

### File
llapi/LLAPI.h

#### Item
All item with namespace LL

#### Note
Move to namespace ll. you should recompile your plugin with latest SDK as soon as possible due to the removal of deprecated API in the future. |
6 changes: 5 additions & 1 deletion LiteLoader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ target_link_libraries(
LLPreLoader
)

target_include_directories(
LiteLoader SYSTEM
PRIVATE ${PROJECT_SOURCE_DIR}/third-party/include
)

target_include_directories(
LiteLoader
PRIVATE ${PROJECT_SOURCE_DIR}/include/
PRIVATE ${PROJECT_SOURCE_DIR}/third-party/include
PRIVATE ${CMAKE_SOURCE_DIR}
)

Expand Down
2 changes: 1 addition & 1 deletion LiteLoader/include/liteloader/AddonsHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct Addon {
std::string name;
std::string description;
Type type;
LL::Version version;
ll::Version version;
std::string uuid;
std::string directory;
bool enable = false;
Expand Down
7 changes: 4 additions & 3 deletions LiteLoader/include/liteloader/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@

/////////////////////// CrashLogger ///////////////////////
// When comes with these plugins, disable builtin CrashLogger since they will cause crash
constexpr const char* NoCrashLogger[] = {"AntiCheats"};
#define CL_PRELOG_MODULE L"plugins/LiteLoader/CrashLogger.dll"


/////////////////////// LL Configs ///////////////////////
#define LITELOADER_CONFIG_FILE "plugins/LiteLoader/LiteLoader.json"

namespace LL {
namespace ll {

constexpr const char* kNoCrashLoggerPluginList[] = {"AntiCheats"};
struct CommandLineOption {
bool noColorOption = false;
};
Expand Down Expand Up @@ -80,7 +81,7 @@ void inline from_json(const nlohmann::json& j, LLConfig& conf);
bool LoadLLConfig();

bool SaveLLConfig();
} // namespace LL
} // namespace ll

/////////////////////// Addon Helper ///////////////////////

Expand Down
4 changes: 2 additions & 2 deletions LiteLoader/include/liteloader/CrashLogger.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

namespace LL {
namespace ll {
bool StartCrashLoggerProcess();
void InitCrashLogger(bool enableCrashLogger);
} // namespace LL
} // namespace ll
6 changes: 3 additions & 3 deletions LiteLoader/include/liteloader/Loader.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <string>

namespace LL {
void LoadMain();
} // namespace LL
namespace ll {
void LoadMain();
} // namespace ll
14 changes: 7 additions & 7 deletions LiteLoader/include/liteloader/PluginManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <string>
#include <unordered_map>

namespace LL {
namespace ll {
struct Plugin;
struct Version;

Expand All @@ -13,12 +13,12 @@ class PluginManager {

public:
static LIAPI bool registerPlugin(HMODULE handle, std::string name, std::string desc,
LL::Version version, std::map<std::string, std::string> others);
ll::Version version, std::map<std::string, std::string> others);

static LIAPI LL::Plugin* getPlugin(HMODULE handle);
static LIAPI LL::Plugin* getPlugin(std::string name, bool includeScriptPlugin = true);
static LIAPI ll::Plugin* getPlugin(HMODULE handle);
static LIAPI ll::Plugin* getPlugin(std::string name, bool includeScriptPlugin = true);
static LIAPI bool hasPlugin(std::string name, bool includeScriptPlugin = true);
static LIAPI std::unordered_map<std::string, LL::Plugin*> getAllPlugins(bool includeScriptPlugin = true);
static LIAPI std::unordered_map<std::string, ll::Plugin*> getAllPlugins(bool includeScriptPlugin = true);

static bool loadPlugin(std::string pluginFilePath, bool outputStatus = false, bool isHotLoad = false);
static bool unloadPlugin(std::string pluginName, bool outputStatus = false);
Expand All @@ -27,7 +27,7 @@ class PluginManager {

static LIAPI bool unRegisterPlugin(std::string name);
};
} // namespace LL
} // namespace ll

LIAPI bool RegisterPlugin(HMODULE handle, std::string name, std::string desc, LL::Version version,
LIAPI bool RegisterPlugin(HMODULE handle, std::string name, std::string desc, ll::Version version,
std::map<std::string, std::string> others);
2 changes: 1 addition & 1 deletion LiteLoader/include/liteloader/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#define TARGET_BDS_PROTOCOL_VERSION 545

#define LITELOADER_VERSION LL::getLoaderVersion()
#define LITELOADER_VERSION ll::getLoaderVersion()


#define TO_VERSION_STRING(ver) #ver
Expand Down
4 changes: 2 additions & 2 deletions LiteLoader/include/llapi/EventAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class EventTemplate {
* @return The event listener
*/
static EventListener<EVENT> subscribe(std::function<bool(EVENT)> callback) {
auto plugin = LL::getPlugin(GetCurrentModule());
auto plugin = ll::getPlugin(GetCurrentModule());
return EventListener<EVENT>(EventManager<EVENT>::addEventListener(plugin ? plugin->name : "", callback));
}

Expand All @@ -142,7 +142,7 @@ class EventTemplate {
* @return The event listener
*/
static EventListener<EVENT> subscribe_ref(std::function<bool(EVENT&)> callback) {
auto plugin = LL::getPlugin(GetCurrentModule());
auto plugin = ll::getPlugin(GetCurrentModule());
return EventListener<EVENT>(EventManager<EVENT>::addEventListenerRef(plugin ? plugin->name : "", callback));
}

Expand Down
14 changes: 7 additions & 7 deletions LiteLoader/include/llapi/HookAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ LIAPI int HookFunction(void* oldfunc, void** poutold, void* newfunc);
LIAPI void* dlsym_real(char const* name);
}

namespace LL::Hook {
namespace ll::hook {
LIAPI uintptr_t findSig(const char* szSignature);
} // namespace LL::Hook
} // namespace ll::Hook
extern std::vector<std::string> dlsym_reverse(int addr);

template <typename RTN = void, typename... Args>
Expand Down Expand Up @@ -93,7 +93,7 @@ static __forceinline auto __imp_Call() {
}

template <FixedString Sig>
__declspec(selectany) void* __sigfind_ptr_cache = (void*)LL::Hook::findSig(Sig);
__declspec(selectany) void* __sigfind_ptr_cache = (void*)ll::hook::findSig(Sig);
template <FixedString Sig, typename ret, typename... p>
static __forceinline auto __imp_Call_Sig() {
return ((ret(*)(p...))(__sigfind_ptr_cache<Sig>));
Expand Down Expand Up @@ -228,17 +228,17 @@ extern THookRegister THookRegisterTemplate;
#define _TStaticNoDefHook(iname, sym, ret, ...) \
_TStaticHook(, iname, sym, ret, VA_EXPAND(__VA_ARGS__))

#define SHook2(iname, ret, sig, ...) _TStaticNoDefHook(iname, (void*)LL::Hook::findSig(sig), ret, VA_EXPAND(__VA_ARGS__))
#define SHook2(iname, ret, sig, ...) _TStaticNoDefHook(iname, (void*)ll::hook::findSig(sig), ret, VA_EXPAND(__VA_ARGS__))
#define SHook(ret, sig, ...) SHook2(sig, ret, sig, VA_EXPAND(__VA_ARGS__))
#define SStaticHook2(iname, ret, sig, type, ...) \
_TStaticDefHook(iname, (void*)LL::Hook::findSig(sig), ret, type, VA_EXPAND(__VA_ARGS__))
_TStaticDefHook(iname, (void*)ll::hook::findSig(sig), ret, type, VA_EXPAND(__VA_ARGS__))
#define SStaticHook(ret, sig, type, ...) SStaticHook2(sig, ret, sig, type, VA_EXPAND(__VA_ARGS__))
#define SClasslessInstanceHook2(iname, ret, sig, ...) \
_TInstanceNoDefHook(iname, (void*)LL::Hook::findSig(sig), ret, VA_EXPAND(__VA_ARGS__))
_TInstanceNoDefHook(iname, (void*)ll::hook::findSig(sig), ret, VA_EXPAND(__VA_ARGS__))
#define SClasslessInstanceHook(ret, sig, ...) \
SClasslessInstanceHook2(sig, ret, sig, VA_EXPAND(__VA_ARGS__))
#define SInstanceHook2(iname, ret, sig, type, ...) \
_TInstanceDefHook(iname, (void*)LL::Hook::findSig(sig), ret, type, VA_EXPAND(__VA_ARGS__))
_TInstanceDefHook(iname, (void*)ll::hook::findSig(sig), ret, type, VA_EXPAND(__VA_ARGS__))
#define SInstanceHook(ret, sig, type, ...) \
SInstanceHook2(sig, ret, sig, type, VA_EXPAND(__VA_ARGS__))

Expand Down
4 changes: 2 additions & 2 deletions LiteLoader/include/llapi/I18nAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ inline I18nBase* load(Args&&... args) {
* @return I18nBase* The pointer to the I18nBase object in PluginOwnData, null if failed
*/
inline I18nBase* loadFrom(const std::string& plugin) {
if (LL::hasPlugin(plugin)) {
auto p = LL::getPlugin(plugin);
if (ll::hasPlugin(plugin)) {
auto p = ll::getPlugin(plugin);
if (p) {
return loadFromImpl(GetCurrentModule(), p->handle);
}
Expand Down
Loading

0 comments on commit 72e3336

Please sign in to comment.