-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Open-source release for Rocket Plugin 0.6.8.
- Add nullcheck marco's everywhere. - Changed the log marco names to avoid conflicts. - Added Notifier to clear physics cache. - Upgraded to c++20. - Rewrote CrazyRumble. - Split RocketPlugin.cpp into modules. - Split ExternalFunctions.cpp into external modules. - Added colored logs.
- Loading branch information
Showing
78 changed files
with
5,326 additions
and
5,035 deletions.
There are no files selected for viewing
317 changes: 254 additions & 63 deletions
317
source/External/BakkesModAdditions/include/utils/cvarmanagerwrapperdebug.h
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
source/External/BakkesModAdditions/include/utils/filesystem.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#pragma once | ||
#include <string> | ||
#include <vector> | ||
#include <algorithm> | ||
#include <filesystem> | ||
|
||
|
||
static inline bool has_extension(const std::string& fileExtension, const std::vector<std::string>& extensions) | ||
{ | ||
// Filter out unwanted file extensions. | ||
return std::ranges::any_of(extensions, [&](const std::string& extension) { | ||
return fileExtension == extension; | ||
}); | ||
} | ||
|
||
|
||
static inline std::vector<std::filesystem::path> iterate_directory(const std::filesystem::path& directory, | ||
const std::vector<std::string>& extensions, const int depth = 0, const int maxDepth = 3) | ||
{ | ||
if (depth > maxDepth) { | ||
return std::vector<std::filesystem::path>(); | ||
} | ||
|
||
std::vector<std::filesystem::path> files; | ||
for (const std::filesystem::directory_entry& file : std::filesystem::directory_iterator(directory)) { | ||
const std::filesystem::path& filePath = file.path(); | ||
if (file.is_directory()) { | ||
std::vector<std::filesystem::path> directoryFiles = iterate_directory( | ||
filePath, extensions, depth + 1, maxDepth); | ||
// Remove if directory is empty. | ||
if (!directoryFiles.empty()) { | ||
files.insert(files.end(), directoryFiles.begin(), directoryFiles.end()); | ||
} | ||
} | ||
else if (has_extension(filePath.extension().string(), extensions)) { | ||
files.push_back(filePath); | ||
} | ||
} | ||
|
||
return files; | ||
} | ||
|
||
|
||
template<class... TArgs, typename = std::enable_if_t<std::conjunction_v<std::is_convertible<TArgs, std::string>...>>> | ||
static inline std::vector<std::filesystem::path> get_files_from_dir(const std::filesystem::path& directory, const int maxDepth, const TArgs... extension) | ||
{ | ||
if (!exists(directory)) { | ||
return std::vector<std::filesystem::path>(); | ||
} | ||
|
||
const std::vector<std::string> fileExtensions = { extension... }; | ||
|
||
return iterate_directory(directory, fileExtensions, 0, maxDepth); | ||
} |
170 changes: 85 additions & 85 deletions
170
source/External/BakkesModAdditions/include/utils/parser_w.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,85 @@ | ||
#pragma once | ||
#include <string> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
|
||
/* | ||
* Wide string parser equivalents. | ||
*/ | ||
|
||
// Checks if the given string starts with given string. | ||
inline bool string_starts_with(const std::wstring& wstr, const std::wstring& begin) | ||
{ | ||
return wstr.compare(0, begin.length(), begin) == 0; | ||
} | ||
|
||
|
||
// Splits the string by delimiter. | ||
inline size_t split(const std::wstring& wstr, std::vector<std::wstring>& wstrs, const wchar_t delimiter) | ||
{ | ||
size_t pos = wstr.find(delimiter); | ||
size_t initialPos = 0; | ||
wstrs.clear(); | ||
|
||
// Decompose statement. | ||
while (pos != std::string::npos) { | ||
wstrs.push_back(wstr.substr(initialPos, pos - initialPos)); | ||
initialPos = pos + 1; | ||
|
||
pos = wstr.find(delimiter, initialPos); | ||
} | ||
|
||
// Add the last one. | ||
wstrs.push_back(wstr.substr(initialPos, std::min(pos, wstr.size()) - initialPos)); | ||
|
||
return wstrs.size(); | ||
} | ||
|
||
|
||
// Trim from start. | ||
inline std::wstring& ltrim(std::wstring& wstr) { | ||
wstr.erase(wstr.begin(), std::find_if(wstr.begin(), wstr.end(), [](const int wc) { | ||
return !std::isspace(wc); | ||
})); | ||
|
||
return wstr; | ||
} | ||
|
||
|
||
// Trim from end. | ||
inline std::wstring& rtrim(std::wstring& wstr) { | ||
wstr.erase(std::find_if(wstr.rbegin(), wstr.rend(), [](const int wc) { | ||
return !std::isspace(wc); | ||
}).base(), wstr.end()); | ||
|
||
return wstr; | ||
} | ||
|
||
|
||
// Trim from both ends. | ||
inline std::wstring& trim(std::wstring& wstr) { | ||
return ltrim(rtrim(wstr)); | ||
} | ||
|
||
|
||
// Replaces the first occurrence with the other string. | ||
inline bool replace(std::wstring& wstr, const std::wstring& from, const std::wstring& to) { | ||
const size_t start_pos = wstr.find(from); | ||
if (start_pos == std::string::npos) { | ||
return false; | ||
} | ||
wstr.replace(start_pos, from.length(), to); | ||
|
||
return true; | ||
} | ||
|
||
|
||
// Replaces all occurrences with the other string. | ||
inline void replace_all(std::wstring& wstr, const std::wstring& from, const std::wstring& to) { | ||
size_t start_pos = wstr.find(from); | ||
while (start_pos != std::string::npos) { | ||
wstr.replace(start_pos, from.length(), to); | ||
start_pos = wstr.find(from); | ||
} | ||
} | ||
#pragma once | ||
#include <string> | ||
#include <vector> | ||
#include <algorithm> | ||
|
||
|
||
/* | ||
* Wide string parser equivalents. | ||
*/ | ||
|
||
// Checks if the given string starts with given string. | ||
inline bool string_starts_with(const std::wstring& wstr, const std::wstring& begin) | ||
{ | ||
return wstr.compare(0, begin.length(), begin) == 0; | ||
} | ||
|
||
|
||
// Splits the string by delimiter. | ||
inline size_t split(const std::wstring& wstr, std::vector<std::wstring>& wstrs, const wchar_t delimiter) | ||
{ | ||
size_t pos = wstr.find(delimiter); | ||
size_t initialPos = 0; | ||
wstrs.clear(); | ||
|
||
// Decompose statement. | ||
while (pos != std::string::npos) { | ||
wstrs.push_back(wstr.substr(initialPos, pos - initialPos)); | ||
initialPos = pos + 1; | ||
|
||
pos = wstr.find(delimiter, initialPos); | ||
} | ||
|
||
// Add the last one. | ||
wstrs.push_back(wstr.substr(initialPos, std::min(pos, wstr.size()) - initialPos)); | ||
|
||
return wstrs.size(); | ||
} | ||
|
||
|
||
// Trim from start. | ||
inline std::wstring& ltrim(std::wstring& wstr) { | ||
wstr.erase(wstr.begin(), std::find_if(wstr.begin(), wstr.end(), [](const int wc) { | ||
return !std::isspace(wc); | ||
})); | ||
|
||
return wstr; | ||
} | ||
|
||
|
||
// Trim from end. | ||
inline std::wstring& rtrim(std::wstring& wstr) { | ||
wstr.erase(std::find_if(wstr.rbegin(), wstr.rend(), [](const int wc) { | ||
return !std::isspace(wc); | ||
}).base(), wstr.end()); | ||
|
||
return wstr; | ||
} | ||
|
||
|
||
// Trim from both ends. | ||
inline std::wstring& trim(std::wstring& wstr) { | ||
return ltrim(rtrim(wstr)); | ||
} | ||
|
||
|
||
// Replaces the first occurrence with the other string. | ||
inline bool replace(std::wstring& wstr, const std::wstring& from, const std::wstring& to) { | ||
const size_t start_pos = wstr.find(from); | ||
if (start_pos == std::string::npos) { | ||
return false; | ||
} | ||
wstr.replace(start_pos, from.length(), to); | ||
|
||
return true; | ||
} | ||
|
||
|
||
// Replaces all occurrences with the other string. | ||
inline void replace_all(std::wstring& wstr, const std::wstring& from, const std::wstring& to) { | ||
size_t start_pos = wstr.find(from); | ||
while (start_pos != std::string::npos) { | ||
wstr.replace(start_pos, from.length(), to); | ||
start_pos = wstr.find(from); | ||
} | ||
} |
Oops, something went wrong.