[MODDING] "cent->currentState.density"


(Madras) #1

Hi! What should I do to use “cent->currentState.density” in CG_DrawWeapRecharge in cg_draw.c. I tried to add this line on the begin of the function:

centity_t *cent;

but the compiler returns that “cent” variable is uninitialized. So help me to correct pass this variable to the function. I looked for another funcs which use currentState.density and they have got centity_t *cent in () only. But I can’t do that way because I’d have to change a tons of code.

Sorry for my quite basic questions, but I got a lots of ideas and could’t solve some of them myself. However my C++ skill rises. :wink:

Greetings!


(Shanks) #2

It needs to be initialized before you can use it. Something like this should work:
cent = &cg_entities[cg.snap->ps.clientNum];


(Madras) #3

Compiler doesn’t return any error, but it didn’tt work out.
I wrote on the begin of function:


centity_t *cent;
cent = &cg_entities[cg.snap->ps.clientNum];

and referention in this function:

if( cent->currentState.density == 0 )

This condition always returns TRUE.

I wanna add ETPro fire support unavailable red power bolt.

I found in cg_event.c fragment with switch, so I thought that is suitable for my purposes.


switch( cent->currentState.density ) {
	case 0: // too many called
		[...]
		break;
	case 1: // aborting can't see target
		[...]
		break;
	case 2: // firing for effect
		[...]
		break;
}

Unfortunately when I set “cent = &cg_entities[cg.snap->ps.clientNum];” the bolt always is red, so “if” expression always is equal to NULL. ;/ :confused:

But thanks for quick reply Bacon.


(Madras) #4

Still waiting for answer. Thanks.