Skip to content

Commit

Permalink
fix(*): don't send voiceChannelName if it's empty (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrappachc authored Nov 6, 2021
1 parent cca2e39 commit e4adc52
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions scripting/connector.sp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public Action HeartbeatGameServer(Handle timerHandle)
return Plugin_Stop;
}

System2HTTPRequest request = new System2HTTPRequest(HeartbeatHttpCallback, "%s/game-servers/", apiAddress);
request.SetHeader("Authorization", "secret %s", secret);
request.SetHeader("Content-Type", "application/x-www-form-urlencoded");

int ipAddr[4];
SteamWorks_GetPublicIP(ipAddr);

Expand All @@ -95,19 +99,20 @@ public Action HeartbeatGameServer(Handle timerHandle)
GetConVarString(FindConVar("rcon_password"), rconPassword, sizeof(rconPassword));
System2_URLEncode(rconPassword, sizeof(rconPassword), rconPassword);

char data[256];
Format(data, sizeof(data), "address=%s&port=%s&name=%s&rconPassword=%s",
address, port, name, rconPassword);

char voiceChannelName[64];
tf2pickupOrgVoiceChannelName.GetString(voiceChannelName, sizeof(voiceChannelName));
System2_URLEncode(voiceChannelName, sizeof(voiceChannelName), voiceChannelName);

int priority = tf2pickupOrgPriority.IntValue;

System2HTTPRequest request = new System2HTTPRequest(HeartbeatHttpCallback, "%s/game-servers/", apiAddress);
request.SetHeader("Authorization", "secret %s", secret);
request.SetHeader("Content-Type", "application/x-www-form-urlencoded");
if (!StrEqual(voiceChannelName, "")) {
System2_URLEncode(voiceChannelName, sizeof(voiceChannelName), voiceChannelName);
Format(data, sizeof(data), "%s&voiceChannelName=%s", data, voiceChannelName);
}

char data[256];
Format(data, sizeof(data), "address=%s&port=%s&name=%s&rconPassword=%s&voiceChannelName=%s&priority=%d",
address, port, name, rconPassword, voiceChannelName, priority);
int priority = tf2pickupOrgPriority.IntValue;
Format(data, sizeof(data), "%s&priority=%d", data, priority);

char overrideInternalAddress[64];
tf2pickupOrgOverrideInternalAddress.GetString(overrideInternalAddress, sizeof(overrideInternalAddress));
Expand Down

0 comments on commit e4adc52

Please sign in to comment.