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
This commit is contained in:
helixhorned 2011-03-08 23:02:38 +00:00
parent c4f613e021
commit b158521449
8 changed files with 546 additions and 544 deletions

View file

@ -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;

View file

@ -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
if (m32_numdebuglines>0)
{
begindrawing();
for (i=0; i<m32_numdebuglines; i++)
{
y+=8;
printext256(x,y,whitecol,0,m32_debugstr[i],xdimgame>640?0:1);
}
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;
if ((unrealedlook && !mskip) &&
(((!mlook && (bstatus&2) && !(bstatus&(1|4)))) || ((bstatus&1) && !(bstatus&(2|4)))))
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);
move_and_update(xvect, yvect, 0);
}
else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0);
}
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])<<pk_uedaccel);
yvect = -((mousx*(int32_t)sintable[(ang+1536)&2047])<<pk_uedaccel);
pos.z += mousy<<(4+pk_uedaccel);
if (noclip)
{
pos.x += xvect>>14;
pos.y += yvect>>14;
updatesectorz(pos.x,pos.y,pos.z,&cursectnum);
move_and_update(xvect, yvect, 0);
}
else clipmove(&pos,&cursectnum,xvect,yvect,128L,4L<<8,4L<<8,CLIPMASK0);
}
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)
<<pk_uedaccel);
zvect = mousy*(((int32_t)sintable[(tempint+2048)&2047])>>(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 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)
{
@ -951,27 +940,17 @@ void editinput(void)
goalz += mousz;
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
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)) //Either shift key
if (DOWN_BK(RUN))
goalz += (12<<8);
}
}
if (goalz != pos.z)
{
@ -1033,8 +1012,10 @@ void editinput(void)
{
//if (pos.z < goalz) hvel += (32<<DOWN_BK(RUN));
//if (pos.z > goalz) hvel -= (32<<DOWN_BK(RUN));
if (pos.z < goalz) hvel = ((synctics* 192)<<DOWN_BK(RUN));
if (pos.z > goalz) hvel = ((synctics*-192)<<DOWN_BK(RUN));
if (pos.z < goalz)
hvel = ((192*synctics)<<DOWN_BK(RUN));
else
hvel = -((192*synctics)<<DOWN_BK(RUN));
pos.z += hvel;
@ -1110,8 +1091,7 @@ void editinput(void)
sprite[i].cstat = tempcstat;
}
cz = getceilzofslope(hitinfo.hitsect, hitinfo.pos.x, hitinfo.pos.y);
fz = getflorzofslope(hitinfo.hitsect, hitinfo.pos.x, hitinfo.pos.y);
getzsofslope(hitinfo.hitsect, hitinfo.pos.x, hitinfo.pos.y, &cz, &fz);
j = spriteheight(i, NULL)>>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<newnumwalls; i++)
wall[i].point2 = i+1;
Bfree(tmpwall);
tmpwall = NULL;
}
return 0;
}
void overheadeditor(void)
{
char buffer[80], *dabuffer, ch;
int32_t i, j, k, m=0, mousxplc, mousyplc, firstx=0, firsty=0, oposz, col;
int32_t tempint, tempint1, tempint2, doubvel;
int32_t tempint, tempint1, tempint2;
int32_t startwall=0, endwall, dax, day, x1, y1, x2, y2, x3, y3, x4, y4;
int32_t highlightx1, highlighty1, highlightx2, highlighty2, xvect, yvect;
int32_t highlightx1, highlighty1, highlightx2, highlighty2;
int16_t pag, suckwall=0, sucksect, split=0, bad;
int16_t splitsect=0, joinsector[2];
int16_t splitstartwall=0, loopnum;
int16_t splitstartwall=0;
int32_t mousx, mousy, bstatus;
int32_t centerx, centery, circlerad;
int16_t circlepoints, circleang1, circleang2, circleangdir;
@ -2086,8 +2102,8 @@ void overheadeditor(void)
mousy = (mousy<<16)+mouseysurp;
{
ldiv_t ld;
ld = ldiv((int32_t)(mousx), (1<<16)); mousx = ld.quot; mousexsurp = ld.rem;
ld = ldiv((int32_t)(mousy), (1<<16)); mousy = ld.quot; mouseysurp = ld.rem;
ld = ldiv(mousx, 1<<16); mousx = ld.quot; mousexsurp = ld.rem;
ld = ldiv(mousy, 1<<16); mousy = ld.quot; mouseysurp = ld.rem;
}
searchx += mousx;
searchy += mousy;
@ -2095,46 +2111,16 @@ void overheadeditor(void)
bclamp(&searchx, 8, xdim-8-1);
bclamp(&searchy, 8, ydim-8-1);
/* if (keystatus[0x3b] > 0) pos.x--, keystatus[0x3b] = 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 (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,8 +3157,9 @@ 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
@ -3222,7 +3209,7 @@ end_yax: ;
message("Attached new inner loop to sector %d", refsect);
}
}
}
}
@ -3318,22 +3305,10 @@ end_yax: ;
if (((bstatus&1) < (oldmousebstatus&1)) && highlightsectorcnt < 0) //after dragging
{
int32_t wallsdrawn = newnumwalls-numwalls, runi;
walltype *tmpwall = NULL;
int32_t runi;
if (newnumwalls != -1)
{
tmpwall = Bmalloc(wallsdrawn * sizeof(walltype));
if (!tmpwall)
{
wallsdrawn = -1;
if (backup_drawn_walls(0))
goto end_after_dragging;
}
newnumwalls = -1;
Bmemcpy(tmpwall, &wall[numwalls], wallsdrawn*sizeof(walltype));
}
else wallsdrawn = -1;
j = 1;
if (highlightcnt > 0)
@ -3401,17 +3376,9 @@ end_yax: ;
}
}
backup_drawn_walls(1);
}
end_after_dragging:
if (wallsdrawn != -1)
{
Bmemcpy(&wall[numwalls], tmpwall, wallsdrawn*sizeof(walltype));
newnumwalls = numwalls + wallsdrawn;
for (i=numwalls; i<newnumwalls; i++)
wall[i].point2 = i+1;
Bfree(tmpwall);
}
}
if ((bstatus&1) > 0) //drag points
{
@ -4462,19 +4429,27 @@ 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)
{
if (wall[k].x != wall[newnumwalls-1].x || wall[k].y != wall[newnumwalls-1].y)
continue;
i = k;
break;
}
if (i==-1)
goto end_space_handling;
doSectorSplit = (loopnumofsector(splitsect,splitstartwall) == loopnumofsector(splitsect,k));
splitendwall = k;
doSectorSplit = (loopnumofsector(splitsect,splitstartwall)
== loopnumofsector(splitsect,splitendwall));
if (numwalls+2*(newnumwalls-numwalls-1) > MAXWALLS)
if (expectedNumwalls > MAXWALLS)
{
printmessage16("%s would exceed wall limit.", bad==0 ?
"Splitting sector" : "Joining sector loops");
@ -4484,7 +4459,6 @@ check_next_sector: ;
////////// common code for splitting/loop joining //////////
splitendwall = k;
newnumwalls--; //first fix up the new walls
for (i=numwalls; i<newnumwalls; i++)
{
@ -4497,6 +4471,7 @@ check_next_sector: ;
if (doSectorSplit)
{
// Copy outer loop of first sector
while (m != splitstartwall)
if (copyloop1(&danumwalls, &m)) goto split_not_enough_walls;
wall[danumwalls-1].point2 = numwalls;
@ -4674,7 +4649,22 @@ check_next_sector: ;
}
}
#endif
printmessage16(doSectorSplit ? "Sector split." : "Loops joined.");
if (numwalls==expectedNumwalls)
{
message("%s", doSectorSplit ? "Sector split." : "Loops joined.");
}
else
{
message("%s WARNING: CREATED %d MORE WALLS THAN EXPECTED!",
doSectorSplit ? "Sector split." : "Loops joined.",
expectedNumwalls-numwalls);
// this would display 'num* out of bounds' but this corruption
// is almost as bad...
if (numcorruptthings < MAXCORRUPTTHINGS)
corruptthings[numcorruptthings++] = 0;
corruptlevel = 5;
}
if (0)
{
@ -4684,8 +4674,6 @@ split_not_enough_walls:
}
newnumwalls = -1;
break;
}
}
}
}
@ -4760,7 +4748,7 @@ end_space_handling:
backspace_last = 0;
}
if (keystatus[0xd3] && eitherCTRL && (numwalls >= 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<newnumwalls; i++)
wall[i].point2 = i+1;
}
backup_drawn_walls(1);
asksave = 1;
}

View file

@ -59,8 +59,8 @@ extern int16_t brightness;
extern int32_t vsync;
extern char game_executable[BMAX_PATH];
extern int32_t fullscreen;
extern char option[9];
extern char keys[NUMBUILDKEYS];
extern char default_buildkeys[NUMBUILDKEYS];
static char *const keys = default_buildkeys;
extern char remap[256];
extern int32_t remapinit;
extern double msens;
@ -134,8 +134,8 @@ int32_t loadsetup(const char *fn)
if (readconfig(fp, "xdim3d", val, VL) > 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,

View file

@ -808,7 +808,8 @@ void getvalidmodes(void)
validmodecnt=0;
// initprintf("Detecting video modes:\n");
#define ADDMODE(x,y,c,f) if (validmodecnt<MAXVALIDMODES) { \
#define ADDMODE(x,y,c,f) do { \
if (validmodecnt<MAXVALIDMODES) { \
int32_t mn; \
for(mn=0;mn<validmodecnt;mn++) \
if (validmode[mn].xdim==x && validmode[mn].ydim==y && \
@ -821,7 +822,8 @@ void getvalidmodes(void)
validmodecnt++; \
/*initprintf(" - %dx%d %d-bit %s\n", x, y, c, (f&1)?"fullscreen":"windowed");*/ \
} \
}
} \
} while (0)
#define CHECK(w,h) if ((w < maxx) && (h < maxy))
@ -849,7 +851,7 @@ void getvalidmodes(void)
if (modes == (SDL_Rect **)-1)
{
for (i=0; defaultres[i][0]; i++)
ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],1)
ADDMODE(defaultres[i][0],defaultres[i][1],cdepths[j],1);
}
else
{
@ -857,7 +859,7 @@ void getvalidmodes(void)
{
if ((modes[i]->w > 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

View file

@ -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

View file

@ -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))
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;
}
@ -6007,9 +6018,9 @@ static void Keys3d(void)
if (mouseaction)
{
i = wall[w].cstat;
i=((i>>3)&1)+((i>>7)&2);
i &= (8|256);
if (i==1||i==3)
if (i==8 || i==256)
changedir*=-1;
if (eitherCTRL)
@ -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<numwalls))
@ -7125,9 +7135,7 @@ static void Keys2d(void)
{
if (autogrid)
{
grid = 0;
if (eitherSHIFT)
grid = 8;
grid = 8*eitherSHIFT;
autogrid = 0;
}
@ -7140,6 +7148,7 @@ static void Keys2d(void)
grid = 0;
}
}
if (autogrid)
printmessage16("Grid size: 9 (autosize)");
else if (!grid)
@ -7147,6 +7156,7 @@ static void Keys2d(void)
else
printmessage16("Grid size: %d (%d units)", grid, 2048>>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<endwall; j++)
checksectorpointer((int16_t)j,(int16_t)i);
checksectorpointer(j, i);
}
}
}
@ -7346,6 +7356,7 @@ static void G_ShowParameterHelp(void)
"-jDIR, -game_dir DIR\n\t\tAdds DIR to the file path stack\n"
"-check\t\tEnables map pointer checking when saving\n"
"-nocheck\t\tDisables map pointer checking when saving (default)\n" // kept for script compat
"-namesfile <filename>\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<argc; j++)
maxlen += (lengths[j] = Bstrlen(argv[j]));
{
lengths[j] = Bstrlen(argv[j]);
maxlen += lengths[j];
}
testplay_addparam = Bmalloc(maxlen+argc);
testplay_addparam[0] = 0;
@ -8116,7 +8130,7 @@ static int32_t osdcmd_do(const osdfuncparm_t *parm)
return OSDCMD_OK;
OUTOFMEM:
OSD_Printf("OUT OF MEMORY!\n");
message("OUT OF MEMORY!\n");
return OSDCMD_OK;
}
@ -8236,6 +8250,7 @@ static int32_t registerosdcommands(void)
#define DUKEOSD
#ifdef DUKEOSD
#if 0
void GAME_drawosdchar(int32_t x, int32_t y, char ch, int32_t shade, int32_t pal)
{
int32_t ac;
@ -8266,12 +8281,14 @@ void GAME_drawosdstr(int32_t x, int32_t y, char *ch, int32_t len, int32_t shade,
else x += tilesizx[ac];
}
}
#endif
static int32_t GetTime(void)
{
return totalclock;
}
#if 0
void GAME_drawosdcursor(int32_t x, int32_t y, int32_t type, int32_t lastkeypress)
{
int32_t ac;
@ -8292,6 +8309,7 @@ int32_t GAME_getrowheight(int32_t w)
{
return w>>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
// 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;
}

View file

@ -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);

View file

@ -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,