how to make recognizable a cvar inside g_main.c from bg_pmov

Locked
3xistence
Posts: 90
Joined: Sun May 13, 2012 3:02 pm

how to make recognizable a cvar inside g_main.c from bg_pmov

Post by 3xistence »

Hi
There's any way in order to use a game cvars in order to alter the bg_pmove.c stuff?
Let me be more clear:
I got a cvar inside g_main.c and g_local.c, this cvar needs to alter, if active, some code inside bg_pmove.c where the code was replaced by a if ( g_fwp.integer == 1 ) {
} else {

obviously bg_pmove doesn't recognize the cvar, any way to extern the cvar in order to be recognized also in bg_pmove?
The cvar will need to be modified by Callvote func

checking and trying to find a way from here
http://www.quake3world.com/forum/viewto ... 16&t=34526
themuffinman
Posts: 384
Joined: Fri Mar 05, 2010 5:29 pm

Re: how to make recognizable a cvar inside g_main.c from bg_pmov

Post by themuffinman »

A couple of ways that I've used before:

1. copy the method they used for pmove_msec: add identically named cvars to game and cgame, add an int or float to pmove_t and set it to the cvar value through ClientThink_real().

2. First create a bg_cvars.h file, include it in bg_pmove.c, g_local.h and cg_local.h. Add identically named cvars to game and cgame and add an extern declaration for it in bg_cvars.h.

There's another possible way (untested) that may actually be the proper way of doing it. Make that bg_cvars.h listed in point 2. Create a bg_main.c file, add it to your makefile near the top of the listing, include q_shared.h in bg_main.c, copy over the cvarTable_t struct from g_main.c, make a table like gameCvarTable and create new cvars there just like you'd do in game or cgame but using bg_cvars.h (as opposed to g_local.h or cg_local.h) for your declaration.
3xistence
Posts: 90
Joined: Sun May 13, 2012 3:02 pm

Re: how to make recognizable a cvar inside g_main.c from bg_pmov

Post by 3xistence »

thanks muffin. I added you, i think, also on QL. i think i will use the second option. Did you managed the ramp jump stuff?
themuffinman
Posts: 384
Joined: Fri Mar 05, 2010 5:29 pm

Re: how to make recognizable a cvar inside g_main.c from bg_pmov

Post by themuffinman »

3xistence wrote:thanks muffin. I added you, i think, also on QL. i think i will use the second option. Did you managed the ramp jump stuff?
Yep got it exactly the same as in Q2... spotted it while I was porting over Q2 physics. It was incredibly easy to add. In PM_CheckJump you change this:

Code: Select all

pm->ps->velocity[2] = JUMP_VELOCITY;
...to this...

Code: Select all

pm->ps->velocity[2] += JUMP_VELOCITY;
That's all it is... additive jump velocity. Then you can just cap the velocity so it doesn't get out of hand. Q2 caps the it to about 1.6 * JUMP_VELOCITY, I did 1.75 instead.
3xistence
Posts: 90
Joined: Sun May 13, 2012 3:02 pm

Re: how to make recognizable a cvar inside g_main.c from bg_pmov

Post by 3xistence »

sorry for the question but add the cvar also on cgame is necessary also if this cvar will be used only by server and can be called only with callvote? i need also to understand how to force a map_restart when the cvar get modified after the callvote g _aircontrol 1 etc...
themuffinman
Posts: 384
Joined: Fri Mar 05, 2010 5:29 pm

Re: how to make recognizable a cvar inside g_main.c from bg_pmov

Post by themuffinman »

Because 'bg' stands for 'both games', in other words cgame + game and sometimes ui. So you have to include it in both.

For the callvote thing you can check out Cmd_CallVote_f in g_cmds.c. Add your cvar as an extra option and do some copy + pasting of the map_restart section.
3xistence
Posts: 90
Joined: Sun May 13, 2012 3:02 pm

Re: how to make recognizable a cvar inside g_main.c from bg_pmov

Post by 3xistence »

[SOLVED]

the second way was the best one, i assigned the CVARs only on game like CVARS_SERVERINFO,
now i need only to add a map_restart everytime the cvar changes and create the stuff for ruleset.

I'm actually working a lot on hud and graphic (ever with this weird monospaced stuff because i'm still unable to turn on the TA fonts) and game behaviour. The UI sucks a lot but for now everything looks to works well.

There's a way in order to log stuff when the game crashes? (it happends only on one new gametype)
Locked