]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_cmds.c
reworked transparent sorting of MATERIALFLAG_BLENDED to not sort water
[xonotic/darkplaces.git] / prvm_cmds.c
index 04f0860dc3411fd966506a661e3a1ce232c0bd04..b7cae0d24e345234b08789055f888fcaed3820e4 100644 (file)
@@ -9,19 +9,28 @@
 #include "prvm_cmds.h"
 #include <time.h>
 
+extern cvar_t prvm_backtraceforwarnings;
+
 // 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, ...)
 {
        va_list argptr;
        char msg[MAX_INPUTLINE];
+       static double recursive = -1;
 
        va_start(argptr,fmt);
        dpvsnprintf(msg,sizeof(msg),fmt,argptr);
        va_end(argptr);
 
-       Con_Print(msg);
+       Con_Printf(msg);
+
        // TODO: either add a cvar/cmd to control the state dumping or replace some of the calls with Con_Printf [9/13/2006 Black]
-       //PRVM_PrintState();
+       if(prvm_backtraceforwarnings.integer && recursive != realtime) // NOTE: this compares to the time, just in case if PRVM_PrintState causes a Host_Error and keeps recursive set
+       {
+               recursive = realtime;
+               PRVM_PrintState();
+               recursive = -1;
+       }
 }
 
 
@@ -320,50 +329,14 @@ void VM_vectoyaw (void)
 =================
 VM_vectoangles
 
-vector vectoangles(vector)
+vector vectoangles(vector[, vector])
 =================
 */
 void VM_vectoangles (void)
 {
-       float   *value1;
-       float   forward;
-       float   yaw, pitch;
-
-       VM_SAFEPARMCOUNT(1,VM_vectoangles);
-
-       value1 = PRVM_G_VECTOR(OFS_PARM0);
-
-       if (value1[1] == 0 && value1[0] == 0)
-       {
-               yaw = 0;
-               if (value1[2] > 0)
-                       pitch = 90;
-               else
-                       pitch = 270;
-       }
-       else
-       {
-               // LordHavoc: optimized a bit
-               if (value1[0])
-               {
-                       yaw = (atan2(value1[1], value1[0]) * 180 / M_PI);
-                       if (yaw < 0)
-                               yaw += 360;
-               }
-               else if (value1[1] > 0)
-                       yaw = 90;
-               else
-                       yaw = 270;
-
-               forward = sqrt(value1[0]*value1[0] + value1[1]*value1[1]);
-               pitch = (atan2(value1[2], forward) * 180 / M_PI);
-               if (pitch < 0)
-                       pitch += 360;
-       }
+       VM_SAFEPARMCOUNTRANGE(1, 2,VM_vectoangles);
 
-       PRVM_G_FLOAT(OFS_RETURN+0) = pitch;
-       PRVM_G_FLOAT(OFS_RETURN+1) = yaw;
-       PRVM_G_FLOAT(OFS_RETURN+2) = 0;
+       AnglesFromVectors(PRVM_G_VECTOR(OFS_RETURN), PRVM_G_VECTOR(OFS_PARM0), prog->argc >= 2 ? PRVM_G_VECTOR(OFS_PARM1) : NULL, true);
 }
 
 /*
@@ -2762,7 +2735,7 @@ void VM_stringwidth(void)
        string = PRVM_G_STRING(OFS_PARM0);
        colors = (int)PRVM_G_FLOAT(OFS_PARM1);
 
-       PRVM_G_FLOAT(OFS_RETURN) = DrawQ_String_Font(0, 0, string, 0, 1, 1, 0, 0, 0, 0, 0, NULL, !colors, getdrawfont()); // 1x1 characters, don't actually draw
+       PRVM_G_FLOAT(OFS_RETURN) = DrawQ_TextWidth_Font(string, 0, !colors, getdrawfont()); // 1x1 characters, don't actually draw
 }
 /*
 =========
@@ -3231,7 +3204,7 @@ void VM_gecko_keyevent( void ) {
        name = PRVM_G_STRING( OFS_PARM0 );
        VM_CheckEmptyString( name );
        key = (unsigned int) PRVM_G_FLOAT( OFS_PARM1 );
-       switch( (unsigned int) PRVM_G_FLOAT( OFS_PARM3 ) ) {
+       switch( (unsigned int) PRVM_G_FLOAT( OFS_PARM2 ) ) {
        case 0:
                eventtype = CLG_BET_DOWN;
                break;
@@ -3284,6 +3257,63 @@ void VM_gecko_movemouse( void ) {
        }
        CL_Gecko_Event_CursorMove( instance, x, y );
 }
+
+
+/*
+========================
+VM_gecko_resize
+
+void gecko_resize( string name, float w, float h )
+========================
+*/
+void VM_gecko_resize( void ) {
+       const char *name;
+       float w, h;
+       clgecko_t *instance;
+
+       VM_SAFEPARMCOUNT( 3, VM_gecko_movemouse );
+
+       name = PRVM_G_STRING( OFS_PARM0 );
+       VM_CheckEmptyString( name );
+       w = PRVM_G_FLOAT( OFS_PARM1 );
+       h = PRVM_G_FLOAT( OFS_PARM2 );
+       
+       instance = CL_Gecko_FindBrowser( name );
+       if( !instance ) {
+               return;
+       }
+       CL_Gecko_Resize( instance, w, h );
+}
+
+
+/*
+========================
+VM_gecko_get_texture_extent
+
+vector gecko_get_texture_extent( string name )
+========================
+*/
+void VM_gecko_get_texture_extent( void ) {
+       const char *name;
+       clgecko_t *instance;
+
+       VM_SAFEPARMCOUNT( 1, VM_gecko_movemouse );
+
+       name = PRVM_G_STRING( OFS_PARM0 );
+       VM_CheckEmptyString( name );
+       
+       PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
+       instance = CL_Gecko_FindBrowser( name );
+       if( !instance ) {
+               PRVM_G_VECTOR(OFS_RETURN)[0] = 0;
+               PRVM_G_VECTOR(OFS_RETURN)[1] = 0;
+               return;
+       }
+       CL_Gecko_GetTextureExtent( instance, 
+               PRVM_G_VECTOR(OFS_RETURN), PRVM_G_VECTOR(OFS_RETURN)+1 );
+}
+
+
 #endif
 
 /*