Add platform information to get_player_information (#50)
This commit is contained in:
parent
e739e47273
commit
f91eca1e5e
@ -4523,14 +4523,15 @@ Utilities
|
|||||||
min_jitter = 0.01, -- minimum packet time jitter
|
min_jitter = 0.01, -- minimum packet time jitter
|
||||||
max_jitter = 0.5, -- maximum packet time jitter
|
max_jitter = 0.5, -- maximum packet time jitter
|
||||||
avg_jitter = 0.03, -- average packet time jitter
|
avg_jitter = 0.03, -- average packet time jitter
|
||||||
-- the following information is available in a debug build only!!!
|
-- DO NOT USE IN MODS WITHOUT A GOOD REASON
|
||||||
-- DO NOT USE IN MODS
|
serialization_version = 26, -- serialization version used by client
|
||||||
--ser_vers = 26, -- serialization version used by client
|
major = 0, -- major version number
|
||||||
--major = 0, -- major version number
|
minor = 4, -- minor version number
|
||||||
--minor = 4, -- minor version number
|
patch = 10, -- patch version number
|
||||||
--patch = 10, -- patch version number
|
version_string = "0.4.9-git", -- full version string
|
||||||
--vers_string = "0.4.9-git", -- full version string
|
platform = "Linux", -- Equivalent to the "PLATFORM" variable
|
||||||
--state = "Active" -- current client state
|
sysinfo = "Linux/5.4.0-109-generic x86_64",
|
||||||
|
state = "Active" -- current client state
|
||||||
}
|
}
|
||||||
|
|
||||||
* `minetest.mkdir(path)`: returns success.
|
* `minetest.mkdir(path)`: returns success.
|
||||||
|
@ -1300,13 +1300,20 @@ void Client::sendRespawn()
|
|||||||
|
|
||||||
void Client::sendReady()
|
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,
|
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
|
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.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;
|
pkt << (u16)FORMSPEC_API_VERSION;
|
||||||
Send(&pkt);
|
Send(&pkt);
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,15 @@ public:
|
|||||||
m_version_major = major;
|
m_version_major = major;
|
||||||
m_version_minor = minor;
|
m_version_minor = minor;
|
||||||
m_version_patch = patch;
|
m_version_patch = patch;
|
||||||
m_full_version = full;
|
m_full_version = full.c_str();
|
||||||
|
const size_t pos = full.find('\x00');
|
||||||
|
if (pos != std::string::npos) {
|
||||||
|
m_platform = full.substr(pos + 1).c_str();
|
||||||
|
|
||||||
|
const size_t pos2 = full.find('\x00', pos + 1);
|
||||||
|
if (pos2 != std::string::npos)
|
||||||
|
m_sysinfo = full.substr(pos2 + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* read version information */
|
/* read version information */
|
||||||
@ -340,7 +348,9 @@ public:
|
|||||||
u8 getMinor() const { return m_version_minor; }
|
u8 getMinor() const { return m_version_minor; }
|
||||||
u8 getPatch() const { return m_version_patch; }
|
u8 getPatch() const { return m_version_patch; }
|
||||||
const std::string &getFullVer() const { return m_full_version; }
|
const std::string &getFullVer() const { return m_full_version; }
|
||||||
|
const std::string &getPlatform() const { return m_platform; }
|
||||||
|
const std::string &getSysInfo() const { return m_sysinfo; }
|
||||||
|
|
||||||
void setLangCode(const std::string &code) { m_lang_code = code; }
|
void setLangCode(const std::string &code) { m_lang_code = code; }
|
||||||
const std::string &getLangCode() const { return m_lang_code; }
|
const std::string &getLangCode() const { return m_lang_code; }
|
||||||
|
|
||||||
@ -426,6 +436,8 @@ private:
|
|||||||
u8 m_version_patch = 0;
|
u8 m_version_patch = 0;
|
||||||
|
|
||||||
std::string m_full_version = "unknown";
|
std::string m_full_version = "unknown";
|
||||||
|
std::string m_platform = "unknown";
|
||||||
|
std::string m_sysinfo = "unknown";
|
||||||
|
|
||||||
u16 m_deployed_compression = 0;
|
u16 m_deployed_compression = 0;
|
||||||
|
|
||||||
|
@ -250,6 +250,14 @@ int ModApiServer::l_get_player_information(lua_State *L)
|
|||||||
lua_pushstring(L, info.vers_string.c_str());
|
lua_pushstring(L, info.vers_string.c_str());
|
||||||
lua_settable(L, table);
|
lua_settable(L, table);
|
||||||
|
|
||||||
|
lua_pushstring(L,"platform");
|
||||||
|
lua_pushstring(L, info.platform.c_str());
|
||||||
|
lua_settable(L, table);
|
||||||
|
|
||||||
|
lua_pushstring(L,"sysinfo");
|
||||||
|
lua_pushstring(L, info.sysinfo.c_str());
|
||||||
|
lua_settable(L, table);
|
||||||
|
|
||||||
lua_pushstring(L,"state");
|
lua_pushstring(L,"state");
|
||||||
lua_pushstring(L, ClientInterface::state2Name(info.state).c_str());
|
lua_pushstring(L, ClientInterface::state2Name(info.state).c_str());
|
||||||
lua_settable(L, table);
|
lua_settable(L, table);
|
||||||
|
@ -1281,6 +1281,8 @@ bool Server::getClientInfo(session_t peer_id, ClientInfo &ret)
|
|||||||
ret.minor = client->getMinor();
|
ret.minor = client->getMinor();
|
||||||
ret.patch = client->getPatch();
|
ret.patch = client->getPatch();
|
||||||
ret.vers_string = client->getFullVer();
|
ret.vers_string = client->getFullVer();
|
||||||
|
ret.platform = client->getPlatform();
|
||||||
|
ret.sysinfo = client->getSysInfo();
|
||||||
|
|
||||||
ret.lang_code = client->getLangCode();
|
ret.lang_code = client->getLangCode();
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ struct ClientInfo {
|
|||||||
u8 ser_vers;
|
u8 ser_vers;
|
||||||
u16 prot_vers;
|
u16 prot_vers;
|
||||||
u8 major, minor, patch;
|
u8 major, minor, patch;
|
||||||
std::string vers_string, lang_code;
|
std::string vers_string, platform, sysinfo, lang_code;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Server : public con::PeerHandler, public MapEventReceiver,
|
class Server : public con::PeerHandler, public MapEventReceiver,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user