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

View file

@ -441,8 +441,10 @@ int32_t writesetup(const char *fn)
#endif
// "; Console key scancode, in hex\n"
"keyconsole = %X\n"
"; example: make 'Q' function as CapsLock and 'N' as AltGr:\n"
"; remap = 10-3A,31-B8\n"
"; example: make 'Q' function as CapsLock, KP. as AltGr\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 = ",
forcesetup, fullscreen, xdim2d, ydim2d, xdimgame, ydimgame, bppgame,