From a38307a54fc8bf0ee6dadd6432adc376cd3b8fe1 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sun, 31 Oct 2010 19:54:03 +0000 Subject: [PATCH] Fixes quite a few nasty bugs with the new clipping code, including the crash. Clip shapes are now loaded from _clipshape0.map through _clipshape9.map (no break like when loading tiles, just see if each is present). Mapster32: insert some safety code for sprites with sectnum<0. Because this is still a bad thing, have the m32script corruption checker catch this and run it periodically from EVENT_DRAW2DSCREEN. Also draw such sprites in 2D mode with a blood-red color, and make them draggable. Remove set[sector,wall,sprite] commands. git-svn-id: https://svn.eduke32.com/eduke32@1722 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/baselayer.h | 1 - polymer/eduke32/build/src/build.c | 35 ++-- polymer/eduke32/build/src/engine.c | 214 ++++++++++++++++------ polymer/eduke32/build/src/winlayer.c | 5 - polymer/eduke32/samples/_clipshape0.map | Bin 0 -> 23858 bytes polymer/eduke32/samples/a.m32 | 46 ++++- polymer/eduke32/samples/spriteclip.txt | 31 ++-- polymer/eduke32/source/astub.c | 13 +- polymer/eduke32/source/game.c | 6 +- polymer/eduke32/source/m32def.c | 6 +- polymer/eduke32/source/m32def.h | 2 + polymer/eduke32/source/m32exec.c | 5 +- 12 files changed, 260 insertions(+), 104 deletions(-) create mode 100644 polymer/eduke32/samples/_clipshape0.map diff --git a/polymer/eduke32/build/include/baselayer.h b/polymer/eduke32/build/include/baselayer.h index e73361960..488aaced0 100644 --- a/polymer/eduke32/build/include/baselayer.h +++ b/polymer/eduke32/build/include/baselayer.h @@ -104,7 +104,6 @@ int32_t handleevents(void); extern inline void idle(void); extern inline void idle_waitevent(void); extern inline void idle_waitevent_timeout(uint32_t timeout); -extern void debug_sleep(int32_t ms); extern void (*keypresscallback)(int32_t,int32_t); extern void (*mousepresscallback)(int32_t,int32_t); diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index fdb4e73bd..daccb2354 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -444,11 +444,11 @@ int32_t app_main(int32_t argc, const char **argv) if (j > k) { k = j; whitecol = i; } } - k = clipmapinfo_load("_clipshape_.map"); + k = clipmapinfo_load("_clipshape0.map"); if (k==0) - initprintf("Loaded sprite clipping map from \"_clipshape_.map\"\n"); + initprintf("Loaded sprite clipping map.\n"); else if (k>0) - initprintf("There was an error loading the sprite clipping map from \"_clipshape_.map\" (status %d).\n", k); + initprintf("There was an error loading the sprite clipping map (status %d).\n", k); for (i=0; i= highlighty1 && sprite[i].y <= highlighty2) { if (!sub) - show2dsprite[i>>3] |= (1<<(i&7)); + { + if (sprite[i].sectnum >= 0) // don't allow to select sprites in null space + show2dsprite[i>>3] |= (1<<(i&7)); + } else show2dsprite[i>>3] &= ~(1<<(i&7)); } @@ -2545,9 +2548,12 @@ void overheadeditor(void) setsprite(j,(vec3_t *)&sprite[j]); - tempint = ((tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<2); - sprite[j].z = max(sprite[j].z,getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint); - sprite[j].z = min(sprite[j].z,getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)); + tempint = (tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<2; + if (sprite[j].sectnum>=0) + { + sprite[j].z = max(sprite[j].z, getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint); + sprite[j].z = min(sprite[j].z, getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)); + } } } } @@ -2559,8 +2565,11 @@ void overheadeditor(void) tempint = ((tilesizy[sprite[j].picnum]*sprite[j].yrepeat)<<2); - sprite[j].z = max(sprite[j].z, getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint); - sprite[j].z = min(sprite[j].z, getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)); + if (sprite[j].sectnum>=0) + { + sprite[j].z = max(sprite[j].z, getceilzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)+tempint); + sprite[j].z = min(sprite[j].z, getflorzofslope(sprite[j].sectnum,sprite[j].x,sprite[j].y)); + } } if ((pointhighlight&0xc000) == 0) @@ -2631,7 +2640,7 @@ SKIP: // updatesector(mousxplc,mousyplc,&cursectorhighlight); cursectorhighlight = -1; for (i=0; i=0) + Bmemcpy(&sprite[daspr], &ovec, sizeof(vec3_t)); /* daz = ((tilesizy[sprite[daspr].picnum]*sprite[daspr].yrepeat)<<2); diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index 74ed985d9..ab30c7d27 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -215,6 +215,10 @@ static int16_t *sectoidx, *sectq; // [numsectors] static int16_t pictoidx[MAXTILES]; // maps tile num to clipinfo[] index static int16_t *tempictoidx; +static sectortype *loadsector; +static walltype *loadwall; +static spritetype *loadsprite; + // sectoidx bits #define CM_NONE (CM_MAX<<1) #define CM_SOME (CM_NONE-1) @@ -243,10 +247,6 @@ static void clipmapinfo_init() { int32_t i; - if (clipmapinfo.sector) { Bfree(clipmapinfo.sector); clipmapinfo.sector=NULL; } - if (clipmapinfo.wall) { Bfree(clipmapinfo.wall); clipmapinfo.wall=NULL; } - clipmapinfo.numsectors = clipmapinfo.numwalls = 0; - numclipmaps = 0; numclipsects = 0; @@ -256,6 +256,14 @@ static void clipmapinfo_init() for (i=0; iMAXSECTORS || + ournumwalls+numwalls>MAXWALLS || + ournumsprites+numsprites>MAXSPRITES) + { + initprintf("clip map: warning: exceeded limits when loading %s, aborting.\n", fn); + break; + } + + Bmemcpy(loadsector+ournumsectors, sector, numsectors*sizeof(sectortype)); + Bmemcpy(loadwall+ournumwalls, wall, numwalls*sizeof(walltype)); + Bmemcpy(loadsprite+ournumsprites, sprite, numsprites*sizeof(spritetype)); + for (i=ournumsectors; i=0) + loadwall[i].point2 += ournumwalls; + if (loadwall[i].nextwall>=0) + { + loadwall[i].nextwall += ournumwalls; + loadwall[i].nextsector += ournumsectors; + } + } + for (i=ournumsprites; i=0) + loadsprite[i].sectnum += ournumsectors; + ournumsectors += numsectors; + ournumwalls += numwalls; + ournumsprites += numsprites; + } quickloadboard = 0; - if (i<0) - return i; + + if (ournumsectors==0 || ournumwalls==0 || ournumsprites==0) // nothing loaded + { + clipmapinfo_init(); + return -1; + } + + loadsector = Brealloc(loadsector, ournumsectors*sizeof(sectortype)); + loadwall = Brealloc(loadwall, ournumwalls*sizeof(walltype)); + + Bmemcpy(sector, loadsector, ournumsectors*sizeof(sectortype)); + Bmemcpy(wall, loadwall, ournumwalls*sizeof(walltype)); + Bmemcpy(sprite, loadsprite, ournumsprites*sizeof(spritetype)); + numsectors = ournumsectors; + numwalls = ournumwalls; + + // vvvv don't use headsprite[sect,stat]! vvvv sectoidx = Bmalloc(numsectors*sizeof(sectoidx[0])); - if (!sectoidx) + if (!sectoidx || !sector || !wall) { clipmapinfo_init(); return 1; @@ -333,8 +419,12 @@ int32_t clipmapinfo_load(char *filename) { if (sectoidx[k]&CM_SOME) { - initprintf("clip map: error: tried to chain picnum %d (sprite %d) in sector %d which" - " already belongs to picnum %d.\n", pn, i, k, clipinfo[sectoidx[k]].picnum); + for (fi=0; fi<9; fi++) + if (k>=fisec[fi]) + break; + initprintf("clip map %d: error: tried to chain picnum %d (sprite %d) in sector %d which" + " already belongs to picnum %d.\n", fi, pn, i-fispr[fi], k-fisec[fi], + clipinfo[sectoidx[k]].picnum); clipmapinfo_init(); return 2; } @@ -353,8 +443,11 @@ int32_t clipmapinfo_load(char *filename) { if (sprite[i].ang!=1536 && sprite[i].ang!=512) { - initprintf("clip map: warning: sprite %d pointing neither northward nor southward. %s" - " will be wrong.", i, (sprite[i].cstat&48)==32 ? "Scaling and flipping" : "X-flipping"); + for (fi=0; fi<9; fi++) + if (i>=fispr[fi]) + break; + initprintf("clip map %d: warning: sprite %d pointing neither northward nor southward. %s will be wrong.\n", + fi, i-fispr[fi], (sprite[i].cstat&48)==32 ? "Scaling and flipping" : "X-flipping"); } } @@ -387,8 +480,11 @@ int32_t clipmapinfo_load(char *filename) { if (outersect>=0 && ns!=outersect) { - initprintf("clip map: error: encountered more than one outer sector" - " (%d and %d) for sprite %d.\n", outersect, ns, i); + for (fi=0; fi<9; fi++) + if (ns>=fisec[fi]) + break; + initprintf("clip map %d: error: encountered more than one outer sector (%d and %d)" + " for sprite %d.\n", fi, outersect-fisec[fi], ns-fisec[fi], i-fispr[fi]); clipmapinfo_init(); return 3; } @@ -398,9 +494,12 @@ int32_t clipmapinfo_load(char *filename) } else if (sectoidx[ns]!=numclipmaps) { - initprintf("clip map: error: encountered sector %d belonging to index %d" + for (fi=0; fi<9; fi++) + if (ns>=fisec[fi]) + break; + initprintf("clip map %d: error: encountered sector %d belonging to index %d" " while collecting sectors for sprite %d (index %d).\n", - ns, sectoidx[ns], i, numclipmaps); + fi, ns-fisec[fi], sectoidx[ns], i-fispr[fi], numclipmaps); clipmapinfo_init(); return 4; } @@ -408,6 +507,13 @@ int32_t clipmapinfo_load(char *filename) } } while (++scnt < numclipsects); + if (outersect==-1) + { + initprintf("clip map: INTERNAL ERROR: outersect==-1!\n"); + clipmapinfo_init(); + return 5; + } + sectq[numclipsects++] = outersect; // last is outer clipinfo[numclipmaps].qend = numclipsects-1; @@ -418,13 +524,13 @@ int32_t clipmapinfo_load(char *filename) { k = sectq[scnt]; - sector[k].floorz -= z; - sector[k].ceilingz -= z; - x = sprite[i].x; y = sprite[i].y; z = sprite[i].z; + sector[k].floorz -= z; + sector[k].ceilingz -= z; + if (scnt==clipinfo[numclipmaps].qbeg) { // backup sprite tags since we'll discard sprites later @@ -497,12 +603,14 @@ int32_t clipmapinfo_load(char *filename) } } + // yes, too much copying, but better than ugly code + Bmemcpy(loadsector, sector, ournumsectors*sizeof(sectortype)); + Bmemcpy(loadwall, wall, ournumwalls*sizeof(walltype)); + clipmapinfo.numsectors = numsectors; - clipmapinfo.sector = Bmalloc(numsectors * sizeof(sectortype)); - Bmemcpy(clipmapinfo.sector, sector, numsectors*sizeof(sectortype)); + clipmapinfo.sector = loadsector; clipmapinfo.numwalls = numwalls; - clipmapinfo.wall = Bmalloc(numwalls * sizeof(walltype)); - Bmemcpy(clipmapinfo.wall, wall, numwalls*sizeof(walltype)); + clipmapinfo.wall = loadwall; for (i=0; iwallptr; endwall = startwall + sec->wallnum; for (j=startwall,wal=&wall[startwall]; jnextsector]; if ((sec2->floorstat&1) == 0) // if (dasect==sectq[clipinfo[curidx].qend] || daz2 < daz-(1<<8)) - if (vect->z <= basez+(flordist-1)) - if (vect->z >= daz2-(flordist-1)) clipyou = 1; + if (daz2-(flordist-1) <= vect->z && vect->z <= basez+(flordist-1)) + clipyou = 1; if (clipyou == 0) { daz = getceilzofslope((int16_t)dasect,dax,day); @@ -9642,8 +9755,8 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, basez = getceilzofslope(sectq[clipinfo[curidx].qend],dax,day); if ((sec2->ceilingstat&1) == 0) // if (dasect==sectq[clipinfo[curidx].qend] || daz2 > daz+(1<<8)) - if (vect->z >= basez-(ceildist-1)) - if (vect->z <= daz2+(ceildist-1)) clipyou = 1; + if (basez-(ceildist-1) <= vect->z && vect->z <= daz2+(ceildist-1)) + clipyou = 1; } } } @@ -9699,7 +9812,7 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, day = walldist; if (dx < 0) day = -day; addclipline(x1+dax,y1+day,x2+dax,y2+day,objtype); } - else + else if (wal->nextsector>=0) { for (i=clipsectnum-1; i>=0; i--) if (wal->nextsector == clipsectorlist[i]) break; @@ -9836,8 +9949,6 @@ int32_t clipmove(vec3_t *vect, int16_t *sectnum, break; } } -//if (clipspritenum) -// initprintf("sect %d/%d sprite %d/%d\n", clipsectcnt,clipsectnum, clipspritecnt,clipspritenum); } while (clipsectcnt < clipsectnum || clipspritecnt < clipspritenum); @@ -11213,11 +11324,6 @@ int32_t sectorofwall(int16_t theline) // int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day) { -#if defined _WIN32 && defined DEBUGGINGAIDS - if (sectnum<0 || sectnum>numsectors) - debug_sleep(15000); -#endif - if (!(sector[sectnum].ceilingstat&2)) return(sector[sectnum].ceilingz); { @@ -11238,11 +11344,6 @@ int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day) // int32_t getflorzofslope(int16_t sectnum, int32_t dax, int32_t day) { -#if defined _WIN32 && defined DEBUGGINGAIDS - if (sectnum<0 || sectnum>numsectors) - debug_sleep(15000); -#endif - if (!(sector[sectnum].floorstat&2)) return(sector[sectnum].floorz); { @@ -11267,11 +11368,6 @@ void getzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int walltype *wal, *wal2; sectortype *sec; -#if defined _WIN32 && defined DEBUGGINGAIDS - if (sectnum<0 || sectnum>numsectors) - debug_sleep(15000); -#endif - sec = §or[sectnum]; *ceilz = sec->ceilingz; *florz = sec->floorz; if ((sec->ceilingstat|sec->floorstat)&2) @@ -12067,19 +12163,27 @@ void draw2dscreen(int32_t posxe, int32_t posye, int16_t ange, int32_t zoome, int faketimerhandler(); if ((zoome >= 256) || (editstatus == 0)) - for (i=0; i=0; j=nextspritesect[j]) + for (j=0; j=0; j=nextspritesect[j]) if ((editstatus == 1) || (show2dsprite[j>>3]&pow2char[j&7])) { - col = 3; - if (spritecol2d[sprite[j].picnum][0]) - col = spritecol2d[sprite[j].picnum][0]; - if ((sprite[j].cstat&1) > 0) + if (sprite[j].sectnum<0) + col = 4; // red + else { - col = 5; - if (spritecol2d[sprite[j].picnum][1]) - col = spritecol2d[sprite[j].picnum][1]; + col = 3; + if (spritecol2d[sprite[j].picnum][0]) + col = spritecol2d[sprite[j].picnum][0]; + else if ((sprite[j].cstat&1) > 0) + { + col = 5; + if (spritecol2d[sprite[j].picnum][1]) + col = spritecol2d[sprite[j].picnum][1]; + } } + if (editstatus == 1) { if ((pointhighlight-16384) >= 0 && (j+16384 == pointhighlight || ((sprite[j].x == sprite[pointhighlight-16384].x) && (sprite[j].y == sprite[pointhighlight-16384].y)))) diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index 894e81417..08f534736 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -847,11 +847,6 @@ inline void idle(void) idle_waitevent(); } -void debug_sleep(int32_t ms) -{ - Sleep(ms); -} - // // setjoydeadzone() -- sets the dead and saturation zones for the joystick // diff --git a/polymer/eduke32/samples/_clipshape0.map b/polymer/eduke32/samples/_clipshape0.map new file mode 100644 index 0000000000000000000000000000000000000000..c1a3b7afb9688029c0c4fd63f3747b0a0c747691 GIT binary patch literal 23858 zcma)E2Y3}#)1EmbB+`44c7Xs<5Q4M-0RjP~i&CUmA{MY0P!QXt*$WCHVv7~5A9hsK zDA*e+D)xweh>F+|QMv!j-aFY{_TB%>eT-nMQ(f_d677vrOt*2c;$49TsFm75)sE02{6^V<+B7v}eBtX!Dio3V0>Li{$y%7yuDij@oV z+Z-zw=J#2w+=39lideZYzi(pY!hW~K%7xdlUF)RgUykOV-=FvH`~R4|I(z5okADX9 zlsJ>m5xE~ia#^u*KZWFSW94>)A-TL*xiG){Sh+C2F0pbuLw*Zl<^BlC^^BF<6_P8Al?&S|;_5`@lBcOuDp)6P zWfH(Xsnn1v$_+O;7tZHfdBzuJP3!Jhmh!HCH%I(RhTA8VnxyNfl=H76;TQO%Qd7Bc z`g%*KU#_h8d(XwEbE7KBEv%y44cs)%?|=Axh-;+fB5~d*k+M%JwYG|KFKS#W&kL^d zydd@EAG4-$ewnLPN$#~O+Iy>t_BK}0-li(r`>2ZcKCPm?FEsyF@A1xCmGxOd)m47{ zPb#%l{ceyvO@#AV;#?k-`@V{DJ4{a6L-2YlGhW9ItKD3z7CD7qP?-MVgXUoUQ@7l<`Y$?Qz718 zu%YskL#IG|O_FG~{N&Qf5Kju06n^{ANf1~4D=s9eK_^07{XcU7QB9f&aphkicrBU% zac}*C*QOI7{=39S_3O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duke32/samples/a.m32 @@ -23,6 +23,9 @@ define SFACTORSTEPS 100 // color of various drawing enhancements define PREVIEW_DRAW_COLOR 11 +// 2d mode corruption checker interval, 120 = 1 second +gamevar checkinterval 600 0 + // whether to use overridden aspect/range values when entering 3d mode (software/Polymost). // tweak with keys 7,8,9,0 on the top row gamevar use_custom_aspect 0 0 // this is now the same as r_usenewaspect @@ -75,6 +78,7 @@ definequote 22 SECTOR[%d]: wallptr+wallnum=%d out of range: numwalls=%d!!! definequote 23 WALL[%d].POINT2=%d out of range: sector[%d].wallptr=%d, endwall=%d!!! definequote 24 WALL[%d].NEXTWALL=%d out of range: numwalls=%d!!! definequote 25 WALL[%d].NEXTSECTOR=%d out of range: numsectors=%d!!! +definequote 26 SPRITE[%d].SECTNUM=%d. Expect problems! define PRSCALE 1000 define MAXSPECULAR 100000 @@ -631,16 +635,6 @@ defstate previewdoors2d } ends -onevent EVENT_DRAW2DSCREEN - ifge cursectnum 0 - { - state connectlocators - state draw_prlightprojections - } - - state previewdoors2d -endevent - // LOCATORS auto-incrementer onevent EVENT_INSERTSPRITE2D @@ -1073,8 +1067,40 @@ defstate corruptchk } } } + + for i allsprites + { + ifl .sectnum 0 + { + qsprintf TQUOTE 26 i .sectnum + quote TQUOTE printmessage16 TQUOTE + } + } ends + +gamevar d2d_lastcheck 0 0 +onevent EVENT_DRAW2DSCREEN + var tmp + + ifge cursectnum 0 + { + state connectlocators + state draw_prlightprojections + } + + state previewdoors2d + + ifl checkinterval 120, set checkinterval 120 + set tmp totalclock, sub tmp checkinterval + ifl d2d_lastcheck tmp + { + set d2d_lastcheck totalclock + state corruptchk + } +endevent + + defstate mkterrain var w2 w3 idx bit tmp sec var warned diff --git a/polymer/eduke32/samples/spriteclip.txt b/polymer/eduke32/samples/spriteclip.txt index c279c2bd9..cf8663722 100644 --- a/polymer/eduke32/samples/spriteclip.txt +++ b/polymer/eduke32/samples/spriteclip.txt @@ -4,8 +4,10 @@ Sprite picnums can be assigned to a bunch of connected sectors so that clipping against these sprites will work as if it is carried out on the -associated sectors. For this, a file named _clipshape_.map must be present -at program start time that must be built to certain rules: +associated sectors. For this, files named _clipshapeX.map (where X is +in 0..9) should be present at program start time. Every such map must be +built to certain rules, and loading many of them has the same effect as +loading a single map with all sectors/walls/sprites thrown together. * Every sector that contains at least one white wall is considered an "outer" sector. Conversely, sectors with only red walls are "inner" (clipping) sectors. @@ -25,21 +27,25 @@ at program start time that must be built to certain rules: orientation). * The sprites in inner sectors should point northward and should not have any orientation- - changing bits like x-flip or y-flip set. Setting centering is permitted, though. + changing bits like x-flip or y-flip set. Setting centering and a custom size is permitted, + though. * A set of picnums can be aliased to a layer. This is useful if "secondary" picnums are going to be used as decoration, for example. For this, set lotags and/or hitags - of any wall of an inner sector to the picnums to be aliased to values greater than 0. - If only one of them is set, it is taken as one picnum, otherwise as a both-sided inclusive + of any wall of an inner sector to the picnums to be aliased to layer containing the wall. + If only one of them is set, it is taken as a picnum, otherwise as a both-sided inclusive range, the order doesn't matter. The pigcop tank is present as an example in - samples/_clipshape_.map. + samples/_clipshape_.map. If a picnum has multiple layers, it is advisable to set the same + lotags/hitags for each layer. Note that you do not need to set tags unless you intend to + have more than one picnum to share a clipping shape. * The inner sectors of a given layer must be all interconnected (not necessarily directly) and for a layer there must be a unique outer sector. * Making the floor or ceiling of a sector parallaxed will disable clipping on it in certain - ways. Normally, there are four horizontal clipping planes (see the round table for an - example). Making the ceiling parallaxed disables the upper two, and analogously for the floor. + ways. Normally, there are four horizontal clipping planes per inner sector (see the round + table for an example). Making the ceiling parallaxed disables the upper two, and analogously + for the floor. * Making a sprite transparent will disable rotation around its origin to match a given sprite's angle. Use it on models with rotational symmetry. @@ -48,7 +54,6 @@ at program start time that must be built to certain rules: Notes: ------ -* Only clipmove and getzrange are changed, so that hitscan weapons will still behave the old way. * The clipping will not change with rendering modes or options. @@ -56,8 +61,12 @@ Known bugs: ----------- * Flipping doesn't work correctly -* The behaviour in Mapster32 and EDuke32 differs slightly, see the - round table arrangement in the test area of _clipshape_.map + + +Predicted bugs: +--------------- + +* Clipping may not work across playing map sector boundaries, especially with large sprites. --Helixhorned diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index ccca9916c..5bd98fbb0 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -2082,7 +2082,7 @@ static void M32_MoveFX(void) S_StopEnvSound(s->lotag, i); } } - else + else if (s->sectnum>=0) { ht = s->hitag; @@ -9152,6 +9152,9 @@ void ExtPreCheckKeys(void) // just before drawrooms int32_t start_wall = sector[isec].wallptr; int32_t end_wall = start_wall + sector[isec].wallnum; + if (isec<0) + continue; + for (w = start_wall; w < end_wall; w++) { if (!wallflag[w]) @@ -9517,6 +9520,9 @@ void ExtAnalyzeSprites(void) if (shadepreview && !(tspr->cstat & 16)) { + if (tspr->sectnum<0) + continue; + if (sector[tspr->sectnum].ceilingstat&1) { l = sector[tspr->sectnum].ceilingshade; @@ -9804,6 +9810,9 @@ void ExtCheckKeys(void) int32_t start_wall = sector[isec].wallptr; int32_t end_wall = start_wall + sector[isec].wallnum; + if (isec<0) + continue; + for (w = start_wall; w < end_wall; w++) { if (wallflag[w]) @@ -10448,7 +10457,7 @@ static void EditSpriteData(int16_t spritenum) if (editval) { printmessage16(edittext); - i = getnumber16(edittext,sprite[spritenum].sectnum,MAXSECTORS-1,0); + i = getnumber16(edittext,sprite[spritenum].sectnum,numsectors-1,0); if (i != sprite[spritenum].sectnum) changespritesect(spritenum,i); } diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index df04f8856..50dbec574 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -9859,11 +9859,11 @@ CLEAN_DIRECTORY: Bfree(ptr); } - i = clipmapinfo_load("_clipshape_.map"); + i = clipmapinfo_load("_clipshape0.map"); if (i==0) - initprintf("Loaded sprite clipping map from \"_clipshape_.map\"\n"); + initprintf("Loaded sprite clipping map.\n"); else if (i>0) - initprintf("There was an error loading the sprite clipping map from \"_clipshape_.map\" (status %d).\n", i); + initprintf("There was an error loading the sprite clipping map (status %d).\n", i); OSD_Exec("autoexec.cfg"); diff --git a/polymer/eduke32/source/m32def.c b/polymer/eduke32/source/m32def.c index ae2f77a86..e89777c92 100644 --- a/polymer/eduke32/source/m32def.c +++ b/polymer/eduke32/source/m32def.c @@ -189,7 +189,7 @@ const char *keyw[] = "jump", "{", "}", - +#if 0 "setsector", "getsector", "setwall", @@ -198,7 +198,7 @@ const char *keyw[] = "getsprite", "gettspr", "settspr", - +#endif "gamearray", "setarray", "getarraysize", @@ -2387,6 +2387,7 @@ repeatcase: return 1; // *** more basic commands +#if 0 case CON_SETSECTOR: case CON_GETSECTOR: case CON_SETWALL: @@ -2463,6 +2464,7 @@ repeatcase: C_GetNextVar(); break; } +#endif case CON_GAMEVAR: // syntax: gamevar diff --git a/polymer/eduke32/source/m32def.h b/polymer/eduke32/source/m32def.h index d73507c71..0a46d21d0 100644 --- a/polymer/eduke32/source/m32def.h +++ b/polymer/eduke32/source/m32def.h @@ -270,6 +270,7 @@ enum ScriptKeywords_t CON_LEFTBRACE, CON_RIGHTBRACE, +#if 0 // more basic commands CON_SETSECTOR, CON_GETSECTOR, @@ -279,6 +280,7 @@ enum ScriptKeywords_t CON_GETSPRITE, //+ CON_GETTSPR, CON_SETTSPR, +#endif // arrays CON_GAMEARRAY, diff --git a/polymer/eduke32/source/m32exec.c b/polymer/eduke32/source/m32exec.c index 2f85a9611..f13dcb4dc 100644 --- a/polymer/eduke32/source/m32exec.c +++ b/polymer/eduke32/source/m32exec.c @@ -55,7 +55,7 @@ instype *insptr; int32_t VM_Execute(int32_t once); static instype *x_sortingstateptr; -#include "m32structures.c" +//#include "m32structures.c" extern void message(const char *fmt, ...); @@ -492,6 +492,7 @@ skip_check: VM_Execute(0); continue; +#if 0 // *** more basic commands case CON_SETSECTOR: case CON_GETSECTOR: @@ -535,7 +536,7 @@ skip_check: VM_AccessTsprite((tw==CON_SETTSPR)|2|4, lVar1, lLabelID, lVar2); continue; } -#if 0 + case CON_SETSPRITE: insptr++; {