C-CON: fix 'readgamearray' on 64-bit platforms.

Also prettify P_DisplaySpit().

git-svn-id: https://svn.eduke32.com/eduke32@4734 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-11-07 22:07:12 +00:00
parent 44373a7698
commit 108a4022fa
2 changed files with 32 additions and 19 deletions

View file

@ -4430,9 +4430,9 @@ finish_qsprintf:
case CON_READARRAYFROMFILE:
insptr++;
{
int32_t j=*insptr++;
const int32_t j=*insptr++;
{
int q = *insptr++;
const int q = *insptr++;
if (EDUKE32_PREDICT_FALSE(ScriptQuotes[q] == NULL))
{
@ -4443,21 +4443,34 @@ finish_qsprintf:
if (tw == CON_READARRAYFROMFILE)
{
int32_t fil = kopen4loadfrommod(ScriptQuotes[q], 0);
int32_t asize;
int32_t numelts;
if (fil < 0)
continue;
asize = kfilelength(fil);
numelts = kfilelength(fil) / sizeof(int32_t);
if (asize > 0)
// NOTE: LunaCON is stricter: if the file has no
// elements, resize the array to size zero.
if (numelts > 0)
{
// NOTE: this is broken on 64-bit, e.g. for LNGA2.
/*OSD_Printf(OSDTEXT_GREEN "CON_RESIZEARRAY: resizing array %s from %d to %d\n",
aGameArrays[j].szLabel, aGameArrays[j].size, asize / GAR_ELTSZ);*/
aGameArrays[j].plValues = (intptr_t *)Xrealloc(aGameArrays[j].plValues, asize);
aGameArrays[j].size = asize/GAR_ELTSZ;
kread(fil, aGameArrays[j].plValues, asize);
aGameArrays[j].szLabel, aGameArrays[j].size, numelts);*/
int32_t numbytes = numelts * sizeof(int32_t);
#ifdef BITNESS64
int32_t *tmpar = Xmalloc(numbytes);
kread(fil, tmpar, numbytes);
#endif
aGameArrays[j].plValues = (intptr_t *)Xrealloc(
aGameArrays[j].plValues, numelts * GAR_ELTSZ);
aGameArrays[j].size = numelts;
#ifdef BITNESS64
for (int32_t i=0; i<numelts; i++)
aGameArrays[j].plValues[i] = tmpar[i]; // int32_t --> int64_t
Bfree(tmpar);
#else
kread(fil, aGameArrays[j].plValues, numbytes);
#endif
}
kclose(fil);

View file

@ -1660,22 +1660,22 @@ int32_t A_ShootWithZvel(int32_t i, int32_t atwith, int32_t override_zvel)
static void P_DisplaySpit(int32_t snum)
{
int32_t i, a, x, y, z;
DukePlayer_t *const ps = g_player[snum].ps;
const int32_t loogcnt = ps->loogcnt;
const int32_t y = loogcnt<<2;
if (ps->loogcnt == 0)
if (loogcnt == 0)
return;
y = (ps->loogcnt<<2);
for (i=0; i<ps->numloogs; i++)
for (int32_t i=0; i < ps->numloogs; i++)
{
a = klabs(sintable[((ps->loogcnt+i)<<5)&2047])>>5;
z = 4096+((ps->loogcnt+i)<<9);
x = (-g_player[snum].sync->avel>>1)+(sintable[((ps->loogcnt+i)<<6)&2047]>>10);
int32_t a = klabs(sintable[((loogcnt+i)<<5)&2047])>>5;
int32_t z = 4096 + ((loogcnt+i)<<9);
int32_t x = (-g_player[snum].sync->avel>>1) + (sintable[((loogcnt+i)<<6)&2047]>>10);
rotatesprite_fs(
(ps->loogiex[i]+x)<<16,(200+ps->loogiey[i]-y)<<16,z-(i<<8),256-a,
(ps->loogiex[i]+x)<<16, (200+ps->loogiey[i]-y)<<16,
z-(i<<8), 256-a,
LOOGIE,0,0,2);
}
}