2004-08-21 01:25:48 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2005-07-03 15:16:20 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
// cmd.c -- Quake script command processing module
|
|
|
|
|
|
|
|
#include "quakedef.h"
|
2014-10-11 19:39:45 +00:00
|
|
|
#include "fs.h"
|
2004-08-21 01:25:48 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
cvar_t rcon_level = SCVAR("rcon_level", "20");
|
2006-02-11 02:09:43 +00:00
|
|
|
cvar_t cmd_maxbuffersize = SCVAR("cmd_maxbuffersize", "65536");
|
2010-07-18 08:42:59 +00:00
|
|
|
cvar_t dpcompat_set = SCVAR("dpcompat_set", "0");
|
2004-08-21 01:25:48 +00:00
|
|
|
int Cmd_ExecLevel;
|
2013-08-21 07:14:39 +00:00
|
|
|
qboolean cmd_didwait;
|
2014-06-24 03:02:32 +00:00
|
|
|
qboolean cmd_blockwait;
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
void Cmd_ForwardToServer (void);
|
|
|
|
|
|
|
|
#define MAX_ALIAS_NAME 32
|
|
|
|
|
|
|
|
typedef struct cmdalias_s
|
|
|
|
{
|
|
|
|
struct cmdalias_s *next;
|
2005-07-03 15:16:20 +00:00
|
|
|
char name[MAX_ALIAS_NAME];
|
2004-08-21 01:25:48 +00:00
|
|
|
char *value;
|
|
|
|
qbyte execlevel;
|
|
|
|
qbyte restriction;
|
|
|
|
int flags;
|
|
|
|
} cmdalias_t;
|
|
|
|
|
|
|
|
#define ALIAS_FROMSERVER 1
|
|
|
|
|
|
|
|
cmdalias_t *cmd_alias;
|
|
|
|
|
2014-03-30 08:55:06 +00:00
|
|
|
cvar_t cl_warncmd = CVARF("cl_warncmd", "1", CVAR_NOSAVE|CVAR_NORESET);
|
|
|
|
cvar_t cl_aliasoverlap = CVARF("cl_aliasoverlap", "1", CVAR_NOTFROMSERVER);
|
2004-08-21 01:25:48 +00:00
|
|
|
|
2014-03-30 08:55:06 +00:00
|
|
|
cvar_t tp_disputablemacros = CVARF("tp_disputablemacros", "1", CVAR_SEMICHEAT);
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define MAX_MACROS 64
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
char name[32];
|
|
|
|
char *(*func) (void);
|
2005-02-28 07:16:19 +00:00
|
|
|
int disputableintentions;
|
2004-08-21 01:25:48 +00:00
|
|
|
} macro_command_t;
|
|
|
|
|
|
|
|
static macro_command_t macro_commands[MAX_MACROS];
|
|
|
|
static int macro_count = 0;
|
|
|
|
|
2005-02-28 07:16:19 +00:00
|
|
|
void Cmd_AddMacro(char *s, char *(*f)(void), int disputableintentions)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < macro_count; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp(macro_commands[i].name, s))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == MAX_MACROS)
|
2004-08-21 01:25:48 +00:00
|
|
|
Sys_Error("Cmd_AddMacro: macro_count == MAX_MACROS");
|
2009-04-01 22:03:56 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
Q_strncpyz(macro_commands[macro_count].name, s, sizeof(macro_commands[macro_count].name));
|
2005-02-28 07:16:19 +00:00
|
|
|
macro_commands[macro_count].func = f;
|
|
|
|
macro_commands[macro_count].disputableintentions = disputableintentions;
|
2009-04-01 22:03:56 +00:00
|
|
|
|
|
|
|
if (i == macro_count)
|
|
|
|
macro_count++;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
2004-09-20 23:25:38 +00:00
|
|
|
char *TP_MacroString (char *s, int *len)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
macro_command_t *macro;
|
|
|
|
|
|
|
|
for (i = 0; i < macro_count; i++)
|
|
|
|
{
|
|
|
|
macro = ¯o_commands[i];
|
|
|
|
if (!Q_strcasecmp(s, macro->name))
|
|
|
|
{
|
2005-02-28 07:16:19 +00:00
|
|
|
if (macro->disputableintentions)
|
2009-11-04 21:16:50 +00:00
|
|
|
if (!tp_disputablemacros.ival)
|
2005-02-28 07:16:19 +00:00
|
|
|
continue;
|
2004-09-20 23:25:38 +00:00
|
|
|
if (len)
|
|
|
|
*len = strlen(macro->name);
|
2004-08-21 01:25:48 +00:00
|
|
|
return macro->func();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cmd_MacroList_f (void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!macro_count)
|
|
|
|
{
|
|
|
|
Con_Printf("No macros!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < macro_count; i++)
|
|
|
|
Con_Printf ("$%s\n", macro_commands[i].name);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=============================================================================
|
|
|
|
|
|
|
|
COMMAND BUFFER
|
|
|
|
|
|
|
|
=============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct {
|
|
|
|
sizebuf_t buf;
|
|
|
|
int noclear;
|
|
|
|
double waitattime;
|
|
|
|
} cmd_text[RESTRICT_MAX+1+MAX_SPLITS]; //max is local.
|
|
|
|
//RESTRICT_MAX+1 is the from sever buffer (max+2 is for second player...)
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cmd_Wait_f
|
|
|
|
|
|
|
|
Causes execution of the remainder of the command buffer to be delayed until
|
|
|
|
next frame. This allows commands like:
|
|
|
|
bind g "impulse 5 ; +attack ; wait ; -attack ; impulse 2"
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void Cmd_Wait_f (void)
|
|
|
|
{
|
2014-06-24 03:02:32 +00:00
|
|
|
if (cmd_blockwait)
|
|
|
|
return;
|
|
|
|
|
2013-08-21 07:57:17 +00:00
|
|
|
#ifndef CLIENTONLY
|
2013-08-21 07:14:39 +00:00
|
|
|
if (cmd_didwait && sv.state)
|
|
|
|
Con_DPrintf("waits without server frames\n");
|
2013-08-21 07:57:17 +00:00
|
|
|
#endif
|
2013-08-21 07:14:39 +00:00
|
|
|
cmd_didwait = true;
|
2005-07-03 15:16:20 +00:00
|
|
|
cmd_text[Cmd_ExecLevel].waitattime = realtime;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cbuf_Init
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void Cbuf_Init (void)
|
|
|
|
{
|
|
|
|
int level;
|
|
|
|
for (level = 0; level <= RESTRICT_MAX+1; level++)
|
|
|
|
cmd_text[level].waitattime = -1;
|
|
|
|
}
|
|
|
|
|
2014-10-11 19:39:45 +00:00
|
|
|
static void Cbuf_WorkerAddText(void *ctx, void *data, size_t a, size_t b)
|
|
|
|
{
|
|
|
|
Cbuf_AddText(data, a);
|
|
|
|
Z_Free(data);
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cbuf_AddText
|
|
|
|
|
|
|
|
Adds command text at the end of the buffer
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void Cbuf_AddText (const char *text, int level)
|
|
|
|
{
|
|
|
|
int l;
|
|
|
|
|
2014-10-14 16:42:48 +00:00
|
|
|
if (!Sys_IsMainThread())
|
2014-10-11 19:39:45 +00:00
|
|
|
{
|
|
|
|
COM_AddWork(0, Cbuf_WorkerAddText, NULL, Z_StrDup(text), level, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
if (level > sizeof(cmd_text)/sizeof(cmd_text[0]) || level < 0)
|
|
|
|
{
|
|
|
|
Con_Printf("Bad execution level\n");
|
|
|
|
return; //reject.
|
|
|
|
}
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
l = Q_strlen (text);
|
|
|
|
|
|
|
|
if (!cmd_text[level].buf.maxsize)
|
|
|
|
{
|
2006-05-07 05:31:01 +00:00
|
|
|
cmd_text[level].buf.data = (qbyte*)BZ_Malloc(8192);
|
2004-08-21 01:25:48 +00:00
|
|
|
cmd_text[level].buf.maxsize = 8192;
|
|
|
|
}
|
|
|
|
if (cmd_text[level].buf.cursize + l >= cmd_text[level].buf.maxsize)
|
|
|
|
{
|
|
|
|
int newmax;
|
|
|
|
|
|
|
|
newmax = cmd_text[level].buf.maxsize*2;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (newmax > cmd_maxbuffersize.ival && cmd_maxbuffersize.ival)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("%s: overflow\n", "Cbuf_AddText");
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
while (newmax < cmd_text[level].buf.cursize + l)
|
|
|
|
newmax*=2;
|
2006-05-07 05:31:01 +00:00
|
|
|
cmd_text[level].buf.data = (qbyte*)BZ_Realloc(cmd_text[level].buf.data, newmax);
|
2004-08-21 01:25:48 +00:00
|
|
|
cmd_text[level].buf.maxsize = newmax;
|
|
|
|
}
|
|
|
|
SZ_Write (&cmd_text[level].buf, text, Q_strlen (text));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cbuf_InsertText
|
|
|
|
|
|
|
|
Adds command text immediately after the current command
|
|
|
|
Adds a \n to the text
|
|
|
|
FIXME: actually change the command buffer to do less copying
|
|
|
|
============
|
|
|
|
*/
|
2006-02-06 01:06:17 +00:00
|
|
|
void Cbuf_InsertText (const char *text, int level, qboolean addnl)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
char *temp;
|
|
|
|
int templen;
|
|
|
|
|
|
|
|
if (level > sizeof(cmd_text)/sizeof(cmd_text[0]) || level < 0)
|
|
|
|
{
|
|
|
|
Con_Printf("Bad execution level\n");
|
|
|
|
return; //reject.
|
|
|
|
}
|
|
|
|
|
|
|
|
// copy off any commands still remaining in the exec buffer
|
|
|
|
templen = cmd_text[level].buf.cursize;
|
|
|
|
if (templen)
|
|
|
|
{
|
2005-03-28 00:11:59 +00:00
|
|
|
temp = (char*)Z_Malloc (templen+1);
|
2004-08-21 01:25:48 +00:00
|
|
|
Q_memcpy (temp, cmd_text[level].buf.data, templen);
|
|
|
|
SZ_Clear (&cmd_text[level].buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
temp = NULL; // shut up compiler
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
// add the entire text of the file
|
|
|
|
Cbuf_AddText (text, level);
|
2006-02-06 01:06:17 +00:00
|
|
|
if (addnl)
|
2014-02-11 17:51:29 +00:00
|
|
|
Cbuf_AddText ("\n", level);
|
2004-08-21 01:25:48 +00:00
|
|
|
// add the copied off data
|
|
|
|
if (templen)
|
|
|
|
{
|
|
|
|
temp[templen] = '\0';
|
|
|
|
Cbuf_AddText(temp, level);
|
|
|
|
// SZ_Write (&cmd_text[level].buf, temp, templen);
|
|
|
|
Z_Free (temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-05 15:23:40 +00:00
|
|
|
char *Cbuf_GetNext(int level, qboolean ignoresemicolon)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char *text;
|
|
|
|
int quotes;
|
|
|
|
static char line[1024];
|
|
|
|
|
|
|
|
start:
|
|
|
|
|
|
|
|
text = (char *)cmd_text[level].buf.data;
|
|
|
|
|
|
|
|
quotes = 0;
|
|
|
|
for (i=0 ; i< cmd_text[level].buf.cursize ; i++)
|
|
|
|
{
|
|
|
|
if (text[i] == '"')
|
|
|
|
quotes++;
|
2011-12-05 15:23:40 +00:00
|
|
|
if ( !(quotes&1) && text[i] == ';' && !ignoresemicolon)
|
2004-08-21 01:25:48 +00:00
|
|
|
break; // don't break if inside a quoted string
|
|
|
|
if (text[i] == '\n')
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i >= sizeof(line)-1)
|
|
|
|
{
|
|
|
|
Con_Printf("Statement too long\n");
|
|
|
|
return "";
|
|
|
|
}
|
2005-07-03 15:16:20 +00:00
|
|
|
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
memcpy (line, text, i);
|
|
|
|
line[i] = 0;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
// delete the text from the command buffer and move remaining commands down
|
|
|
|
// this is necessary because commands (exec, alias) can insert data at the
|
|
|
|
// beginning of the text buffer
|
|
|
|
|
|
|
|
if (i == cmd_text[level].buf.cursize)
|
|
|
|
cmd_text[level].buf.cursize = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
cmd_text[level].buf.cursize -= i;
|
2011-01-30 01:32:30 +00:00
|
|
|
memmove (text, text+i, cmd_text[level].buf.cursize);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Con_Printf("Found \"%s\"\n", line);
|
|
|
|
text=line;
|
|
|
|
while(*text == ' ' || *text == '\t')
|
|
|
|
text++;
|
|
|
|
|
|
|
|
if (!*text)
|
|
|
|
if (cmd_text[level].buf.cursize)
|
|
|
|
goto start; //should be a while.
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *Cbuf_StripText(int level) //remove all text in the command buffer and return it (so it can be readded later)
|
|
|
|
{
|
|
|
|
char *buf;
|
2005-03-28 00:11:59 +00:00
|
|
|
buf = (char*)Z_Malloc(cmd_text[level].buf.cursize+1);
|
2004-08-21 01:25:48 +00:00
|
|
|
Q_memcpy (buf, cmd_text[level].buf.data, cmd_text[level].buf.cursize);
|
|
|
|
cmd_text[level].buf.cursize = 0;
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cbuf_ExecuteLevel (int level)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char *text;
|
|
|
|
char line[1024];
|
2006-03-06 21:54:32 +00:00
|
|
|
qboolean quotes, comment;
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
while (cmd_text[level].buf.cursize)
|
|
|
|
{
|
|
|
|
if (cmd_text[level].waitattime == realtime)
|
|
|
|
{ // skip out while text still remains in buffer, leaving it
|
|
|
|
// for next frame
|
|
|
|
break;
|
|
|
|
}
|
2004-11-13 17:22:13 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
// find a \n or ; line break
|
|
|
|
text = (char *)cmd_text[level].buf.data;
|
|
|
|
|
2006-03-06 21:54:32 +00:00
|
|
|
quotes = false;
|
|
|
|
comment = false;
|
2004-08-21 01:25:48 +00:00
|
|
|
for (i=0 ; i< cmd_text[level].buf.cursize ; i++)
|
|
|
|
{
|
2006-03-06 21:54:32 +00:00
|
|
|
if (text[i] == '\n')
|
|
|
|
break;
|
2004-08-21 01:25:48 +00:00
|
|
|
if (text[i] == '"')
|
2006-03-06 21:54:32 +00:00
|
|
|
{
|
2004-08-21 01:25:48 +00:00
|
|
|
quotes++;
|
2006-03-06 21:54:32 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (comment || (quotes&1))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (text[i] == '/' && i+1 < cmd_text[level].buf.cursize && text[i+1] == '/')
|
|
|
|
comment = true;
|
|
|
|
else if (text[i] == ';')
|
2004-08-21 01:25:48 +00:00
|
|
|
break; // don't break if inside a quoted string
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i >= sizeof(line))
|
|
|
|
i = sizeof(line)-1;
|
|
|
|
memcpy (line, text, i);
|
|
|
|
line[i] = 0;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
// delete the text from the command buffer and move remaining commands down
|
|
|
|
// this is necessary because commands (exec, alias) can insert data at the
|
|
|
|
// beginning of the text buffer
|
|
|
|
|
|
|
|
if (i == cmd_text[level].buf.cursize)
|
|
|
|
cmd_text[level].buf.cursize = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
cmd_text[level].buf.cursize -= i;
|
2010-07-12 22:46:37 +00:00
|
|
|
memmove (text, text+i, cmd_text[level].buf.cursize);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
2005-07-03 15:16:20 +00:00
|
|
|
// execute the command line
|
2004-08-21 01:25:48 +00:00
|
|
|
Cmd_ExecuteString (line, level);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cbuf_Execute
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void Cbuf_Execute (void)
|
|
|
|
{
|
|
|
|
int level;
|
|
|
|
|
2004-08-26 10:17:21 +00:00
|
|
|
for (level = 0; level < sizeof(cmd_text)/sizeof(cmd_text[0]); level++)
|
2014-10-22 19:41:20 +00:00
|
|
|
if (cmd_text[level].buf.cursize)
|
|
|
|
Cbuf_ExecuteLevel(level);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==============================================================================
|
|
|
|
|
|
|
|
SCRIPT COMMANDS
|
|
|
|
|
|
|
|
==============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
Cmd_StuffCmds_f
|
|
|
|
|
|
|
|
Adds command line parameters as script statements
|
|
|
|
Commands lead with a +, and continue until a - or another +
|
|
|
|
quake +prog jctest.qp +cmd amlev1
|
|
|
|
quake -nosound +cmd amlev1
|
|
|
|
===============
|
|
|
|
*/
|
2005-01-07 02:46:11 +00:00
|
|
|
void Cmd_StuffCmds (void)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
int s;
|
|
|
|
char *text, *build, c;
|
|
|
|
|
|
|
|
|
|
|
|
// build the combined string to parse from
|
|
|
|
s = 0;
|
|
|
|
for (i=1 ; i<com_argc ; i++)
|
|
|
|
{
|
|
|
|
if (!com_argv[i])
|
|
|
|
continue; // NEXTSTEP nulls out -NXHost
|
|
|
|
s += Q_strlen (com_argv[i]) + 3;
|
|
|
|
}
|
|
|
|
if (!s)
|
|
|
|
return;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
text = (char*)Z_Malloc (s+1);
|
2004-08-21 01:25:48 +00:00
|
|
|
text[0] = 0;
|
|
|
|
for (i=1 ; i<com_argc ; i++)
|
|
|
|
{
|
|
|
|
if (!com_argv[i])
|
|
|
|
continue; // NEXTSTEP nulls out -NXHost
|
2010-03-14 14:35:56 +00:00
|
|
|
if (strchr(com_argv[i], ' ') || strchr(com_argv[i], '\t') || strchr(com_argv[i], '@'))
|
2008-03-14 11:52:09 +00:00
|
|
|
{
|
|
|
|
Q_strcat (text,"\"");
|
|
|
|
Q_strcat (text,com_argv[i]);
|
|
|
|
Q_strcat (text,"\"");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Q_strcat (text,com_argv[i]);
|
2004-08-21 01:25:48 +00:00
|
|
|
if (i != com_argc-1)
|
|
|
|
Q_strcat (text, " ");
|
|
|
|
}
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
// pull out the commands
|
2005-03-28 00:11:59 +00:00
|
|
|
build = (char*)Z_Malloc (s+1);
|
2004-08-21 01:25:48 +00:00
|
|
|
build[0] = 0;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
for (i=0 ; i<s-1 ; i++)
|
|
|
|
{
|
|
|
|
if (text[i] == '+')
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
|
2010-03-14 14:35:56 +00:00
|
|
|
for (j=i ; ((text[j-1] != ' ') || ((text[j] != '+') && (text[j] != '-'))) && (text[j] != 0) ; j++)
|
2004-08-21 01:25:48 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
c = text[j];
|
|
|
|
text[j] = 0;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
Q_strcat (build, text+i);
|
|
|
|
Q_strcat (build, "\n");
|
|
|
|
text[j] = c;
|
|
|
|
i = j-1;
|
|
|
|
}
|
|
|
|
}
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
if (build[0])
|
2005-01-07 02:46:11 +00:00
|
|
|
Cbuf_AddText (build, RESTRICT_LOCAL);
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
Z_Free (text);
|
|
|
|
Z_Free (build);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
Cmd_Exec_f
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
void Cmd_Exec_f (void)
|
|
|
|
{
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
char *f, *s;
|
2004-08-21 01:25:48 +00:00
|
|
|
char name[256];
|
2014-10-11 19:39:45 +00:00
|
|
|
flocation_t loc;
|
|
|
|
qboolean untrusted;
|
|
|
|
vfsfile_t *file;
|
|
|
|
size_t l;
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
if (Cmd_Argc () != 2)
|
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("exec <filename> : execute a script file\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!strcmp(Cmd_Argv(0), "cfg_load"))
|
|
|
|
{
|
|
|
|
f = Cmd_Argv(1);
|
|
|
|
if (!*f)
|
|
|
|
f = "fte";
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf(name, sizeof(name)-5, "configs/%s", f);
|
2006-03-11 03:12:10 +00:00
|
|
|
COM_DefaultExtension(name, ".cfg", sizeof(name));
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
Q_strncpyz(name, Cmd_Argv(1), sizeof(name));
|
|
|
|
|
2014-10-11 19:39:45 +00:00
|
|
|
if (!FS_FLocateFile(name, FSLFRT_IFFOUND, &loc) && !FS_FLocateFile(va("%s.cfg", name), FSLFRT_IFFOUND, &loc))
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
2014-10-11 19:39:45 +00:00
|
|
|
Con_TPrintf ("couldn't exec %s\n", name);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
file = FS_OpenReadLocation(&loc);
|
|
|
|
if (!file)
|
|
|
|
{
|
|
|
|
Con_TPrintf ("couldn't exec %s. check permissions.\n", name);
|
2005-10-16 03:46:33 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
if (cl_warncmd.ival || developer.ival)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("execing %s\n",name);
|
2005-04-16 16:21:27 +00:00
|
|
|
|
2014-10-11 19:39:45 +00:00
|
|
|
l = VFS_GETLEN(file);
|
|
|
|
f = BZ_Malloc(l+1);
|
|
|
|
f[l] = 0;
|
|
|
|
VFS_READ(file, f, l);
|
|
|
|
VFS_CLOSE(file);
|
|
|
|
untrusted = !!(loc.search->flags&SPF_UNTRUSTED);
|
|
|
|
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
s = f;
|
|
|
|
if (s[0] == '\xef' && s[1] == '\xbb' && s[2] == '\xbf')
|
|
|
|
{
|
|
|
|
Con_DPrintf("Ignoring UTF-8 BOM\n");
|
|
|
|
s+=3;
|
|
|
|
}
|
2014-10-05 20:04:11 +00:00
|
|
|
|
|
|
|
if (!strcmp(name, "config.cfg") || !strcmp(name, "fte.cfg"))
|
|
|
|
{
|
|
|
|
//if the config is from id1 and the default.cfg was from some mod, make sure the default.cfg overrides the config.
|
|
|
|
//we won't just exec the default instead, because we can at least retain things which are not specified (ie: a few binds)
|
|
|
|
int cfgdepth = COM_FDepthFile(name, true);
|
|
|
|
int defdepth = COM_FDepthFile("default.cfg", true);
|
|
|
|
if (defdepth < cfgdepth)
|
2014-10-11 19:39:45 +00:00
|
|
|
Cbuf_InsertText("exec default.cfg\n", ((Cmd_FromGamecode() || untrusted) ? RESTRICT_INSECURE : Cmd_ExecLevel), false);
|
2014-10-05 20:04:11 +00:00
|
|
|
}
|
2013-06-23 02:17:02 +00:00
|
|
|
// don't execute anything if it was from server (either the stuffcmd/localcmd, or the file)
|
2014-10-11 19:39:45 +00:00
|
|
|
if (!strcmp(name, "default.cfg") && !(Cmd_FromGamecode() || untrusted))
|
|
|
|
Cbuf_InsertText ("\ncvar_lockdefaults 1\n", ((Cmd_FromGamecode() || untrusted) ? RESTRICT_INSECURE : Cmd_ExecLevel), false);
|
|
|
|
Cbuf_InsertText (s, ((Cmd_FromGamecode() || untrusted) ? RESTRICT_INSECURE : Cmd_ExecLevel), true);
|
|
|
|
BZ_Free(f);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
Cmd_Echo_f
|
|
|
|
|
|
|
|
Just prints the rest of the line to the console
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
void Cmd_Echo_f (void)
|
|
|
|
{
|
|
|
|
int i;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
for (i=1 ; i<Cmd_Argc() ; i++)
|
2014-10-05 20:04:11 +00:00
|
|
|
{
|
|
|
|
#ifdef SERVERONLY
|
|
|
|
Con_Printf ("%s", Cmd_Argv(i));
|
|
|
|
#else
|
|
|
|
Con_PrintFlags (Cmd_Argv(i), (com_parseezquake.ival?PFS_EZQUAKEMARKUP:0), 0);
|
|
|
|
#endif
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
Con_Printf ("\n");
|
|
|
|
}
|
|
|
|
|
2004-12-21 04:38:02 +00:00
|
|
|
void Cmd_ShowAlias_f (void)
|
|
|
|
{
|
|
|
|
cmdalias_t *a;
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
s = Cmd_Argv(1);
|
|
|
|
|
|
|
|
//find it, print it
|
|
|
|
for (a = cmd_alias ; a ; a=a->next)
|
|
|
|
{
|
|
|
|
if (!strcmp(s, a->name))
|
|
|
|
{
|
|
|
|
Con_Printf ("alias %s %s\n", a->name, a->value);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Con_Printf("Alias doesn't exist\n");
|
|
|
|
}
|
|
|
|
|
2013-10-29 17:38:22 +00:00
|
|
|
//returns a zoned string.
|
|
|
|
char *Cmd_ParseMultiline(qboolean checkheader)
|
|
|
|
{
|
|
|
|
char *result;
|
|
|
|
char *end;
|
|
|
|
int in = checkheader?0:1;
|
|
|
|
char *s;
|
|
|
|
result = NULL;
|
|
|
|
for(;;)
|
|
|
|
{
|
|
|
|
s = Cbuf_GetNext(Cmd_ExecLevel, false);
|
|
|
|
if (!*s)
|
|
|
|
{
|
|
|
|
if (in)
|
|
|
|
Con_Printf(CON_WARNING "WARNING: Multiline alias was not terminated\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
while (*s <= ' ' && *s)
|
|
|
|
s++;
|
|
|
|
for (end = s + strlen(s)-1; end >= s && *end <= ' '; end--)
|
|
|
|
*end = '\0';
|
|
|
|
if (!strcmp(s, "{"))
|
|
|
|
{
|
|
|
|
in++;
|
|
|
|
if (in == 1)
|
|
|
|
continue; //don't embed the first one in the string, because that would be weird.
|
|
|
|
}
|
|
|
|
else if (!strcmp(s, "}"))
|
|
|
|
{
|
|
|
|
in--;
|
|
|
|
if (!in)
|
|
|
|
break; //phew
|
|
|
|
}
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
char *newv = (char*)Z_Malloc(strlen(result) + strlen(s) + 2);
|
|
|
|
sprintf(newv, "%s;%s", result, s);
|
|
|
|
Z_Free(result);
|
|
|
|
result = newv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
result = Z_StrDup(s);
|
|
|
|
if (!in)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
/*
|
|
|
|
===============
|
|
|
|
Cmd_Alias_f
|
|
|
|
|
|
|
|
Creates a new command that executes a command string (possibly ; seperated)
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
|
|
|
|
void Cmd_Alias_f (void)
|
|
|
|
{
|
|
|
|
cmdalias_t *a, *b;
|
|
|
|
char cmd[1024];
|
|
|
|
int i, c;
|
|
|
|
char *s;
|
|
|
|
qboolean multiline;
|
|
|
|
|
|
|
|
if (Cmd_Argc() == 1) //list em all.
|
|
|
|
{
|
2005-04-16 16:21:27 +00:00
|
|
|
if (Cmd_FromGamecode())
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
if (Cmd_ExecLevel==RESTRICT_SERVER)
|
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("Current alias commands:\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
for (a = cmd_alias ; a ; a=a->next)
|
|
|
|
{
|
|
|
|
if (a->flags & ALIAS_FROMSERVER)
|
|
|
|
Con_Printf ("%s : %s\n", a->name, a->value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("Current alias commands:\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
for (a = cmd_alias ; a ; a=a->next)
|
|
|
|
{
|
|
|
|
/* extern int con_linewidth;
|
|
|
|
if (strlen(a->value)+strlen(a->name)+3 > con_linewidth)
|
|
|
|
Con_Printf ("%s ...\n", a->name);
|
|
|
|
else*/
|
|
|
|
Con_Printf ("%s : %s\n", a->name, a->value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
s = Cmd_Argv(1);
|
|
|
|
if (strlen(s) >= MAX_ALIAS_NAME || !strcmp(s, "say")) //reject aliasing the say command. We use it as an easy way to warn that our player is cheating.
|
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("Alias name is too long\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!cl_aliasoverlap.value)
|
|
|
|
{
|
|
|
|
if (Cvar_FindVar (s))
|
|
|
|
{
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
if (Cmd_IsInsecure())
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf(cmd, sizeof(cmd), "%s_a", s);
|
2004-08-21 01:25:48 +00:00
|
|
|
Con_Printf ("Can't register alias, %s is a cvar\nAlias has been named %s instead\n", s, cmd);
|
|
|
|
s = cmd;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Con_Printf ("Can't register alias, %s is a cvar\n", s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
// check for overlap with a command
|
|
|
|
if (Cmd_Exists (s))
|
|
|
|
{
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
if (Cmd_IsInsecure())
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
2006-03-06 01:41:09 +00:00
|
|
|
snprintf(cmd, sizeof(cmd), "%s_a", s);
|
2004-08-21 01:25:48 +00:00
|
|
|
Con_Printf ("Can't register alias, %s is a command\nAlias has been named %s instead\n", s, cmd);
|
|
|
|
s = cmd;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Con_Printf ("Can't register alias, %s is a command\n", s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-28 15:22:15 +00:00
|
|
|
// if the alias already exists, reuse it
|
2004-08-21 01:25:48 +00:00
|
|
|
for (a = cmd_alias ; a ; a=a->next)
|
|
|
|
{
|
|
|
|
if (!strcmp(s, a->name))
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
if ((a->restriction?a->restriction:rcon_level.ival) > Cmd_ExecLevel)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("Alias is already bound with a higher restriction\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2008-01-05 09:58:55 +00:00
|
|
|
|
|
|
|
if (!stricmp(Cmd_Argv(0), "newalias"))
|
|
|
|
return; //newalias command only registers the alias if it is new, and does not change it if it already exists
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
Z_Free (a->value);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!a)
|
|
|
|
{
|
2005-03-28 00:11:59 +00:00
|
|
|
a = (cmdalias_t*)Z_Malloc (sizeof(cmdalias_t));
|
2004-08-21 01:25:48 +00:00
|
|
|
a->next = cmd_alias;
|
|
|
|
cmd_alias = a;
|
|
|
|
}
|
2005-04-16 16:21:27 +00:00
|
|
|
if (Cmd_FromGamecode())
|
2004-08-21 01:25:48 +00:00
|
|
|
a->flags |= ALIAS_FROMSERVER;
|
|
|
|
else
|
|
|
|
a->flags &= ~ALIAS_FROMSERVER;
|
|
|
|
|
|
|
|
strcpy (a->name, s);
|
|
|
|
multiline = false;
|
|
|
|
if (Cmd_Argc() == 2) //check the next statement for being '{'
|
|
|
|
{
|
|
|
|
char *line, *end;
|
2011-12-05 15:23:40 +00:00
|
|
|
line = Cbuf_GetNext(Cmd_ExecLevel, false);
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
while(*line <= ' ' && *line) //skip leading whitespace.
|
|
|
|
line++;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
for (end = line + strlen(line)-1; end >= line && *end <= ' '; end--) //skip trailing
|
|
|
|
*end = '\0';
|
|
|
|
if (!strcmp(line, "{"))
|
|
|
|
multiline = true;
|
|
|
|
else
|
2006-02-06 01:06:17 +00:00
|
|
|
Cbuf_InsertText(line, Cmd_ExecLevel, true); //whoops. Stick the trimmed string back in to the cbuf.
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(Cmd_Argv(2), "{"))
|
|
|
|
multiline = true;
|
|
|
|
|
|
|
|
if (multiline)
|
|
|
|
{ //fun! MULTILINE ALIASES!!!!
|
2013-10-29 17:38:22 +00:00
|
|
|
a->value = Cmd_ParseMultiline(false);
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// copy the rest of the command line
|
|
|
|
cmd[0] = 0; // start out with a null string
|
|
|
|
c = Cmd_Argc();
|
|
|
|
for (i=2 ; i< c ; i++)
|
|
|
|
{
|
|
|
|
strcat (cmd, Cmd_Argv(i));
|
2006-02-06 01:06:17 +00:00
|
|
|
if (i != c-1)
|
2004-08-21 01:25:48 +00:00
|
|
|
strcat (cmd, " ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!*cmd) //someone wants to wipe it. let them
|
|
|
|
{
|
|
|
|
if (a == cmd_alias)
|
|
|
|
{
|
|
|
|
cmd_alias = a->next;
|
|
|
|
Z_Free(a);
|
2004-09-06 11:13:43 +00:00
|
|
|
return;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (b = cmd_alias ; b ; b=b->next)
|
|
|
|
{
|
|
|
|
if (b->next == a)
|
|
|
|
{
|
|
|
|
b->next = a->next;
|
|
|
|
Z_Free(a);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-04-16 16:21:27 +00:00
|
|
|
if (Cmd_FromGamecode())
|
2004-12-24 08:45:56 +00:00
|
|
|
{
|
|
|
|
a->execlevel = RESTRICT_SERVER; //server-set aliases MUST run at the server's level.
|
|
|
|
a->restriction = 1; //and be runnable at the user's level
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
a->execlevel = 0; //run at users exec level
|
|
|
|
a->restriction = 1; //this is possibly a security risk if the admin also changes execlevel
|
|
|
|
}
|
2013-08-27 13:18:09 +00:00
|
|
|
a->value = Z_StrDup (cmd);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Cmd_DeleteAlias(char *name)
|
|
|
|
{
|
|
|
|
cmdalias_t *a, *b;
|
|
|
|
if (!strcmp(cmd_alias->name, name))
|
|
|
|
{
|
|
|
|
a = cmd_alias;
|
|
|
|
cmd_alias = cmd_alias->next;
|
2013-08-27 13:18:09 +00:00
|
|
|
Z_Free(a->value);
|
2004-08-21 01:25:48 +00:00
|
|
|
Z_Free(a);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (a = cmd_alias ; a ; a=a->next)
|
|
|
|
{
|
|
|
|
if (!strcmp(a->next->name, name))
|
|
|
|
{
|
|
|
|
b = a->next;
|
|
|
|
a->next = b->next;
|
2013-08-27 13:18:09 +00:00
|
|
|
Z_Free(b->value);
|
2004-08-21 01:25:48 +00:00
|
|
|
Z_Free(b);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-30 08:55:06 +00:00
|
|
|
char *Cmd_AliasExist(const char *name, int restrictionlevel)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
cmdalias_t *a;
|
2005-07-28 15:22:15 +00:00
|
|
|
// if the alias already exists, reuse it
|
2004-08-21 01:25:48 +00:00
|
|
|
for (a = cmd_alias ; a ; a=a->next)
|
|
|
|
{
|
|
|
|
if (!strcmp(name, a->name))
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
if ((a->restriction?a->restriction:rcon_level.ival) > restrictionlevel)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
return NULL; //not at this level...
|
|
|
|
}
|
|
|
|
return a->value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cmd_AliasLevel_f (void)
|
|
|
|
{
|
|
|
|
cmdalias_t *a;
|
|
|
|
char *s = Cmd_Argv(1);
|
|
|
|
int level;
|
|
|
|
if (Cmd_Argc() < 2 || Cmd_Argc() > 3)
|
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("aliaslevel <var> [execlevel]\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (a = cmd_alias ; a ; a=a->next)
|
|
|
|
{
|
|
|
|
if (!strcmp(s, a->name))
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!a)
|
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("Alias not found\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Cmd_Argc() == 3)
|
|
|
|
{
|
|
|
|
level = atoi(Cmd_Argv(2));
|
|
|
|
if (level > RESTRICT_MAX)
|
|
|
|
{
|
|
|
|
level = RESTRICT_MAX;
|
|
|
|
}
|
|
|
|
else if (level < RESTRICT_MIN)
|
|
|
|
level = RESTRICT_MIN;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (level > Cmd_ExecLevel || (a->restriction?a->restriction:rcon_level.ival) > Cmd_ExecLevel)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("You arn't allowed to raise a command above your own level\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
a->execlevel = level;
|
|
|
|
|
|
|
|
if (a->restriction == 1)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("WARNING: %s is available to all clients, any client will be able to use it at the new level.\n", a->name);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
else
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("alias %s is set to run at the user level of %i\n", s, a->execlevel);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//lists commands, also prints restriction level
|
|
|
|
void Cmd_AliasList_f (void)
|
|
|
|
{
|
|
|
|
cmdalias_t *cmd;
|
2005-07-03 15:16:20 +00:00
|
|
|
int num=0;
|
2006-09-18 22:53:22 +00:00
|
|
|
int flags;
|
|
|
|
|
|
|
|
if (!strcmp(Cmd_Argv(1), "server"))
|
|
|
|
flags = ALIAS_FROMSERVER;
|
|
|
|
else
|
|
|
|
flags = 0;
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
for (cmd=cmd_alias ; cmd ; cmd=cmd->next)
|
2005-07-03 15:16:20 +00:00
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
if ((cmd->restriction?cmd->restriction:rcon_level.ival) > Cmd_ExecLevel)
|
2004-08-21 01:25:48 +00:00
|
|
|
continue;
|
2006-09-18 22:53:22 +00:00
|
|
|
if (flags && !(cmd->flags & flags))
|
|
|
|
continue;
|
2004-08-21 01:25:48 +00:00
|
|
|
if (!num)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("Alias list:\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
if (cmd->execlevel)
|
2009-11-04 21:16:50 +00:00
|
|
|
Con_Printf("(%2i)(%2i) %s\n", (int)(cmd->restriction?cmd->restriction:rcon_level.ival), cmd->execlevel, cmd->name);
|
2004-08-21 01:25:48 +00:00
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
Con_Printf("(%2i) %s\n", (int)(cmd->restriction?cmd->restriction:rcon_level.ival), cmd->name);
|
2004-08-21 01:25:48 +00:00
|
|
|
num++;
|
|
|
|
}
|
|
|
|
if (num)
|
|
|
|
Con_Printf("\n");
|
|
|
|
}
|
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
void Alias_WriteAliases (vfsfile_t *f)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
2005-12-21 03:07:33 +00:00
|
|
|
char *s;
|
2004-08-21 01:25:48 +00:00
|
|
|
cmdalias_t *cmd;
|
2005-07-03 15:16:20 +00:00
|
|
|
int num=0;
|
2013-08-21 07:14:39 +00:00
|
|
|
char buf[2048];
|
2004-08-21 01:25:48 +00:00
|
|
|
for (cmd=cmd_alias ; cmd ; cmd=cmd->next)
|
2005-07-03 15:16:20 +00:00
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
// if ((cmd->restriction?cmd->restriction:rcon_level.ival) > Cmd_ExecLevel)
|
2004-08-21 01:25:48 +00:00
|
|
|
// continue;
|
2004-12-24 08:45:56 +00:00
|
|
|
if (cmd->flags & ALIAS_FROMSERVER)
|
|
|
|
continue;
|
2004-08-21 01:25:48 +00:00
|
|
|
if (!num)
|
2005-12-21 03:07:33 +00:00
|
|
|
{
|
|
|
|
s = va("\n//////////////////\n//Aliases\n");
|
|
|
|
VFS_WRITE(f, s, strlen(s));
|
|
|
|
}
|
2013-08-21 07:14:39 +00:00
|
|
|
s = va("alias %s %s\n", cmd->name, COM_QuotedString(cmd->value, buf, sizeof(buf)));
|
2005-12-21 03:07:33 +00:00
|
|
|
VFS_WRITE(f, s, strlen(s));
|
2004-12-24 08:45:56 +00:00
|
|
|
if (cmd->restriction != 1) //1 is default
|
2005-12-21 03:07:33 +00:00
|
|
|
{
|
|
|
|
s = va("restrict %s %i\n", cmd->name, cmd->restriction);
|
|
|
|
VFS_WRITE(f, s, strlen(s));
|
|
|
|
}
|
2004-12-24 08:45:56 +00:00
|
|
|
if (cmd->execlevel != 0) //0 is default (runs at user's level)
|
2005-12-21 03:07:33 +00:00
|
|
|
{
|
|
|
|
s = va("aliaslevel %s %i\n", cmd->name, cmd->execlevel);
|
|
|
|
VFS_WRITE(f, s, strlen(s));
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
num++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-27 13:18:09 +00:00
|
|
|
void Alias_WipeStuffedAliases(void)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
2013-08-27 13:18:09 +00:00
|
|
|
cmdalias_t **link, *cmd;
|
|
|
|
for (link=&cmd_alias ; (cmd=*link) ; )
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
if (cmd->flags & ALIAS_FROMSERVER)
|
|
|
|
{
|
2013-08-27 13:18:09 +00:00
|
|
|
*link = cmd->next;
|
|
|
|
Z_Free(cmd->value);
|
|
|
|
Z_Free(cmd);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
else
|
2013-08-27 13:18:09 +00:00
|
|
|
link=&(*link)->next;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cvar_List_f (void);
|
2005-08-23 03:25:22 +00:00
|
|
|
void Cvar_Reset_f (void);
|
2013-10-29 17:38:22 +00:00
|
|
|
void Cvar_LockDefaults_f(void);
|
|
|
|
void Cvar_PurgeDefaults_f(void);
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
=============================================================================
|
|
|
|
|
|
|
|
COMMAND EXECUTION
|
|
|
|
|
|
|
|
=============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct cmd_function_s
|
|
|
|
{
|
|
|
|
struct cmd_function_s *next;
|
|
|
|
char *name;
|
2012-03-19 06:30:41 +00:00
|
|
|
char *description;
|
2004-08-21 01:25:48 +00:00
|
|
|
xcommand_t function;
|
|
|
|
|
|
|
|
qbyte restriction; //restriction of admin level
|
|
|
|
} cmd_function_t;
|
|
|
|
|
|
|
|
|
|
|
|
#define MAX_ARGS 80
|
|
|
|
|
|
|
|
static int cmd_argc;
|
|
|
|
static char *cmd_argv[MAX_ARGS];
|
|
|
|
static char *cmd_null_string = "";
|
2008-01-29 23:18:06 +00:00
|
|
|
static char *cmd_args = NULL, *cmd_args_buf;
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static cmd_function_t *cmd_functions; // possible commands to execute
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cmd_Argc
|
|
|
|
============
|
|
|
|
*/
|
2005-03-18 06:13:36 +00:00
|
|
|
int VARGS Cmd_Argc (void)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
return cmd_argc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cmd_Argv
|
|
|
|
============
|
|
|
|
*/
|
2005-03-18 06:13:36 +00:00
|
|
|
char *VARGS Cmd_Argv (int arg)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
if ( arg >= cmd_argc )
|
|
|
|
return cmd_null_string;
|
2005-07-03 15:16:20 +00:00
|
|
|
return cmd_argv[arg];
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cmd_Args
|
|
|
|
|
|
|
|
Returns a single string containing argv(1) to argv(argc()-1)
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
|
2005-03-18 06:13:36 +00:00
|
|
|
char *VARGS Cmd_Args (void)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
if (!cmd_args)
|
|
|
|
return "";
|
|
|
|
return cmd_args;
|
|
|
|
}
|
|
|
|
|
2014-03-30 08:55:06 +00:00
|
|
|
void Cmd_Args_Set(const char *newargs)
|
2007-02-23 00:21:33 +00:00
|
|
|
{
|
2008-01-29 23:18:06 +00:00
|
|
|
if (cmd_args_buf)
|
|
|
|
Z_Free(cmd_args_buf);
|
|
|
|
|
|
|
|
if (newargs)
|
|
|
|
{
|
|
|
|
cmd_args_buf = (char*)Z_Malloc (Q_strlen(newargs)+1);
|
|
|
|
Q_strcpy (cmd_args_buf, newargs);
|
|
|
|
cmd_args = cmd_args_buf;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmd_args = NULL;
|
|
|
|
cmd_args_buf = NULL;
|
|
|
|
}
|
2007-02-23 00:21:33 +00:00
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cmd_ShiftArgs
|
|
|
|
|
|
|
|
Shifts Cmd_Argv results down one (killing first param)
|
|
|
|
============
|
|
|
|
*/
|
2004-12-08 04:14:52 +00:00
|
|
|
void Cmd_ShiftArgs (int ammount, qboolean expandstring)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
int arg;
|
|
|
|
while (ammount>0 && cmd_argc)
|
|
|
|
{
|
|
|
|
arg=0;
|
|
|
|
cmd_argc--;
|
|
|
|
Z_Free(cmd_argv[0]);
|
|
|
|
while ( arg < cmd_argc )
|
|
|
|
{
|
|
|
|
cmd_argv[arg] = cmd_argv[arg+1];
|
|
|
|
arg++;
|
|
|
|
}
|
|
|
|
cmd_argv[arg]=NULL;
|
|
|
|
|
|
|
|
ammount--;
|
|
|
|
|
|
|
|
if (cmd_args)
|
|
|
|
{
|
2011-02-25 04:22:14 +00:00
|
|
|
cmd_args = COM_StringParse(cmd_args, com_token, sizeof(com_token), expandstring, false);
|
2004-08-21 01:25:48 +00:00
|
|
|
if (cmd_args)
|
2007-01-08 03:11:36 +00:00
|
|
|
while(*cmd_args == ' ' || *cmd_args == '\t')
|
2004-08-21 01:25:48 +00:00
|
|
|
cmd_args++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-29 23:18:06 +00:00
|
|
|
char *Cmd_ExpandCvar(char *cvarname, int maxaccesslevel, int *len)
|
|
|
|
{
|
|
|
|
char *ret = NULL, *end, *namestart;
|
|
|
|
char *fixup = NULL, fixval=0;
|
|
|
|
cvar_t *var;
|
|
|
|
static char temp[12];
|
2013-05-11 05:03:07 +00:00
|
|
|
unsigned int result;
|
2008-01-29 23:18:06 +00:00
|
|
|
|
|
|
|
namestart = cvarname;
|
|
|
|
if (*cvarname == '{')
|
|
|
|
{
|
|
|
|
fixup = &cvarname[strlen(cvarname)-1];
|
|
|
|
if (*fixup != '}')
|
|
|
|
return NULL;
|
|
|
|
fixval = *fixup;
|
|
|
|
*fixup = 0;
|
|
|
|
cvarname++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fixup = &cvarname[strlen(cvarname)];
|
|
|
|
fixval = *fixup;
|
|
|
|
}
|
|
|
|
|
2013-05-11 05:03:07 +00:00
|
|
|
result = strtoul(cvarname, &end, 10);
|
|
|
|
if (fixval && *end == 0) //only expand $0 if its actually ${0} - this avoids conflicting with the $0 macro
|
2008-01-29 23:18:06 +00:00
|
|
|
{ //purely numerical
|
2013-05-11 05:03:07 +00:00
|
|
|
ret = Cmd_Argv(result);
|
2008-01-29 23:18:06 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(cvarname, "*") || !stricmp(cvarname, "cmd_args"))
|
|
|
|
{
|
|
|
|
ret = Cmd_Args();
|
|
|
|
}
|
|
|
|
else if (!strnicmp(cvarname, "cmd_argv", 8))
|
|
|
|
{
|
|
|
|
ret = Cmd_Argv(atoi(cvarname+8));
|
|
|
|
}
|
|
|
|
else if (!stricmp(cvarname, "cmd_argc"))
|
|
|
|
{
|
|
|
|
Q_snprintfz(temp, sizeof(temp), "%u", Cmd_Argc());
|
|
|
|
ret = temp;
|
|
|
|
}
|
|
|
|
else if ( (var = Cvar_FindVar(cvarname)) != NULL )
|
|
|
|
{
|
|
|
|
if (var->restriction <= maxaccesslevel && !((var->flags & CVAR_NOUNSAFEEXPAND) && Cmd_IsInsecure()))
|
|
|
|
{
|
|
|
|
ret = var->string;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*fixup = fixval;
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
*len = fixup - namestart;
|
|
|
|
if (fixval)
|
|
|
|
(*len)++;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
/*
|
|
|
|
================
|
|
|
|
Cmd_ExpandString
|
|
|
|
|
|
|
|
Expands all $cvar expressions to cvar values
|
|
|
|
If not SERVERONLY, also expands $macro expressions
|
|
|
|
Note: dest must point to a 1024 byte buffer
|
|
|
|
================
|
|
|
|
*/
|
2008-05-25 22:23:43 +00:00
|
|
|
char *Cmd_ExpandString (char *data, char *dest, int destlen, int maxaccesslevel, qboolean expandcvars, qboolean expandmacros)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
unsigned int c;
|
|
|
|
char buf[255];
|
|
|
|
int i, len;
|
|
|
|
int quotes = 0;
|
|
|
|
char *str;
|
2008-01-29 23:18:06 +00:00
|
|
|
char *bestmacro, *bestvar;
|
|
|
|
int name_length, macro_length, var_length;
|
2004-09-20 23:25:38 +00:00
|
|
|
qboolean striptrailing;
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
len = 0;
|
|
|
|
|
|
|
|
while ( (c = *data) != 0)
|
|
|
|
{
|
|
|
|
if (c == '"')
|
|
|
|
quotes++;
|
|
|
|
|
|
|
|
if (c == '$' && !(quotes&1))
|
|
|
|
{
|
|
|
|
data++;
|
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
striptrailing = (*data == '-')?true:false;
|
2004-09-20 23:25:38 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
// Copy the text after '$' to a temp buffer
|
|
|
|
i = 0;
|
|
|
|
buf[0] = 0;
|
2008-01-29 23:18:06 +00:00
|
|
|
buf[1] = 0;
|
2004-08-21 01:25:48 +00:00
|
|
|
bestvar = NULL;
|
2004-09-20 23:25:38 +00:00
|
|
|
bestmacro = NULL;
|
|
|
|
macro_length=0;
|
2008-01-29 23:18:06 +00:00
|
|
|
var_length = 0;
|
2004-08-21 01:25:48 +00:00
|
|
|
while ((c = *data) > 32)
|
|
|
|
{
|
|
|
|
if (c == '$')
|
|
|
|
break;
|
|
|
|
data++;
|
|
|
|
buf[i++] = c;
|
|
|
|
buf[i] = 0;
|
2008-01-29 23:18:06 +00:00
|
|
|
if (!bestmacro)
|
2004-09-20 23:25:38 +00:00
|
|
|
{
|
2008-01-29 23:18:06 +00:00
|
|
|
if ((str = Cmd_ExpandCvar(buf+striptrailing, maxaccesslevel, &var_length)))
|
|
|
|
bestvar = str;
|
2004-09-20 23:25:38 +00:00
|
|
|
}
|
2005-03-28 00:11:59 +00:00
|
|
|
if (expandmacros && (str = TP_MacroString (buf+striptrailing, ¯o_length)))
|
2004-09-20 23:25:38 +00:00
|
|
|
bestmacro = str;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
2004-09-20 23:25:38 +00:00
|
|
|
if (bestmacro)
|
|
|
|
{
|
|
|
|
str = bestmacro;
|
2004-08-21 01:25:48 +00:00
|
|
|
name_length = macro_length;
|
|
|
|
}
|
2004-09-20 23:25:38 +00:00
|
|
|
else if (bestvar)
|
|
|
|
{
|
2008-01-29 23:18:06 +00:00
|
|
|
str = bestvar;
|
|
|
|
name_length = var_length;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
2004-09-20 23:25:38 +00:00
|
|
|
else
|
|
|
|
{
|
2004-08-21 01:25:48 +00:00
|
|
|
str = NULL;
|
2004-09-20 23:25:38 +00:00
|
|
|
name_length = 0;
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
// check buffer size
|
2004-09-20 23:25:38 +00:00
|
|
|
if (len + strlen(str) >= destlen-1)
|
2004-08-21 01:25:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
strcpy(&dest[len], str);
|
|
|
|
len += strlen(str);
|
|
|
|
i = name_length;
|
|
|
|
while (buf[i])
|
|
|
|
dest[len++] = buf[i++];
|
2004-09-20 23:25:38 +00:00
|
|
|
|
|
|
|
if (striptrailing && !*str)
|
|
|
|
while(*data <= ' ' && *data)
|
|
|
|
data++;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// no matching cvar or macro
|
|
|
|
dest[len++] = '$';
|
2004-09-20 23:25:38 +00:00
|
|
|
if (len + strlen(buf) >= destlen-1)
|
2004-08-21 01:25:48 +00:00
|
|
|
break;
|
|
|
|
strcpy (&dest[len], buf);
|
|
|
|
len += strlen(buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dest[len] = c;
|
|
|
|
data++;
|
|
|
|
len++;
|
2004-09-20 23:25:38 +00:00
|
|
|
if (len >= destlen-1)
|
2004-08-21 01:25:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
dest[len] = 0;
|
2004-09-20 23:25:38 +00:00
|
|
|
|
2014-02-11 17:51:29 +00:00
|
|
|
if (len && dest[len-1] == '\r') //with dos line endings, don't add some pointless \r char on the end.
|
|
|
|
dest[len-1] = 0;
|
|
|
|
|
2004-09-20 23:25:38 +00:00
|
|
|
return dest;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
2008-01-29 23:18:06 +00:00
|
|
|
char *Cmd_ExpandStringArguments (char *data, char *dest, int destlen)
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
int quotes = 0;
|
|
|
|
int len = 0;
|
|
|
|
|
|
|
|
char *str, *strend;
|
|
|
|
int old_len;
|
|
|
|
while ( (c = *data) != 0)
|
|
|
|
{
|
|
|
|
if (c == '"')
|
|
|
|
quotes++;
|
|
|
|
|
|
|
|
if (c == '%' && !(quotes&1))
|
|
|
|
{
|
|
|
|
if (data[1] == '%')
|
|
|
|
{
|
|
|
|
str = "%";
|
|
|
|
old_len = 2;
|
|
|
|
}
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
else if (data[1] == '#')
|
|
|
|
{
|
|
|
|
str = va("\"%s\"", Cmd_Args());
|
|
|
|
old_len = 2;
|
|
|
|
}
|
2008-01-29 23:18:06 +00:00
|
|
|
else if (data[1] == '*')
|
|
|
|
{
|
|
|
|
str = Cmd_Args();
|
|
|
|
old_len = 2;
|
|
|
|
}
|
|
|
|
else if (strtol(data+1, &strend, 10))
|
|
|
|
{
|
|
|
|
str = Cmd_Argv(atoi(data+1));
|
|
|
|
old_len = strend - data;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
str = NULL;
|
|
|
|
old_len = 0;
|
|
|
|
}
|
2011-05-15 13:23:13 +00:00
|
|
|
|
2008-01-29 23:18:06 +00:00
|
|
|
if (str)
|
|
|
|
{
|
|
|
|
// check buffer size
|
|
|
|
if (len + strlen(str) >= destlen-1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
strcpy(&dest[len], str);
|
|
|
|
len += strlen(str);
|
|
|
|
dest[len] = 0;
|
|
|
|
data += old_len;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dest[len] = c;
|
|
|
|
data++;
|
|
|
|
len++;
|
|
|
|
dest[len] = 0;
|
|
|
|
if (len >= destlen-1)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
dest[len] = 0;
|
|
|
|
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cmd_TokenizeString
|
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
Parses the given string into command line tokens, stopping at the \n
|
2004-08-21 01:25:48 +00:00
|
|
|
============
|
|
|
|
*/
|
2014-03-30 08:55:06 +00:00
|
|
|
const char *Cmd_TokenizeString (const char *text, qboolean expandmacros, qboolean qctokenize)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
int i;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
// clear the args from the last string
|
|
|
|
for (i=0 ; i<cmd_argc ; i++)
|
|
|
|
Z_Free (cmd_argv[i]);
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
cmd_argc = 0;
|
2008-01-29 23:18:06 +00:00
|
|
|
Cmd_Args_Set(NULL);
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
while (1)
|
|
|
|
{
|
2008-05-25 22:23:43 +00:00
|
|
|
// skip whitespace up to a \n
|
2005-08-03 23:14:59 +00:00
|
|
|
while (*text && (unsigned)*text <= ' ' && *text != '\n')
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
text++;
|
|
|
|
}
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
if (*text == '\n')
|
|
|
|
{ // a newline seperates commands in the buffer
|
2005-07-03 15:16:20 +00:00
|
|
|
text++;
|
2004-08-21 01:25:48 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!*text)
|
2012-11-27 03:23:19 +00:00
|
|
|
return text;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
if (cmd_argc == 1)
|
2008-01-29 23:18:06 +00:00
|
|
|
{
|
|
|
|
Cmd_Args_Set(text);
|
|
|
|
}
|
2004-12-08 04:14:52 +00:00
|
|
|
|
2011-02-25 04:22:14 +00:00
|
|
|
text = COM_StringParse (text, com_token, sizeof(com_token), expandmacros, qctokenize);
|
2004-08-21 01:25:48 +00:00
|
|
|
if (!text)
|
2012-11-27 03:23:19 +00:00
|
|
|
return text;
|
|
|
|
if (!strcmp(com_token, "\n"))
|
|
|
|
return text;
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
if (cmd_argc < MAX_ARGS)
|
|
|
|
{
|
2005-03-28 00:11:59 +00:00
|
|
|
cmd_argv[cmd_argc] = (char*)Z_Malloc (Q_strlen(com_token)+1);
|
2004-08-21 01:25:48 +00:00
|
|
|
Q_strcpy (cmd_argv[cmd_argc], com_token);
|
|
|
|
cmd_argc++;
|
|
|
|
}
|
|
|
|
}
|
2012-11-27 03:23:19 +00:00
|
|
|
return text;
|
2008-11-09 22:29:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Cmd_TokenizePunctation (char *text, char *punctuation)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// clear the args from the last string
|
|
|
|
for (i=0 ; i<cmd_argc ; i++)
|
|
|
|
Z_Free (cmd_argv[i]);
|
|
|
|
|
|
|
|
cmd_argc = 0;
|
|
|
|
Cmd_Args_Set(NULL);
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
// skip whitespace up to a \n
|
|
|
|
while (*text && (unsigned)*text <= ' ' && *text != '\n')
|
|
|
|
{
|
|
|
|
text++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*text == '\n')
|
|
|
|
{ // a newline seperates commands in the buffer
|
|
|
|
text++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!*text)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (cmd_argc == 1)
|
|
|
|
{
|
|
|
|
Cmd_Args_Set(text);
|
|
|
|
}
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
text = COM_ParseToken (text, punctuation);
|
|
|
|
if (!text)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (cmd_argc < MAX_ARGS)
|
|
|
|
{
|
|
|
|
cmd_argv[cmd_argc] = (char*)Z_Malloc (Q_strlen(com_token)+1);
|
|
|
|
Q_strcpy (cmd_argv[cmd_argc], com_token);
|
|
|
|
cmd_argc++;
|
|
|
|
}
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cmd_AddCommand
|
|
|
|
============
|
|
|
|
*/
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
qboolean Cmd_AddCommandD (char *cmd_name, xcommand_t function, char *desc)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
cmd_function_t *cmd;
|
|
|
|
|
|
|
|
// fail if the command is a variable name
|
|
|
|
if (Cvar_VariableString(cmd_name)[0])
|
|
|
|
{
|
|
|
|
Con_Printf ("Cmd_AddCommand: %s already defined as a var\n", cmd_name);
|
2005-01-15 17:39:12 +00:00
|
|
|
return false;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
// fail if the command already exists
|
|
|
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
|
|
|
{
|
|
|
|
if (!Q_strcmp (cmd_name, cmd->name))
|
|
|
|
{
|
2006-02-26 05:50:37 +00:00
|
|
|
if (cmd->function == function) //happens a lot with q3
|
|
|
|
Con_DPrintf ("Cmd_AddCommand: %s already defined\n", cmd_name);
|
|
|
|
else
|
2009-04-01 22:03:56 +00:00
|
|
|
{
|
2006-02-26 05:50:37 +00:00
|
|
|
Con_Printf ("Cmd_AddCommand: %s already defined\n", cmd_name);
|
2009-04-01 22:03:56 +00:00
|
|
|
break;
|
|
|
|
}
|
2005-01-15 17:39:12 +00:00
|
|
|
return false;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
cmd = (cmd_function_t*)Z_Malloc (sizeof(cmd_function_t)+strlen(cmd_name)+1);
|
2005-01-15 20:50:02 +00:00
|
|
|
cmd->name = (char*)(cmd+1);
|
2012-11-27 03:23:19 +00:00
|
|
|
cmd->description = desc;
|
2005-01-15 20:50:02 +00:00
|
|
|
strcpy(cmd->name, cmd_name);
|
2004-08-21 01:25:48 +00:00
|
|
|
cmd->function = function;
|
|
|
|
cmd->next = cmd_functions;
|
|
|
|
cmd->restriction = 0;
|
|
|
|
cmd_functions = cmd;
|
2005-01-15 17:39:12 +00:00
|
|
|
|
|
|
|
return true;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
qboolean Cmd_AddCommand (char *cmd_name, xcommand_t function)
|
|
|
|
{
|
|
|
|
return Cmd_AddCommandD(cmd_name, function, NULL);
|
|
|
|
}
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
void Cmd_RemoveCommand (char *cmd_name)
|
|
|
|
{
|
|
|
|
cmd_function_t *cmd, **back;
|
|
|
|
|
|
|
|
back = &cmd_functions;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
cmd = *back;
|
|
|
|
if (!cmd)
|
|
|
|
{
|
2004-09-30 22:49:01 +00:00
|
|
|
// Con_Printf ("Cmd_RemoveCommand: %s not added\n", cmd_name);
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!strcmp (cmd_name, cmd->name))
|
|
|
|
{
|
|
|
|
*back = cmd->next;
|
|
|
|
Z_Free (cmd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
back = &cmd->next;
|
|
|
|
}
|
|
|
|
}
|
2013-08-27 13:18:09 +00:00
|
|
|
void Cmd_RemoveCommands (xcommand_t function)
|
|
|
|
{
|
|
|
|
cmd_function_t *cmd, **back;
|
|
|
|
|
|
|
|
for (back = &cmd_functions; (cmd = *back); )
|
|
|
|
{
|
|
|
|
if (cmd->function == function)
|
|
|
|
{
|
|
|
|
*back = cmd->next;
|
|
|
|
Z_Free (cmd);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
back = &cmd->next;
|
|
|
|
}
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
void Cmd_RestrictCommand_f (void)
|
|
|
|
{
|
|
|
|
cmdalias_t *a;
|
|
|
|
cvar_t *v;
|
|
|
|
cmd_function_t *cmd;
|
|
|
|
char *cmd_name = Cmd_Argv(1);
|
2005-03-12 23:40:42 +00:00
|
|
|
int level;
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
if (Cmd_Argc() != 3 && Cmd_Argc() != 2)
|
|
|
|
{
|
|
|
|
Con_Printf("restrict <commandname> [level]\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-03-12 23:40:42 +00:00
|
|
|
if (Cmd_Argc() > 2)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
2005-03-12 23:40:42 +00:00
|
|
|
level = atoi(Cmd_Argv(2));
|
2004-08-21 01:25:48 +00:00
|
|
|
if (level > RESTRICT_MAX)
|
|
|
|
{
|
|
|
|
level = RESTRICT_MAX;
|
|
|
|
if (level > Cmd_ExecLevel)
|
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("You arn't allowed to raise a command above your own level\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (level < RESTRICT_MIN)
|
|
|
|
level = RESTRICT_MIN;
|
|
|
|
}
|
2005-03-12 23:40:42 +00:00
|
|
|
else level = 0;
|
2004-08-21 01:25:48 +00:00
|
|
|
//commands
|
|
|
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
|
|
|
{
|
|
|
|
if (!Q_strcmp (cmd_name, cmd->name))
|
|
|
|
{
|
|
|
|
if (Cmd_Argc() == 2)
|
|
|
|
{
|
|
|
|
if (cmd->restriction)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("%s is restricted to %i\n", cmd_name, (int)cmd->restriction);
|
2004-08-21 01:25:48 +00:00
|
|
|
else
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("%s is restricted to rcon_level (%i)\n", cmd_name, rcon_level.ival);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
else if ((cmd->restriction?cmd->restriction:rcon_level.ival) > Cmd_ExecLevel)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("You arn't allowed to alter a level above your own\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
else
|
2005-07-03 15:16:20 +00:00
|
|
|
cmd->restriction = level;
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//cvars
|
|
|
|
v = Cvar_FindVar(cmd_name);
|
|
|
|
if (v)
|
|
|
|
{
|
|
|
|
if (Cmd_Argc() == 2)
|
|
|
|
{
|
|
|
|
if (v->restriction)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("%s is restricted to %i\n", cmd_name, (int)v->restriction);
|
2004-08-21 01:25:48 +00:00
|
|
|
else
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("%s is restricted to rcon_level (%i)\n", cmd_name, rcon_level.ival);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
else if ((v->restriction?v->restriction:rcon_level.ival) > Cmd_ExecLevel)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("You arn't allowed to alter a level above your own\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
else
|
|
|
|
v->restriction = level;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check alias
|
|
|
|
for (a=cmd_alias ; a ; a=a->next)
|
|
|
|
{
|
|
|
|
if (!Q_strcasecmp (cmd_name, a->name))
|
|
|
|
{
|
|
|
|
if (Cmd_Argc() == 2)
|
|
|
|
{
|
|
|
|
if (a->restriction)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("%s is restricted to %i\n", cmd_name, (int)a->restriction);
|
2004-08-21 01:25:48 +00:00
|
|
|
else
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("%s is restricted to rcon_level (%i)\n", cmd_name, rcon_level.ival);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
else if ((a->restriction?a->restriction:rcon_level.ival) > Cmd_ExecLevel)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("You arn't allowed to alter a level above your own\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
else
|
|
|
|
a->restriction = level;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("restrict: %s not defined\n", cmd_name);
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Cmd_Level(char *name)
|
|
|
|
{
|
|
|
|
cmdalias_t *a;
|
|
|
|
cmd_function_t *cmds;
|
|
|
|
for (cmds = cmd_functions; cmds; cmds=cmds->next)
|
|
|
|
{
|
|
|
|
if (!strcmp(cmds->name, name))
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
return cmds->restriction?cmds->restriction:rcon_level.ival;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (a=cmd_alias ; a ; a=a->next)
|
|
|
|
{
|
|
|
|
if (!strcmp(a->name, name))
|
|
|
|
{
|
|
|
|
return a->restriction?a->restriction:Cmd_ExecLevel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cmd_Exists
|
|
|
|
============
|
|
|
|
*/
|
2014-03-30 08:55:06 +00:00
|
|
|
qboolean Cmd_Exists (const char *cmd_name)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
cmd_function_t *cmd;
|
|
|
|
|
|
|
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
|
|
|
{
|
|
|
|
if (!Q_strcmp (cmd_name,cmd->name))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-03-19 06:30:41 +00:00
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cmd_Exists
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
char *Cmd_Describe (char *cmd_name)
|
|
|
|
{
|
|
|
|
cmd_function_t *cmd;
|
|
|
|
|
|
|
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
|
|
|
{
|
|
|
|
if (!Q_strcmp (cmd_name,cmd->name))
|
|
|
|
return cmd->description;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cmd_CompleteCommand
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
int matchnum;
|
|
|
|
qboolean allowcutdown;
|
|
|
|
qboolean cutdown;
|
|
|
|
char result[256];
|
2012-11-27 03:23:19 +00:00
|
|
|
char *desc;
|
2004-08-21 01:25:48 +00:00
|
|
|
} match_t;
|
2012-11-27 03:23:19 +00:00
|
|
|
void Cmd_CompleteCheck(char *check, match_t *match, char *desc) //compare cumulative strings and join the result
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
if (*match->result)
|
|
|
|
{
|
2005-07-03 15:16:20 +00:00
|
|
|
char *r;
|
2004-08-21 01:25:48 +00:00
|
|
|
if (match->allowcutdown)
|
|
|
|
{
|
|
|
|
for(r = match->result; *r == *check && *r; r++, check++)
|
|
|
|
;
|
|
|
|
*r = '\0';
|
|
|
|
match->cutdown = true;
|
|
|
|
if (match->matchnum > 0)
|
|
|
|
match->matchnum--;
|
|
|
|
}
|
|
|
|
else if (match->matchnum > 0)
|
|
|
|
{
|
|
|
|
strcpy(match->result, check);
|
2012-11-27 03:23:19 +00:00
|
|
|
match->desc = desc;
|
2004-08-21 01:25:48 +00:00
|
|
|
match->matchnum--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (match->matchnum > 0)
|
|
|
|
match->matchnum--;
|
2012-11-27 03:23:19 +00:00
|
|
|
strcpy(match->result, check);
|
|
|
|
match->desc = desc;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-27 03:23:19 +00:00
|
|
|
char *Cmd_CompleteCommand (char *partial, qboolean fullonly, qboolean caseinsens, int matchnum, char **descptr)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
extern cvar_group_t *cvar_groups;
|
|
|
|
cmd_function_t *cmd;
|
|
|
|
int len;
|
|
|
|
cmdalias_t *a;
|
|
|
|
|
|
|
|
static match_t match;
|
|
|
|
|
|
|
|
cvar_group_t *grp;
|
2005-07-03 15:16:20 +00:00
|
|
|
cvar_t *cvar;
|
2012-03-19 06:30:41 +00:00
|
|
|
char *sp;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2012-03-19 06:30:41 +00:00
|
|
|
sp = strchr(partial, ' ');
|
|
|
|
if (sp)
|
|
|
|
len = sp - partial;
|
|
|
|
else
|
|
|
|
len = Q_strlen(partial);
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2012-11-27 03:23:19 +00:00
|
|
|
if (descptr)
|
|
|
|
*descptr = NULL;
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
if (!len)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (matchnum == -1)
|
|
|
|
len++;
|
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
match.allowcutdown = !fullonly?true:false;
|
2004-08-21 01:25:48 +00:00
|
|
|
match.cutdown = false;
|
2012-11-27 03:23:19 +00:00
|
|
|
match.desc = NULL;
|
2004-08-21 01:25:48 +00:00
|
|
|
if (matchnum)
|
|
|
|
match.matchnum = matchnum;
|
|
|
|
else
|
|
|
|
match.matchnum = 0;
|
|
|
|
|
|
|
|
strcpy(match.result, "");
|
|
|
|
|
2005-06-04 04:20:20 +00:00
|
|
|
// check for partial match
|
|
|
|
if (caseinsens)
|
|
|
|
{
|
|
|
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
2012-03-19 06:30:41 +00:00
|
|
|
if (!Q_strncasecmp (partial,cmd->name, len) && (matchnum == -1 || !partial[len] || strlen(cmd->name) == len))
|
2012-11-27 03:23:19 +00:00
|
|
|
Cmd_CompleteCheck(cmd->name, &match, cmd->description);
|
2005-06-04 04:20:20 +00:00
|
|
|
for (a=cmd_alias ; a ; a=a->next)
|
2012-03-19 06:30:41 +00:00
|
|
|
if (!Q_strncasecmp (partial, a->name, len) && (matchnum == -1 || !partial[len] || strlen(a->name) == len))
|
2012-11-27 03:23:19 +00:00
|
|
|
Cmd_CompleteCheck(a->name, &match, "");
|
2005-06-04 04:20:20 +00:00
|
|
|
for (grp=cvar_groups ; grp ; grp=grp->next)
|
|
|
|
for (cvar=grp->cvars ; cvar ; cvar=cvar->next)
|
2006-04-21 06:02:06 +00:00
|
|
|
{
|
2012-03-19 06:30:41 +00:00
|
|
|
if (!Q_strncasecmp (partial,cvar->name, len) && (matchnum == -1 || !partial[len] || strlen(cvar->name) == len))
|
2012-11-27 03:23:19 +00:00
|
|
|
Cmd_CompleteCheck(cvar->name, &match, cvar->description);
|
2012-03-19 06:30:41 +00:00
|
|
|
if (cvar->name2 && !Q_strncasecmp (partial,cvar->name2, len) && (matchnum == -1 || !partial[len] || strlen(cvar->name2) == len))
|
2012-11-27 03:23:19 +00:00
|
|
|
Cmd_CompleteCheck(cvar->name2, &match, cvar->description);
|
2006-04-21 06:02:06 +00:00
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
|
2005-06-04 04:20:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
2012-03-19 06:30:41 +00:00
|
|
|
if (!Q_strncmp (partial,cmd->name, len) && (matchnum == -1 || !partial[len] || strlen(cmd->name) == len))
|
2012-11-27 03:23:19 +00:00
|
|
|
Cmd_CompleteCheck(cmd->name, &match, cmd->description);
|
2005-06-04 04:20:20 +00:00
|
|
|
for (a=cmd_alias ; a ; a=a->next)
|
2012-03-19 06:30:41 +00:00
|
|
|
if (!Q_strncmp (partial, a->name, len) && (matchnum == -1 || !partial[len] || strlen(a->name) == len))
|
2012-11-27 03:23:19 +00:00
|
|
|
Cmd_CompleteCheck(a->name, &match, "");
|
2005-06-04 04:20:20 +00:00
|
|
|
for (grp=cvar_groups ; grp ; grp=grp->next)
|
|
|
|
for (cvar=grp->cvars ; cvar ; cvar=cvar->next)
|
2006-04-21 06:02:06 +00:00
|
|
|
{
|
2012-03-19 06:30:41 +00:00
|
|
|
if (!Q_strncmp (partial,cvar->name, len) && (matchnum == -1 || !partial[len] || strlen(cvar->name) == len))
|
2012-11-27 03:23:19 +00:00
|
|
|
Cmd_CompleteCheck(cvar->name, &match, cvar->description);
|
2012-03-19 06:30:41 +00:00
|
|
|
if (cvar->name2 && !Q_strncmp (partial,cvar->name2, len) && (matchnum == -1 || !partial[len] || strlen(cvar->name2) == len))
|
2012-11-27 03:23:19 +00:00
|
|
|
Cmd_CompleteCheck(cvar->name2, &match, cvar->description);
|
2006-04-21 06:02:06 +00:00
|
|
|
}
|
2005-06-04 04:20:20 +00:00
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
if (match.matchnum>0)
|
|
|
|
return NULL;
|
|
|
|
if (!*match.result)
|
|
|
|
return NULL;
|
2012-11-27 03:23:19 +00:00
|
|
|
|
|
|
|
if (descptr)
|
|
|
|
*descptr = match.desc;
|
2004-08-21 01:25:48 +00:00
|
|
|
return match.result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//lists commands, also prints restriction level
|
|
|
|
void Cmd_List_f (void)
|
|
|
|
{
|
|
|
|
cmd_function_t *cmd;
|
2005-07-03 15:16:20 +00:00
|
|
|
int num=0;
|
2004-08-21 01:25:48 +00:00
|
|
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
if ((cmd->restriction?cmd->restriction:rcon_level.ival) > Cmd_ExecLevel)
|
2004-08-21 01:25:48 +00:00
|
|
|
continue;
|
|
|
|
if (!num)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("Command list:\n");
|
2009-11-04 21:16:50 +00:00
|
|
|
Con_Printf("(%2i) %s\n", (int)(cmd->restriction?cmd->restriction:rcon_level.ival), cmd->name);
|
2004-08-21 01:25:48 +00:00
|
|
|
num++;
|
|
|
|
}
|
|
|
|
if (num)
|
|
|
|
Con_Printf("\n");
|
|
|
|
}
|
|
|
|
|
2014-10-05 20:04:11 +00:00
|
|
|
//I'm not personally keen on this name, but its somewhat standard in both DP and suse (which lh uses, hence why DP uses that name). oh well.
|
|
|
|
void Cmd_Apropos_f (void)
|
|
|
|
{
|
|
|
|
extern cvar_group_t *cvar_groups;
|
|
|
|
cmd_function_t *cmd;
|
|
|
|
cvar_group_t *grp;
|
|
|
|
cvar_t *var;
|
|
|
|
char *name;
|
|
|
|
char escapedvalue[1024];
|
|
|
|
char latchedvalue[1024];
|
|
|
|
char *query = Cmd_Argv(1);
|
|
|
|
|
|
|
|
for (grp=cvar_groups ; grp ; grp=grp->next)
|
|
|
|
for (var=grp->cvars ; var ; var=var->next)
|
|
|
|
{
|
|
|
|
if (var->name && Q_strcasestr(var->name, query))
|
|
|
|
name = var->name;
|
|
|
|
else if (var->name2 && Q_strcasestr(var->name2, query))
|
|
|
|
name = var->name2;
|
|
|
|
else if (var->description && Q_strcasestr(var->description, query))
|
|
|
|
name = var->name;
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
|
|
|
|
COM_QuotedString(var->string, escapedvalue, sizeof(escapedvalue));
|
|
|
|
|
|
|
|
if (var->latched_string)
|
|
|
|
{
|
|
|
|
COM_QuotedString(var->latched_string, latchedvalue, sizeof(latchedvalue));
|
|
|
|
Con_Printf("cvar ^2%s^7: %s (effective %s): %s\n", name, latchedvalue, escapedvalue, var->description?var->description:"no description");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Con_Printf("cvar ^2%s^7: %s : %s\n", name, escapedvalue, var->description?var->description:"no description");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
|
|
|
{
|
|
|
|
if (cmd->name && Q_strcasestr(cmd->name, query))
|
|
|
|
;
|
|
|
|
else if (cmd->description && strstr(cmd->description, query))
|
|
|
|
;
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
Con_Printf("command ^2%s^7: %s\n", cmd->name, cmd->description?cmd->description:"no description");
|
|
|
|
}
|
|
|
|
//FIXME: add aliases.
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
#ifndef SERVERONLY // FIXME
|
|
|
|
/*
|
|
|
|
===================
|
|
|
|
Cmd_ForwardToServer
|
|
|
|
|
|
|
|
adds the current command line as a clc_stringcmd to the client message.
|
|
|
|
things like godmode, noclip, etc, are commands directed to the server,
|
|
|
|
so when they are typed in at the console, they will need to be forwarded.
|
|
|
|
===================
|
|
|
|
*/
|
|
|
|
void Cmd_ForwardToServer (void)
|
|
|
|
{
|
2013-03-12 23:18:12 +00:00
|
|
|
int sp;
|
2004-08-21 01:25:48 +00:00
|
|
|
if (cls.state == ca_disconnected)
|
|
|
|
{
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
if (cl_warncmd.ival)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("Can't \"%s\", not connected\n", Cmd_Argv(0));
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
if (cls.demoplayback)
|
|
|
|
return; // not really connected
|
|
|
|
|
2004-12-24 08:45:56 +00:00
|
|
|
#ifdef Q3CLIENT
|
2005-06-04 04:20:20 +00:00
|
|
|
if (cls.protocol == CP_QUAKE3)
|
2004-12-24 08:45:56 +00:00
|
|
|
{
|
2005-02-09 19:32:09 +00:00
|
|
|
CLQ3_SendClientCommand("%s %s", Cmd_Argv(0), Cmd_Args());
|
2004-12-24 08:45:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-03-12 23:18:12 +00:00
|
|
|
sp = CL_TargettedSplit(false);
|
|
|
|
if (sp)
|
|
|
|
{
|
|
|
|
if (Cmd_Argc() > 1)
|
|
|
|
CL_SendClientCommand(true, "%i %s %s", sp+1, Cmd_Argv(0), Cmd_Args());
|
|
|
|
else
|
|
|
|
CL_SendClientCommand(true, "%i %s", sp+1, Cmd_Argv(0));
|
|
|
|
}
|
2005-02-28 07:16:19 +00:00
|
|
|
else
|
2013-03-12 23:18:12 +00:00
|
|
|
{
|
|
|
|
if (Cmd_Argc() > 1)
|
|
|
|
CL_SendClientCommand(true, "%s %s", Cmd_Argv(0), Cmd_Args());
|
|
|
|
else
|
|
|
|
CL_SendClientCommand(true, "%s", Cmd_Argv(0));
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// don't forward the first argument
|
|
|
|
void Cmd_ForwardToServer_f (void)
|
|
|
|
{
|
|
|
|
if (cls.state == ca_disconnected)
|
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("Can't \"%s\", not connected\n", Cmd_Argv(0));
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-12 23:24:15 +00:00
|
|
|
if (Q_strcasecmp(Cmd_Argv(1), "snap") == 0 && cls.protocol == CP_QUAKEWORLD)
|
2006-11-03 15:53:04 +00:00
|
|
|
{
|
2004-08-21 01:25:48 +00:00
|
|
|
if (SCR_RSShot())
|
|
|
|
return;
|
|
|
|
}
|
2013-03-12 22:35:33 +00:00
|
|
|
if (Q_strcasecmp(Cmd_Argv(1), "pext") == 0 && (cls.protocol != CP_NETQUAKE || cls.protocol_nq != CPNQ_ID || cls.netchan.remote_address.type != NA_LOOPBACK))
|
|
|
|
{ //don't send any extension flags this if we're using cl_loopbackprotocol nqid, purely for a compat test.
|
|
|
|
//if you want to record compat-demos, disable extensions instead.
|
|
|
|
unsigned int fp1 = Net_PextMask(1, cls.protocol == CP_NETQUAKE), fp2 = Net_PextMask(2, cls.protocol == CP_NETQUAKE);
|
|
|
|
CL_SendClientCommand(true, "pext %#x %#x %#x %#x", PROTOCOL_VERSION_FTE, fp1, PROTOCOL_VERSION_FTE2, fp2);
|
|
|
|
return;
|
|
|
|
}
|
2006-11-03 15:53:04 +00:00
|
|
|
if (Q_strcasecmp(Cmd_Argv(1), "ptrack") == 0)
|
|
|
|
{
|
2013-06-23 02:17:02 +00:00
|
|
|
playerview_t *pv = &cl.playerview[CL_TargettedSplit(false)];
|
2006-11-03 15:53:04 +00:00
|
|
|
if (!*Cmd_Argv(2))
|
|
|
|
{
|
2013-06-23 02:17:02 +00:00
|
|
|
Cam_Unlock(pv);
|
2006-11-03 15:53:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-06-23 02:17:02 +00:00
|
|
|
Cam_Lock(pv, atoi(Cmd_Argv(2)));
|
|
|
|
pv->cam_auto = CAM_TRACK;
|
2006-11-03 15:53:04 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
if (Cmd_Argc() > 1)
|
2014-02-07 08:38:40 +00:00
|
|
|
{
|
|
|
|
int split = CL_TargettedSplit(true);
|
|
|
|
if (split)
|
|
|
|
CL_SendClientCommand(true, "%i %s", split+1, Cmd_Args());
|
|
|
|
else
|
|
|
|
CL_SendClientCommand(true, "%s", Cmd_Args());
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
void Cmd_ForwardToServer (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cmd_ExecuteString
|
|
|
|
|
|
|
|
A complete command line has been parsed, so try to execute it
|
|
|
|
FIXME: lookupnoadd the token to speed search?
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void Cmd_ExecuteString (char *text, int level)
|
2005-07-03 15:16:20 +00:00
|
|
|
{
|
2013-08-21 07:14:39 +00:00
|
|
|
//WARNING: PF_checkcommand should match the order.
|
2004-08-21 01:25:48 +00:00
|
|
|
cmd_function_t *cmd;
|
|
|
|
cmdalias_t *a;
|
|
|
|
|
2008-01-29 23:18:06 +00:00
|
|
|
char dest[8192];
|
2004-09-20 23:25:38 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
Cmd_ExecLevel = level;
|
|
|
|
|
2008-05-25 22:23:43 +00:00
|
|
|
text = Cmd_ExpandString(text, dest, sizeof(dest), level, !Cmd_IsInsecure()?true:false, true);
|
2005-03-28 00:11:59 +00:00
|
|
|
Cmd_TokenizeString (text, level == RESTRICT_LOCAL?true:false, false);
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
// execute the command line
|
|
|
|
if (!Cmd_Argc())
|
|
|
|
return; // no tokens
|
|
|
|
|
|
|
|
// check functions
|
|
|
|
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
|
|
|
|
{
|
|
|
|
if (!Q_strcasecmp (cmd_argv[0],cmd->name))
|
|
|
|
{
|
|
|
|
if (strcmp (cmd_argv[0],cmd->name))
|
|
|
|
break; //yes, I know we found it... (but it's the wrong case, go for an alias or cvar instead FIRST)
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if ((cmd->restriction?cmd->restriction:rcon_level.ival) > level)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("%s was restricted.\n", cmd_argv[0]);
|
2004-08-21 01:25:48 +00:00
|
|
|
else if (!cmd->function)
|
2005-09-08 22:52:46 +00:00
|
|
|
{
|
|
|
|
#ifdef VM_CG
|
|
|
|
if (CG_Command())
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
#ifdef Q3SERVER
|
|
|
|
if (SVQ3_Command())
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
#ifdef VM_UI
|
|
|
|
if (UI_Command())
|
|
|
|
return;
|
|
|
|
#endif
|
2009-07-14 15:14:25 +00:00
|
|
|
if (Cmd_AliasExist(cmd_argv[0], level))
|
2014-10-05 20:04:11 +00:00
|
|
|
return; //server stuffed an alias for a command that it would already have received. use that instead.
|
|
|
|
#if defined(CSQC_DAT) && !defined(SERVERONLY)
|
|
|
|
if (CSQC_ConsoleCommand(text))
|
|
|
|
return; //let the csqc handle it if it wants.
|
|
|
|
#endif
|
2004-08-21 01:25:48 +00:00
|
|
|
Cmd_ForwardToServer ();
|
2005-09-08 22:52:46 +00:00
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
else
|
|
|
|
cmd->function ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check alias
|
|
|
|
for (a=cmd_alias ; a ; a=a->next)
|
|
|
|
{
|
|
|
|
if (!Q_strcasecmp (cmd_argv[0], a->name))
|
|
|
|
{
|
2005-07-03 15:16:20 +00:00
|
|
|
int execlevel;
|
2005-09-17 17:05:21 +00:00
|
|
|
|
|
|
|
#ifndef SERVERONLY //an emergency escape mechansim, to avoid infinatly recursing aliases.
|
2005-09-14 04:20:19 +00:00
|
|
|
extern qboolean keydown[];
|
|
|
|
|
2013-05-11 14:02:55 +00:00
|
|
|
if (keydown[K_SHIFT] && (keydown[K_LCTRL]||keydown[K_RCTRL]) && (keydown[K_LALT]||keydown[K_RALT]))
|
2005-09-14 04:20:19 +00:00
|
|
|
return;
|
2005-09-17 17:05:21 +00:00
|
|
|
#endif
|
2004-08-21 01:25:48 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if ((a->restriction?a->restriction:rcon_level.ival) > level)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("%s was restricted.\n", cmd_argv[0]);
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (a->execlevel)
|
2005-07-03 15:16:20 +00:00
|
|
|
execlevel = a->execlevel;
|
|
|
|
else
|
|
|
|
execlevel = level;
|
2004-08-21 01:25:48 +00:00
|
|
|
|
2006-02-06 01:06:17 +00:00
|
|
|
Cbuf_InsertText ("\n", execlevel, false);
|
2004-08-30 07:05:41 +00:00
|
|
|
|
|
|
|
// if the alias value is a command or cvar and
|
|
|
|
// the alias is called with parameters, add them
|
2008-01-29 23:18:06 +00:00
|
|
|
if (Cmd_Argc() > 1 && (!strncmp(a->value, "cmd ", 4) || (!strchr(a->value, ' ') && !strchr(a->value, '\t') &&
|
|
|
|
(Cvar_FindVar(a->value) || (Cmd_Exists(a->value) && a->value[0] != '+' && a->value[0] != '-'))))
|
2004-08-30 07:05:41 +00:00
|
|
|
)
|
|
|
|
{
|
2006-02-06 01:06:17 +00:00
|
|
|
Cbuf_InsertText (Cmd_Args(), execlevel, false);
|
|
|
|
Cbuf_InsertText (" ", execlevel, false);
|
2004-08-30 07:05:41 +00:00
|
|
|
}
|
|
|
|
|
2008-01-29 23:18:06 +00:00
|
|
|
Cmd_ExpandStringArguments (a->value, dest, sizeof(dest));
|
|
|
|
Cbuf_InsertText (dest, execlevel, false);
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// check cvars
|
|
|
|
if (Cvar_Command (level))
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cmd) //go for skipped ones
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
if ((cmd->restriction?cmd->restriction:rcon_level.ival) > level)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("%s was restricted.\n", cmd_argv[0]);
|
2004-08-21 01:25:48 +00:00
|
|
|
else if (!cmd->function)
|
|
|
|
Cmd_ForwardToServer ();
|
|
|
|
else
|
|
|
|
cmd->function ();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-05-15 18:49:04 +00:00
|
|
|
#ifndef SERVERONLY
|
|
|
|
#ifdef CSQC_DAT
|
|
|
|
if (CSQC_ConsoleCommand(text))
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2005-07-14 01:57:34 +00:00
|
|
|
#ifdef PLUGINS
|
|
|
|
if (Plugin_ExecuteString())
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
#ifndef CLIENTONLY
|
|
|
|
if (sv.state)
|
|
|
|
{
|
2013-08-21 07:14:39 +00:00
|
|
|
if (PR_ConsoleCmd(text))
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-12-24 08:45:56 +00:00
|
|
|
#ifdef VM_CG
|
|
|
|
if (CG_Command())
|
2005-05-15 18:49:04 +00:00
|
|
|
return;
|
2004-12-24 08:45:56 +00:00
|
|
|
#endif
|
2005-09-08 22:52:46 +00:00
|
|
|
#ifdef Q3SERVER
|
|
|
|
if (SVQ3_Command())
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
#ifdef VM_UI
|
|
|
|
if (UI_Command())
|
|
|
|
return;
|
|
|
|
#endif
|
2004-08-21 01:25:48 +00:00
|
|
|
#ifdef Q2CLIENT
|
2005-09-08 22:52:46 +00:00
|
|
|
if (cls.protocol == CP_QUAKE2 || cls.protocol == CP_QUAKE3)
|
2005-05-26 12:55:34 +00:00
|
|
|
{ //q2 servers convert unknown commands to text.
|
2004-08-21 01:25:48 +00:00
|
|
|
Cmd_ForwardToServer();
|
2005-05-15 18:49:04 +00:00
|
|
|
return;
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
#endif
|
2013-12-29 22:48:28 +00:00
|
|
|
if ((cl_warncmd.value && level <= RESTRICT_LOCAL) || developer.value)
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf ("Unknown command \"%s\"\n", Cmd_Argv(0));
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
Cmd_CheckParm
|
|
|
|
|
|
|
|
Returns the position (1 to argc-1) in the command's argument list
|
|
|
|
where the given parameter apears, or 0 if not present
|
|
|
|
================
|
|
|
|
*/
|
|
|
|
int Cmd_CheckParm (char *parm)
|
|
|
|
{
|
|
|
|
int i;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
if (!parm)
|
|
|
|
Sys_Error ("Cmd_CheckParm: NULL");
|
|
|
|
|
|
|
|
for (i = 1; i < Cmd_Argc (); i++)
|
|
|
|
if (! Q_strcasecmp (parm, Cmd_Argv (i)))
|
|
|
|
return i;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct tempstack_s{
|
|
|
|
struct tempstack_s *next;
|
|
|
|
char str[1];
|
|
|
|
} tempstack_t;
|
|
|
|
tempstack_t *ifstack;
|
|
|
|
|
|
|
|
void If_Token_Clear (tempstack_t *mark)
|
|
|
|
{
|
|
|
|
tempstack_t *ois;
|
|
|
|
while(ifstack)
|
|
|
|
{
|
|
|
|
if (ifstack == mark)
|
|
|
|
break;
|
|
|
|
ois = ifstack;
|
|
|
|
ifstack = ifstack->next;
|
|
|
|
Z_Free(ois);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tempstack_t *If_Token_GetMark (void)
|
|
|
|
{
|
|
|
|
return ifstack;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-28 00:11:59 +00:00
|
|
|
const char *retstring(const char *s)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
// return s;
|
|
|
|
tempstack_t *ret;
|
2005-03-28 00:11:59 +00:00
|
|
|
ret = (tempstack_t*)Z_Malloc(sizeof(tempstack_t)+strlen(s));
|
2004-08-21 01:25:48 +00:00
|
|
|
ret->next = ifstack;
|
|
|
|
ifstack=ret;
|
|
|
|
strcpy(ret->str, s);
|
|
|
|
return ret->str;
|
|
|
|
}
|
2012-01-17 07:57:46 +00:00
|
|
|
const char *retint(int f)
|
|
|
|
{
|
|
|
|
char s[1024];
|
|
|
|
tempstack_t *ret;
|
|
|
|
if (!f)
|
|
|
|
return "";
|
|
|
|
sprintf(s, "%d", f);
|
|
|
|
ret = (tempstack_t*)Z_Malloc(sizeof(tempstack_t)+strlen(s));
|
|
|
|
ret->next = ifstack;
|
|
|
|
ifstack=ret;
|
|
|
|
strcpy(ret->str, s);
|
|
|
|
return ret->str;
|
|
|
|
}
|
2005-03-28 00:11:59 +00:00
|
|
|
const char *retfloat(float f)
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
char s[1024];
|
|
|
|
tempstack_t *ret;
|
|
|
|
if (!f)
|
|
|
|
return "";
|
|
|
|
sprintf(s, "%f", f);
|
2005-03-28 00:11:59 +00:00
|
|
|
ret = (tempstack_t*)Z_Malloc(sizeof(tempstack_t)+strlen(s));
|
2004-08-21 01:25:48 +00:00
|
|
|
ret->next = ifstack;
|
|
|
|
ifstack=ret;
|
|
|
|
strcpy(ret->str, s);
|
|
|
|
return ret->str;
|
|
|
|
}
|
2005-03-28 00:11:59 +00:00
|
|
|
qboolean is_numeric (const char *c)
|
2005-07-03 15:16:20 +00:00
|
|
|
{
|
2004-08-21 01:25:48 +00:00
|
|
|
return (*c >= '0' && *c <= '9') ||
|
|
|
|
((*c == '-' || *c == '+') && (c[1] == '.' || (c[1]>='0' && c[1]<='9'))) ||
|
2005-03-28 00:11:59 +00:00
|
|
|
(*c == '.' && (c[1]>='0' && c[1]<='9'))?true:false;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
2006-09-17 00:59:22 +00:00
|
|
|
#define IFPUNCT "(,{})(\':;=!><&|+*/-"
|
2005-03-28 00:11:59 +00:00
|
|
|
const char *If_Token(const char *func, const char **end)
|
2005-07-03 15:16:20 +00:00
|
|
|
{
|
2005-03-28 00:11:59 +00:00
|
|
|
const char *s, *s2;
|
2004-08-21 01:25:48 +00:00
|
|
|
cvar_t *var;
|
|
|
|
int level;
|
|
|
|
while(*func <= ' ' && *func)
|
|
|
|
func++;
|
|
|
|
|
2006-09-17 00:59:22 +00:00
|
|
|
s = COM_ParseToken(func, IFPUNCT);
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
if (*com_token == '(')
|
|
|
|
{
|
|
|
|
s2 = s;
|
|
|
|
level=1;
|
|
|
|
while (*s2)
|
|
|
|
{
|
|
|
|
if (*s2 == ')')
|
|
|
|
{
|
|
|
|
level--;
|
|
|
|
if (!level)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (*s2 == '(')
|
|
|
|
level++;
|
|
|
|
s2++;
|
2005-07-03 15:16:20 +00:00
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
func = If_Token(s, end);
|
|
|
|
*end = s2+1;
|
|
|
|
s = *end;
|
|
|
|
s2 = func;
|
|
|
|
// return func;
|
|
|
|
}
|
|
|
|
else if (*com_token == '!')
|
|
|
|
{
|
|
|
|
func = If_Token(s, end);
|
|
|
|
for (s = func; *s; s++);
|
|
|
|
if (func && *func)
|
|
|
|
return "";
|
|
|
|
else
|
|
|
|
return "true";
|
|
|
|
}
|
2006-09-17 00:59:22 +00:00
|
|
|
else if (!strcmp(com_token, "int"))
|
|
|
|
{
|
|
|
|
func = If_Token(s, end);
|
2012-01-17 07:57:46 +00:00
|
|
|
return retint(atoi(func));
|
2006-09-17 00:59:22 +00:00
|
|
|
}
|
|
|
|
else if (!strcmp(com_token, "strlen"))
|
|
|
|
{
|
|
|
|
func = If_Token(s, end);
|
|
|
|
return retfloat(strlen(func));
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
else if (!strcmp(com_token, "defined")) //functions
|
|
|
|
{
|
2006-09-17 00:59:22 +00:00
|
|
|
s = COM_ParseToken(s, IFPUNCT);
|
2004-08-21 01:25:48 +00:00
|
|
|
var = Cvar_FindVar(com_token);
|
|
|
|
*end = s;
|
|
|
|
return retstring((var != NULL)?"true":"");
|
|
|
|
}
|
|
|
|
else if (!strcmp(com_token, "random"))
|
|
|
|
{
|
|
|
|
s2 = retfloat((rand()&0x7fff) / (float)0x7fff);
|
|
|
|
}
|
|
|
|
else if (!strcmp(com_token, "vid")) //mostly for use with the menu system.
|
|
|
|
{
|
2006-09-17 00:59:22 +00:00
|
|
|
s = COM_ParseToken(s, IFPUNCT);
|
2004-08-21 01:25:48 +00:00
|
|
|
#ifndef SERVERONLY
|
|
|
|
if (qrenderer == QR_NONE)
|
|
|
|
s2 = "";
|
|
|
|
else if (!strcmp(com_token, "width"))
|
|
|
|
s2 = retfloat(vid.width);
|
|
|
|
else if (!strcmp(com_token, "height"))
|
|
|
|
s2 = retfloat(vid.height);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
s2 = "";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (*com_token == '$')
|
|
|
|
var = Cvar_FindVar(com_token+1);
|
|
|
|
else
|
|
|
|
var = Cvar_FindVar(com_token); //for consistancy.
|
|
|
|
if (var)
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
if ((var->restriction?var->restriction:rcon_level.ival) > Cmd_ExecLevel)
|
2004-08-21 01:25:48 +00:00
|
|
|
s2 = "RESTRICTED";
|
|
|
|
else
|
2005-07-03 15:16:20 +00:00
|
|
|
s2 = var->string;
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
s2 = retstring(com_token);
|
|
|
|
}
|
|
|
|
|
|
|
|
*end = s;
|
|
|
|
|
2006-09-17 00:59:22 +00:00
|
|
|
s = COM_ParseToken(s, IFPUNCT);
|
2004-08-21 01:25:48 +00:00
|
|
|
if (!strcmp(com_token, "=")) //comparisions
|
|
|
|
{
|
2006-09-17 00:59:22 +00:00
|
|
|
func=COM_ParseToken(s, IFPUNCT);
|
2004-08-21 01:25:48 +00:00
|
|
|
if (*com_token == '=') //lol. "=" == "=="
|
|
|
|
return retfloat(!strcmp(s2, If_Token(func, end)));
|
|
|
|
else
|
|
|
|
return retfloat(!strcmp(s2, If_Token(s, end)));
|
|
|
|
}
|
|
|
|
if (!strncmp(com_token, "equal", 5))
|
|
|
|
return retfloat(!strcmp(s2, If_Token(s, end)));
|
|
|
|
if (!strcmp(com_token, "!"))
|
|
|
|
{
|
2006-09-17 00:59:22 +00:00
|
|
|
func=COM_ParseToken(s, IFPUNCT);
|
2004-08-21 01:25:48 +00:00
|
|
|
if (*com_token == '=')
|
|
|
|
{
|
|
|
|
s = If_Token(func, end);
|
|
|
|
if (!is_numeric(s) || !is_numeric(s2))
|
|
|
|
{
|
|
|
|
if (strcmp(s2, s))
|
|
|
|
return "true";
|
|
|
|
else
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
return retfloat(atof(s2)!=atof(s));
|
|
|
|
}
|
|
|
|
else if (!strcmp(com_token, "isin"))
|
|
|
|
return retfloat(NULL==strstr(If_Token(s, end), s2));
|
|
|
|
}
|
|
|
|
if (!strcmp(com_token, ">"))
|
|
|
|
{
|
2006-09-17 00:59:22 +00:00
|
|
|
func=COM_ParseToken(s, IFPUNCT);
|
2004-08-21 01:25:48 +00:00
|
|
|
if (*com_token == '=')
|
|
|
|
return retfloat(atof(s2)>=atof(If_Token(func, end)));
|
|
|
|
else if (*com_token == '<')//vb?
|
|
|
|
{
|
|
|
|
s = If_Token(func, end);
|
|
|
|
if (is_numeric(s) && is_numeric(s2))
|
|
|
|
{
|
|
|
|
if (strcmp(s2, s))
|
|
|
|
return "true";
|
|
|
|
else
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
return retfloat(atof(s2)!=atof(s));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return retfloat(atof(s2)>atof(If_Token(s, end)));
|
|
|
|
}
|
|
|
|
if (!strcmp(com_token, "<"))
|
|
|
|
{
|
2006-09-17 00:59:22 +00:00
|
|
|
func=COM_ParseToken(s, IFPUNCT);
|
2004-08-21 01:25:48 +00:00
|
|
|
if (*com_token == '=')
|
|
|
|
return retfloat(atof(s2)<=atof(If_Token(func, end)));
|
|
|
|
else if (*com_token == '>')//vb?
|
|
|
|
return retfloat(atof(s2)!=atof(If_Token(func, end)));
|
|
|
|
else
|
|
|
|
return retfloat(atof(s2)<atof(If_Token(s, end)));
|
|
|
|
}
|
|
|
|
if (!strcmp(com_token, "isin"))//fuhq
|
|
|
|
return retfloat(NULL!=strstr(If_Token(s, end), s2));
|
|
|
|
|
|
|
|
if (!strcmp(com_token, "-")) //subtract
|
|
|
|
return retfloat(atof(s2)-atof(If_Token(s, end)));
|
|
|
|
if (!strcmp(com_token, "+")) //add
|
|
|
|
return retfloat(atof(s2)+atof(If_Token(s, end)));
|
|
|
|
if (!strcmp(com_token, "*"))
|
|
|
|
return retfloat(atof(s2)*atof(If_Token(s, end)));
|
|
|
|
if (!strcmp(com_token, "/"))
|
|
|
|
return retfloat(atof(s2)/atof(If_Token(s, end)));
|
2006-09-17 00:59:22 +00:00
|
|
|
if (!strcmp(com_token, "%"))
|
|
|
|
{
|
|
|
|
level = (int)atof(If_Token(s, end));
|
|
|
|
if (level == 0)
|
|
|
|
return retfloat(0);
|
|
|
|
else
|
|
|
|
return retfloat((int)atof(s2)%level);
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
if (!strcmp(com_token, "&")) //and
|
|
|
|
{
|
2006-09-17 00:59:22 +00:00
|
|
|
func=COM_ParseToken(s, IFPUNCT);
|
2004-08-21 01:25:48 +00:00
|
|
|
if (*com_token == '&')
|
|
|
|
return retfloat(*s2&&*If_Token(s, end));
|
|
|
|
else
|
|
|
|
return retfloat(atoi(s2)&atoi(If_Token(s, end)));
|
|
|
|
}
|
2006-09-17 00:59:22 +00:00
|
|
|
if (!strcmp(com_token, "div")) //qw262 compatability
|
|
|
|
return retfloat(atof(s2)/atof(If_Token(s, end)));
|
|
|
|
if (!strcmp(com_token, "or")) //qw262 compatability
|
|
|
|
return retfloat(atoi(s2)|atoi(If_Token(s, end)));
|
|
|
|
if (!strcmp(com_token, "xor")) //qw262 compatability
|
|
|
|
return retfloat(atoi(s2)^atoi(If_Token(s, end)));
|
|
|
|
if (!strcmp(com_token, "and")) //qw262 compatability
|
|
|
|
return retfloat(atoi(s2)&atoi(If_Token(s, end)));
|
2004-08-21 01:25:48 +00:00
|
|
|
if (!strcmp(com_token, "|")) //or
|
|
|
|
{
|
2006-09-17 00:59:22 +00:00
|
|
|
func=COM_ParseToken(s, IFPUNCT);
|
2004-08-21 01:25:48 +00:00
|
|
|
if (*com_token == '|')
|
|
|
|
{
|
|
|
|
func = If_Token(func, end);
|
|
|
|
return retfloat(atoi(s2)||atoi(func));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return retfloat(atoi(s2)|atoi(If_Token(s, end)));
|
|
|
|
}
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
return s2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cbuf_ExecBlock(int level)
|
|
|
|
{
|
|
|
|
char *remainingcbuf;
|
|
|
|
char *exectext = NULL;
|
|
|
|
char *line, *end;
|
2011-12-05 15:23:40 +00:00
|
|
|
line = Cbuf_GetNext(level, false);
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
while(*line <= ' ' && *line) //skip leading whitespace.
|
|
|
|
line++;
|
|
|
|
|
|
|
|
for (end = line + strlen(line)-1; end >= line && *end <= ' '; end--) //skip trailing
|
|
|
|
*end = '\0';
|
|
|
|
|
|
|
|
if (!strcmp(line, "{")) //multiline block
|
|
|
|
{
|
|
|
|
int indent = 1;
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
2011-12-05 15:23:40 +00:00
|
|
|
line = Cbuf_GetNext(level, false);
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
while(*line <= ' ' && *line) //skip leading whitespace.
|
|
|
|
line++;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
for (end = line + strlen(line)-1; end >= line && *end <= ' '; end--) //skip trailing
|
|
|
|
*end = '\0';
|
|
|
|
|
|
|
|
if (!strcmp(line, "{"))
|
|
|
|
indent++;
|
|
|
|
else if (!strcmp(line, "}"))
|
|
|
|
{
|
|
|
|
indent--;
|
|
|
|
if (!indent)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!*line)
|
|
|
|
{
|
|
|
|
Con_Printf("Unterminated block\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (exectext)
|
|
|
|
{
|
|
|
|
char *newv;
|
2005-03-28 00:11:59 +00:00
|
|
|
newv = (char*)Z_Malloc(strlen(exectext) + strlen(line) + 2);
|
2004-08-21 01:25:48 +00:00
|
|
|
sprintf(newv, "%s;%s", exectext, line);
|
|
|
|
Z_Free(exectext);
|
|
|
|
exectext = newv;
|
|
|
|
}
|
|
|
|
else
|
2013-08-27 13:18:09 +00:00
|
|
|
exectext = Z_StrDup(line);
|
2004-08-21 01:25:48 +00:00
|
|
|
// Con_Printf("Exec \"%s\"\n", line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-08-27 13:18:09 +00:00
|
|
|
exectext = Z_StrDup(line);
|
2004-08-21 01:25:48 +00:00
|
|
|
// Con_Printf("Exec \"%s\"\n", line);
|
|
|
|
}
|
|
|
|
remainingcbuf = Cbuf_StripText(level); //this craziness is to prevent an if } from breaking the entire con text
|
|
|
|
Cbuf_AddText(exectext, level);
|
|
|
|
Z_Free(exectext);
|
|
|
|
Cbuf_ExecuteLevel(level);
|
|
|
|
Cbuf_AddText(remainingcbuf, level);
|
|
|
|
Z_Free(remainingcbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cbuf_SkipBlock(int level)
|
|
|
|
{
|
|
|
|
char *line, *end;
|
2011-12-05 15:23:40 +00:00
|
|
|
line = Cbuf_GetNext(level, false);
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
while(*line <= ' ' && *line) //skip leading whitespace.
|
|
|
|
line++;
|
|
|
|
|
|
|
|
for (end = line + strlen(line)-1; end >= line && *end <= ' '; end--) //skip trailing
|
|
|
|
*end = '\0';
|
|
|
|
|
|
|
|
if (!strcmp(line, "{")) //multiline block
|
|
|
|
{
|
|
|
|
int indent = 1;
|
|
|
|
|
|
|
|
for(;;)
|
|
|
|
{
|
2011-12-05 15:23:40 +00:00
|
|
|
line = Cbuf_GetNext(level, false);
|
2004-08-21 01:25:48 +00:00
|
|
|
|
|
|
|
while(*line <= ' ' && *line) //skip leading whitespace.
|
|
|
|
line++;
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
for (end = line + strlen(line)-1; end >= line && *end <= ' '; end--) //skip trailing
|
|
|
|
*end = '\0';
|
|
|
|
|
|
|
|
if (!strcmp(line, "{"))
|
|
|
|
indent++;
|
|
|
|
else if (!strcmp(line, "}"))
|
|
|
|
{
|
|
|
|
indent--;
|
|
|
|
if (!indent)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!*line)
|
|
|
|
{
|
|
|
|
Con_Printf("Unterminated block\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Con_Printf("Skip \"%s\"\n", line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// else
|
|
|
|
// Con_Printf("Skip \"%s\"\n", line);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cmd_if_f(void)
|
|
|
|
{
|
|
|
|
char *text = Cmd_Args();
|
2005-03-28 00:11:59 +00:00
|
|
|
const char *ret;
|
2004-08-21 01:25:48 +00:00
|
|
|
char *end;
|
2005-03-28 00:11:59 +00:00
|
|
|
char *ws;
|
2004-08-21 01:25:48 +00:00
|
|
|
int level;
|
|
|
|
qboolean trueblock=false;
|
|
|
|
tempstack_t *ts;
|
|
|
|
|
|
|
|
if (Cmd_Argc()==1)
|
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("if <condition> <statement> [elseif <condition> <statement>] [...] [else <statement>]\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ts = If_Token_GetMark();
|
|
|
|
level = Cmd_ExecLevel;
|
|
|
|
|
|
|
|
elseif:
|
|
|
|
// Con_Printf("if %s\n", text);
|
2005-03-28 00:11:59 +00:00
|
|
|
for(ret = If_Token(text, (const char **)&end); *ret; ret++) {if (*ret != '0' && *ret != '.')break;}
|
2004-08-21 01:25:48 +00:00
|
|
|
if (!end)
|
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("Not terminated\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
If_Token_Clear(ts);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
skipws:
|
|
|
|
while(*end <= ' ' && *end) //skip leading whitespace.
|
|
|
|
end++;
|
|
|
|
|
|
|
|
for (ws = end + strlen(end)-1; ws >= end && *ws <= ' '; ws--) //skip trailing
|
|
|
|
*ws = '\0';
|
|
|
|
|
2005-04-26 16:04:12 +00:00
|
|
|
if (!strncmp(end, "then", 4)) //sigh... trying to make fuhquake's ifs work.
|
2004-08-21 01:25:48 +00:00
|
|
|
{
|
|
|
|
end+=4;
|
|
|
|
goto skipws;
|
|
|
|
}
|
2005-07-03 15:16:20 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
if (!*end)
|
|
|
|
{
|
|
|
|
if (ret && *ret) //equation was true.
|
|
|
|
{
|
|
|
|
trueblock = true;
|
|
|
|
Cbuf_ExecBlock(level);
|
|
|
|
}
|
|
|
|
else //equation was false.
|
|
|
|
{
|
|
|
|
skipblock:
|
|
|
|
Cbuf_SkipBlock(level);
|
|
|
|
}
|
2011-12-05 15:23:40 +00:00
|
|
|
end = Cbuf_GetNext(level, false);
|
2004-08-21 01:25:48 +00:00
|
|
|
while(*end <= ' ' && *end)
|
|
|
|
end++;
|
|
|
|
if (!strncmp(end, "else", 4))
|
|
|
|
{
|
|
|
|
end+=4;
|
|
|
|
while(*end <= ' ' && *end) //skip leading whitespace.
|
|
|
|
end++;
|
|
|
|
|
|
|
|
if (!strncmp(end, "if", 2))
|
|
|
|
{
|
|
|
|
text = end + 2;
|
|
|
|
if (trueblock)
|
|
|
|
goto skipblock; //we've had our true, all others are assumed to be false.
|
|
|
|
else
|
|
|
|
goto elseif; //and have annother go.
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ //we got an else. This is the last block. Don't go through the normal way, cos that would let us follow up with a second else.
|
|
|
|
if (trueblock)
|
|
|
|
Cbuf_SkipBlock(level);
|
|
|
|
else
|
|
|
|
Cbuf_ExecBlock(level);
|
|
|
|
|
|
|
|
If_Token_Clear(ts);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//whoops. Too far.
|
2006-02-06 01:06:17 +00:00
|
|
|
Cbuf_InsertText(end, level, true);
|
2004-08-21 01:25:48 +00:00
|
|
|
If_Token_Clear(ts);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
text = strstr(end, "else");
|
|
|
|
if (ret && *ret)
|
|
|
|
{
|
|
|
|
if (text) //don't bother execing the else bit...
|
|
|
|
*text = '\0';
|
2006-02-06 01:06:17 +00:00
|
|
|
Cbuf_InsertText(end, level, true);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (text)
|
2006-02-06 01:06:17 +00:00
|
|
|
Cbuf_InsertText(text+4, level, true); //ironically, this will do elseif...
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
If_Token_Clear(ts);
|
|
|
|
}
|
|
|
|
|
2005-09-08 22:52:46 +00:00
|
|
|
void Cmd_Vstr_f( void )
|
|
|
|
{
|
|
|
|
char *v;
|
|
|
|
|
|
|
|
if (Cmd_Argc () != 2)
|
|
|
|
{
|
|
|
|
Con_Printf ("vstr <variablename> : execute a variable command\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
v = Cvar_VariableString(Cmd_Argv(1));
|
2006-02-06 01:06:17 +00:00
|
|
|
Cbuf_InsertText(v, Cmd_ExecLevel, true);
|
2005-09-08 22:52:46 +00:00
|
|
|
}
|
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
void Cmd_toggle_f(void)
|
|
|
|
{
|
|
|
|
cvar_t *v;
|
|
|
|
if (Cmd_Argc()<2)
|
|
|
|
{
|
|
|
|
Con_Printf("missing cvar name\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
v = Cvar_Get(Cmd_Argv(1), "0", 0, "Custom variables");
|
|
|
|
if (!v)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (v->value)
|
|
|
|
Cvar_Set(v, "0");
|
|
|
|
else
|
|
|
|
Cvar_Set(v, "1");
|
|
|
|
}
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
void Cmd_set_f(void)
|
|
|
|
{
|
2005-09-17 16:49:21 +00:00
|
|
|
void *mark;
|
2004-08-21 01:25:48 +00:00
|
|
|
cvar_t *var;
|
2005-03-28 00:11:59 +00:00
|
|
|
const char *end;
|
|
|
|
const char *text;
|
|
|
|
int forceflags = 0;
|
2006-09-17 00:59:22 +00:00
|
|
|
qboolean docalc;
|
2010-07-18 08:42:59 +00:00
|
|
|
char name[256];
|
2005-03-28 00:11:59 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
if (Cmd_Argc()<3)
|
|
|
|
{
|
2013-11-29 14:36:47 +00:00
|
|
|
Con_TPrintf("set <var> <equation>\n");
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-09-17 00:59:22 +00:00
|
|
|
if (!strcmp(Cmd_Argv(0), "set_calc") || !strcmp(Cmd_Argv(0), "seta_calc"))
|
|
|
|
docalc = true;
|
|
|
|
else
|
|
|
|
docalc = false;
|
|
|
|
|
2010-07-18 08:42:59 +00:00
|
|
|
Q_strncpyz(name, Cmd_Argv(1), sizeof(name));
|
2005-03-28 00:11:59 +00:00
|
|
|
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
if (!strcmp(Cmd_Argv(0), "setfl") || Cmd_FromGamecode()) //AAHHHH!!! Q2 set command is different
|
2005-03-28 00:11:59 +00:00
|
|
|
{
|
|
|
|
text = Cmd_Argv(3);
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
while(*text)
|
|
|
|
{
|
|
|
|
switch(*text++)
|
|
|
|
{
|
|
|
|
case 'u':
|
|
|
|
forceflags |= CVAR_USERINFO;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
forceflags |= CVAR_SERVERINFO;
|
|
|
|
break;
|
|
|
|
case 'a':
|
|
|
|
forceflags |= CVAR_ARCHIVE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2005-03-28 00:11:59 +00:00
|
|
|
text = Cmd_Argv(2);
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
|
|
|
|
/*desc = Cmd_Argv(4)*/
|
2005-03-28 00:11:59 +00:00
|
|
|
}
|
2012-01-17 07:57:46 +00:00
|
|
|
else if (dpcompat_set.ival && !docalc)
|
2010-07-18 08:42:59 +00:00
|
|
|
{
|
|
|
|
text = Cmd_Argv(2);
|
|
|
|
/*desc = Cmd_Argv(3)*/
|
|
|
|
}
|
2005-03-28 00:11:59 +00:00
|
|
|
else
|
|
|
|
{
|
2006-09-17 00:59:22 +00:00
|
|
|
Cmd_ShiftArgs(1, false);
|
2005-03-28 00:11:59 +00:00
|
|
|
text = Cmd_Args();
|
2013-07-26 17:19:06 +00:00
|
|
|
if (*text == '\"' || (*text == '\\' && text[1] == '\"')) //if it's already quoted, dequote it, and ignore trailing stuff, for q2/q3 compatability
|
2006-09-17 00:59:22 +00:00
|
|
|
text = Cmd_Argv(1);
|
2008-11-09 22:29:28 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
end = strstr(text, "//");
|
|
|
|
if (end)
|
|
|
|
{
|
2010-07-11 10:53:13 +00:00
|
|
|
end--;
|
2008-11-09 22:29:28 +00:00
|
|
|
while (end >= text)
|
|
|
|
{
|
|
|
|
if (*end == ' ')
|
|
|
|
end--;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
end++;
|
|
|
|
*(char*)end = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2005-03-28 00:11:59 +00:00
|
|
|
forceflags = 0;
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
|
2010-07-18 08:42:59 +00:00
|
|
|
var = Cvar_Get (name, text, 0, "Custom variables");
|
|
|
|
|
2005-09-17 16:49:21 +00:00
|
|
|
mark = If_Token_GetMark();
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
if (var)
|
2004-11-13 17:22:13 +00:00
|
|
|
{
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
if (var->flags & CVAR_NOTFROMSERVER && Cmd_IsInsecure())
|
2004-11-13 17:22:13 +00:00
|
|
|
{
|
|
|
|
Con_Printf ("Server tried setting %s cvar\n", var->name);
|
2004-11-17 17:37:18 +00:00
|
|
|
return;
|
2004-11-13 17:22:13 +00:00
|
|
|
}
|
2013-10-29 17:38:22 +00:00
|
|
|
if (var->flags & CVAR_NOSET)
|
|
|
|
{
|
|
|
|
Con_Printf ("variable %s is readonly\n", var->name);
|
|
|
|
return;
|
|
|
|
}
|
2004-11-13 17:22:13 +00:00
|
|
|
|
2005-04-16 16:21:27 +00:00
|
|
|
if (Cmd_FromGamecode())
|
2005-03-28 00:11:59 +00:00
|
|
|
{
|
|
|
|
if (forceflags)
|
|
|
|
{
|
|
|
|
var->flags &=~(CVAR_USERINFO|CVAR_SERVERINFO);
|
|
|
|
var->flags |= forceflags;
|
|
|
|
}
|
2004-11-13 17:22:13 +00:00
|
|
|
Cvar_LockFromServer(var, text);
|
2005-03-28 00:11:59 +00:00
|
|
|
}
|
2004-11-13 17:22:13 +00:00
|
|
|
else
|
2005-03-28 00:11:59 +00:00
|
|
|
{
|
2006-09-17 00:59:22 +00:00
|
|
|
if (docalc)
|
|
|
|
text = If_Token(text, &end);
|
2004-11-13 17:22:13 +00:00
|
|
|
Cvar_Set(var, text);
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
var->flags |= CVAR_USERCREATED | forceflags;
|
2006-01-28 06:41:20 +00:00
|
|
|
|
|
|
|
if (!stricmp(Cmd_Argv(0), "seta"))
|
|
|
|
var->flags |= CVAR_ARCHIVE;
|
2005-03-28 00:11:59 +00:00
|
|
|
}
|
2004-11-13 17:22:13 +00:00
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
else
|
2004-11-13 17:22:13 +00:00
|
|
|
{
|
2006-09-17 00:59:22 +00:00
|
|
|
if (docalc)
|
|
|
|
text = If_Token(text, &end);
|
2005-04-16 16:21:27 +00:00
|
|
|
if (Cmd_FromGamecode())
|
2004-11-13 17:22:13 +00:00
|
|
|
{
|
|
|
|
var = Cvar_Get(Cmd_Argv(1), "", 0, "Game variables");
|
2006-09-17 00:59:22 +00:00
|
|
|
if (var)
|
|
|
|
Cvar_LockFromServer(var, text);
|
2004-11-13 17:22:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
var = Cvar_Get(Cmd_Argv(1), text, 0, "User variables");
|
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
|
2006-01-28 06:41:20 +00:00
|
|
|
if (var && !Cmd_FromGamecode())
|
2004-11-13 17:22:13 +00:00
|
|
|
if (!stricmp(Cmd_Argv(0), "seta"))
|
|
|
|
var->flags |= CVAR_ARCHIVE|CVAR_USERCREATED;
|
2005-09-17 16:49:21 +00:00
|
|
|
|
|
|
|
If_Token_Clear(mark);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Cvar_Inc_f (void)
|
|
|
|
{
|
|
|
|
int c;
|
|
|
|
cvar_t *var;
|
|
|
|
float delta;
|
|
|
|
|
|
|
|
c = Cmd_Argc();
|
|
|
|
if (c != 2 && c != 3)
|
|
|
|
{
|
|
|
|
Con_Printf ("inc <cvar> [value]\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var = Cvar_FindVar (Cmd_Argv(1));
|
|
|
|
if (!var)
|
|
|
|
{
|
|
|
|
Con_Printf ("Unknown variable \"%s\"\n", Cmd_Argv(1));
|
|
|
|
return;
|
|
|
|
}
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
if (var->flags & CVAR_NOTFROMSERVER && Cmd_IsInsecure())
|
2004-11-13 17:22:13 +00:00
|
|
|
{
|
|
|
|
Con_Printf ("Server tried setting %s cvar\n", var->name);
|
2004-11-17 17:37:18 +00:00
|
|
|
return;
|
2004-11-13 17:22:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
delta = (c == 3) ? atof (Cmd_Argv(2)) : 1;
|
|
|
|
|
|
|
|
Cvar_SetValue (var, var->value + delta);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cmd_WriteConfig_f(void)
|
|
|
|
{
|
2005-12-21 03:07:33 +00:00
|
|
|
vfsfile_t *f;
|
2004-08-21 01:25:48 +00:00
|
|
|
char *filename;
|
2006-03-11 03:12:10 +00:00
|
|
|
char fname[MAX_OSPATH];
|
2012-11-27 03:23:19 +00:00
|
|
|
char sysname[MAX_OSPATH];
|
2004-08-21 01:25:48 +00:00
|
|
|
|
2013-03-12 22:35:33 +00:00
|
|
|
if (Cmd_IsInsecure())
|
|
|
|
{
|
|
|
|
Con_Printf ("%s not allowed\n", Cmd_Argv(0));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
filename = Cmd_Argv(1);
|
|
|
|
if (!*filename)
|
|
|
|
{
|
2014-10-05 20:04:11 +00:00
|
|
|
#ifdef QUAKETC
|
|
|
|
snprintf(fname, sizeof(fname), "config.cfg");
|
|
|
|
#else
|
2009-06-21 17:45:33 +00:00
|
|
|
snprintf(fname, sizeof(fname), "fte.cfg");
|
2014-10-05 20:04:11 +00:00
|
|
|
#endif
|
2014-04-06 15:16:39 +00:00
|
|
|
FS_NativePath(fname, FS_GAMEONLY, sysname, sizeof(sysname));
|
2009-06-21 17:45:33 +00:00
|
|
|
FS_CreatePath(fname, FS_GAMEONLY);
|
2014-08-27 08:41:31 +00:00
|
|
|
f = FS_OpenVFS(fname, "wbp", FS_GAMEONLY);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
2009-06-21 17:45:33 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (strstr(filename, ".."))
|
|
|
|
{
|
|
|
|
Con_Printf ("Couldn't write config %s\n",filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
snprintf(fname, sizeof(fname), "configs/%s", filename);
|
|
|
|
COM_DefaultExtension(fname, ".cfg", sizeof(fname));
|
2007-10-05 17:23:43 +00:00
|
|
|
|
2014-04-06 15:16:39 +00:00
|
|
|
FS_NativePath(fname, FS_BASEGAMEONLY, sysname, sizeof(sysname));
|
2014-03-30 08:55:06 +00:00
|
|
|
FS_CreatePath(fname, FS_BASEGAMEONLY);
|
2014-08-27 08:41:31 +00:00
|
|
|
f = FS_OpenVFS(fname, "wbp", FS_BASEGAMEONLY);
|
2009-06-21 17:45:33 +00:00
|
|
|
}
|
2004-08-21 01:25:48 +00:00
|
|
|
if (!f)
|
|
|
|
{
|
2014-04-06 15:16:39 +00:00
|
|
|
Con_Printf ("Couldn't write config %s\n", sysname);
|
2004-08-21 01:25:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-06-21 17:45:33 +00:00
|
|
|
|
2005-12-21 03:07:33 +00:00
|
|
|
VFS_WRITE(f, "// FTE config file\n\n", 20);
|
2004-08-21 01:25:48 +00:00
|
|
|
#ifndef SERVERONLY
|
|
|
|
Key_WriteBindings (f);
|
2005-11-30 01:20:53 +00:00
|
|
|
CL_SaveInfo(f);
|
2004-08-21 01:25:48 +00:00
|
|
|
#else
|
2005-12-21 03:07:33 +00:00
|
|
|
VFS_WRITE(f, "// Dedicated Server config\n\n", 28);
|
2004-11-17 17:37:18 +00:00
|
|
|
#endif
|
|
|
|
#ifdef CLIENTONLY
|
2005-12-21 03:07:33 +00:00
|
|
|
VFS_WRITE(f, "// no local/server infos\n\n", 26);
|
2004-11-17 17:37:18 +00:00
|
|
|
#else
|
|
|
|
SV_SaveInfos(f);
|
2004-08-21 01:25:48 +00:00
|
|
|
#endif
|
|
|
|
Alias_WriteAliases (f);
|
|
|
|
Cvar_WriteVariables (f, true);
|
2005-12-21 03:07:33 +00:00
|
|
|
VFS_CLOSE(f);
|
2005-11-30 01:20:53 +00:00
|
|
|
|
2012-04-24 07:59:11 +00:00
|
|
|
Cvar_Saved();
|
2012-11-27 03:23:19 +00:00
|
|
|
|
|
|
|
Con_Printf ("Wrote %s\n",sysname);
|
2004-08-21 01:25:48 +00:00
|
|
|
}
|
|
|
|
|
2006-01-02 23:01:54 +00:00
|
|
|
void Cmd_Reset_f(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2005-09-21 01:14:04 +00:00
|
|
|
#ifndef SERVERONLY
|
|
|
|
// dumps current console contents to a text file
|
|
|
|
void Cmd_Condump_f(void)
|
|
|
|
{
|
2006-01-02 23:01:54 +00:00
|
|
|
vfsfile_t *f;
|
2005-09-21 01:14:04 +00:00
|
|
|
char *filename;
|
2006-01-02 23:01:54 +00:00
|
|
|
unsigned char c;
|
2005-09-21 01:14:04 +00:00
|
|
|
|
|
|
|
if (!con_current)
|
|
|
|
{
|
|
|
|
Con_Printf ("No console to dump.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Cmd_IsInsecure()) // don't allow insecure level execute this
|
|
|
|
return;
|
|
|
|
|
|
|
|
filename = Cmd_Argv(1);
|
|
|
|
if (!*filename)
|
|
|
|
filename = "condump";
|
|
|
|
|
2006-01-02 23:01:54 +00:00
|
|
|
filename = va("%s", filename);
|
2006-03-11 03:12:10 +00:00
|
|
|
COM_DefaultExtension(filename, ".txt", MAX_QPATH);
|
2011-05-15 13:23:13 +00:00
|
|
|
|
2006-01-02 23:01:54 +00:00
|
|
|
f = FS_OpenVFS (filename, "wb", FS_GAME);
|
2005-09-21 01:14:04 +00:00
|
|
|
if (!f)
|
|
|
|
{
|
|
|
|
Con_Printf ("Couldn't write console dump %s\n",filename);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// print out current contents of console
|
|
|
|
// stripping out starting blank lines and blank spaces
|
|
|
|
{
|
|
|
|
console_t *curcon = &con_main;
|
2009-07-05 18:45:53 +00:00
|
|
|
conline_t *l;
|
|
|
|
int i;
|
|
|
|
conchar_t *t;
|
|
|
|
for (l = curcon->oldest; l; l = l->newer)
|
|
|
|
{
|
|
|
|
t = (conchar_t*)(l+1);
|
|
|
|
//FIXME: utf8?
|
|
|
|
for (i = 0; i < l->length; i++)
|
2005-09-21 01:14:04 +00:00
|
|
|
{
|
2009-07-05 18:45:53 +00:00
|
|
|
c = (qbyte)t[i]&0xff;
|
|
|
|
VFS_WRITE(f, &c, 1);
|
2005-09-21 01:14:04 +00:00
|
|
|
}
|
2009-07-05 18:45:53 +00:00
|
|
|
VFS_WRITE(f, "\n", 1);
|
2005-09-21 01:14:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-01-02 23:01:54 +00:00
|
|
|
VFS_CLOSE(f);
|
2005-09-21 01:14:04 +00:00
|
|
|
|
|
|
|
Con_Printf ("Dumped console to %s\n",filename);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
void Cmd_Shutdown(void)
|
|
|
|
{
|
2012-05-09 15:30:53 +00:00
|
|
|
cmd_function_t *c;
|
2011-01-30 01:32:30 +00:00
|
|
|
cmdalias_t *a;
|
2012-07-05 19:42:36 +00:00
|
|
|
int i;
|
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
//make sure we get no other execution
|
|
|
|
int level;
|
|
|
|
for (level = 0; level < sizeof(cmd_text)/sizeof(cmd_text[0]); level++)
|
2012-07-05 19:42:36 +00:00
|
|
|
{
|
2009-04-01 22:03:56 +00:00
|
|
|
SZ_Clear (&cmd_text[level].buf);
|
|
|
|
|
2012-07-05 19:42:36 +00:00
|
|
|
if (cmd_text[level].buf.data)
|
|
|
|
{
|
|
|
|
BZ_Free(cmd_text[level].buf.data);
|
|
|
|
cmd_text[level].buf.data = NULL;
|
|
|
|
cmd_text[level].buf.maxsize = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-09 15:30:53 +00:00
|
|
|
while(cmd_functions)
|
|
|
|
{
|
|
|
|
c = cmd_functions;
|
|
|
|
cmd_functions = c->next;
|
|
|
|
Z_Free(c);
|
|
|
|
}
|
2011-01-30 01:32:30 +00:00
|
|
|
while(cmd_alias)
|
|
|
|
{
|
|
|
|
a = cmd_alias;
|
|
|
|
cmd_alias = a->next;
|
|
|
|
Z_Free(a->value);
|
|
|
|
Z_Free(a);
|
|
|
|
}
|
2012-07-05 19:42:36 +00:00
|
|
|
|
|
|
|
for (i=0 ; i<cmd_argc ; i++)
|
|
|
|
Z_Free (cmd_argv[i]);
|
|
|
|
Z_Free(cmd_args_buf);
|
|
|
|
cmd_argc = 0;
|
|
|
|
cmd_args_buf = NULL;
|
2009-04-01 22:03:56 +00:00
|
|
|
}
|
|
|
|
|
2012-04-16 12:15:05 +00:00
|
|
|
|
|
|
|
static char macro_buf[256] = "";
|
|
|
|
static char *Macro_Time (void)
|
|
|
|
{
|
|
|
|
time_t t;
|
|
|
|
struct tm *ptm;
|
|
|
|
|
|
|
|
time (&t);
|
|
|
|
ptm = localtime (&t);
|
|
|
|
if (!ptm)
|
|
|
|
return "#bad date#";
|
|
|
|
strftime (macro_buf, sizeof(macro_buf)-1, "%H:%M", ptm);
|
|
|
|
return macro_buf;
|
|
|
|
}
|
|
|
|
static char *Macro_UKDate (void) //and much but not all of EU
|
|
|
|
{
|
|
|
|
time_t t;
|
|
|
|
struct tm *ptm;
|
|
|
|
|
|
|
|
time (&t);
|
|
|
|
ptm = localtime (&t);
|
|
|
|
if (!ptm)
|
|
|
|
return "#bad date#";
|
|
|
|
strftime (macro_buf, sizeof(macro_buf)-1, "%d.%m.%Y", ptm);
|
|
|
|
return macro_buf;
|
|
|
|
}
|
2013-05-03 04:28:08 +00:00
|
|
|
static char *Macro_USDate (void) //and much but not all of EU
|
|
|
|
{
|
|
|
|
time_t t;
|
|
|
|
struct tm *ptm;
|
|
|
|
|
|
|
|
time (&t);
|
|
|
|
ptm = localtime (&t);
|
|
|
|
if (!ptm)
|
|
|
|
return "#bad date#";
|
2013-06-24 09:04:00 +00:00
|
|
|
strftime (macro_buf, sizeof(macro_buf)-1, "%m.%d.%Y", ptm);
|
2013-05-03 04:28:08 +00:00
|
|
|
return macro_buf;
|
|
|
|
}
|
2012-04-16 12:15:05 +00:00
|
|
|
static char *Macro_ProperDate (void) //americans get it wrong. besides, this is more easily sortable for filenames etc
|
|
|
|
{
|
|
|
|
time_t t;
|
|
|
|
struct tm *ptm;
|
|
|
|
|
|
|
|
time (&t);
|
|
|
|
ptm = localtime (&t);
|
|
|
|
if (!ptm)
|
|
|
|
return "#bad date#";
|
|
|
|
strftime (macro_buf, sizeof(macro_buf)-1, "%Y-%m-%d", ptm);
|
|
|
|
return macro_buf;
|
|
|
|
}
|
|
|
|
static char *Macro_Version (void)
|
|
|
|
{
|
|
|
|
/* you probably don't need date, but it's included as this is likly to be used by
|
|
|
|
q2 servers checking for cheats. */
|
|
|
|
return va("%.2f %s", 2.57, version_string());
|
|
|
|
}
|
|
|
|
static char *Macro_Quote (void)
|
|
|
|
{
|
|
|
|
return "\"";
|
|
|
|
}
|
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
/*
|
|
|
|
============
|
|
|
|
Cmd_Init
|
|
|
|
============
|
|
|
|
*/
|
|
|
|
void Cmd_Init (void)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// register our commands
|
|
|
|
//
|
2004-08-30 07:05:41 +00:00
|
|
|
Cmd_AddCommand ("cfg_save",Cmd_WriteConfig_f);
|
2005-03-18 06:13:36 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
Cmd_AddCommand ("cfg_load",Cmd_Exec_f);
|
2006-01-02 23:01:54 +00:00
|
|
|
Cmd_AddCommand ("cfg_reset",Cmd_Reset_f);
|
2004-08-30 07:05:41 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
Cmd_AddCommand ("exec",Cmd_Exec_f);
|
|
|
|
Cmd_AddCommand ("echo",Cmd_Echo_f);
|
|
|
|
Cmd_AddCommand ("alias",Cmd_Alias_f);
|
2008-01-05 09:58:55 +00:00
|
|
|
Cmd_AddCommand ("newalias",Cmd_Alias_f);
|
2004-08-21 01:25:48 +00:00
|
|
|
Cmd_AddCommand ("wait", Cmd_Wait_f);
|
|
|
|
#ifndef SERVERONLY
|
|
|
|
Cmd_AddCommand ("cmd", Cmd_ForwardToServer_f);
|
2005-09-21 01:14:04 +00:00
|
|
|
Cmd_AddCommand ("condump", Cmd_Condump_f);
|
2005-03-12 23:40:42 +00:00
|
|
|
#endif
|
2004-08-21 01:25:48 +00:00
|
|
|
Cmd_AddCommand ("restrict", Cmd_RestrictCommand_f);
|
|
|
|
Cmd_AddCommand ("aliaslevel", Cmd_AliasLevel_f);
|
2005-03-12 23:40:42 +00:00
|
|
|
|
2004-12-21 04:38:02 +00:00
|
|
|
Cmd_AddCommand ("showalias", Cmd_ShowAlias_f);
|
2004-08-21 01:25:48 +00:00
|
|
|
|
2004-09-30 22:49:01 +00:00
|
|
|
// Cmd_AddCommand ("msg_trigger", Cmd_Msg_Trigger_f);
|
|
|
|
// Cmd_AddCommand ("filter", Cmd_Msg_Filter_f);
|
2004-08-21 01:25:48 +00:00
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
Cmd_AddCommand ("toggle", Cmd_toggle_f);
|
2004-08-21 01:25:48 +00:00
|
|
|
Cmd_AddCommand ("set", Cmd_set_f);
|
------------------------------------------------------------------------
r4169 | acceptthis | 2013-01-17 08:55:12 +0000 (Thu, 17 Jan 2013) | 31 lines
removed MAX_VISEDICTS limit.
PEXT2_REPLACEMENTDELTAS tweaked, now has 4 million entity limit. still not enabled by default.
TE_BEAM now maps to a separate TEQW_BEAM to avoid conflicts with QW.
added android multitouch emulation for windows/rawinput (in_simulatemultitouch).
split topcolor/bottomcolor from scoreboard, for dp's colormap|1024 feature.
now using utf-8 for windows consoles.
qcc warnings/errors now give clickable console links for quick+easy editing.
disabled menutint when the currently active item changes contrast or gamma (for OneManClan).
Added support for drawfont/drawfontscale.
tweaked the qcvm a little to reduce the number of pointers.
.doll file loading. still experimental and will likely crash. requires csqc active, even if its a dummy progs. this will be fixed in time. Still other things that need cleaning up.
windows: gl_font "?" shows the standard windows font-selection dialog, and can be used to select windows fonts. not all work. and you probably don't want to use windings.
fixed splitscreen support when playing mvds. added mini-scoreboards to splitscreen.
editor/debugger now shows asm if there's no linenumber info. also, pressing f1 for help shows the shortcuts.
Added support for .framegroups files for psk(psa) and iqm formats.
True support for ezquake's colour codes. Mutually exclusive with background colours.
path command output slightly more readable.
added support for digest_hex (MD4, SHA1, CRC16).
skingroups now colourmap correctly.
Fix terrain colour hints, and litdata from the wrong bsp.
fix ftp dual-homed issue. support epsv command, and enable ipv6 (eprt still not supported).
remove d3d11 compilation from the makefile. the required headers are not provided by mingw, and are not available to the build bot, so don't bother.
fix v *= v.x and similar opcodes.
fteqcc: fixed support for áéÃóú type chars in names. utf-8 files now properly supported (even with the utf-8 bom/identifier). utf-16 also supported.
fteqcc: fixed '#if 1 == 3 && 4' parsing.
fteqcc: -Werror acts on the warning, rather than as a separate error. Line numbers are thus more readable.
fteqcc: copyright message now includes compile date instead.
fteqccgui: the treeview control is now coloured depending on whether there were warnings/errors in the last compile.
fteqccgui: the output window is now focused and scrolls down as compilation progresses.
pr_dumpplatform command dumps out some pragmas to convert more serious warnings to errors. This is to avoid the infamous 'fteqcc sucks cos my code sucks' issue.
rewrote prespawn/modelist/soundlist code. server tracks progress now.
------------------------------------------------------------------------
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4167 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 22:29:40 +00:00
|
|
|
Cmd_AddCommand ("setfl", Cmd_set_f);
|
2006-09-17 00:59:22 +00:00
|
|
|
Cmd_AddCommand ("set_calc", Cmd_set_f);
|
2004-08-21 01:25:48 +00:00
|
|
|
Cmd_AddCommand ("seta", Cmd_set_f);
|
2006-09-17 00:59:22 +00:00
|
|
|
Cmd_AddCommand ("seta_calc", Cmd_set_f);
|
2005-09-08 22:52:46 +00:00
|
|
|
Cmd_AddCommand ("vstr", Cmd_Vstr_f);
|
2004-08-21 01:25:48 +00:00
|
|
|
Cmd_AddCommand ("inc", Cvar_Inc_f);
|
|
|
|
//FIXME: Add seta some time.
|
|
|
|
Cmd_AddCommand ("if", Cmd_if_f);
|
|
|
|
|
|
|
|
Cmd_AddCommand ("cmdlist", Cmd_List_f);
|
|
|
|
Cmd_AddCommand ("aliaslist", Cmd_AliasList_f);
|
2012-04-16 12:15:05 +00:00
|
|
|
Cmd_AddCommand ("macrolist", Cmd_MacroList_f);
|
2004-08-21 01:25:48 +00:00
|
|
|
Cmd_AddCommand ("cvarlist", Cvar_List_f);
|
2005-08-23 03:25:22 +00:00
|
|
|
Cmd_AddCommand ("cvarreset", Cvar_Reset_f);
|
2013-10-29 17:38:22 +00:00
|
|
|
Cmd_AddCommand ("cvar_lockdefaults", Cvar_LockDefaults_f);
|
|
|
|
Cmd_AddCommand ("cvar_purgedefaults", Cvar_PurgeDefaults_f);
|
2004-08-21 01:25:48 +00:00
|
|
|
Cmd_AddCommand ("fs_flush", COM_RefreshFSCache_f);
|
2005-09-21 01:14:04 +00:00
|
|
|
|
2014-10-05 20:04:11 +00:00
|
|
|
Cmd_AddCommandD ("apropos", Cmd_Apropos_f, "Lists all cvars or commands with the specified substring somewhere in their name or descrition.");
|
|
|
|
|
2012-04-16 12:15:05 +00:00
|
|
|
Cmd_AddMacro("time", Macro_Time, true);
|
2013-05-03 04:28:08 +00:00
|
|
|
Cmd_AddMacro("ukdate", Macro_UKDate, false);
|
|
|
|
Cmd_AddMacro("usdate", Macro_USDate, false);
|
|
|
|
Cmd_AddMacro("date", Macro_ProperDate, false);
|
2014-01-16 03:53:36 +00:00
|
|
|
Cmd_AddMacro("properdate", Macro_ProperDate, false);
|
2012-04-16 12:15:05 +00:00
|
|
|
Cmd_AddMacro("version", Macro_Version, false);
|
|
|
|
Cmd_AddMacro("qt", Macro_Quote, false);
|
|
|
|
|
2005-02-28 07:16:19 +00:00
|
|
|
Cvar_Register(&tp_disputablemacros, "Teamplay");
|
|
|
|
|
2011-05-20 04:10:46 +00:00
|
|
|
Cvar_Register(&dpcompat_set, "Darkplaces compatibility");
|
2013-06-23 02:17:02 +00:00
|
|
|
Cvar_Register (&cl_warncmd, "Warnings");
|
2011-05-20 04:10:46 +00:00
|
|
|
|
2004-08-21 01:25:48 +00:00
|
|
|
#ifndef SERVERONLY
|
2013-10-29 17:38:22 +00:00
|
|
|
rcon_level.ival = atof(rcon_level.enginevalue); //client is restricted to not be allowed to change restrictions.
|
2004-08-21 01:25:48 +00:00
|
|
|
#else
|
|
|
|
Cvar_Register(&rcon_level, "Access controls"); //server gains versatility.
|
|
|
|
#endif
|
|
|
|
rcon_level.restriction = RESTRICT_MAX; //default. Don't let anyone change this too easily.
|
|
|
|
cmd_maxbuffersize.restriction = RESTRICT_MAX; //filling this causes a loop for quite some time.
|
|
|
|
|
|
|
|
Cvar_Register(&cl_aliasoverlap, "Console");
|
|
|
|
//FIXME: go through quake.rc and parameters looking for sets and setas and setting them now.
|
|
|
|
}
|
|
|
|
|