safety check when copying sectors; a suggestion to bypass a strange bug

git-svn-id: https://svn.eduke32.com/eduke32@1449 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2009-07-03 13:01:52 +00:00
parent f2aa52ac07
commit 28e5528417
2 changed files with 60 additions and 40 deletions

View file

@ -3958,55 +3958,73 @@ SKIP:
} }
if (keystatus[0xd2] || keystatus[0x17]) //InsertPoint if (keystatus[0xd2] || keystatus[0x17]) //InsertPoint
{ {
if (highlightsectorcnt >= 0) if (highlightsectorcnt >= 0)
{ {
newnumsectors = numsectors; int32_t newwalls = 0;
newnumwalls = numwalls;
for (i=0; i<highlightsectorcnt; i++) for (i=0; i<highlightsectorcnt; i++)
{ newwalls += sector[highlightsector[i]].wallnum;
copysector(highlightsector[i],newnumsectors,newnumwalls,1);
newnumsectors++;
newnumwalls += sector[highlightsector[i]].wallnum;
}
for (i=0; i<highlightsectorcnt; i++) if (highlightsectorcnt + numsectors <= MAXSECTORS && numwalls+newwalls <= MAXWALLS)
{ {
startwall = sector[highlightsector[i]].wallptr; newnumsectors = numsectors;
endwall = startwall+sector[highlightsector[i]].wallnum-1; newnumwalls = numwalls;
for (j=startwall; j<=endwall; j++) for (i=0; i<highlightsectorcnt; i++)
{ {
if (wall[j].nextwall >= 0) copysector(highlightsector[i],newnumsectors,newnumwalls,1);
checksectorpointer(wall[j].nextwall,wall[j].nextsector); newnumsectors++;
checksectorpointer((int16_t)j,highlightsector[i]); newnumwalls += sector[highlightsector[i]].wallnum;
} }
highlightsector[i] = numsectors+i;
for (i=0; i<highlightsectorcnt; i++)
{
startwall = sector[highlightsector[i]].wallptr;
endwall = startwall+sector[highlightsector[i]].wallnum-1;
for (j=startwall; j<=endwall; j++)
{
if (wall[j].nextwall >= 0)
checksectorpointer(wall[j].nextwall,wall[j].nextsector);
checksectorpointer((int16_t)j,highlightsector[i]);
}
highlightsector[i] = numsectors+i;
}
numsectors = newnumsectors;
numwalls = newnumwalls;
newnumwalls = -1;
newnumsectors = -1;
updatenumsprites();
printmessage16("Sectors duplicated and stamped.");
asksave = 1;
}
else
{
printmessage16("Copying sectors would exceed sector or wall limit.");
} }
numsectors = newnumsectors;
numwalls = newnumwalls;
newnumwalls = -1;
newnumsectors = -1;
updatenumsprites();
printmessage16("Sectors duplicated and stamped.");
asksave = 1;
} }
else if (highlightcnt >= 0) else if (highlightcnt >= 0)
{ {
for (i=0; i<highlightcnt; i++) if (highlightcnt + numsprites <= MAXSPRITES)
if ((highlight[i]&0xc000) == 16384) {
{ for (i=0; i<highlightcnt; i++)
//duplicate sprite if ((highlight[i]&0xc000) == 16384)
k = (highlight[i]&16383); {
j = insertsprite(sprite[k].sectnum,sprite[k].statnum); //duplicate sprite
Bmemcpy(&sprite[j],&sprite[k],sizeof(spritetype)); k = (highlight[i]&16383);
sprite[j].sectnum = sprite[k].sectnum; //Don't let memcpy overwrite sector! j = insertsprite(sprite[k].sectnum,sprite[k].statnum);
setsprite(j,(vec3_t *)&sprite[j]); Bmemcpy(&sprite[j],&sprite[k],sizeof(spritetype));
} sprite[j].sectnum = sprite[k].sectnum; //Don't let memcpy overwrite sector!
updatenumsprites(); setsprite(j,(vec3_t *)&sprite[j]);
printmessage16("Sprites duplicated and stamped."); }
asksave = 1; updatenumsprites();
printmessage16("Sprites duplicated and stamped.");
asksave = 1;
}
else
{
printmessage16("Copying sprites would exceed sprite limit.");
}
} }
else if (linehighlight >= 0) else if (linehighlight >= 0)
{ {

View file

@ -441,8 +441,10 @@ int32_t writesetup(const char *fn)
#endif #endif
// "; Console key scancode, in hex\n" // "; Console key scancode, in hex\n"
"keyconsole = %X\n" "keyconsole = %X\n"
"; example: make 'Q' function as CapsLock and 'N' as AltGr:\n" "; example: make 'Q' function as CapsLock, KP. as AltGr\n"
"; remap = 10-3A,31-B8\n" "; and KP0 as KP5 (counters inability to pan using Shift-KP5-KP8/2\n"
"; in 3D mode)\n"
"; remap = 10-3A,52-4C,53-B8\n"
"remap = ", "remap = ",
forcesetup, fullscreen, xdim2d, ydim2d, xdimgame, ydimgame, bppgame, forcesetup, fullscreen, xdim2d, ydim2d, xdimgame, ydimgame, bppgame,