File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ g_clients.cpp implementation.*/
77
88#include < algorithm>
99#include < cstddef>
10+ #include < new>
1011
1112namespace {
1213 int ClampMaxClients (int maxClients) {
@@ -65,6 +66,9 @@ void AllocateClientArray(int maxClients) {
6566 const std::size_t lagCount = static_cast <std::size_t >(game.maxClients ) * static_cast <std::size_t >(game.maxLagOrigins );
6667 game.lagOrigins = static_cast <Vector3*>(TagMallocChecked (sizeof (Vector3) * lagCount));
6768
69+ for (std::size_t i = 0 ; i < lagCount; ++i)
70+ new (&game.lagOrigins [i]) Vector3 ();
71+
6872 // [KEX]: Ensure client pointers are linked immediately to prevent engine crashes
6973 // if SV_CalcPings runs before a client is fully connected.
7074 if (g_entities) {
@@ -86,6 +90,14 @@ void FreeClientArray() {
8690 DestroyClients (game.clients , game.maxClients );
8791
8892 TagFreeChecked (game.clients );
93+
94+ if (game.lagOrigins ) {
95+ const std::size_t lagCount = static_cast <std::size_t >(game.maxClients ) * static_cast <std::size_t >(game.maxLagOrigins );
96+
97+ for (std::size_t i = 0 ; i < lagCount; ++i)
98+ game.lagOrigins [i].~Vector3 ();
99+ }
100+
89101 TagFreeChecked (game.lagOrigins );
90102
91103 game.clients = nullptr ;
You can’t perform that action at this time.
0 commit comments