From: havoc Date: Fri, 21 Oct 2005 05:05:49 +0000 (+0000) Subject: made darkplaces compile successfully with g++ to test for errors C doesn't care about... X-Git-Tag: xonotic-v0.1.0preview~4540 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=aa33d8f8642530f7f266d6cde1422f95aa74b2be;p=xonotic%2Fdarkplaces.git made darkplaces compile successfully with g++ to test for errors C doesn't care about (result: found no actual bugs, just C++ compilers being ultra fussy) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5743 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cgame.c b/cgame.c index ad162bc1..5dab064b 100644 --- a/cgame.c +++ b/cgame.c @@ -336,10 +336,10 @@ static void net_gibshower(unsigned char num) // called by engine void CG_Init(void) { - localentity = CGVM_Malloc(sizeof(*localentity) * MAX_LOCALENTITIES); - localentityactive = CGVM_Malloc(sizeof(*localentityactive) * MAX_LOCALENTITIES); - localentityfreetime = CGVM_Malloc(sizeof(*localentityfreetime) * MAX_LOCALENTITIES); - phys_entity = CGVM_Malloc(sizeof(*phys_entity) * MAX_LOCALENTITIES); + localentity = (localentity_t *)CGVM_Malloc(sizeof(*localentity) * MAX_LOCALENTITIES); + localentityactive = (unsigned char *)CGVM_Malloc(sizeof(*localentityactive) * MAX_LOCALENTITIES); + localentityfreetime = (float *)CGVM_Malloc(sizeof(*localentityfreetime) * MAX_LOCALENTITIES); + phys_entity = (cgphysentity_t *)CGVM_Malloc(sizeof(*phys_entity) * MAX_LOCALENTITIES); CGVM_RegisterNetworkCode(1, net_explosion); CGVM_RegisterNetworkCode(2, net_gibshower); gametime = 0; diff --git a/cl_main.c b/cl_main.c index 9436dbeb..2cae309c 100644 --- a/cl_main.c +++ b/cl_main.c @@ -151,15 +151,15 @@ void CL_ClearState(void) cl_max_lightstyle = MAX_LIGHTSTYLES; cl_max_brushmodel_entities = MAX_EDICTS; - cl_entities = Mem_Alloc(cl_mempool, cl_max_entities * sizeof(entity_t)); - cl_entities_active = Mem_Alloc(cl_mempool, cl_max_brushmodel_entities * sizeof(qbyte)); - cl_static_entities = Mem_Alloc(cl_mempool, cl_max_static_entities * sizeof(entity_t)); - cl_temp_entities = Mem_Alloc(cl_mempool, cl_max_temp_entities * sizeof(entity_t)); - cl_effects = Mem_Alloc(cl_mempool, cl_max_effects * sizeof(cl_effect_t)); - cl_beams = Mem_Alloc(cl_mempool, cl_max_beams * sizeof(beam_t)); - cl_dlights = Mem_Alloc(cl_mempool, cl_max_dlights * sizeof(dlight_t)); - cl_lightstyle = Mem_Alloc(cl_mempool, cl_max_lightstyle * sizeof(lightstyle_t)); - cl_brushmodel_entities = Mem_Alloc(cl_mempool, cl_max_brushmodel_entities * sizeof(int)); + cl_entities = (entity_t *)Mem_Alloc(cl_mempool, cl_max_entities * sizeof(entity_t)); + cl_entities_active = (qbyte *)Mem_Alloc(cl_mempool, cl_max_brushmodel_entities * sizeof(qbyte)); + cl_static_entities = (entity_t *)Mem_Alloc(cl_mempool, cl_max_static_entities * sizeof(entity_t)); + cl_temp_entities = (entity_t *)Mem_Alloc(cl_mempool, cl_max_temp_entities * sizeof(entity_t)); + cl_effects = (cl_effect_t *)Mem_Alloc(cl_mempool, cl_max_effects * sizeof(cl_effect_t)); + cl_beams = (beam_t *)Mem_Alloc(cl_mempool, cl_max_beams * sizeof(beam_t)); + cl_dlights = (dlight_t *)Mem_Alloc(cl_mempool, cl_max_dlights * sizeof(dlight_t)); + cl_lightstyle = (lightstyle_t *)Mem_Alloc(cl_mempool, cl_max_lightstyle * sizeof(lightstyle_t)); + cl_brushmodel_entities = (int *)Mem_Alloc(cl_mempool, cl_max_brushmodel_entities * sizeof(int)); cl_lastquakeentity = 0; memset(cl_isquakeentity, 0, sizeof(cl_isquakeentity)); @@ -205,7 +205,7 @@ void CL_ExpandEntities(int num) oldmaxentities = cl_max_entities; oldentities = cl_entities; cl_max_entities = (num & ~255) + 256; - cl_entities = Mem_Alloc(cl_mempool, cl_max_entities * sizeof(entity_t)); + cl_entities = (entity_t *)Mem_Alloc(cl_mempool, cl_max_entities * sizeof(entity_t)); memcpy(cl_entities, oldentities, oldmaxentities * sizeof(entity_t)); Mem_Free(oldentities); for (i = oldmaxentities;i < cl_max_entities;i++) @@ -1442,10 +1442,10 @@ void CL_Init (void) memset(&r_refdef, 0, sizeof(r_refdef)); // max entities sent to renderer per frame r_refdef.maxentities = MAX_EDICTS + 256 + 512; - r_refdef.entities = Mem_Alloc(cl_mempool, sizeof(entity_render_t *) * r_refdef.maxentities); + r_refdef.entities = (entity_render_t **)Mem_Alloc(cl_mempool, sizeof(entity_render_t *) * r_refdef.maxentities); // 256k drawqueue buffer r_refdef.maxdrawqueuesize = 256 * 1024; - r_refdef.drawqueue = Mem_Alloc(cl_mempool, r_refdef.maxdrawqueuesize); + r_refdef.drawqueue = (qbyte *)Mem_Alloc(cl_mempool, r_refdef.maxdrawqueuesize); cls.message.data = cls.message_buf; cls.message.maxsize = sizeof(cls.message_buf); diff --git a/cl_parse.c b/cl_parse.c index eba47c48..5580300f 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -366,7 +366,7 @@ void CL_ParseServerInfo (void) Host_Error("Bad maxclients (%u) from server\n", cl.maxclients); return; } - cl.scores = Mem_Alloc(cl_mempool, cl.maxclients*sizeof(*cl.scores)); + cl.scores = (scoreboard_t *)Mem_Alloc(cl_mempool, cl.maxclients*sizeof(*cl.scores)); // parse gametype cl.gametype = MSG_ReadByte (); diff --git a/cl_particles.c b/cl_particles.c index cb3cf0c8..775df5e4 100644 --- a/cl_particles.c +++ b/cl_particles.c @@ -1686,7 +1686,7 @@ static void R_InitParticleTexture (void) // and white on black background) so we can alpha fade it to black, then // we invert it again during the blendfunc to make it work... - particletexturedata = Mem_Alloc(tempmempool, PARTICLEFONTSIZE*PARTICLEFONTSIZE*4); + particletexturedata = (qbyte *)Mem_Alloc(tempmempool, PARTICLEFONTSIZE*PARTICLEFONTSIZE*4); memset(particletexturedata, 255, PARTICLEFONTSIZE*PARTICLEFONTSIZE*4); // smoke @@ -1898,7 +1898,7 @@ void R_DrawParticle(particle_t *p) #else void R_DrawParticleCallback(const void *calldata1, int calldata2) { - const particle_t *p = calldata1; + const particle_t *p = (particle_t *)calldata1; rmeshstate_t m; #endif pblend_t blendmode; diff --git a/cl_screen.c b/cl_screen.c index 687f6113..eb0a4035 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -683,7 +683,7 @@ void DrawQ_String_Real(float x, float y, const char *string, int maxlen, float s green = bound(0, green, 1); blue = bound(0, blue, 1); alpha = bound(0, alpha, 1); - dq = (void *)(r_refdef.drawqueue + r_refdef.drawqueuesize); + dq = (drawqueue_t *)(r_refdef.drawqueue + r_refdef.drawqueuesize); dq->size = size; dq->command = DRAWQUEUE_STRING; dq->flags = flags; @@ -760,7 +760,7 @@ void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags) size += sizeof(float[4]) * mesh->num_vertices; if (r_refdef.drawqueuesize + size > r_refdef.maxdrawqueuesize) return; - dq = (void *)(r_refdef.drawqueue + r_refdef.drawqueuesize); + dq = (drawqueue_t *)(r_refdef.drawqueue + r_refdef.drawqueuesize); dq->size = size; dq->command = DRAWQUEUE_MESH; dq->flags = flags; @@ -770,14 +770,14 @@ void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags) dq->scalex = 0; dq->scaley = 0; p = (void *)(dq + 1); - m = p;p = (qbyte*)p + sizeof(drawqueuemesh_t); + m = (drawqueuemesh_t *)p;p = (qbyte*)p + sizeof(drawqueuemesh_t); m->num_triangles = mesh->num_triangles; m->num_vertices = mesh->num_vertices; m->texture = mesh->texture; - m->data_element3i = p;memcpy(m->data_element3i , mesh->data_element3i , m->num_triangles * sizeof(int[3]));p = (qbyte*)p + m->num_triangles * sizeof(int[3]); - m->data_vertex3f = p;memcpy(m->data_vertex3f , mesh->data_vertex3f , m->num_vertices * sizeof(float[3]));p = (qbyte*)p + m->num_vertices * sizeof(float[3]); - m->data_texcoord2f = p;memcpy(m->data_texcoord2f, mesh->data_texcoord2f, m->num_vertices * sizeof(float[2]));p = (qbyte*)p + m->num_vertices * sizeof(float[2]); - m->data_color4f = p;memcpy(m->data_color4f , mesh->data_color4f , m->num_vertices * sizeof(float[4]));p = (qbyte*)p + m->num_vertices * sizeof(float[4]); + m->data_element3i = (int *)p;memcpy(m->data_element3i , mesh->data_element3i , m->num_triangles * sizeof(int[3]));p = (qbyte*)p + m->num_triangles * sizeof(int[3]); + m->data_vertex3f = (float *)p;memcpy(m->data_vertex3f , mesh->data_vertex3f , m->num_vertices * sizeof(float[3]));p = (qbyte*)p + m->num_vertices * sizeof(float[3]); + m->data_texcoord2f = (float *)p;memcpy(m->data_texcoord2f, mesh->data_texcoord2f, m->num_vertices * sizeof(float[2]));p = (qbyte*)p + m->num_vertices * sizeof(float[2]); + m->data_color4f = (float *)p;memcpy(m->data_color4f , mesh->data_color4f , m->num_vertices * sizeof(float[4]));p = (qbyte*)p + m->num_vertices * sizeof(float[4]); r_refdef.drawqueuesize += dq->size; } @@ -789,7 +789,7 @@ void DrawQ_SetClipArea(float x, float y, float width, float height) Con_DPrint("DrawQueue full !\n"); return; } - dq = (void*) (r_refdef.drawqueue + r_refdef.drawqueuesize); + dq = (drawqueue_t *) (r_refdef.drawqueue + r_refdef.drawqueuesize); dq->size = sizeof(*dq); dq->command = DRAWQUEUE_SETCLIP; dq->x = x; @@ -810,7 +810,7 @@ void DrawQ_ResetClipArea(void) Con_DPrint("DrawQueue full !\n"); return; } - dq = (void*) (r_refdef.drawqueue + r_refdef.drawqueuesize); + dq = (drawqueue_t *) (r_refdef.drawqueue + r_refdef.drawqueuesize); dq->size = sizeof(*dq); dq->command = DRAWQUEUE_RESETCLIP; dq->x = 0; @@ -859,9 +859,9 @@ void SCR_ScreenShot_f (void) sprintf(filename, "%s%06d.%s", base, shotnumber, jpeg ? "jpg" : "tga"); - buffer1 = Mem_Alloc(tempmempool, vid.width * vid.height * 3); - buffer2 = Mem_Alloc(tempmempool, vid.width * vid.height * 3); - buffer3 = Mem_Alloc(tempmempool, vid.width * vid.height * 3 + 18); + buffer1 = (qbyte *)Mem_Alloc(tempmempool, vid.width * vid.height * 3); + buffer2 = (qbyte *)Mem_Alloc(tempmempool, vid.width * vid.height * 3); + buffer3 = (qbyte *)Mem_Alloc(tempmempool, vid.width * vid.height * 3 + 18); if (SCR_ScreenShot (filename, buffer1, buffer2, buffer3, 0, 0, vid.width, vid.height, false, false, false, jpeg, true)) Con_Printf("Wrote %s\n", filename); @@ -910,7 +910,7 @@ void SCR_CaptureVideo_BeginVideo(void) cl_capturevideo_framerate = bound(1, cl_capturevideo_fps.value, 1000); cl_capturevideo_soundrate = 0; cl_capturevideo_frame = 0; - cl_capturevideo_buffer = Mem_Alloc(tempmempool, vid.width * vid.height * (3+3+3) + 18); + cl_capturevideo_buffer = (qbyte *)Mem_Alloc(tempmempool, vid.width * vid.height * (3+3+3) + 18); gamma = 1.0/scr_screenshot_gamma.value; /* @@ -1258,9 +1258,9 @@ static void R_Envmap_f (void) r_refdef.fov_x = 90; r_refdef.fov_y = 90; - buffer1 = Mem_Alloc(tempmempool, size * size * 3); - buffer2 = Mem_Alloc(tempmempool, size * size * 3); - buffer3 = Mem_Alloc(tempmempool, size * size * 3 + 18); + buffer1 = (qbyte *)Mem_Alloc(tempmempool, size * size * 3); + buffer2 = (qbyte *)Mem_Alloc(tempmempool, size * size * 3); + buffer3 = (qbyte *)Mem_Alloc(tempmempool, size * size * 3 + 18); for (j = 0;j < 12;j++) { diff --git a/cl_video.c b/cl_video.c index 692dc941..c3a7fc98 100644 --- a/cl_video.c +++ b/cl_video.c @@ -195,7 +195,7 @@ static void VideoFrame( clvideo_t *video ) return; } } while( video->framenum < destframe ); - R_UpdateTexture( video->cpif.tex, video->imagedata ); + R_UpdateTexture( video->cpif.tex, (qbyte *)video->imagedata ); } } diff --git a/client.h b/client.h index 2da0549c..338f2ba6 100644 --- a/client.h +++ b/client.h @@ -909,7 +909,7 @@ typedef struct } refdef_t; -refdef_t r_refdef; +extern refdef_t r_refdef; #include "cgamevm.h" diff --git a/cmd.c b/cmd.c index ee08ff9b..2939779e 100644 --- a/cmd.c +++ b/cmd.c @@ -87,7 +87,7 @@ void Cbuf_AddText (const char *text) return; } - SZ_Write (&cmd_text, text, (int)strlen (text)); + SZ_Write (&cmd_text, (const qbyte *)text, (int)strlen (text)); } @@ -109,7 +109,7 @@ void Cbuf_InsertText (const char *text) templen = cmd_text.cursize; if (templen) { - temp = Mem_Alloc (tempmempool, templen); + temp = (char *)Mem_Alloc (tempmempool, templen); memcpy (temp, cmd_text.data, templen); SZ_Clear (&cmd_text); } @@ -122,7 +122,7 @@ void Cbuf_InsertText (const char *text) // add the copied off data if (temp != NULL) { - SZ_Write (&cmd_text, temp, templen); + SZ_Write (&cmd_text, (const qbyte *)temp, templen); Mem_Free (temp); } } @@ -337,7 +337,7 @@ static void Cmd_Alias_f (void) { cmdalias_t *prev, *current; - a = Z_Malloc (sizeof(cmdalias_t)); + a = (cmdalias_t *)Z_Malloc (sizeof(cmdalias_t)); strlcpy (a->name, s, sizeof (a->name)); // insert it at the right alphanumeric position for( prev = NULL, current = cmd_alias ; current && strcmp( current->name, a->name ) < 0 ; prev = current, current = current->next ) @@ -362,7 +362,7 @@ static void Cmd_Alias_f (void) } strlcat (cmd, "\n", sizeof (cmd)); - a->value = Z_Malloc (strlen (cmd) + 1); + a->value = (char *)Z_Malloc (strlen (cmd) + 1); strcpy (a->value, cmd); } @@ -702,7 +702,7 @@ void Cmd_AddCommand (const char *cmd_name, xcommand_t function) } } - cmd = Mem_Alloc(cmd_mempool, sizeof(cmd_function_t)); + cmd = (cmd_function_t *)Mem_Alloc(cmd_mempool, sizeof(cmd_function_t)); cmd->name = cmd_name; cmd->function = function; cmd->next = cmd_functions; @@ -805,7 +805,7 @@ const char **Cmd_CompleteBuildList (const char *partial) const char **buf; len = strlen(partial); - buf = Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *)); + buf = (const char **)Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *)); // Loop through the alias list and print all matches for (cmd = cmd_functions; cmd; cmd = cmd->next) if (!strncasecmp(partial, cmd->name, len)) @@ -890,7 +890,7 @@ const char **Cmd_CompleteAliasBuildList (const char *partial) const char **buf; len = strlen(partial); - buf = Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *)); + buf = (const char **)Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *)); // Loop through the alias list and print all matches for (alias = cmd_alias; alias; alias = alias->next) if (!strncasecmp(partial, alias->name, len)) @@ -977,7 +977,7 @@ void Cmd_ForwardStringToServer (const char *s) // attention, it has been eradicated from here, its only (former) use in // all of darkplaces. MSG_WriteByte(&cls.message, clc_stringcmd); - SZ_Write(&cls.message, s, (int)strlen(s) + 1); + SZ_Write(&cls.message, (const qbyte *)s, (int)strlen(s) + 1); } /* diff --git a/collision.c b/collision.c index 6fc28f0a..be5fd1ba 100644 --- a/collision.c +++ b/collision.c @@ -322,14 +322,14 @@ colbrushf_t *Collision_NewBrushFromPlanes(mempool_t *mempool, int numoriginalpla colbrushf_t *Collision_AllocBrushFloat(mempool_t *mempool, int numpoints, int numplanes, int numtriangles, int supercontents) { colbrushf_t *brush; - brush = Mem_Alloc(mempool, sizeof(colbrushf_t) + sizeof(colpointf_t) * numpoints + sizeof(colplanef_t) * numplanes + sizeof(int[3]) * numtriangles); + brush = (colbrushf_t *)Mem_Alloc(mempool, sizeof(colbrushf_t) + sizeof(colpointf_t) * numpoints + sizeof(colplanef_t) * numplanes + sizeof(int[3]) * numtriangles); brush->supercontents = supercontents; brush->numplanes = numplanes; brush->numpoints = numpoints; brush->numtriangles = numtriangles; - brush->planes = (void *)(brush + 1); - brush->points = (void *)(brush->planes + brush->numplanes); - brush->elements = (void *)(brush->points + brush->numpoints); + brush->planes = (colplanef_t *)(brush + 1); + brush->points = (colpointf_t *)(brush->planes + brush->numplanes); + brush->elements = (int *)(brush->points + brush->numpoints); return brush; } @@ -505,11 +505,11 @@ void Collision_CalcPlanesForPolygonBrushFloat(colbrushf_t *brush) colbrushf_t *Collision_AllocBrushFromPermanentPolygonFloat(mempool_t *mempool, int numpoints, float *points, int supercontents) { colbrushf_t *brush; - brush = Mem_Alloc(mempool, sizeof(colbrushf_t) + sizeof(colplanef_t) * (numpoints + 2)); + brush = (colbrushf_t *)Mem_Alloc(mempool, sizeof(colbrushf_t) + sizeof(colplanef_t) * (numpoints + 2)); brush->supercontents = supercontents; brush->numpoints = numpoints; brush->numplanes = numpoints + 2; - brush->planes = (void *)(brush + 1); + brush->planes = (colplanef_t *)(brush + 1); brush->points = (colpointf_t *)points; Sys_Error("Collision_AllocBrushFromPermanentPolygonFloat: FIXME: this code needs to be updated to generate a mesh...\n"); return brush; @@ -1339,9 +1339,9 @@ colbsp_t; colbsp_t *Collision_CreateCollisionBSP(mempool_t *mempool) { colbsp_t *bsp; - bsp = Mem_Alloc(mempool, sizeof(colbsp_t)); + bsp = (colbsp_t *)Mem_Alloc(mempool, sizeof(colbsp_t)); bsp->mempool = mempool; - bsp->nodes = Mem_Alloc(bsp->mempool, sizeof(colbspnode_t)); + bsp->nodes = (colbspnode_t *)Mem_Alloc(bsp->mempool, sizeof(colbspnode_t)); return bsp; } diff --git a/common.c b/common.c index 561d404f..334a31b1 100644 --- a/common.c +++ b/common.c @@ -241,21 +241,21 @@ void MSG_WriteFloat (sizebuf_t *sb, float f) dat.f = f; dat.l = LittleLong (dat.l); - SZ_Write (sb, &dat.l, 4); + SZ_Write (sb, (qbyte *)&dat.l, 4); } void MSG_WriteString (sizebuf_t *sb, const char *s) { if (!s) - SZ_Write (sb, "", 1); + SZ_Write (sb, (qbyte *)"", 1); else - SZ_Write (sb, s, (int)strlen(s)+1); + SZ_Write (sb, (qbyte *)s, (int)strlen(s)+1); } void MSG_WriteUnterminatedString (sizebuf_t *sb, const char *s) { if (s) - SZ_Write (sb, s, (int)strlen(s)); + SZ_Write (sb, (qbyte *)s, (int)strlen(s)); } void MSG_WriteCoord13i (sizebuf_t *sb, float f) @@ -502,9 +502,9 @@ void SZ_Clear (sizebuf_t *buf) buf->cursize = 0; } -void *SZ_GetSpace (sizebuf_t *buf, int length) +qbyte *SZ_GetSpace (sizebuf_t *buf, int length) { - void *data; + qbyte *data; if (buf->cursize + length > buf->maxsize) { @@ -525,7 +525,7 @@ void *SZ_GetSpace (sizebuf_t *buf, int length) return data; } -void SZ_Write (sizebuf_t *buf, const void *data, int length) +void SZ_Write (sizebuf_t *buf, const qbyte *data, int length) { memcpy (SZ_GetSpace(buf,length),data,length); } @@ -990,7 +990,7 @@ void COM_InitGameType (void) for (i = 1; i < sizeof (gamemode_info) / sizeof (gamemode_info[0]); i++) if (strstr (name, gamemode_info[i].prog_name)) { - gamemode = i; + gamemode = (gamemode_t)i; break; } @@ -998,7 +998,7 @@ void COM_InitGameType (void) for (i = 0; i < sizeof (gamemode_info) / sizeof (gamemode_info[0]); i++) if (COM_CheckParm (gamemode_info[i].cmdline)) { - gamemode = i; + gamemode = (gamemode_t)i; break; } diff --git a/common.h b/common.h index c94e668f..699c4598 100644 --- a/common.h +++ b/common.h @@ -50,8 +50,8 @@ typedef struct sizebuf_s } sizebuf_t; void SZ_Clear (sizebuf_t *buf); -void *SZ_GetSpace (sizebuf_t *buf, int length); -void SZ_Write (sizebuf_t *buf, const void *data, int length); +qbyte *SZ_GetSpace (sizebuf_t *buf, int length); +void SZ_Write (sizebuf_t *buf, const qbyte *data, int length); void SZ_HexDumpToConsole(const sizebuf_t *buf); void Com_HexDumpToConsole(const qbyte *data, int size); diff --git a/console.c b/console.c index b99f7c4b..7fbe3056 100644 --- a/console.c +++ b/console.c @@ -186,7 +186,7 @@ void Log_ConPrint (const char *msg) qbyte* newqueue; logq_size *= factor; - newqueue = Mem_Alloc (tempmempool, logq_size); + newqueue = (qbyte *)Mem_Alloc (tempmempool, logq_size); memcpy (newqueue, logqueue, logq_ind); Mem_Free (logqueue); logqueue = newqueue; @@ -369,7 +369,7 @@ void Con_Init (void) // Allocate a log queue logq_size = 512; - logqueue = Mem_Alloc (tempmempool, logq_size); + logqueue = (qbyte *)Mem_Alloc (tempmempool, logq_size); logq_ind = 0; Cvar_RegisterVariable (&log_file); @@ -542,7 +542,7 @@ void Con_Print(const char *msg) if (index == 0) { // if this is the beginning of a new line, print timestamp - char *timestamp = timestamps.integer ? Sys_TimeString(timeformat.string) : ""; + const char *timestamp = timestamps.integer ? Sys_TimeString(timeformat.string) : ""; // reset the color // FIXME: 1. perhaps we should use a terminal system 2. use a constant instead of 7! line[index++] = STRING_COLOR_TAG; @@ -730,7 +730,7 @@ void Con_DrawNotify (void) char *text; int i; float time; - extern char chat_buffer[]; + extern char chat_buffer[256]; char temptext[256]; int colorindex = -1; //-1 for default @@ -802,7 +802,6 @@ Draws the console with the solid background The typing input line at the bottom should only be drawn if typing is allowed ================ */ -extern char engineversion[40]; void Con_DrawConsole (int lines) { int i, y, rows, j; diff --git a/cvar.c b/cvar.c index 5df43cc2..27853eec 100644 --- a/cvar.c +++ b/cvar.c @@ -181,7 +181,7 @@ const char **Cvar_CompleteBuildList (const char *partial) const char **buf; len = strlen(partial); - buf = Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *)); + buf = (const char **)Mem_Alloc(tempmempool, sizeofbuf + sizeof (const char *)); // Loop through the alias list and print all matches for (cvar = cvar_vars; cvar; cvar = cvar->next) if (!strncasecmp(partial, cvar->name, len)) @@ -210,7 +210,7 @@ void Cvar_SetQuick_Internal (cvar_t *var, const char *value) { Z_Free (var->string); // free the old value string - var->string = Z_Malloc (strlen(value)+1); + var->string = (char *)Z_Malloc (strlen(value)+1); } strcpy (var->string, value); var->value = atof (var->string); @@ -339,9 +339,9 @@ void Cvar_RegisterVariable (cvar_t *variable) // copy the value off, because future sets will Z_Free it oldstr = variable->string; - variable->string = Z_Malloc (strlen(variable->string)+1); + variable->string = (char *)Z_Malloc (strlen(variable->string)+1); strcpy (variable->string, oldstr); - variable->defstring = Z_Malloc (strlen(variable->string)+1); + variable->defstring = (char *)Z_Malloc (strlen(variable->string)+1); strcpy (variable->defstring, oldstr); variable->value = atof (variable->string); variable->integer = (int) variable->value; @@ -384,7 +384,7 @@ cvar_t *Cvar_Get (const char *name, const char *value, int flags) cvar->flags |= CVAR_DEFAULTSET; Z_Free(cvar->defstring); - cvar->defstring = Z_Malloc(strlen(value) + 1); + cvar->defstring = (char *)Z_Malloc(strlen(value) + 1); strcpy(cvar->defstring, value); } return cvar; @@ -399,13 +399,13 @@ cvar_t *Cvar_Get (const char *name, const char *value, int flags) // allocate a new cvar, cvar name, and cvar string // FIXME: these never get Z_Free'd - cvar = Z_Malloc(sizeof(cvar_t)); + cvar = (cvar_t *)Z_Malloc(sizeof(cvar_t)); cvar->flags = flags | CVAR_ALLOCATED | CVAR_DEFAULTSET; - cvar->name = Z_Malloc(strlen(name)+1); + cvar->name = (char *)Z_Malloc(strlen(name)+1); strcpy(cvar->name, name); - cvar->string = Z_Malloc(strlen(value)+1); + cvar->string = (char *)Z_Malloc(strlen(value)+1); strcpy(cvar->string, value); - cvar->defstring = Z_Malloc(strlen(value)+1); + cvar->defstring = (char *)Z_Malloc(strlen(value)+1); strcpy(cvar->defstring, value); cvar->value = atof (cvar->string); cvar->integer = (int) cvar->value; diff --git a/dpvsimpledecode.c b/dpvsimpledecode.c index 9f415497..a8d537ef 100644 --- a/dpvsimpledecode.c +++ b/dpvsimpledecode.c @@ -40,7 +40,7 @@ hz_bitstream_read_t *hz_bitstream_read_open(char *filename) hz_bitstream_read_t *stream; if ((file = FS_Open (filename, "rb", false, false))) { - stream = malloc(sizeof(hz_bitstream_read_t)); + stream = (hz_bitstream_read_t *)malloc(sizeof(hz_bitstream_read_t)); memset(stream, 0, sizeof(*stream)); stream->file = file; return stream; @@ -61,7 +61,7 @@ void hz_bitstream_read_close(hz_bitstream_read_t *stream) hz_bitstream_readblocks_t *hz_bitstream_read_blocks_new(void) { hz_bitstream_readblocks_t *blocks; - blocks = malloc(sizeof(hz_bitstream_readblocks_t)); + blocks = (hz_bitstream_readblocks_t *)malloc(sizeof(hz_bitstream_readblocks_t)); if (blocks == NULL) return NULL; memset(blocks, 0, sizeof(hz_bitstream_readblocks_t)); @@ -98,7 +98,7 @@ int hz_bitstream_read_blocks_read(hz_bitstream_readblocks_t *blocks, hz_bitstrea { if (b == NULL) { - b = malloc(sizeof(hz_bitstream_readblock_t)); + b = (hz_bitstream_readblock_t *)malloc(sizeof(hz_bitstream_readblock_t)); if (b == NULL) return HZREADERROR_MALLOCFAILED; b->next = NULL; @@ -201,7 +201,7 @@ unsigned int hz_bitstream_read_int(hz_bitstream_readblocks_t *blocks) void hz_bitstream_read_bytes(hz_bitstream_readblocks_t *blocks, void *outdata, unsigned int size) { unsigned char *out; - out = outdata; + out = (unsigned char *)outdata; while (size--) *out++ = hz_bitstream_read_byte(blocks); } @@ -364,7 +364,7 @@ void *dpvsimpledecode_open(char *filename, char **errorstring) char t[8], *wavename; if (errorstring != NULL) *errorstring = NULL; - s = malloc(sizeof(dpvsimpledecodestream_t)); + s = (dpvsimpledecodestream_t *)Z_Malloc(sizeof(dpvsimpledecodestream_t)); if (s != NULL) { s->bitstream = hz_bitstream_read_open(filename); @@ -389,10 +389,10 @@ void *dpvsimpledecode_open(char *filename, char **errorstring) if (s->info_framerate > 0.0) { - s->videopixels = malloc(s->info_imagewidth * s->info_imageheight * sizeof(*s->videopixels)); + s->videopixels = (unsigned int *)Z_Malloc(s->info_imagewidth * s->info_imageheight * sizeof(*s->videopixels)); if (s->videopixels != NULL) { - wavename = malloc(strlen(filename) + 10); + wavename = (char *)Z_Malloc(strlen(filename) + 10); if (wavename) { sfx_t* sfx; @@ -439,7 +439,7 @@ void *dpvsimpledecode_open(char *filename, char **errorstring) // closes a stream void dpvsimpledecode_close(void *stream) { - dpvsimpledecodestream_t *s = stream; + dpvsimpledecodestream_t *s = (dpvsimpledecodestream_t *)stream; if (s == NULL) return; if (s->videopixels) @@ -461,7 +461,7 @@ void dpvsimpledecode_close(void *stream) // error message int dpvsimpledecode_error(void *stream, char **errorstring) { - dpvsimpledecodestream_t *s = stream; + dpvsimpledecodestream_t *s = (dpvsimpledecodestream_t *)stream; int e; e = s->error; s->error = 0; @@ -510,21 +510,21 @@ int dpvsimpledecode_error(void *stream, char **errorstring) // returns the width of the image data unsigned int dpvsimpledecode_getwidth(void *stream) { - dpvsimpledecodestream_t *s = stream; + dpvsimpledecodestream_t *s = (dpvsimpledecodestream_t *)stream; return s->info_imagewidth; } // returns the height of the image data unsigned int dpvsimpledecode_getheight(void *stream) { - dpvsimpledecodestream_t *s = stream; + dpvsimpledecodestream_t *s = (dpvsimpledecodestream_t *)stream; return s->info_imageheight; } // returns the framerate of the stream double dpvsimpledecode_getframerate(void *stream) { - dpvsimpledecodestream_t *s = stream; + dpvsimpledecodestream_t *s = (dpvsimpledecodestream_t *)stream; return s->info_framerate; } @@ -557,7 +557,7 @@ static int dpvsimpledecode_convertpixels(dpvsimpledecodestream_t *s, void *image unsigned int *outrow; for (y = 0;y < height;y++) { - outrow = (void *)((unsigned char *)imagedata + y * imagebytesperrow); + outrow = (unsigned int *)((unsigned char *)imagedata + y * imagebytesperrow); for (x = 0;x < width;x++) { a = *in++; @@ -570,7 +570,7 @@ static int dpvsimpledecode_convertpixels(dpvsimpledecodestream_t *s, void *image unsigned short *outrow; for (y = 0;y < height;y++) { - outrow = (void *)((unsigned char *)imagedata + y * imagebytesperrow); + outrow = (unsigned short *)((unsigned char *)imagedata + y * imagebytesperrow); if (Rloss == 19 && Gloss == 10 && Bloss == 3 && Rshift == 11 && Gshift == 5 && Bshift == 0) { // optimized @@ -640,7 +640,7 @@ static int dpvsimpledecode_decompressimage(dpvsimpledecodestream_t *s) // decodes a video frame to the supplied output pixels int dpvsimpledecode_video(void *stream, void *imagedata, unsigned int Rmask, unsigned int Gmask, unsigned int Bmask, unsigned int bytesperpixel, int imagebytesperrow) { - dpvsimpledecodestream_t *s = stream; + dpvsimpledecodestream_t *s = (dpvsimpledecodestream_t *)stream; unsigned int framedatasize; char t[4]; s->error = DPVSIMPLEDECODEERROR_NONE; diff --git a/filematch.c b/filematch.c index 758575f2..ca0969ce 100644 --- a/filematch.c +++ b/filematch.c @@ -61,7 +61,7 @@ int matchpattern(char *in, char *pattern, int caseinsensitive) stringlist_t *stringlistappend(stringlist_t *current, char *text) { stringlist_t *newitem; - newitem = Z_Malloc(strlen(text) + 1 + sizeof(stringlist_t)); + newitem = (stringlist_t *)Z_Malloc(strlen(text) + 1 + sizeof(stringlist_t)); newitem->next = NULL; newitem->text = (char *)(newitem + 1); strcpy(newitem->text, text); diff --git a/fractalnoise.c b/fractalnoise.c index 90419e3d..eabe7ead 100644 --- a/fractalnoise.c +++ b/fractalnoise.c @@ -24,7 +24,7 @@ void fractalnoise(qbyte *noise, int size, int startgrid) startgrid = bound(0, startgrid, size); amplitude = 0xFFFF; // this gets halved before use - noisebuf = Mem_Alloc(tempmempool, size*size*sizeof(int)); + noisebuf = (int *)Mem_Alloc(tempmempool, size*size*sizeof(int)); memset(noisebuf, 0, size*size*sizeof(int)); for (g2 = startgrid;g2;g2 >>= 1) diff --git a/fs.c b/fs.c index fcd5b7d0..1a071c2c 100644 --- a/fs.c +++ b/fs.c @@ -135,12 +135,10 @@ typedef struct } z_stream; -typedef enum -{ - QFILE_FLAG_NONE = 0, - QFILE_FLAG_PACKED = (1 << 0), // inside a package (PAK or PK3) - QFILE_FLAG_DEFLATED = (1 << 1) // file is compressed using the deflate algorithm (PK3 only) -} qfile_flags_t; +// inside a package (PAK or PK3) +#define QFILE_FLAG_PACKED (1 << 0) +// file is compressed using the deflate algorithm (PK3 only) +#define QFILE_FLAG_DEFLATED (1 << 1) #define FILE_BUFF_SIZE 2048 typedef struct @@ -154,7 +152,7 @@ typedef struct struct qfile_s { - qfile_flags_t flags; + int flags; int handle; // file descriptor fs_offset_t real_length; // uncompressed file size (for files opened in "read" mode) fs_offset_t position; // current position in the file @@ -203,17 +201,15 @@ typedef struct // Packages in memory -typedef enum -{ - PACKFILE_FLAG_NONE = 0, - PACKFILE_FLAG_TRUEOFFS = (1 << 0), // the offset in packfile_t is the true contents offset - PACKFILE_FLAG_DEFLATED = (1 << 1) // file compressed using the deflate algorithm -} packfile_flags_t; +// the offset in packfile_t is the true contents offset +#define PACKFILE_FLAG_TRUEOFFS (1 << 0) +// file compressed using the deflate algorithm +#define PACKFILE_FLAG_DEFLATED (1 << 1) typedef struct { char name [MAX_QPATH]; - packfile_flags_t flags; + int flags; fs_offset_t offset; fs_offset_t packsize; // size in the package fs_offset_t realsize; // real file size (uncompressed) @@ -253,7 +249,7 @@ void FS_Ls_f(void); static packfile_t* FS_AddFileToPack (const char* name, pack_t* pack, fs_offset_t offset, fs_offset_t packsize, - fs_offset_t realsize, packfile_flags_t flags); + fs_offset_t realsize, int flags); /* @@ -399,7 +395,7 @@ qboolean PK3_GetEndOfCentralDir (const char *packfile, int packhandle, pk3_endOf maxsize = filesize; else maxsize = ZIP_MAX_COMMENTS_SIZE + ZIP_END_CDIR_SIZE; - buffer = Mem_Alloc (tempmempool, maxsize); + buffer = (qbyte *)Mem_Alloc (tempmempool, maxsize); lseek (packhandle, filesize - maxsize, SEEK_SET); if (read (packhandle, buffer, maxsize) != (fs_offset_t) maxsize) { @@ -453,7 +449,7 @@ int PK3_BuildFileList (pack_t *pack, const pk3_endOfCentralDir_t *eocd) fs_offset_t remaining; // Load the central directory in memory - central_dir = Mem_Alloc (tempmempool, eocd->cdir_size); + central_dir = (qbyte *)Mem_Alloc (tempmempool, eocd->cdir_size); lseek (pack->handle, eocd->cdir_offset, SEEK_SET); read (pack->handle, central_dir, eocd->cdir_size); @@ -503,7 +499,7 @@ int PK3_BuildFileList (pack_t *pack, const pk3_endOfCentralDir_t *eocd) { char filename [sizeof (pack->files[0].name)]; fs_offset_t offset, packsize, realsize; - packfile_flags_t flags; + int flags; // Extract the name (strip it if necessary) namesize = min(namesize, (int)sizeof (filename) - 1); @@ -581,12 +577,12 @@ pack_t *FS_LoadPackPK3 (const char *packfile) #endif // Create a package structure in memory - pack = Mem_Alloc(fs_mempool, sizeof (pack_t)); + pack = (pack_t *)Mem_Alloc(fs_mempool, sizeof (pack_t)); pack->ignorecase = true; // PK3 ignores case strlcpy (pack->filename, packfile, sizeof (pack->filename)); pack->handle = packhandle; pack->numfiles = eocd.nbentries; - pack->files = Mem_Alloc(fs_mempool, eocd.nbentries * sizeof(packfile_t)); + pack->files = (packfile_t *)Mem_Alloc(fs_mempool, eocd.nbentries * sizeof(packfile_t)); pack->next = packlist; packlist = pack; @@ -655,7 +651,7 @@ Add a file to the list of files contained into a package */ static packfile_t* FS_AddFileToPack (const char* name, pack_t* pack, fs_offset_t offset, fs_offset_t packsize, - fs_offset_t realsize, packfile_flags_t flags) + fs_offset_t realsize, int flags) { int (*strcmp_funct) (const char* str1, const char* str2); int left, right, middle; @@ -792,16 +788,16 @@ pack_t *FS_LoadPackPAK (const char *packfile) return NULL; } - pack = Mem_Alloc(fs_mempool, sizeof (pack_t)); + pack = (pack_t *)Mem_Alloc(fs_mempool, sizeof (pack_t)); pack->ignorecase = false; // PAK is case sensitive strlcpy (pack->filename, packfile, sizeof (pack->filename)); pack->handle = packhandle; pack->numfiles = 0; - pack->files = Mem_Alloc(fs_mempool, numpackfiles * sizeof(packfile_t)); + pack->files = (packfile_t *)Mem_Alloc(fs_mempool, numpackfiles * sizeof(packfile_t)); pack->next = packlist; packlist = pack; - info = Mem_Alloc(tempmempool, sizeof(*info) * numpackfiles); + info = (dpackfile_t *)Mem_Alloc(tempmempool, sizeof(*info) * numpackfiles); lseek (packhandle, header.dirofs, SEEK_SET); read (packhandle, (void *)info, header.dirlen); @@ -849,7 +845,7 @@ void FS_AddGameDirectory (const char *dir) pak = FS_LoadPackPAK (pakfile); if (pak) { - search = Mem_Alloc(fs_mempool, sizeof(searchpath_t)); + search = (searchpath_t *)Mem_Alloc(fs_mempool, sizeof(searchpath_t)); search->pack = pak; search->next = fs_searchpaths; fs_searchpaths = search; @@ -868,7 +864,7 @@ void FS_AddGameDirectory (const char *dir) pak = FS_LoadPackPK3 (pakfile); if (pak) { - search = Mem_Alloc(fs_mempool, sizeof(searchpath_t)); + search = (searchpath_t *)Mem_Alloc(fs_mempool, sizeof(searchpath_t)); search->pack = pak; search->next = fs_searchpaths; fs_searchpaths = search; @@ -881,7 +877,7 @@ void FS_AddGameDirectory (const char *dir) // Add the directory to the search path // (unpacked files have the priority over packed files) - search = Mem_Alloc(fs_mempool, sizeof(searchpath_t)); + search = (searchpath_t *)Mem_Alloc(fs_mempool, sizeof(searchpath_t)); strlcpy (search->filename, dir, sizeof (search->filename)); search->next = fs_searchpaths; fs_searchpaths = search; @@ -991,7 +987,7 @@ void FS_Init (void) if (!com_argv[i] || com_argv[i][0] == '+' || com_argv[i][0] == '-') break; - search = Mem_Alloc(fs_mempool, sizeof(searchpath_t)); + search = (searchpath_t *)Mem_Alloc(fs_mempool, sizeof(searchpath_t)); if (!strcasecmp (FS_FileExtension(com_argv[i]), "pak")) { search->pack = FS_LoadPackPAK (com_argv[i]); @@ -1133,7 +1129,7 @@ static qfile_t* FS_SysOpen (const char* filepath, const char* mode, qboolean non if (nonblocking) opt |= O_NONBLOCK; - file = Mem_Alloc (fs_mempool, sizeof (*file)); + file = (qfile_t *)Mem_Alloc (fs_mempool, sizeof (*file)); memset (file, 0, sizeof (*file)); file->ungetc = EOF; @@ -1203,7 +1199,7 @@ qfile_t *FS_OpenPackedFile (pack_t* pack, int pack_ind) return NULL; } - file = Mem_Alloc (fs_mempool, sizeof (*file)); + file = (qfile_t *)Mem_Alloc (fs_mempool, sizeof (*file)); memset (file, 0, sizeof (*file)); file->handle = dup_handle; file->flags = QFILE_FLAG_PACKED; @@ -1219,7 +1215,7 @@ qfile_t *FS_OpenPackedFile (pack_t* pack, int pack_ind) file->flags |= QFILE_FLAG_DEFLATED; // We need some more variables - ztk = Mem_Alloc (fs_mempool, sizeof (*ztk)); + ztk = (ztoolkit_t *)Mem_Alloc (fs_mempool, sizeof (*ztk)); ztk->comp_length = pfile->packsize; @@ -1737,13 +1733,13 @@ int FS_VPrintf (qfile_t* file, const char* format, va_list ap) char *tempbuff = NULL; buff_size = 1024; - tempbuff = Mem_Alloc (tempmempool, buff_size); + tempbuff = (char *)Mem_Alloc (tempmempool, buff_size); len = dpvsnprintf (tempbuff, buff_size, format, ap); while (len < 0) { Mem_Free (tempbuff); buff_size *= 2; - tempbuff = Mem_Alloc (tempmempool, buff_size); + tempbuff = (char *)Mem_Alloc (tempmempool, buff_size); len = dpvsnprintf (tempbuff, buff_size, format, ap); } @@ -1863,7 +1859,7 @@ int FS_Seek (qfile_t* file, fs_offset_t offset, int whence) // We need a big buffer to force inflating into it directly buffersize = 2 * sizeof (file->buff); - buffer = Mem_Alloc (tempmempool, buffersize); + buffer = (qbyte *)Mem_Alloc (tempmempool, buffersize); // Skip all data until we reach the requested offset while (offset > file->position) @@ -1930,7 +1926,7 @@ qbyte *FS_LoadFile (const char *path, mempool_t *pool, qboolean quiet) if (!file) return NULL; - buf = Mem_Alloc (pool, fs_filesize + 1); + buf = (qbyte *)Mem_Alloc (pool, fs_filesize + 1); buf[fs_filesize] = '\0'; FS_Read (file, buf, fs_filesize); @@ -2114,7 +2110,7 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) separator = max(slash, backslash); separator = max(separator, colon); basepathlength = separator ? (separator + 1 - pattern) : 0; - basepath = Mem_Alloc (tempmempool, basepathlength + 1); + basepath = (char *)Mem_Alloc (tempmempool, basepathlength + 1); if (basepathlength) memcpy(basepath, pattern, basepathlength); basepath[basepathlength] = 0; @@ -2201,7 +2197,7 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) numfiles++; numchars += (int)strlen(listtemp->text) + 1; } - search = Z_Malloc(sizeof(fssearch_t) + numchars + numfiles * sizeof(char *)); + search = (fssearch_t *)Z_Malloc(sizeof(fssearch_t) + numchars + numfiles * sizeof(char *)); search->filenames = (char **)((char *)search + sizeof(fssearch_t)); search->filenamesbuffer = (char *)((char *)search + sizeof(fssearch_t) + numfiles * sizeof(char *)); search->numfilenames = (int)numfiles; diff --git a/gl_backend.c b/gl_backend.c index 38c47073..61e606fe 100644 --- a/gl_backend.c +++ b/gl_backend.c @@ -432,8 +432,8 @@ void GL_SetupTextureState(void) unsigned int i; gltextureunit_t *unit; CHECKGLERROR - gl_state.unit = -1; - gl_state.clientunit = -1; + gl_state.unit = MAX_TEXTUREUNITS; + gl_state.clientunit = MAX_TEXTUREUNITS; for (i = 0;i < MAX_TEXTUREUNITS;i++) { unit = gl_state.units + i; @@ -2052,7 +2052,7 @@ int R_Mesh_CacheArray(rcachearrayrequest_t *r) //R_Mesh_CacheArray_ValidateState(3); // calculate a hashindex to choose a cache chain r->data = NULL; - hashindex = CRC_Block((void *)r, sizeof(*r)) % RCACHEARRAY_HASHSIZE; + hashindex = CRC_Block((qbyte *)r, sizeof(*r)) % RCACHEARRAY_HASHSIZE; // is it already cached? for (lhead = &r_mesh_rcachechain[hashindex], l = lhead->next;l != lhead;l = l->next) diff --git a/gl_draw.c b/gl_draw.c index 365aef20..d6879c8b 100644 --- a/gl_draw.c +++ b/gl_draw.c @@ -44,8 +44,6 @@ static qbyte concharimage[FONT_FILESIZE] = #include "lhfont.h" }; -extern qbyte *LoadTGA (qbyte *f, int matchwidth, int matchheight); - static rtexture_t *draw_generateconchars(void) { int i; @@ -100,8 +98,7 @@ static rtexture_t *draw_generateconchars(void) return R_LoadTexture2D(drawtexturepool, "conchars", 256, 256, &buffer[0][0], TEXTYPE_RGBA, TEXF_ALPHA | TEXF_PRECACHE, NULL); } -static qbyte pointerimage[256] = -{ +static char *pointerimage = "333333332......." "26777761........" "2655541........." @@ -118,7 +115,7 @@ static qbyte pointerimage[256] = "................" "................" "................" -}; +; static rtexture_t *draw_generatemousepointer(void) { @@ -147,9 +144,8 @@ static rtexture_t *draw_generatemousepointer(void) // must match NUMCROSSHAIRS in r_crosshairs.c #define NUMCROSSHAIRS 6 -static qbyte crosshairtexdata[NUMCROSSHAIRS][16*16] = +static char *crosshairtexdata[NUMCROSSHAIRS] = { - { "................" "................" "................" @@ -166,8 +162,7 @@ static qbyte crosshairtexdata[NUMCROSSHAIRS][16*16] = "................" "................" "................" - }, - { + , "................" "................" "................" @@ -184,8 +179,7 @@ static qbyte crosshairtexdata[NUMCROSSHAIRS][16*16] = "................" "................" "................" - }, - { + , "................" ".......77......." ".......77......." @@ -202,8 +196,7 @@ static qbyte crosshairtexdata[NUMCROSSHAIRS][16*16] = ".......77......." ".......77......." "................" - }, - { + , "................" "................" "................" @@ -220,8 +213,7 @@ static qbyte crosshairtexdata[NUMCROSSHAIRS][16*16] = "........7......." "........7......." "................" - }, - { + , "................" "................" "................" @@ -238,8 +230,7 @@ static qbyte crosshairtexdata[NUMCROSSHAIRS][16*16] = "................" "................" "................" - }, - { + , "................" "................" "................" @@ -256,13 +247,12 @@ static qbyte crosshairtexdata[NUMCROSSHAIRS][16*16] = "................" "................" "................" - } }; static rtexture_t *draw_generatecrosshair(int num) { int i; - qbyte *in; + char *in; qbyte data[16*16][4]; in = crosshairtexdata[num]; for (i = 0;i < 16*16;i++) @@ -361,7 +351,7 @@ cachepic_t *Draw_CachePic (const char *path, qboolean persistent) // compatibility with older versions pic->tex = loadtextureimage(drawtexturepool, path + 4, 0, 0, false, flags); // failed to find gfx/whatever.tga or similar, try the wad - if (pic->tex == NULL && (p = W_GetLumpName (path + 4))) + if (pic->tex == NULL && (p = (qpic_t *)W_GetLumpName (path + 4))) { if (!strcmp(path, "gfx/conchars")) { @@ -646,7 +636,7 @@ void R_DrawQueue(void) } break; case DRAWQUEUE_MESH: - mesh = (void *)(dq + 1); + mesh = (drawqueuemesh_t *)(dq + 1); m.pointer_vertex = mesh->data_vertex3f; m.pointer_color = mesh->data_color4f; m.pointer_texcoord[0] = mesh->data_texcoord2f; diff --git a/gl_rmain.c b/gl_rmain.c index 6a1693e3..8525e1d2 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -1156,7 +1156,7 @@ float nomodelcolor4f[6*4] = void R_DrawNoModelCallback(const void *calldata1, int calldata2) { - const entity_render_t *ent = calldata1; + const entity_render_t *ent = (entity_render_t *)calldata1; int i; float f1, f2, *c, diff[3]; float color4f[6*4]; @@ -2011,7 +2011,7 @@ static void R_DrawTextureSurfaceList(const entity_render_t *ent, texture_t *text static void RSurfShader_Transparent_Callback(const void *calldata1, int calldata2) { - const entity_render_t *ent = calldata1; + const entity_render_t *ent = (entity_render_t *)calldata1; const msurface_t *surface = ent->model->data_surfaces + calldata2; vec3_t modelorg; texture_t *texture; diff --git a/gl_rsurf.c b/gl_rsurf.c index cff28d66..bec9823d 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -299,7 +299,7 @@ static void R_DrawPortal_Callback(const void *calldata1, int calldata2) int i; float *v; rmeshstate_t m; - const mportal_t *portal = calldata1; + const mportal_t *portal = (mportal_t *)calldata1; GL_BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL_DepthMask(false); GL_DepthTest(true); diff --git a/gl_textures.c b/gl_textures.c index 51ae4f6e..3d2c5b06 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -255,7 +255,7 @@ rtexturepool_t *R_AllocTexturePool(void) gltexturepool_t *pool; if (texturemempool == NULL) return NULL; - pool = Mem_Alloc(texturemempool, sizeof(gltexturepool_t)); + pool = (gltexturepool_t *)Mem_Alloc(texturemempool, sizeof(gltexturepool_t)); if (pool == NULL) return NULL; pool->next = gltexturepoolchain; @@ -458,8 +458,6 @@ static void R_TextureStats_f(void) R_TextureStats_Print(true, true, true); } -char engineversion[40]; - static void r_textures_start(void) { // deal with size limits of various drivers (3dfx in particular) @@ -575,8 +573,8 @@ void R_MakeResizeBufferBigger(int size) Mem_Free(resizebuffer); if (colorconvertbuffer) Mem_Free(colorconvertbuffer); - resizebuffer = Mem_Alloc(texturemempool, resizebuffersize); - colorconvertbuffer = Mem_Alloc(texturemempool, resizebuffersize); + resizebuffer = (qbyte *)Mem_Alloc(texturemempool, resizebuffersize); + colorconvertbuffer = (qbyte *)Mem_Alloc(texturemempool, resizebuffersize); if (!resizebuffer || !colorconvertbuffer) Host_Error("R_Upload: out of memory\n"); } @@ -926,7 +924,7 @@ static void R_FindImageForTexture(gltexture_t *glt) return; } - image = Mem_Alloc(texturemempool, sizeof(gltextureimage_t)); + image = (gltextureimage_t *)Mem_Alloc(texturemempool, sizeof(gltextureimage_t)); if (image == NULL) { Con_Printf ("R_FindImageForTexture: ran out of memory\n"); @@ -941,7 +939,7 @@ static void R_FindImageForTexture(gltexture_t *glt) image->depth = 1; if (gltexturetypedimensions[glt->texturetype] >= 3) for (image->depth = block_size;image->depth < glt->depth;image->depth <<= 1); - image->blockallocation = Mem_Alloc(texturemempool, image->width * sizeof(short)); + image->blockallocation = (short int *)Mem_Alloc(texturemempool, image->width * sizeof(short)); memset(image->blockallocation, 0, image->width * sizeof(short)); x = 0; @@ -954,7 +952,7 @@ static void R_FindImageForTexture(gltexture_t *glt) { for (imagechainpointer = &pool->imagechain;*imagechainpointer;imagechainpointer = &(*imagechainpointer)->imagechain); - image = Mem_Alloc(texturemempool, sizeof(gltextureimage_t)); + image = (gltextureimage_t *)Mem_Alloc(texturemempool, sizeof(gltextureimage_t)); if (image == NULL) { Con_Printf ("R_FindImageForTexture: ran out of memory\n"); @@ -1094,7 +1092,7 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden Host_Error("R_LoadTexture: unknown texture type\n"); } - glt = Mem_Alloc(texturemempool, sizeof(gltexture_t)); + glt = (gltexture_t *)Mem_Alloc(texturemempool, sizeof(gltexture_t)); if (identifier) strlcpy (glt->identifier, identifier, sizeof(glt->identifier)); glt->pool = pool; @@ -1111,7 +1109,7 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden if (data) { - glt->inputtexels = Mem_Alloc(texturemempool, size); + glt->inputtexels = (qbyte *)Mem_Alloc(texturemempool, size); if (glt->inputtexels == NULL) Con_Printf ("R_LoadTexture: out of memory\n"); else diff --git a/host.c b/host.c index 99a1adcb..97b51e24 100644 --- a/host.c +++ b/host.c @@ -201,7 +201,7 @@ void Host_ServerOptions (void) svs.maxclients = bound(1, svs.maxclients, MAX_SCOREBOARD); - svs.clients = Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients); + svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients); if (svs.maxclients > 1 && !deathmatch.integer) Cvar_SetValueQuick(&deathmatch, 1); diff --git a/host_cmd.c b/host_cmd.c index 303ea034..b98566f6 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -1888,7 +1888,7 @@ static void MaxPlayers_f(void) if (svs.clients) Mem_Free(svs.clients); svs.maxclients = n; - svs.clients = Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients); + svs.clients = (client_t *)Mem_Alloc(sv_mempool, sizeof(client_t) * svs.maxclients); if (n == 1) Cvar_Set ("deathmatch", "0"); else diff --git a/image.c b/image.c index a5eeeff6..e58b98f2 100644 --- a/image.c +++ b/image.c @@ -116,7 +116,7 @@ void Image_GammaRemapRGB(const qbyte *in, qbyte *out, int pixels, const qbyte *g // note: pal must be 32bit color void Image_Copy8bitRGBA(const qbyte *in, qbyte *out, int pixels, const unsigned int *pal) { - int *iout = (void *)out; + int *iout = (int *)out; while (pixels >= 8) { iout[0] = pal[in[0]]; @@ -220,7 +220,7 @@ qbyte* LoadPCX (const qbyte *f, int matchwidth, int matchheight) palette = f + fs_filesize - 768; - image_rgba = Mem_Alloc(tempmempool, image_width*image_height*4); + image_rgba = (qbyte *)Mem_Alloc(tempmempool, image_width*image_height*4); if (!image_rgba) { Con_Printf("LoadPCX: not enough memory for %i by %i image\n", image_width, image_height); @@ -433,7 +433,7 @@ qbyte *LoadTGA (const qbyte *f, int matchwidth, int matchheight) return NULL; } - image_rgba = Mem_Alloc(tempmempool, image_width * image_height * 4); + image_rgba = (qbyte *)Mem_Alloc(tempmempool, image_width * image_height * 4); if (!image_rgba) { Con_Printf("LoadTGA: not enough memory for %i by %i image\n", image_width, image_height); @@ -565,12 +565,12 @@ qbyte *LoadLMP (const qbyte *f, int matchwidth, int matchheight, qboolean loadAs if (loadAs8Bit) { - image_buffer = Mem_Alloc(tempmempool, image_width * image_height); + image_buffer = (qbyte *)Mem_Alloc(tempmempool, image_width * image_height); memcpy(image_buffer, f + 8, image_width * image_height); } else { - image_buffer = Mem_Alloc(tempmempool, image_width * image_height * 4); + image_buffer = (qbyte *)Mem_Alloc(tempmempool, image_width * image_height * 4); Image_Copy8bitRGBA(f + 8, image_buffer, image_width * image_height, palette_complete); } return image_buffer; @@ -596,7 +596,7 @@ typedef struct qbyte *LoadWAL (const qbyte *f, int matchwidth, int matchheight) { qbyte *image_rgba; - const q2wal_t *inwal = (const void *)f; + const q2wal_t *inwal = (const q2wal_t *)f; if (fs_filesize < (int) sizeof(q2wal_t)) { @@ -620,7 +620,7 @@ qbyte *LoadWAL (const qbyte *f, int matchwidth, int matchheight) return NULL; } - image_rgba = Mem_Alloc(tempmempool, image_width * image_height * 4); + image_rgba = (qbyte *)Mem_Alloc(tempmempool, image_width * image_height * 4); if (!image_rgba) { Con_Printf("LoadLMP: not enough memory for %i by %i image\n", image_width, image_height); @@ -800,7 +800,7 @@ rtexture_t *loadtextureimagewithmaskandnmap (rtexturepool_t *pool, const char *f if (!(data = loadimagepixels (filename, complain, matchwidth, matchheight))) return 0; - data2 = Mem_Alloc(tempmempool, image_width * image_height * 4); + data2 = (qbyte *)Mem_Alloc(tempmempool, image_width * image_height * 4); rt = R_LoadTexture2D(pool, filename, image_width, image_height, data, TEXTYPE_RGBA, flags, NULL); @@ -822,7 +822,7 @@ rtexture_t *loadtextureimagebumpasnmap (rtexturepool_t *pool, const char *filena rtexture_t *rt; if (!(data = loadimagepixels (filename, complain, matchwidth, matchheight))) return 0; - data2 = Mem_Alloc(tempmempool, image_width * image_height * 4); + data2 = (qbyte *)Mem_Alloc(tempmempool, image_width * image_height * 4); Image_HeightmapToNormalmap(data, data2, image_width, image_height, (flags & TEXF_CLAMP) != 0, bumpscale); rt = R_LoadTexture2D(pool, filename, image_width, image_height, data2, TEXTYPE_RGBA, flags, NULL); @@ -867,7 +867,7 @@ void Image_WriteTGARGB (const char *filename, int width, int height, const qbyte qbyte *buffer, *out; const qbyte *in, *end; - buffer = Mem_Alloc(tempmempool, width*height*3 + 18); + buffer = (qbyte *)Mem_Alloc(tempmempool, width*height*3 + 18); memset (buffer, 0, 18); buffer[2] = 2; // uncompressed type @@ -901,7 +901,7 @@ void Image_WriteTGARGBA (const char *filename, int width, int height, const qbyt qbyte *buffer, *out; const qbyte *in, *end; - buffer = Mem_Alloc(tempmempool, width*height*4 + 18); + buffer = (qbyte *)Mem_Alloc(tempmempool, width*height*4 + 18); memset (buffer, 0, 18); buffer[2] = 2; // uncompressed type @@ -1019,13 +1019,13 @@ void Image_Resample32Lerp(const void *indata, int inwidth, int inheight, void *o const qbyte *inrow; qbyte *resamplerow1; qbyte *resamplerow2; - out = outdata; + out = (qbyte *)outdata; fstep = (int) (inheight*65536.0f/outheight); - resamplerow1 = Mem_Alloc(tempmempool, outwidth*4*2); + resamplerow1 = (qbyte *)Mem_Alloc(tempmempool, outwidth*4*2); resamplerow2 = resamplerow1 + outwidth*4; - inrow = indata; + inrow = (const qbyte *)indata; oldy = 0; Image_Resample32LerpLine (inrow, resamplerow1, inwidth, outwidth); Image_Resample32LerpLine (inrow + inwidth4, resamplerow2, inwidth, outwidth); @@ -1122,7 +1122,7 @@ void Image_Resample32Nolerp(const void *indata, int inwidth, int inheight, void unsigned frac, fracstep; // relies on int being 4 bytes int *inrow, *out; - out = outdata; + out = (int *)outdata; fracstep = inwidth*0x10000/outwidth; for (i = 0;i < outheight;i++) @@ -1160,13 +1160,13 @@ void Image_Resample24Lerp(const void *indata, int inwidth, int inheight, void *o const qbyte *inrow; qbyte *resamplerow1; qbyte *resamplerow2; - out = outdata; + out = (qbyte *)outdata; fstep = (int) (inheight*65536.0f/outheight); - resamplerow1 = Mem_Alloc(tempmempool, outwidth*3*2); + resamplerow1 = (qbyte *)Mem_Alloc(tempmempool, outwidth*3*2); resamplerow2 = resamplerow1 + outwidth*3; - inrow = indata; + inrow = (const qbyte *)indata; oldy = 0; Image_Resample24LerpLine (inrow, resamplerow1, inwidth, outwidth); Image_Resample24LerpLine (inrow + inwidth3, resamplerow2, inwidth, outwidth); @@ -1254,7 +1254,7 @@ void Image_Resample24Nolerp(const void *indata, int inwidth, int inheight, void int i, j, f, inwidth3 = inwidth * 3; unsigned frac, fracstep; qbyte *inrow, *out; - out = outdata; + out = (qbyte *)outdata; fracstep = inwidth*0x10000/outwidth; for (i = 0;i < outheight;i++) @@ -1529,7 +1529,7 @@ int image_loadskin(imageskin_t *s, char *shadername) bumppixels = NULL;bumppixels_width = 0;bumppixels_height = 0; if (Image_CheckAlpha(s->basepixels, s->basepixels_width * s->basepixels_height, true)) { - s->maskpixels = Mem_Alloc(loadmodel->mempool, s->basepixels_width * s->basepixels_height * 4); + s->maskpixels = (qbyte *)Mem_Alloc(loadmodel->mempool, s->basepixels_width * s->basepixels_height * 4); s->maskpixels_width = s->basepixels_width; s->maskpixels_height = s->basepixels_height; memcpy(s->maskpixels, s->basepixels, s->maskpixels_width * s->maskpixels_height * 4); @@ -1583,7 +1583,7 @@ int image_loadskin(imageskin_t *s, char *shadername) { if (r_shadow_bumpscale_bumpmap.value > 0) { - s->nmappixels = Mem_Alloc(loadmodel->mempool, bumppixels_width * bumppixels_height * 4); + s->nmappixels = (qbyte *)Mem_Alloc(loadmodel->mempool, bumppixels_width * bumppixels_height * 4); s->nmappixels_width = bumppixels_width; s->nmappixels_height = bumppixels_height; Image_HeightmapToNormalmap(bumppixels, s->nmappixels, s->nmappixels_width, s->nmappixels_height, false, r_shadow_bumpscale_bumpmap.value); @@ -1593,7 +1593,7 @@ int image_loadskin(imageskin_t *s, char *shadername) { if (r_shadow_bumpscale_basetexture.value > 0) { - s->nmappixels = Mem_Alloc(loadmodel->mempool, s->basepixels_width * s->basepixels_height * 4); + s->nmappixels = (qbyte *)Mem_Alloc(loadmodel->mempool, s->basepixels_width * s->basepixels_height * 4); s->nmappixels_width = s->basepixels_width; s->nmappixels_height = s->basepixels_height; Image_HeightmapToNormalmap(s->basepixels, s->nmappixels, s->nmappixels_width, s->nmappixels_height, false, r_shadow_bumpscale_basetexture.value); diff --git a/image.h b/image.h index 71168916..b9464c46 100644 --- a/image.h +++ b/image.h @@ -21,6 +21,8 @@ void Image_Copy8bitRGBA(const qbyte *in, qbyte *out, int pixels, const unsigned // makes a RGBA mask from RGBA input, in can be the same as out int image_makemask (const qbyte *in, qbyte *out, int size); +qbyte *LoadTGA (const qbyte *f, int matchwidth, int matchheight); + // loads a texture, as pixel data qbyte *loadimagepixels (const char *filename, qboolean complain, int matchwidth, int matchheight); @@ -34,8 +36,8 @@ qbyte *loadimagepixelsmask (const char *filename, qboolean complain, int matchwi rtexture_t *loadtextureimagemask (rtexturepool_t *pool, const char *filename, int matchwidth, int matchheight, qboolean complain, int flags); // loads a texture and it's alpha mask at once (NULL if it has no translucent pixels) -rtexture_t *image_masktex; -rtexture_t *image_nmaptex; +extern rtexture_t *image_masktex; +extern rtexture_t *image_nmaptex; rtexture_t *loadtextureimagewithmask (rtexturepool_t *pool, const char *filename, int matchwidth, int matchheight, qboolean complain, int flags); rtexture_t *loadtextureimagewithmaskandnmap (rtexturepool_t *pool, const char *filename, int matchwidth, int matchheight, qboolean complain, int flags, float bumpscale); rtexture_t *loadtextureimagebumpasnmap (rtexturepool_t *pool, const char *filename, int matchwidth, int matchheight, qboolean complain, int flags, float bumpscale); diff --git a/jpeg.c b/jpeg.c index b0a8da90..4934b758 100644 --- a/jpeg.c +++ b/jpeg.c @@ -472,7 +472,7 @@ static void JPEG_SkipInputData (j_decompress_ptr cinfo, long num_bytes) static void JPEG_MemSrc (j_decompress_ptr cinfo, const qbyte *buffer) { - cinfo->src = cinfo->mem->alloc_small ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof (struct jpeg_source_mgr)); + cinfo->src = (struct jpeg_source_mgr *)cinfo->mem->alloc_small ((j_common_ptr) cinfo, JPOOL_PERMANENT, sizeof (struct jpeg_source_mgr)); cinfo->src->next_input_byte = buffer; cinfo->src->bytes_in_buffer = fs_filesize; @@ -530,8 +530,8 @@ qbyte* JPEG_LoadImage (const qbyte *f, int matchwidth, int matchheight) return NULL; } - image_rgba = Mem_Alloc(tempmempool, image_width * image_height * 4); - scanline = Mem_Alloc(tempmempool, image_width * cinfo.output_components); + image_rgba = (qbyte *)Mem_Alloc(tempmempool, image_width * image_height * 4); + scanline = (qbyte *)Mem_Alloc(tempmempool, image_width * cinfo.output_components); if (!image_rgba || !scanline) { if (!image_rgba) diff --git a/keys.c b/keys.c index 2b0017a0..b17c3f66 100644 --- a/keys.c +++ b/keys.c @@ -553,7 +553,7 @@ Key_KeynumToString (int keynum) void Key_SetBinding (int keynum, int bindmap, const char *binding) { - char *new; + char *newbinding; size_t l; if (keynum == -1) @@ -566,10 +566,10 @@ Key_SetBinding (int keynum, int bindmap, const char *binding) } // allocate memory for new binding l = strlen (binding); - new = Z_Malloc (l + 1); - strcpy (new, binding); - new[l] = 0; - keybindings[bindmap][keynum] = new; + newbinding = (char *)Z_Malloc (l + 1); + strcpy (newbinding, binding); + newbinding[l] = 0; + keybindings[bindmap][keynum] = newbinding; } static void diff --git a/lhnet.c b/lhnet.c index b80f0986..89b47df4 100644 --- a/lhnet.c +++ b/lhnet.c @@ -447,7 +447,7 @@ lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address) lhnetsocket_t *lhnetsocket, *s; if (!address) return NULL; - lhnetsocket = Z_Malloc(sizeof(*lhnetsocket)); + lhnetsocket = (lhnetsocket_t *)Z_Malloc(sizeof(*lhnetsocket)); if (lhnetsocket) { memset(lhnetsocket, 0, sizeof(*lhnetsocket)); @@ -508,10 +508,10 @@ lhnetsocket_t *LHNET_OpenSocket_Connectionless(lhnetaddress_t *address) socklen_t namelen; #endif namelen = address->addresstype == LHNETADDRESSTYPE_INET6 ? sizeof(lhnetsocket->address.addressdata.inet6) : sizeof(lhnetsocket->address.addressdata.inet4); - if (bind(lhnetsocket->inetsocket, (void *)&lhnetsocket->address.addressdata, namelen) != -1) + if (bind(lhnetsocket->inetsocket, (struct sockaddr *)&lhnetsocket->address.addressdata, namelen) != -1) { int i = 1; - getsockname(lhnetsocket->inetsocket, (void *)&lhnetsocket->address.addressdata, &namelen); + getsockname(lhnetsocket->inetsocket, (struct sockaddr *)&lhnetsocket->address.addressdata, &namelen); // enable broadcast on this socket setsockopt(lhnetsocket->inetsocket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i)); lhnetsocket->next = &lhnet_socketlist; @@ -715,7 +715,7 @@ int LHNET_Write(lhnetsocket_t *lhnetsocket, const void *content, int contentleng if (lhnetsocket->address.addresstype == LHNETADDRESSTYPE_LOOP) { lhnetpacket_t *p; - p = Z_Malloc(sizeof(*p) + contentlength); + p = (lhnetpacket_t *)Z_Malloc(sizeof(*p) + contentlength); p->data = (void *)(p + 1); memcpy(p->data, content, contentlength); p->length = contentlength; diff --git a/menu.c b/menu.c index 097e58f1..a49f2eb7 100644 --- a/menu.c +++ b/menu.c @@ -196,7 +196,7 @@ void M_PrintRed (float cx, float cy, const char *str) DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 0, 0, 1, 0); } -void M_ItemPrint(float cx, float cy, char *str, int unghosted) +void M_ItemPrint(float cx, float cy, const char *str, int unghosted) { if (unghosted) DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 1, 1, 1, 1, 0); @@ -204,7 +204,7 @@ void M_ItemPrint(float cx, float cy, char *str, int unghosted) DrawQ_String(menu_x + cx, menu_y + cy, str, 0, 8, 8, 0.4, 0.4, 0.4, 1, 0); } -void M_DrawPic (float cx, float cy, char *picname) +void M_DrawPic (float cx, float cy, const char *picname) { DrawQ_Pic (menu_x + cx, menu_y + cy, picname, 0, 0, 1, 1, 1, 1, 0); } @@ -1330,8 +1330,8 @@ void M_Setup_Draw (void) menuplyr_width = image_width; menuplyr_height = image_height; Mem_Free(f); - menuplyr_pixels = Mem_Alloc(cl_mempool, menuplyr_width * menuplyr_height); - menuplyr_translated = Mem_Alloc(cl_mempool, menuplyr_width * menuplyr_height * 4); + menuplyr_pixels = (qbyte *)Mem_Alloc(cl_mempool, menuplyr_width * menuplyr_height); + menuplyr_translated = (unsigned int *)Mem_Alloc(cl_mempool, menuplyr_width * menuplyr_height * 4); memcpy(menuplyr_pixels, data, menuplyr_width * menuplyr_height); Mem_Free(data); } @@ -1603,7 +1603,7 @@ int optnum; int opty; int optcursor; -void M_Options_PrintCommand(char *s, int enabled) +void M_Options_PrintCommand(const char *s, int enabled) { if (opty >= 32) { @@ -1614,7 +1614,7 @@ void M_Options_PrintCommand(char *s, int enabled) optnum++; } -void M_Options_PrintCheckbox(char *s, int enabled, int yes) +void M_Options_PrintCheckbox(const char *s, int enabled, int yes) { if (opty >= 32) { @@ -1626,7 +1626,7 @@ void M_Options_PrintCheckbox(char *s, int enabled, int yes) optnum++; } -void M_Options_PrintSlider(char *s, int enabled, float value, float minvalue, float maxvalue) +void M_Options_PrintSlider(const char *s, int enabled, float value, float minvalue, float maxvalue) { if (opty >= 32) { @@ -3055,7 +3055,7 @@ void M_Quit_Key (int key, char ascii) case 'N': if (wasInMenus) { - m_state = m_quit_prevstate; + m_state = (enum m_state_e)m_quit_prevstate; m_entersound = true; } else @@ -3696,7 +3696,7 @@ gameinfo_t gamelist[] = {GAME_BATTLEMECH, &battlemechgame, &battlemechgame}, {GAME_OPENQUARTZ, &openquartzgame, &openquartzgame}, {GAME_DEFEATINDETAIL2, &defeatindetail2game, &defeatindetail2game}, - {-1, &sharewarequakegame, ®isteredquakegame} // final fallback + {(gamemode_t)-1, &sharewarequakegame, ®isteredquakegame} // final fallback }; gamelevels_t *lookupgameinfo(void) @@ -4774,6 +4774,11 @@ void MP_Restart(void) static cvar_t forceqmenu = { 0, "forceqmenu", "0" }; +void (*MR_Keydown) (int key, char ascii); +void (*MR_Draw) (void); +void (*MR_ToggleMenu_f) (void); +void (*MR_Shutdown) (void); + void MR_SetRouting(qboolean forceold) { static qboolean m_init = FALSE, mp_init = FALSE; diff --git a/menu.h b/menu.h index 6f5952c0..73adb738 100644 --- a/menu.h +++ b/menu.h @@ -78,9 +78,9 @@ void MP_Shutdown (void);*/ void MR_Init_Commands (void); void MR_Init (void); void MR_Restart (void); -void (*MR_Keydown) (int key, char ascii); -void (*MR_Draw) (void); -void (*MR_ToggleMenu_f) (void); -void (*MR_Shutdown) (void); +extern void (*MR_Keydown) (int key, char ascii); +extern void (*MR_Draw) (void); +extern void (*MR_ToggleMenu_f) (void); +extern void (*MR_Shutdown) (void); #endif diff --git a/meshqueue.c b/meshqueue.c index f3131544..f2e17ff8 100644 --- a/meshqueue.c +++ b/meshqueue.c @@ -47,7 +47,7 @@ void R_MeshQueue_Render(void) static void R_MeshQueue_EnlargeTransparentArray(int newtotal) { meshqueue_t *newarray; - newarray = Mem_Alloc(cl_mempool, newtotal * sizeof(meshqueue_t)); + newarray = (meshqueue_t *)Mem_Alloc(cl_mempool, newtotal * sizeof(meshqueue_t)); if (mqt_array) { memcpy(newarray, mqt_array, mqt_total * sizeof(meshqueue_t)); @@ -155,11 +155,11 @@ void R_MeshQueue_BeginScene(void) mq_total = r_meshqueue_entries.integer; if (mq_array) Mem_Free(mq_array); - mq_array = Mem_Alloc(cl_mempool, mq_total * sizeof(meshqueue_t)); + mq_array = (meshqueue_t *)Mem_Alloc(cl_mempool, mq_total * sizeof(meshqueue_t)); } if (mqt_array == NULL) - mqt_array = Mem_Alloc(cl_mempool, mqt_total * sizeof(meshqueue_t)); + mqt_array = (meshqueue_t *)Mem_Alloc(cl_mempool, mqt_total * sizeof(meshqueue_t)); mq_count = 0; mqt_count = 0; diff --git a/model_alias.c b/model_alias.c index e0f3efac..f14739e0 100644 --- a/model_alias.c +++ b/model_alias.c @@ -190,7 +190,7 @@ int Mod_Alias_GetTagIndexForName(const model_t *model, unsigned int skin, const static void Mod_Alias_Mesh_CompileFrameZero(surfmesh_t *mesh) { frameblend_t frameblend[4] = {{0, 1}, {0, 0}, {0, 0}, {0, 0}}; - mesh->data_vertex3f = Mem_Alloc(loadmodel->mempool, mesh->num_vertices * sizeof(float[3][4])); + mesh->data_vertex3f = (float *)Mem_Alloc(loadmodel->mempool, mesh->num_vertices * sizeof(float[3][4])); mesh->data_svector3f = mesh->data_vertex3f + mesh->num_vertices * 3; mesh->data_tvector3f = mesh->data_vertex3f + mesh->num_vertices * 6; mesh->data_normal3f = mesh->data_vertex3f + mesh->num_vertices * 9; @@ -457,7 +457,7 @@ void Mod_IDP0_Load(model_t *mod, void *buffer, void *bufferend) int *vertonseam, *vertremap; skinfile_t *skinfiles; - datapointer = buffer; + datapointer = (qbyte *)buffer; pinmodel = (mdl_t *)datapointer; datapointer += sizeof(mdl_t); @@ -477,14 +477,14 @@ void Mod_IDP0_Load(model_t *mod, void *buffer, void *bufferend) loadmodel->num_surfaces = 1; loadmodel->nummodelsurfaces = loadmodel->num_surfaces; loadmodel->nummeshes = loadmodel->num_surfaces; - data = Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(msurface_t) + loadmodel->num_surfaces * sizeof(int) + loadmodel->nummeshes * sizeof(surfmesh_t *) + loadmodel->nummeshes * sizeof(surfmesh_t)); - loadmodel->data_surfaces = (void *)data;data += loadmodel->num_surfaces * sizeof(msurface_t); - loadmodel->surfacelist = (void *)data;data += loadmodel->num_surfaces * sizeof(int); - loadmodel->meshlist = (void *)data;data += loadmodel->num_surfaces * sizeof(surfmesh_t *); + data = (qbyte *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(msurface_t) + loadmodel->num_surfaces * sizeof(int) + loadmodel->nummeshes * sizeof(surfmesh_t *) + loadmodel->nummeshes * sizeof(surfmesh_t)); + loadmodel->data_surfaces = (msurface_t *)data;data += loadmodel->num_surfaces * sizeof(msurface_t); + loadmodel->surfacelist = (int *)data;data += loadmodel->num_surfaces * sizeof(int); + loadmodel->meshlist = (surfmesh_t **)data;data += loadmodel->num_surfaces * sizeof(surfmesh_t *); for (i = 0;i < loadmodel->num_surfaces;i++) { loadmodel->surfacelist[i] = i; - loadmodel->meshlist[i] = (void *)data;data += sizeof(surfmesh_t); + loadmodel->meshlist[i] = (surfmesh_t *)data;data += sizeof(surfmesh_t); } loadmodel->numskins = LittleLong(pinmodel->numskins); @@ -564,8 +564,8 @@ void Mod_IDP0_Load(model_t *mod, void *buffer, void *bufferend) // store texture coordinates into temporary array, they will be stored // after usage is determined (triangle data) - vertst = Mem_Alloc(tempmempool, numverts * 2 * sizeof(float[2])); - vertremap = Mem_Alloc(tempmempool, numverts * 3 * sizeof(int)); + vertst = (float *)Mem_Alloc(tempmempool, numverts * 2 * sizeof(float[2])); + vertremap = (int *)Mem_Alloc(tempmempool, numverts * 3 * sizeof(int)); vertonseam = vertremap + numverts * 2; scales = 1.0 / skinwidth; @@ -580,7 +580,7 @@ void Mod_IDP0_Load(model_t *mod, void *buffer, void *bufferend) } // load triangle data - loadmodel->meshlist[0]->data_element3i = Mem_Alloc(loadmodel->mempool, sizeof(int[3]) * loadmodel->meshlist[0]->num_triangles); + loadmodel->meshlist[0]->data_element3i = (int *)Mem_Alloc(loadmodel->mempool, sizeof(int[3]) * loadmodel->meshlist[0]->num_triangles); // read the triangle elements for (i = 0;i < loadmodel->meshlist[0]->num_triangles;i++) @@ -619,7 +619,7 @@ void Mod_IDP0_Load(model_t *mod, void *buffer, void *bufferend) for (i = 0;i < loadmodel->meshlist[0]->num_triangles * 3;i++) loadmodel->meshlist[0]->data_element3i[i] = vertremap[loadmodel->meshlist[0]->data_element3i[i]]; // store the texture coordinates - loadmodel->meshlist[0]->data_texcoordtexture2f = Mem_Alloc(loadmodel->mempool, sizeof(float[2]) * loadmodel->meshlist[0]->num_vertices); + loadmodel->meshlist[0]->data_texcoordtexture2f = (float *)Mem_Alloc(loadmodel->mempool, sizeof(float[2]) * loadmodel->meshlist[0]->num_vertices); for (i = 0;i < loadmodel->meshlist[0]->num_vertices;i++) { loadmodel->meshlist[0]->data_texcoordtexture2f[i*2+0] = vertst[i*2+0]; @@ -627,9 +627,9 @@ void Mod_IDP0_Load(model_t *mod, void *buffer, void *bufferend) } // load the frames - loadmodel->animscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes); - loadmodel->meshlist[0]->data_morphvertex3f = Mem_Alloc(loadmodel->mempool, sizeof(float[3]) * loadmodel->meshlist[0]->num_morphframes * loadmodel->meshlist[0]->num_vertices); - loadmodel->meshlist[0]->data_neighbor3i = Mem_Alloc(loadmodel->mempool, loadmodel->meshlist[0]->num_triangles * sizeof(int[3])); + loadmodel->animscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes); + loadmodel->meshlist[0]->data_morphvertex3f = (float *)Mem_Alloc(loadmodel->mempool, sizeof(float[3]) * loadmodel->meshlist[0]->num_morphframes * loadmodel->meshlist[0]->num_vertices); + loadmodel->meshlist[0]->data_neighbor3i = (int *)Mem_Alloc(loadmodel->mempool, loadmodel->meshlist[0]->num_triangles * sizeof(int[3])); Mod_MDL_LoadFrames (startframes, numverts, scale, translate, vertremap); Mod_BuildTriangleNeighbors(loadmodel->meshlist[0]->data_neighbor3i, loadmodel->meshlist[0]->data_element3i, loadmodel->meshlist[0]->num_triangles); Mod_CalcAliasModelBBoxes(); @@ -640,9 +640,9 @@ void Mod_IDP0_Load(model_t *mod, void *buffer, void *bufferend) // load the skins skinfiles = Mod_LoadSkinFiles(); - loadmodel->skinscenes = Mem_Alloc(loadmodel->mempool, loadmodel->numskins * sizeof(animscene_t)); + loadmodel->skinscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, loadmodel->numskins * sizeof(animscene_t)); loadmodel->num_textures = loadmodel->num_surfaces; - loadmodel->data_textures = Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * totalskins * sizeof(texture_t)); + loadmodel->data_textures = (texture_t *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * totalskins * sizeof(texture_t)); if (skinfiles) { Mod_BuildAliasSkinsFromSkinFiles(loadmodel->data_textures, skinfiles, "default", ""); @@ -712,12 +712,12 @@ void Mod_IDP0_Load(model_t *mod, void *buffer, void *bufferend) { // expand the arrays to make room tempskinscenes = loadmodel->skinscenes; - loadmodel->skinscenes = Mem_Alloc(loadmodel->mempool, (loadmodel->numskins + 1) * sizeof(animscene_t)); + loadmodel->skinscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, (loadmodel->numskins + 1) * sizeof(animscene_t)); memcpy(loadmodel->skinscenes, tempskinscenes, loadmodel->numskins * sizeof(animscene_t)); Mem_Free(tempskinscenes); tempaliasskins = loadmodel->data_textures; - loadmodel->data_textures = Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * (totalskins + 1) * sizeof(texture_t)); + loadmodel->data_textures = (texture_t *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * (totalskins + 1) * sizeof(texture_t)); memcpy(loadmodel->data_textures, tempaliasskins, loadmodel->num_surfaces * totalskins * sizeof(texture_t)); Mem_Free(tempaliasskins); @@ -779,8 +779,8 @@ void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend) skinframe_t tempskinframe; skinfile_t *skinfiles; - pinmodel = buffer; - base = buffer; + pinmodel = (md2_t *)buffer; + base = (qbyte *)buffer; version = LittleLong (pinmodel->version); if (version != MD2ALIAS_VERSION) @@ -819,14 +819,14 @@ void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend) loadmodel->num_surfaces = 1; loadmodel->nummodelsurfaces = loadmodel->num_surfaces; loadmodel->nummeshes = loadmodel->num_surfaces; - data = Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(msurface_t) + loadmodel->num_surfaces * sizeof(int) + loadmodel->nummeshes * sizeof(surfmesh_t *) + loadmodel->nummeshes * sizeof(surfmesh_t)); - loadmodel->data_surfaces = (void *)data;data += loadmodel->num_surfaces * sizeof(msurface_t); - loadmodel->surfacelist = (void *)data;data += loadmodel->num_surfaces * sizeof(int); - loadmodel->meshlist = (void *)data;data += loadmodel->num_surfaces * sizeof(surfmesh_t *); + data = (qbyte *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(msurface_t) + loadmodel->num_surfaces * sizeof(int) + loadmodel->nummeshes * sizeof(surfmesh_t *) + loadmodel->nummeshes * sizeof(surfmesh_t)); + loadmodel->data_surfaces = (msurface_t *)data;data += loadmodel->num_surfaces * sizeof(msurface_t); + loadmodel->surfacelist = (int *)data;data += loadmodel->num_surfaces * sizeof(int); + loadmodel->meshlist = (surfmesh_t **)data;data += loadmodel->num_surfaces * sizeof(surfmesh_t *); for (i = 0;i < loadmodel->num_surfaces;i++) { loadmodel->surfacelist[i] = i; - loadmodel->meshlist[i] = (void *)data;data += sizeof(surfmesh_t); + loadmodel->meshlist[i] = (surfmesh_t *)data;data += sizeof(surfmesh_t); } loadmodel->numskins = LittleLong(pinmodel->num_skins); @@ -835,18 +835,18 @@ void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend) loadmodel->meshlist[0]->num_triangles = LittleLong(pinmodel->num_tris); loadmodel->numframes = LittleLong(pinmodel->num_frames); loadmodel->meshlist[0]->num_morphframes = loadmodel->numframes; - loadmodel->animscenes = Mem_Alloc(loadmodel->mempool, loadmodel->numframes * sizeof(animscene_t)); + loadmodel->animscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, loadmodel->numframes * sizeof(animscene_t)); loadmodel->flags = 0; // there are no MD2 flags loadmodel->synctype = ST_RAND; // load the skins - inskin = (void*)(base + LittleLong(pinmodel->ofs_skins)); + inskin = (char *)(base + LittleLong(pinmodel->ofs_skins)); skinfiles = Mod_LoadSkinFiles(); if (skinfiles) { loadmodel->num_textures = loadmodel->num_surfaces; - loadmodel->data_textures = Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t)); + loadmodel->data_textures = (texture_t *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t)); Mod_BuildAliasSkinsFromSkinFiles(loadmodel->data_textures, skinfiles, "default", ""); Mod_FreeSkinFiles(skinfiles); } @@ -854,7 +854,7 @@ void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend) { // skins found (most likely not a player model) loadmodel->num_textures = loadmodel->num_surfaces; - loadmodel->data_textures = Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t)); + loadmodel->data_textures = (texture_t *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t)); for (i = 0;i < loadmodel->numskins;i++, inskin += MD2_SKINNAME) { if (Mod_LoadSkinFrame(&tempskinframe, inskin, (r_mipskins.integer ? TEXF_MIPMAP : 0) | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, true, true)) @@ -871,11 +871,11 @@ void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend) // no skins (most likely a player model) loadmodel->numskins = 1; loadmodel->num_textures = loadmodel->num_surfaces; - loadmodel->data_textures = Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t)); + loadmodel->data_textures = (texture_t *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t)); Mod_BuildAliasSkinFromSkinFrame(loadmodel->data_textures, NULL); } - loadmodel->skinscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numskins); + loadmodel->skinscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numskins); for (i = 0;i < loadmodel->numskins;i++) { loadmodel->skinscenes[i].firstframe = i; @@ -885,12 +885,12 @@ void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend) } // load the triangles and stvert data - inst = (void*)(base + LittleLong(pinmodel->ofs_st)); - intri = (void*)(base + LittleLong(pinmodel->ofs_tris)); + inst = (unsigned short *)(base + LittleLong(pinmodel->ofs_st)); + intri = (md2triangle_t *)(base + LittleLong(pinmodel->ofs_tris)); skinwidth = LittleLong(pinmodel->skinwidth); skinheight = LittleLong(pinmodel->skinheight); - stverts = Mem_Alloc(tempmempool, numst * sizeof(float[2])); + stverts = (float *)Mem_Alloc(tempmempool, numst * sizeof(float[2])); s = 1.0f / skinwidth; t = 1.0f / skinheight; for (i = 0;i < numst;i++) @@ -907,11 +907,11 @@ void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend) stverts[i*2+1] = k * t; } - md2verthash = Mem_Alloc(tempmempool, 256 * sizeof(hash)); - md2verthashdata = Mem_Alloc(tempmempool, loadmodel->meshlist[0]->num_triangles * 3 * sizeof(*hash)); + md2verthash = (struct md2verthash_s **)Mem_Alloc(tempmempool, 256 * sizeof(hash)); + md2verthashdata = (struct md2verthash_s *)Mem_Alloc(tempmempool, loadmodel->meshlist[0]->num_triangles * 3 * sizeof(*hash)); // swap the triangle list num = 0; - loadmodel->meshlist[0]->data_element3i = Mem_Alloc(loadmodel->mempool, loadmodel->meshlist[0]->num_triangles * sizeof(int[3])); + loadmodel->meshlist[0]->data_element3i = (int *)Mem_Alloc(loadmodel->mempool, loadmodel->meshlist[0]->num_triangles * sizeof(int[3])); for (i = 0;i < loadmodel->meshlist[0]->num_triangles;i++) { for (j = 0;j < 3;j++) @@ -951,8 +951,8 @@ void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend) numverts = num; loadmodel->meshlist[0]->num_vertices = numverts; - vertremap = Mem_Alloc(loadmodel->mempool, num * sizeof(int)); - loadmodel->meshlist[0]->data_texcoordtexture2f = Mem_Alloc(loadmodel->mempool, num * sizeof(float[2])); + vertremap = (int *)Mem_Alloc(loadmodel->mempool, num * sizeof(int)); + loadmodel->meshlist[0]->data_texcoordtexture2f = (float *)Mem_Alloc(loadmodel->mempool, num * sizeof(float[2])); for (i = 0;i < num;i++) { hash = md2verthashdata + i; @@ -966,7 +966,7 @@ void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend) // load the frames datapointer = (base + LittleLong(pinmodel->ofs_frames)); - loadmodel->meshlist[0]->data_morphvertex3f = Mem_Alloc(loadmodel->mempool, numverts * loadmodel->meshlist[0]->num_morphframes * sizeof(float[3])); + loadmodel->meshlist[0]->data_morphvertex3f = (float *)Mem_Alloc(loadmodel->mempool, numverts * loadmodel->meshlist[0]->num_morphframes * sizeof(float[3])); for (i = 0;i < loadmodel->meshlist[0]->num_morphframes;i++) { pinframe = (md2frame_t *)datapointer; @@ -976,7 +976,7 @@ void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend) scale[j] = LittleFloat(pinframe->scale[j]); translate[j] = LittleFloat(pinframe->translate[j]); } - Mod_MD2_ConvertVerts(scale, translate, (void *)datapointer, loadmodel->meshlist[0]->data_morphvertex3f + i * numverts * 3, numverts, vertremap); + Mod_MD2_ConvertVerts(scale, translate, (trivertx_t *)datapointer, loadmodel->meshlist[0]->data_morphvertex3f + i * numverts * 3, numverts, vertremap); datapointer += numxyz * sizeof(trivertx_t); strcpy(loadmodel->animscenes[i].name, pinframe->name); @@ -988,7 +988,7 @@ void Mod_IDP2_Load(model_t *mod, void *buffer, void *bufferend) Mem_Free(vertremap); - loadmodel->meshlist[0]->data_neighbor3i = Mem_Alloc(loadmodel->mempool, loadmodel->meshlist[0]->num_triangles * sizeof(int[3])); + loadmodel->meshlist[0]->data_neighbor3i = (int *)Mem_Alloc(loadmodel->mempool, loadmodel->meshlist[0]->num_triangles * sizeof(int[3])); Mod_BuildTriangleNeighbors(loadmodel->meshlist[0]->data_neighbor3i, loadmodel->meshlist[0]->data_element3i, loadmodel->meshlist[0]->num_triangles); Mod_CalcAliasModelBBoxes(); Mod_Alias_Mesh_CompileFrameZero(loadmodel->meshlist[0]); @@ -1014,7 +1014,7 @@ void Mod_IDP3_Load(model_t *mod, void *buffer, void *bufferend) md3tag_t *pintag; skinfile_t *skinfiles; - pinmodel = buffer; + pinmodel = (md3modelheader_t *)buffer; if (memcmp(pinmodel->identifier, "IDP3", 4)) Host_Error ("%s is not a MD3 (IDP3) file\n", loadmodel->name); @@ -1042,7 +1042,7 @@ void Mod_IDP3_Load(model_t *mod, void *buffer, void *bufferend) loadmodel->num_surfaces = LittleLong(pinmodel->num_meshes); // make skinscenes for the skins (no groups) - loadmodel->skinscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numskins); + loadmodel->skinscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numskins); for (i = 0;i < loadmodel->numskins;i++) { loadmodel->skinscenes[i].firstframe = i; @@ -1052,7 +1052,7 @@ void Mod_IDP3_Load(model_t *mod, void *buffer, void *bufferend) } // load frameinfo - loadmodel->animscenes = Mem_Alloc(loadmodel->mempool, loadmodel->numframes * sizeof(animscene_t)); + loadmodel->animscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, loadmodel->numframes * sizeof(animscene_t)); for (i = 0, pinframe = (md3frameinfo_t *)((qbyte *)pinmodel + LittleLong(pinmodel->lump_frameinfo));i < loadmodel->numframes;i++, pinframe++) { strcpy(loadmodel->animscenes[i].name, pinframe->name); @@ -1065,7 +1065,7 @@ void Mod_IDP3_Load(model_t *mod, void *buffer, void *bufferend) // load tags loadmodel->num_tagframes = loadmodel->numframes; loadmodel->num_tags = LittleLong(pinmodel->num_tags); - loadmodel->data_tags = Mem_Alloc(loadmodel->mempool, loadmodel->num_tagframes * loadmodel->num_tags * sizeof(aliastag_t)); + loadmodel->data_tags = (aliastag_t *)Mem_Alloc(loadmodel->mempool, loadmodel->num_tagframes * loadmodel->num_tags * sizeof(aliastag_t)); for (i = 0, pintag = (md3tag_t *)((qbyte *)pinmodel + LittleLong(pinmodel->lump_tags));i < loadmodel->num_tagframes * loadmodel->num_tags;i++, pintag++) { strcpy(loadmodel->data_tags[i].name, pintag->name); @@ -1083,15 +1083,15 @@ void Mod_IDP3_Load(model_t *mod, void *buffer, void *bufferend) loadmodel->nummodelsurfaces = loadmodel->num_surfaces; loadmodel->nummeshes = loadmodel->num_surfaces; loadmodel->num_textures = loadmodel->num_surfaces; - data = Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(msurface_t) + loadmodel->num_surfaces * sizeof(int) + loadmodel->nummeshes * sizeof(surfmesh_t *) + loadmodel->nummeshes * sizeof(surfmesh_t) + loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t)); - loadmodel->data_surfaces = (void *)data;data += loadmodel->num_surfaces * sizeof(msurface_t); - loadmodel->surfacelist = (void *)data;data += loadmodel->num_surfaces * sizeof(int); - loadmodel->meshlist = (void *)data;data += loadmodel->num_surfaces * sizeof(surfmesh_t *); - loadmodel->data_textures = (void *)data;data += loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t); + data = (qbyte *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(msurface_t) + loadmodel->num_surfaces * sizeof(int) + loadmodel->nummeshes * sizeof(surfmesh_t *) + loadmodel->nummeshes * sizeof(surfmesh_t) + loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t)); + loadmodel->data_surfaces = (msurface_t *)data;data += loadmodel->num_surfaces * sizeof(msurface_t); + loadmodel->surfacelist = (int *)data;data += loadmodel->num_surfaces * sizeof(int); + loadmodel->meshlist = (surfmesh_t **)data;data += loadmodel->num_surfaces * sizeof(surfmesh_t *); + loadmodel->data_textures = (texture_t *)data;data += loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t); for (i = 0;i < loadmodel->num_surfaces;i++) { loadmodel->surfacelist[i] = i; - loadmodel->meshlist[i] = (void *)data;data += sizeof(surfmesh_t); + loadmodel->meshlist[i] = (surfmesh_t *)data;data += sizeof(surfmesh_t); } for (i = 0, pinmesh = (md3mesh_t *)((qbyte *)pinmodel + LittleLong(pinmodel->lump_meshes));i < loadmodel->num_surfaces;i++, pinmesh = (md3mesh_t *)((qbyte *)pinmesh + LittleLong(pinmesh->lump_end))) { @@ -1101,10 +1101,10 @@ void Mod_IDP3_Load(model_t *mod, void *buffer, void *bufferend) mesh->num_morphframes = LittleLong(pinmesh->num_frames); mesh->num_vertices = LittleLong(pinmesh->num_vertices); mesh->num_triangles = LittleLong(pinmesh->num_triangles); - mesh->data_element3i = Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); - mesh->data_neighbor3i = Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); - mesh->data_texcoordtexture2f = Mem_Alloc(loadmodel->mempool, mesh->num_vertices * sizeof(float[2])); - mesh->data_morphvertex3f = Mem_Alloc(loadmodel->mempool, mesh->num_vertices * mesh->num_morphframes * sizeof(float[3])); + mesh->data_element3i = (int *)Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); + mesh->data_neighbor3i = (int *)Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); + mesh->data_texcoordtexture2f = (float *)Mem_Alloc(loadmodel->mempool, mesh->num_vertices * sizeof(float[2])); + mesh->data_morphvertex3f = (float *)Mem_Alloc(loadmodel->mempool, mesh->num_vertices * mesh->num_morphframes * sizeof(float[3])); for (j = 0;j < mesh->num_triangles * 3;j++) mesh->data_element3i[j] = LittleLong(((int *)((qbyte *)pinmesh + LittleLong(pinmesh->lump_elements)))[j]); for (j = 0;j < mesh->num_vertices;j++) @@ -1156,8 +1156,8 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) msurface_t *surface; surfmesh_t *mesh; - pinmodel = (void *)buffer; - pbase = buffer; + pinmodel = (zymtype1header_t *)buffer; + pbase = (qbyte *)buffer; if (memcmp(pinmodel->id, "ZYMOTICMODEL", 12)) Host_Error ("Mod_ZYMOTICMODEL_Load: %s is not a zymotic model\n"); if (BigLong(pinmodel->type) != 1) @@ -1216,7 +1216,7 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) loadmodel->numskins = 1; // make skinscenes for the skins (no groups) - loadmodel->skinscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numskins); + loadmodel->skinscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numskins); for (i = 0;i < loadmodel->numskins;i++) { loadmodel->skinscenes[i].firstframe = i; @@ -1248,8 +1248,8 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) // go through the lumps, swapping things //zymlump_t lump_scenes; // zymscene_t scene[numscenes]; // name and other information for each scene (see zymscene struct) - loadmodel->animscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes); - scene = (void *) (pheader->lump_scenes.start + pbase); + loadmodel->animscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes); + scene = (zymscene_t *) (pheader->lump_scenes.start + pbase); numposes = pheader->lump_poses.length / pheader->numbones / sizeof(float[3][4]); for (i = 0;i < pheader->numscenes;i++) { @@ -1269,15 +1269,15 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) //zymlump_t lump_poses; // float pose[numposes][numbones][3][4]; // animation data loadmodel->num_poses = pheader->lump_poses.length / sizeof(float[3][4]); - loadmodel->data_poses = Mem_Alloc(loadmodel->mempool, pheader->lump_poses.length); - poses = (void *) (pheader->lump_poses.start + pbase); + loadmodel->data_poses = (float *)Mem_Alloc(loadmodel->mempool, pheader->lump_poses.length); + poses = (float *) (pheader->lump_poses.start + pbase); for (i = 0;i < pheader->lump_poses.length / 4;i++) loadmodel->data_poses[i] = BigFloat(poses[i]); //zymlump_t lump_bones; // zymbone_t bone[numbones]; loadmodel->num_bones = pheader->numbones; - loadmodel->data_bones = Mem_Alloc(loadmodel->mempool, pheader->numbones * sizeof(aliasbone_t)); - bone = (void *) (pheader->lump_bones.start + pbase); + loadmodel->data_bones = (aliasbone_t *)Mem_Alloc(loadmodel->mempool, pheader->numbones * sizeof(aliasbone_t)); + bone = (zymbone_t *) (pheader->lump_bones.start + pbase); for (i = 0;i < pheader->numbones;i++) { memcpy(loadmodel->data_bones[i].name, bone[i].name, sizeof(bone[i].name)); @@ -1288,8 +1288,8 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) } //zymlump_t lump_vertbonecounts; // int vertbonecounts[numvertices]; // how many bones influence each vertex (separate mainly to make this compress better) - vertbonecounts = Mem_Alloc(loadmodel->mempool, pheader->numverts * sizeof(int)); - bonecount = (void *) (pheader->lump_vertbonecounts.start + pbase); + vertbonecounts = (int *)Mem_Alloc(loadmodel->mempool, pheader->numverts * sizeof(int)); + bonecount = (int *) (pheader->lump_vertbonecounts.start + pbase); for (i = 0;i < pheader->numverts;i++) { vertbonecounts[i] = BigLong(bonecount[i]); @@ -1298,8 +1298,8 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) } //zymlump_t lump_verts; // zymvertex_t vert[numvertices]; // see vertex struct - verts = Mem_Alloc(loadmodel->mempool, pheader->lump_verts.length); - vertdata = (void *) (pheader->lump_verts.start + pbase); + verts = (zymvertex_t *)Mem_Alloc(loadmodel->mempool, pheader->lump_verts.length); + vertdata = (zymvertex_t *) (pheader->lump_verts.start + pbase); for (i = 0;i < pheader->lump_verts.length / (int) sizeof(zymvertex_t);i++) { verts[i].bonenum = BigLong(vertdata[i].bonenum); @@ -1309,8 +1309,8 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) } //zymlump_t lump_texcoords; // float texcoords[numvertices][2]; - outtexcoord2f = Mem_Alloc(loadmodel->mempool, pheader->numverts * sizeof(float[2])); - intexcoord2f = (void *) (pheader->lump_texcoords.start + pbase); + outtexcoord2f = (float *)Mem_Alloc(loadmodel->mempool, pheader->numverts * sizeof(float[2])); + intexcoord2f = (float *) (pheader->lump_texcoords.start + pbase); for (i = 0;i < pheader->numverts;i++) { outtexcoord2f[i*2+0] = BigFloat(intexcoord2f[i*2+0]); @@ -1325,15 +1325,15 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) loadmodel->nummodelsurfaces = loadmodel->num_surfaces; loadmodel->nummeshes = loadmodel->num_surfaces; loadmodel->num_textures = loadmodel->num_surfaces; - data = Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(msurface_t) + loadmodel->num_surfaces * sizeof(int) + loadmodel->nummeshes * sizeof(surfmesh_t *) + loadmodel->nummeshes * sizeof(surfmesh_t) + loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t)); - loadmodel->data_surfaces = (void *)data;data += loadmodel->num_surfaces * sizeof(msurface_t); - loadmodel->surfacelist = (void *)data;data += loadmodel->num_surfaces * sizeof(int); - loadmodel->meshlist = (void *)data;data += loadmodel->num_surfaces * sizeof(surfmesh_t *); - loadmodel->data_textures = (void *)data;data += loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t); + data = (qbyte *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(msurface_t) + loadmodel->num_surfaces * sizeof(int) + loadmodel->nummeshes * sizeof(surfmesh_t *) + loadmodel->nummeshes * sizeof(surfmesh_t) + loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t)); + loadmodel->data_surfaces = (msurface_t *)data;data += loadmodel->num_surfaces * sizeof(msurface_t); + loadmodel->surfacelist = (int *)data;data += loadmodel->num_surfaces * sizeof(int); + loadmodel->meshlist = (surfmesh_t **)data;data += loadmodel->num_surfaces * sizeof(surfmesh_t *); + loadmodel->data_textures = (texture_t *)data;data += loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t); for (i = 0;i < loadmodel->num_surfaces;i++) { loadmodel->surfacelist[i] = i; - loadmodel->meshlist[i] = (void *)data;data += sizeof(surfmesh_t); + loadmodel->meshlist[i] = (surfmesh_t *)data;data += sizeof(surfmesh_t); } //zymlump_t lump_shaders; // char shadername[numshaders][32]; // shaders used on this model @@ -1342,8 +1342,8 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) count = pheader->numshaders * sizeof(int) + pheader->numtris * sizeof(int[3]); if (pheader->lump_render.length != count) Host_Error("%s renderlist is wrong size (%i bytes, should be %i bytes)\n", loadmodel->name, pheader->lump_render.length, count); - renderlist = (void *) (pheader->lump_render.start + pbase); - renderlistend = (void *) ((qbyte *) renderlist + pheader->lump_render.length); + renderlist = (int *) (pheader->lump_render.start + pbase); + renderlistend = (int *) ((qbyte *) renderlist + pheader->lump_render.length); for (i = 0;i < loadmodel->num_surfaces;i++) { if (renderlist >= renderlistend) @@ -1353,8 +1353,8 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) Host_Error("%s corrupt renderlist (wrong size)\n", loadmodel->name); mesh = loadmodel->meshlist[i]; mesh->num_triangles = count; - mesh->data_element3i = Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); - mesh->data_neighbor3i = Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); + mesh->data_element3i = (int *)Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); + mesh->data_neighbor3i = (int *)Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); outelements = mesh->data_element3i; for (j = 0;j < mesh->num_triangles;j++) { @@ -1370,11 +1370,11 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) renderlist += 3; outelements += 3; } - remapvertices = Mem_Alloc(loadmodel->mempool, pheader->numverts * sizeof(int)); + remapvertices = (int *)Mem_Alloc(loadmodel->mempool, pheader->numverts * sizeof(int)); mesh->num_vertices = Mod_BuildVertexRemapTableFromElements(mesh->num_triangles * 3, mesh->data_element3i, pheader->numverts, remapvertices); for (j = 0;j < mesh->num_triangles * 3;j++) mesh->data_element3i[j] = remapvertices[mesh->data_element3i[j]]; - mesh->data_texcoordtexture2f = Mem_Alloc(loadmodel->mempool, mesh->num_vertices * sizeof(float[2])); + mesh->data_texcoordtexture2f = (float *)Mem_Alloc(loadmodel->mempool, mesh->num_vertices * sizeof(float[2])); for (j = 0;j < pheader->numverts;j++) { if (remapvertices[j] >= 0) @@ -1387,7 +1387,7 @@ void Mod_ZYMOTICMODEL_Load(model_t *mod, void *buffer, void *bufferend) for (j = 0;j < pheader->numverts;j++) if (remapvertices[j] >= 0) mesh->num_vertexboneweights += vertbonecounts[remapvertices[j]]; - mesh->data_vertexboneweights = Mem_Alloc(loadmodel->mempool, mesh->num_vertexboneweights * sizeof(surfmeshvertexboneweight_t)); + mesh->data_vertexboneweights = (surfmeshvertexboneweight_t *)Mem_Alloc(loadmodel->mempool, mesh->num_vertexboneweights * sizeof(surfmeshvertexboneweight_t)); mesh->num_vertexboneweights = 0; // note this vertexboneweight ordering requires that the remapvertices array is sequential numbers (separated by -1 values for omitted vertices) l = 0; @@ -1449,8 +1449,8 @@ void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend) skinfile_t *skinfiles; qbyte *data; - pheader = (void *)buffer; - pbase = buffer; + pheader = (dpmheader_t *)buffer; + pbase = (qbyte *)buffer; if (memcmp(pheader->id, "DARKPLACESMODEL\0", 16)) Host_Error ("Mod_DARKPLACESMODEL_Load: %s is not a darkplaces model\n"); if (BigLong(pheader->type) != 2) @@ -1508,15 +1508,15 @@ void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend) loadmodel->num_textures = loadmodel->nummeshes = loadmodel->nummodelsurfaces = loadmodel->num_surfaces = pheader->num_meshs; // do most allocations as one merged chunk - data = Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(msurface_t) + loadmodel->num_surfaces * sizeof(int) + loadmodel->nummeshes * sizeof(surfmesh_t *) + loadmodel->nummeshes * sizeof(surfmesh_t) + loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t) + loadmodel->numskins * sizeof(animscene_t) + loadmodel->num_bones * sizeof(aliasbone_t) + loadmodel->num_poses * sizeof(float[12]) + loadmodel->numframes * sizeof(animscene_t)); - loadmodel->data_surfaces = (void *)data;data += loadmodel->num_surfaces * sizeof(msurface_t); - loadmodel->surfacelist = (void *)data;data += loadmodel->num_surfaces * sizeof(int); - loadmodel->meshlist = (void *)data;data += loadmodel->num_surfaces * sizeof(surfmesh_t *); - loadmodel->data_textures = (void *)data;data += loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t); - loadmodel->skinscenes = (void *)data;data += loadmodel->numskins * sizeof(animscene_t); - loadmodel->data_bones = (void *)data;data += loadmodel->num_bones * sizeof(aliasbone_t); - loadmodel->data_poses = (void *)data;data += loadmodel->num_poses * sizeof(float[12]); - loadmodel->animscenes = (void *)data;data += loadmodel->numframes * sizeof(animscene_t); + data = (qbyte *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(msurface_t) + loadmodel->num_surfaces * sizeof(int) + loadmodel->nummeshes * sizeof(surfmesh_t *) + loadmodel->nummeshes * sizeof(surfmesh_t) + loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t) + loadmodel->numskins * sizeof(animscene_t) + loadmodel->num_bones * sizeof(aliasbone_t) + loadmodel->num_poses * sizeof(float[12]) + loadmodel->numframes * sizeof(animscene_t)); + loadmodel->data_surfaces = (msurface_t *)data;data += loadmodel->num_surfaces * sizeof(msurface_t); + loadmodel->surfacelist = (int *)data;data += loadmodel->num_surfaces * sizeof(int); + loadmodel->meshlist = (surfmesh_t **)data;data += loadmodel->num_surfaces * sizeof(surfmesh_t *); + loadmodel->data_textures = (texture_t *)data;data += loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t); + loadmodel->skinscenes = (animscene_t *)data;data += loadmodel->numskins * sizeof(animscene_t); + loadmodel->data_bones = (aliasbone_t *)data;data += loadmodel->num_bones * sizeof(aliasbone_t); + loadmodel->data_poses = (float *)data;data += loadmodel->num_poses * sizeof(float[12]); + loadmodel->animscenes = (animscene_t *)data;data += loadmodel->numframes * sizeof(animscene_t); for (i = 0;i < loadmodel->numskins;i++) { loadmodel->skinscenes[i].firstframe = i; @@ -1527,11 +1527,11 @@ void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend) for (i = 0;i < loadmodel->num_surfaces;i++) { loadmodel->surfacelist[i] = i; - loadmodel->meshlist[i] = (void *)data;data += sizeof(surfmesh_t); + loadmodel->meshlist[i] = (surfmesh_t *)data;data += sizeof(surfmesh_t); } // load the bone info - bone = (void *) (pbase + pheader->ofs_bones); + bone = (dpmbone_t *) (pbase + pheader->ofs_bones); for (i = 0;i < loadmodel->num_bones;i++) { memcpy(loadmodel->data_bones[i].name, bone[i].name, sizeof(bone[i].name)); @@ -1542,7 +1542,7 @@ void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend) } // load the frames - frame = (void *) (pbase + pheader->ofs_frames); + frame = (dpmframe_t *) (pbase + pheader->ofs_frames); for (i = 0;i < loadmodel->numframes;i++) { const float *poses; @@ -1552,7 +1552,7 @@ void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend) loadmodel->animscenes[i].loop = true; loadmodel->animscenes[i].framerate = 10; // load the bone poses for this frame - poses = (void *) (pbase + BigLong(frame->ofs_bonepositions)); + poses = (float *) (pbase + BigLong(frame->ofs_bonepositions)); for (j = 0;j < loadmodel->num_bones*12;j++) loadmodel->data_poses[i * loadmodel->num_bones*12 + j] = BigFloat(poses[j]); // stuff not processed here: mins, maxs, yawradius, allradius @@ -1560,7 +1560,7 @@ void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend) } // load the meshes now - dpmmesh = (void *) (pbase + pheader->ofs_meshs); + dpmmesh = (dpmmesh_t *) (pbase + pheader->ofs_meshs); for (i = 0;i < loadmodel->num_surfaces;i++) { const int *inelements; @@ -1575,7 +1575,7 @@ void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend) // to find out how many weights exist we two a two-stage load... mesh->num_vertexboneweights = 0; - data = (void *) (pbase + BigLong(dpmmesh->ofs_verts)); + data = (qbyte *) (pbase + BigLong(dpmmesh->ofs_verts)); for (j = 0;j < mesh->num_vertices;j++) { int numweights = BigLong(((dpmvertex_t *)data)->numbones); @@ -1585,12 +1585,12 @@ void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend) } // allocate things now that we know how many - mesh->data_vertexboneweights = Mem_Alloc(loadmodel->mempool, mesh->num_vertexboneweights * sizeof(surfmeshvertexboneweight_t)); - mesh->data_element3i = Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); - mesh->data_neighbor3i = Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); - mesh->data_texcoordtexture2f = Mem_Alloc(loadmodel->mempool, mesh->num_vertices * sizeof(float[2])); + mesh->data_vertexboneweights = (surfmeshvertexboneweight_t *)Mem_Alloc(loadmodel->mempool, mesh->num_vertexboneweights * sizeof(surfmeshvertexboneweight_t)); + mesh->data_element3i = (int *)Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); + mesh->data_neighbor3i = (int *)Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); + mesh->data_texcoordtexture2f = (float *)Mem_Alloc(loadmodel->mempool, mesh->num_vertices * sizeof(float[2])); - inelements = (void *) (pbase + BigLong(dpmmesh->ofs_indices)); + inelements = (int *) (pbase + BigLong(dpmmesh->ofs_indices)); outelements = mesh->data_element3i; for (j = 0;j < mesh->num_triangles;j++) { @@ -1602,20 +1602,20 @@ void Mod_DARKPLACESMODEL_Load(model_t *mod, void *buffer, void *bufferend) outelements += 3; } - intexcoord = (void *) (pbase + BigLong(dpmmesh->ofs_texcoords)); + intexcoord = (float *) (pbase + BigLong(dpmmesh->ofs_texcoords)); for (j = 0;j < mesh->num_vertices*2;j++) mesh->data_texcoordtexture2f[j] = BigFloat(intexcoord[j]); // now load them for real mesh->num_vertexboneweights = 0; - data = (void *) (pbase + BigLong(dpmmesh->ofs_verts)); + data = (qbyte *) (pbase + BigLong(dpmmesh->ofs_verts)); for (j = 0;j < mesh->num_vertices;j++) { int numweights = BigLong(((dpmvertex_t *)data)->numbones); data += sizeof(dpmvertex_t); for (k = 0;k < numweights;k++) { - const dpmbonevert_t *vert = (void *) data; + const dpmbonevert_t *vert = (dpmbonevert_t *) data; // stuff not processed here: normal mesh->data_vertexboneweights[mesh->num_vertexboneweights].vertexindex = j; mesh->data_vertexboneweights[mesh->num_vertexboneweights].boneindex = BigLong(vert->bonenum); @@ -1681,7 +1681,7 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) skinfile_t *skinfiles; char animname[MAX_QPATH]; - pchunk = (void *)buffer; + pchunk = (pskchunk_t *)buffer; if (strcmp(pchunk->id, "ACTRHEAD")) Host_Error ("Mod_PSKMODEL_Load: %s is not a ActorX model\n"); @@ -1699,7 +1699,7 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) skinfiles = Mod_LoadSkinFiles(); if (loadmodel->numskins < 1) loadmodel->numskins = 1; - loadmodel->skinscenes = Mem_Alloc(loadmodel->mempool, loadmodel->numskins * sizeof(animscene_t)); + loadmodel->skinscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, loadmodel->numskins * sizeof(animscene_t)); for (i = 0;i < loadmodel->numskins;i++) { loadmodel->skinscenes[i].firstframe = i; @@ -1734,7 +1734,7 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) while (buffer < bufferend) { - pchunk = buffer; + pchunk = (pskchunk_t *)buffer; buffer = (void *)((unsigned char *)buffer + sizeof(pskchunk_t)); version = LittleLong(pchunk->version); recordsize = LittleLong(pchunk->recordsize); @@ -1754,8 +1754,8 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) Host_Error("%s: %s has unsupported recordsize\n", loadmodel->name, pchunk->id); // byteswap in place and keep the pointer numpnts = numrecords; - pnts = buffer; - for (index = 0, p = buffer;index < numrecords;index++, p++) + pnts = (pskpnts_t *)buffer; + for (index = 0, p = (pskpnts_t *)buffer;index < numrecords;index++, p++) { p->origin[0] = LittleFloat(p->origin[0]); p->origin[1] = LittleFloat(p->origin[1]); @@ -1770,8 +1770,8 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) Host_Error("%s: %s has unsupported recordsize\n", loadmodel->name, pchunk->id); // byteswap in place and keep the pointer numvtxw = numrecords; - vtxw = buffer; - for (index = 0, p = buffer;index < numrecords;index++, p++) + vtxw = (pskvtxw_t *)buffer; + for (index = 0, p = (pskvtxw_t *)buffer;index < numrecords;index++, p++) { p->pntsindex = LittleShort(p->pntsindex); p->texcoord[0] = LittleFloat(p->texcoord[0]); @@ -1791,8 +1791,8 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) Host_Error("%s: %s has unsupported recordsize\n", loadmodel->name, pchunk->id); // byteswap in place and keep the pointer numfaces = numrecords; - faces = buffer; - for (index = 0, p = buffer;index < numrecords;index++, p++) + faces = (pskface_t *)buffer; + for (index = 0, p = (pskface_t *)buffer;index < numrecords;index++, p++) { p->vtxwindex[0] = LittleShort(p->vtxwindex[0]); p->vtxwindex[1] = LittleShort(p->vtxwindex[1]); @@ -1823,8 +1823,8 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) Host_Error("%s: %s has unsupported recordsize\n", loadmodel->name, pchunk->id); // byteswap in place and keep the pointer nummatts = numrecords; - matts = buffer; - for (index = 0, p = buffer;index < numrecords;index++, p++) + matts = (pskmatt_t *)buffer; + for (index = 0, p = (pskmatt_t *)buffer;index < numrecords;index++, p++) { } buffer = p; @@ -1836,8 +1836,8 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) Host_Error("%s: %s has unsupported recordsize\n", loadmodel->name, pchunk->id); // byteswap in place and keep the pointer numbones = numrecords; - bones = buffer; - for (index = 0, p = buffer;index < numrecords;index++, p++) + bones = (pskboneinfo_t *)buffer; + for (index = 0, p = (pskboneinfo_t *)buffer;index < numrecords;index++, p++) { p->numchildren = LittleLong(p->numchildren); p->parent = LittleLong(p->parent); @@ -1881,8 +1881,8 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) Host_Error("%s: %s has unsupported recordsize\n", loadmodel->name, pchunk->id); // byteswap in place and keep the pointer numrawweights = numrecords; - rawweights = buffer; - for (index = 0, p = buffer;index < numrecords;index++, p++) + rawweights = (pskrawweights_t *)buffer; + for (index = 0, p = (pskrawweights_t *)buffer;index < numrecords;index++, p++) { p->weight = LittleFloat(p->weight); p->pntsindex = LittleLong(p->pntsindex); @@ -1904,7 +1904,7 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) while (animbuffer < animbufferend) { - pchunk = animbuffer; + pchunk = (pskchunk_t *)animbuffer; animbuffer = (void *)((unsigned char *)animbuffer + sizeof(pskchunk_t)); version = LittleLong(pchunk->version); recordsize = LittleLong(pchunk->recordsize); @@ -1924,14 +1924,14 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) Host_Error("%s: %s has unsupported recordsize\n", animname, pchunk->id); // byteswap in place and keep the pointer numanimbones = numrecords; - animbones = animbuffer; + animbones = (pskboneinfo_t *)animbuffer; // NOTE: supposedly psa does not need to match the psk model, the // bones missing from the psa would simply use their base // positions from the psk, but this is hard for me to implement // and people can easily make animations that match. if (numanimbones != numbones) Host_Error("%s: this loader only supports animations with the same bones as the mesh\n"); - for (index = 0, p = animbuffer;index < numrecords;index++, p++) + for (index = 0, p = (pskboneinfo_t *)animbuffer;index < numrecords;index++, p++) { p->numchildren = LittleLong(p->numchildren); p->parent = LittleLong(p->parent); @@ -1978,8 +1978,8 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) Host_Error("%s: %s has unsupported recordsize\n", animname, pchunk->id); // byteswap in place and keep the pointer numanims = numrecords; - anims = animbuffer; - for (index = 0, p = animbuffer;index < numrecords;index++, p++) + anims = (pskaniminfo_t *)animbuffer; + for (index = 0, p = (pskaniminfo_t *)animbuffer;index < numrecords;index++, p++) { p->numbones = LittleLong(p->numbones); p->playtime = LittleFloat(p->playtime); @@ -1999,8 +1999,8 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) if (recordsize != sizeof(*p)) Host_Error("%s: %s has unsupported recordsize\n", animname, pchunk->id); numanimkeys = numrecords; - animkeys = animbuffer; - for (index = 0, p = animbuffer;index < numrecords;index++, p++) + animkeys = (pskanimkeys_t *)animbuffer; + for (index = 0, p = (pskanimkeys_t *)animbuffer;index < numrecords;index++, p++) { p->origin[0] = LittleFloat(p->origin[0]); p->origin[1] = LittleFloat(p->origin[1]); @@ -2060,20 +2060,20 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) if (numanimkeys != loadmodel->num_bones * loadmodel->numframes) Host_Error("%s: %s has incorrect number of animation keys\n", animname, pchunk->id); - loadmodel->data_poses = Mem_Alloc(loadmodel->mempool, loadmodel->num_poses * sizeof(float[12])); - loadmodel->animscenes = Mem_Alloc(loadmodel->mempool, loadmodel->numframes * sizeof(animscene_t)); - loadmodel->data_textures = Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t)); - loadmodel->data_surfaces = Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(msurface_t)); - loadmodel->surfacelist = Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(int)); - loadmodel->data_bones = Mem_Alloc(loadmodel->mempool, loadmodel->num_bones * sizeof(aliasbone_t)); + loadmodel->data_poses = (float *)Mem_Alloc(loadmodel->mempool, loadmodel->num_poses * sizeof(float[12])); + loadmodel->animscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, loadmodel->numframes * sizeof(animscene_t)); + loadmodel->data_textures = (texture_t *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * loadmodel->numskins * sizeof(texture_t)); + loadmodel->data_surfaces = (msurface_t *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(msurface_t)); + loadmodel->surfacelist = (int *)Mem_Alloc(loadmodel->mempool, loadmodel->num_surfaces * sizeof(int)); + loadmodel->data_bones = (aliasbone_t *)Mem_Alloc(loadmodel->mempool, loadmodel->num_bones * sizeof(aliasbone_t)); - loadmodel->meshlist = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t *)); - mesh = loadmodel->meshlist[0] = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t)); + loadmodel->meshlist = (surfmesh_t **)Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t *)); + mesh = loadmodel->meshlist[0] = (surfmesh_t *)Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t)); mesh->num_vertices = numvtxw; mesh->num_triangles = numfaces; - mesh->data_element3i = Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); - mesh->data_neighbor3i = Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); - mesh->data_texcoordtexture2f = Mem_Alloc(loadmodel->mempool, mesh->num_vertices * sizeof(float[2])); + mesh->data_element3i = (int *)Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); + mesh->data_neighbor3i = (int *)Mem_Alloc(loadmodel->mempool, mesh->num_triangles * sizeof(int[3])); + mesh->data_texcoordtexture2f = (float *)Mem_Alloc(loadmodel->mempool, mesh->num_vertices * sizeof(float[2])); // create surfaces for (index = 0, i = 0;index < nummatts;index++) @@ -2130,7 +2130,7 @@ void Mod_PSKMODEL_Load(model_t *mod, void *buffer, void *bufferend) for (j = 0;j < numrawweights;j++) if (rawweights[j].pntsindex == vtxw[index].pntsindex) mesh->num_vertexboneweights++; - mesh->data_vertexboneweights = Mem_Alloc(loadmodel->mempool, mesh->num_vertexboneweights * sizeof(surfmeshvertexboneweight_t)); + mesh->data_vertexboneweights = (surfmeshvertexboneweight_t *)Mem_Alloc(loadmodel->mempool, mesh->num_vertexboneweights * sizeof(surfmeshvertexboneweight_t)); mesh->num_vertexboneweights = 0; for (index = 0;index < numvtxw;index++) { diff --git a/model_brush.c b/model_brush.c index 2c3a0e95..3e57add4 100644 --- a/model_brush.c +++ b/model_brush.c @@ -1049,7 +1049,7 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) loadmodel->num_textures = 2; } - loadmodel->data_textures = Mem_Alloc(loadmodel->mempool, loadmodel->num_textures * sizeof(texture_t)); + loadmodel->data_textures = (texture_t *)Mem_Alloc(loadmodel->mempool, loadmodel->num_textures * sizeof(texture_t)); // fill out all slots with notexture for (i = 0, tx = loadmodel->data_textures;i < loadmodel->num_textures;i++, tx++) @@ -1160,7 +1160,7 @@ static void Mod_Q1BSP_LoadTextures(lump_t *l) tx->skin.base = tx->skin.merged = R_LoadTexture2D(loadmodel->texturepool, tx->name, image_width, image_height, pixels, TEXTYPE_RGBA, TEXF_MIPMAP | TEXF_ALPHA | TEXF_PRECACHE | TEXF_PICMIP, NULL); if (Image_CheckAlpha(pixels, image_width * image_height, true)) { - fogpixels = Mem_Alloc(tempmempool, image_width * image_height * 4); + fogpixels = (qbyte *)Mem_Alloc(tempmempool, image_width * image_height * 4); for (j = 0;j < image_width * image_height * 4;j += 4) { fogpixels[j + 0] = 255; @@ -1333,13 +1333,13 @@ static void Mod_Q1BSP_LoadLighting(lump_t *l) loadmodel->brushq1.lightdata = NULL; if (loadmodel->brush.ishlbsp) // LordHavoc: load the colored lighting data straight { - loadmodel->brushq1.lightdata = Mem_Alloc(loadmodel->mempool, l->filelen); + loadmodel->brushq1.lightdata = (qbyte *)Mem_Alloc(loadmodel->mempool, l->filelen); for (i=0; ifilelen; i++) loadmodel->brushq1.lightdata[i] = mod_base[l->fileofs+i] >>= 1; } else if (loadmodel->brush.ismcbsp) { - loadmodel->brushq1.lightdata = Mem_Alloc(loadmodel->mempool, l->filelen); + loadmodel->brushq1.lightdata = (qbyte *)Mem_Alloc(loadmodel->mempool, l->filelen); memcpy(loadmodel->brushq1.lightdata, mod_base + l->fileofs, l->filelen); } else // LordHavoc: bsp version 29 (normal white lighting) @@ -1357,7 +1357,7 @@ static void Mod_Q1BSP_LoadLighting(lump_t *l) if (i == 1) { Con_DPrintf("loaded %s\n", litfilename); - loadmodel->brushq1.lightdata = Mem_Alloc(loadmodel->mempool, fs_filesize - 8); + loadmodel->brushq1.lightdata = (qbyte *)Mem_Alloc(loadmodel->mempool, fs_filesize - 8); memcpy(loadmodel->brushq1.lightdata, data + 8, fs_filesize - 8); Mem_Free(data); return; @@ -1380,7 +1380,7 @@ static void Mod_Q1BSP_LoadLighting(lump_t *l) // LordHavoc: oh well, expand the white lighting data if (!l->filelen) return; - loadmodel->brushq1.lightdata = Mem_Alloc(loadmodel->mempool, l->filelen*3); + loadmodel->brushq1.lightdata = (qbyte *)Mem_Alloc(loadmodel->mempool, l->filelen*3); in = loadmodel->brushq1.lightdata + l->filelen*2; // place the file at the end, so it will not be overwritten until the very last write out = loadmodel->brushq1.lightdata; memcpy(in, mod_base + l->fileofs, l->filelen); @@ -1420,7 +1420,7 @@ static void Mod_Q1BSP_LoadLightList(void) s++; numlights++; } - loadmodel->brushq1.lights = Mem_Alloc(loadmodel->mempool, numlights * sizeof(mlight_t)); + loadmodel->brushq1.lights = (mlight_t *)Mem_Alloc(loadmodel->mempool, numlights * sizeof(mlight_t)); s = lightsstring; n = 0; while (*s && n < numlights) @@ -1463,7 +1463,7 @@ static void Mod_Q1BSP_LoadVisibility(lump_t *l) if (!l->filelen) return; loadmodel->brushq1.num_compressedpvs = l->filelen; - loadmodel->brushq1.data_compressedpvs = Mem_Alloc(loadmodel->mempool, l->filelen); + loadmodel->brushq1.data_compressedpvs = (qbyte *)Mem_Alloc(loadmodel->mempool, l->filelen); memcpy(loadmodel->brushq1.data_compressedpvs, mod_base + l->fileofs, l->filelen); } @@ -1532,7 +1532,7 @@ static void Mod_Q1BSP_LoadEntities(lump_t *l) loadmodel->brush.entities = NULL; if (!l->filelen) return; - loadmodel->brush.entities = Mem_Alloc(loadmodel->mempool, l->filelen); + loadmodel->brush.entities = (char *)Mem_Alloc(loadmodel->mempool, l->filelen); memcpy(loadmodel->brush.entities, mod_base + l->fileofs, l->filelen); if (loadmodel->brush.ishlbsp) Mod_Q1BSP_ParseWadsFromEntityLump(loadmodel->brush.entities); @@ -1545,11 +1545,11 @@ static void Mod_Q1BSP_LoadVertexes(lump_t *l) mvertex_t *out; int i, count; - in = (void *)(mod_base + l->fileofs); + in = (dvertex_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadVertexes: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count*sizeof(*out)); + out = (mvertex_t *)Mem_Alloc(loadmodel->mempool, count*sizeof(*out)); loadmodel->brushq1.vertexes = out; loadmodel->brushq1.numvertexes = count; @@ -1597,7 +1597,7 @@ static void Mod_Q1BSP_LoadSubmodels(lump_t *l, hullinfo_t *hullinfo) Host_Error ("Mod_Q1BSP_LoadSubmodels: funny lump size in %s", loadmodel->name); count = l->filelen / (48+4*hullinfo->filehulls); - out = Mem_Alloc (loadmodel->mempool, count*sizeof(*out)); + out = (dmodel_t *)Mem_Alloc (loadmodel->mempool, count*sizeof(*out)); loadmodel->brushq1.submodels = out; loadmodel->brush.numsubmodels = count; @@ -1628,11 +1628,11 @@ static void Mod_Q1BSP_LoadEdges(lump_t *l) medge_t *out; int i, count; - in = (void *)(mod_base + l->fileofs); + in = (dedge_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadEdges: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (medge_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brushq1.edges = out; loadmodel->brushq1.numedges = count; @@ -1650,11 +1650,11 @@ static void Mod_Q1BSP_LoadTexinfo(lump_t *l) mtexinfo_t *out; int i, j, k, count, miptex; - in = (void *)(mod_base + l->fileofs); + in = (texinfo_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadTexinfo: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (mtexinfo_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brushq1.texinfo = out; loadmodel->brushq1.numtexinfo = count; @@ -1851,18 +1851,18 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l) int i, j, count, surfacenum, planenum, smax, tmax, ssize, tsize, firstedge, numedges, totalverts, totaltris; float texmins[2], texmaxs[2], val; - in = (void *)(mod_base + l->fileofs); + in = (dface_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadFaces: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - loadmodel->data_surfaces = Mem_Alloc(loadmodel->mempool, count*sizeof(msurface_t)); - loadmodel->data_surfaces_lightmapinfo = Mem_Alloc(loadmodel->mempool, count*sizeof(msurface_lightmapinfo_t)); + loadmodel->data_surfaces = (msurface_t *)Mem_Alloc(loadmodel->mempool, count*sizeof(msurface_t)); + loadmodel->data_surfaces_lightmapinfo = (msurface_lightmapinfo_t *)Mem_Alloc(loadmodel->mempool, count*sizeof(msurface_lightmapinfo_t)); loadmodel->num_surfaces = count; totalverts = 0; totaltris = 0; - for (surfacenum = 0, in = (void *)(mod_base + l->fileofs);surfacenum < count;surfacenum++, in++) + for (surfacenum = 0, in = (dface_t *)(mod_base + l->fileofs);surfacenum < count;surfacenum++, in++) { numedges = LittleShort(in->numedges); totalverts += numedges; @@ -1872,12 +1872,12 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l) // TODO: split up into multiple meshes as needed to avoid exceeding 65536 // vertex limit loadmodel->nummeshes = 1; - loadmodel->meshlist = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t *)); + loadmodel->meshlist = (surfmesh_t **)Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t *)); loadmodel->meshlist[0] = Mod_AllocSurfMesh(loadmodel->mempool, totalverts, totaltris, true, false, false); totalverts = 0; totaltris = 0; - for (surfacenum = 0, in = (void *)(mod_base + l->fileofs), surface = loadmodel->data_surfaces;surfacenum < count;surfacenum++, in++, surface++) + for (surfacenum = 0, in = (dface_t *)(mod_base + l->fileofs), surface = loadmodel->data_surfaces;surfacenum < count;surfacenum++, in++, surface++) { surface->lightmapinfo = loadmodel->data_surfaces_lightmapinfo + surfacenum; @@ -1975,7 +1975,7 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l) // give non-lightmapped water a 1x white lightmap if ((surface->texture->basematerialflags & MATERIALFLAG_WATER) && (surface->lightmapinfo->texinfo->flags & TEX_SPECIAL) && ssize <= 256 && tsize <= 256) { - surface->lightmapinfo->samples = Mem_Alloc(loadmodel->mempool, ssize * tsize * 3); + surface->lightmapinfo->samples = (qbyte *)Mem_Alloc(loadmodel->mempool, ssize * tsize * 3); surface->lightmapinfo->styles[0] = 0; memset(surface->lightmapinfo->samples, 128, ssize * tsize * 3); } @@ -1993,7 +1993,7 @@ static void Mod_Q1BSP_LoadFaces(lump_t *l) if (ssize > 256 || tsize > 256) Host_Error("Bad surface extents"); // stainmap for permanent marks on walls - surface->lightmapinfo->stainsamples = Mem_Alloc(loadmodel->mempool, ssize * tsize * 3); + surface->lightmapinfo->stainsamples = (qbyte *)Mem_Alloc(loadmodel->mempool, ssize * tsize * 3); // clear to white memset(surface->lightmapinfo->stainsamples, 255, ssize * tsize * 3); @@ -2044,11 +2044,11 @@ static void Mod_Q1BSP_LoadNodes(lump_t *l) dnode_t *in; mnode_t *out; - in = (void *)(mod_base + l->fileofs); + in = (dnode_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadNodes: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count*sizeof(*out)); + out = (mnode_t *)Mem_Alloc(loadmodel->mempool, count*sizeof(*out)); loadmodel->brush.data_nodes = out; loadmodel->brush.num_nodes = count; @@ -2086,18 +2086,18 @@ static void Mod_Q1BSP_LoadLeafs(lump_t *l) mleaf_t *out; int i, j, count, p; - in = (void *)(mod_base + l->fileofs); + in = (dleaf_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadLeafs: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count*sizeof(*out)); + out = (mleaf_t *)Mem_Alloc(loadmodel->mempool, count*sizeof(*out)); loadmodel->brush.data_leafs = out; loadmodel->brush.num_leafs = count; // get visleafs from the submodel data loadmodel->brush.num_pvsclusters = loadmodel->brushq1.submodels[0].visleafs; loadmodel->brush.num_pvsclusterbytes = (loadmodel->brush.num_pvsclusters+7)>>3; - loadmodel->brush.data_pvsclusters = Mem_Alloc(loadmodel->mempool, loadmodel->brush.num_pvsclusters * loadmodel->brush.num_pvsclusterbytes); + loadmodel->brush.data_pvsclusters = (unsigned char *)Mem_Alloc(loadmodel->mempool, loadmodel->brush.num_pvsclusters * loadmodel->brush.num_pvsclusterbytes); memset(loadmodel->brush.data_pvsclusters, 0xFF, loadmodel->brush.num_pvsclusters * loadmodel->brush.num_pvsclusterbytes); for ( i=0 ; ifileofs); + in = (dclipnode_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadClipnodes: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count*sizeof(*out)); + out = (dclipnode_t *)Mem_Alloc(loadmodel->mempool, count*sizeof(*out)); loadmodel->brushq1.clipnodes = out; loadmodel->brushq1.numclipnodes = count; @@ -2194,7 +2194,7 @@ static void Mod_Q1BSP_MakeHull0(void) hull = &loadmodel->brushq1.hulls[0]; in = loadmodel->brush.data_nodes; - out = Mem_Alloc(loadmodel->mempool, loadmodel->brush.num_nodes * sizeof(dclipnode_t)); + out = (dclipnode_t *)Mem_Alloc(loadmodel->mempool, loadmodel->brush.num_nodes * sizeof(dclipnode_t)); hull->clipnodes = out; hull->firstclipnode = 0; @@ -2214,11 +2214,11 @@ static void Mod_Q1BSP_LoadLeaffaces(lump_t *l) int i, j; short *in; - in = (void *)(mod_base + l->fileofs); + in = (short *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadLeaffaces: funny lump size in %s",loadmodel->name); loadmodel->brush.num_leafsurfaces = l->filelen / sizeof(*in); - loadmodel->brush.data_leafsurfaces = Mem_Alloc(loadmodel->mempool, loadmodel->brush.num_leafsurfaces * sizeof(int)); + loadmodel->brush.data_leafsurfaces = (int *)Mem_Alloc(loadmodel->mempool, loadmodel->brush.num_leafsurfaces * sizeof(int)); for (i = 0;i < loadmodel->brush.num_leafsurfaces;i++) { @@ -2234,11 +2234,11 @@ static void Mod_Q1BSP_LoadSurfedges(lump_t *l) int i; int *in; - in = (void *)(mod_base + l->fileofs); + in = (int *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadSurfedges: funny lump size in %s",loadmodel->name); loadmodel->brushq1.numsurfedges = l->filelen / sizeof(*in); - loadmodel->brushq1.surfedges = Mem_Alloc(loadmodel->mempool, loadmodel->brushq1.numsurfedges * sizeof(int)); + loadmodel->brushq1.surfedges = (int *)Mem_Alloc(loadmodel->mempool, loadmodel->brushq1.numsurfedges * sizeof(int)); for (i = 0;i < loadmodel->brushq1.numsurfedges;i++) loadmodel->brushq1.surfedges[i] = LittleLong(in[i]); @@ -2251,12 +2251,12 @@ static void Mod_Q1BSP_LoadPlanes(lump_t *l) mplane_t *out; dplane_t *in; - in = (void *)(mod_base + l->fileofs); + in = (dplane_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q1BSP_LoadPlanes: funny lump size in %s", loadmodel->name); loadmodel->brush.num_planes = l->filelen / sizeof(*in); - loadmodel->brush.data_planes = out = Mem_Alloc(loadmodel->mempool, loadmodel->brush.num_planes * sizeof(*out)); + loadmodel->brush.data_planes = out = (mplane_t *)Mem_Alloc(loadmodel->mempool, loadmodel->brush.num_planes * sizeof(*out)); for (i = 0;i < loadmodel->brush.num_planes;i++, in++, out++) { @@ -2388,7 +2388,7 @@ AllocPortal static portal_t *AllocPortal(void) { portal_t *p; - p = Mem_Alloc(loadmodel->mempool, sizeof(portal_t)); + p = (portal_t *)Mem_Alloc(loadmodel->mempool, sizeof(portal_t)); p->chain = portalchain; portalchain = p; return p; @@ -2473,9 +2473,9 @@ static void Mod_Q1BSP_FinalizePortals(void) } p = p->chain; } - loadmodel->brush.data_portals = Mem_Alloc(loadmodel->mempool, numportals * sizeof(mportal_t) + numpoints * sizeof(mvertex_t)); + loadmodel->brush.data_portals = (mportal_t *)Mem_Alloc(loadmodel->mempool, numportals * sizeof(mportal_t) + numpoints * sizeof(mvertex_t)); loadmodel->brush.num_portals = numportals; - loadmodel->brush.data_portalpoints = (void *)((qbyte *) loadmodel->brush.data_portals + numportals * sizeof(mportal_t)); + loadmodel->brush.data_portalpoints = (mvertex_t *)((qbyte *) loadmodel->brush.data_portals + numportals * sizeof(mportal_t)); loadmodel->brush.num_portalpoints = numpoints; // clear all leaf portal chains for (i = 0;i < loadmodel->brush.num_leafs;i++) @@ -2586,7 +2586,7 @@ static void RemovePortalFromNodes(portal_t *portal) portalpointer = (void **) &node->portals; while (1) { - t = *portalpointer; + t = (portal_t *)*portalpointer; if (!t) Host_Error("RemovePortalFromNodes: portal not in leaf"); @@ -2778,10 +2778,10 @@ static void Mod_Q1BSP_BuildLightmapUpdateChains(mempool_t *mempool, model_t *mod } if (!totalcount) return; - model->brushq1.light_style = Mem_Alloc(mempool, model->brushq1.light_styles * sizeof(qbyte)); - model->brushq1.light_stylevalue = Mem_Alloc(mempool, model->brushq1.light_styles * sizeof(int)); - model->brushq1.light_styleupdatechains = Mem_Alloc(mempool, model->brushq1.light_styles * sizeof(msurface_t **)); - model->brushq1.light_styleupdatechainsbuffer = Mem_Alloc(mempool, totalcount * sizeof(msurface_t *)); + model->brushq1.light_style = (qbyte *)Mem_Alloc(mempool, model->brushq1.light_styles * sizeof(qbyte)); + model->brushq1.light_stylevalue = (int *)Mem_Alloc(mempool, model->brushq1.light_styles * sizeof(int)); + model->brushq1.light_styleupdatechains = (msurface_t ***)Mem_Alloc(mempool, model->brushq1.light_styles * sizeof(msurface_t **)); + model->brushq1.light_styleupdatechainsbuffer = (msurface_t **)Mem_Alloc(mempool, totalcount * sizeof(msurface_t *)); model->brushq1.light_styles = 0; for (i = 0;i < 255;i++) if (stylecounts[i]) @@ -3079,7 +3079,7 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer, void *bufferend) Mod_BuildTriangleNeighbors(loadmodel->brush.shadowmesh->neighbor3i, loadmodel->brush.shadowmesh->element3i, loadmodel->brush.shadowmesh->numtriangles); if (loadmodel->brush.numsubmodels) - loadmodel->brush.submodels = Mem_Alloc(loadmodel->mempool, loadmodel->brush.numsubmodels * sizeof(model_t *)); + loadmodel->brush.submodels = (model_t **)Mem_Alloc(loadmodel->mempool, loadmodel->brush.numsubmodels * sizeof(model_t *)); if (loadmodel->isworldmodel) { @@ -3146,7 +3146,7 @@ void Mod_Q1BSP_Load(model_t *mod, void *buffer, void *bufferend) mod->nummodelsurfaces = bm->numfaces; // make the model surface list (used by shadowing/lighting) - mod->surfacelist = Mem_Alloc(loadmodel->mempool, mod->nummodelsurfaces * sizeof(*mod->surfacelist)); + mod->surfacelist = (int *)Mem_Alloc(loadmodel->mempool, mod->nummodelsurfaces * sizeof(*mod->surfacelist)); for (j = 0;j < mod->nummodelsurfaces;j++) mod->surfacelist[j] = mod->firstmodelsurface + j; @@ -3666,7 +3666,7 @@ static void Mod_Q3BSP_LoadEntities(lump_t *l) loadmodel->brushq3.num_lightgrid_cellsize[2] = 128; if (!l->filelen) return; - loadmodel->brush.entities = Mem_Alloc(loadmodel->mempool, l->filelen); + loadmodel->brush.entities = (char *)Mem_Alloc(loadmodel->mempool, l->filelen); memcpy(loadmodel->brush.entities, mod_base + l->fileofs, l->filelen); data = loadmodel->brush.entities; // some Q3 maps override the lightgrid_cellsize with a worldspawn key @@ -3711,11 +3711,11 @@ static void Mod_Q3BSP_LoadTextures(lump_t *l) char firstpasstexturename[Q3PATHLENGTH]; char parameter[4][Q3PATHLENGTH]; - in = (void *)(mod_base + l->fileofs); + in = (q3dtexture_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadTextures: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (texture_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->data_textures = out; loadmodel->num_textures = count; @@ -4000,11 +4000,11 @@ static void Mod_Q3BSP_LoadPlanes(lump_t *l) mplane_t *out; int i, count; - in = (void *)(mod_base + l->fileofs); + in = (q3dplane_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadPlanes: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (mplane_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brush.data_planes = out; loadmodel->brush.num_planes = count; @@ -4025,11 +4025,11 @@ static void Mod_Q3BSP_LoadBrushSides(lump_t *l) q3mbrushside_t *out; int i, n, count; - in = (void *)(mod_base + l->fileofs); + in = (q3dbrushside_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadBrushSides: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (q3mbrushside_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brush.data_brushsides = out; loadmodel->brush.num_brushsides = count; @@ -4054,11 +4054,11 @@ static void Mod_Q3BSP_LoadBrushes(lump_t *l) int i, j, n, c, count, maxplanes; mplane_t *planes; - in = (void *)(mod_base + l->fileofs); + in = (q3dbrush_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadBrushes: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (q3mbrush_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brush.data_brushes = out; loadmodel->brush.num_brushes = count; @@ -4085,7 +4085,7 @@ static void Mod_Q3BSP_LoadBrushes(lump_t *l) maxplanes = out->numbrushsides; if (planes) Mem_Free(planes); - planes = Mem_Alloc(tempmempool, sizeof(mplane_t) * maxplanes); + planes = (mplane_t *)Mem_Alloc(tempmempool, sizeof(mplane_t) * maxplanes); } for (j = 0;j < out->numbrushsides;j++) { @@ -4105,11 +4105,11 @@ static void Mod_Q3BSP_LoadEffects(lump_t *l) q3deffect_t *out; int i, n, count; - in = (void *)(mod_base + l->fileofs); + in = (q3deffect_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadEffects: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (q3deffect_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brushq3.data_effects = out; loadmodel->brushq3.num_effects = count; @@ -4133,11 +4133,11 @@ static void Mod_Q3BSP_LoadVertices(lump_t *l) q3dvertex_t *in; int i, count; - in = (void *)(mod_base + l->fileofs); + in = (q3dvertex_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadVertices: funny lump size in %s",loadmodel->name); loadmodel->brushq3.num_vertices = count = l->filelen / sizeof(*in); - loadmodel->brushq3.data_vertex3f = Mem_Alloc(loadmodel->mempool, count * (sizeof(float) * (3 + 2 + 2 + 4))); + loadmodel->brushq3.data_vertex3f = (float *)Mem_Alloc(loadmodel->mempool, count * (sizeof(float) * (3 + 2 + 2 + 4))); loadmodel->brushq3.data_texcoordtexture2f = loadmodel->brushq3.data_vertex3f + count * 3; loadmodel->brushq3.data_texcoordlightmap2f = loadmodel->brushq3.data_texcoordtexture2f + count * 2; loadmodel->brushq3.data_color4f = loadmodel->brushq3.data_texcoordlightmap2f + count * 2; @@ -4165,11 +4165,11 @@ static void Mod_Q3BSP_LoadTriangles(lump_t *l) int *out; int i, count; - in = (void *)(mod_base + l->fileofs); + in = (int *)(mod_base + l->fileofs); if (l->filelen % sizeof(int[3])) Host_Error("Mod_Q3BSP_LoadTriangles: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (int *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brushq3.num_triangles = count / 3; loadmodel->brushq3.data_element3i = out; @@ -4193,11 +4193,11 @@ static void Mod_Q3BSP_LoadLightmaps(lump_t *l) if (!l->filelen) return; - in = (void *)(mod_base + l->fileofs); + in = (q3dlightmap_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadLightmaps: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (rtexture_t **)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brushq3.data_lightmaps = out; loadmodel->brushq3.num_lightmaps = count; @@ -4223,11 +4223,11 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) float *v; surfmesh_t *mesh, *tempmeshlist[1024]; - in = (void *)(mod_base + l->fileofs); + in = (q3dface_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadFaces: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (msurface_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->data_surfaces = out; loadmodel->num_surfaces = count; @@ -4460,8 +4460,8 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) finalvertices = finalwidth * finalheight; finaltriangles = (finalwidth - 1) * (finalheight - 1) * 2; - out->data_collisionvertex3f = Mem_Alloc(loadmodel->mempool, sizeof(float[3]) * finalvertices); - out->data_collisionelement3i = Mem_Alloc(loadmodel->mempool, sizeof(int[3]) * finaltriangles); + out->data_collisionvertex3f = (float *)Mem_Alloc(loadmodel->mempool, sizeof(float[3]) * finalvertices); + out->data_collisionelement3i = (int *)Mem_Alloc(loadmodel->mempool, sizeof(int[3]) * finaltriangles); out->num_collisionvertices = finalvertices; out->num_collisiontriangles = finaltriangles; Q3PatchTesselateFloat(3, sizeof(float[3]), out->data_collisionvertex3f, patchsize[0], patchsize[1], sizeof(float[3]), originalvertex3f, xtess, ytess); @@ -4532,7 +4532,7 @@ static void Mod_Q3BSP_LoadFaces(lump_t *l) loadmodel->nummeshes = meshnum; if (loadmodel->nummeshes) { - loadmodel->meshlist = Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t *) * loadmodel->nummeshes); + loadmodel->meshlist = (surfmesh_t **)Mem_Alloc(loadmodel->mempool, sizeof(surfmesh_t *) * loadmodel->nummeshes); memcpy(loadmodel->meshlist, tempmeshlist, sizeof(surfmesh_t *) * loadmodel->nummeshes); } @@ -4555,11 +4555,11 @@ static void Mod_Q3BSP_LoadModels(lump_t *l) q3dmodel_t *out; int i, j, n, c, count; - in = (void *)(mod_base + l->fileofs); + in = (q3dmodel_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadModels: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (q3dmodel_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brushq3.data_models = out; loadmodel->brushq3.num_models = count; @@ -4592,11 +4592,11 @@ static void Mod_Q3BSP_LoadLeafBrushes(lump_t *l) int *out; int i, n, count; - in = (void *)(mod_base + l->fileofs); + in = (int *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadLeafBrushes: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (int *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brush.data_leafbrushes = out; loadmodel->brush.num_leafbrushes = count; @@ -4616,11 +4616,11 @@ static void Mod_Q3BSP_LoadLeafFaces(lump_t *l) int *out; int i, n, count; - in = (void *)(mod_base + l->fileofs); + in = (int *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadLeafFaces: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (int *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brush.data_leafsurfaces = out; loadmodel->brush.num_leafsurfaces = count; @@ -4640,11 +4640,11 @@ static void Mod_Q3BSP_LoadLeafs(lump_t *l) mleaf_t *out; int i, j, n, c, count; - in = (void *)(mod_base + l->fileofs); + in = (q3dleaf_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadLeafs: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (mleaf_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brush.data_leafs = out; loadmodel->brush.num_leafs = count; @@ -4682,11 +4682,11 @@ static void Mod_Q3BSP_LoadNodes(lump_t *l) mnode_t *out; int i, j, n, count; - in = (void *)(mod_base + l->fileofs); + in = (q3dnode_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadNodes: funny lump size in %s",loadmodel->name); count = l->filelen / sizeof(*in); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (mnode_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brush.data_nodes = out; loadmodel->brush.num_nodes = count; @@ -4733,7 +4733,7 @@ static void Mod_Q3BSP_LoadLightGrid(lump_t *l) q3dlightgrid_t *out; int count; - in = (void *)(mod_base + l->fileofs); + in = (q3dlightgrid_t *)(mod_base + l->fileofs); if (l->filelen % sizeof(*in)) Host_Error("Mod_Q3BSP_LoadLightGrid: funny lump size in %s",loadmodel->name); loadmodel->brushq3.num_lightgrid_scale[0] = 1.0f / loadmodel->brushq3.num_lightgrid_cellsize[0]; @@ -4759,7 +4759,7 @@ static void Mod_Q3BSP_LoadLightGrid(lump_t *l) Host_Error("Mod_Q3BSP_LoadLightGrid: invalid lightgrid lump size %i bytes, should be %i bytes (%ix%ix%i)\n", l->filelen, count * sizeof(*in), loadmodel->brushq3.num_lightgrid_dimensions[0], loadmodel->brushq3.num_lightgrid_dimensions[1], loadmodel->brushq3.num_lightgrid_dimensions[2]); if (l->filelen != count * (int)sizeof(*in)) Con_Printf("Mod_Q3BSP_LoadLightGrid: Warning: calculated lightgrid size %i bytes does not match lump size %i\n", count * sizeof(*in), l->filelen); - out = Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); + out = (q3dlightgrid_t *)Mem_Alloc(loadmodel->mempool, count * sizeof(*out)); loadmodel->brushq3.data_lightgrid = out; loadmodel->brushq3.num_lightgrid = count; // no swapping or validation necessary @@ -4784,12 +4784,12 @@ static void Mod_Q3BSP_LoadPVS(lump_t *l) // create clusters loadmodel->brush.num_pvsclusterbytes = (loadmodel->brush.num_pvsclusters + 7) / 8; totalchains = loadmodel->brush.num_pvsclusterbytes * loadmodel->brush.num_pvsclusters; - loadmodel->brush.data_pvsclusters = Mem_Alloc(loadmodel->mempool, totalchains); + loadmodel->brush.data_pvsclusters = (unsigned char *)Mem_Alloc(loadmodel->mempool, totalchains); memset(loadmodel->brush.data_pvsclusters, 0xFF, totalchains); return; } - in = (void *)(mod_base + l->fileofs); + in = (q3dpvs_t *)(mod_base + l->fileofs); if (l->filelen < 9) Host_Error("Mod_Q3BSP_LoadPVS: funny lump size in %s",loadmodel->name); @@ -4801,7 +4801,7 @@ static void Mod_Q3BSP_LoadPVS(lump_t *l) if (l->filelen < totalchains + (int)sizeof(*in)) Host_Error("Mod_Q3BSP_LoadPVS: lump too small ((numclusters = %i) * (chainlength = %i) + sizeof(q3dpvs_t) == %i bytes, lump is %i bytes)\n", loadmodel->brush.num_pvsclusters, loadmodel->brush.num_pvsclusterbytes, totalchains + sizeof(*in), l->filelen); - loadmodel->brush.data_pvsclusters = Mem_Alloc(loadmodel->mempool, totalchains); + loadmodel->brush.data_pvsclusters = (unsigned char *)Mem_Alloc(loadmodel->mempool, totalchains); memcpy(loadmodel->brush.data_pvsclusters, (qbyte *)(in + 1), totalchains); } @@ -5615,7 +5615,7 @@ void Mod_Q3BSP_Load(model_t *mod, void *buffer, void *bufferend) mod->nummodelsurfaces = mod->brushq3.data_models[i].numfaces; mod->firstmodelbrush = mod->brushq3.data_models[i].firstbrush; mod->nummodelbrushes = mod->brushq3.data_models[i].numbrushes; - mod->surfacelist = Mem_Alloc(loadmodel->mempool, mod->nummodelsurfaces * sizeof(*mod->surfacelist)); + mod->surfacelist = (int *)Mem_Alloc(loadmodel->mempool, mod->nummodelsurfaces * sizeof(*mod->surfacelist)); for (j = 0;j < mod->nummodelsurfaces;j++) mod->surfacelist[j] = mod->firstmodelsurface + j; diff --git a/model_shared.c b/model_shared.c index 7ff896c7..b8b83586 100644 --- a/model_shared.c +++ b/model_shared.c @@ -153,7 +153,7 @@ model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, qboolea buf = FS_LoadFile (mod->name, tempmempool, false); if (buf) { - crc = CRC_Block(buf, fs_filesize); + crc = CRC_Block((qbyte *)buf, fs_filesize); if (mod->crc != crc) mod->loaded = false; } @@ -201,7 +201,7 @@ model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk, qboolea else if (!memcmp(buf, "IBSP", 4)) Mod_IBSP_Load(mod, buf, bufend); else if (!memcmp(buf, "ZYMOTICMODEL", 12)) Mod_ZYMOTICMODEL_Load(mod, buf, bufend); else if (!memcmp(buf, "DARKPLACESMODEL", 16)) Mod_DARKPLACESMODEL_Load(mod, buf, bufend); - else if (!strcmp(buf, "ACTRHEAD")) Mod_PSKMODEL_Load(mod, buf, bufend); + else if (!memcmp(buf, "ACTRHEAD", 8)) Mod_PSKMODEL_Load(mod, buf, bufend); else if (strlen(mod->name) >= 4 && !strcmp(mod->name - 4, ".map")) Mod_MAP_Load(mod, buf, bufend); else if (!memcmp(buf, "MCBSPpad", 8)) Mod_Q1BSP_Load(mod, buf, bufend); else if (num == BSPVERSION || num == 30) Mod_Q1BSP_Load(mod, buf, bufend); @@ -362,7 +362,7 @@ int Mod_BuildVertexRemapTableFromElements(int numelements, const int *elements, { int i, count; qbyte *used; - used = Mem_Alloc(tempmempool, numvertices); + used = (qbyte *)Mem_Alloc(tempmempool, numvertices); memset(used, 0, numvertices); for (i = 0;i < numelements;i++) used[elements[i]] = 1; @@ -391,7 +391,7 @@ void Mod_BuildTriangleNeighbors(int *neighbors, const int *elements, int numtria edgehashentries = edgehashentriesbuffer; // if there are too many triangles for the stack array, allocate larger buffer if (numtriangles > TRIANGLEEDGEHASH) - edgehashentries = Mem_Alloc(tempmempool, numtriangles * 3 * sizeof(edgehashentry_t)); + edgehashentries = (edgehashentry_t *)Mem_Alloc(tempmempool, numtriangles * 3 * sizeof(edgehashentry_t)); // find neighboring triangles for (i = 0, e = elements, n = neighbors;i < numtriangles;i++, e += 3, n += 3) { @@ -636,7 +636,7 @@ surfmesh_t *Mod_AllocSurfMesh(mempool_t *mempool, int numvertices, int numtriang { surfmesh_t *mesh; qbyte *data; - mesh = Mem_Alloc(mempool, sizeof(surfmesh_t) + numvertices * (3 + 3 + 3 + 3 + 2 + 2 + (vertexcolors ? 4 : 0)) * sizeof(float) + numvertices * (lightmapoffsets ? 1 : 0) * sizeof(int) + numtriangles * (3 + (neighbors ? 3 : 0)) * sizeof(int)); + mesh = (surfmesh_t *)Mem_Alloc(mempool, sizeof(surfmesh_t) + numvertices * (3 + 3 + 3 + 3 + 2 + 2 + (vertexcolors ? 4 : 0)) * sizeof(float) + numvertices * (lightmapoffsets ? 1 : 0) * sizeof(int) + numtriangles * (3 + (neighbors ? 3 : 0)) * sizeof(int)); mesh->num_vertices = numvertices; mesh->num_triangles = numtriangles; data = (qbyte *)(mesh + 1); @@ -676,8 +676,8 @@ shadowmesh_t *Mod_ShadowMesh_Alloc(mempool_t *mempool, int maxverts, int maxtria size += maxtriangles * sizeof(int[3]); if (expandable) size += SHADOWMESHVERTEXHASH * sizeof(shadowmeshvertexhash_t *) + maxverts * sizeof(shadowmeshvertexhash_t); - data = Mem_Alloc(mempool, size); - newmesh = (void *)data;data += sizeof(*newmesh); + data = (qbyte *)Mem_Alloc(mempool, size); + newmesh = (shadowmesh_t *)data;data += sizeof(*newmesh); newmesh->map_diffuse = map_diffuse; newmesh->map_specular = map_specular; newmesh->map_normal = map_normal; @@ -686,23 +686,23 @@ shadowmesh_t *Mod_ShadowMesh_Alloc(mempool_t *mempool, int maxverts, int maxtria newmesh->numverts = 0; newmesh->numtriangles = 0; - newmesh->vertex3f = (void *)data;data += maxverts * sizeof(float[3]); + newmesh->vertex3f = (float *)data;data += maxverts * sizeof(float[3]); if (light) { - newmesh->svector3f = (void *)data;data += maxverts * sizeof(float[3]); - newmesh->tvector3f = (void *)data;data += maxverts * sizeof(float[3]); - newmesh->normal3f = (void *)data;data += maxverts * sizeof(float[3]); - newmesh->texcoord2f = (void *)data;data += maxverts * sizeof(float[2]); + newmesh->svector3f = (float *)data;data += maxverts * sizeof(float[3]); + newmesh->tvector3f = (float *)data;data += maxverts * sizeof(float[3]); + newmesh->normal3f = (float *)data;data += maxverts * sizeof(float[3]); + newmesh->texcoord2f = (float *)data;data += maxverts * sizeof(float[2]); } - newmesh->element3i = (void *)data;data += maxtriangles * sizeof(int[3]); + newmesh->element3i = (int *)data;data += maxtriangles * sizeof(int[3]); if (neighbors) { - newmesh->neighbor3i = (void *)data;data += maxtriangles * sizeof(int[3]); + newmesh->neighbor3i = (int *)data;data += maxtriangles * sizeof(int[3]); } if (expandable) { - newmesh->vertexhashtable = (void *)data;data += SHADOWMESHVERTEXHASH * sizeof(shadowmeshvertexhash_t *); - newmesh->vertexhashentries = (void *)data;data += maxverts * sizeof(shadowmeshvertexhash_t); + newmesh->vertexhashtable = (shadowmeshvertexhash_t **)data;data += SHADOWMESHVERTEXHASH * sizeof(shadowmeshvertexhash_t *); + newmesh->vertexhashentries = (shadowmeshvertexhash_t *)data;data += maxverts * sizeof(shadowmeshvertexhash_t); } return newmesh; } @@ -951,7 +951,7 @@ int Mod_LoadSkinFrame_Internal(skinframe_t *skinframe, char *basename, int textu return false; if (r_shadow_bumpscale_basetexture.value > 0) { - temp1 = Mem_Alloc(loadmodel->mempool, width * height * 8); + temp1 = (qbyte *)Mem_Alloc(loadmodel->mempool, width * height * 8); temp2 = temp1 + width * height * 4; Image_Copy8bitRGBA(skindata, temp1, width * height, palette_nofullbrights); Image_HeightmapToNormalmap(temp1, temp2, width, height, false, r_shadow_bumpscale_basetexture.value); @@ -1084,12 +1084,12 @@ tag_torso, // If it's the first file we parse if (skinfile == NULL) { - skinfile = Mem_Alloc(tempmempool, sizeof(skinfile_t)); + skinfile = (skinfile_t *)Mem_Alloc(tempmempool, sizeof(skinfile_t)); first = skinfile; } else { - skinfile->next = Mem_Alloc(tempmempool, sizeof(skinfile_t)); + skinfile->next = (skinfile_t *)Mem_Alloc(tempmempool, sizeof(skinfile_t)); skinfile = skinfile->next; } skinfile->next = NULL; @@ -1122,7 +1122,7 @@ tag_torso, if (words == 3) { Con_DPrintf("Mod_LoadSkinFiles: parsed mesh \"%s\" shader replacement \"%s\"\n", word[1], word[2]); - skinfileitem = Mem_Alloc(tempmempool, sizeof(skinfileitem_t)); + skinfileitem = (skinfileitem_t *)Mem_Alloc(tempmempool, sizeof(skinfileitem_t)); skinfileitem->next = skinfile->items; skinfile->items = skinfileitem; strlcpy (skinfileitem->name, word[1], sizeof (skinfileitem->name)); @@ -1143,7 +1143,7 @@ tag_torso, { // mesh shader name, like "U_RArm,models/players/Legoman/BikerA1.tga" Con_DPrintf("Mod_LoadSkinFiles: parsed mesh \"%s\" shader replacement \"%s\"\n", word[0], word[2]); - skinfileitem = Mem_Alloc(tempmempool, sizeof(skinfileitem_t)); + skinfileitem = (skinfileitem_t *)Mem_Alloc(tempmempool, sizeof(skinfileitem_t)); skinfileitem->next = skinfile->items; skinfile->items = skinfileitem; strlcpy (skinfileitem->name, word[0], sizeof (skinfileitem->name)); @@ -1159,14 +1159,14 @@ tag_torso, overridetagnameset_t *t; t = tagsets + i; t->num_overridetagnames = numtags; - t->data_overridetagnames = Mem_Alloc(loadmodel->mempool, t->num_overridetagnames * sizeof(overridetagname_t)); + t->data_overridetagnames = (overridetagname_t *)Mem_Alloc(loadmodel->mempool, t->num_overridetagnames * sizeof(overridetagname_t)); memcpy(t->data_overridetagnames, tags, t->num_overridetagnames * sizeof(overridetagname_t)); tagsetsused = true; } } if (tagsetsused) { - loadmodel->data_overridetagnamesforskin = Mem_Alloc(loadmodel->mempool, i * sizeof(overridetagnameset_t)); + loadmodel->data_overridetagnamesforskin = (overridetagnameset_t *)Mem_Alloc(loadmodel->mempool, i * sizeof(overridetagnameset_t)); memcpy(loadmodel->data_overridetagnamesforskin, tagsets, i * sizeof(overridetagnameset_t)); } if (i) diff --git a/model_sprite.c b/model_sprite.c index ec41b6e4..835623e0 100644 --- a/model_sprite.c +++ b/model_sprite.c @@ -97,10 +97,10 @@ static void Mod_Sprite_SharedSetup(const qbyte *datapointer, int version, const realframes += groupframes; } - loadmodel->animscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes); - loadmodel->sprite.sprdata_frames = Mem_Alloc(loadmodel->mempool, sizeof(mspriteframe_t) * realframes); + loadmodel->animscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes); + loadmodel->sprite.sprdata_frames = (mspriteframe_t *)Mem_Alloc(loadmodel->mempool, sizeof(mspriteframe_t) * realframes); - datapointer = startframes; + datapointer = (qbyte *)startframes; realframes = 0; for (i = 0;i < loadmodel->numframes;i++) { @@ -172,7 +172,7 @@ static void Mod_Sprite_SharedSetup(const qbyte *datapointer, int version, const { loadmodel->sprite.sprdata_frames[realframes].texture = R_LoadTexture2D(loadmodel->texturepool, name, width, height, datapointer, TEXTYPE_RGBA, TEXF_ALPHA | (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_CLAMP | TEXF_PRECACHE | TEXF_PICMIP, NULL); // make fog version (just alpha) - pixbuf = Mem_Alloc(tempmempool, width*height*4); + pixbuf = (qbyte *)Mem_Alloc(tempmempool, width*height*4); Image_CopyMux(pixbuf, datapointer, width, height, false, false, false, 4, 4, alphaonlytable); loadmodel->sprite.sprdata_frames[realframes].fogtexture = R_LoadTexture2D(loadmodel->texturepool, fogname, width, height, pixbuf, TEXTYPE_RGBA, TEXF_ALPHA | (r_mipsprites.integer ? TEXF_MIPMAP : 0) | TEXF_CLAMP | TEXF_PRECACHE | TEXF_PICMIP, NULL); Mem_Free(pixbuf); @@ -209,7 +209,7 @@ void Mod_IDSP_Load(model_t *mod, void *buffer, void *bufferend) int version; const qbyte *datapointer; - datapointer = buffer; + datapointer = (qbyte *)buffer; loadmodel->type = mod_sprite; loadmodel->flags2 = EF_FULLBRIGHT; @@ -355,8 +355,8 @@ void Mod_IDS2_Load(model_t *mod, void *buffer, void *bufferend) } } - loadmodel->animscenes = Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes); - loadmodel->sprite.sprdata_frames = Mem_Alloc(loadmodel->mempool, sizeof(mspriteframe_t) * loadmodel->numframes); + loadmodel->animscenes = (animscene_t *)Mem_Alloc(loadmodel->mempool, sizeof(animscene_t) * loadmodel->numframes); + loadmodel->sprite.sprdata_frames = (mspriteframe_t *)Mem_Alloc(loadmodel->mempool, sizeof(mspriteframe_t) * loadmodel->numframes); modelradius = 0; for (i = 0;i < loadmodel->numframes;i++) diff --git a/mvm_cmds.c b/mvm_cmds.c index 5e1e65a1..09345132 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -250,7 +250,7 @@ void VM_M_writetofile(void) if( !file ) { return; } - + ent = PRVM_G_EDICT(OFS_PARM1); if(ent->priv.required->free) { @@ -480,7 +480,7 @@ void VM_M_setserverlistmaskstring( void ) } mask->active = true; - mask->tests[field] = (int) PRVM_G_FLOAT( OFS_PARM3 ); + mask->tests[field] = (serverlist_maskop_t) PRVM_G_FLOAT( OFS_PARM3 ); } /* @@ -533,7 +533,7 @@ void VM_M_setserverlistmasknumber( void ) } mask->active = true; - mask->tests[field] = (int) PRVM_G_FLOAT( OFS_PARM3 ); + mask->tests[field] = (serverlist_maskop_t) PRVM_G_FLOAT( OFS_PARM3 ); } @@ -654,7 +654,7 @@ void VM_M_setserverlistsort( void ) { VM_SAFEPARMCOUNT( 2, VM_M_setserverlistsort ); - serverlist_sortbyfield = (int) PRVM_G_FLOAT( OFS_PARM0 ); + serverlist_sortbyfield = (serverlist_infofield_t) PRVM_G_FLOAT( OFS_PARM0 ); serverlist_sortdescending = (qboolean) PRVM_G_FLOAT( OFS_PARM1 ); } diff --git a/netconn.c b/netconn.c index 748db1b6..dea11660 100755 --- a/netconn.c +++ b/netconn.c @@ -397,7 +397,7 @@ int NetConn_Read(lhnetsocket_t *mysocket, void *data, int maxlength, lhnetaddres { LHNETADDRESS_ToString(peeraddress, addressstring2, sizeof(addressstring2), true); Con_Printf("LHNET_Read(%p (%s), %p, %i, %p) = %i from %s:\n", mysocket, addressstring, data, maxlength, peeraddress, length, addressstring2); - Com_HexDumpToConsole(data, length); + Com_HexDumpToConsole((qbyte *)data, length); } else Con_Printf("LHNET_Read(%p (%s), %p, %i, %p) = %i\n", mysocket, addressstring, data, maxlength, peeraddress, length); @@ -420,7 +420,7 @@ int NetConn_Write(lhnetsocket_t *mysocket, const void *data, int length, const l LHNETADDRESS_ToString(LHNET_AddressFromSocket(mysocket), addressstring, sizeof(addressstring), true); LHNETADDRESS_ToString(peeraddress, addressstring2, sizeof(addressstring2), true); Con_Printf("LHNET_Write(%p (%s), %p, %i, %p (%s)) = %i%s\n", mysocket, addressstring, data, length, peeraddress, addressstring2, length, ret == length ? "" : " (ERROR)"); - Com_HexDumpToConsole(data, length); + Com_HexDumpToConsole((qbyte *)data, length); } return ret; } @@ -474,7 +474,7 @@ int NetConn_SendReliableMessage(netconn_t *conn, sizebuf_t *data) packetLen = NET_HEADERSIZE + dataLen; - header = (void *)sendbuffer; + header = (unsigned int *)sendbuffer; header[0] = BigLong(packetLen | (NETFLAG_DATA | eom)); header[1] = BigLong(conn->sendSequence); memcpy(sendbuffer + NET_HEADERSIZE, conn->sendMessage, dataLen); @@ -513,7 +513,7 @@ static void NetConn_SendMessageNext(netconn_t *conn) packetLen = NET_HEADERSIZE + dataLen; - header = (void *)sendbuffer; + header = (unsigned int *)sendbuffer; header[0] = BigLong(packetLen | (NETFLAG_DATA | eom)); header[1] = BigLong(conn->sendSequence); memcpy(sendbuffer + NET_HEADERSIZE, conn->sendMessage, dataLen); @@ -551,7 +551,7 @@ static void NetConn_ReSendMessage(netconn_t *conn) packetLen = NET_HEADERSIZE + dataLen; - header = (void *)sendbuffer; + header = (unsigned int *)sendbuffer; header[0] = BigLong(packetLen | (NETFLAG_DATA | eom)); header[1] = BigLong(conn->sendSequence - 1); memcpy(sendbuffer + NET_HEADERSIZE, conn->sendMessage, dataLen); @@ -574,7 +574,7 @@ qboolean NetConn_CanSendMessage(netconn_t *conn) int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data) { int packetLen; - int *header; + unsigned int *header; packetLen = NET_HEADERSIZE + data->cursize; @@ -592,7 +592,7 @@ int NetConn_SendUnreliableMessage(netconn_t *conn, sizebuf_t *data) } //#endif - header = (void *)sendbuffer; + header = (unsigned int *)sendbuffer; header[0] = BigLong(packetLen | NETFLAG_UNRELIABLE); header[1] = BigLong(conn->unreliableSendSequence); memcpy(sendbuffer + NET_HEADERSIZE, data->data, data->cursize); @@ -732,7 +732,7 @@ lhnetsocket_t *NetConn_ChooseServerSocketForAddress(lhnetaddress_t *address) netconn_t *NetConn_Open(lhnetsocket_t *mysocket, lhnetaddress_t *peeraddress) { netconn_t *conn; - conn = Mem_Alloc(netconn_mempool, sizeof(*conn)); + conn = (netconn_t *)Mem_Alloc(netconn_mempool, sizeof(*conn)); conn->mysocket = mysocket; conn->peeraddress = *peeraddress; conn->canSend = true; diff --git a/protocol.c b/protocol.c index 7ae6db28..509ffba0 100644 --- a/protocol.c +++ b/protocol.c @@ -63,7 +63,7 @@ protocolversion_t Protocol_EnumForName(const char *s) int i; for (i = 1;protocolversioninfo[i].name;i++) if (!strcasecmp(s, protocolversioninfo[i].name)) - return i; + return (protocolversion_t)i; return PROTOCOL_UNKNOWN; } @@ -77,7 +77,7 @@ protocolversion_t Protocol_EnumForNumber(int n) int i; for (i = 1;protocolversioninfo[i].name;i++) if (protocolversioninfo[i].number == n) - return i; + return (protocolversion_t)i; return PROTOCOL_UNKNOWN; } @@ -754,7 +754,7 @@ void EntityState_ReadFields(entity_state_t *e, unsigned int bits) // (client and server) allocates a new empty database entityframe_database_t *EntityFrame_AllocDatabase(mempool_t *mempool) { - return Mem_Alloc(mempool, sizeof(entityframe_database_t)); + return (entityframe_database_t *)Mem_Alloc(mempool, sizeof(entityframe_database_t)); } // (client and server) frees the database @@ -1081,7 +1081,7 @@ entity_state_t *EntityFrame4_GetReferenceEntity(entityframe4_database_t *d, int int oldmax = d->maxreferenceentities; entity_state_t *oldentity = d->referenceentity; d->maxreferenceentities = (number + 15) & ~7; - d->referenceentity = Mem_Alloc(d->mempool, d->maxreferenceentities * sizeof(*d->referenceentity)); + d->referenceentity = (entity_state_t *)Mem_Alloc(d->mempool, d->maxreferenceentities * sizeof(*d->referenceentity)); if (oldentity) { memcpy(d->referenceentity, oldentity, oldmax * sizeof(*d->referenceentity)); @@ -1104,7 +1104,7 @@ void EntityFrame4_AddCommitEntity(entityframe4_database_t *d, const entity_state { entity_state_t *oldentity = d->currentcommit->entity; d->currentcommit->maxentities += 8; - d->currentcommit->entity = Mem_Alloc(d->mempool, d->currentcommit->maxentities * sizeof(*d->currentcommit->entity)); + d->currentcommit->entity = (entity_state_t *)Mem_Alloc(d->mempool, d->currentcommit->maxentities * sizeof(*d->currentcommit->entity)); if (oldentity) { memcpy(d->currentcommit->entity, oldentity, d->currentcommit->numentities * sizeof(*d->currentcommit->entity)); @@ -1117,7 +1117,7 @@ void EntityFrame4_AddCommitEntity(entityframe4_database_t *d, const entity_state entityframe4_database_t *EntityFrame4_AllocDatabase(mempool_t *pool) { entityframe4_database_t *d; - d = Mem_Alloc(pool, sizeof(*d)); + d = (entityframe4_database_t *)Mem_Alloc(pool, sizeof(*d)); d->mempool = pool; EntityFrame4_ResetDatabase(d); return d; @@ -1448,7 +1448,7 @@ void EntityFrame4_WriteFrame(sizebuf_t *msg, entityframe4_database_t *d, int num entityframe5_database_t *EntityFrame5_AllocDatabase(mempool_t *pool) { entityframe5_database_t *d; - d = Mem_Alloc(pool, sizeof(*d)); + d = (entityframe5_database_t *)Mem_Alloc(pool, sizeof(*d)); EntityFrame5_ResetDatabase(d); return d; } @@ -1483,12 +1483,12 @@ void EntityFrame5_ExpandEdicts(entityframe5_database_t *d, int newmax) entity_state_t *oldstates = d->states; qbyte *oldvisiblebits = d->visiblebits; d->maxedicts = newmax; - data = Mem_Alloc(sv_mempool, d->maxedicts * sizeof(int) + d->maxedicts * sizeof(qbyte) + d->maxedicts * sizeof(int) + d->maxedicts * sizeof(entity_state_t) + (d->maxedicts+7)/8 * sizeof(qbyte)); - d->deltabits = (void *)data;data += d->maxedicts * sizeof(int); - d->priorities = (void *)data;data += d->maxedicts * sizeof(qbyte); - d->updateframenum = (void *)data;data += d->maxedicts * sizeof(int); - d->states = (void *)data;data += d->maxedicts * sizeof(entity_state_t); - d->visiblebits = (void *)data;data += (d->maxedicts+7)/8 * sizeof(qbyte); + data = (qbyte *)Mem_Alloc(sv_mempool, d->maxedicts * sizeof(int) + d->maxedicts * sizeof(qbyte) + d->maxedicts * sizeof(int) + d->maxedicts * sizeof(entity_state_t) + (d->maxedicts+7)/8 * sizeof(qbyte)); + d->deltabits = (int *)data;data += d->maxedicts * sizeof(int); + d->priorities = (qbyte *)data;data += d->maxedicts * sizeof(qbyte); + d->updateframenum = (int *)data;data += d->maxedicts * sizeof(int); + d->states = (entity_state_t *)data;data += d->maxedicts * sizeof(entity_state_t); + d->visiblebits = (qbyte *)data;data += (d->maxedicts+7)/8 * sizeof(qbyte); if (oldmaxedicts) { memcpy(d->deltabits, olddeltabits, oldmaxedicts * sizeof(int)); diff --git a/protocol.h b/protocol.h index b749fe6a..4adda06a 100644 --- a/protocol.h +++ b/protocol.h @@ -352,7 +352,7 @@ typedef struct entity_state_t; // baseline state values -entity_state_t defaultstate; +extern entity_state_t defaultstate; // reads a quake entity from the network stream void EntityFrameQuake_ReadEntity(int bits); // writes a list of quake entities to the network stream diff --git a/prvm_cmds.c b/prvm_cmds.c index 44872aff..e3f63929 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -252,24 +252,20 @@ void VM_normalize (void) { float *value1; vec3_t newvalue; - float new; + double f; VM_SAFEPARMCOUNT(1,VM_normalize); value1 = PRVM_G_VECTOR(OFS_PARM0); - new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2]; - new = sqrt(new); - - if (new == 0) - newvalue[0] = newvalue[1] = newvalue[2] = 0; - else + f = VectorLength2(value1); + if (f) { - new = 1/new; - newvalue[0] = value1[0] * new; - newvalue[1] = value1[1] * new; - newvalue[2] = value1[2] * new; + f = 1.0 / sqrt(f); + VectorScale(value1, f, newvalue); } + else + VectorClear(newvalue); VectorCopy (newvalue, PRVM_G_VECTOR(OFS_RETURN)); } @@ -283,17 +279,8 @@ scalar vlen(vector) */ void VM_vlen (void) { - float *value1; - float new; - VM_SAFEPARMCOUNT(1,VM_vlen); - - value1 = PRVM_G_VECTOR(OFS_PARM0); - - new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2]; - new = sqrt(new); - - PRVM_G_FLOAT(OFS_RETURN) = new; + PRVM_G_FLOAT(OFS_RETURN) = VectorLength(PRVM_G_VECTOR(OFS_PARM0)); } /* @@ -2695,7 +2682,7 @@ void VM_cin_setstate( void ) name = PRVM_G_STRING( OFS_PARM0 ); VM_CheckEmptyString( name ); - state = PRVM_G_FLOAT( OFS_PARM1 ); + state = (clvideostate_t)PRVM_G_FLOAT( OFS_PARM1 ); video = CL_GetVideo( name ); if( video && state > CLVIDEO_UNUSED && state < CLVIDEO_STATECOUNT ) diff --git a/prvm_edict.c b/prvm_edict.c index 168e62ae..7c87aa3e 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -57,7 +57,7 @@ void PRVM_MEM_Alloc(void) prog->edictprivate_size = max(prog->edictprivate_size,(int)sizeof(prvm_edict_private_t)); // alloc edicts - prog->edicts = Mem_Alloc(prog->progs_mempool,prog->limit_edicts * sizeof(prvm_edict_t)); + prog->edicts = (prvm_edict_t *)Mem_Alloc(prog->progs_mempool,prog->limit_edicts * sizeof(prvm_edict_t)); // alloc edict private space prog->edictprivate = Mem_Alloc(prog->progs_mempool, prog->max_edicts * prog->edictprivate_size); @@ -373,7 +373,7 @@ char *PRVM_ValueString (etype_t type, prvm_eval_t *val) mfunction_t *f; int n; - type &= ~DEF_SAVEGLOBAL; + type = (etype_t)((int) type & ~DEF_SAVEGLOBAL); switch (type) { @@ -433,7 +433,7 @@ char *PRVM_UglyValueString (etype_t type, prvm_eval_t *val) ddef_t *def; mfunction_t *f; - type &= ~DEF_SAVEGLOBAL; + type = (etype_t)((int)type & ~DEF_SAVEGLOBAL); switch (type) { @@ -510,7 +510,7 @@ char *PRVM_GlobalString (int ofs) sprintf (line,"%i(?)", ofs); else { - s = PRVM_ValueString (def->type, val); + s = PRVM_ValueString ((etype_t)def->type, (prvm_eval_t *)val); sprintf (line,"%i(%s)%s", ofs, PRVM_GetString(def->s_name), s); } @@ -600,7 +600,7 @@ void PRVM_ED_Print(prvm_edict_t *ed) strcat(tempstring, " "); strcat(tempstring, " "); - name = PRVM_ValueString(d->type, (prvm_eval_t *)v); + name = PRVM_ValueString((etype_t)d->type, (prvm_eval_t *)v); if (strlen(name) > 256) { memcpy (tempstring2, name, 256); @@ -661,7 +661,7 @@ void PRVM_ED_Write (qfile_t *f, prvm_edict_t *ed) continue; FS_Printf(f,"\"%s\" ",name); - FS_Printf(f,"\"%s\"\n", PRVM_UglyValueString(d->type, (prvm_eval_t *)v)); + FS_Printf(f,"\"%s\"\n", PRVM_UglyValueString((etype_t)d->type, (prvm_eval_t *)v)); } FS_Print(f, "}\n"); @@ -813,7 +813,7 @@ void PRVM_ED_WriteGlobals (qfile_t *f) name = PRVM_GetString(def->s_name); FS_Printf(f,"\"%s\" ", name); - FS_Printf(f,"\"%s\"\n", PRVM_UglyValueString(type, (prvm_eval_t *)&prog->globals.generic[def->ofs])); + FS_Printf(f,"\"%s\"\n", PRVM_UglyValueString((etype_t)type, (prvm_eval_t *)&prog->globals.generic[def->ofs])); } FS_Print(f,"}\n"); } @@ -1264,7 +1264,7 @@ void PRVM_LoadLNO( const char *progname ) { (unsigned int)LittleLong( header[ 4 ] ) == (unsigned int)prog->progs->numfielddefs && (unsigned int)LittleLong( header[ 5 ] ) == (unsigned int)prog->progs->numstatements ) { - prog->statement_linenums = Mem_Alloc(prog->progs_mempool, prog->progs->numstatements * sizeof( int ) ); + prog->statement_linenums = (int *)Mem_Alloc(prog->progs_mempool, prog->progs->numstatements * sizeof( int ) ); memcpy( prog->statement_linenums, (int *) lno + 6, prog->progs->numstatements * sizeof( int ) ); } Mem_Free( lno ); @@ -1325,7 +1325,7 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, char **required // so allocate a new place for it infielddefs = (ddef_t *)((qbyte *)prog->progs + prog->progs->ofs_fielddefs); // ( + DPFIELDS ) - prog->fielddefs = Mem_Alloc(prog->progs_mempool, (prog->progs->numfielddefs + numrequiredfields) * sizeof(ddef_t)); + prog->fielddefs = (ddef_t *)Mem_Alloc(prog->progs_mempool, (prog->progs->numfielddefs + numrequiredfields) * sizeof(ddef_t)); prog->statements = (dstatement_t *)((qbyte *)prog->progs + prog->progs->ofs_statements); @@ -1343,7 +1343,7 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, char **required prog->statements[i].c = LittleShort(prog->statements[i].c); } - prog->functions = Mem_Alloc(prog->progs_mempool, sizeof(mfunction_t) * prog->progs->numfunctions); + prog->functions = (mfunction_t *)Mem_Alloc(prog->progs_mempool, sizeof(mfunction_t) * prog->progs->numfunctions); for (i = 0;i < prog->progs->numfunctions;i++) { prog->functions[i].first_statement = LittleLong (dfunctions[i].first_statement); @@ -1558,7 +1558,7 @@ void PRVM_Fields_f (void) if(!PRVM_SetProgFromString(Cmd_Argv(1))) return; - counts = Mem_Alloc(tempmempool, prog->progs->numfielddefs * sizeof(int)); + counts = (int *)Mem_Alloc(tempmempool, prog->progs->numfielddefs * sizeof(int)); for (ednum = 0;ednum < prog->max_edicts;ednum++) { ed = PRVM_EDICT_NUM(ednum); @@ -1701,7 +1701,7 @@ void PRVM_Global_f(void) if( !global ) Con_Printf( "No global '%s' in %s!\n", Cmd_Argv(2), Cmd_Argv(1) ); else - Con_Printf( "%s: %s\n", Cmd_Argv(2), PRVM_ValueString( global->type, (prvm_eval_t *) &prog->globals.generic[ global->ofs ] ) ); + Con_Printf( "%s: %s\n", Cmd_Argv(2), PRVM_ValueString( (etype_t)global->type, (prvm_eval_t *) &prog->globals.generic[ global->ofs ] ) ); PRVM_End; } @@ -1887,8 +1887,8 @@ int PRVM_SetEngineString(const char *s) const char **oldstrings = prog->knownstrings; const qbyte *oldstrings_freeable = prog->knownstrings_freeable; prog->maxknownstrings += 128; - prog->knownstrings = PRVM_Alloc(prog->maxknownstrings * sizeof(char *)); - prog->knownstrings_freeable = PRVM_Alloc(prog->maxknownstrings * sizeof(qbyte)); + prog->knownstrings = (const char **)PRVM_Alloc(prog->maxknownstrings * sizeof(char *)); + prog->knownstrings_freeable = (qbyte *)PRVM_Alloc(prog->maxknownstrings * sizeof(qbyte)); if (prog->numknownstrings) { memcpy((char **)prog->knownstrings, oldstrings, prog->numknownstrings * sizeof(char *)); @@ -1917,8 +1917,8 @@ int PRVM_AllocString(size_t bufferlength, char **pointer) const char **oldstrings = prog->knownstrings; const qbyte *oldstrings_freeable = prog->knownstrings_freeable; prog->maxknownstrings += 128; - prog->knownstrings = PRVM_Alloc(prog->maxknownstrings * sizeof(char *)); - prog->knownstrings_freeable = PRVM_Alloc(prog->maxknownstrings * sizeof(qbyte)); + prog->knownstrings = (const char **)PRVM_Alloc(prog->maxknownstrings * sizeof(char *)); + prog->knownstrings_freeable = (qbyte *)PRVM_Alloc(prog->maxknownstrings * sizeof(qbyte)); if (prog->numknownstrings) { memcpy((char **)prog->knownstrings, oldstrings, prog->numknownstrings * sizeof(char *)); @@ -1928,7 +1928,7 @@ int PRVM_AllocString(size_t bufferlength, char **pointer) prog->numknownstrings++; } prog->firstfreeknownstring = i + 1; - prog->knownstrings[i] = PRVM_Alloc(bufferlength); + prog->knownstrings[i] = (char *)PRVM_Alloc(bufferlength); prog->knownstrings_freeable[i] = true; if (pointer) *pointer = (char *)(prog->knownstrings[i]); diff --git a/qtypes.h b/qtypes.h index 4e82c72a..22ac69a6 100644 --- a/qtypes.h +++ b/qtypes.h @@ -7,7 +7,11 @@ typedef unsigned char qbyte; #undef true #undef false +#ifndef __cplusplus typedef enum {false, true} qboolean; +#else +typedef bool qboolean; +#endif #if defined(WIN32) && !defined(WIN64) # define ssize_t long @@ -18,8 +22,8 @@ typedef enum {false, true} qboolean; #endif #ifndef FALSE -#define FALSE 0 -#define TRUE 1 +#define FALSE false +#define TRUE true #endif // up / down diff --git a/quakedef.h b/quakedef.h index 45aad902..54c7fe3a 100644 --- a/quakedef.h +++ b/quakedef.h @@ -35,6 +35,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "qtypes.h" extern char *buildstring; +extern char engineversion[128]; #define GAMENAME "id1" diff --git a/r_explosion.c b/r_explosion.c index 430e399c..4ce210da 100644 --- a/r_explosion.c +++ b/r_explosion.c @@ -186,7 +186,7 @@ static void R_DrawExplosionCallback(const void *calldata1, int calldata2) float alpha; rmeshstate_t m; const explosion_t *e; - e = calldata1; + e = (explosion_t *)calldata1; GL_BlendFunc(GL_SRC_ALPHA, GL_ONE); GL_DepthMask(false); diff --git a/r_lightning.c b/r_lightning.c index 639df83f..15ac5933 100644 --- a/r_lightning.c +++ b/r_lightning.c @@ -114,9 +114,9 @@ void r_lightningbeams_setuptexture(void) int x, y; qbyte *data, *noise1, *noise2; - data = Mem_Alloc(tempmempool, BEAMWIDTH * BEAMHEIGHT * 4); - noise1 = Mem_Alloc(tempmempool, BEAMHEIGHT * BEAMHEIGHT); - noise2 = Mem_Alloc(tempmempool, BEAMHEIGHT * BEAMHEIGHT); + data = (qbyte *)Mem_Alloc(tempmempool, BEAMWIDTH * BEAMHEIGHT * 4); + noise1 = (qbyte *)Mem_Alloc(tempmempool, BEAMHEIGHT * BEAMHEIGHT); + noise2 = (qbyte *)Mem_Alloc(tempmempool, BEAMHEIGHT * BEAMHEIGHT); fractalnoise(noise1, BEAMHEIGHT, BEAMHEIGHT / 8); fractalnoise(noise2, BEAMHEIGHT, BEAMHEIGHT / 16); @@ -229,7 +229,7 @@ float beamrepeatscale; void R_DrawLightningBeamCallback(const void *calldata1, int calldata2) { - const beam_t *b = calldata1; + const beam_t *b = (beam_t *)calldata1; rmeshstate_t m; vec3_t beamdir, right, up, offset; float length, t1, t2; diff --git a/r_shadow.c b/r_shadow.c index a6570c6d..79725fde 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -733,7 +733,7 @@ int *R_Shadow_ResizeShadowElements(int numtris) maxshadowelements = numtris * 24; if (shadowelements) Mem_Free(shadowelements); - shadowelements = Mem_Alloc(r_shadow_mempool, maxshadowelements * sizeof(int)); + shadowelements = (int *)Mem_Alloc(r_shadow_mempool, maxshadowelements * sizeof(int)); } return shadowelements; } @@ -749,8 +749,8 @@ static void R_Shadow_EnlargeLeafSurfaceBuffer(int numleafs, int numsurfaces) if (r_shadow_buffer_leaflist) Mem_Free(r_shadow_buffer_leaflist); r_shadow_buffer_numleafpvsbytes = numleafpvsbytes; - r_shadow_buffer_leafpvs = Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numleafpvsbytes); - r_shadow_buffer_leaflist = Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numleafpvsbytes * 8 * sizeof(*r_shadow_buffer_leaflist)); + r_shadow_buffer_leafpvs = (qbyte *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numleafpvsbytes); + r_shadow_buffer_leaflist = (int *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numleafpvsbytes * 8 * sizeof(*r_shadow_buffer_leaflist)); } if (r_shadow_buffer_numsurfacepvsbytes < numsurfacepvsbytes) { @@ -759,8 +759,8 @@ static void R_Shadow_EnlargeLeafSurfaceBuffer(int numleafs, int numsurfaces) if (r_shadow_buffer_surfacelist) Mem_Free(r_shadow_buffer_surfacelist); r_shadow_buffer_numsurfacepvsbytes = numsurfacepvsbytes; - r_shadow_buffer_surfacepvs = Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numsurfacepvsbytes); - r_shadow_buffer_surfacelist = Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numsurfacepvsbytes * 8 * sizeof(*r_shadow_buffer_surfacelist)); + r_shadow_buffer_surfacepvs = (qbyte *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numsurfacepvsbytes); + r_shadow_buffer_surfacelist = (int *)Mem_Alloc(r_shadow_mempool, r_shadow_buffer_numsurfacepvsbytes * 8 * sizeof(*r_shadow_buffer_surfacelist)); } } @@ -774,8 +774,8 @@ void R_Shadow_PrepareShadowMark(int numtris) Mem_Free(shadowmark); if (shadowmarklist) Mem_Free(shadowmarklist); - shadowmark = Mem_Alloc(r_shadow_mempool, maxshadowmark * sizeof(*shadowmark)); - shadowmarklist = Mem_Alloc(r_shadow_mempool, maxshadowmark * sizeof(*shadowmarklist)); + shadowmark = (int *)Mem_Alloc(r_shadow_mempool, maxshadowmark * sizeof(*shadowmark)); + shadowmarklist = (int *)Mem_Alloc(r_shadow_mempool, maxshadowmark * sizeof(*shadowmarklist)); shadowmarkcount = 0; } shadowmarkcount++; @@ -802,8 +802,8 @@ int R_Shadow_ConstructShadowVolume(int innumvertices, int innumtris, const int * Mem_Free(vertexupdate); if (vertexremap) Mem_Free(vertexremap); - vertexupdate = Mem_Alloc(r_shadow_mempool, maxvertexupdate * sizeof(int)); - vertexremap = Mem_Alloc(r_shadow_mempool, maxvertexupdate * sizeof(int)); + vertexupdate = (int *)Mem_Alloc(r_shadow_mempool, maxvertexupdate * sizeof(int)); + vertexremap = (int *)Mem_Alloc(r_shadow_mempool, maxvertexupdate * sizeof(int)); vertexupdatenum = 0; } vertexupdatenum++; @@ -1005,7 +1005,7 @@ static void R_Shadow_MakeTextures(void) r_shadow_attenscale = r_shadow_lightattenuationscale.value; #define ATTEN2DSIZE 64 #define ATTEN3DSIZE 32 - data = Mem_Alloc(tempmempool, max(ATTEN3DSIZE*ATTEN3DSIZE*ATTEN3DSIZE*4, ATTEN2DSIZE*ATTEN2DSIZE*4)); + data = (qbyte *)Mem_Alloc(tempmempool, max(ATTEN3DSIZE*ATTEN3DSIZE*ATTEN3DSIZE*4, ATTEN2DSIZE*ATTEN2DSIZE*4)); for (y = 0;y < ATTEN2DSIZE;y++) { for (x = 0;x < ATTEN2DSIZE;x++) @@ -2606,13 +2606,13 @@ void R_RTLight_Compile(rtlight_t *rtlight) R_Shadow_EnlargeLeafSurfaceBuffer(model->brush.num_leafs, model->num_surfaces); model->GetLightInfo(ent, rtlight->shadoworigin, rtlight->radius, rtlight->cullmins, rtlight->cullmaxs, r_shadow_buffer_leaflist, r_shadow_buffer_leafpvs, &numleafs, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces); numleafpvsbytes = (model->brush.num_leafs + 7) >> 3; - data = Mem_Alloc(r_shadow_mempool, sizeof(int) * numleafs + numleafpvsbytes + sizeof(int) * numsurfaces); + data = (qbyte *)Mem_Alloc(r_shadow_mempool, sizeof(int) * numleafs + numleafpvsbytes + sizeof(int) * numsurfaces); rtlight->static_numleafs = numleafs; rtlight->static_numleafpvsbytes = numleafpvsbytes; - rtlight->static_leaflist = (void *)data;data += sizeof(int) * numleafs; - rtlight->static_leafpvs = (void *)data;data += numleafpvsbytes; + rtlight->static_leaflist = (int *)data;data += sizeof(int) * numleafs; + rtlight->static_leafpvs = (qbyte *)data;data += numleafpvsbytes; rtlight->static_numsurfaces = numsurfaces; - rtlight->static_surfacelist = (void *)data;data += sizeof(int) * numsurfaces; + rtlight->static_surfacelist = (int *)data;data += sizeof(int) * numsurfaces; if (numleafs) memcpy(rtlight->static_leaflist, r_shadow_buffer_leaflist, rtlight->static_numleafs * sizeof(*rtlight->static_leaflist)); if (numleafpvsbytes) @@ -3003,7 +3003,7 @@ rtexture_t *R_Shadow_LoadCubemap(const char *basename) { cubemapsize = image_width; // note this clears to black, so unavailable sides are black - cubemappixels = Mem_Alloc(tempmempool, 6*cubemapsize*cubemapsize*4); + cubemappixels = (qbyte *)Mem_Alloc(tempmempool, 6*cubemapsize*cubemapsize*4); } // copy the image with any flipping needed by the suffix (px and posx types don't need flipping) if (cubemappixels) @@ -3060,7 +3060,7 @@ void R_Shadow_FreeCubemaps(void) dlight_t *R_Shadow_NewWorldLight(void) { dlight_t *light; - light = Mem_Alloc(r_shadow_mempool, sizeof(dlight_t)); + light = (dlight_t *)Mem_Alloc(r_shadow_mempool, sizeof(dlight_t)); light->next = r_shadow_worldlightchain; r_shadow_worldlightchain = light; return light; @@ -3135,7 +3135,7 @@ void R_Shadow_DrawLightSpriteCallback(const void *calldata1, int calldata2) { float intensity; const dlight_t *light; - light = calldata1; + light = (dlight_t *)calldata1; intensity = 0.5; if (light->selected) intensity = 0.75 + 0.25 * sin(realtime * M_PI * 4.0); @@ -3306,7 +3306,7 @@ void R_Shadow_SaveWorldLights(void) { bufmaxchars = bufchars + strlen(line) + 2048; oldbuf = buf; - buf = Mem_Alloc(tempmempool, bufmaxchars); + buf = (char *)Mem_Alloc(tempmempool, bufmaxchars); if (oldbuf) { if (bufchars) diff --git a/r_sky.c b/r_sky.c index d6bea016..dfb3af5d 100644 --- a/r_sky.c +++ b/r_sky.c @@ -113,7 +113,7 @@ int R_LoadSkyBox(void) } } } - temp = Mem_Alloc(tempmempool, image_width*image_height*4); + temp = (qbyte *)Mem_Alloc(tempmempool, image_width*image_height*4); Image_CopyMux (temp, image_rgba, image_width, image_height, suffix[j][i].flipx, suffix[j][i].flipy, suffix[j][i].flipdiagonal, 4, 4, indices); skyboxside[i] = R_LoadTexture2D(skytexturepool, va("skyboxside%d", i), image_width, image_height, temp, TEXTYPE_RGBA, TEXF_CLAMP | TEXF_PRECACHE, NULL); Mem_Free(image_rgba); diff --git a/r_sprites.c b/r_sprites.c index 16b493be..ccc9bb0d 100644 --- a/r_sprites.c +++ b/r_sprites.c @@ -79,7 +79,7 @@ static void R_DrawSpriteImage (int additive, int depthdisable, mspriteframe_t *f void R_DrawSpriteModelCallback(const void *calldata1, int calldata2) { - const entity_render_t *ent = calldata1; + const entity_render_t *ent = (entity_render_t *)calldata1; int i; vec3_t left, up, org, color, diffusecolor, diffusenormal; mspriteframe_t *frame; diff --git a/render.h b/render.h index c89b8ff4..ed658f85 100644 --- a/render.h +++ b/render.h @@ -24,11 +24,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // flag arrays used for visibility checking on world model // (all other entities have no per-surface/per-leaf visibility checks) // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_clusters -qbyte r_pvsbits[(32768+7)>>3]; +extern qbyte r_pvsbits[(32768+7)>>3]; // TODO: dynamic resize according to r_refdef.worldmodel->brush.num_leafs -qbyte r_worldleafvisible[32768]; +extern qbyte r_worldleafvisible[32768]; // TODO: dynamic resize according to r_refdef.worldmodel->num_surfaces -qbyte r_worldsurfacevisible[262144]; +extern qbyte r_worldsurfacevisible[262144]; extern matrix4x4_t r_identitymatrix; diff --git a/server.h b/server.h index 3cf0fcf2..ad31f39d 100644 --- a/server.h +++ b/server.h @@ -321,6 +321,8 @@ qboolean SV_PlayerCheckGround (prvm_edict_t *ent); qboolean SV_CheckBottom (prvm_edict_t *ent); qboolean SV_movestep (prvm_edict_t *ent, vec3_t move, qboolean relink); +struct trace_s SV_ClipMoveToEntity(prvm_edict_t *ent, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int movetype, int hitsupercontents); + void SV_WriteClientdataToMessage (client_t *client, prvm_edict_t *ent, sizebuf_t *msg, int *stats); void SV_MoveToGoal (void); diff --git a/snd_alsa.c b/snd_alsa.c index b230bf52..30237fc3 100644 --- a/snd_alsa.c +++ b/snd_alsa.c @@ -282,7 +282,7 @@ int SNDDMA_GetDMAPos (void) offset *= shm->format.channels; nframes *= shm->format.channels; shm->samplepos = offset; - shm->buffer = areas->addr; + shm->buffer = (qbyte *)areas->addr; return shm->samplepos; } diff --git a/snd_main.c b/snd_main.c index fafb23c1..11a24406 100644 --- a/snd_main.c +++ b/snd_main.c @@ -124,7 +124,7 @@ void S_Startup(void) shm->format.channels = 2; shm->samples = 32768; shm->samplepos = 0; - shm->buffer = Mem_Alloc(snd_mempool, shm->format.channels * shm->samples * shm->format.width); + shm->buffer = (qbyte *)Mem_Alloc(snd_mempool, shm->format.channels * shm->samples * shm->format.width); } else { @@ -269,7 +269,7 @@ sfx_t *S_FindName (const char *name) return sfx; // Add a sfx_t struct for this sound - sfx = Mem_Alloc (snd_mempool, sizeof (*sfx)); + sfx = (sfx_t *)Mem_Alloc (snd_mempool, sizeof (*sfx)); memset (sfx, 0, sizeof(*sfx)); strlcpy (sfx->name, name, sizeof (sfx->name)); sfx->memsize = sizeof(*sfx); @@ -699,7 +699,7 @@ void S_StopAllSounds (void) memset(channels, 0, MAX_CHANNELS * sizeof(channel_t)); // Clear sound buffer - pbuf = S_LockBuffer(); + pbuf = (unsigned char *)S_LockBuffer(); if (pbuf != NULL) { int setsize = shm->samples * shm->format.width; diff --git a/snd_ogg.c b/snd_ogg.c index 7cba800b..7e37fe7e 100644 --- a/snd_ogg.c +++ b/snd_ogg.c @@ -413,9 +413,9 @@ static const sfxbuffer_t* OGG_FetchSound (channel_t* ch, unsigned int start, uns unsigned int factor; size_t buff_len; - per_ch = ch->fetcher_data; + per_ch = (ogg_stream_perchannel_t *)ch->fetcher_data; sfx = ch->sfx; - per_sfx = sfx->fetcher_data; + per_sfx = (ogg_stream_persfx_t *)sfx->fetcher_data; format = &sfx->format; buff_len = STREAM_BUFFER_SIZE(format); @@ -426,9 +426,9 @@ static const sfxbuffer_t* OGG_FetchSound (channel_t* ch, unsigned int start, uns ogg_stream_persfx_t* per_sfx; memsize = sizeof (*per_ch) - sizeof (per_ch->sb.data) + buff_len; - per_ch = Mem_Alloc (snd_mempool, memsize); + per_ch = (ogg_stream_perchannel_t *)Mem_Alloc (snd_mempool, memsize); sfx->memsize += memsize; - per_sfx = sfx->fetcher_data; + per_sfx = (ogg_stream_persfx_t *)sfx->fetcher_data; // Open it with the VorbisFile API per_ch->ov_decode.buffer = per_sfx->file; @@ -518,7 +518,7 @@ static void OGG_FetchEnd (channel_t* ch) { ogg_stream_perchannel_t* per_ch; - per_ch = ch->fetcher_data; + per_ch = (ogg_stream_perchannel_t *)ch->fetcher_data; if (per_ch != NULL) { size_t buff_len; @@ -544,7 +544,7 @@ OGG_FreeSfx */ static void OGG_FreeSfx (sfx_t* sfx) { - ogg_stream_persfx_t* per_sfx = sfx->fetcher_data; + ogg_stream_persfx_t* per_sfx = (ogg_stream_persfx_t *)sfx->fetcher_data; // Free the Ogg Vorbis file Mem_Free(per_sfx->file); @@ -621,7 +621,7 @@ qboolean OGG_LoadVorbisFile (const char *filename, sfx_t *s) ogg_stream_persfx_t* per_sfx; Con_DPrintf ("\"%s\" will be streamed\n", filename); - per_sfx = Mem_Alloc (snd_mempool, sizeof (*per_sfx)); + per_sfx = (ogg_stream_persfx_t *)Mem_Alloc (snd_mempool, sizeof (*per_sfx)); s->memsize += sizeof (*per_sfx); per_sfx->file = data; per_sfx->filesize = fs_filesize; @@ -652,7 +652,7 @@ qboolean OGG_LoadVorbisFile (const char *filename, sfx_t *s) Con_DPrintf ("\"%s\" will be cached\n", filename); // Decode it - buff = Mem_Alloc (snd_mempool, (int)len); + buff = (char *)Mem_Alloc (snd_mempool, (int)len); done = 0; bs = 0; #if BYTE_ORDER == LITTLE_ENDIAN @@ -668,7 +668,7 @@ qboolean OGG_LoadVorbisFile (const char *filename, sfx_t *s) // Resample it memsize = (size_t)len + sizeof (*sb) - sizeof (sb->data); - sb = Mem_Alloc (snd_mempool, memsize); + sb = (sfxbuffer_t *)Mem_Alloc (snd_mempool, memsize); s->memsize += memsize; s->fetcher_data = sb; s->fetcher = &wav_fetcher; diff --git a/snd_sdl.c b/snd_sdl.c index ddd87fe1..83964094 100644 --- a/snd_sdl.c +++ b/snd_sdl.c @@ -92,7 +92,7 @@ qboolean SNDDMA_Init(void) // Init the shm structure memset( (void*) shm, 0, sizeof(*shm) ); - + shm->format.channels = 2; //stereo shm->format.width = 2; @@ -106,7 +106,7 @@ qboolean SNDDMA_Init(void) shm->samplepos = 0; shm->samples = AUDIO_SDL_SAMPLES * AUDIO_LOCALFACTOR; shm->bufferlength = shm->samples * shm->format.width; - shm->buffer = Mem_Alloc( snd_mempool, shm->bufferlength ); + shm->buffer = (qbyte *)Mem_Alloc( snd_mempool, shm->bufferlength ); // Init the as structure as.buffer = shm->buffer; @@ -120,18 +120,18 @@ qboolean SNDDMA_Init(void) spec.format = AUDIO_S16SYS; spec.freq = shm->format.speed; spec.userdata = NULL; - spec.samples = AUDIO_SDL_SAMPLES; - + spec.samples = AUDIO_SDL_SAMPLES; + if( SDL_OpenAudio( &spec, NULL ) ) { Con_Print( "Failed to open the audio device!\n" ); - Con_DPrintf( + Con_DPrintf( "Audio Specification:\n" "\tChannels : %i\n" "\tFormat : %x\n" "\tFrequency : %i\n" - "\tBuffersize: %i Bytes(%i Samples)\n", + "\tBuffersize: %i Bytes(%i Samples)\n", spec.channels, spec.format, spec.freq, shm->bufferlength , spec.samples ); - Mem_Free( shm->buffer ); + Mem_Free( shm->buffer ); return false; } diff --git a/snd_wav.c b/snd_wav.c index 1aa9690e..a972ef41 100644 --- a/snd_wav.c +++ b/snd_wav.c @@ -225,7 +225,7 @@ WAV_FetchSound */ static const sfxbuffer_t* WAV_FetchSound (channel_t* ch, unsigned int start, unsigned int nbsamples) { - return ch->sfx->fetcher_data; + return (sfxbuffer_t *)ch->sfx->fetcher_data; } /* @@ -235,7 +235,7 @@ WAV_FreeSfx */ static void WAV_FreeSfx (sfx_t* sfx) { - sfxbuffer_t* sb = sfx->fetcher_data; + sfxbuffer_t* sb = (sfxbuffer_t *)sfx->fetcher_data; // Free the sound buffer sfx->memsize -= (sb->length * sfx->format.channels * sfx->format.width) + sizeof (*sb) - sizeof (sb->data); @@ -295,7 +295,7 @@ qboolean S_LoadWavFile (const char *filename, sfx_t *s) len = len * info.width * info.channels; memsize = len + sizeof (*sb) - sizeof (sb->data); - sb = Mem_Alloc (snd_mempool, memsize); + sb = (sfxbuffer_t *)Mem_Alloc (snd_mempool, memsize); if (sb == NULL) { Con_Printf("failed to allocate memory for sound \"%s\"\n", s->name); diff --git a/sv_main.c b/sv_main.c index 4cb6c957..7935327f 100644 --- a/sv_main.c +++ b/sv_main.c @@ -1712,7 +1712,7 @@ void SV_SpawnServer (const char *server) // progs fields, often accessed by server prog->edictsfields = PR_Alloc(prog->max_edicts * prog->edict_size);*/ // used by PushMove to move back pushed entities - sv.moved_edicts = PRVM_Alloc(prog->max_edicts * sizeof(prvm_edict_t *)); + sv.moved_edicts = (prvm_edict_t **)PRVM_Alloc(prog->max_edicts * sizeof(prvm_edict_t *)); /*for (i = 0;i < prog->max_edicts;i++) { ent = prog->edicts + i; @@ -1850,7 +1850,7 @@ void SV_VM_CB_BeginIncreaseEdicts(void) prvm_edict_t *ent; PRVM_Free( sv.moved_edicts ); - sv.moved_edicts = PRVM_Alloc(prog->max_edicts * sizeof(prvm_edict_t *)); + sv.moved_edicts = (prvm_edict_t **)PRVM_Alloc(prog->max_edicts * sizeof(prvm_edict_t *)); // links don't survive the transition, so unlink everything for (i = 0, ent = prog->edicts;i < prog->max_edicts;i++, ent++) diff --git a/sv_phys.c b/sv_phys.c index 60e36273..123ea8fc 100644 --- a/sv_phys.c +++ b/sv_phys.c @@ -359,7 +359,7 @@ int SV_FlyMove (prvm_edict_t *ent, float time, float *stepnormal) // run the impact function if (impact) { - SV_Impact(ent, trace.ent); + SV_Impact(ent, (prvm_edict_t *)trace.ent); // break if removed by the impact function if (ent->priv.server->free) @@ -512,7 +512,7 @@ trace_t SV_PushEntity (prvm_edict_t *ent, vec3_t push) SV_LinkEdict (ent, true); if (trace.ent && (!((int)ent->fields.server->flags & FL_ONGROUND) || ent->fields.server->groundentity != PRVM_EDICT_TO_PROG(trace.ent))) - SV_Impact (ent, trace.ent); + SV_Impact (ent, (prvm_edict_t *)trace.ent); return trace; } @@ -523,7 +523,6 @@ SV_PushMove ============ */ -trace_t SV_ClipMoveToEntity (prvm_edict_t *ent, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int movetype, int hitsupercontents); void SV_PushMove (prvm_edict_t *pusher, float movetime) { int i, e, index; diff --git a/ui.c b/ui.c index 1e4ed791..bcb46b8a 100644 --- a/ui.c +++ b/ui.c @@ -136,8 +136,8 @@ void UI_Key(ui_itemlist_t list, int key, int ascii) ui_item_t UI_CloneItem(ui_item_t item) { ui_item_t clone; - clone = UI_Alloc(item->size); - clone = memcpy(clone, item, item->size); + clone = (ui_item_t)UI_Alloc(item->size); + memcpy(clone, item, item->size); return clone; } @@ -184,7 +184,7 @@ void UI_FreeItemByName(ui_itemlist_t list, const char *name) // itemlist stuff ui_itemlist_t UI_CreateItemList(void) { - return UI_Alloc(sizeof(ui_itemlist_t)); + return (ui_itemlist_t)UI_Alloc(sizeof(ui_itemlist_t)); } ui_itemlist_t UI_CloneItemList(ui_itemlist_t list) diff --git a/ui.h b/ui.h index 1f20e185..e4aff297 100644 --- a/ui.h +++ b/ui.h @@ -29,7 +29,7 @@ struct ui_item_s // used to build the item list struct ui_item_s *prev, *next; // items are allowed to be freed everywhere - // called for system events (true means message processed) + // called for system events (true means message processed) int (*eventhandler)(ui_itemlist_t list, ui_item_t self, ui_message_t *in, ui_message_queue_t *out); // z-order (the higher, the later it is drawn) @@ -126,7 +126,7 @@ typedef struct ui_button_s *ui_button_t; typedef struct ui_label_s *ui_label_t; typedef struct ui_text_s *ui_text_t; -struct ui_label_t +struct ui_label_s { struct ui_item_s item; @@ -142,7 +142,7 @@ struct ui_button const char *caption; }; -ui_item_t UI_CreateButton(void); +ui_item_t UI_CreateButton(void); ui_item_t UI_CreateLabel(void); ui_item_t UI_CreateText(void); diff --git a/vid_agl.c b/vid_agl.c index 6fa1e75a..aa7e8b01 100644 --- a/vid_agl.c +++ b/vid_agl.c @@ -389,7 +389,7 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp) scr_width = width; scr_height = height; - if ((qglGetString = GL_GetProcAddress("glGetString")) == NULL) + if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL) Sys_Error("glGetString not found in %s", gl_driver); if (fullscreen) diff --git a/vid_glx.c b/vid_glx.c index 890cf78f..8c2ab74e 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -555,7 +555,7 @@ void *GL_GetProcAddress(const char *name) { void *p = NULL; if (qglXGetProcAddressARB != NULL) - p = (void *) qglXGetProcAddressARB(name); + p = (void *) qglXGetProcAddressARB((GLubyte *)name); if (p == NULL) p = (void *) dlsym(prjobj, name); return p; @@ -726,11 +726,12 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp) vidmode_ext = true; } - if ((qglXChooseVisual = GL_GetProcAddress("glXChooseVisual")) == NULL - || (qglXCreateContext = GL_GetProcAddress("glXCreateContext")) == NULL - || (qglXMakeCurrent = GL_GetProcAddress("glXMakeCurrent")) == NULL - || (qglXSwapBuffers = GL_GetProcAddress("glXSwapBuffers")) == NULL - || (qglXQueryExtensionsString = GL_GetProcAddress("glXQueryExtensionsString")) == NULL) + if ((qglXChooseVisual = (XVisualInfo *(GLAPIENTRY *)(Display *dpy, int screen, int *attribList))GL_GetProcAddress("glXChooseVisual")) == NULL + || (qglXCreateContext = (GLXContext (GLAPIENTRY *)(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct))GL_GetProcAddress("glXCreateContext")) == NULL + || (qglXDestroyContext = (void (GLAPIENTRY *)(Display *dpy, GLXContext ctx))GL_GetProcAddress("glXDestroyContext")) == NULL + || (qglXMakeCurrent = (Bool (GLAPIENTRY *)(Display *dpy, GLXDrawable drawable, GLXContext ctx))GL_GetProcAddress("glXMakeCurrent")) == NULL + || (qglXSwapBuffers = (void (GLAPIENTRY *)(Display *dpy, GLXDrawable drawable))GL_GetProcAddress("glXSwapBuffers")) == NULL + || (qglXQueryExtensionsString = (const char *(GLAPIENTRY *)(Display *dpy, int screen))GL_GetProcAddress("glXQueryExtensionsString")) == NULL) { Con_Printf("glX functions not found in %s\n", gl_driver); return false; @@ -845,16 +846,16 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp) XSync(vidx11_display, False); - if ((qglGetString = GL_GetProcAddress("glGetString")) == NULL) + if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL) { Con_Printf ("glGetString not found in %s", gl_driver); return false; } - gl_renderer = qglGetString(GL_RENDERER); - gl_vendor = qglGetString(GL_VENDOR); - gl_version = qglGetString(GL_VERSION); - gl_extensions = qglGetString(GL_EXTENSIONS); + gl_renderer = (const char *)qglGetString(GL_RENDERER); + gl_vendor = (const char *)qglGetString(GL_VENDOR); + gl_version = (const char *)qglGetString(GL_VERSION); + gl_extensions = (const char *)qglGetString(GL_EXTENSIONS); gl_platform = "GLX"; gl_platformextensions = qglXQueryExtensionsString(vidx11_display, vidx11_screen); diff --git a/vid_sdl.c b/vid_sdl.c index 940f57df..50513fe6 100644 --- a/vid_sdl.c +++ b/vid_sdl.c @@ -374,17 +374,15 @@ int VID_InitMode(int fullscreen, int width, int height, int bpp) return false; } - qglGetString = GL_GetProcAddress("glGetString"); - - // Knghtbrd: should do platform-specific extension string function here - - if (qglGetString == NULL) + if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL) { VID_Shutdown(); Con_Print("Required OpenGL function glGetString not found\n"); return false; } + // Knghtbrd: should do platform-specific extension string function here + vid_isfullscreen = false; if (fullscreen) { flags |= SDL_FULLSCREEN; diff --git a/vid_wgl.c b/vid_wgl.c index d15c5b0a..afb773f5 100644 --- a/vid_wgl.c +++ b/vid_wgl.c @@ -909,14 +909,14 @@ int VID_InitMode (int fullscreen, int width, int height, int bpp) return false; } - qglGetString = GL_GetProcAddress("glGetString"); - qwglGetExtensionsStringARB = GL_GetProcAddress("wglGetExtensionsStringARB"); - if (qglGetString == NULL) + if ((qglGetString = (const GLubyte* (GLAPIENTRY *)(GLenum name))GL_GetProcAddress("glGetString")) == NULL) { VID_Shutdown(); Con_Print("glGetString not found\n"); return false; } + if ((qwglGetExtensionsStringARB = (const char *(WINAPI *)(HDC hdc))GL_GetProcAddress("wglGetExtensionsStringARB")) == NULL) + Con_Print("wglGetExtensionsStringARB not found\n"); gl_renderer = qglGetString(GL_RENDERER); gl_vendor = qglGetString(GL_VENDOR); gl_version = qglGetString(GL_VERSION); diff --git a/wad.c b/wad.c index b0ea75f1..eda0e4ce 100644 --- a/wad.c +++ b/wad.c @@ -82,7 +82,7 @@ void *W_GetLumpName(const char *name) Con_Print("gfx.wad doesn't have WAD2 id\n"); else { - wad_base = Mem_Alloc(cl_mempool, fs_filesize); + wad_base = (qbyte *)Mem_Alloc(cl_mempool, fs_filesize); memcpy(wad_base, temp, fs_filesize); Mem_Free(temp); @@ -175,7 +175,7 @@ void W_LoadTextureWadFile (char *filename, int complain) infotableofs = LittleLong(header.infotableofs); if (FS_Seek (file, infotableofs, SEEK_SET)) {Con_Print("W_LoadTextureWadFile: unable to seek to lump table\n");return;} - if (!(lumps = Mem_Alloc(tempmempool, sizeof(lumpinfo_t)*numlumps))) + if (!(lumps = (lumpinfo_t *)Mem_Alloc(tempmempool, sizeof(lumpinfo_t)*numlumps))) {Con_Print("W_LoadTextureWadFile: unable to allocate temporary memory for lump table\n");return;} if (FS_Read(file, lumps, sizeof(lumpinfo_t) * numlumps) != (fs_offset_t)sizeof(lumpinfo_t) * numlumps) @@ -212,7 +212,7 @@ qbyte *W_ConvertWAD3Texture(miptex_t *tex) int d, p; in = (qbyte *)tex + tex->offsets[0]; - data = out = Mem_Alloc(tempmempool, tex->width * tex->height * 4); + data = out = (qbyte *)Mem_Alloc(tempmempool, tex->width * tex->height * 4); if (!data) return NULL; image_width = tex->width; @@ -257,7 +257,7 @@ qbyte *W_GetTexture(char *name) if (FS_Seek(file, texwadlump[i].position, SEEK_SET)) {Con_Print("W_GetTexture: corrupt WAD3 file\n");return NULL;} - tex = Mem_Alloc(tempmempool, texwadlump[i].size); + tex = (miptex_t *)Mem_Alloc(tempmempool, texwadlump[i].size); if (!tex) return NULL; if (FS_Read(file, tex, texwadlump[i].size) < texwadlump[i].size) diff --git a/zone.c b/zone.c index ced5e82e..590dd839 100644 --- a/zone.c +++ b/zone.c @@ -101,7 +101,7 @@ choseclump: // big allocations are not clumped #endif pool->realsize += sizeof(memheader_t) + size + sizeof(int); - mem = malloc(sizeof(memheader_t) + size + sizeof(int)); + mem = (memheader_t *)malloc(sizeof(memheader_t) + size + sizeof(int)); if (mem == NULL) Sys_Error("Mem_Alloc: out of memory (alloc at %s:%i)", filename, fileline); #if MEMCLUMPING @@ -216,7 +216,7 @@ mempool_t *_Mem_AllocPool(const char *name, int flags, mempool_t *parent, const mempool_t *pool; if (developer.integer && developer_memorydebug.integer) _Mem_CheckSentinelsGlobal(filename, fileline); - pool = malloc(sizeof(mempool_t)); + pool = (mempool_t *)malloc(sizeof(mempool_t)); if (pool == NULL) Sys_Error("Mem_AllocPool: out of memory (allocpool at %s:%i)", filename, fileline); memset(pool, 0, sizeof(mempool_t)); diff --git a/zone.h b/zone.h index af6ddfd5..2d672dbb 100644 --- a/zone.h +++ b/zone.h @@ -136,7 +136,7 @@ void _Mem_CheckSentinelsGlobal(const char *filename, int fileline); qboolean Mem_IsAllocated(mempool_t *pool, void *data); // used for temporary allocations -mempool_t *tempmempool; +extern mempool_t *tempmempool; void Memory_Init (void); void Memory_Shutdown (void);