Quake3World.com Forums
     Programming Discussion
        passing strings from cgame to game


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




Print view Previous topic | Next topic 
Topic Starter Topic: passing strings from cgame to game

Recruit
Recruit
Joined: 14 Feb 2010
Posts: 4
PostPosted: 07-29-2011 08:29 AM           Profile Send private message  E-mail  Edit post Reply with quote


getting frustrated trying to get this to work

I have a cvar (vmCvar_t gear ) in the config file that I can read using gear.string, from inside cg_ files, no problem there, but I need to pass that string to game files, specifically g_weapon.c and g_client.c. I am really struggling to get this to work.

I tried creating a variable in bg_ that I can use to hold the data, but when I print out the variable inside g_client.c it's value is NULL.
I have had no problems passing other types of data this way, but passing a string of characters just isn't working for me.

Any suggestions on how to accomplish this.




Top
                 

Mentor
Mentor
Joined: 12 Mar 2005
Posts: 3958
PostPosted: 07-29-2011 10:19 AM           Profile Send private message  E-mail  Edit post Reply with quote


Keep in mind that the client and server may run on different machines so global variables are definitely not the way to go. Grep the source for `CG_ConfigString` and `trap_SetConfigstring`, that'll show you how to pass data between them.




Top
                 

Recruit
Recruit
Joined: 14 Feb 2010
Posts: 4
PostPosted: 08-01-2011 05:27 AM           Profile Send private message  E-mail  Edit post Reply with quote


So `CG_ConfigString` and `trap_SetConfigstring` both appear to pass info to cgame from game, server to client . The opposite of what I need. I needed to pass info from a cvar on the client to the server. I figured out how to do it, and it was very easy and straight forward. Look into Info_ValueForKey( ). I passed the info in the clientinfo config string.




Top
                 

Commander
Commander
Joined: 06 Oct 2006
Posts: 148
PostPosted: 11-14-2012 07:53 AM           Profile Send private message  E-mail  Edit post Reply with quote


Does anyone know of another way a cvar could be passed from cgame to game without using Info_ValueForKey()?




Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44136
PostPosted: 11-14-2012 08:38 AM           Profile   Send private message  E-mail  Edit post Reply with quote


You oughta specify why the original solution is insufficient for you. Now it's kind of guessing what you need.




Top
                 

Commander
Commander
Joined: 06 Oct 2006
Posts: 148
PostPosted: 11-14-2012 10:11 AM           Profile Send private message  E-mail  Edit post Reply with quote


I am trying to reverse engineer a mod in order to make mine compatible with it. I printf what gets passed through Info_ValueForKey and that method is not being used to pass the data. How else could the data get sent from cgame to game?




Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44136
PostPosted: 11-14-2012 09:31 PM           Profile   Send private message  E-mail  Edit post Reply with quote


Info_ValueForKey doesn't send any data, it's a helper function to read data from a special kind of string that contains key/value pairs. The clue is the bit about clientinfo. That is client specific data that's transmitted to the server




Top
                 

Commander
Commander
Joined: 06 Oct 2006
Posts: 148
PostPosted: 11-15-2012 06:41 AM           Profile Send private message  E-mail  Edit post Reply with quote


Yes, I have checked there to by issuing the clientinfo command, but unfortunately the data is not being stored in there. Any other ways of transferring data between cgame and game??




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.