More undo fixes

git-svn-id: https://svn.eduke32.com/eduke32@1447 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2009-06-28 23:47:38 +00:00
parent 5cdc55591b
commit ad3b34c49b

View file

@ -210,6 +210,8 @@ void create_map_snapshot(void)
tempcrc = crc32once((uint8_t *)&sector[0],sizeof(sectortype) * numsectors);
if (numsectors)
{
if (mapstate->prev && mapstate->prev->sectcrc == tempcrc)
{
mapstate->sectors = mapstate->prev->sectors;
@ -226,6 +228,8 @@ void create_map_snapshot(void)
mapstate->sectcrc = tempcrc;
}
if (numwalls)
{
tempcrc = crc32once((uint8_t *)&wall[0],sizeof(walltype) * numwalls);
@ -244,7 +248,10 @@ void create_map_snapshot(void)
mapstate->walls = (walltype *)Brealloc(mapstate->walls, j);
mapstate->wallcrc = tempcrc;
}
}
if (numsprites)
{
tempcrc = crc32once((uint8_t *)&sprite[0],sizeof(spritetype) * MAXSPRITES);
if (mapstate->prev && mapstate->prev->spritecrc == tempcrc)
@ -277,38 +284,35 @@ void create_map_snapshot(void)
Bfree(tspri);
}
}
}
}
void map_undoredo_free(void)
{
if (mapstate)
{
if (mapstate->next != NULL)
{
mapundo_t *next = mapstate->next;
while (mapstate->next)
mapstate = mapstate->next;
while (next->next)
next = next->next;
while (next->prev)
while (mapstate->prev)
{
next = next->prev;
if (next->next->sectors && (next->next->sectors != next->sectors)) Bfree(next->next->sectors);
if (next->next->walls && (next->next->walls != next->walls)) Bfree(next->next->walls);
if (next->next->sprites && (next->next->sprites != next->sprites)) Bfree(next->next->sprites);
if (next->next == mapstate)
mapstate = NULL;
Bfree(next->next);
next->next = NULL;
}
mapundo_t *state = mapstate->prev;
if (mapstate->sectors && (mapstate->sectcrc != mapstate->prev->sectcrc)) Bfree(mapstate->sectors);
if (mapstate->walls && (mapstate->wallcrc != mapstate->prev->wallcrc)) Bfree(mapstate->walls);
if (mapstate->sprites && (mapstate->spritecrc != mapstate->prev->spritecrc)) Bfree(mapstate->sprites);
Bfree(mapstate);
mapstate = state;
}
if (mapstate)
if (mapstate->sectors) Bfree(mapstate->sectors);
if (mapstate->walls) Bfree(mapstate->walls);
if (mapstate->sprites) Bfree(mapstate->sprites);
Bfree(mapstate);
mapstate = NULL;
}
map_revision = 1;
}
int32_t map_undoredo(int32_t dir)
@ -343,9 +347,16 @@ int32_t map_undoredo(int32_t dir)
clearbuf(&show2dsprite[0],(int32_t)((MAXSPRITES+3)>>5),0L);
clearbuf(&show2dwall[0],(int32_t)((MAXWALLS+3)>>5),0L);
if (mapstate->numsectors)
{
lzf_decompress(&mapstate->sectors[0], mapstate->sectsiz, &sector[0], sizeof(sectortype) * numsectors);
if (mapstate->numwalls)
lzf_decompress(&mapstate->walls[0], mapstate->wallsiz, &wall[0], sizeof(walltype) * numwalls);
if (mapstate->numsprites)
lzf_decompress(&mapstate->sprites[0], mapstate->spritesiz, &sprite[0], sizeof(spritetype) * numsprites);
}
updatenumsprites();