Hello!
Im making here my dynamic hud but have a question.
PHP Code:
new dhud_enable[192]
// i did skip code parts what have anything to do with my question, i also have few other things there right now...
// here is how i create dynamic hud
stock add_dynamichud()
{
new a
for(a = 0; a < 192; a++)
{
if( !dhud_enable[a] ) return a
}
}
// here is how i remove
dhud_enable[dhudid] = 0
here is dynamic hud thinking
public f_think_25fps()
{
static a
for(a = 0; a < 192; a++) if( dhud_enable[a] ) dhud_think(a)
}
dhud_think(dhudID)
{
// here come some dynamic effects :)
}
with this code in f_think_25fps() loop does useless checks
example if i have only 25 dynamic hud messages right now, loop will check 192 what is maximum number of dhuds.
but i cant also create variable what count dhud count and then but it into loop line like this
PHP Code:
for(a = 0; a < dhud_count; a++)
there will be always small or even big holes.
so i took a new way.
creating variable that holds dhud_enable[this number].
example in the variable dhud_enable :
{
1,
0,
0,
1,
1,
0,
1,
0,
0,
0,
...
}
you see 0 is a hole, no needed thing. all 0-s must be in the end but cant do this with one variable so new variable help.
inside of new variable:
{
0,
3,
4,
6,
-1,
-1,
-1,
...
}
this variable tell the system where are 1-s in dhud_enable
new code:
PHP Code:
new a, b
for(a = 0; a < dhudcount; a++)
{
b = newvariable; dhud_think(b)
using way 2 make things more complex ( for me not for cpu : ) )
here comes my question, do i really need to use that new way or the first way is not that bad and does not take so many cpu by doing useless checking?