whichpack: distinguish file not found from file is physical.
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 28 May 2014 15:14:24 +0000 (15:14 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 28 May 2014 15:14:24 +0000 (15:14 +0000)
csqc: add cltime global.

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

csprogs.c
dpdefs/dpextensions.qc
fs.c
prvm_cmds.c
prvm_offsets.h

index fd2d8f6..e9295bc 100644 (file)
--- 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;
index 7364e3d..c8ceac3 100644 (file)
@@ -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 a32d6fa..4540663 100644 (file)
--- 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;
 }
index 8e47638..746d480 100644 (file)
@@ -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
index 36256c5..fcb57ad 100644 (file)
@@ -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)