Add lots of memory safety to client interface

This commit is contained in:
Lion Kortlepel
2020-11-08 02:50:17 +01:00
parent 96668add6e
commit 26383d5346
8 changed files with 38 additions and 29 deletions

View File

@@ -240,9 +240,10 @@ int lua_Sleep(lua_State* L) {
return 1;
}
Client* GetClient(int ID) {
for (Client* c : CI->Clients) {
if (c != nullptr && c->GetID() == ID)
return c;
for (auto& c : CI->Clients) {
if (c != nullptr && c->GetID() == ID) {
return c.get();
}
}
return nullptr;
}
@@ -295,7 +296,7 @@ int lua_GetDID(lua_State* L) {
int lua_GetAllPlayers(lua_State* L) {
lua_newtable(L);
int i = 1;
for (Client* c : CI->Clients) {
for (auto& c : CI->Clients) {
if (c == nullptr)
continue;
lua_pushinteger(L, c->GetID());