From fd726ac9658cd7d684d68a63f255ea6df7baf166 Mon Sep 17 00:00:00 2001 From: divverent Date: Wed, 28 May 2014 15:14:24 +0000 Subject: [PATCH] whichpack: distinguish file not found from file is physical. csqc: add cltime global. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12079 d7cf8633-e32d-0410-b094-e92efae38249 --- csprogs.c | 1 + dpdefs/dpextensions.qc | 10 ++++++---- fs.c | 2 ++ prvm_cmds.c | 2 +- prvm_offsets.h | 2 ++ 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/csprogs.c b/csprogs.c index fd2d8f6e..e9295bce 100644 --- a/csprogs.c +++ b/csprogs.c @@ -227,6 +227,7 @@ static void CSQC_SetGlobals (double frametime) prvm_prog_t *prog = CLVM_prog; CSQC_BEGIN PRVM_clientglobalfloat(time) = cl.time; + PRVM_clientglobalfloat(cltime) = realtime; // Spike named it that way. PRVM_clientglobalfloat(frametime) = frametime; PRVM_clientglobalfloat(servercommandframe) = cls.servermovesequence; PRVM_clientglobalfloat(clientcommandframe) = cl.movecmd[0].sequence; diff --git a/dpdefs/dpextensions.qc b/dpdefs/dpextensions.qc index 7364e3d5..c8ceac35 100644 --- a/dpdefs/dpextensions.qc +++ b/dpdefs/dpextensions.qc @@ -899,10 +899,10 @@ vector gettaginfo_up; //idea: tZork //darkplaces implementation: tZork, divVerent //constant definitions: -float GETTIME_FRAMESTART = 0; // time of start of frame -float GETTIME_REALTIME = 1; // current time (may be OS specific) +float GETTIME_FRAMESTART = 0; // time of start of frame relative to an arbitrary point in time +float GETTIME_REALTIME = 1; // current absolute time (OS specific) float GETTIME_HIRES = 2; // like REALTIME, but may reset between QC invocations and thus can be higher precision -float GETTIME_UPTIME = 3; // time since start of the engine +float GETTIME_UPTIME = 3; // time of start of frame since start of the engine //builtin definitions: float(float tmr) gettime = #519; //description: @@ -1183,7 +1183,9 @@ void(vector dir) vectorvectors = #432; //builtin definitions: string(string filename) whichpack = #503; //description: -//returns the name of the pak/pk3/whatever containing the given file, in the same path space as FRIK_FILE functions use (that is, possibly with a path name prefix) +//for files in a pak/pk3/whatever, returns the pack's file name in FRIK_FILE name space. +//for physical files, returns "". +//in case of error, returns string_null. //DP_QC_URI_ESCAPE //idea: divVerent diff --git a/fs.c b/fs.c index a32d6fab..45406637 100644 --- a/fs.c +++ b/fs.c @@ -3723,6 +3723,8 @@ const char *FS_WhichPack(const char *filename) searchpath_t *sp = FS_FindFile(filename, &index, true); if(sp && sp->pack) return sp->pack->shortname; + else if(sp) + return ""; else return 0; } diff --git a/prvm_cmds.c b/prvm_cmds.c index 8e476383..746d480e 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -6136,7 +6136,7 @@ void VM_whichpack (prvm_prog_t *prog) fn = PRVM_G_STRING(OFS_PARM0); pack = FS_WhichPack(fn); - PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, pack ? pack : ""); + PRVM_G_INT(OFS_RETURN) = pack ? PRVM_SetTempString(prog, pack) : 0; } typedef struct diff --git a/prvm_offsets.h b/prvm_offsets.h index 36256c5f..fcb57ad0 100644 --- a/prvm_offsets.h +++ b/prvm_offsets.h @@ -100,6 +100,7 @@ PRVM_DECLARE_clientglobaledict(self) PRVM_DECLARE_clientglobaledict(trace_ent) PRVM_DECLARE_clientglobaledict(world) PRVM_DECLARE_clientglobalfloat(clientcommandframe) +PRVM_DECLARE_clientglobalfloat(cltime) PRVM_DECLARE_clientglobalfloat(coop) PRVM_DECLARE_clientglobalfloat(deathmatch) PRVM_DECLARE_clientglobalfloat(dmg_save) @@ -444,6 +445,7 @@ PRVM_DECLARE_function(m_toggle) PRVM_DECLARE_function(main) PRVM_DECLARE_global(SV_InitCmd) PRVM_DECLARE_global(clientcommandframe) +PRVM_DECLARE_global(cltime) PRVM_DECLARE_global(coop) PRVM_DECLARE_global(deathmatch) PRVM_DECLARE_global(dmg_origin) -- 2.39.2