Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various netplay / joining fixes #3517

Merged
merged 6 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/framework/crc.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct Sha256
std::string toString() const;
void fromString(std::string const &s);

uint8_t bytes[Bytes];
uint8_t bytes[Bytes] = {0};
};
Sha256 sha256Sum(void const *data, size_t dataLen);
template <>
Expand Down
7 changes: 7 additions & 0 deletions lib/netplay/netplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4117,6 +4117,7 @@ static void NETallowJoining()
NETflush();
NETpop(NETnetTmpQueue(i));

NETaddSessionBanBadIP(tmp_connectState[i].ip);
NETcloseTempSocket(i);
sync_counter.cantjoin++;
}
Expand Down Expand Up @@ -4158,6 +4159,7 @@ static void NETallowJoining()
NETflush();
NETpop(NETnetTmpQueue(i));

NETaddSessionBanBadIP(tmp_connectState[i].ip);
NETcloseTempSocket(i);
sync_counter.cantjoin++;
continue;
Expand Down Expand Up @@ -4831,6 +4833,7 @@ bool NETjoinGame(const char *host, uint32_t port, const char *playername, const

if (bsocket == nullptr)
{
NETclose();
return false; // Connection dropped while sending NET_JOIN.
}
socketFlush(bsocket, NetPlay.hostPlayer); // Make sure the message was completely sent.
Expand All @@ -4846,11 +4849,13 @@ bool NETjoinGame(const char *host, uint32_t port, const char *playername, const
if ((unsigned)wzGetTicks() > i + 5000)
{
// timeout
NETclose();
return false;
}

if (bsocket == nullptr)
{
NETclose();
return false; // Connection dropped.
}

Expand All @@ -4876,6 +4881,7 @@ bool NETjoinGame(const char *host, uint32_t port, const char *playername, const
if (NetPlay.hostPlayer >= MAX_CONNECTED_PLAYERS)
{
debug(LOG_ERROR, "Bad host player number (%" PRIu32 ") received from host!", NetPlay.hostPlayer);
NETclose();
return false;
}

Expand All @@ -4893,6 +4899,7 @@ bool NETjoinGame(const char *host, uint32_t port, const char *playername, const
if (index >= MAX_CONNECTED_PLAYERS)
{
debug(LOG_ERROR, "Bad player number (%u) received from host!", index);
NETclose();
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7168,7 +7168,7 @@ bool loadTerrainTypeMap(const char *pFilePath)
}

// Maps built into the game with custom tile types need to be excluded for overrides.
bool shouldLoadTerrainTypeOverrides(const char* name)
bool shouldLoadTerrainTypeOverrides(const std::string& name)
{
std::vector<std::string> excludedMaps = {"Monocot"};

Expand Down
Loading
Loading