"DP_QC_RANDOMVEC "
"DP_QC_SINCOSSQRTPOW "
//"DP_QC_STRINGBUFFERS " //[515]: not needed ?
+"DP_QC_STRFTIME "
"DP_QC_STRINGCOLORFUNCTIONS "
"DP_QC_TRACEBOX "
//"DP_QC_TRACETOSS "
VM_tan, // #475 float(float a) VM_tan (DP_QC_ASINACOSATANATAN2TAN)
VM_strlennocol, // #476 float(string s) : DRESK - String Length (not counting color codes) (DP_QC_STRINGCOLORFUNCTIONS)
VM_strdecolorize, // #477 string(string s) : DRESK - Decolorized String (DP_QC_STRINGCOLORFUNCTIONS)
-NULL, // #478
+VM_strftime, // #478 string(float uselocaltime, string format, ...) (DP_QC_STRFTIME)
NULL, // #479
e10, e10 // #480-499 (LordHavoc)
};
// also applies here
#include "prvm_cmds.h"
+#include <time.h>
// LordHavoc: changed this to NOT use a return statement, so that it can be used in functions that must return a value
void VM_Warning(const char *fmt, ...)
PRVM_G_INT(OFS_RETURN) = ent;
}
+/*
+=========
+VM_strftime
+
+string strftime(float uselocaltime, string[, string ...])
+=========
+*/
+void VM_strftime(void)
+{
+ time_t t;
+ struct tm *tm;
+ char fmt[VM_STRINGTEMP_LENGTH];
+ char result[VM_STRINGTEMP_LENGTH];
+ VM_VarString(0, fmt, sizeof(fmt));
+ t = time(NULL);
+ if (PRVM_G_FLOAT(OFS_PARM0))
+ tm = localtime(&t);
+ else
+ tm = gmtime(&t);
+ if (!tm)
+ {
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ return;
+ }
+ strftime(result, sizeof(result), fmt, tm);
+ PRVM_G_FLOAT(OFS_RETURN) = PRVM_SetTempString(result);
+}
+
/*
=========
VM_spawn
void VM_stof(void);
void VM_itof(void);
void VM_ftoe(void);
+void VM_strftime(void);
void VM_spawn (void);
void VM_remove (void);
void VM_find (void);
"DP_QC_MULTIPLETEMPSTRINGS "
"DP_QC_RANDOMVEC "
"DP_QC_SINCOSSQRTPOW "
+"DP_QC_STRFTIME "
"DP_QC_STRINGBUFFERS "
"DP_QC_STRINGCOLORFUNCTIONS "
"DP_QC_UNLIMITEDTEMPSTRINGS "
VM_tan, // #475 float(float a) VM_tan (DP_QC_ASINACOSATANATAN2TAN)
VM_strlennocol, // #476 float(string s) : DRESK - String Length (not counting color codes) (DP_QC_STRINGCOLORFUNCTIONS)
VM_strdecolorize, // #477 string(string s) : DRESK - Decolorized String (DP_SV_STRINGCOLORFUNCTIONS)
+VM_strftime, // #478 string(float uselocaltime, string format, ...) (DP_QC_STRFTIME)
NULL, // #478
NULL, // #479
e10, e10 // #480-499 (LordHavoc)