diff --git a/polymer/eduke32/source/gameexec.c b/polymer/eduke32/source/gameexec.c index 2089e7e54..d0d634b44 100644 --- a/polymer/eduke32/source/gameexec.c +++ b/polymer/eduke32/source/gameexec.c @@ -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 int64_t + Bfree(tmpar); +#else + kread(fil, aGameArrays[j].plValues, numbytes); +#endif } kclose(fil); diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index ba45b7d3d..f9824b455 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -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; inumloogs; 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); } }