Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some type errors for c++ compilation #199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Quake/cvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ cvar_t *Cvar_Create (const char *name, const char *value)
if (Cmd_Exists (name))
return NULL; //error! panic! oh noes!

newvar = Z_Malloc(sizeof(cvar_t) + strlen(name)+1);
newvar = (cvar_t*) Z_Malloc(sizeof(cvar_t) + strlen(name)+1);
newvar->name = (char*)(newvar+1);
strcpy((char*)(newvar+1), name);
newvar->flags = CVAR_USERDEFINED;
Expand Down
2 changes: 1 addition & 1 deletion Quake/gl_rmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ static void GL_AllocFrameResources (frameres_bits_t bits)
if (gl_buffer_storage_able)
{
GL_BufferStorageFunc (GL_ARRAY_BUFFER, frameres_host_buffer_size, NULL, flags);
frame->host_ptr = GL_MapBufferRangeFunc (GL_ARRAY_BUFFER, 0, frameres_host_buffer_size, flags);
frame->host_ptr = (GLubyte *) GL_MapBufferRangeFunc (GL_ARRAY_BUFFER, 0, frameres_host_buffer_size, flags);
if (!frame->host_ptr)
Sys_Error ("GL_AllocFrameResources: MapBufferRange failed on %" SDL_PRIu64 " bytes", (uint64_t)frameres_host_buffer_size);
}
Expand Down
2 changes: 1 addition & 1 deletion Quake/gl_shaders.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ static GLuint GL_CreateProgramFromSources (int count, const GLchar **sources, co
q_vsnprintf (eval, sizeof (eval), name, argptr);
macros[0] = 0;

pipe = strchr (name, '|');
pipe = (char*) strchr (name, '|');
if (pipe) // parse symbol list and generate #defines
{
char *dst = macros;
Expand Down
2 changes: 1 addition & 1 deletion Quake/gl_sky.c
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void Sky_LoadSkyBox (const char *name)
const int cubemap_order[6] = {3, 1, 4, 5, 0, 2}; // ft/bk/up/dn/rt/lf
size_t numfacebytes = samesize * samesize * 4;

newsky.cubemap_pixels = malloc (numfacebytes * 6);
newsky.cubemap_pixels = (byte *) malloc (numfacebytes * 6);
if (!newsky.cubemap_pixels)
{
Con_Warning ("Sky_LoadSkyBox: out of memory on %" SDL_PRIu64 " bytes\n", (uint64_t) numfacebytes);
Expand Down
8 changes: 4 additions & 4 deletions Quake/gl_texmgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ TexMgr_SoftEmu_f -- called when r_softemu changes
*/
static void TexMgr_SoftEmu_f (cvar_t *var)
{
softemu = (int)r_softemu.value;
softemu = CLAMP (0, (int)softemu, SOFTEMU_NUMMODES - 1);
softemu = (softemu_t)r_softemu.value;
softemu = (softemu_t)CLAMP (0, softemu, SOFTEMU_NUMMODES - 1);
}

/*
Expand Down Expand Up @@ -2046,8 +2046,8 @@ void GLPalette_UpdateLookupTable (void)
}
else
{
metric = (int)r_softemu_metric.value;
metric = CLAMP (0, (int)metric, SOFTEMU_METRIC_COUNT - 1);
metric = (softemu_metric_t)r_softemu_metric.value;
metric = (softemu_metric_t)CLAMP (0, (int)metric, SOFTEMU_METRIC_COUNT - 1);
}

SDL_assert ((unsigned)metric < SOFTEMU_METRIC_COUNT);
Expand Down
16 changes: 8 additions & 8 deletions Quake/host_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static void FileList_Print (filelist_item_t *list, const char *types[2], const c
filelist_item_t *item;
const char *desc;
char buf[256], buf2[256];
char padchar = '.' | 0x80;
char padchar = '.' | (char)0x80;
size_t ofsdesc = list == extralevels ? maxlevelnamelen + 2 : 0;

if (substr && *substr)
Expand Down Expand Up @@ -252,7 +252,7 @@ static maptype_t ExtraMaps_Categorize (const char *name, const searchpath_t *sou
break;
case 'e':
if (name[1] >= '1' && name[1] <= '4')
return MAPTYPE_ID_EP1_LEVEL + (name[1] - '1');
return (maptype_t)(MAPTYPE_ID_EP1_LEVEL + (name[1] - '1'));
if (!strcmp (name + 1, "nd"))
return MAPTYPE_ID_END;
break;
Expand Down Expand Up @@ -282,12 +282,12 @@ static maptype_t ExtraMaps_Categorize (const char *name, const searchpath_t *sou

base = *source->filename ? MAPTYPE_CUSTOM_MOD_START : MAPTYPE_MOD_START;
if (is_start)
return base + MAPTYPE_CUSTOM_MOD_START;
return (maptype_t)(base + MAPTYPE_CUSTOM_MOD_START);
if (is_end)
return base + MAPTYPE_CUSTOM_MOD_END;
return (maptype_t)(base + MAPTYPE_CUSTOM_MOD_END);
if (is_dm)
return base + MAPTYPE_CUSTOM_MOD_DM;
return base + MAPTYPE_CUSTOM_MOD_LEVEL;
return (maptype_t)(base + MAPTYPE_CUSTOM_MOD_DM);
return (maptype_t)(base + MAPTYPE_CUSTOM_MOD_LEVEL);
}

typedef struct levelinfo_s
Expand All @@ -314,7 +314,7 @@ ExtraMaps_GetType
maptype_t ExtraMaps_GetType (const filelist_item_t *item)
{
const levelinfo_t *info = ExtraMaps_GetInfo (item);
return SDL_AtomicGet ((SDL_atomic_t *) &info->type);
return (maptype_t)SDL_AtomicGet ((SDL_atomic_t *) &info->type);
}

/*
Expand Down Expand Up @@ -3009,7 +3009,7 @@ static void Host_Spawn_f (void)

MSG_WriteByte (&host_client->message, svc_signonnum);
MSG_WriteByte (&host_client->message, 3);
host_client->sendsignon = true;
host_client->sendsignon = PRESPAWN_FLUSH;
}

/*
Expand Down
8 changes: 4 additions & 4 deletions Quake/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,7 @@ static void M_Maps_Init (void)
if (type >= MAPTYPE_BMODEL)
continue;
if (prev_type != -1 && prev_type != type)
M_Maps_AddSeparator (prev_type, type);
M_Maps_AddSeparator ((maptype_t)prev_type, (maptype_t)type);
prev_type = type;

map.name = item->name;
Expand All @@ -1683,7 +1683,7 @@ static void M_Maps_Init (void)
map.mapidx = mapsmenu.mapcount++;
if (map.active && active == -1)
active = VEC_SIZE (mapsmenu.items);
if ((map.active && !cls.demoplayback) || (mapsmenu.list.cursor == -1 && ExtraMaps_IsStart (type)))
if ((map.active && !cls.demoplayback) || (mapsmenu.list.cursor == -1 && ExtraMaps_IsStart ((maptype_t)type)))
mapsmenu.list.cursor = VEC_SIZE (mapsmenu.items);
VEC_PUSH (mapsmenu.items, map);
mapsmenu.list.numitems++;
Expand Down Expand Up @@ -2650,7 +2650,7 @@ chooses next window mode in order, then updates vid_fullscreen and vid_borderles
static void VID_Menu_ChooseNextDisplayMode (int dir)
{
windowmode_t mode = VID_Menu_GetDisplayMode ();
mode = (mode + DISPLAYMODE_COUNT - dir) % DISPLAYMODE_COUNT;
mode = (windowmode_t)((mode + DISPLAYMODE_COUNT - dir) % DISPLAYMODE_COUNT);
VID_Menu_SetDisplayMode (mode);
}

Expand Down Expand Up @@ -3209,7 +3209,7 @@ void M_AdjustSliders (int dir)
Cvar_SetValueQuick (&crosshair, ((int) q_max (crosshair.value, 0.f) + 3 + dir) % 3);
break;
case OPT_UIMOUSE: // UI mouse support
M_Options_SetUIMouse ((M_Options_GetUIMouse () + UI_MOUSE_NUMSETTINGS + dir) % UI_MOUSE_NUMSETTINGS);
M_Options_SetUIMouse ((uimouse_t)((M_Options_GetUIMouse () + UI_MOUSE_NUMSETTINGS + dir) % UI_MOUSE_NUMSETTINGS));
break;
case OPT_GAMMA: // gamma
f = vid_gamma.value - dir * 0.05;
Expand Down
2 changes: 1 addition & 1 deletion Quake/net_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ void NET_Shutdown (void)
//
for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++)
{
if (net_drivers[net_driverlevel].initialized == true)
if (net_drivers[net_driverlevel].initialized == (qboolean)true)
{
net_drivers[net_driverlevel].Shutdown ();
net_drivers[net_driverlevel].initialized = false;
Expand Down
18 changes: 9 additions & 9 deletions Quake/pr_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#include "quakedef.h"
#include "q_ctype.h"
#include "server.h"

#define STRINGTEMP_BUFFERS 1024
#define STRINGTEMP_LENGTH 1024
Expand Down Expand Up @@ -2056,8 +2057,7 @@ static void PF_cl_playerkey_f(void)
PF_cl_playerkey_internal(playernum, keyname, true);
}


static struct
static struct qcpics_t
{
char name[MAX_QPATH];
unsigned int flags;
Expand Down Expand Up @@ -2104,7 +2104,7 @@ static qpic_t *DrawQC_CachePic(const char *picname, unsigned int flags)
if (i+1 > maxqcpics)
{
maxqcpics = i + 32;
qcpics = realloc(qcpics, maxqcpics * sizeof(*qcpics));
qcpics = (struct qcpics_t*)realloc(qcpics, maxqcpics * sizeof(*qcpics));
}

strcpy(qcpics[i].name, picname);
Expand Down Expand Up @@ -2540,13 +2540,13 @@ static void PF_strzone(void)
}
len++; /*for the null*/

buf = Z_Malloc(len);
buf = (char*)Z_Malloc(len);
G_INT(OFS_RETURN) = PR_SetEngineString(buf);
id = -1-G_INT(OFS_RETURN);
if (id >= qcvm->knownzonesize)
{
qcvm->knownzonesize = (id+32)&~7;
qcvm->knownzone = Z_Realloc(qcvm->knownzone, (qcvm->knownzonesize+7)>>3);
qcvm->knownzone = (unsigned char *)Z_Realloc(qcvm->knownzone, (qcvm->knownzonesize+7)>>3);
}
qcvm->knownzone[id>>3] |= 1u<<(id&7);

Expand Down Expand Up @@ -3237,7 +3237,7 @@ static void PF_tokenizebyseparator(void)
if (found)
{
tlen = qctoken[qctoken_count].end - qctoken[qctoken_count].start;
qctoken[qctoken_count].token = malloc(tlen + 1);
qctoken[qctoken_count].token = (char*)malloc(tlen + 1);
memcpy(qctoken[qctoken_count].token, start + qctoken[qctoken_count].start, tlen);
qctoken[qctoken_count].token[tlen] = 0;

Expand Down Expand Up @@ -3401,7 +3401,7 @@ static void PF_cl_registercommand(void)
Cmd_AddCommand(cmdname, NULL);
}

static struct svcustomstat_s *PR_CustomStat(int idx, int type)
static svcustomstat_t *PR_CustomStat(int idx, int type)
{
size_t i;
if (idx < 0 || idx >= MAX_CL_STATS)
Expand All @@ -3428,14 +3428,14 @@ static struct svcustomstat_s *PR_CustomStat(int idx, int type)
sv.customstats[i].type = type;
sv.customstats[i].fld = 0;
sv.customstats[i].ptr = NULL;
return &sv.customstats[i];
return (svcustomstat_t*) & sv.customstats[i];
}
static void PF_clientstat(void)
{
int idx = G_FLOAT(OFS_PARM0);
int type = G_FLOAT(OFS_PARM1);
int fldofs = G_INT(OFS_PARM2);
struct svcustomstat_s *stat = PR_CustomStat(idx, type);
svcustomstat_t *stat = PR_CustomStat(idx, type);
if (!stat)
return;
stat->fld = fldofs;
Expand Down
8 changes: 4 additions & 4 deletions Quake/pr_edict.c
Original file line number Diff line number Diff line change
Expand Up @@ -985,14 +985,14 @@ static void ED_RezoneString (string_t *ref, const char *str)
// Con_Warning("ED_RezoneString: string wasn't strzoned\n"); //warnings would trigger from the default cvar value that autocvars are initialised with
}

buf = Z_Malloc(len);
buf = (char *)Z_Malloc(len);
memcpy(buf, str, len);
id = -1-(*ref = PR_SetEngineString(buf));
//make sure its flagged as zoned so we can clean up properly after.
if (id >= qcvm->knownzonesize)
{
qcvm->knownzonesize = (id+32)&~7;
qcvm->knownzone = Z_Realloc(qcvm->knownzone, (qcvm->knownzonesize+7)>>3);
qcvm->knownzone = (unsigned char *)Z_Realloc(qcvm->knownzone, (qcvm->knownzonesize+7)>>3);
}
qcvm->knownzone[id>>3] |= 1u<<(id&7);
}
Expand Down Expand Up @@ -1378,7 +1378,7 @@ static func_t PR_FindExtFunction(const char *entryname)
return 0;
}

static void *PR_FindExtGlobal(int type, const char *name)
static float *PR_FindExtGlobal(int type, const char *name)
{
ddef_t *def = ED_FindGlobal(name);
if (def && (def->type&~DEF_SAVEGLOBAL) == type && def->ofs < qcvm->progs->numglobals)
Expand Down Expand Up @@ -1529,7 +1529,7 @@ static void PR_MergeEngineFieldDefs (void)
if (maxdefs != qcvm->progs->numfielddefs)
{ //we now know how many entries we need to add...
ddef_t *olddefs = qcvm->fielddefs;
qcvm->fielddefs = malloc(maxdefs * sizeof(*qcvm->fielddefs));
qcvm->fielddefs = (ddef_t *)malloc(maxdefs * sizeof(*qcvm->fielddefs));
memcpy(qcvm->fielddefs, olddefs, qcvm->progs->numfielddefs*sizeof(*qcvm->fielddefs));
if (olddefs != (ddef_t *)((byte *)qcvm->progs + qcvm->progs->ofs_fielddefs))
free(olddefs);
Expand Down
12 changes: 6 additions & 6 deletions Quake/r_world.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,32 +379,32 @@ static void R_DrawBrushModels_Real (entity_t **ents, int count, brushpass_t pass
{
default:
case BP_SOLID:
texbegin = 0;
texbegin = (textype_t)0;
texend = TEXTYPE_CUTOUT;
program = glprogs.world[oit][q_max(0, (int)softemu - 1)][WORLDSHADER_SOLID];
break;
case BP_ALPHATEST:
texbegin = TEXTYPE_CUTOUT;
texend = TEXTYPE_CUTOUT + 1;
texend = (textype_t)(TEXTYPE_CUTOUT + 1);
program = glprogs.world[oit][q_max(0, (int)softemu - 1)][WORLDSHADER_ALPHATEST];
break;
case BP_SKYLAYERS:
texbegin = TEXTYPE_SKY;
texend = TEXTYPE_SKY + 1;
texend = (textype_t)(TEXTYPE_SKY + 1);
program = glprogs.skylayers[softemu == SOFTEMU_COARSE];
break;
case BP_SKYCUBEMAP:
texbegin = TEXTYPE_SKY;
texend = TEXTYPE_SKY + 1;
texend = (textype_t)(TEXTYPE_SKY + 1);
program = glprogs.skycubemap[Sky_IsAnimated ()][softemu == SOFTEMU_COARSE];
break;
case BP_SKYSTENCIL:
texbegin = TEXTYPE_SKY;
texend = TEXTYPE_SKY + 1;
texend = (textype_t)(TEXTYPE_SKY + 1);
program = glprogs.skystencil;
break;
case BP_SHOWTRIS:
texbegin = 0;
texbegin = (textype_t)0;
texend = TEXTYPE_COUNT;
program = glprogs.world[0][0][0];
break;
Expand Down
31 changes: 17 additions & 14 deletions Quake/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ typedef struct
qboolean changelevel_issued; // cleared when at SV_SpawnServer
} server_static_t;

typedef struct
{
int idx;
int type;
int fld;
eval_t* ptr;
} svcustomstat_t;

//=============================================================================

#define MAX_SIGNON_BUFFERS 256
Expand Down Expand Up @@ -75,13 +83,7 @@ typedef struct
unsigned protocol; //johnfitz
unsigned protocolflags;

struct svcustomstat_s
{
int idx;
int type;
int fld;
eval_t *ptr;
} customstats[MAX_CL_STATS*2]; //strings or numeric...
svcustomstat_t customstats[MAX_CL_STATS*2]; //strings or numeric...
size_t numcustomstats;

char lastsave[MAX_OSPATH];
Expand All @@ -103,18 +105,19 @@ typedef struct

#define NUM_PING_TIMES 16

typedef enum {
PRESPAWN_DONE,
PRESPAWN_FLUSH = 1,
PRESPAWN_SIGNONBUFS,
PRESPAWN_SIGNONMSG,
} sendsignon_t;

typedef struct client_s
{
qboolean active; // false = client is free
qboolean spawned; // false = don't send datagrams
qboolean dropasap; // has been told to go to another level
enum
{
PRESPAWN_DONE,
PRESPAWN_FLUSH=1,
PRESPAWN_SIGNONBUFS,
PRESPAWN_SIGNONMSG,
} sendsignon; // only valid before spawned
sendsignon_t sendsignon; // only valid before spawned
int signonidx;

double last_message; // reliable messages must be sent
Expand Down
2 changes: 1 addition & 1 deletion Quake/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ void SV_SendServerinfo (client_t *client)
MSG_WriteByte (&client->message, svc_signonnum);
MSG_WriteByte (&client->message, 1);

client->sendsignon = true;
client->sendsignon = PRESPAWN_FLUSH;
client->spawned = false; // need prespawn, spawn, etc
}

Expand Down
6 changes: 3 additions & 3 deletions Quake/sys_sdl_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ static qboolean Sys_GetKnownFolder (const KNOWNFOLDERID *base, const char *subdi
if (FAILED (hr))
return false;

hr = SHGetKnownFolderPath (base, 0, NULL, &wpath);
hr = SHGetKnownFolderPath ((REFKNOWNFOLDERID)base, 0, NULL, &wpath);
if (FAILED (hr))
{
CoUninitialize ();
Expand Down Expand Up @@ -568,9 +568,9 @@ typedef struct winfindfile_s {
static void Sys_FillFindData (winfindfile_t *find)
{
WideStringToUTF8 (find->data.cFileName, find->base.name, countof (find->base.name));
find->base.attribs = 0;
find->base.attribs = (fileattribs_t)0;
if (find->data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
find->base.attribs |= FA_DIRECTORY;
find->base.attribs = (fileattribs_t)(find->base.attribs | FA_DIRECTORY);
}

findfile_t *Sys_FindFirst (const char *dir, const char *ext)
Expand Down