From b158521449bcdae20fa034370c7a54a9d3e0dffc Mon Sep 17 00:00:00 2001 From: helixhorned Date: Tue, 8 Mar 2011 23:02:38 +0000 Subject: [PATCH] Besides catching a few more corner cases, there's better mouselook handling and a warning (but no fix) for a rare and bad corruption when splitting a sector in this revision. git-svn-id: https://svn.eduke32.com/eduke32@1836 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/include/editor.h | 2 +- polymer/eduke32/build/src/build.c | 907 ++++++++++++------------- polymer/eduke32/build/src/config.c | 23 +- polymer/eduke32/build/src/sdlayer.c | 36 +- polymer/eduke32/samples/a.m32 | 18 +- polymer/eduke32/source/astub.c | 92 ++- polymer/eduke32/source/m32exec.c | 4 +- polymer/eduke32/source/mapster32.h | 8 +- 8 files changed, 546 insertions(+), 544 deletions(-) diff --git a/polymer/eduke32/build/include/editor.h b/polymer/eduke32/build/include/editor.h index c0accd53d..c9658b804 100644 --- a/polymer/eduke32/build/include/editor.h +++ b/polymer/eduke32/build/include/editor.h @@ -39,7 +39,7 @@ extern "C" { extern int32_t qsetmode; extern int16_t searchsector, searchwall, searchstat; extern int16_t searchbottomwall; -extern int32_t zmode, kensplayerheight; +extern int32_t zmode, kensplayerheight, zlock; #define DEFAULT_SPRITE_CSTAT 0 //extern int16_t defaultspritecstat; diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 10900e176..6a7b85376 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -350,21 +350,24 @@ static void M32_drawdebug(void) int i; int x=4, y=8; - begindrawing(); #if 0 { static char tstr[128]; - Bsprintf(tstr, "searchstat=%d, searchsector=%d, searchwall=%d (%d)", - searchstat, searchsector, searchwall, searchbottomwall); + Bsprintf(tstr, "searchstat=%d, searchsector=%d, searchwall=%d (%d), asksave=%d", + searchstat, searchsector, searchwall, searchbottomwall, asksave); printext256(x,y,whitecol,0,tstr,xdimgame>640?0:1); } #endif - for (i=0; i0) { - y+=8; - printext256(x,y,whitecol,0,m32_debugstr[i],xdimgame>640?0:1); + begindrawing(); + for (i=0; i640?0:1); + } + enddrawing(); } - enddrawing(); m32_numdebuglines=0; } #endif @@ -450,7 +453,7 @@ int32_t app_main(int32_t argc, const char **argv) loadnames(g_namesFileName); if (initinput()) return -1; - // if (option[3] != 0) moustat = + initmouse(); inittimer(TIMERINTSPERSECOND); @@ -713,56 +716,96 @@ void loadmhk(int32_t domessage) } } + +static void move_and_update(int32_t xvect, int32_t yvect, int32_t addshr) +{ + if (noclip) + { + pos.x += xvect>>(14+addshr); + pos.y += yvect>>(14+addshr); + updatesector(pos.x,pos.y, &cursectnum); + } + else + clipmove(&pos,&cursectnum, xvect>>addshr,yvect>>addshr, + 128,4<<8,4<<8, CLIPMASK0); +} + +static void mainloop_move() +{ + int32_t xvect, yvect, doubvel; + + if (angvel != 0) //ang += angvel * constant + { + //ENGINE calculates angvel for you + + //Lt. shift makes turn velocity 50% faster + doubvel = (synctics + DOWN_BK(RUN)*(synctics>>1)); + + ang += ((angvel*doubvel)>>4); + ang &= 2047; + } + if ((vel|svel) != 0) + { + //Lt. shift doubles forward velocity + doubvel = (1+(DOWN_BK(RUN)))*synctics; + + xvect = 0; + yvect = 0; + + if (vel != 0) + { + xvect += (vel*doubvel*(int32_t)sintable[(ang+2560)&2047])>>3; + yvect += (vel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3; + } + if (svel != 0) + { + xvect += (svel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3; + yvect += (svel*doubvel*(int32_t)sintable[(ang+1536)&2047])>>3; + } + + move_and_update(xvect, yvect, 0); + } +} + void editinput(void) { -// char smooshyalign, repeatpanalign, buffer[80]; -// short sectnum, nextsectnum, startwall, endwall, dasector, daang; int32_t mousz, bstatus; - int32_t i, j, k, /*cnt,*/ tempint=0, doubvel/*, changedir, wallfind[2], daz[2]*/; - int32_t /*dashade[2],*/ goalz, xvect, yvect,/*PK*/ zvect, hiz, loz; - int32_t dax, day, hihit, lohit; + int32_t i, j, k, tempint=0; + int32_t goalz, xvect, yvect, hiz, loz; + int32_t dax, day, hihit, lohit, omlook=mlook; // 3B 3C 3D 3E 3F 40 41 42 43 44 57 58 46 // F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 SCROLL - /* if (keystatus[0x57] > 0) //F11 - brightness - { - keystatus[0x57] = 0; - brightness++; - if (brightness >= 16) brightness = 0; - setbrightness(brightness,palette,0); - } - if (keystatus[88] > 0) //F12 - { - screencapture("captxxxx.tga",eitherSHIFT); - keystatus[88] = 0; - }*/ - mousz = 0; getmousevalues(&mousx,&mousy,&bstatus); - mousx = (mousx<<16)+mousexsurp; - mousy = (mousy<<16)+mouseysurp; + mousx = (mousx<<16) + mousexsurp; + mousy = (mousy<<16) + mouseysurp; - if ((unrealedlook && !mskip) && - (((!mlook && (bstatus&2) && !(bstatus&(1|4)))) || ((bstatus&1) && !(bstatus&(2|4))))) - mlook = 3; + if (unrealedlook && !mskip) + { + if (mlook==0 && (bstatus&(1|2|4))==2) + mlook = 3; + else if ((bstatus&(1|2|4))==1) + mlook = 3; + } { ldiv_t ld; if (mlook) { - ld = ldiv((int32_t)mousx, (int32_t)((1<<16)/(msens*0.5f))); mousx = ld.quot; mousexsurp = ld.rem; - ld = ldiv((int32_t)mousy, (int32_t)((1<<16)/(msens*0.25f))); mousy = ld.quot; mouseysurp = ld.rem; + ld = ldiv(mousx, (int32_t)((1<<16)/(msens*0.5f))); mousx = ld.quot; mousexsurp = ld.rem; + ld = ldiv(mousy, (int32_t)((1<<16)/(msens*0.25f))); mousy = ld.quot; mouseysurp = ld.rem; } else { - ld = ldiv((int32_t)mousx, (int32_t)((1<<16)/msens)); mousx = ld.quot; mousexsurp = ld.rem; - ld = ldiv((int32_t)mousy, (int32_t)((1<<16)/msens)); mousy = ld.quot; mouseysurp = ld.rem; + ld = ldiv(mousx, (int32_t)((1<<16)/msens)); mousx = ld.quot; mousexsurp = ld.rem; + ld = ldiv(mousy, (int32_t)((1<<16)/msens)); mousy = ld.quot; mouseysurp = ld.rem; } } if (mlook == 3) - mlook = 0; + mlook = omlook; // UnrealEd: // rmb: mouselook @@ -772,39 +815,28 @@ void editinput(void) if (unrealedlook && !mskip) //PK { - if ((bstatus&1) && !(bstatus&(2|4))) + if ((bstatus&(1|2|4))==1) { ang += mousx; xvect = -((mousy*(int32_t)sintable[(ang+2560)&2047])<<(3+pk_uedaccel)); yvect = -((mousy*(int32_t)sintable[(ang+2048)&2047])<<(3+pk_uedaccel)); - if (noclip) - { - pos.x += xvect>>14; - pos.y += yvect>>14; - updatesector(pos.x,pos.y,&cursectnum); - } - else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); + move_and_update(xvect, yvect, 0); } - else if (!mlook && (bstatus&2) && !(bstatus&(1|4))) + else if (!mlook && (bstatus&(1|2|4))==2) { mlook=2; } - else if ((bstatus&1) && (bstatus&2) && !(bstatus&4)) + else if ((bstatus&(1|2|4))==(1|2)) { zmode = 2; xvect = -((mousx*(int32_t)sintable[(ang+2048)&2047])<>14; - pos.y += yvect>>14; - updatesectorz(pos.x,pos.y,pos.z,&cursectnum); - } - else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); + + move_and_update(xvect, yvect, 0); } - else if (bstatus&4) + else if ((bstatus&(1|2|4))==4) { zmode = 2; @@ -820,32 +852,31 @@ void editinput(void) ((int32_t)sintable[(tempint+512)&2047])>>6) <>(10-pk_uedaccel)); + pos.z += mousy*(((int32_t)sintable[(tempint+2048)&2047])>>(10-pk_uedaccel)); - pos.z += zvect; - if (noclip) - { - pos.x += xvect>>16; - pos.y += yvect>>16; - updatesectorz(pos.x,pos.y,pos.z,&cursectnum); - } - else clipmove(&pos,&cursectnum,xvect>>2,yvect>>2,128L,4L<<8,4L<<8,CLIPMASK0); + move_and_update(xvect, yvect, 2); } } if (mskip) - mskip=0; + { + // mskip was set in astub.c to not trigger UEd mouse movements. + // Reset now. + mskip = 0; + } else { - if (mlook && !(unrealedlook && bstatus&(1|4))) + if (mlook && (unrealedlook==0 || (bstatus&(1|4))==0)) { ang += mousx; horiz -= mousy; -// if (mousy && !(mousy/4)) - // horiz--; - // if (mousx && !(mousx/2)) - // ang++; + /* + if (mousy && !(mousy/4)) + horiz--; + if (mousx && !(mousx/2)) + ang++; + */ bclamp(&horiz, -99, 299); @@ -857,7 +888,7 @@ void editinput(void) osearchx = searchx-mousx; osearchy = searchy-mousy; } - else if (!(unrealedlook && (bstatus&(1|2|4)))) + else if (unrealedlook==0 || (bstatus&(1|2|4))==0) { osearchx = searchx; osearchy = searchy; @@ -897,51 +928,9 @@ void editinput(void) keystatus[0x43] = 0; } - if (angvel != 0) //ang += angvel * constant - { - //ENGINE calculates angvel for you - doubvel = synctics; - if (DOWN_BK(RUN)) //Lt. shift makes turn velocity 50% faster - doubvel += (synctics>>1); - ang += ((angvel*doubvel)>>4); - ang = (ang+2048)&2047; - } - if ((vel|svel) != 0) - { - //Lt. shift doubles forward velocity - doubvel = (1+(DOWN_BK(RUN)))*synctics; + mainloop_move(); - xvect = 0; - yvect = 0; - - if (vel != 0) - { - xvect += (vel*doubvel*(int32_t)sintable[(ang+2560)&2047])>>3; - yvect += (vel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3; - } - if (svel != 0) - { - xvect += (svel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3; - yvect += (svel*doubvel*(int32_t)sintable[(ang+1536)&2047])>>3; - } - if (noclip) - { - pos.x += xvect>>14; - pos.y += yvect>>14; - updatesector(pos.x,pos.y,&cursectnum); - } - else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); - } - - getzrange(&pos,cursectnum,&hiz,&hihit,&loz,&lohit,128L,CLIPMASK0); - - /* if (keystatus[0x3a] > 0) - { - zmode++; - if (zmode == 3) zmode = 0; - if (zmode == 1) zlock = (loz-pos.z)&0xfffffc00; - keystatus[0x3a] = 0; - }*/ + getzrange(&pos,cursectnum, &hiz,&hihit, &loz,&lohit, 128,CLIPMASK0); if (zmode == 0) { @@ -952,25 +941,15 @@ void editinput(void) if (DOWN_BK(MOVEUP)) //A (stand high) { - /* if (eitherCTRL) - horiz = max(-100,horiz-((DOWN_BK(RUN)+1)*synctics*2)); - else */ - { - goalz -= (16<<8); - if (DOWN_BK(RUN)) //Either shift key - goalz -= (24<<8); - } + goalz -= (16<<8); + if (DOWN_BK(RUN)) + goalz -= (24<<8); } if (DOWN_BK(MOVEDOWN)) //Z (stand low) { - /* if (eitherCTRL) - horiz = min(300,horiz+((DOWN_BK(RUN)+1)*synctics*2)); - else */ - { + goalz += (12<<8); + if (DOWN_BK(RUN)) goalz += (12<<8); - if (DOWN_BK(RUN)) //Either shift key - goalz += (12<<8); - } } if (goalz != pos.z) @@ -1033,8 +1012,10 @@ void editinput(void) { //if (pos.z < goalz) hvel += (32< goalz) hvel -= (32< goalz) hvel = ((synctics*-192)<>1; sprite[i].z = hitinfo.pos.z; @@ -1145,19 +1125,6 @@ void editinput(void) keystatus[0x1f] = 0; } -#if 0 - if (keystatus[0xd3] > 0) - { - if (searchstat == 3) - { - deletesprite(searchwall); - updatenumsprites(); - asksave = 1; - } - keystatus[0xd3] = 0; - } -#endif - if (keystatus[0x3f]||keystatus[0x40]) //F5,F6 { switch (searchstat) @@ -1171,7 +1138,8 @@ void editinput(void) case 3: ExtShowSpriteData(searchwall); break; } - keystatus[0x3f] = 0, keystatus[0x40] = 0; + + keystatus[0x3f] = keystatus[0x40] = 0; } if (keystatus[0x41]||keystatus[0x42]) //F7,F8 { @@ -1186,7 +1154,8 @@ void editinput(void) case 3: ExtEditSpriteData(searchwall); break; } - keystatus[0x41] = 0, keystatus[0x42] = 0; + + keystatus[0x41] = keystatus[0x42] = 0; } } @@ -1961,16 +1930,63 @@ static int32_t trace_loop(int32_t j, uint8_t *visitedwall, int16_t *ignore_ret, return k; } +static int32_t backup_drawn_walls(int32_t restore) +{ + static int32_t wallsdrawn = -1; + static walltype *tmpwall; + + // back up + if (restore==0) + { + if (newnumwalls == -1) + { + wallsdrawn = -1; + } + else + { + wallsdrawn = newnumwalls-numwalls; + + tmpwall = Bmalloc(wallsdrawn * sizeof(walltype)); + if (!tmpwall) + { + wallsdrawn = -1; + return 1; + } + + Bmemcpy(tmpwall, &wall[numwalls], wallsdrawn*sizeof(walltype)); + newnumwalls = -1; + } + + return 0; + } + + // restore + if (wallsdrawn != -1) + { + int32_t i; + + Bmemcpy(&wall[numwalls], tmpwall, wallsdrawn*sizeof(walltype)); + newnumwalls = numwalls + wallsdrawn; + for (i=numwalls; i 0) pos.x--, keystatus[0x3b] = 0; - if (keystatus[0x3c] > 0) pos.x++, keystatus[0x3c] = 0; - if (keystatus[0x3d] > 0) pos.y--, keystatus[0x3d] = 0; - if (keystatus[0x3e] > 0) pos.y++, keystatus[0x3e] = 0; - if (keystatus[0x43] > 0) ang--, keystatus[0x43] = 0; - if (keystatus[0x44] > 0) ang++, keystatus[0x44] = 0; */ + /* + if (keystatus[0x3b] > 0) pos.x--, keystatus[0x3b] = 0; + if (keystatus[0x3c] > 0) pos.x++, keystatus[0x3c] = 0; + if (keystatus[0x3d] > 0) pos.y--, keystatus[0x3d] = 0; + if (keystatus[0x3e] > 0) pos.y++, keystatus[0x3e] = 0; + if (keystatus[0x43] > 0) ang--, keystatus[0x43] = 0; + if (keystatus[0x44] > 0) ang++, keystatus[0x44] = 0; + */ - if (angvel != 0) //ang += angvel * constant - { - //ENGINE calculates angvel for you - doubvel = synctics; - if (DOWN_BK(RUN)) //Lt. shift makes turn velocity 50% faster - doubvel += (synctics>>1); - ang += ((angvel*doubvel)>>4); - ang = (ang+2048)&2047; - } - if ((vel|svel) != 0) - { - doubvel = synctics; - if (DOWN_BK(RUN)) //Lt. shift doubles forward velocity - doubvel += synctics; - xvect = 0, yvect = 0; - if (vel != 0) - { - xvect += (vel*doubvel*(int32_t)sintable[(ang+2560)&2047])>>3; - yvect += (vel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3; - } - if (svel != 0) - { - xvect += (svel*doubvel*(int32_t)sintable[(ang+2048)&2047])>>3; - yvect += (svel*doubvel*(int32_t)sintable[(ang+1536)&2047])>>3; - } - if (noclip) - { - pos.x += xvect>>14; - pos.y += yvect>>14; - updatesector(pos.x,pos.y,&cursectnum); - } - else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0); - } + mainloop_move(); getpoint(searchx,searchy,&mousxplc,&mousyplc); linehighlight = getlinehighlight(mousxplc, mousyplc, linehighlight); @@ -3171,58 +3157,59 @@ end_yax: ; break; // outer loop too } - if (!ignore) + if (ignore) + continue; + + wall[k-1].point2 = numwalls; // close the loop + newnumwalls = k; + n = (newnumwalls-numwalls); // number of walls in just constructed loop + + if (clockdir(numwalls)==0) { - wall[k-1].point2 = numwalls; // close the loop - newnumwalls = k; - n = (newnumwalls-numwalls); // number of walls in just constructed loop + int16_t begwalltomove = sector[refsect].wallptr+sector[refsect].wallnum; - if (clockdir(numwalls)==0) + flipwalls(numwalls, newnumwalls); + + sector[refsect].wallnum += n; + if (refsect != numsectors-1) { - int16_t begwalltomove = sector[refsect].wallptr+sector[refsect].wallnum; + walltype *tmpwall = Bmalloc(n * sizeof(walltype)); - flipwalls(numwalls, newnumwalls); - - sector[refsect].wallnum += n; - if (refsect != numsectors-1) + if (!tmpwall) { - walltype *tmpwall = Bmalloc(n * sizeof(walltype)); - - if (!tmpwall) - { - message("out of memory!"); - ExtUnInit(); - uninitsystem(); - exit(1); - } - - for (m=0; m= begwalltomove) - wall[m].nextwall += n; - } - for (m=refsect+1; m= begwalltomove) + wall[m].nextwall += n; + } + for (m=refsect+1; m 0) @@ -3401,17 +3376,9 @@ end_yax: ; } } -end_after_dragging: - if (wallsdrawn != -1) - { - Bmemcpy(&wall[numwalls], tmpwall, wallsdrawn*sizeof(walltype)); - newnumwalls = numwalls + wallsdrawn; - for (i=numwalls; i 0) //drag points { @@ -4462,230 +4429,251 @@ check_next_sector: ; { int16_t danumwalls, splitendwall, doSectorSplit; int16_t secondstartwall=-1; // used only with splitting + int32_t expectedNumwalls = numwalls+2*(newnumwalls-numwalls-1), loopnum; startwall = sector[splitsect].wallptr; endwall = startwall + sector[splitsect].wallnum - 1; // OSD_Printf("numwalls: %d, newnumwalls: %d\n", numwalls, newnumwalls); + i = -1; for (k=startwall; k<=endwall; k++) - { - if (wall[k].x != wall[newnumwalls-1].x || wall[k].y != wall[newnumwalls-1].y) - continue; - - doSectorSplit = (loopnumofsector(splitsect,splitstartwall) == loopnumofsector(splitsect,k)); - - if (numwalls+2*(newnumwalls-numwalls-1) > MAXWALLS) + if (wall[k].x == wall[newnumwalls-1].x && wall[k].y == wall[newnumwalls-1].y) { - printmessage16("%s would exceed wall limit.", bad==0 ? - "Splitting sector" : "Joining sector loops"); - newnumwalls--; + i = k; break; } + if (i==-1) + goto end_space_handling; - ////////// common code for splitting/loop joining ////////// + splitendwall = k; + doSectorSplit = (loopnumofsector(splitsect,splitstartwall) + == loopnumofsector(splitsect,splitendwall)); - splitendwall = k; - newnumwalls--; //first fix up the new walls - for (i=numwalls; i MAXWALLS) + { + printmessage16("%s would exceed wall limit.", bad==0 ? + "Splitting sector" : "Joining sector loops"); + newnumwalls--; + break; + } - danumwalls = newnumwalls; //where to add more walls - m = splitendwall; //copy rest of loop next + ////////// common code for splitting/loop joining ////////// - if (doSectorSplit) - { - while (m != splitstartwall) - if (copyloop1(&danumwalls, &m)) goto split_not_enough_walls; - wall[danumwalls-1].point2 = numwalls; + newnumwalls--; //first fix up the new walls + for (i=numwalls; inumwalls; j--) - { - Bmemcpy(&wall[danumwalls],&wall[j],sizeof(walltype)); - wall[danumwalls].nextwall = -1; - wall[danumwalls].nextsector = -1; - wall[danumwalls].point2 = danumwalls+1; - danumwalls++; - } - - m = splitstartwall; //copy rest of loop next - - if (doSectorSplit) - { - while (m != splitendwall) - if (copyloop1(&danumwalls, &m)) goto split_not_enough_walls; - wall[danumwalls-1].point2 = secondstartwall; - } - else - { - do - if (copyloop1(&danumwalls, &m)) goto split_not_enough_walls; - while (m != splitstartwall); - wall[danumwalls-1].point2 = numwalls; - } - - //Add other loops for 2nd sector + //Add other loops for 1st sector i = loopnum = loopnumofsector(splitsect,splitstartwall); for (j=startwall; j<=endwall; j++) { - k = loopnumofsector(splitsect, j); - if (k==i) + k = loopnumofsector(splitsect,j); + if (k == i) continue; - if (doSectorSplit && k==loopnum) - continue; - if (!doSectorSplit && (k == loopnumofsector(splitsect,splitstartwall) || k == loopnumofsector(splitsect,splitendwall))) + if (k == loopnum) continue; i = k; - if (doSectorSplit && (loopinside(wall[j].x,wall[j].y, secondstartwall) != 1)) + if (loopinside(wall[j].x,wall[j].y, numwalls) != 1) continue; - m = j; k = danumwalls; //copy loop + m = j; //copy loop + k = danumwalls; do if (copyloop1(&danumwalls, &m)) goto split_not_enough_walls; while (m != j); wall[danumwalls-1].point2 = k; } - //fix all next pointers on old sector line - for (j=numwalls; j= 0) - { - NEXTWALL(j).nextwall = j; - - if (!doSectorSplit || j < secondstartwall) - NEXTWALL(j).nextsector = numsectors; - else - NEXTWALL(j).nextsector = numsectors+1; - } - } - - if (doSectorSplit) - { - //set all next pointers on split - for (j=numwalls; j= 0) - checksectorpointer(wall[j].nextwall, wall[j].nextsector); - checksectorpointer(j, sectorofwall(j)); - } - - //k now safe to use as temp -#if 0 - if (doSectorSplit) - for (m=numsectors-2; mnumwalls; j--) + { + Bmemcpy(&wall[danumwalls], &wall[j], sizeof(walltype)); + wall[danumwalls].nextwall = -1; + wall[danumwalls].nextsector = -1; + wall[danumwalls].point2 = danumwalls+1; + danumwalls++; + } + + m = splitstartwall; //copy rest of loop next + + if (doSectorSplit) + { + while (m != splitendwall) + if (copyloop1(&danumwalls, &m)) goto split_not_enough_walls; + wall[danumwalls-1].point2 = secondstartwall; + } + else + { + do + if (copyloop1(&danumwalls, &m)) goto split_not_enough_walls; + while (m != splitstartwall); + wall[danumwalls-1].point2 = numwalls; + } + + //Add other loops for 2nd sector + i = loopnum = loopnumofsector(splitsect,splitstartwall); + + for (j=startwall; j<=endwall; j++) + { + k = loopnumofsector(splitsect, j); + if (k==i) + continue; + + if (doSectorSplit && k==loopnum) + continue; + if (!doSectorSplit && (k == loopnumofsector(splitsect,splitstartwall) || k == loopnumofsector(splitsect,splitendwall))) + continue; + + i = k; + + if (doSectorSplit && (loopinside(wall[j].x,wall[j].y, secondstartwall) != 1)) + continue; + + m = j; k = danumwalls; //copy loop + do + if (copyloop1(&danumwalls, &m)) goto split_not_enough_walls; + while (m != j); + wall[danumwalls-1].point2 = k; + } + + //fix all next pointers on old sector line + for (j=numwalls; j= 0) + { + NEXTWALL(j).nextwall = j; + + if (!doSectorSplit || j < secondstartwall) + NEXTWALL(j).nextsector = numsectors; + else + NEXTWALL(j).nextsector = numsectors+1; + } + } + + if (doSectorSplit) + { + //set all next pointers on split + for (j=numwalls; j= 0) + checksectorpointer(wall[j].nextwall, wall[j].nextsector); + checksectorpointer(j, sectorofwall(j)); + } + + //k now safe to use as temp +#if 0 + if (doSectorSplit) + for (m=numsectors-2; m= 0)) //sector delete + if (keystatus[0xd3] && eitherCTRL && numwalls > 0) //sector delete { keystatus[0xd3] = 0; @@ -4828,18 +4816,17 @@ end_space_handling: duplicate_selected_sprites(); else if (linehighlight >= 0) { - int32_t wallsdrawn = newnumwalls-numwalls; + int32_t onewnumwalls = newnumwalls; int32_t wallis2sided = (wall[linehighlight].nextwall>=0); - if (newnumwalls != -1) + if (backup_drawn_walls(0)) { - newnumwalls = -1; - Bmemcpy(&wall[MAXWALLS-wallsdrawn],&wall[numwalls],sizeof(walltype) * wallsdrawn); + message("OUT OF MEMORY!"); } - else wallsdrawn = -1; - - if (max(numwalls,newnumwalls) >= MAXWALLS-wallis2sided) + else if (max(numwalls,onewnumwalls) >= MAXWALLS-wallis2sided) + { printmessage16("Inserting point would exceed wall limit."); + } else { getclosestpointonwall(mousxplc,mousyplc, linehighlight, &dax,&day); @@ -4876,13 +4863,7 @@ end_space_handling: //} } - if (wallsdrawn != -1) - { - Bmemcpy(&wall[numwalls],&wall[MAXWALLS-wallsdrawn], sizeof(walltype)*wallsdrawn); - newnumwalls = numwalls + wallsdrawn; - for (i=numwalls; i 0) xdimgame = Batoi(val); if (readconfig(fp, "ydim3d", val, VL) > 0) ydimgame = Batoi(val); // if (readconfig(fp, "samplerate", val, VL) > 0) option[7] = (Batoi(val) & 0x0f) << 4; - if (readconfig(fp, "music", val, VL) > 0) { if (Batoi(val) != 0) option[2] = 1; else option[2] = 0; } - if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; } +// if (readconfig(fp, "music", val, VL) > 0) { if (Batoi(val) != 0) option[2] = 1; else option[2] = 0; } +// if (readconfig(fp, "mouse", val, VL) > 0) { if (Batoi(val) != 0) option[3] = 1; else option[3] = 0; } if (readconfig(fp, "bpp", val, VL) > 0) bppgame = Batoi(val); if (readconfig(fp, "vsync", val, VL) > 0) vsync = Batoi(val)?1:0; if (readconfig(fp, "editorgridextent", val, VL) > 0) editorgridextent = max(min(262144,Batoi(val)),32768); @@ -187,10 +187,10 @@ int32_t loadsetup(const char *fn) if (readconfig(fp, "gameexecutable", val, VL) > 0) Bstrcpy(game_executable, val); - option[0] = 1; // vesa all the way... - option[1] = 1; // sound all the way... - option[4] = 0; // no multiplayer - option[5] = 0; +// option[0] = 1; // vesa all the way... +// option[1] = 1; // sound all the way... +// option[4] = 0; // no multiplayer +// option[5] = 0; #if 1 if (readconfig(fp, "keyforward", val, VL) > 0) keys[0] = Bstrtol(val, NULL, 16); @@ -393,11 +393,6 @@ int32_t writesetup(const char *fn) "music = %d\n" "\n" #endif - "; Enable mouse\n" - "; 0 - No\n" - "; 1 - Yes\n" - "mouse = %d\n" - "\n" "; Mouse sensitivity\n" "mousesensitivity = %g\n" "\n" @@ -525,7 +520,7 @@ int32_t writesetup(const char *fn) #if 0 option[7]>>4, option[2], #endif - option[3], msens, unrealedlook, pk_uedaccel, quickmapcycling, + msens, unrealedlook, pk_uedaccel, quickmapcycling, sideview_reversehrot, revertCTRL,scrollamount,pk_turnaccel,pk_turndecel,autosave,autocorruptcheck, showheightindicators,showambiencesounds,graphicsmode, diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index fc8b957d1..24a2d40f8 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -808,20 +808,22 @@ void getvalidmodes(void) validmodecnt=0; // initprintf("Detecting video modes:\n"); -#define ADDMODE(x,y,c,f) if (validmodecntw > MAXXDIM) || (modes[i]->h > MAXYDIM)) continue; - ADDMODE(modes[i]->w, modes[i]->h, cdepths[j], 1) + ADDMODE(modes[i]->w, modes[i]->h, cdepths[j], 1); if ((modes[i]->w > maxx) && (modes[i]->h > maxy)) { @@ -883,7 +885,7 @@ void getvalidmodes(void) if (cdepths[j] < 0) continue; for (i=0; defaultres[i][0]; i++) CHECK(defaultres[i][0],defaultres[i][1]) - ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],0) + ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],0); } #undef CHECK diff --git a/polymer/eduke32/samples/a.m32 b/polymer/eduke32/samples/a.m32 index 34b927d75..860be045d 100644 --- a/polymer/eduke32/samples/a.m32 +++ b/polymer/eduke32/samples/a.m32 @@ -998,14 +998,22 @@ defstate js // jump to current sprite updatecursectnum ends -defstate jumptosec // (tmp) - ifge tmp 0 ifl tmp numsectors nullop else return - set j sector[tmp].wallptr - set posx wall[j].x - set posy wall[j].y +var sec 0 0 +var wal 0 0 + +defstate jumptowal // (wal) + ifge wal 0 ifl wal numwalls nullop else return + set posx wall[wal].x + set posy wall[wal].y updatecursectnum ends +defstate jumptosec // (sec) + ifge sec 0 ifl sec numsectors nullop else return + set wal sector[sec].wallptr + state jumptowal +ends + onevent EVENT_DRAW2DSCREEN var tmp diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 5a6f2e28d..5eeff82d1 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -4898,11 +4898,19 @@ static void Keys3d(void) smooshyalign = keystatus[KEYSC_gKP5]; repeatpanalign = eitherSHIFT || eitherALT || (bstatus&2); - if (mlook == 2) - mlook = 0; + { + static int32_t omlook; - if (!unrealedlook && (bstatus&4)) - mlook = 2; + if (mlook == 2) + { + mlook = omlook; + } + else if (!unrealedlook && (bstatus&4)) + { + omlook = mlook; + mlook = 2; + } + } // PK: no btn: wheel changes shade if ((bstatus&(16|32) && !(bstatus&(1|2|4))) || keystatus[KEYSC_gMINUS] || keystatus[KEYSC_gPLUS]) @@ -5613,7 +5621,8 @@ static void Keys3d(void) int16_t ohitag = AIMED(hitag); Bsprintf(tempbuf, "%s hitag: ", Typestr_wss[searchstat]); AIMED(hitag) = getnumber256(tempbuf, ohitag, BTAG_MAX,0); - asksave |= (AIMED(hitag) != ohitag); + if (AIMED(hitag) != ohitag) + asksave = 1; } } @@ -5624,7 +5633,8 @@ static void Keys3d(void) int8_t oshade = AIMED_CF_SEL(shade); Bsprintf(tempbuf, "%s shade: ", Typestr[searchstat]); getnumberptr256(tempbuf, &AIMED_CF_SEL(shade), sizeof(int8_t), 128, 1, NULL); - asksave |= (AIMED_CF_SEL(shade) != oshade); + if (AIMED_CF_SEL(shade) != oshade) + asksave = 1; } } @@ -5682,7 +5692,8 @@ static void Keys3d(void) static const char *Typestr_tmp[5] = { "Wall", "Sector ceiling", "Sector floor", "Sprite", "Masked wall" }; Bsprintf(tempbuf, "%s picnum: ", Typestr_tmp[searchstat]); getnumberptr256(tempbuf, &AIMED_CF_SEL(picnum), sizeof(int16_t), MAXTILES-1, 0, NULL); - asksave |= (opicnum != AIMED_CF_SEL(picnum)); + if (opicnum != AIMED_CF_SEL(picnum)) + asksave = 1; if (aimspr) correct_sprite_yoffset(searchwall); @@ -5954,7 +5965,7 @@ static void Keys3d(void) mouseay=0; } - if ((bstatus&1) && searchstat != SEARCH_CEILING && searchstat != SEARCH_FLOOR) + if ((bstatus&1) && !AIMING_AT_CEILING_OR_FLOOR) { if (eitherSHIFT) { @@ -5963,7 +5974,7 @@ static void Keys3d(void) { mouseaction = 1; mouseax += mousex; - updownunits = klabs((int32_t)(mouseax/2.)); + updownunits = klabs(mouseax/2); if (updownunits) mouseax=0; } @@ -6006,10 +6017,10 @@ static void Keys3d(void) if (mouseaction) { - i=wall[w].cstat; - i=((i>>3)&1)+((i>>7)&2); + i = wall[w].cstat; + i &= (8|256); - if (i==1||i==3) + if (i==8 || i==256) changedir*=-1; if (eitherCTRL) @@ -6546,7 +6557,7 @@ static void Keys3d(void) if (ASSERT_AIMING) { Bsprintf(tempbuf, "%s pal: ", Typestr[searchstat]); - getnumberptr256(tempbuf, &AIMED_CF_SEL(pal) , sizeof(uint8_t), 255, 0, NULL); + getnumberptr256(tempbuf, &AIMED_CF_SEL(pal), sizeof(uint8_t), 255, 0, NULL); asksave = 1; } } @@ -6899,9 +6910,6 @@ static void Keys2d(void) { Bsprintf(tempbuf,"Sector %d Extra: ",i); sector[i].extra = getnumber16(tempbuf,sector[i].extra,BTAG_MAX,1); -// clearmidstatbar16(); -// showsectordata(i, 0); -// break; } } } @@ -7090,7 +7098,9 @@ static void Keys2d(void) } } else if (wallsprite==0) + { SearchSectors(tsign); + } else if (wallsprite==1) { if ((tsign<0 && curwallnum>0) || (tsign>0 && curwallnum>grid); } + if (autogrid) { grid = min(zoom+512, 65536); @@ -7333,7 +7343,7 @@ void ExtPreSaveMap(void) startwall = sector[i].wallptr; endwall = startwall + sector[i].wallnum; for (j=startwall; j\t\tOverride NAMES.H\n" #if defined RENDERTYPEWIN || (defined RENDERTYPESDL && !defined __APPLE__ && defined HAVE_GTK2) "-setup\t\tDisplays the configuration dialog\n" #endif @@ -7412,7 +7423,10 @@ static void G_CheckCommandLine(int32_t argc, const char **argv) { lengths = Bmalloc(argc*sizeof(int32_t)); for (j=1; j>3; } +#endif //#define BGTILE 311 //#define BGTILE 1156 @@ -8334,7 +8352,8 @@ void GAME_clearbackground(int32_t numcols, int32_t numrows) ysiz = tilesizx[BORDTILE]; for (x=0; x<=tx2; x++) - rotatesprite(x*xsiz<<16,(daydim+ysiz+1)<<16,65536L,1536,BORDTILE,SHADE-12,PALETTE,BITS,0,0,xdim,daydim+ysiz+1); + rotatesprite(x*xsiz<<16,(daydim+ysiz+1)<<16,65536L,1536, + BORDTILE,SHADE-12,PALETTE,BITS,0,0,xdim,daydim+ysiz+1); return; } @@ -8355,7 +8374,7 @@ static void m32_osdsetfunctions() */ 0,0,0,0,0, GAME_clearbackground, - (int32_t( *)(void))GetTime, + /*(int32_t( *)(void))*/GetTime, NULL ); } @@ -9194,7 +9213,8 @@ int32_t ExtInit(void) if (Bstrcmp(setupfilename, "mapster32.cfg")) initprintf("Using config file '%s'.\n",setupfilename); - if (loadsetup(setupfilename) < 0) initprintf("Configuration file not found, using defaults.\n"), rv = 1; + if (loadsetup(setupfilename) < 0) + initprintf("Configuration file not found, using defaults.\n"), rv = 1; if (glusetexcache == -1) { @@ -9212,7 +9232,7 @@ int32_t ExtInit(void) } #endif - Bmemcpy((void *)buildkeys,(void *)keys,NUMBUILDKEYS); //Trick to make build use setup.dat keys + Bmemcpy(buildkeys, default_buildkeys, NUMBUILDKEYS); //Trick to make build use setup.dat keys if (initengine()) { @@ -9225,7 +9245,6 @@ int32_t ExtInit(void) kensplayerheight = 40; //32 zmode = 2; zlock = kensplayerheight<<8; -// defaultspritecstat = 0; ReadGamePalette(); // InitWater(); @@ -10041,29 +10060,28 @@ void ExtCheckKeys(void) } } - if (asksave == 1 && (bstatus + lastbstatus) == 0 && mapstate) + if (asksave == 1) + asksave++; + else if (asksave == 2 && (bstatus + lastbstatus) == 0 && mapstate) { -#if 0 int32_t i; - // check keys so that e.g. bunch deletions won't produce - // as much revisions - for (i=sizeof(keystatus)/sizeof(keystatus[0]) - 1; i>=0; i--) + // check keys so that e.g. bulk deletions won't produce + // as much revisions as deleted sprites + for (i=sizeof(keystatus)/sizeof(keystatus[0])-1; i>=0; i--) if (keystatus[i]) break; - // message("Saved undo rev %d",map_revision); if (i==-1) -#endif { create_map_snapshot(); asksave++; } } - else if (asksave == 2) + else if (asksave == 3) asksave++; if (totalclock > autosavetimer && autosave) { - if (asksave == 3) + if (asksave == 4) { if (CheckMapCorruption(6, 0)>=4) { @@ -10076,7 +10094,7 @@ void ExtCheckKeys(void) message("Board autosaved to AUTOSAVE.MAP"); } - asksave = 4; + asksave++; } autosavetimer = totalclock+120*autosave; } diff --git a/polymer/eduke32/source/m32exec.c b/polymer/eduke32/source/m32exec.c index d96c78b2f..d9f76bbd4 100644 --- a/polymer/eduke32/source/m32exec.c +++ b/polymer/eduke32/source/m32exec.c @@ -60,7 +60,7 @@ static instype *x_sortingstateptr; extern void message(const char *fmt, ...); // from sector.c vvv -static int32_t ldist(spritetype *s1,spritetype *s2) +static int32_t ldist(const spritetype *s1, const spritetype *s2) { int32_t x= klabs(s1->x-s2->x); int32_t y= klabs(s1->y-s2->y); @@ -73,7 +73,7 @@ static int32_t ldist(spritetype *s1,spritetype *s2) } } -static int32_t dist(spritetype *s1,spritetype *s2) +static int32_t dist(const spritetype *s1, const spritetype *s2) { int32_t x= klabs(s1->x-s2->x); int32_t y= klabs(s1->y-s2->y); diff --git a/polymer/eduke32/source/mapster32.h b/polymer/eduke32/source/mapster32.h index b9a530cd4..ce906157e 100644 --- a/polymer/eduke32/source/mapster32.h +++ b/polymer/eduke32/source/mapster32.h @@ -37,8 +37,6 @@ extern char names[MAXTILES][25]; extern int32_t ydim16, xdimgame, ydimgame, bppgame, xdim2d, ydim2d; -extern int32_t zmode, kensplayerheight, zlock; - extern int16_t editstatus, searchit; extern int32_t searchx, searchy, osearchx, osearchy; //search input extern int16_t searchsector, searchwall, searchstat; //search output @@ -47,10 +45,10 @@ extern int16_t searchbottomwall; #define COLOR_RED 248 #define COLOR_WHITE 31 -#define NUMOPTIONS 9 -char option[NUMOPTIONS] = {0,0,0,0,0,0,1,0,0}; +//#define NUMOPTIONS 9 +//char option[NUMOPTIONS] = {0,0,0,0,0,0,1,0,0}; -uint8_t keys[NUMBUILDKEYS] = +uint8_t default_buildkeys[NUMBUILDKEYS] = { 0xc8,0xd0,0xcb,0xcd,0x2a,0x9d,0x1d,0x39, 0x1e,0x2c,0xd1,0xc9,0x47,0x49,