1
This commit is contained in:
parent
545309494a
commit
d3adadee76
@ -1,5 +1,7 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
@ -582,10 +584,35 @@ long long App::AllocTempWeaponUniId()
|
||||
return -curr_uniid_;
|
||||
}
|
||||
|
||||
static std::string GetSelfPath()
|
||||
{
|
||||
char self[PATH_MAX] = { 0 };
|
||||
int nchar = readlink("/proc/self/exe", self, sizeof self);
|
||||
if (nchar < 0) {
|
||||
A8_ABORT();
|
||||
}
|
||||
std::string path((char*)self);
|
||||
a8::XPrintf("exe:%s path:%s\n", {self, path});
|
||||
return path;
|
||||
}
|
||||
|
||||
int App::GetVersion()
|
||||
{
|
||||
const char* current_file_name = __FILE__;
|
||||
if (!version_) {
|
||||
#if 1
|
||||
std::string self_path = GetSelfPath();
|
||||
//self_path = "/data/backups_app/b_game2006_gameserver_ty_z9.1.0.0.1.20231124R2/bin/gameserver2006";
|
||||
std::vector<std::string> strings;
|
||||
a8::Split(self_path, strings, '/');
|
||||
std::string tag = strings.at(strings.size() - 3);
|
||||
std::vector<std::string> strings2;
|
||||
a8::Split(tag, strings2, '.');
|
||||
std::string version_str = strings2.at(strings2.size() - 1);
|
||||
a8::ReplaceString(version_str, "R", "0");
|
||||
version_ = std::make_shared<int>(a8::XValue(version_str).GetInt());
|
||||
a8::XPrintf("%s %s %s\n", {self_path, *version_, version_str});
|
||||
#else
|
||||
std::vector<std::string> strings;
|
||||
a8::Split(current_file_name, strings, '/');
|
||||
std::string tag = strings.at(strings.size() - 6);
|
||||
@ -595,6 +622,7 @@ int App::GetVersion()
|
||||
a8::ReplaceString(version_str, "R", "0");
|
||||
version_ = std::make_shared<int>(a8::XValue(version_str).GetInt());
|
||||
a8::XPrintf("%s %s %s\n", {current_file_name, *version_, version_str});
|
||||
#endif
|
||||
}
|
||||
return *version_;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user