Quake3World.com Forums
     Programming Discussion
        how to make recognizable a cvar inside g_main.c from bg_pmov


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: how to make recognizable a cvar inside g_main.c from bg_pmov

Warrior
Warrior
Joined: 13 May 2012
Posts: 90
PostPosted: 03-24-2013 07:31 AM           Profile Send private message  E-mail  Edit post Reply with quote


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/viewtopic.php?f=16&t=34526




Top
                 

Insane Quaker
Insane Quaker
Joined: 05 Mar 2010
Posts: 384
PostPosted: 03-24-2013 11:22 PM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Warrior
Warrior
Joined: 13 May 2012
Posts: 90
PostPosted: 03-26-2013 01:06 PM           Profile Send private message  E-mail  Edit post Reply with quote


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?




Top
                 

Insane Quaker
Insane Quaker
Joined: 05 Mar 2010
Posts: 384
PostPosted: 03-27-2013 10:26 AM           Profile Send private message  E-mail  Edit post Reply with quote


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:
pm->ps->velocity[2] = JUMP_VELOCITY;


...to this...

Code:
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.




Top
                 

Warrior
Warrior
Joined: 13 May 2012
Posts: 90
PostPosted: 04-03-2013 05:44 AM           Profile Send private message  E-mail  Edit post Reply with quote


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...




Top
                 

Insane Quaker
Insane Quaker
Joined: 05 Mar 2010
Posts: 384
PostPosted: 04-05-2013 01:45 AM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Warrior
Warrior
Joined: 13 May 2012
Posts: 90
PostPosted: 04-06-2013 04:12 PM           Profile Send private message  E-mail  Edit post Reply with quote


[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)




Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.