Fix quite a few issues with casting away const and volatile qualifiers, found with -Wcast-qual. If we're going to use const everywhere, we should really mean it!

git-svn-id: https://svn.eduke32.com/eduke32@5540 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2016-01-11 05:05:38 +00:00
parent 8fc803fee3
commit a7e6ed8745
37 changed files with 165 additions and 139 deletions

View file

@ -241,8 +241,8 @@ void copybufreverse(const void *S, void *D, int32_t c);
static inline int32_t krecipasm(int32_t i)
{
// Ken did this
float const f = (float)i;
i = *(int32_t *)&f;
float const f = (float const)i;
i = *(int32_t const *)&f;
return ((reciptable[(i >> 12) & 2047] >> (((i - 0x3f800000) >> 23) & 31)) ^ (i >> 31));
}

View file

@ -80,10 +80,10 @@ void clearbufbyte(void *D, int32_t c, int32_t a);
void copybufbyte(const void *S, void *D, int32_t c);
void copybufreverse(const void *S, void *D, int32_t c);
static inline int32_t krecipasm(int32_t i)
static inline int32_t krecipasm(int32_t const i)
{
// Ken did this
float f = (float)i;
float f = (float const)i;
i = *(int32_t *)&f;
return ((reciptable[(i >> 12) & 2047] >> (((i - 0x3f800000) >> 23) & 31)) ^ (i >> 31));
}

View file

@ -518,10 +518,6 @@ void removesearchpaths_withuser(int32_t usermask)
int32_t findfrompath(const char *fn, char **where)
{
searchpath_t *sp;
char *pfn, *ffn;
int32_t allocsiz;
// pathsearchmode == 0: tests current dir and then the dirs of the path stack
// pathsearchmode == 1: tests fn without modification, then like for pathsearchmode == 0
@ -557,16 +553,18 @@ int32_t findfrompath(const char *fn, char **where)
#endif
}
for (pfn = (char *)fn; toupperlookup[*pfn] == '/'; pfn++);
ffn = Xstrdup(pfn);
char const *cpfn;
for (cpfn = fn; toupperlookup[*cpfn] == '/'; cpfn++);
char *ffn = Xstrdup(cpfn);
Bcorrectfilename(ffn,0); // compress relative paths
allocsiz = max(maxsearchpathlen, 2); // "./" (aka. curdir)
int32_t allocsiz = max(maxsearchpathlen, 2); // "./" (aka. curdir)
allocsiz += strlen(ffn);
allocsiz += 1; // a nul
pfn = (char *)Xmalloc(allocsiz);
char *pfn = (char *)Xmalloc(allocsiz);
strcpy(pfn, "./");
strcat(pfn, ffn);
@ -577,7 +575,7 @@ int32_t findfrompath(const char *fn, char **where)
return 0;
}
for (sp = searchpathhead; sp; sp = sp->next)
for (searchpath_t *sp = searchpathhead; sp; sp = sp->next)
{
char *tfn = Xstrdup(ffn);
@ -1765,7 +1763,7 @@ static uint32_t compress_part(uint32_t k, intptr_t f)
// Write from 'buffer' to 'f'.
C1D_STATIC void c1d_write_compressed(const void *buffer, bsize_t dasizeof, bsize_t count, intptr_t f)
{
const char *ptr = (char*)buffer;
char const *ptr = (char const *)buffer;
if (dasizeof > LZWSIZE)
{

View file

@ -40,7 +40,7 @@ void initfastcolorlookup_palette(uint8_t const * const pal)
colmatch_palette = pal;
char const *pal1 = (char *)&pal[768-3];
char const *pal1 = (char const *)&pal[768-3];
for (int i=255; i>=0; i--,pal1-=3)
{
int32_t const j = (pal1[0]>>FASTPALRIGHTSHIFT)*FASTPALGRIDSIZ*FASTPALGRIDSIZ
@ -155,7 +155,7 @@ int32_t getclosestcol_nocache_lim(int32_t r, int32_t g, int32_t b, int32_t const
do
{
char const * const pal1 = (char *)&colmatch_palette[i*3];
char const * const pal1 = (char const *)&colmatch_palette[i*3];
int dist = gdist[pal1[1]+g];
if (dist >= mindist || i > lastokcol) continue;
@ -175,7 +175,7 @@ int32_t getclosestcol_nocache_lim(int32_t r, int32_t g, int32_t b, int32_t const
for (int i = 0; i < lastokcol; ++i)
{
char const * const pal1 = (char *)&colmatch_palette[i*3];
char const * const pal1 = (char const *)&colmatch_palette[i*3];
int dist = gdist[pal1[1]+g];
if (dist >= mindist) continue;

View file

@ -189,15 +189,15 @@ int32_t maybe_append_ext(char *wbuf, int32_t wbufsiz, const char *fn, const char
int32_t ldist(const void *s1, const void *s2)
{
tspritetype const *const sp1 = (tspritetype *)s1;
tspritetype const *const sp2 = (tspritetype *)s2;
tspritetype const *const sp1 = (tspritetype const *)s1;
tspritetype const *const sp2 = (tspritetype const *)s2;
return sepldist(sp1->x - sp2->x, sp1->y - sp2->y);
}
int32_t dist(const void *s1, const void *s2)
{
tspritetype const *const sp1 = (tspritetype *)s1;
tspritetype const *const sp2 = (tspritetype *)s2;
tspritetype const *const sp1 = (tspritetype const *)s1;
tspritetype const *const sp2 = (tspritetype const *)s2;
return sepdist(sp1->x - sp2->x, sp1->y - sp2->y, sp1->z - sp2->z);
}

View file

@ -6,7 +6,7 @@
uint32_t Bcrc32(const void* data, size_t length, uint32_t crc)
{
const uint32_t* current = (const uint32_t*) data;
uint8_t *currentChar;
uint8_t const * currentChar;
crc = ~crc;
#ifdef BITNESS64
@ -61,7 +61,7 @@ uint32_t Bcrc32(const void* data, size_t length, uint32_t crc)
}
#endif
currentChar = (uint8_t*) current;
currentChar = (uint8_t const *) current;
// remaining 1 to 7 bytes (standard algorithm)
while (length-- > 0)
crc = (crc >> 8) ^ crc32table[0][(crc & 0xFF) ^ *currentChar++];

View file

@ -98,7 +98,7 @@ usermaphack_t g_loadedMapHack; // used only for the MD4 part
int32_t compare_usermaphacks(const void *a, const void *b)
{
return Bmemcmp(((usermaphack_t*) a)->md4, ((usermaphack_t*) b)->md4, 16);
return Bmemcmp(((usermaphack_t const *) a)->md4, ((usermaphack_t const *) b)->md4, 16);
}
usermaphack_t *usermaphacks;
int32_t num_usermaphacks;
@ -12635,7 +12635,7 @@ int32_t setsprite(int16_t spritenum, const vec3_t *newpos)
{
int16_t tempsectnum = sprite[spritenum].sectnum;
if ((void *)newpos != (void *)&sprite[spritenum])
if ((void const *)newpos != (void *)&sprite[spritenum])
Bmemcpy(&sprite[spritenum], newpos, sizeof(vec3_t));
updatesector(newpos->x,newpos->y,&tempsectnum);
@ -12652,7 +12652,7 @@ int32_t setspritez(int16_t spritenum, const vec3_t *newpos)
{
int16_t tempsectnum = sprite[spritenum].sectnum;
if ((void *)newpos != (void *)&sprite[spritenum])
if ((void const *)newpos != (void *)&sprite[spritenum])
Bmemcpy(&sprite[spritenum], newpos, sizeof(vec3_t));
updatesectorz(newpos->x,newpos->y,newpos->z,&tempsectnum);
@ -13393,7 +13393,7 @@ restart_grand:
if (klabs(intx-sv->x)+klabs(inty-sv->y) > klabs((hit->pos.x)-sv->x)+klabs((hit->pos.y)-sv->y))
continue;
get_floorspr_points((tspritetype *)spr, intx, inty, &x1, &x2, &x3, &x4,
get_floorspr_points((tspritetype const *)spr, intx, inty, &x1, &x2, &x3, &x4,
&y1, &y2, &y3, &y4);
if (get_floorspr_clipyou(x1, x2, x3, x4, y1, y2, y3, y4))
@ -14214,7 +14214,7 @@ int32_t clipmove(vec3_t *pos, int16_t *sectnum,
rxi[0] = x1;
ryi[0] = y1;
get_floorspr_points((tspritetype *) spr, 0, 0, &rxi[0], &rxi[1], &rxi[2], &rxi[3],
get_floorspr_points((tspritetype const *) spr, 0, 0, &rxi[0], &rxi[1], &rxi[2], &rxi[3],
&ryi[0], &ryi[1], &ryi[2], &ryi[3]);
dax = mulscale14(sintable[(spr->ang-256+512)&2047],walldist);
@ -15082,7 +15082,7 @@ restart_grand:
if ((pos->z > daz) == ((cstat&8)==0))
continue;
get_floorspr_points((tspritetype *) spr, pos->x, pos->y, &x1, &x2, &x3, &x4,
get_floorspr_points((tspritetype const *) spr, pos->x, pos->y, &x1, &x2, &x3, &x4,
&y1, &y2, &y3, &y4);
const int32_t dax = mulscale14(sintable[(spr->ang-256+512)&2047],walldist+4);
@ -18052,11 +18052,13 @@ static int32_t screencapture_png(const char *filename, char inverseit, const cha
#endif
text[0].compression = PNG_TEXT_COMPRESSION_NONE;
text[0].key = "Title";
text[0].text = (png_charp)(editstatus ? "Mapster32 screenshot" : "EDuke32 screenshot");
char *pngtext = Bstrdup((editstatus ? "Mapster32 screenshot" : "EDuke32 screenshot"));
text[0].text = pngtext;
text[1].compression = PNG_TEXT_COMPRESSION_NONE;
text[1].key = "Software";
text[1].text = (char *)versionstr;
char *pngversion = Bstrdup(versionstr);
text[1].text = pngversion;
png_set_text(png_ptr, info_ptr, text, 2);
// get/set the pixel data
@ -18095,6 +18097,10 @@ static int32_t screencapture_png(const char *filename, char inverseit, const cha
Bfclose(fp);
if (palette) png_free(png_ptr, palette);
if (text) png_free(png_ptr, text);
DO_FREE_AND_NULL(pngtext);
DO_FREE_AND_NULL(pngversion);
if (buf) png_free(png_ptr, buf);
if (rowptrs) png_free(png_ptr, rowptrs);
png_destroy_write_struct(&png_ptr, &info_ptr);
@ -18287,7 +18293,7 @@ int32_t setrendermode(int32_t renderer)
#ifdef USE_OPENGL
void setrollangle(int32_t rolla)
{
gtang = (float)rolla * (PI * (1.f/1024.f));
gtang = (float)rolla * ((float)PI * (1.f/1024.f));
}
#endif

View file

@ -160,7 +160,7 @@ int32_t hicsetsubsttex(int32_t picnum, int32_t palnum, const char *filen, float
Bfree(hrn->filename);
hrn->filename = Xstrdup(filen);
hrn->alphacut = min(alphacut,1.0);
hrn->alphacut = min(alphacut,1.f);
hrn->scale.x = xscale;
hrn->scale.y = yscale;
hrn->specpower = specpower;

View file

@ -208,7 +208,8 @@ static inline int32_t bitrev(int32_t b, int32_t c)
#endif
static uint8_t fakebuf[8], *nfilptr;
static uint8_t fakebuf[8];
static uint8_t const *nfilptr;
static int32_t nbitpos;
static void suckbitsnextblock()
{
@ -237,7 +238,7 @@ static void suckbitsnextblock()
// |===|===|
//----x O---x O--------
nbitpos = B_BIG32(B_UNBUF32(&filptr[8]));
nfilptr = (uint8_t *)&filptr[nbitpos+12];
nfilptr = &filptr[nbitpos+12];
B_BUF32(&fakebuf[0], B_UNBUF32(&filptr[0])); //Copy last dword of IDAT chunk
if (B_UNBUF32(&filptr[12]) == B_LITTLE32(0x54414449)) //Copy 1st dword of next IDAT chunk
B_BUF32(&fakebuf[4], B_UNBUF32(&filptr[16]));
@ -754,7 +755,7 @@ static int32_t kpngrend(const char *kfilebuf, int32_t kfilength,
if ((B_UNBUF32(&kfilebuf[0]) != B_LITTLE32(0x474e5089)) || (B_UNBUF32(&kfilebuf[4]) != B_LITTLE32(0x0a1a0a0d)))
return(-1); //"Invalid PNG file signature"
filptr = (uint8_t *)&kfilebuf[8];
filptr = (uint8_t const *)&kfilebuf[8];
trnsrgb = 0; filter1st = -1; filterest = 0;
@ -1289,7 +1290,7 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
if (!kpeginited) { kpeginited = 1; initkpeg(); }
kfileptr = (uint8_t *)kfilebuf;
kfileptr = (uint8_t const *)kfilebuf;
kfileend = &kfileptr[kfilength];
if (B_UNBUF16(kfileptr) == B_LITTLE16(0xd8ff)) kfileptr += 2;
@ -1348,7 +1349,7 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
ch = *kfileptr++; leng--;
if (ch >= 16) { index = ch-12; }
else { index = ch; }
Bmemcpy((void *)&hufnumatbit[index][1],(void *)kfileptr,16); kfileptr += 16;
Bmemcpy((void *)&hufnumatbit[index][1],(void const *)kfileptr,16); kfileptr += 16;
leng -= 16;
v = 0; hufcnt[index] = 0;
@ -1357,7 +1358,7 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
{
hufmaxatbit[index][i] = v+hufnumatbit[index][i];
hufvalatbit[index][i] = hufcnt[index]-v;
Bmemcpy((void *)&huftable[index][hufcnt[index]],(void *)kfileptr,(int32_t)hufnumatbit[index][i]);
Bmemcpy((void *)&huftable[index][hufcnt[index]],(void const *)kfileptr,(int32_t)hufnumatbit[index][i]);
if (i <= 10)
for (c=0; c<hufnumatbit[index][i]; c++)
for (j=(1<<(10-i)); j>0; j--)
@ -1468,7 +1469,7 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
for (y=0; y<ydim; y+=glvstep)
for (x=0; x<xdim; x+=glhstep)
{
if (kfileptr-4-(uint8_t *)kfilebuf >= kfilength) goto kpegrend_break2; //rest of file is missing!
if (kfileptr-4-(uint8_t const *)kfilebuf >= kfilength) goto kpegrend_break2; //rest of file is missing!
if (!dctbuf) dc = dct[0];
for (c=0; c<lnumcomponents; c++)
@ -1607,7 +1608,7 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
default: kfileptr += leng; break;
}
}
while (kfileptr-(uint8_t *)kfilebuf < kfilength);
while (kfileptr-(uint8_t const *)kfilebuf < kfilength);
if (!dctbuf) return(0);
@ -1663,7 +1664,7 @@ static int32_t kgifrend(const char *kfilebuf, int32_t kfilelength,
if ((kfilebuf[0] != 'G') || (kfilebuf[1] != 'I') || (kfilebuf[2] != 'F')) return(-1);
paleng = (1<<((kfilebuf[10]&7)+1));
ptr = (uint8_t *)&kfilebuf[13];
ptr = (uint8_t const *)&kfilebuf[13];
if (kfilebuf[10]&128) { cptr = ptr; ptr += paleng*3; }
transcol = -1;
while ((chunkind = *ptr++) == '!')
@ -1827,7 +1828,7 @@ static int32_t ktgarend(const char *header, int32_t fleng,
if ((header[16]&7) || (header[16] == 0) || (header[16] > 32)) return(-1);
if (header[17]&0xc0) return(-1);
fptr = (uint8_t *)&header[header[0]+18];
fptr = (uint8_t const *)&header[header[0]+18];
xsiz = (int32_t)B_LITTLE16(B_UNBUF16(&header[12])); if (xsiz <= 0) return(-1);
ysiz = (int32_t)B_LITTLE16(B_UNBUF16(&header[14])); if (ysiz <= 0) return(-1);
colbyte = ((((int32_t)header[16])+7)>>3);
@ -2027,7 +2028,8 @@ static int32_t kpcxrend(const char *buf, int32_t fleng,
{
int32_t j, x, y, nplanes, x0, x1, y0, y1, bpl, xsiz, ysiz;
intptr_t p,i;
uint8_t c, *cptr;
uint8_t c;
uint8_t const *cptr;
if (B_UNBUF32(buf) != B_LITTLE32(0x0801050a)) return(-1);
xsiz = B_LITTLE16(B_UNBUF16(&buf[ 8]))-B_LITTLE16(B_UNBUF16(&buf[4]))+1; if (xsiz <= 0) return(-1);
@ -2038,7 +2040,7 @@ static int32_t kpcxrend(const char *buf, int32_t fleng,
if (nplanes == 1)
{
//if (buf[fleng-769] != 12) return(-1); //Some PCX are buggy!
cptr = (uint8_t *)&buf[fleng-768];
cptr = (uint8_t const *)&buf[fleng-768];
for (i=0; i<256; i++)
{
palcol[i] = (((int32_t)cptr[0])<<16) +
@ -2062,7 +2064,7 @@ static int32_t kpcxrend(const char *buf, int32_t fleng,
x = x0 = 0; x1 = xsiz;
y = y0 = 0; y1 = ysiz;
cptr = (uint8_t *)&buf[128];
cptr = (uint8_t const *)&buf[128];
p = y*dabytesperline+daframeplace;
if (bpl > xsiz) { daxres = min(daxres,x1); x1 += bpl-xsiz; }
@ -2238,14 +2240,14 @@ static int32_t istarga(const uint8_t *buf, int32_t leng)
void kpgetdim(const char *buf, int32_t leng, int32_t *xsiz, int32_t *ysiz)
{
int32_t *lptr;
int32_t const *lptr;
const uint8_t *cptr;
const uint8_t *ubuf = (uint8_t *)buf;
const uint8_t *ubuf = (uint8_t const *)buf;
(*xsiz) = (*ysiz) = 0; if (leng < 16) return;
if (B_UNBUF16(&ubuf[0]) == B_LITTLE16(0x5089)) //.PNG
{
lptr = (int32_t *)buf;
lptr = (int32_t const *)buf;
if ((lptr[0] != (int32_t)B_LITTLE32(0x474e5089)) || (lptr[1] != (int32_t)B_LITTLE32(0x0a1a0a0d))) return;
lptr = &lptr[2];
while (((uintptr_t)lptr-(uintptr_t)buf) < (uintptr_t)(leng-16))
@ -2257,7 +2259,7 @@ void kpgetdim(const char *buf, int32_t leng, int32_t *xsiz, int32_t *ysiz)
}
else if (B_UNBUF16(&ubuf[0]) == B_LITTLE16(0xd8ff)) //.JPG
{
cptr = (uint8_t *)&buf[2];
cptr = (uint8_t const *)&buf[2];
while (((uintptr_t)cptr-(uintptr_t)buf) < (uintptr_t)(leng-8))
{
if ((cptr[0] != 0xff) || (cptr[1] == 0xff)) { cptr++; continue; }
@ -2323,7 +2325,7 @@ void kpgetdim(const char *buf, int32_t leng, int32_t *xsiz, int32_t *ysiz)
int32_t kprender(const char *buf, int32_t leng, intptr_t frameptr, int32_t bpl,
int32_t xdim, int32_t ydim)
{
uint8_t *ubuf = (uint8_t *)buf;
uint8_t const *ubuf = (uint8_t const *)buf;
paleng = 0; bakcol = 0; numhufblocks = zlibcompflags = 0; filtype = -1;

View file

@ -25,6 +25,7 @@
*/
typedef unsigned char *POINTER;
typedef unsigned char const *RPOINTER;
typedef unsigned short UINT2;
typedef unsigned int UINT4;
@ -130,7 +131,7 @@ void md4block(MD4_CTX *context, const unsigned char *input, unsigned int inputLe
if (inputLen >= partLen)
{
MD4_memcpy
((POINTER)&context->buffer[index], (POINTER)input, partLen);
((POINTER)&context->buffer[index], (RPOINTER)input, partLen);
MD4Transform(context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
@ -143,7 +144,7 @@ void md4block(MD4_CTX *context, const unsigned char *input, unsigned int inputLe
/* Buffer remaining input */
MD4_memcpy
((POINTER)&context->buffer[index], (POINTER)&input[i],
((POINTER)&context->buffer[index], (RPOINTER)&input[i],
inputLen-i);
}

View file

@ -2597,7 +2597,7 @@ mdmodel_t *mdload(const char *filnam)
vm = (mdmodel_t *)voxload(filnam);
if (vm) return vm;
fil = kopen4load((char *)filnam,0);
fil = kopen4load(filnam,0);
if (fil < 0)
return NULL;
@ -2688,7 +2688,7 @@ int32_t polymost_mddraw(const tspritetype *tspr)
allocmodelverts = maxmodelverts;
}
mdmodel_t const *const vm = models[tile2model[Ptile2tile(tspr->picnum,
mdmodel_t *const vm = models[tile2model[Ptile2tile(tspr->picnum,
(tspr->owner >= MAXSPRITES) ? tspr->pal : sprite[tspr->owner].pal)].modelid];
if (vm->mdnum == 1) { return polymost_voxdraw((voxmodel_t *)vm,tspr); }
if (vm->mdnum == 3) { return polymost_md3draw((md3model_t *)vm,tspr); }

View file

@ -332,7 +332,7 @@ static int32_t _internal_osdfunc_fileinfo(const osdfuncparm_t *parm)
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
if ((i = kopen4load((char *)parm->parms[0],0)) < 0)
if ((i = kopen4load(parm->parms[0],0)) < 0)
{
OSD_Printf("fileinfo: File \"%s\" not found.\n", parm->parms[0]);
return OSDCMD_OK;
@ -1797,7 +1797,7 @@ int32_t OSD_Dispatch(const char *cmd)
int32_t numparms = 0;
symbol_t *symb;
osdfuncparm_t ofp;
char *parms[MAXPARMS];
char const *parms[MAXPARMS];
Bmemset(parms, 0, sizeof(parms));
@ -2054,7 +2054,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
{
if (showval)
{
OSD_Printf("\"%s\" is \"%f\"\n%s: %s\n",osd->cvars[i].c.name,*(float *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,(char *)osd->cvars[i].c.desc);
OSD_Printf("\"%s\" is \"%f\"\n%s: %s\n",osd->cvars[i].c.name,*(float *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,osd->cvars[i].c.desc);
return OSDCMD_OK;
}
@ -2075,7 +2075,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
{
if (showval)
{
OSD_Printf("\"%s\" is \"%f\"\n%s: %s\n",osd->cvars[i].c.name,*(double *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,(char *)osd->cvars[i].c.desc);
OSD_Printf("\"%s\" is \"%f\"\n%s: %s\n",osd->cvars[i].c.name,*(double *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,osd->cvars[i].c.desc);
return OSDCMD_OK;
}
@ -2098,7 +2098,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
{
if (showval)
{
OSD_Printf((osd->cvars[i].c.type & CVAR_UINT) ? "\"%s\" is \"%u\"\n%s: %s\n" : "\"%s\" is \"%d\"\n%s: %s\n",osd->cvars[i].c.name,*(int32_t *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,(char *)osd->cvars[i].c.desc);
OSD_Printf((osd->cvars[i].c.type & CVAR_UINT) ? "\"%s\" is \"%u\"\n%s: %s\n" : "\"%s\" is \"%d\"\n%s: %s\n",osd->cvars[i].c.name,*(int32_t *)osd->cvars[i].c.vptr,osd->cvars[i].c.name,osd->cvars[i].c.desc);
return OSDCMD_OK;
}
@ -2119,7 +2119,7 @@ int32_t osdcmd_cvar_set(const osdfuncparm_t *parm)
{
if (showval)
{
OSD_Printf("\"%s\" is \"%s\"\n%s: %s\n",osd->cvars[i].c.name,(char *)osd->cvars[i].c.vptr,osd->cvars[i].c.name, (char *)osd->cvars[i].c.desc);
OSD_Printf("\"%s\" is \"%s\"\n%s: %s\n",osd->cvars[i].c.name,(char *)osd->cvars[i].c.vptr,osd->cvars[i].c.name, osd->cvars[i].c.desc);
return OSDCMD_OK;
}

View file

@ -424,8 +424,8 @@ static void fogcalc_old(int32_t shade, int32_t vis)
// For GL_LINEAR fog:
#define FOGDISTCONST 600
#define FULLVIS_BEGIN 2.9e30
#define FULLVIS_END 3.0e30
#define FULLVIS_BEGIN 2.9e30f
#define FULLVIS_END 3.0e30f
static inline void fogcalc(int32_t tile, int32_t shade, int32_t vis, int32_t pal)
{
@ -2735,7 +2735,7 @@ static void polymost_drawalls(int32_t const bunch)
ytex.d = ytex.u = 0;
otex.d = dd;
xtex.u = otex.d * (t * (float)((uint64_t)(xdimscale * yxaspect) * viewingrange)) *
(1.f / (16384.0 * 65536.0 * 65536.0 * 5.0 * 1024.0));
(1.f / (16384.f * 65536.f * 65536.f * 5.f * 1024.f));
ytex.v = vv[1];
otex.v = r_parallaxskypanning ? vv[0] + dd*(float)sec->floorypanning*(float)i*(1.f/256.f) : vv[0];
@ -3027,7 +3027,7 @@ static void polymost_drawalls(int32_t const bunch)
ytex.d = ytex.u = 0;
otex.d = dd;
xtex.u = otex.d * (t * (float)((uint64_t)(xdimscale * yxaspect) * viewingrange)) *
(1.f / (16384.0 * 65536.0 * 65536.0 * 5.0 * 1024.0));
(1.f / (16384.f * 65536.f * 65536.f * 5.f * 1024.f));
ytex.v = vv[1];
otex.v = r_parallaxskypanning ? vv[0] + dd*(float)sec->ceilingypanning*(float)i*(1.f/256.f) : vv[0];
@ -4839,7 +4839,7 @@ void polymost_dorotatespritemodel(int32_t sx, int32_t sy, int32_t z, int16_t a,
fov = pr_hudfov;
#endif
if (fov != -1)
f = 1.f/tanf(((float)fov * 2.56f) * ((.5f * PI) * (1.0f/2048.f)));
f = 1.f/tanf(((float)fov * 2.56f) * ((.5f * (float)PI) * (1.0f/2048.f)));
m[0][0] = f*fydimen; m[0][2] = 1.f;
m[1][1] = f*fxdimen; m[1][2] = 1.f;
@ -5617,7 +5617,7 @@ int32_t polymost_printext256(int32_t xpos, int32_t ypos, int16_t col, int16_t ba
static int32_t gltexturemode(const osdfuncparm_t *parm)
{
int32_t m;
const char *p;
char *p;
if (parm->numparms != 1)
{
@ -5629,7 +5629,7 @@ static int32_t gltexturemode(const osdfuncparm_t *parm)
return OSDCMD_OK;
}
m = Bstrtoul(parm->parms[0], (char **)&p, 10);
m = Bstrtoul(parm->parms[0], &p, 10);
if (p == parm->parms[0])
{
// string

View file

@ -461,7 +461,7 @@ static const char * texcache_calcid(char *cachefn, const char *fn, const int32_t
Bstrcat(id.name, fn);
Bsprintf(cachefn, "%08x%08x%08x",
XXH32((uint8_t *)fn, Bstrlen(fn), TEXCACHEMAGIC[3]),
XXH32((uint8_t const *)fn, Bstrlen(fn), TEXCACHEMAGIC[3]),
XXH32((uint8_t *)id.name, Bstrlen(id.name), TEXCACHEMAGIC[3]),
XXH32((uint8_t *)&id, sizeof(struct texcacheid_t), TEXCACHEMAGIC[3]));

View file

@ -5584,7 +5584,7 @@ static void MaybeTrainKillPlayer(const spritetype *s, int32_t dosetopos)
ps->cursectnum = s->sectnum;
setsprite(ps->i,(vec3_t *)s);
setsprite(ps->i,(vec3_t const *)s);
P_QuickKill(ps);
}
}

View file

@ -384,7 +384,7 @@ static int32_t texuploaded;
// YUV->RGB conversion fragment shader adapted from
// http://www.fourcc.org/fccyvrgb.php: "Want some sample code?"
// direct link: http://www.fourcc.org/source/YUV420P-OpenGL-GLSLang.c
static char *fragprog_src =
static const char *fragprog_src =
"#version 120\n"
"uniform sampler2D tex;\n"

View file

@ -8042,7 +8042,7 @@ static void G_CheckCommandLine(int32_t argc, const char **argv)
while (i < argc)
{
c = (char *)argv[i];
c = argv[i];
if ((*c == '-')
#ifdef _WIN32

View file

@ -417,7 +417,7 @@ static inline int32_t G_GetTeamPalette(int32_t team)
#define minitextshade(x, y, t, s, p, sb) minitext_(x,y,t,s,p,sb)
#define minitext(x, y, t, p, sb) minitext_(x,y,t,0,p,sb)
#define menutext(x,y,s,p,t) menutext_(x,y,s,p,(char *)OSD_StripColors(menutextbuf,t),10+16)
#define menutext(x,y,s,p,t) menutext_(x,y,s,p,OSD_StripColors(menutextbuf,t),10+16)
#define gametext(x,y,t,s,dabits) G_PrintGameText(0,STARTALPHANUM, x,y,t,s,0,dabits,0, 0, xdim-1, ydim-1, 65536, 0)
#define gametextscaled(x,y,t,s,dabits) G_PrintGameText(1,STARTALPHANUM, x,y,t,s,0,dabits,0, 0, xdim-1, ydim-1, 65536, 0)
#define gametextpal(x,y,t,s,p) G_PrintGameText(0,STARTALPHANUM, x,y,t,s,p,26,0, 0, xdim-1, ydim-1, 65536, 0)

View file

@ -93,7 +93,7 @@ enum
};
#if !defined LUNATIC
static const char *C_GetLabelType(int32_t type)
static char *C_GetLabelType(int32_t type)
{
int32_t i;
char x[64];
@ -1954,7 +1954,7 @@ static int32_t C_GetNextValue(int32_t type)
{
if (!(g_numCompilerErrors || g_numCompilerWarnings) && g_scriptDebug > 1)
{
char *gl = (char *)C_GetLabelType(labeltype[i]);
char *gl = C_GetLabelType(labeltype[i]);
initprintf("%s:%d: debug: %s label `%s'.\n",g_szScriptFileName,g_lineNumber,gl,label+(i<<6));
Bfree(gl);
}
@ -1969,8 +1969,8 @@ static int32_t C_GetNextValue(int32_t type)
BITPTR_CLEAR(g_scriptPtr-script);
*(g_scriptPtr++) = 0;
textptr += l;
char *el = (char *)C_GetLabelType(type);
char *gl = (char *)C_GetLabelType(labeltype[i]);
char *el = C_GetLabelType(type);
char *gl = C_GetLabelType(labeltype[i]);
C_ReportError(-1);
initprintf("%s:%d: warning: expected %s, found %s.\n",g_szScriptFileName,g_lineNumber,el,gl);
g_numCompilerWarnings++;
@ -6162,7 +6162,7 @@ void C_Compile(const char *filenam)
C_InitProjectiles();
int32_t fp = kopen4loadfrommod((char *)filenam,g_loadFromGroupOnly);
int32_t fp = kopen4loadfrommod(filenam,g_loadFromGroupOnly);
if (fp == -1) // JBF: was 0
{

View file

@ -142,7 +142,7 @@ G_EXTERN sound_t g_sounds[MAXSOUNDS];
G_EXTERN uint32_t everyothertime;
G_EXTERN uint32_t g_moveThingsCount;
G_EXTERN vec3_t my,omy,myvel;
G_EXTERN volatile char g_soundlocks[MAXSOUNDS];
G_EXTERN char g_soundlocks[MAXSOUNDS];
G_EXTERN int32_t g_restorePalette;
G_EXTERN int32_t g_screenCapture;
G_EXTERN int32_t g_noEnemies;

View file

@ -84,7 +84,7 @@ typedef struct VoiceNode
const int16_t *LeftVolume;
const int16_t *RightVolume;
const void *rawdataptr;
void *rawdataptr;
const char *NextBlock;
const char *LoopStart;

View file

@ -80,7 +80,7 @@ static playbackstatus MV_GetNextVOCBlock(VoiceNode *voice)
return KeepPlaying;
}
const uint8_t *ptr = (uint8_t *)voice->NextBlock;
const uint8_t *ptr = (uint8_t const *)voice->NextBlock;
voice->Playing = TRUE;
voice->Paused = FALSE;
@ -186,7 +186,7 @@ end_of_data:
// Repeat begin
if (voice->LoopEnd == NULL)
{
voice->LoopCount = LITTLE16(*(uint16_t *)ptr);
voice->LoopCount = LITTLE16(*(uint16_t const *)ptr);
voice->LoopStart = (char *)((intptr_t) ptr + blocklength);
}
ptr += blocklength;
@ -201,7 +201,7 @@ end_of_data:
{
if ((voice->LoopCount > 0) && (voice->LoopStart != NULL))
{
ptr = (uint8_t *) voice->LoopStart;
ptr = (uint8_t const *) voice->LoopStart;
if (voice->LoopCount < 0xffff)
{
@ -216,7 +216,7 @@ end_of_data:
// Extended block
voice->bits = 8;
voice->channels = 1;
tc = LITTLE16(*(uint16_t *)ptr);
tc = LITTLE16(*(uint16_t const *)ptr);
packtype = *(ptr + 2);
voicemode = *(ptr + 3);
ptr += blocklength;
@ -224,10 +224,10 @@ end_of_data:
case 9 :
// New sound data block
samplespeed = LITTLE32(*(uint32_t *)ptr);
samplespeed = LITTLE32(*(uint32_t const *)ptr);
BitsPerSample = (unsigned)*(ptr + 4);
Channels = (unsigned)*(ptr + 5);
Format = (unsigned)LITTLE16(*(uint16_t *)(ptr + 6));
Format = (unsigned)LITTLE16(*(uint16_t const *)(ptr + 6));
if ((BitsPerSample == 8) && (Channels == 1 || Channels == 2) && (Format == VOC_8BIT))
{
@ -271,8 +271,8 @@ end_of_data:
if (voice->Playing)
{
voice->NextBlock = (char *)ptr + blocklength;
voice->sound = (char *)ptr;
voice->NextBlock = (char const *)ptr + blocklength;
voice->sound = (char const *)ptr;
// CODEDUP multivoc.c MV_SetVoicePitch
voice->SamplingRate = samplespeed;

View file

@ -193,7 +193,7 @@ static wavefmt_t FX_AutoDetectFormat(const char *ptr, uint32_t length)
if (length < 12)
return fmt;
switch (LITTLE32(*(int32_t *)ptr))
switch (LITTLE32(*(int32_t const *)ptr))
{
case 'C' + ('r' << 8) + ('e' << 16) + ('a' << 24): // Crea
fmt = FMT_VOC;
@ -202,7 +202,7 @@ static wavefmt_t FX_AutoDetectFormat(const char *ptr, uint32_t length)
fmt = FMT_VORBIS;
break;
case 'R' + ('I' << 8) + ('F' << 16) + ('F' << 24): // RIFF
switch (LITTLE32(*(int32_t *)(ptr + 8)))
switch (LITTLE32(*(int32_t const *)(ptr + 8)))
{
case 'C' + ('D' << 8) + ('X' << 16) + ('A' << 24): // CDXA
fmt = FMT_XA;
@ -214,7 +214,7 @@ static wavefmt_t FX_AutoDetectFormat(const char *ptr, uint32_t length)
fmt = FMT_FLAC;
break;
default:
switch (LITTLE32(*(int32_t *)(ptr + 8)))
switch (LITTLE32(*(int32_t const *)(ptr + 8)))
{
case 'W' + ('A' << 8) + ('V' << 16) + ('E' << 24): // WAVE
fmt = FMT_WAV;

View file

@ -32,7 +32,7 @@
// 8-bit mono source, 16-bit mono output
void MV_Mix16BitMono(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
uint8_t const * const source = (uint8_t *) start;
uint8_t const * const source = (uint8_t const *) start;
int16_t *dest = (int16_t *) MV_MixDestination;
int32_t sample0;
@ -56,7 +56,7 @@ void MV_Mix16BitMono(uint32_t position, uint32_t rate, const char *start, uint32
// 8-bit mono source, 16-bit stereo output
void MV_Mix16BitStereo(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
uint8_t const * const source = (uint8_t *) start;
uint8_t const * const source = (uint8_t const *) start;
int16_t *dest = (int16_t *) MV_MixDestination;
int32_t sample0, sample1;
@ -85,7 +85,7 @@ void MV_Mix16BitStereo(uint32_t position, uint32_t rate, const char *start, uint
// 16-bit mono source, 16-bit mono output
void MV_Mix16BitMono16(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
uint16_t const * const source = (uint16_t *) start;
uint16_t const * const source = (uint16_t const *) start;
int16_t *dest = (int16_t *) MV_MixDestination;
int32_t sample0l, sample0h, sample0;
@ -118,7 +118,7 @@ void MV_Mix16BitMono16(uint32_t position, uint32_t rate, const char *start, uint
// 16-bit mono source, 16-bit stereo output
void MV_Mix16BitStereo16(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
uint16_t const * const source = (uint16_t *) start;
uint16_t const * const source = (uint16_t const *) start;
int16_t *dest = (int16_t *) MV_MixDestination;
int32_t sample0l, sample0h, sample0;
int32_t sample1l, sample1h, sample1;
@ -159,7 +159,7 @@ void MV_Mix16BitStereo16(uint32_t position, uint32_t rate, const char *start, ui
void MV_16BitReverb(char const *src, char *dest, int16_t *volume, int32_t count)
{
uint16_t const * input = (uint16_t *) src;
uint16_t const * input = (uint16_t const *) src;
int16_t * output = (int16_t *) dest;
int16_t sample0l, sample0h, sample0;

View file

@ -33,7 +33,7 @@
// 8-bit stereo source, 16-bit mono output
void MV_Mix16BitMono8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
uint8_t const * const source = (uint8_t *) start;
uint8_t const * const source = (uint8_t const *) start;
int16_t *dest = (int16_t *) MV_MixDestination;
int32_t sample0, sample1;
@ -58,7 +58,7 @@ void MV_Mix16BitMono8Stereo(uint32_t position, uint32_t rate, const char *start,
// 8-bit stereo source, 16-bit stereo output
void MV_Mix16BitStereo8Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
uint8_t const * const source = (uint8_t *) start;
uint8_t const * const source = (uint8_t const *) start;
int16_t *dest = (int16_t *) MV_MixDestination;
int32_t sample0, sample1;
@ -87,7 +87,7 @@ void MV_Mix16BitStereo8Stereo(uint32_t position, uint32_t rate, const char *star
// 16-bit stereo source, 16-bit mono output
void MV_Mix16BitMono16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
uint16_t const * const source = (uint16_t *) start;
uint16_t const * const source = (uint16_t const *) start;
int16_t *dest = (int16_t *) MV_MixDestination;
int32_t sample0l, sample0h, sample0;
int32_t sample1l, sample1h, sample1;
@ -131,7 +131,7 @@ void MV_Mix16BitMono16Stereo(uint32_t position, uint32_t rate, const char *start
// 16-bit stereo source, 16-bit stereo output
void MV_Mix16BitStereo16Stereo(uint32_t position, uint32_t rate, const char *start, uint32_t length)
{
uint16_t const * const source = (uint16_t *) start;
uint16_t const * const source = (uint16_t const *) start;
int16_t *dest = (int16_t *) MV_MixDestination;
int32_t sample0l, sample0h, sample0;
int32_t sample1l, sample1h, sample1;

View file

@ -89,7 +89,7 @@ typedef struct
lp_descriptor * curlp; // header of large page currently in memory
uint16_t * thepage; // buffer where current large page is loaded
uint8_t imagebuffer[IMAGEBUFFERSIZE]; // buffer where anim frame is decoded
const uint8_t * buffer;
uint8_t * buffer;
uint8_t pal[768];
int32_t currentframe;
} anim_t;
@ -255,7 +255,7 @@ static inline void drawframe(uint16_t framenumber)
}
// <length> is the file size, for consistency checking.
int32_t ANIM_LoadAnim(const uint8_t *buffer, int32_t length)
int32_t ANIM_LoadAnim(uint8_t *buffer, int32_t length)
{
int32_t i;

View file

@ -45,7 +45,7 @@ extern "C" {
//
//****************************************************************************
int32_t ANIM_LoadAnim(const uint8_t *buffer, int32_t length);
int32_t ANIM_LoadAnim(uint8_t *buffer, int32_t length);
//****************************************************************************
//

View file

@ -116,7 +116,7 @@ static const char *LabelTypeText[] =
"event"
};
static const char *C_GetLabelType(int32_t type)
static char *C_GetLabelType(int32_t type)
{
uint32_t i;
char x[64];
@ -1457,8 +1457,8 @@ static int32_t C_GetNextValue(int32_t type)
*(g_scriptPtr++) = 0;
textptr += l;
el = (char *)C_GetLabelType(type);
gl = (char *)C_GetLabelType(labeltype[i]);
el = C_GetLabelType(type);
gl = C_GetLabelType(labeltype[i]);
C_CUSTOMERROR("expected %s, found %s.", el, gl);
// initprintf("i=%d, %s!!! lt:%d t:%d\n", i, label+(i*MAXLABELLEN), labeltype[i], type);
Bfree(el);

View file

@ -226,13 +226,13 @@ static inline void __fastcall VM_DoConditional(register int32_t condition)
static int X_DoSortDefault(const void *lv, const void *rv)
{
return *(int32_t *)rv - *(int32_t *)lv;
return *(int32_t const *)rv - *(int32_t const *)lv;
}
static int X_DoSort(const void *lv, const void *rv)
{
m32_sortvar1 = *(int32_t *)lv;
m32_sortvar2 = *(int32_t *)rv;
m32_sortvar1 = *(int32_t const *)lv;
m32_sortvar2 = *(int32_t const *)rv;
insptr = x_sortingstateptr;
VM_Execute(0);
return g_iReturnVar;

View file

@ -100,7 +100,7 @@ static void creditsminitext(int32_t x, int32_t y, const char *t, int32_t p)
G_ScreenTextShadow(1, 1, MINIFONT, x, y, 65536, 0, 0, t, 0, p, 2|8|16|ROTATESPRITE_FULL16, 0, 4<<16, 8<<16, 1<<16, 0, f, 0, 0, xdim-1, ydim-1);
}
int32_t menutext_(int32_t x, int32_t y, int32_t s, int32_t p, char *t, int32_t bits)
int32_t menutext_(int32_t x, int32_t y, int32_t s, int32_t p, char const *t, int32_t bits)
{
vec2_t dim;
int32_t f = TEXT_BIGALPHANUM|TEXT_UPPERCASE|TEXT_LITERALESCAPE;

View file

@ -418,7 +418,7 @@ extern Menu_t *m_currentMenu;
extern int32_t g_lastSaveSlot;
extern int32_t g_quitDeadline;
extern int32_t voting;
int32_t menutext_(int32_t x,int32_t y,int32_t s,int32_t p,char *t,int32_t bits);
int32_t menutext_(int32_t x,int32_t y,int32_t s,int32_t p,char const *t,int32_t bits);
int M_ChangeMenu(int32_t cm);
void M_ChangeMenuAnimate(int32_t cm, MenuAnimationType_t animtype);
int32_t M_IsTextInput(Menu_t *cm);

View file

@ -1109,7 +1109,7 @@ void Net_ReceiveMapUpdate(ENetEvent *event)
static int Net_CompareActors(const void *actor1, const void *actor2)
{
return ((netactor_t *)actor1)->netIndex - ((netactor_t *)actor2)->netIndex;
return ((netactor_t const *)actor1)->netIndex - ((netactor_t const *)actor2)->netIndex;
}
void Net_SaveMapState(netmapstate_t *save)

View file

@ -47,7 +47,7 @@ static int32_t RTS_AddFile(const char *filename)
// read the entire file in
// FIXME: shared opens
handle = kopen4loadfrommod((char *)filename, 0);
handle = kopen4loadfrommod(filename, 0);
if (handle < 0)
{
initprintf("RTS file \"%s\" was not found\n",filename);

View file

@ -505,11 +505,19 @@ void G_SavePlayerMaybeMulti(int32_t slot)
typedef struct dataspec_
{
uint32_t flags;
void *ptr;
void * const ptr;
uint32_t size;
intptr_t cnt;
} dataspec_t;
typedef struct dataspec_gv_
{
uint32_t flags;
void * ptr;
uint32_t size;
intptr_t cnt;
} dataspec_gv_t;
#define SV_DEFAULTCOMPRTHRES 8
static uint8_t savegame_diffcompress; // 0:none, 1:Ken's LZW in cache1d.c
static uint8_t savegame_comprthres;
@ -690,7 +698,8 @@ static int32_t readspecdata(const dataspec_t *spec, int32_t fil, uint8_t **dumpv
#define UINT(bits) uint##bits##_t
#define BYTES(bits) (bits>>3)
#define VAL(bits,p) (*(UINT(bits) *)(p))
#define VAL(bits,p) (*(UINT(bits) const *)(p))
#define WVAL(bits,p) (*(UINT(bits) *)(p))
static void docmpsd(const void *ptr, void *dump, uint32_t size, uint32_t cnt, uint8_t **diffvar)
{
@ -700,7 +709,7 @@ static void docmpsd(const void *ptr, void *dump, uint32_t size, uint32_t cnt, ui
#define CPSINGLEVAL(Datbits) \
if (VAL(Datbits, ptr) != VAL(Datbits, dump)) \
{ \
VAL(Datbits, retdiff) = VAL(Datbits, dump) = VAL(Datbits, ptr); \
WVAL(Datbits, retdiff) = WVAL(Datbits, dump) = VAL(Datbits, ptr); \
*diffvar = retdiff+BYTES(Datbits); \
}
@ -720,21 +729,21 @@ static void docmpsd(const void *ptr, void *dump, uint32_t size, uint32_t cnt, ui
if (*p!=*op) \
{ \
*op = *p; \
VAL(Idxbits, retdiff) = i; \
WVAL(Idxbits, retdiff) = i; \
retdiff += BYTES(Idxbits); \
VAL(Datbits, retdiff) = *p; \
WVAL(Datbits, retdiff) = *p; \
retdiff += BYTES(Datbits); \
} \
p++; \
op++; \
} \
VAL(Idxbits, retdiff) = -1; \
WVAL(Idxbits, retdiff) = -1; \
retdiff += BYTES(Idxbits); \
} while (0)
#define CPDATA(Datbits) do \
{ \
const UINT(Datbits) *p=(UINT(Datbits) *)ptr; \
const UINT(Datbits) *p=(UINT(Datbits) const *)ptr; \
UINT(Datbits) *op=(UINT(Datbits) *)dump; \
uint32_t i, nelts=tabledivide32_noinline(size*cnt, BYTES(Datbits)); \
if (nelts>65536) \
@ -844,7 +853,7 @@ static int32_t applydiff(const dataspec_t *spec, uint8_t **dumpvar, uint8_t **di
// ----------
#define CPSINGLEVAL(Datbits) \
VAL(Datbits, dumptr) = VAL(Datbits, diffptr); \
WVAL(Datbits, dumptr) = VAL(Datbits, diffptr); \
diffptr += BYTES(Datbits); \
dumptr += BYTES(Datbits)
@ -983,9 +992,10 @@ static char(*savegame_quotes)[MAXQUOTELEN];
static char(*savegame_quoteredefs)[MAXQUOTELEN];
static uint8_t savegame_restdata[SVARDATALEN];
static char svgm_udnetw_string [] = "blK:udnt";
static const dataspec_t svgm_udnetw[] =
{
{ DS_STRING, (void *)"blK:udnt", 0, 1 },
{ DS_STRING, (void *)svgm_udnetw_string, 0, 1 },
{ 0, &ud.multimode, sizeof(ud.multimode), 1 },
{ 0, &g_numPlayerSprites, sizeof(g_numPlayerSprites), 1 },
{ 0, &g_playerSpawnPoints, sizeof(g_playerSpawnPoints), 1 },
@ -1031,9 +1041,10 @@ static const dataspec_t svgm_udnetw[] =
# define DS_MAINAR 0
#endif
static char svgm_secwsp_string [] = "blK:swsp";
static const dataspec_t svgm_secwsp[] =
{
{ DS_STRING, (void *)"blK:swsp", 0, 1 },
{ DS_STRING, (void *)svgm_secwsp_string, 0, 1 },
{ DS_NOCHK, &numwalls, sizeof(numwalls), 1 },
{ DS_MAINAR|DS_CNT(numwalls), &wall, sizeof(walltype), (intptr_t)&numwalls },
{ DS_NOCHK, &numsectors, sizeof(numsectors), 1 },
@ -1077,9 +1088,10 @@ static const dataspec_t svgm_secwsp[] =
{ DS_END, 0, 0, 0 }
};
static char svgm_script_string [] = "blK:scri";
static const dataspec_t svgm_script[] =
{
{ DS_STRING, (void *)"blK:scri", 0, 1 },
{ DS_STRING, (void *)svgm_script_string, 0, 1 },
#if !defined LUNATIC
{ DS_NOCHK, &g_scriptSize, sizeof(g_scriptSize), 1 },
{ DS_SAVEFN|DS_LOADFN|DS_NOCHK, (void *)&sv_calcbitptrsize, 0, 1 },
@ -1108,9 +1120,12 @@ static const dataspec_t svgm_script[] =
{ DS_END, 0, 0, 0 }
};
static char svgm_anmisc_string [] = "blK:anms";
static char svgm_end_string [] = "savegame_end";
static const dataspec_t svgm_anmisc[] =
{
{ DS_STRING, (void *)"blK:anms", 0, 1 },
{ DS_STRING, (void *)svgm_anmisc_string, 0, 1 },
{ 0, &g_animateCount, sizeof(g_animateCount), 1 },
{ 0, &animatesect[0], sizeof(animatesect[0]), MAXANIMATES },
{ 0, &animategoal[0], sizeof(animategoal[0]), MAXANIMATES },
@ -1151,12 +1166,12 @@ static const dataspec_t svgm_anmisc[] =
{ 0, savegame_restdata, 1, sizeof(savegame_restdata) }, // sz/cnt swapped for kdfread
{ DS_LOADFN, (void *)&sv_restload, 0, 1 },
{ DS_STRING, (void *)"savegame_end", 0, 1 },
{ DS_STRING, (void *)svgm_end_string, 0, 1 },
{ DS_END, 0, 0, 0 }
};
#if !defined LUNATIC
static dataspec_t *svgm_vars=NULL;
static dataspec_gv_t *svgm_vars=NULL;
#endif
static uint8_t *dosaveplayer2(FILE *fil, uint8_t *mem);
static int32_t doloadplayer2(int32_t fil, uint8_t **memptr);
@ -1186,7 +1201,7 @@ static void sv_makevarspec()
numsavedarrays += !(aGameArrays[i].dwFlags & GAMEARRAY_READONLY); // SYSTEM_GAMEARRAY
Bfree(svgm_vars);
svgm_vars = (dataspec_t *)Xmalloc((numsavedvars+numsavedarrays+2)*sizeof(dataspec_t));
svgm_vars = (dataspec_gv_t *)Xmalloc((numsavedvars+numsavedarrays+2)*sizeof(dataspec_gv_t));
svgm_vars[0].flags = DS_STRING;
svgm_vars[0].ptr = magic;
@ -1261,7 +1276,7 @@ int32_t sv_saveandmakesnapshot(FILE *fil, int8_t spot, int8_t recdiffsp, int8_t
// calculate total snapshot size
#if !defined LUNATIC
sv_makevarspec();
svsnapsiz = calcsz(svgm_vars);
svsnapsiz = calcsz((const dataspec_t *)svgm_vars);
#else
svsnapsiz = 0;
#endif
@ -1523,7 +1538,7 @@ uint32_t sv_writediff(FILE *fil)
cmpspecdata(svgm_script, &p, &d);
cmpspecdata(svgm_anmisc, &p, &d);
#if !defined LUNATIC
cmpspecdata(svgm_vars, &p, &d);
cmpspecdata((const dataspec_t *)svgm_vars, &p, &d);
#endif
if (p != svsnapshot+svsnapsiz)
@ -1570,7 +1585,7 @@ int32_t sv_readdiff(int32_t fil)
if (applydiff(svgm_script, &p, &d)) return -5;
if (applydiff(svgm_anmisc, &p, &d)) return -6;
#if !defined LUNATIC
if (applydiff(svgm_vars, &p, &d)) return -7;
if (applydiff((const dataspec_t *)svgm_vars, &p, &d)) return -7;
#endif
if (p!=svsnapshot+svsnapsiz)
@ -1915,7 +1930,7 @@ static uint8_t *dosaveplayer2(FILE *fil, uint8_t *mem)
#if !defined LUNATIC
Gv_WriteSave(fil, 1); // gamevars
mem=writespecdata(svgm_vars, 0, mem);
mem=writespecdata((const dataspec_t *)svgm_vars, 0, mem);
PRINTSIZE("vars");
#endif
@ -2042,7 +2057,7 @@ int32_t sv_updatestate(int32_t frominit)
if (readspecdata(svgm_anmisc, -1, &p)) return -6;
#if !defined LUNATIC
if (readspecdata(svgm_vars, -1, &p)) return -8;
if (readspecdata((const dataspec_t *)svgm_vars, -1, &p)) return -8;
#endif
if (p != pbeg+svsnapsiz)

View file

@ -277,19 +277,23 @@ void S_Cleanup(void)
// process from our own local copy of the delete queue so we don't hold the lock long
mutex_lock(&s_mutex);
if (!dnum)
uint32_t ldnum = dnum;
if (!ldnum)
{
mutex_unlock(&s_mutex);
return;
}
Bmemcpy(ldq, (void *)dq, dnum * sizeof(int32_t));
uint32_t ldnum = dnum-1;
dnum = 0;
for (uint32_t i = 0; i < ldnum; i++)
ldq[i] = dq[i];
mutex_unlock(&s_mutex);
ldnum--;
do
{
uint32_t num = ldq[ldnum];

View file

@ -76,7 +76,7 @@ typedef struct
char pr,m; // 2b
} sound_t;
extern volatile char g_soundlocks[MAXSOUNDS];
extern char g_soundlocks[MAXSOUNDS];
extern sound_t g_sounds[MAXSOUNDS];
extern int32_t g_skillSoundVoice;
extern int32_t g_numEnvSoundsPlaying,g_maxSoundPos;

View file

@ -40,7 +40,7 @@ typedef struct {
SOUNDOWNER SoundOwner[4];
int16_t ps,pe,vo;
char pr,m;
volatile char lock;
char lock;
char *definedname; // new
} sound_t;