]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - clvm_cmds.c
Gecko: load OffscreenGecko dynamically
[xonotic/darkplaces.git] / clvm_cmds.c
index 6718b750fb5c6a20513f7057b92f6535e2b00b1c..1de807cbc9dc6d0cc88ee4812fd0ee3ccceab449 100644 (file)
@@ -56,12 +56,28 @@ void VM_CL_setorigin (void)
        CL_LinkEdict(e);
 }
 
+static void SetMinMaxSize (prvm_edict_t *e, float *min, float *max)
+{
+       int             i;
+
+       for (i=0 ; i<3 ; i++)
+               if (min[i] > max[i])
+                       PRVM_ERROR("SetMinMaxSize: backwards mins/maxs");
+
+       // set derived values
+       VectorCopy (min, e->fields.client->mins);
+       VectorCopy (max, e->fields.client->maxs);
+       VectorSubtract (max, min, e->fields.client->size);
+
+       CL_LinkEdict (e);
+}
+
 // #3 void(entity e, string m) setmodel
 void VM_CL_setmodel (void)
 {
        prvm_edict_t    *e;
        const char              *m;
-       struct model_s  *mod;
+       model_t *mod;
        int                             i;
 
        VM_SAFEPARMCOUNT(2, VM_CL_setmodel);
@@ -92,6 +108,14 @@ void VM_CL_setmodel (void)
        e->fields.client->modelindex = 0;
        e->fields.client->model = 0;
        VM_Warning ("setmodel: model '%s' not precached\n", m);
+
+       // TODO: check if this breaks needed consistency and maybe add a cvar for it too?? [1/10/2008 Black]
+       if (mod)
+       {
+               SetMinMaxSize (e, mod->normalmins, mod->normalmaxs);
+       }
+       else
+               SetMinMaxSize (e, vec3_origin, vec3_origin);
 }
 
 // #4 void(entity e, vector min, vector max) setsize
@@ -115,9 +139,7 @@ static void VM_CL_setsize (void)
        min = PRVM_G_VECTOR(OFS_PARM1);
        max = PRVM_G_VECTOR(OFS_PARM2);
 
-       VectorCopy (min, e->fields.client->mins);
-       VectorCopy (max, e->fields.client->maxs);
-       VectorSubtract (max, min, e->fields.client->size);
+       SetMinMaxSize( e, min, max );
 
        CL_LinkEdict(e);
 }
@@ -196,8 +218,6 @@ static void VM_CL_spawn (void)
 {
        prvm_edict_t *ed;
        ed = PRVM_ED_Alloc();
-       // FIXME: WTF.. this should be removed imo.. entnum points to the server.. [12/17/2007 Black]
-       ed->fields.client->entnum = PRVM_NUM_FOR_EDICT(ed);     //[515]: not needed any more ?
        VM_RETURN_EDICT(ed);
 }
 
@@ -978,6 +998,14 @@ static void VM_CL_setmodelindex (void)
        }
        t->fields.client->model = PRVM_SetEngineString(model->name);
        t->fields.client->modelindex = i;
+
+       // TODO: check if this breaks needed consistency and maybe add a cvar for it too?? [1/10/2008 Black]
+       if (model)
+       {
+               SetMinMaxSize (t, model->normalmins, model->normalmaxs);
+       }
+       else
+               SetMinMaxSize (t, vec3_origin, vec3_origin);
 }
 
 //#334 string(float mdlindex) modelnameforindex (EXT_CSQC)
@@ -1791,8 +1819,8 @@ static void VM_CL_getsurfacepoint(void)
 //PF_getsurfacepointattribute,     // #486 vector(entity e, float s, float n, float a) getsurfacepointattribute = #486;
 // float SPA_POSITION = 0;
 // float SPA_S_AXIS = 1;
-// float SPA_R_AXIS = 2;
-// float SPA_T_AXIS = 3; // same as SPA_NORMAL
+// float SPA_T_AXIS = 2;
+// float SPA_R_AXIS = 3; // same as SPA_NORMAL
 // float SPA_TEXCOORDS0 = 4;
 // float SPA_LIGHTMAP0_TEXCOORDS = 5;
 // float SPA_LIGHTMAP0_COLOR = 6;
@@ -1805,7 +1833,7 @@ static void VM_CL_getsurfacepointattribute(void)
        int pointnum;
        int attributetype;
 
-       VM_SAFEPARMCOUNT(3, VM_CL_getsurfacenumpoints);
+       VM_SAFEPARMCOUNT(4, VM_CL_getsurfacenumpoints);
        VectorClear(PRVM_G_VECTOR(OFS_RETURN));
        ed = PRVM_G_EDICT(OFS_PARM0);
        if (!(model = CL_GetModelFromEdict(ed)) || !(surface = cl_getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))
@@ -1827,11 +1855,11 @@ static void VM_CL_getsurfacepointattribute(void)
                case 1:
                        VectorCopy(&(model->surfmesh.data_svector3f + 3 * surface->num_firstvertex)[pointnum * 3], PRVM_G_VECTOR(OFS_RETURN));
                        break;
-               // float SPA_R_AXIS = 2;
+               // float SPA_T_AXIS = 2;
                case 2:
                        VectorCopy(&(model->surfmesh.data_tvector3f + 3 * surface->num_firstvertex)[pointnum * 3], PRVM_G_VECTOR(OFS_RETURN));
                        break;
-               // float SPA_T_AXIS = 3; // same as SPA_NORMAL
+               // float SPA_R_AXIS = 3; // same as SPA_NORMAL
                case 3:
                        VectorCopy(&(model->surfmesh.data_normal3f + 3 * surface->num_firstvertex)[pointnum * 3], PRVM_G_VECTOR(OFS_RETURN));
                        break;
@@ -1856,7 +1884,7 @@ static void VM_CL_getsurfacepointattribute(void)
                // float SPA_LIGHTMAP0_COLOR = 6;
                case 6:
                        // ignore alpha for now..
-                       VectorCopy( &(model->surfmesh.data_normal3f + 4 * surface->num_firstvertex)[pointnum * 4], PRVM_G_VECTOR(OFS_RETURN));
+                       VectorCopy( &(model->surfmesh.data_lightmapcolor4f + 4 * surface->num_firstvertex)[pointnum * 4], PRVM_G_VECTOR(OFS_RETURN));
                        break;
                default:
                        VectorSet( PRVM_G_VECTOR(OFS_RETURN), 0.0f, 0.0f, 0.0f );
@@ -2866,10 +2894,10 @@ void VM_CL_serverkey(void)
 //============================================================================
 
 // To create a almost working builtin file from this replace:
-// "^NULL,.*" with ""
-// "^{.*//.*}:Wh\(.*)" with ""
+// "^NULL.*" with ""
+// "^{.*//.*}:Wh\(.*\)" with "\1"
 // "\:" with "//"
-// ".*//:Wh{\#:d*}:Wh{.*}" with "\2 = \1;"
+// "^.*//:Wh{\#:d*}:Wh{.*}" with "\2 = \1;"
 // "\n\n+" with "\n\n"
 
 prvm_builtin_t vm_cl_builtins[] = {
@@ -3364,7 +3392,6 @@ VM_CL_pointsound,                         // #483 void(vector origin, string sample, float volume, fl
 VM_strreplace,                                 // #484 string(string search, string replace, string subject) strreplace (DP_QC_STRREPLACE)
 VM_strireplace,                                        // #485 string(string search, string replace, string subject) strireplace (DP_QC_STRREPLACE)
 VM_CL_getsurfacepointattribute,// #486 vector(entity e, float s, float n, float a) getsurfacepointattribute
-#ifdef SUPPORT_GECKO
 VM_gecko_create,                                       // #487 float gecko_create( string name )
 VM_gecko_destroy,                                      // #488 void gecko_destroy( string name )
 VM_gecko_navigate,                             // #489 void gecko_navigate( string name, string URI )
@@ -3372,15 +3399,6 @@ VM_gecko_keyevent,                               // #490 float gecko_keyevent( string name, float key, floa
 VM_gecko_movemouse,                            // #491 void gecko_mousemove( string name, float x, float y )
 VM_gecko_resize,                                       // #492 void gecko_resize( string name, float w, float h )
 VM_gecko_get_texture_extent,   // #493 vector gecko_get_texture_extent( string name )
-#else
-NULL,                                                                  // #487
-NULL,                                                                  // #488
-NULL,                                                                  // #489
-NULL,                                                                  // #490
-NULL,                                                                  // #491
-NULL,                                                                  // #492
-NULL,                                                                  // #493
-#endif
 NULL,                                                  // #494
 NULL,                                                  // #495
 NULL,                                                  // #496