Merge pull request #34 from PixieCore/master

Added check_sum to post request.
This commit is contained in:
PixieCore 2021-08-14 23:05:10 +02:00 committed by GitHub
commit 6b79be3a45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 6 deletions

View File

@ -101,8 +101,9 @@ void CCompanion::RefreshServerList()
void CCompanion::SendHostingPostRequest()
{
HostToken = "";
bool result = r5net->PostServerHost(HostRequestMessage, HostToken, ServerListing{ MyServer.name, std::string(GameGlobals::HostState->m_levelName), "", GameGlobals::Cvar->FindVar("hostport")->m_pzsCurrentValue, MyServer.password});
HostToken = std::string();
HostRequestMessage = std::string();
bool result = r5net->PostServerHost(HostRequestMessage, HostToken, ServerListing{ MyServer.name, std::string(GameGlobals::HostState->m_levelName), "", GameGlobals::Cvar->FindVar("hostport")->m_pzsCurrentValue, MyServer.password, std::to_string(*reinterpret_cast<std::int32_t*>(0x1656057E0)) /* checksum */});
if (result)
{
HostRequestMessageColor = ImVec4(0.00f, 1.00f, 0.00f, 1.00f);
@ -113,8 +114,6 @@ void CCompanion::SendHostingPostRequest()
msg << "Share the following token for people to connect: ";
}
HostRequestMessage = msg.str().c_str();
}
else
{

View File

@ -7,5 +7,6 @@ struct ServerListing
std::string ip;
std::string port;
std::string password;
std::string checksum;
};

View File

@ -30,6 +30,7 @@ bool R5Net::Client::PostServerHost(std::string& outMessage, std::string& outToke
reqBody["map"] = serverListing.map;
reqBody["port"] = serverListing.port;
reqBody["password"] = serverListing.password;
reqBody["remote_checksum"] = serverListing.checksum;
std::string reqBodyStr = reqBody.dump();
@ -45,8 +46,6 @@ bool R5Net::Client::PostServerHost(std::string& outMessage, std::string& outToke
nlohmann::json resBody = nlohmann::json::parse(res->body);
if (resBody["success"].is_boolean() && resBody["success"])
{
outMessage = "Broadcasting!";
if (resBody["token"].is_string())
outToken = resBody["token"].get<std::string>();
else