]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
-Added $parameter parsing to the alias and $cvar parsing to the cmd system.
authorblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 19 Jul 2005 20:53:45 +0000 (20:53 +0000)
committerblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 19 Jul 2005 20:53:45 +0000 (20:53 +0000)
E.g.:
alias test "connect $1"
test "127.0.0.1"
set testcvar "127.0.0.1"
connect $testcvar
TODO: Add the extension description and the extension to the extension list.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5539 d7cf8633-e32d-0410-b094-e92efae38249

cmd.c
common.c
todo

diff --git a/cmd.c b/cmd.c
index 41c38794562dbf90b5ab7bfec9a135bb3dad0274..870f18090b99ffca8fbbbefb53e22e363e381f0c 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -394,6 +394,51 @@ cmd_source_t cmd_source;
 
 static cmd_function_t *cmd_functions;          // possible commands to execute
 
+/*
+============
+Cmd_ExecuteAlias
+
+Called for aliases and fills in the alias into the cbuffer
+============
+*/
+static void Cmd_ExecuteAlias (cmdalias_t *alias)
+{
+       const char *text = alias->value;
+       
+       while( COM_ParseTokenConsole( &text ) ) 
+       {
+               Cbuf_AddText( "\"" );
+
+               if( com_token[0] == '$' )
+               {
+                       int argNum;
+                       argNum = atoi( &com_token[1] );
+
+                       // no number at all?
+                       if( argNum == 0 )
+                       {
+                               Cbuf_AddText( com_token );
+                       }
+                       else if( argNum >= Cmd_Argc() )
+                       {
+                               Con_Printf( "Warning: Not enough parameters passed to alias '%s', at least %i expected:\n    %s\n", alias->name, argNum, alias->value );
+                               Cbuf_AddText( com_token );
+                       }
+                       else
+                       {
+                               Cbuf_AddText( Cmd_Argv( argNum ) );
+                       }
+               }
+               else 
+               {
+                       Cbuf_AddText( com_token );
+               }
+
+               Cbuf_AddText( "\"" );
+       }
+       Cbuf_AddText( "\n" );
+}
+
 /*
 ========
 Cmd_List
@@ -836,7 +881,7 @@ void Cmd_ExecuteString (const char *text, cmd_source_t src)
        {
                if (!strcasecmp (cmd_argv[0], a->name))
                {
-                       Cbuf_InsertText (a->value);
+                       Cmd_ExecuteAlias(a);
                        cmd_tokenizebufferpos = oldpos;
                        return;
                }
index a8d0a9f43d262cfe40a7ee85db488d4e017751d8..3849138cf84d61093ee7d6c3ebc58259f125ca63 100644 (file)
--- a/common.c
+++ b/common.c
@@ -783,7 +783,6 @@ skipwhite:
                }
                com_token[len] = 0;
                *datapointer = data+1;
-               return true;
        }
        else
        {
@@ -800,8 +799,30 @@ skipwhite:
                }
                com_token[len] = 0;
                *datapointer = data;
-               return true;
        }
+
+       // check for $cvar
+       if (com_token[0] == '$' && com_token[1]) 
+       {
+               cvar_t *cvar;
+
+               cvar = Cvar_FindVar(&com_token[1]);
+               if (cvar)
+               {
+                       strcpy(com_token, cvar->string);
+               }
+               else if( com_token[1] == '$' )
+               {
+                       // remove the first $
+                       char *pos;
+               
+                       for( pos = com_token ; *pos ; pos++ )
+                       {
+                               *pos = *(pos + 1);
+                       }
+               }
+       }
+       return true;
 }
 
 
diff --git a/todo b/todo
index 44e798122879e742bdb4c4a44c9a51406b5257c0..afa64721e26671e01a328a45a3b2abe9e9d51c2f 100644 (file)
--- a/todo
+++ b/todo
 -d (flum) bug darkplaces client: corona on your own muzzleflash is annoying when looking down because it can be seen, disable corona on all muzzleflashes (flum)
 -d (mashakos) bug darkplaces input: fix the mouse move when console is raised in glx, probably by ignoring the first move after console raise (mashakos)
 -d (romi) feature darkplaces editlights: add coronasize setting to rtlights (romi)
--d feature darkplaces server: add sv_playerphysicsqc cvar to allow engine to ignore SV_PlayerPhysics function, this would also have to change the reported extensions (Gleeb)
+-d feature darkplaces server: add sv_playerphysicsqc cvar to allow engine to ignore 
+SV_PlayerPhysics function, this would also have to change the reported extensions (Gleeb)
+-d bug darkplaces prvm: assignment to world is not producing an error after world spawn stage (Spike)
+-d feature darkplaces server: add filename/line number reporting to progs stack and opcode printouts (Spike)
+-d feature darkplaces console: expand parameters such as $cvar to use the value of the cvar, DP_CON_EXPANDCVAR (up2nogood)
+-d feature darkplaces console: make aliases given parameters insert the parameters in place of $1, $2, $* macros in the alias string, add this as DP_CON_ALIASPARAMETERS (up2nogood)
 0 bug darkplaces WGL client: figure out why GDI input has stuttering problems with gl_finish 0 mode (Kinn, Urre, romi, Spike, Black)
 0 bug darkplaces WGL client: fix GDI input init/shutdown, it is using weird mouse acceleration and not restoring it on exit (innovati)
 0 bug darkplaces WGL/GLX/SDL client bug: if sound is unavailable (causing a freeze waiting for it to become available), the config is reset (SavageX)
@@ -44,7 +49,6 @@
 0 bug darkplaces protocol: models sometimes staying in nexuiz after a big battle, entities that don't exist on the server anymore (Spike)
 0 bug darkplaces protocol: sometimes players are invisible in nexuiz, showing only their gun model, this may be related to svc_precache messages not being sent during signon (Vermeulen)
 0 bug darkplaces prvm: add back the leak checking http://cvs.icculus.org/cvs/twilight/darkplaces/prvm_cmds.c?r1=1.67&r2=1.68 (Black)
-0 bug darkplaces prvm: assignment to world is not producing an error after world spawn stage (Spike)
 0 bug darkplaces renderer: animated textures are not being lit by static rtlights (LordHavoc)
 0 bug darkplaces renderer: do bloom effect before world crosshair and coronas and things (KrimZon)
 0 bug darkplaces renderer: lit sprites (which use R_CompleteLightPoint) are being lit blue by glow_color 108 dlights (Cheapy)
 0 feature darkplaces server: add a DP_QC_WARNING extension which has a "warning" builtin that does a PF_WARNING just to print the requested message, opcode dump, and stack trace (FrikaC)
 0 feature darkplaces server: add a clipmask thingy to allow QC to mask off collisions as it wishes (Uffe)
 0 feature darkplaces server: add cl_prydoncursor_centeredcursor cvar and PRYDON_CLIENTCURSOR_CENTEREDCURSOR extension (Wazat)
-0 feature darkplaces server: add filename/line number reporting to progs stack and opcode printouts (Spike)
 0 feature darkplaces server: add sv_antilag cvar which would upgrade the aim() builtin to aim at the creature the player's prydon cursor trace was hitting (Spike)
 0 feature darkplaces server: make fopen builtin have the ability to disable fopen builtin access to read /, read data/, write data/, or disable fopen builtin entirely
 0 feature darkplaces server: make noclip/fly cheats use MOVETYPE_CHEATNOCLIP/MOVETYPE_CHEATFLY which would have the nicer movement interface (Spikester)
 2 feature darkplaces client: make CL_Video use TEXF_FRAGMENT again by adding general, transparent support for it in all drawqueue functions (so you dont need to call FragmentLocation) (Black)
 2 feature darkplaces client: make tab completion able to complete map names when using a map or changelevel command (Zenex)
 2 feature darkplaces console: add a "maps" command which takes the list from "dir maps/*.bsp" and prints the actual names of all the levels according to their worldspawn.message keys (RPG, Zenex)
-2 feature darkplaces console: expand parameters such as $cvar to use the value of the cvar, DP_CON_EXPANDCVAR (up2nogood)
-2 feature darkplaces console: make aliases given parameters insert the parameters in place of $1, $2, $* macros in the alias string, add this as DP_CON_ALIASPARAMETERS (up2nogood)
 2 feature darkplaces image: add scaling capabilities to Image_CopyMux
 2 feature darkplaces loader: add support for fuhquake naming of map textures (textures/start/quake.tga style)
 2 feature darkplaces menu: implement menu_clearkeyconfig and menu_keyconfig and the corresponding menu (diGGer)