Merge branch 'develop' into feature/codo-zones

This commit is contained in:
RektInator 2019-10-03 07:59:32 +02:00
commit 40099cdcbe
6 changed files with 38 additions and 5 deletions

View File

@ -10,6 +10,10 @@ The format is based on [Keep a Changelog v0.3.0](http://keepachangelog.com/en/0.
- Add host information to /info endpoint (request) - Add host information to /info endpoint (request)
### Changed
- Stats are now separate for each mod (#6). Player stats are copied to `fs_game` folder if no stats exist for this mod yet. Keep in mind this also means that level, XP and classes will not be synchronized with the main stats file after this point.
## [0.6.0] - 2018-12-30 ## [0.6.0] - 2018-12-30
### Added ### Added

View File

@ -1,5 +1,7 @@
# AppVeyor CI configuration # AppVeyor CI configuration
version: "#{build} ({branch})"
environment: environment:
matrix: matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019

View File

@ -1,4 +1,5 @@
gitVersioningCommand = "git describe --tags --dirty --always" gitVersioningCommand = "git describe --tags --dirty --always"
gitCurrentBranchCommand = "git symbolic-ref -q --short HEAD"
-- Quote the given string input as a C string -- Quote the given string input as a C string
function cstrquote(value) function cstrquote(value)
@ -86,8 +87,19 @@ newaction {
local proc = assert(io.popen(gitVersioningCommand, "r")) local proc = assert(io.popen(gitVersioningCommand, "r"))
local gitDescribeOutput = assert(proc:read('*a')):gsub("%s+", "") local gitDescribeOutput = assert(proc:read('*a')):gsub("%s+", "")
proc:close() proc:close()
local version = gitDescribeOutput
print(gitDescribeOutput) proc = assert(io.popen(gitCurrentBranchCommand, "r"))
local gitCurrentBranchOutput = assert(proc:read('*a')):gsub("%s+", "")
local gitCurrentBranchSuccess = proc:close()
if gitCurrentBranchSuccess then
-- We got a branch name, check if it is a feature branch
if gitCurrentBranchOutput ~= "develop" and gitCurrentBranchOutput ~= "master" then
version = version .. "-" .. gitCurrentBranchOutput
end
end
print(version)
os.exit(0) os.exit(0)
end end
} }

View File

@ -63,6 +63,17 @@ namespace Components
Stats::SendStats(); Stats::SendStats();
} }
int Stats::SaveStats(char* dest, const char* folder, const char* buffer, size_t length)
{
const auto fs_game = Game::Dvar_FindVar("fs_game");
if (fs_game && fs_game->current.string && strlen(fs_game->current.string) && !strncmp(fs_game->current.string, "mods/", 5))
{
folder = fs_game->current.string;
}
return Utils::Hook::Call<int(char*, const char*, const char*, size_t)>(0x426450)(dest, folder, buffer, length);
}
Stats::Stats() Stats::Stats()
{ {
// This UIScript should be added in the onClose code of the cac_popup menu, // This UIScript should be added in the onClose code of the cac_popup menu,
@ -91,6 +102,9 @@ namespace Components
// Don't create stat backup // Don't create stat backup
Utils::Hook::Nop(0x402CE6, 2); Utils::Hook::Nop(0x402CE6, 2);
// Write stats to mod folder if a mod is loaded
Utils::Hook(0x682F7B, Stats::SaveStats, HOOK_CALL).install()->quick();
} }
Stats::~Stats() Stats::~Stats()

View File

@ -13,6 +13,7 @@ namespace Components
private: private:
static void UpdateClasses(UIScript::Token token); static void UpdateClasses(UIScript::Token token);
static void SendStats(); static void SendStats();
static int SaveStats(char* dest, const char* folder, const char* buffer, size_t length);
static int64_t* GetStatsID(); static int64_t* GetStatsID();
}; };

View File

@ -81,24 +81,24 @@ namespace Utils
bool CreateDir(const std::string& dir) bool CreateDir(const std::string& dir)
{ {
return std::experimental::filesystem::create_directories(dir); return std::filesystem::create_directories(dir);
} }
bool DirectoryExists(const std::string& directory) bool DirectoryExists(const std::string& directory)
{ {
return std::experimental::filesystem::is_directory(directory); return std::filesystem::is_directory(directory);
} }
bool DirectoryIsEmpty(const std::string& directory) bool DirectoryIsEmpty(const std::string& directory)
{ {
return std::experimental::filesystem::is_empty(directory); return std::filesystem::is_empty(directory);
} }
std::vector<std::string> ListFiles(const std::string& dir) std::vector<std::string> ListFiles(const std::string& dir)
{ {
std::vector<std::string> files; std::vector<std::string> files;
for (auto& file : std::experimental::filesystem::directory_iterator(dir)) for (auto& file : std::filesystem::directory_iterator(dir))
{ {
files.push_back(file.path().generic_string()); files.push_back(file.path().generic_string());
} }