Skip to content

Commit

Permalink
Merge branch 'no-setinfo-login' into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
drzel committed May 9, 2024
2 parents f1bb88a + e589b97 commit 93f440e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions csqc/main.qc
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,8 @@ float FoLogin(string token, float print_error) {
return FALSE;
}

localcmd("setinfo _fo_token ", token, "\n");
localcmd("cmd fo-login-silent\n");
localcmd("setinfo _fo_token \"\"\n");
localcmd(sprintf("cmd fo-login-silent %s\n", token));
return TRUE;
}

Expand Down
4 changes: 2 additions & 2 deletions ssqc/commands.qc
Original file line number Diff line number Diff line change
Expand Up @@ -957,13 +957,13 @@ float (string arg1, string arg2, string arg3) ParseCmds = {
if (self.fo_login != string_null) {
sprint (self, PRINT_HIGH, "You are logged in\n");
} else {
performFoLogin(self);
performFoLogin(self, arg2);
}
break;
case "fo-login-silent":
processedCmd = TRUE;
if (self.fo_login == string_null)
performFoLogin(self);
performFoLogin(self, arg2);
break;
case "who":
processedCmd = TRUE;
Expand Down
3 changes: 1 addition & 2 deletions ssqc/login.qc
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ void (entity player, string login, string secret) performLogin = {
dprint("\n");
}

void (entity player) performFoLogin = {
void (entity player, string token) performFoLogin = {
local string uri = sprintf("%s/results/api/v1/fo_login", backend_address);
local string token = FO_GetUserSettingString(player, "_fo_token", "fo_token", "");
uri_get(uri, FO_LOGIN_REQUEST, "application/json", sprintf("{ \"auth_token\": \"%s\" }", token));
dprint(sprintf("%s [%s] logging in\n", infokey(player, "name"), infokey(player, "ip")));
}
Expand Down
9 changes: 2 additions & 7 deletions ssqc/quadmode.qc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ void () PostFOQuadStarted = {
local float tn;
local float prefix_comma;
local entity p;
local string token;

for (tn = 1; tn <= number_of_teams; ++tn) {
data = strcat(data, " \"", ftos(tn), "\": {\n");
Expand All @@ -70,9 +69,8 @@ void () PostFOQuadStarted = {
if (prefix_comma)
data = strcat(data, ",");

token = FO_GetUserSettingString(p, "_fo_token", "fo_token", "");
data = strcat(data, " {\n");
data = strcat(data, " \"auth_token\": \"", token, "\",\n");
data = strcat(data, " \"id\": \"", p.fo_login, "\",\n");
data = strcat(data, " \"playerclass\": \"", ftos(p.playerclass), "\"\n");
data = strcat(data, " }\n");
prefix_comma = TRUE;
Expand Down Expand Up @@ -115,7 +113,6 @@ void () PostFOQuadFinalRoundStarted = {
local float tn;
local float prefix_comma;
local entity p;
local string token;

for (tn = 1; tn <= number_of_teams; ++tn) {
local float score = TeamFortress_TeamGetScore(tn);
Expand All @@ -132,9 +129,8 @@ void () PostFOQuadFinalRoundStarted = {
if (prefix_comma)
data = strcat(data, ",");

token = FO_GetUserSettingString(p, "_fo_token", "fo_token", "");
data = strcat(data, " {\n");
data = strcat(data, " \"auth_token\": \"", token, "\",\n");
data = strcat(data, " \"id\": \"", p.fo_login, "\",\n");
data = strcat(data, " \"playerclass\": \"", ftos(p.playerclass), "\"\n");
data = strcat(data, " }\n");
prefix_comma = TRUE;
Expand Down Expand Up @@ -187,7 +183,6 @@ void (float winner) PostFOQuadFinished = {
local float tn;
local float prefix_comma;
local entity p;
local string token;

for (tn = 1; tn <= number_of_teams; ++tn) {
local float score = TeamFortress_TeamGetScore(tn);
Expand Down

0 comments on commit 93f440e

Please sign in to comment.