Inside3D!
     

FuhQuake: Server Aliases as Temporary

 
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming
View previous topic :: View next topic  
Author Message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Tue Jan 05, 2010 6:37 am    Post subject: FuhQuake: Server Aliases as Temporary Reply with quote

Most of the Quakeworld engines clear server aliases on map change.

According to Spike, I guess the main driver of this is that Quakeworld engines save aliases to a config.

I'm more interested in this functionality to avoid infinite accumulation of aliases in a NetQuake client that connects from server to server or even if the server performs a mod switch (which doesn't really happen today, but that's going to be changing).

In NetQuake and probably original Quakeworld, if you connect to a server, it might send you several aliases to play the mod more efficiently. Some mods have a ton of these like CRMOD, CTF, RuneQuake, NQ Team Fortress.

If you switch to a different server, these aliases persist and the effects of the alias on the new server you have connected to is impredictable.

Quote:
For instance:

This might be what is sent to a client on some server with a hook.

ALIAS +HOOK "IMPULSE 97"
ALIAS -HOOK "IMPULSE 98"

If you connect to a different server with no hook, and you have +hook bound to a key, what is going to do on this no hook server?

Impulse 97 might something like detonate a bomb or go observer or even an admin impulse. You don't know.


FuhQuake implementation

Studying the FuhQuake implementation I see in cmd.c ...

Quote:
//Creates a new command that executes a command string (possibly ; separated)
void Cmd_Alias_f (void) {
cmd_alias_t *a;
char *s;
int c, key;

c = Cmd_Argc();
if (c == 1) {
Com_Printf ("%s <name> <command> : create or modify an alias\n", Cmd_Argv(0));
Com_Printf ("aliaslist : list all aliases\n");
return;
}

s = Cmd_Argv(1);
if (strlen(s) >= MAX_ALIAS_NAME) {
Com_Printf ("Alias name is too long\n");
return;
}

key = Com_HashKey(s);

// if the alias already exists, reuse it
for (a = cmd_alias_hash[key]; a; a = a->hash_next) {
if (!Q_strcasecmp(a->name, s)) {
Z_Free (a->value);
break;
}
}

if (!a) {
a = Z_Malloc (sizeof(cmd_alias_t));
a->next = cmd_alias;
cmd_alias = a;
a->hash_next = cmd_alias_hash[key];
cmd_alias_hash[key] = a;
}
strcpy (a->name, s);

a->flags = 0;
if (!Q_strcasecmp(Cmd_Argv(0), "aliasa"))
a->flags |= ALIAS_ARCHIVE;

#ifndef SERVERONLY
if (cbuf_current == &cbuf_svc)
a->flags |= ALIAS_SERVER;
// Baker: flag aliases as from server

if (!Q_strcasecmp(Cmd_Argv(0), "tempalias"))
a->flags |= ALIAS_TEMP;
#endif


// copy the rest of the command line
a->value = CopyString (Cmd_MakeArgs(2));
}


And if a disconnect occurs ...

Quote:
void CL_Disconnect (void) {
byte final[10];

connect_time = 0;
cl.teamfortress = false;

VID_SetCaption("FuhQuake");

// stop sounds (especially looping!)
S_StopAllSounds (true);

MT_Disconnect();

if (cls.demorecording && cls.state != ca_disconnected)
CL_Stop_f();

if (cls.demoplayback) {
CL_StopPlayback();
} else if (cls.state != ca_disconnected) {
final[0] = clc_stringcmd;
strcpy (final + 1, "drop");
Netchan_Transmit (&cls.netchan, 6, final);
Netchan_Transmit (&cls.netchan, 6, final);
Netchan_Transmit (&cls.netchan, 6, final);
}

memset(&cls.netchan, 0, sizeof(cls.netchan));
cls.state = ca_disconnected;

Cam_Reset();

if (cls.download) {
fclose(cls.download);
cls.download = NULL;
}

CL_StopUpload();
DeleteServerAliases(); \\ Baker: this deletes the server aliases on disconnect
}


And then look through all the aliases and delete where applicable:

Code:
void DeleteServerAliases(void) {
   extern cmd_alias_t *cmd_alias;
   cmd_alias_t   *a;

   for (a = cmd_alias; a; a = a->next) {
      if (a->flags & ALIAS_SERVER)
         Cmd_DeleteAlias(a->name);
   }
}


Some NQ engines have unalias and unaliasall type of commands already, although this is not a feature of GLQuake. FitzQuake for sure. ProQuake 4 has unalias but not unaliasall (couldn't think of a need for that at the time). Qrack has neither.
Back to top
View user's profile Send private message
r00k



Joined: 13 Nov 2004
Posts: 483

PostPosted: Tue Jan 05, 2010 6:48 am    Post subject: Reply with quote

i use the "unalias" commands.
Code:

/*
===============
Cmd_Unaliasall_f -- johnfitz
===============
*/
void Cmd_Unaliasall_f (void)
{
   cmdalias_t   *blah;

   while (cmd_alias)
   {
      blah = cmd_alias->next;
      Z_Free(cmd_alias->value);
      Z_Free(cmd_alias);
      cmd_alias = blah;
   }
}

and this just use this
Code:

void CL_Disconnect_f (void)
{
   // We have to shut down webdownloading first
   if( cls.download.web )
   {
      cls.download.disconnect = true;
      return;
   }
   
   Cbuf_InsertText ("unaliasall\n");//R00k Clean out alias commands from server to server.

   CL_Disconnect ();
   if (sv.active)
      Host_ShutdownServer (false);
}


poof no alias carry over from crmod to ca to runequake Smile
Back to top
View user's profile Send private message
Baker



Joined: 14 Mar 2006
Posts: 1538

PostPosted: Tue Jan 05, 2010 6:55 am    Post subject: Reply with quote

I think the above would need modification to mark server aliases. Otherwise you are going to lose them all, even the ones in a player's autoexec.cfg file.

/I checked for the unalias command in Qrack but I guess I have 1.85 on this machine and not the current version. Oops! Sad
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Inside3d Forums Forum Index -> Engine Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2004 phpBB Group