diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 717817cc7..c6dc550e1 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -217,6 +217,7 @@ int32_t menuselect_pk(int32_t); //PK int32_t getfilenames(char *path, char *kind); void clearfilenames(void); void loadmhk(); +extern int32_t map_revision; void clearkeys(void) { memset(keystatus,0,sizeof(keystatus)); } @@ -5733,58 +5734,6 @@ int16_t whitelinescan(int16_t dalinehighlight) else return(newnumwalls); } -/* -#define loadbyte(fil,tempbuf,bufplc,dat) \ -{ \ - if (bufplc == 0) \ - { \ - for(bufplc=0;bufplc<4096;bufplc++) \ - tempbuf[bufplc] = 0; \ - bufplc = 0; \ - read(fil,tempbuf,4096); \ - } \ - dat = tempbuf[bufplc]; \ - bufplc = ((bufplc+1)&4095); \ -} \ - -int32_t loadnames(void) -{ - char buffer[80], firstch, ch; - int32_t fil, i, num, buffercnt, bufplc; - - if ((fil = open("names.h",O_BINARY|O_RDWR,S_IREAD)) == -1) return(-1); - bufplc = 0; - do { loadbyte(fil,tempbuf,bufplc,firstch); } while (firstch != '#'); - - while ((firstch == '#') || (firstch == '/')) - { - do { loadbyte(fil,tempbuf,bufplc,ch); } while (ch > 32); - - buffercnt = 0; - do - { - loadbyte(fil,tempbuf,bufplc,ch); - if (ch > 32) buffer[buffercnt++] = ch; - } - while (ch > 32); - - num = 0; - do - { - loadbyte(fil,tempbuf,bufplc,ch); - if ((ch >= 48) && (ch <= 57)) num = num*10+(ch-48); - } - while (ch != 13); - for(i=0;inumwalls = numwalls; mapstate->numsprites = numsprites; - if (mapstate->prev && mapstate->prev->numsectors == numsectors && - mapstate->prev->sectcrc == crc32once((uint8_t *)§or[0],sizeof(sectortype) * numsectors)) + tempcrc = crc32once((uint8_t *)§or[0],sizeof(sectortype) * numsectors); + + if (mapstate->prev && mapstate->prev->numsectors == numsectors && mapstate->prev->sectcrc == tempcrc) { mapstate->sectors = mapstate->prev->sectors; /*OSD_Printf("found a match between undo sectors\n");*/ @@ -201,12 +201,15 @@ void create_map_snapshot(void) else { mapstate->sectors = (sectortype *)Bcalloc(1, sizeof(sectortype) * numsectors); - Bmemcpy(&mapstate->sectors[0], §or[0], sizeof(sectortype) * numsectors); - mapstate->sectcrc = crc32once((uint8_t *)&mapstate->sectors[0],sizeof(sectortype) * numsectors); + mapstate->sectsiz = j = lzf_compress(§or[0], sizeof(sectortype) * numsectors, + &mapstate->sectors[0], sizeof(sectortype) * numsectors); + mapstate->sectors = (sectortype *)Brealloc(mapstate->sectors, j); + mapstate->sectcrc = tempcrc; } - if (mapstate->prev && mapstate->prev->numwalls == numwalls && - mapstate->prev->wallcrc == crc32once((uint8_t *)&wall[0],sizeof(walltype) * numwalls)) + tempcrc = crc32once((uint8_t *)&wall[0],sizeof(walltype) * numwalls); + + if (mapstate->prev && mapstate->prev->numwalls == numwalls && mapstate->prev->wallcrc == tempcrc) { mapstate->walls = mapstate->prev->walls; /*OSD_Printf("found a match between undo walls\n");*/ @@ -214,28 +217,36 @@ void create_map_snapshot(void) else { mapstate->walls = (walltype *)Bcalloc(1, sizeof(walltype) * numwalls); - Bmemcpy(&mapstate->walls[0], &wall[0], sizeof(walltype) * numwalls); - mapstate->wallcrc = crc32once((uint8_t *)&mapstate->walls[0],sizeof(walltype) * numwalls); + mapstate->wallsiz = j = lzf_compress(&wall[0], sizeof(walltype) * numwalls, + &mapstate->walls[0], sizeof(walltype) * numwalls); + mapstate->walls = (walltype *)Brealloc(mapstate->walls, j); + mapstate->wallcrc = tempcrc; } - if (mapstate->prev && mapstate->prev->numsprites == numsprites && - mapstate->prev->spritecrc == crc32once((uint8_t *)&sprite[0],sizeof(spritetype) * numsprites)) + tempcrc = crc32once((uint8_t *)&sprite[0],sizeof(spritetype) * numsprites); + + if (mapstate->prev && mapstate->prev->numsprites == numsprites && mapstate->prev->spritecrc == tempcrc) { mapstate->sprites = mapstate->prev->sprites; /*OSD_Printf("found a match between undo sprites\n");*/ } else { - spritetype *spri; + spritetype *spri, *tspri = (spritetype *)Bcalloc(1, sizeof(spritetype) * numsprites); mapstate->sprites = (spritetype *)Bcalloc(1, sizeof(spritetype) * numsprites); - spri=&mapstate->sprites[0]; + + spri = &tspri[0]; for (j=0; jspritecrc = crc32once((uint8_t *)&mapstate->sprites[0],sizeof(spritetype) * numsprites); + mapstate->spritesiz = j = lzf_compress(&tspri[0], sizeof(spritetype) * numsprites, + &mapstate->sprites[0], sizeof(spritetype) * numsprites); + mapstate->sprites = (spritetype *)Brealloc(mapstate->sprites, j); + mapstate->spritecrc = tempcrc; + Bfree(tspri); } mapstate->revision = ++map_revision; @@ -246,7 +257,7 @@ int32_t map_undo(void) { int32_t i; - if (mapstate == NULL || mapstate->prev == NULL) return 1; + if (mapstate == NULL || mapstate->prev == NULL || !mapstate->prev->numsectors) return 1; mapstate = mapstate->prev; @@ -256,9 +267,9 @@ int32_t map_undo(void) initspritelists(); - Bmemcpy(§or[0], &mapstate->sectors[0], sizeof(sectortype) * numsectors); - Bmemcpy(&wall[0], &mapstate->walls[0], sizeof(walltype) * numwalls); - Bmemcpy(&sprite[0], &mapstate->sprites[0], sizeof(spritetype) * numsprites); + lzf_decompress(&mapstate->sectors[0], mapstate->sectsiz, §or[0], sizeof(sectortype) * numsectors); + lzf_decompress(&mapstate->walls[0], mapstate->wallsiz, &wall[0], sizeof(walltype) * numwalls); + lzf_decompress(&mapstate->sprites[0], mapstate->spritesiz, &sprite[0], sizeof(spritetype) * numsprites); updatenumsprites(); @@ -270,6 +281,10 @@ int32_t map_undo(void) map_revision = mapstate->revision; +#ifdef POLYMER + if (qsetmode == 200 && rendmode == 4) + polymer_loadboard(); +#endif return 0; } @@ -287,9 +302,9 @@ int32_t map_redo(void) initspritelists(); - Bmemcpy(§or[0], &mapstate->sectors[0], sizeof(sectortype) * numsectors); - Bmemcpy(&wall[0], &mapstate->walls[0], sizeof(walltype) * numwalls); - Bmemcpy(&sprite[0], &mapstate->sprites[0], sizeof(spritetype) * numsprites); + lzf_decompress(&mapstate->sectors[0], mapstate->sectsiz, §or[0], sizeof(sectortype) * numsectors); + lzf_decompress(&mapstate->walls[0], mapstate->wallsiz, &wall[0], sizeof(walltype) * numwalls); + lzf_decompress(&mapstate->sprites[0], mapstate->spritesiz, &sprite[0], sizeof(spritetype) * numsprites); updatenumsprites(); @@ -301,6 +316,10 @@ int32_t map_redo(void) map_revision = mapstate->revision; +#ifdef POLYMER + if (qsetmode == 200 && rendmode == 4) + polymer_loadboard(); +#endif return 0; } @@ -7474,7 +7493,7 @@ static void Keys2d(void) { showsectordata((int16_t)cursectornum+16384); } - if (totalclock < (lastpm16time + 120*3)) + if (totalclock < (lastpm16time + 120*2)) _printmessage16(lastpm16buf); } /* @@ -10260,6 +10279,8 @@ static void Keys2d3d(void) { mapstate = (mapundo_t *)Bcalloc(1, sizeof(mapundo_t)); create_map_snapshot(); // initial map state + Bfree(mapstate->next); + mapstate = mapstate->prev; } if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_A]) // ' a @@ -10295,12 +10316,12 @@ static void Keys2d3d(void) if (eitherSHIFT) { if (map_redo()) message("Nothing to redo!"); - else message("Restored undo rev %d",map_revision); + else message("Restored undo rev %d",map_revision-1); } else { if (map_undo()) message("Nothing to undo!"); - else message("Restored undo rev %d",map_revision); + else message("Restored undo rev %d",map_revision-1); } }