Compare commits
3 Commits
b9971da87a
...
2af5896ed1
Author | SHA1 | Date | |
---|---|---|---|
2af5896ed1 | |||
f0cea26ac5 | |||
0edc870820 |
@ -4087,7 +4087,9 @@ Utilities
|
||||
major = 5, -- major version number
|
||||
minor = 2, -- minor version number
|
||||
patch = 1, -- patch version number
|
||||
vers_string = "5.2.1", -- full version string
|
||||
version_string = "5.2.1", -- full version string (or maybe version_string)
|
||||
platform = "Linux", -- as PLATFORM variable
|
||||
sysinfo = "Linux/2.6.32 x86",
|
||||
state = "Active" -- current client state
|
||||
}
|
||||
|
||||
|
@ -1244,13 +1244,21 @@ void Client::sendRespawn()
|
||||
|
||||
void Client::sendReady()
|
||||
{
|
||||
const char *platform_name = porting::getPlatformName();
|
||||
const std::string sysinfo = porting::get_sysinfo();
|
||||
const size_t version_len = strlen(g_version_hash) + 1 + strlen(platform_name) + 1 + sysinfo.size();
|
||||
|
||||
NetworkPacket pkt(TOSERVER_CLIENT_READY,
|
||||
1 + 1 + 1 + 1 + 2 + sizeof(char) * strlen(g_version_hash) + 2);
|
||||
1 + 1 + 1 + 1 + 2 + sizeof(char) * version_len + 2);
|
||||
|
||||
pkt << (u8) VERSION_MAJOR << (u8) VERSION_MINOR << (u8) VERSION_PATCH
|
||||
<< (u8) 0 << (u16) strlen(g_version_hash);
|
||||
<< (u8) 0 << (u16) version_len;
|
||||
|
||||
pkt.putRawString(g_version_hash, (u16) strlen(g_version_hash));
|
||||
pkt << (u8) 0;
|
||||
pkt.putRawString(platform_name, (u16) strlen(platform_name));
|
||||
pkt << (u8) 0;
|
||||
pkt.putRawString(sysinfo.c_str(), sysinfo.size());
|
||||
pkt << (u16)FORMSPEC_API_VERSION;
|
||||
Send(&pkt);
|
||||
}
|
||||
|
@ -332,7 +332,13 @@ public:
|
||||
m_version_major = major;
|
||||
m_version_minor = minor;
|
||||
m_version_patch = patch;
|
||||
m_full_version = full;
|
||||
m_full_version = full.c_str();
|
||||
const size_t pos1 = full.find('\x00');
|
||||
if (pos1 != std::string::npos)
|
||||
m_platform = full.substr(pos1 + 1).c_str();
|
||||
const size_t pos2 = full.find('\x00', pos1 + 1);
|
||||
if (pos2 != std::string::npos)
|
||||
m_sysinfo = full.substr(pos2 + 1);
|
||||
}
|
||||
|
||||
/* read version information */
|
||||
@ -340,6 +346,8 @@ public:
|
||||
u8 getMinor() const { return m_version_minor; }
|
||||
u8 getPatch() const { return m_version_patch; }
|
||||
const std::string &getFull() const { return m_full_version; }
|
||||
const std::string &getPlatform() const { return m_platform; }
|
||||
const std::string &getSysInfo() const { return m_sysinfo; }
|
||||
private:
|
||||
// Version is stored in here after INIT before INIT2
|
||||
u8 m_pending_serialization_version = SER_FMT_VER_INVALID;
|
||||
@ -413,6 +421,8 @@ private:
|
||||
u8 m_version_patch = 0;
|
||||
|
||||
std::string m_full_version = "unknown";
|
||||
std::string m_platform = "unknown";
|
||||
std::string m_sysinfo = "unknown";
|
||||
|
||||
u16 m_deployed_compression = 0;
|
||||
|
||||
|
@ -935,6 +935,8 @@ enum ToServerCommand
|
||||
u8 reserved
|
||||
u16 len
|
||||
u8[len] full_version_string
|
||||
u8[len] platform
|
||||
u8[len] sysinfo
|
||||
*/
|
||||
|
||||
TOSERVER_FIRST_SRP = 0x50,
|
||||
|
@ -234,21 +234,21 @@ inline u64 getTimeMs()
|
||||
{
|
||||
struct timespec ts;
|
||||
os_get_clock(&ts);
|
||||
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
|
||||
return ((u64) ts.tv_sec) * 1000LL + ((u64) ts.tv_nsec) / 1000000LL;
|
||||
}
|
||||
|
||||
inline u64 getTimeUs()
|
||||
{
|
||||
struct timespec ts;
|
||||
os_get_clock(&ts);
|
||||
return ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
|
||||
return ((u64) ts.tv_sec) * 1000000LL + ((u64) ts.tv_nsec) / 1000LL;
|
||||
}
|
||||
|
||||
inline u64 getTimeNs()
|
||||
{
|
||||
struct timespec ts;
|
||||
os_get_clock(&ts);
|
||||
return ts.tv_sec * 1000000000 + ts.tv_nsec;
|
||||
return ((u64) ts.tv_sec) * 1000000000LL + ((u64) ts.tv_nsec);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -162,7 +162,9 @@ int ModApiServer::l_get_player_information(lua_State *L)
|
||||
u32 uptime;
|
||||
u16 prot_vers;
|
||||
u8 ser_vers,major,minor,patch;
|
||||
std::string vers_string;
|
||||
std::string version_string;
|
||||
std::string platform;
|
||||
std::string sysinfo;
|
||||
|
||||
#define ERET(code) \
|
||||
if (!(code)) { \
|
||||
@ -182,7 +184,7 @@ int ModApiServer::l_get_player_information(lua_State *L)
|
||||
&avg_jitter))
|
||||
|
||||
ERET(getServer(L)->getClientInfo(player->getPeerId(), &state, &uptime, &ser_vers,
|
||||
&prot_vers, &major, &minor, &patch, &vers_string))
|
||||
&prot_vers, &major, &minor, &patch, &version_string, &platform, &sysinfo))
|
||||
|
||||
lua_newtable(L);
|
||||
int table = lua_gettop(L);
|
||||
@ -254,7 +256,15 @@ int ModApiServer::l_get_player_information(lua_State *L)
|
||||
lua_settable(L, table);
|
||||
|
||||
lua_pushstring(L,"version_string");
|
||||
lua_pushstring(L, vers_string.c_str());
|
||||
lua_pushstring(L, version_string.c_str());
|
||||
lua_settable(L, table);
|
||||
|
||||
lua_pushstring(L,"platform");
|
||||
lua_pushstring(L, platform.c_str());
|
||||
lua_settable(L, table);
|
||||
|
||||
lua_pushstring(L,"sysinfo");
|
||||
lua_pushstring(L, sysinfo.c_str());
|
||||
lua_settable(L, table);
|
||||
|
||||
lua_pushstring(L,"state");
|
||||
|
@ -1263,7 +1263,9 @@ bool Server::getClientInfo(
|
||||
u8* major,
|
||||
u8* minor,
|
||||
u8* patch,
|
||||
std::string* vers_string
|
||||
std::string* version_string,
|
||||
std::string* platform,
|
||||
std::string* sysinfo
|
||||
)
|
||||
{
|
||||
*state = m_clients.getClientState(peer_id);
|
||||
@ -1282,7 +1284,9 @@ bool Server::getClientInfo(
|
||||
*major = client->getMajor();
|
||||
*minor = client->getMinor();
|
||||
*patch = client->getPatch();
|
||||
*vers_string = client->getFull();
|
||||
*version_string = client->getFull();
|
||||
*platform = client->getPlatform();
|
||||
*sysinfo = client->getSysInfo();
|
||||
|
||||
m_clients.unlock();
|
||||
|
||||
|
@ -335,7 +335,7 @@ public:
|
||||
bool getClientConInfo(session_t peer_id, con::rtt_stat_type type, float *retval);
|
||||
bool getClientInfo(session_t peer_id, ClientState *state, u32 *uptime,
|
||||
u8* ser_vers, u16* prot_vers, u8* major, u8* minor, u8* patch,
|
||||
std::string* vers_string);
|
||||
std::string* version_string, std::string* platform, std::string* sysinfo);
|
||||
|
||||
void printToConsoleOnly(const std::string &text);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user