danielkrupinski / Osiris

Cross-platform game hack for Counter-Strike 2 with Panorama-based GUI.
MIT License
3.31k stars 961 forks source link

Optimize entity loops #996

Closed ClaudiuHKS closed 11 months ago

ClaudiuHKS commented 4 years ago

I am not sure if it's better, I am just giving an idea of a change.

Osiris\Hacks\Glow.cpp

for (int i = 65; i <= interfaces.entityList->getHighestEntityIndex(); i++) {for (int i = interfaces.engine->getMaxClients() + 1; i <= interfaces.entityList->getHighestEntityIndex(); i++) {

Osiris\Hacks\SkinChanger.cpp

for (int i = 65; i <= interfaces.entityList->getHighestEntityIndex(); i++) {for (int i = interfaces.engine->getMaxClients() + 1; i <= interfaces.entityList->getHighestEntityIndex(); i++) {

Osiris\Hacks\Misc.cpp

for (int i = interfaces.engine->getMaxClients(); i <= interfaces.entityList->getHighestEntityIndex(); i++) {for (int i = interfaces.engine->getMaxClients() + 1; i <= interfaces.entityList->getHighestEntityIndex(); i++) {

danielkrupinski commented 4 years ago

Isn't maxclients always set to 64? https://wiki.alliedmods.net/CSGO_Quirks#The_engine.27s_Maxclients

ClaudiuHKS commented 4 years ago

You're right, both interfaces.engine->getMaxClients() and memory.globalVars->maxClients return 64. But in my opinion, it looks better when not hard coded. Of course, you decide about it.

woah1337 commented 4 years ago

changing it to getmaxclients() will actually become a little less optimized since your calling a virtual method every tick rather than hardcoding a value that doesn't change anyways.