]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cgamevm.c
eliminated qbyte type, now uses unsigned char throughout the engine for this purpose
[xonotic/darkplaces.git] / cgamevm.c
index 277c7eb0c2a07b7d2a83b609deb85dc2e7cbafba..45b81c4e3e60f8326c82873f52c278984aa57b20 100644 (file)
--- a/cgamevm.c
+++ b/cgamevm.c
@@ -12,7 +12,7 @@ static mempool_t *cgvm_mempool;
 
 static void (*cgvm_networkcode[256])(unsigned char num);
 
-static qbyte *cgvm_netbuffer;
+static unsigned char *cgvm_netbuffer;
 static int cgvm_netbufferlength;
 static int cgvm_netbufferpos;
 
@@ -26,6 +26,11 @@ void CL_CGVM_Init(void)
        cgvm_mempool = Mem_AllocPool("CGVM", 0, NULL);
 }
 
+void CL_CGVM_Shutdown(void)
+{
+       Mem_FreePool (&cgvm_mempool);
+}
+
 void CL_CGVM_Clear(void)
 {
        Mem_EmptyPool(cgvm_mempool);
@@ -47,7 +52,7 @@ void CL_CGVM_Start(void)
        CG_Init(); // API call
 }
 
-void CL_CGVM_ParseNetwork(qbyte *netbuffer, int length)
+void CL_CGVM_ParseNetwork(unsigned char *netbuffer, int length)
 {
        int num;
        cgvm_netbuffer = netbuffer;
@@ -57,7 +62,7 @@ void CL_CGVM_ParseNetwork(qbyte *netbuffer, int length)
        {
                num = CGVM_MSG_ReadByte();
                if (cgvm_networkcode[num])
-                       cgvm_networkcode[num]((qbyte)num);
+                       cgvm_networkcode[num]((unsigned char)num);
                else
                        Host_Error("CL_CGVM_ParseNetwork: unregistered network code %i", num);
        }
@@ -169,7 +174,7 @@ void CGVM_Draw_Light(const cgdrawlight_t *l)
 {
        matrix4x4_t matrix;
        Matrix4x4_CreateTranslate(&matrix, l->origin[0], l->origin[1], l->origin[2]);
-       CL_AllocDlight(NULL, &matrix, l->radius, l->color[0], l->color[1], l->color[2], 0, 0, 0, 0, true, 1);
+       CL_AllocDlight(NULL, &matrix, l->radius, l->color[0], l->color[1], l->color[2], 0, 0, 0, -1, true, 1, 0.25, 0, 1, 1, LIGHTFLAG_NORMALMODE | LIGHTFLAG_REALTIMEMODE);
 }
 
 void *CGVM_Malloc(const int size)
@@ -189,19 +194,13 @@ float CGVM_RandomRange(const float r1, const float r2)
 
 float CGVM_TracePhysics(const float *start, const float *end, const float *worldmins, const float *worldmaxs, const float *entitymins, const float *entitymaxs, const cgphysentity_t *physentities, const int numphysentities, float *impactpos, float *impactnormal, int *impactentnum)
 {
-       float frac;
-       vec3_t start2, end2, middle;
+       trace_t trace;
        // FIXME: do tracing agains network entities and physentities here
-       // placeholder world only code assuming 0 size
-       middle[0] = (worldmins[0] + worldmaxs[0]) * 0.5f;
-       middle[1] = (worldmins[1] + worldmaxs[1]) * 0.5f;
-       middle[2] = (worldmins[2] + worldmaxs[2]) * 0.5f;
-       VectorAdd(start, middle, start2);
-       VectorAdd(end, middle, end2);
-       frac = CL_TraceLine((float *)start2, (float *)end2, impactpos, impactnormal, true, NULL, SUPERCONTENTS_SOLID);
-       VectorSubtract(impactpos, middle, impactpos);
+       trace = CL_TraceBox(start, vec3_origin, vec3_origin, end, true, NULL, SUPERCONTENTS_SOLID, false);
+       VectorCopy(trace.endpos, impactpos);
+       VectorCopy(trace.plane.normal, impactnormal);
        *impactentnum = -1;
-       return frac;
+       return trace.fraction;
 }
 
 char *CGVM_GetCvarString(const char *name)
@@ -254,7 +253,7 @@ int CGVM_Model(const char *name)
        }
        if (i >= MAX_CGVM_MODELS)
                return 0;
-       model = Mod_ForName((char *)name, false, false, false);
+       model = Mod_ForName(name, false, false, false);
        if (!model)
                return 0;
        strcpy(cgvm_modelname[i], name);