engine: fix a possible crash with texel-hitscan.

Reproduced as follows (assuming all tiles have texel-hitscan for simplicity):
In E2L5, shoot the opening switch with the shotgun, aiming for the border.
The crash occurs because the *other*, depressed switch tile isn't yet loaded
when we index into its tile storage. Dereferencing 0+small number == BAD!

git-svn-id: https://svn.eduke32.com/eduke32@3364 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2013-01-02 22:33:27 +00:00
parent e4caa58cf2
commit 4a6ded3f98

View file

@ -11670,14 +11670,20 @@ restart_grand:
{ {
if (picanm[tilenum].sf&PICANM_TEXHITSCAN_BIT) if (picanm[tilenum].sf&PICANM_TEXHITSCAN_BIT)
{ {
// daz-intz > 0 && daz-intz < k if (!waloff[tilenum])
int32_t xtex = mulscale16(ucoefup16, tilesizx[tilenum]); loadtile(tilenum);
int32_t vcoefup16 = 65536-divscale16(daz-intz, k);
int32_t ytex = mulscale16(vcoefup16, tilesizy[tilenum]);
const char *texel = (char *)(waloff[tilenum] + tilesizy[tilenum]*xtex + ytex); if (waloff[tilenum])
if (*texel == 255) {
continue; // daz-intz > 0 && daz-intz < k
int32_t xtex = mulscale16(ucoefup16, tilesizx[tilenum]);
int32_t vcoefup16 = 65536-divscale16(daz-intz, k);
int32_t ytex = mulscale16(vcoefup16, tilesizy[tilenum]);
const char *texel = (char *)(waloff[tilenum] + tilesizy[tilenum]*xtex + ytex);
if (*texel == 255)
continue;
}
} }
hit_set(hit, dasector, -1, z, intx, inty, intz); hit_set(hit, dasector, -1, z, intx, inty, intz);