]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_cmds.c
cl_movement: move crouch handling so that sv_maxairspeed*0.5 is maximum crouching...
[xonotic/darkplaces.git] / prvm_cmds.c
index a82c0179d02ebf1cdf2f44dac25fbaf69f5a6895..267cee53a39360e6f42c2d7b883aea978862767f 100644 (file)
@@ -1090,7 +1090,7 @@ void VM_precache_sound (void)
        PRVM_G_INT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0);
        VM_CheckEmptyString(s);
 
-       if(snd_initialized.integer && !S_PrecacheSound(s, true, false))
+       if(snd_initialized.integer && !S_PrecacheSound(s, true, true))
        {
                VM_Warning("VM_precache_sound: Failed to load %s for %s\n", s, PRVM_NAME);
                return;
@@ -2101,7 +2101,7 @@ string    substring(string s, float start, float length)
 // returns a section of a string as a tempstring
 void VM_substring(void)
 {
-       int start, length, slength;
+       int start, length, slength, maxlen;
        const char *s;
        char string[VM_STRINGTEMP_LENGTH];
 
@@ -2111,13 +2111,16 @@ void VM_substring(void)
        start = (int)PRVM_G_FLOAT(OFS_PARM1);
        length = (int)PRVM_G_FLOAT(OFS_PARM2);
        slength = strlen(s);
-       if (length < 0) // FTE_STRINGS feature
-               length += slength - start;
+
        if (start < 0) // FTE_STRINGS feature
                start += slength;
-       start = bound(0, start, slength); // consistent with php 5.2.0 but not 5.2.3
-       length = min(length, (int)sizeof(string) - 1);
-       length = min(length, slength - start);
+       start = bound(0, start, slength);
+
+       if (length < 0) // FTE_STRINGS feature
+               length += slength - start + 1;
+       maxlen = min((int)sizeof(string) - 1, slength - start);
+       length = bound(0, length, maxlen);
+
        memcpy(string, s + start, length);
        string[length] = 0;
        PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(string);
@@ -2607,6 +2610,7 @@ float     gettime(void)
 =========
 */
 extern double host_starttime;
+float CDAudio_GetPosition(void);
 void VM_gettime(void)
 {
        int timer_index;
@@ -2632,7 +2636,10 @@ void VM_gettime(void)
                 PRVM_G_FLOAT(OFS_RETURN) = (float) (Sys_DoubleTime() - realtime);
                 break;
             case 3: // GETTIME_UPTIME
-                PRVM_G_FLOAT(OFS_RETURN) = (float) Sys_DoubleTime() - host_starttime;
+                PRVM_G_FLOAT(OFS_RETURN) = (float) (Sys_DoubleTime() - host_starttime);
+                break;
+            case 4: // GETTIME_CDTRACK
+                PRVM_G_FLOAT(OFS_RETURN) = (float) CDAudio_GetPosition();
                 break;
                        default:
                                VM_Warning("VM_gettime: %s: unsupported timer specified, returning realtime\n", PRVM_NAME);
@@ -5229,3 +5236,19 @@ void VM_netaddress_resolve (void)
        else
                PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString("");
 }
+
+//string(void) getextresponse = #624; // returns the next extResponse packet that was sent to this client
+void VM_getextresponse (void)
+{
+       VM_SAFEPARMCOUNT(0,VM_argv);
+
+       if (net_extresponse_count <= 0)
+               PRVM_G_INT(OFS_RETURN) = OFS_NULL;
+       else
+       {
+               int first;
+               --net_extresponse_count;
+               first = (net_extresponse_last + NET_EXTRESPONSE_MAX - net_extresponse_count) % NET_EXTRESPONSE_MAX;
+               PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(net_extresponse[first]);
+       }
+}