]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_cmds.c
-Fixed an old qc bug that's already been existing in the original quake
[xonotic/darkplaces.git] / prvm_cmds.c
index 40a1646dd4b22d6e4aa17d887e4da191a9aeb895..56c9f4bc8d1572d6bb69830c2f860b972f2ad7f0 100644 (file)
@@ -559,13 +559,9 @@ float random()
 */
 void VM_random (void)
 {
-       float           num;
-
        VM_SAFEPARMCOUNT(0,VM_random);
 
-       num = (rand ()&0x7fff) / ((float)0x7fff);
-
-       PRVM_G_FLOAT(OFS_RETURN) = num;
+       PRVM_G_FLOAT(OFS_RETURN) = lhrandom(0, 1);
 }
 
 /*
@@ -1040,7 +1036,7 @@ void VM_findchain (void)
                if (strcmp(t,s))
                        continue;
 
-               PRVM_E_FLOAT(ent,chain_of) = PRVM_NUM_FOR_EDICT(chain);
+               PRVM_E_INT(ent,chain_of) = PRVM_NUM_FOR_EDICT(chain);
                chain = ent;
        }
 
@@ -1083,10 +1079,10 @@ void VM_findchainfloat (void)
                prog->xfunction->builtinsprofile++;
                if (ent->p.e->free)
                        continue;
-               if (E_FLOAT(ent,f) != s)
+               if (PRVM_E_FLOAT(ent,f) != s)
                        continue;
 
-               PRVM_E_FLOAT(ent,chain_of) = PRVM_NUM_FOR_EDICT(chain);
+               PRVM_E_INT(ent,chain_of) = PRVM_EDICT_TO_PROG(chain);
                chain = ent;
        }
 
@@ -1136,7 +1132,7 @@ void VM_precache_sound (void)
        s = PRVM_G_STRING(OFS_PARM0);
        PRVM_G_INT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0);
        VM_CheckEmptyString (s);
-       
+
        if(!S_PrecacheSound (s,true, true))
                Con_Printf("VM_precache_sound: Failed to load %s for %s\n", s, PRVM_NAME);
 }
@@ -1594,7 +1590,7 @@ void VM_max (void)
                for (i = 1;i < prog->argc;i++)
                        if (PRVM_G_FLOAT((OFS_PARM0+i*3)) > f)
                                f = PRVM_G_FLOAT((OFS_PARM0+i*3));
-               G_FLOAT(OFS_RETURN) = f;
+               PRVM_G_FLOAT(OFS_RETURN) = f;
        }
        else
                PRVM_ERROR("VM_max: %s must supply at least 2 floats\n", PRVM_NAME);
@@ -2646,7 +2642,7 @@ void VM_drawstring(void)
                return;
        }
        
-       VM_CheckEmptyString(string);
+       //VM_CheckEmptyString(string); Why should it be checked - perhaps the menu wants to the precolored letters, too?
        
        pos = PRVM_G_VECTOR(OFS_PARM0);
        scale = PRVM_G_VECTOR(OFS_PARM2);
@@ -2833,6 +2829,14 @@ void VM_Cmd_Init(void)
 void VM_Cmd_Reset(void)
 {
        //Mem_EmptyPool(VM_STRINGS_MEMPOOL);
+       if( developer.integer >= 2 && VM_STRINGS_MEMPOOL ) {
+               memheader_t *header;
+               int     i;
+
+               for( i = 0, header = VM_STRINGS_MEMPOOL->chain ; header ; header = header->next, i++ )
+                       Con_DPrintf( "Leaked string %i (size: %i): %.*s\n", i, header->size, header->size, ((char*)header) + sizeof( memheader_t ) );
+       }
+
        Mem_FreePool(&VM_STRINGS_MEMPOOL);
        VM_Search_Reset();
        VM_Files_CloseAll();