1
0
Fork 0
forked from fte/fteqw

Added $time and $properdate macros to dedicated servers too, for bigfoot's easyrecord stuff.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4015 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2012-04-16 12:15:05 +00:00
parent 161f9e46b1
commit b6d08f44c5
2 changed files with 57 additions and 51 deletions

View file

@ -302,12 +302,6 @@ static void MacroBuf_strcat_with_separator (char *str) {
}
static char *Macro_Quote (void)
{
return "\"";
}
static char *Macro_Latency (void)
{
sprintf(macro_buf, "%i", Q_rint(cls.latency*1000));
@ -557,32 +551,6 @@ static char *Macro_Last_Location (void)
return Macro_Location();
}
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_Date (void)
{
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;
}
// returns the last item picked up
static char *Macro_Took (void)
{
@ -843,14 +811,6 @@ static char *Macro_Match_Type (void)
return "ffa";
}
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_Point_LED(void)
{
TP_FindPoint();
@ -1126,8 +1086,6 @@ $triggermatch is the last chat message that exec'd a msg_trigger.
static void TP_InitMacros(void)
{
Cmd_AddMacro("version", Macro_Version, false);
Cmd_AddMacro("qt", Macro_Quote, false);
Cmd_AddMacro("latency", Macro_Latency, false);
Cmd_AddMacro("health", Macro_Health, true);
Cmd_AddMacro("armortype", Macro_ArmorType, true);
@ -1145,8 +1103,6 @@ static void TP_InitMacros(void)
Cmd_AddMacro("powerups", Macro_Powerups, true);
Cmd_AddMacro("location", Macro_Location, false);
Cmd_AddMacro("deathloc", Macro_LastDeath, true);
Cmd_AddMacro("time", Macro_Time, true);
Cmd_AddMacro("date", Macro_Date, false);
Cmd_AddMacro("tookatloc", Macro_TookAtLoc, true);
Cmd_AddMacro("tookloc", Macro_TookLoc, true);
Cmd_AddMacro("took", Macro_Took, true);

View file

@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// cmd.c -- Quake script command processing module
#include "quakedef.h"
#include "errno.h"
cvar_t com_fs_cache = SCVARF("fs_cache", IFMINIMAL("2","1"), CVAR_ARCHIVE);
cvar_t rcon_level = SCVAR("rcon_level", "20");
@ -188,9 +187,6 @@ void Cbuf_AddText (const char *text, int level)
{
int l;
if (!strcmp(text, "cmd "))
Con_Printf("cmd text\n");
if (level > sizeof(cmd_text)/sizeof(cmd_text[0]) || level < 0)
{
Con_Printf("Bad execution level\n");
@ -1123,7 +1119,7 @@ char *Cmd_ExpandCvar(char *cvarname, int maxaccesslevel, int *len)
result = strtol(cvarname, &end, 10); // do something with result
if (result == 0)
Con_DPrintf("Cmd_ExpandCvar() strtol returned zero cvar: %s (%i)\n", cvarname, errno);
Con_DPrintf("Cmd_ExpandCvar() strtol returned zero cvar: %s\n", cvarname);
if (fixval && *end == '\0') //only expand $0 if its actually ${0} - this avoids conflicting with the $0 macro
{ //purely numerical
@ -1212,10 +1208,8 @@ char *Cmd_ExpandString (char *data, char *dest, int destlen, int maxaccesslevel,
if ((str = Cmd_ExpandCvar(buf+striptrailing, maxaccesslevel, &var_length)))
bestvar = str;
}
#ifndef SERVERONLY
if (expandmacros && (str = TP_MacroString (buf+striptrailing, &macro_length)))
bestmacro = str;
#endif
}
if (bestmacro)
@ -2909,6 +2903,55 @@ void Cmd_Shutdown(void)
}
}
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;
}
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 "\"";
}
/*
============
Cmd_Init
@ -2953,10 +2996,17 @@ void Cmd_Init (void)
Cmd_AddCommand ("cmdlist", Cmd_List_f);
Cmd_AddCommand ("aliaslist", Cmd_AliasList_f);
Cmd_AddCommand ("macrolist", Cmd_MacroList_f);
Cmd_AddCommand ("cvarlist", Cvar_List_f);
Cmd_AddCommand ("cvarreset", Cvar_Reset_f);
Cmd_AddCommand ("fs_flush", COM_RefreshFSCache_f);
Cmd_AddMacro("time", Macro_Time, true);
Cmd_AddMacro("date", Macro_UKDate, false);
Cmd_AddMacro("properdate", Macro_ProperDate, false);
Cmd_AddMacro("version", Macro_Version, false);
Cmd_AddMacro("qt", Macro_Quote, false);
Cvar_Register(&com_fs_cache, "Filesystem");
Cvar_Register(&tp_disputablemacros, "Teamplay");