session stuff

Discussions about ET modding (sdk code, player/weapon modeling)

Moderators: Forum moderators, developers

Post Reply
ensiform
Posts: 3
Joined: Fri Sep 30, 2005 4:43 pm

session stuff

Post by ensiform »

hey bani would it be possible to go into more detail on how to make this work?

http://www.quakesrc.org/forums/viewtopi ... 7407#47407

if done this:

g_local.h :

Code: Select all

clientSession_t		*g_sess;
g_session.c:

Code: Select all

/*
==================
G_WriteSessionData

==================
*/
void G_WriteSessionData( void ) {
	int		i;

	trap_Cvar_Set( "session", va2("%i", g_gametype.integer) );

	/*for &#40; i = 0 ; i < level.maxclients ; i++ &#41; &#123;
		if &#40; level.clients&#91;i&#93;.pers.connected == CON_CONNECTED &#41; &#123;
			G_WriteClientSessionData&#40; &level.clients&#91;i&#93; &#41;;
		&#125;
	&#125;*/
	for&#40; i=0; i < g_maxclients.integer; i++ &#41; &#123;
		g_sess&#91;i&#93; = level.clients&#91;i&#93;.sess;
	&#125;
&#125;

void G_InitSess&#40; gclient_t *client &#41; &#123;
	char		gsessptr&#91;MAX_STRING_CHARS&#93;;

	// bani - allocate client persistent session data
	trap_Cvar_VariableStringBuffer&#40; "gsess", gsessptr, sizeof&#40; gsessptr &#41; &#41;;
	if&#40; !Q_stricmp&#40; gsessptr, "" &#41; &#41; &#123;
		g_sess = malloc&#40; g_maxclients.integer * sizeof&#40; clientSession_t &#41; &#41;;
		trap_Cvar_Set&#40; "gsess", va2&#40; "%p", g_sess &#41; &#41;;
		memset&#40; g_sess, 0, g_maxclients.integer * sizeof&#40; clientSession_t &#41; &#41;;
	&#125; else &#123;
		sscanf&#40; gsessptr, "%p", &g_sess &#41;;
	&#125; 
&#125;

void G_ReadSess&#40; gclient_t *client &#41; &#123;
	client->sess = g_sess&#91;client->ps.clientNum&#93;;
&#125;
then i called read, write, init appropriately in the spots in g_client.c

seems okay afaik on first load but when i go to restart or something crashes, i havent attempted to debug yet for 1 cause i dont even think im actually doing it right but i dunno.

gsess atm = 02441E18
ensiform
Posts: 3
Joined: Fri Sep 30, 2005 4:43 pm

Post by ensiform »

im trying this in Jedi Academy btw.
ensiform
Posts: 3
Joined: Fri Sep 30, 2005 4:43 pm

Post by ensiform »

got it working took a bit of hacking i just need to get IPstring in session to stay even over gametype change, ill report back when i have it all working.
Post Reply