Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit d281de8

Browse files
committed
fix giant stack memory of network server
1 parent f1bfe80 commit d281de8

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

Managers/NetworkServer.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,7 +1737,10 @@ namespace RTE {
17371737
double compressionRatio = (m_DataUncompressedTotal[i] > 0) ? static_cast<double>(m_DataSentTotal[i]) / static_cast<double>(m_DataUncompressedTotal[i]) : 0;
17381738
double emptyRatio = (m_EmptyBlocks[i] > 0) ? static_cast<double>(m_FullBlocks[i]) / static_cast<double>(m_EmptyBlocks[i]) : 0;
17391739

1740-
std::string playerName = IsPlayerConnected(i) ? GetPlayerName(i) : "- NO PLAYER -";
1740+
std::string playerName = " - NO PLAYER - ";
1741+
if (IsPlayerConnected(i)) {
1742+
playerName = GetPlayerName(i);
1743+
}
17411744

17421745
// Jesus christ
17431746
std::snprintf(buf, sizeof(buf),
@@ -1747,18 +1750,18 @@ namespace RTE {
17471750
"R : % .2f\n"
17481751
"Full Blck %lu (%.1f Kb)\n"
17491752
"Empty Blck %lu (%.1f Kb)\n"
1750-
"Frame Kb : % lu\n"
1751-
"Glow Kb : % lu\n"
1752-
"Sound Kb : % lu\n"
1753-
"Scene Kb : % lu\n"
1754-
"Frames sent : % uK\n"
1755-
"Frame skipped : % uK\n"
1756-
"Blocks full : % uK\n"
1757-
"Blocks empty : % uK\n"
1753+
"Frame Kb : %lu\n"
1754+
"Glow Kb : %lu\n"
1755+
"Sound Kb : %lu\n"
1756+
"Scene Kb : %lu\n"
1757+
"Frames sent : %uK\n"
1758+
"Frame skipped : %uK\n"
1759+
"Blocks full : %uK\n"
1760+
"Blocks empty : %uK\n"
17581761
"Blk Ratio : % .2f\n"
17591762
"Frames ms : % d\n"
17601763
"Send ms % d\n"
1761-
"Total Data % lu MB",
1764+
"Total Data %lu MB",
17621765

17631766
(i == c_MaxClients) ? "- TOTALS - " : playerName.c_str(),
17641767
(i < c_MaxClients) ? m_Ping[i] : 0,

Managers/NetworkServer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ namespace RTE {
219219

220220
std::string m_ServerPort; //!<
221221

222-
ClientConnection m_ClientConnections[c_MaxClients]; //!<
222+
std::array<ClientConnection, c_MaxClients> m_ClientConnections; //!<
223223

224224
bool m_UseNATService; //!< Whether a NAT service is used for punch-through.
225225
RakNet::NatPunchthroughClient m_NATPunchthroughClient; //!<
@@ -280,8 +280,8 @@ namespace RTE {
280280

281281
unsigned char m_SceneID; //!<
282282

283-
bool m_EndActivityVotes[c_MaxClients]; //!< Votes from each player required to return to the Multiplayer Lobby.
284-
bool m_RestartActivityVotes[c_MaxClients]; //!< Votes from each player required to restart the current activity.
283+
std::array<bool, c_MaxClients> m_EndActivityVotes; //!< Votes from each player required to return to the Multiplayer Lobby.
284+
std::array<bool, c_MaxClients> m_RestartActivityVotes; //!< Votes from each player required to restart the current activity.
285285

286286
long long m_LatestRestartTime; //!< The time, in ticks, that the last activity restart took place on the server.
287287

0 commit comments

Comments
 (0)