Add telemetry dashboard and automatic server names; record Workshop 0.0.137
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""Exercise the production name resolver with native metadata boundaries doubled."""
|
||||
from policy_harness import ROOT, body, run
|
||||
p = ROOT / 'addons/core/Scripts/Game/ERR/00_Core/ERR_TelemetryServerName.c'
|
||||
method = body(p, 'static string Resolve(')
|
||||
for a, b in [('ServerConfig config', 'ServerConfig* config'), ('ServerInfo info', 'ServerInfo* info'),
|
||||
('GetGame().GetServerInfo()', 'ServerLobbyApi::GetServerInfo()'), ('ServerLobbyApi.', 'ServerLobbyApi::'), ('config.GetName()', 'config->GetName()'), ('info.GetName()', 'info->GetName()')]:
|
||||
method = method.replace(a, b)
|
||||
run(r'''
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
struct string:std::string {
|
||||
using std::string::string;using std::string::operator=;
|
||||
string(std::string v):std::string(v){}
|
||||
bool IsEmpty(){return empty();}int Length(){return size();}
|
||||
string Substring(int start,int count){return substr(start,count);}
|
||||
void TrimInPlace(){auto a=find_first_not_of(" \t\r\n");if(a==npos){clear();return;}*this=substr(a,find_last_not_of(" \t\r\n")-a+1);}
|
||||
};
|
||||
struct ServerConfig {string name=" Community Escape ";string GetName(){return name;}};
|
||||
struct ServerInfo {string name="Listed server";string GetName(){return name;}};
|
||||
namespace ServerLobbyApi {ServerConfig cfg;ServerInfo info;bool configPresent=true,infoPresent=true;
|
||||
ServerConfig* GetServerConfig(){return configPresent?&cfg:nullptr;}ServerInfo* GetServerInfo(){return infoPresent?&info:nullptr;}}
|
||||
struct Names {
|
||||
''' + method + r'''
|
||||
};
|
||||
int main(){
|
||||
assert(Names::Resolve("")=="Community Escape");
|
||||
assert(Names::Resolve(" Manual label ")=="Manual label");
|
||||
assert(Names::Resolve(" ")=="Community Escape");
|
||||
ServerLobbyApi::configPresent=false;assert(Names::Resolve("")=="Listed server");
|
||||
ServerLobbyApi::infoPresent=false;assert(Names::Resolve("")=="");
|
||||
ServerLobbyApi::configPresent=true;ServerLobbyApi::cfg.name="Changed name";
|
||||
assert(Names::Resolve("")=="Changed name");
|
||||
assert(Names::Resolve(string(160,'x')).Length()==120);
|
||||
ServerLobbyApi::cfg.name=" ";ServerLobbyApi::infoPresent=true;assert(Names::Resolve("")=="Listed server");
|
||||
}
|
||||
''')
|
||||
telemetry = p.with_name('ERR_Telemetry.c')
|
||||
assert 'ERR_TelemetryServerName.Resolve(m_Config.ServerName)' in body(telemetry, 'protected void Event(')
|
||||
print('PASS: automatic server config/lobby name, explicit override, startup absence, rename and payload bound')
|
||||
Reference in New Issue
Block a user