PDA

View Full Version : I need an explanation of a define


Alucard^
06-13-2010, 03:44
Hi,

Well, nothing... i just don't understand this code:

#define MAX_ENTS 900 + MAX_PLAYERS * 15
#define HOLDING_ENTS_ARRAY_SIZE (MAX_ENTS / 32) + _:!!(MAX_ENTS % 32)

Something can explain me this?

Also, apart of this... i see in some codes using two "!!", like in the code above... what means that?

Thanks

hleV
06-13-2010, 04:26
MAX_ENTS simply tells how many entities can possibly be in the map. So instead of writing "900 + MAX_PLAYERS * 15" all the time, you use MAX_ENTS.

!! means "no" to "no", but giving you a bool value (1 or 0). If you had number 10, it will return number 1, if you had 0, you'll get 0.
new Number = 20;
Number = !Number // Number is now 0 ("not 20")
Number = 20;
Number = !!Number; // Number is now 1 ("not 20" is 0, "not 0" is 1)
The "HOLDING_ENTS_ARRAY_SIZE" define is probably used to set the side of an array which holds the data of (all?) entities.

I'm not really familiar with "%", I'm afraid.

ConnorMcLeod
06-13-2010, 04:45
According to arkshine,

900 + MAX_PLAYERS * 15

should be replaced with :

900 + (MAX_PLAYERS-1) * 15

not that in plugins you can see, MAX_PLAYERS is 32 because they are public, but if you make a private plugin you can replace it with the real maxplayer amount of your server.

Arkshine
06-13-2010, 05:20
Don't why they remove -1 ; it would make sense to use MAX_PLAYERS.

Alucard^
06-13-2010, 10:06
I know the basic things -.- like define and others... i added the first define so you can understand the second define.

The part that i didn't understand at all is exactly this:

_:!!(MAX_ENTS % 32)

Thanks hleV for the !! explanation...

@ Connor

The code is used in your plugin kz buttonlocs xd

Thanks to all

wrecked_
06-13-2010, 12:26
@Alucard^
The % operator is the modulo operator. It returns the remainder after division. So if you did 8 % 5, you'd get 3 as a return value. The _: "untags" certain things. For example, if you did something likenew iTeam = _:cs_get_user_team( id )

// tag mismatch
if( cs_get_user_team( id ) == CS_TEAM_T ) {}

// untagged, so it is not a mismatch
if( cs_get_user_team( id ) == 1 ) {}

Alucard^
06-13-2010, 12:34
Oh thanks...

About the _: thing... if i understand is for not use the enum things right?

Thanks

wrecked_
06-13-2010, 12:39
Yes, it's more commonly used to detag members of an enum (don't know the pawn terminology for member).

No problem.

Arkshine
06-13-2010, 18:37
// no tag mismatch whether iTeam is tagged or not.
if( iTeam == CS_TEAM_T )

For your information, CS_TEAM_T is tagged, you will get a tag mismatch since iTeam is not tagged.