MCPcopy Create free account
hub / github.com/assaultcube/AC / changeclientrole

Function changeclientrole

source/src/server.cpp:2749–2779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2747}
2748
2749void changeclientrole(int client, int role, char *pwd, bool force)
2750{
2751 pwddetail pd;
2752 bool success = false;
2753 if(!isdedicated || !valid_client(client)) return;
2754 pd.line = -1;
2755 if(role == clients[client]->role) return;
2756 if(role == CR_ADMIN && pwd && pwd[0] && passwords.check(clients[client]->name, pwd, clients[client]->salt, &pd) && !pd.denyadmin)
2757 {
2758 mlog(ACLOG_INFO,"[%s] player %s used admin password in line %d", clients[client]->hostname, clients[client]->name[0] ? clients[client]->name : "[unnamed]", pd.line);
2759 success = true;
2760 }
2761 if(clients[client]->checkvitadate(VS_ADMIN))
2762 {
2763 mlog(ACLOG_INFO,"[%s] player %s claimed admin through valid vita claim (pubkey: %s)", clients[client]->hostname, clients[client]->name[0] ? clients[client]->name : "[unnamed]", clients[client]->pubkeyhex);
2764 success = true;
2765 }
2766 if(force || role == CR_DEFAULT || success)
2767 {
2768 if(role > CR_DEFAULT)
2769 {
2770 loopv(clients) clients[i]->role = CR_DEFAULT;
2771 }
2772 clients[client]->role = role;
2773 sendserveropinfo(-1);
2774 mlog(ACLOG_INFO,"[%s] set role of player %s to %s", clients[client]->hostname, clients[client]->name[0] ? clients[client]->name : "[unnamed]", role == CR_ADMIN ? "admin" : "normal player"); // flowtron : connecting players haven't got a name yet (connectadmin)
2775 if(role > CR_DEFAULT) sendiplist(client);
2776 }
2777 else if(pwd && pwd[0]) disconnect_client(client, DISC_SOPLOGINFAIL); // avoid brute-force
2778 if(curvote) curvote->evaluate();
2779}
2780
2781void senddisconnectedscores(int cn)
2782{

Callers 2

performMethod · 0.85
processFunction · 0.85

Calls 9

valid_clientFunction · 0.85
mlogFunction · 0.85
sendserveropinfoFunction · 0.85
sendiplistFunction · 0.85
disconnect_clientFunction · 0.85
checkvitadateMethod · 0.80
evaluateMethod · 0.80
loopvFunction · 0.70
checkMethod · 0.45

Tested by

no test coverage detected