Mapster undo fixes and some other relatively minor stuff... SPRITE_NOLIGHT flag to kill built in lights from CONs

git-svn-id: https://svn.eduke32.com/eduke32@1444 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2009-06-28 20:23:12 +00:00
parent 6f6f0900c8
commit f061313bef
5 changed files with 1949 additions and 1906 deletions

View file

@ -7853,6 +7853,17 @@ void G_MoveWorld(void)
{ {
spritetype *s = &sprite[i]; spritetype *s = &sprite[i];
if ((s->cstat & 32768) || A_CheckSpriteFlags(i, SPRITE_NOLIGHT))
{
if (ActorExtra[i].lightptr != NULL)
{
polymer_deletelight(ActorExtra[i].lightId);
ActorExtra[i].lightId = -1;
ActorExtra[i].lightptr = NULL;
}
break;
}
if (ActorExtra[i].lightptr != NULL && ActorExtra[i].lightcount) if (ActorExtra[i].lightptr != NULL && ActorExtra[i].lightcount)
{ {
if (!(--ActorExtra[i].lightcount)) if (!(--ActorExtra[i].lightcount))
@ -7883,8 +7894,16 @@ void G_MoveWorld(void)
{ {
int32_t x, y; int32_t x, y;
if (s->cstat & 32768 || !inside(s->x+((sintable[(s->ang+512)&2047])>>9), s->y+((sintable[(s->ang)&2047])>>9), s->sectnum)) if ((s->cstat & 32768) || A_CheckSpriteFlags(i, SPRITE_NOLIGHT) || !inside(s->x+((sintable[(s->ang+512)&2047])>>9), s->y+((sintable[(s->ang)&2047])>>9), s->sectnum))
{
if (ActorExtra[i].lightptr != NULL)
{
polymer_deletelight(ActorExtra[i].lightId);
ActorExtra[i].lightId = -1;
ActorExtra[i].lightptr = NULL;
}
break; break;
}
x = ((sintable[(s->ang+512)&2047])>>7); x = ((sintable[(s->ang+512)&2047])>>7);
y = ((sintable[(s->ang)&2047])>>7); y = ((sintable[(s->ang)&2047])>>7);
@ -7981,7 +8000,7 @@ void G_MoveWorld(void)
{ {
int32_t x, y; int32_t x, y;
if ((s->cstat & 32768) || !inside(s->x+((sintable[(s->ang+512)&2047])>>9), s->y+((sintable[(s->ang)&2047])>>9), s->sectnum)) if ((s->cstat & 32768) || A_CheckSpriteFlags(i, SPRITE_NOLIGHT) || !inside(s->x+((sintable[(s->ang+512)&2047])>>9), s->y+((sintable[(s->ang)&2047])>>9), s->sectnum))
{ {
if (ActorExtra[i].lightptr != NULL) if (ActorExtra[i].lightptr != NULL)
{ {

View file

@ -143,18 +143,26 @@ typedef struct _mapundo
mapundo_t *mapstate = NULL; mapundo_t *mapstate = NULL;
int32_t map_revision = 0; int32_t map_revision = 1;
void create_map_snapshot(void) void create_map_snapshot(void)
{ {
int32_t j; int32_t j;
uint32_t tempcrc; uint32_t tempcrc;
// if (mapstate == NULL) mapstate = (mapundo_t *)Bcalloc(1, sizeof(mapundo_t)); /*
if (mapstate->prev == NULL && mapstate->next != NULL) // should be the first map version if (mapstate->prev == NULL && mapstate->next != NULL) // should be the first map version
mapstate = mapstate->next; mapstate = mapstate->next;
*/
if (mapstate == NULL)
{
mapstate = (mapundo_t *)Bcalloc(1, sizeof(mapundo_t));
mapstate->revision = map_revision = 1;
mapstate->prev = mapstate->next = NULL;
}
else
{
if (mapstate->next != NULL) if (mapstate->next != NULL)
{ {
mapundo_t *next = mapstate->next; mapundo_t *next = mapstate->next;
@ -163,24 +171,33 @@ void create_map_snapshot(void)
while (next->next) while (next->next)
next = next->next; next = next->next;
while (next->prev) do
{ {
next = next->prev; if (next->sectors && (next->prev == NULL || (next->sectcrc != next->prev->sectcrc))) Bfree(next->sectors);
if (next->next->sectors && (next->next->sectors != next->sectors)) Bfree(next->next->sectors); if (next->walls && (next->prev == NULL || (next->wallcrc != next->prev->wallcrc))) Bfree(next->walls);
if (next->next->walls && (next->next->walls != next->walls)) Bfree(next->next->walls); if (next->sprites && (next->prev == NULL || (next->spritecrc != next->prev->spritecrc))) Bfree(next->sprites);
if (next->next->sprites && (next->next->sprites != next->sprites)) Bfree(next->next->sprites); if (!next->prev)
Bfree(next->next); {
next->next = NULL; Bfree(next);
break;
} }
next = next->prev;
Bfree(next->next);
}
while (next);
} }
mapstate->next = (mapundo_t *)Bcalloc(1, sizeof(mapundo_t)); mapstate->next = (mapundo_t *)Bcalloc(1, sizeof(mapundo_t));
mapstate->next->prev = mapstate; mapstate->next->prev = mapstate;
mapstate = mapstate->next;
mapstate->revision = ++map_revision;
}
fixspritesectors(); fixspritesectors();
numsprites = 0; numsprites = 0;
for (j=0; j<MAXSPRITES; j++) for (j=MAXSPRITES-1; j>=0; j--)
{ {
if (sprite[j].statnum != MAXSTATUS) if (sprite[j].statnum != MAXSTATUS)
numsprites++; numsprites++;
@ -193,7 +210,7 @@ void create_map_snapshot(void)
tempcrc = crc32once((uint8_t *)&sector[0],sizeof(sectortype) * numsectors); tempcrc = crc32once((uint8_t *)&sector[0],sizeof(sectortype) * numsectors);
if (mapstate->prev && mapstate->prev->numsectors == numsectors && mapstate->prev->sectcrc == tempcrc) if (mapstate->prev && mapstate->prev->sectcrc == tempcrc)
{ {
mapstate->sectors = mapstate->prev->sectors; mapstate->sectors = mapstate->prev->sectors;
mapstate->sectsiz = mapstate->prev->sectsiz; mapstate->sectsiz = mapstate->prev->sectsiz;
@ -212,7 +229,7 @@ void create_map_snapshot(void)
tempcrc = 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) if (mapstate->prev && mapstate->prev->wallcrc == tempcrc)
{ {
mapstate->walls = mapstate->prev->walls; mapstate->walls = mapstate->prev->walls;
mapstate->wallsiz = mapstate->prev->wallsiz; mapstate->wallsiz = mapstate->prev->wallsiz;
@ -230,7 +247,7 @@ void create_map_snapshot(void)
tempcrc = crc32once((uint8_t *)&sprite[0],sizeof(spritetype) * MAXSPRITES); tempcrc = crc32once((uint8_t *)&sprite[0],sizeof(spritetype) * MAXSPRITES);
if (mapstate->prev && mapstate->prev->numsprites == numsprites && mapstate->prev->spritecrc == tempcrc) if (mapstate->prev && mapstate->prev->spritecrc == tempcrc)
{ {
mapstate->sprites = mapstate->prev->sprites; mapstate->sprites = mapstate->prev->sprites;
mapstate->spritesiz = mapstate->prev->spritesiz; mapstate->spritesiz = mapstate->prev->spritesiz;
@ -245,10 +262,13 @@ void create_map_snapshot(void)
spri = &tspri[0]; spri = &tspri[0];
for (j=0; j<MAXSPRITES && i < numsprites; j++,i++) for (j=0; j<MAXSPRITES && i < numsprites; j++)
{ {
if (sprite[j].statnum != MAXSTATUS) if (sprite[j].statnum != MAXSTATUS)
{
Bmemcpy(spri++,&sprite[j],sizeof(spritetype)); Bmemcpy(spri++,&sprite[j],sizeof(spritetype));
i++;
}
} }
mapstate->spritesiz = j = lzf_compress(&tspri[0], sizeof(spritetype) * numsprites, mapstate->spritesiz = j = lzf_compress(&tspri[0], sizeof(spritetype) * numsprites,
&mapstate->sprites[0], sizeof(spritetype) * numsprites); &mapstate->sprites[0], sizeof(spritetype) * numsprites);
@ -256,9 +276,6 @@ void create_map_snapshot(void)
mapstate->spritecrc = tempcrc; mapstate->spritecrc = tempcrc;
Bfree(tspri); Bfree(tspri);
} }
mapstate->revision = ++map_revision;
mapstate = mapstate->next;
} }
void map_undoredo_free(void) void map_undoredo_free(void)
@ -290,7 +307,7 @@ void map_undoredo_free(void)
mapstate = NULL; mapstate = NULL;
} }
map_revision = 0; map_revision = 1;
} }
@ -298,24 +315,27 @@ int32_t map_undoredo(int32_t dir)
{ {
int32_t i; int32_t i;
if (mapstate == NULL) return 1;
if (dir) if (dir)
{ {
if (mapstate == NULL || mapstate->next == NULL || !mapstate->next->numsectors) return 1; if (mapstate->next == NULL || !mapstate->next->numsectors) return 1;
while (map_revision+1 != mapstate->revision && mapstate->next) // while (map_revision+1 != mapstate->revision && mapstate->next)
mapstate = mapstate->next; mapstate = mapstate->next;
} }
else else
{ {
if (mapstate == NULL || mapstate->prev == NULL || !mapstate->prev->numsectors) return 1; if (mapstate->prev == NULL || !mapstate->prev->numsectors) return 1;
while (map_revision-1 != mapstate->revision && mapstate->prev) // while (map_revision-1 != mapstate->revision && mapstate->prev)
mapstate = mapstate->prev; mapstate = mapstate->prev;
} }
numsectors = mapstate->numsectors; numsectors = mapstate->numsectors;
numwalls = mapstate->numwalls; numwalls = mapstate->numwalls;
numsprites = mapstate->numsprites; numsprites = mapstate->numsprites;
map_revision = mapstate->revision;
initspritelists(); initspritelists();
@ -335,8 +355,6 @@ int32_t map_undoredo(int32_t dir)
insertsprite(sprite[i].sectnum,sprite[i].statnum); insertsprite(sprite[i].sectnum,sprite[i].statnum);
} }
map_revision = mapstate->revision;
#ifdef POLYMER #ifdef POLYMER
if (qsetmode == 200 && rendmode == 4) if (qsetmode == 200 && rendmode == 4)
polymer_loadboard(); polymer_loadboard();
@ -667,7 +685,7 @@ const char *ExtGetSectorType(int32_t lotag)
default : default :
if (lotag > 10000 && lotag < 32767) if (lotag > 10000 && lotag < 32767)
Bsprintf(tempbuf,"1 TIME SOUND"); Bsprintf(tempbuf,"1 TIME SOUND");
// else Bsprintf(tempbuf,"%hu",lotag); // else Bsprintf(tempbuf,"%hu",lotag);
break; break;
} }
return(tempbuf); return(tempbuf);
@ -1646,7 +1664,7 @@ static void IntegratedHelp()
enddrawing(); enddrawing();
memset(oldpattern, 0, sizeof(char)); memset(oldpattern, 0, sizeof(char));
// clearmidstatbar16(); // clearmidstatbar16();
while (keystatus[KEYSC_ESC]==0 && keystatus[KEYSC_Q]==0 && keystatus[KEYSC_F1]==0) while (keystatus[KEYSC_ESC]==0 && keystatus[KEYSC_Q]==0 && keystatus[KEYSC_F1]==0)
{ {
@ -1655,7 +1673,7 @@ static void IntegratedHelp()
if (quitevent) quitevent = 0; if (quitevent) quitevent = 0;
} }
idle(); idle();
// printmessage16("Help mode, press <Esc> to exit"); // printmessage16("Help mode, press <Esc> to exit");
if (keystatus[KEYSC_T]) // goto table of contents if (keystatus[KEYSC_T]) // goto table of contents
{ {
@ -1880,12 +1898,12 @@ ENDFOR1:
} }
overridepm16y = -1; overridepm16y = -1;
// i=ydim16; // i=ydim16;
// ydim16=ydim; // ydim16=ydim;
// drawline16(0,ydim-STATUS2DSIZ,xdim-1,ydim-STATUS2DSIZ,editorcolors[1]); // drawline16(0,ydim-STATUS2DSIZ,xdim-1,ydim-STATUS2DSIZ,editorcolors[1]);
// ydim16=i; // ydim16=i;
// // printmessage16(""); // // printmessage16("");
// showframe(1); // showframe(1);
keystatus[KEYSC_ESC] = keystatus[KEYSC_Q] = keystatus[KEYSC_F1] = 0; keystatus[KEYSC_ESC] = keystatus[KEYSC_Q] = keystatus[KEYSC_F1] = 0;
} }
@ -2040,7 +2058,7 @@ static void SoundDisplay()
static int32_t cursnd=0, curofs=0; static int32_t cursnd=0, curofs=0;
char disptext[SOUND_NUMDISPLINES][80]; char disptext[SOUND_NUMDISPLINES][80];
// SoundToggle = 1; // SoundToggle = 1;
while (keystatus[KEYSC_ESC]==0 && keystatus[KEYSC_Q]==0 && keystatus[KEYSC_F2]==0 while (keystatus[KEYSC_ESC]==0 && keystatus[KEYSC_Q]==0 && keystatus[KEYSC_F2]==0
&& keystatus[buildkeys[BK_MODE2D_3D]]==0) // quickjump to 3d mode && keystatus[buildkeys[BK_MODE2D_3D]]==0) // quickjump to 3d mode
@ -2234,16 +2252,16 @@ static void SoundDisplay()
} }
overridepm16y = -1; overridepm16y = -1;
// i=ydim16; // i=ydim16;
// ydim16=ydim; // ydim16=ydim;
// drawline16(0,ydim-STATUS2DSIZ,xdim-1,ydim-STATUS2DSIZ,editorcolors[1]); // drawline16(0,ydim-STATUS2DSIZ,xdim-1,ydim-STATUS2DSIZ,editorcolors[1]);
// ydim16=i; // ydim16=i;
// // printmessage16(""); // // printmessage16("");
// showframe(1); // showframe(1);
FX_StopAllSounds(); FX_StopAllSounds();
S_ClearSoundLocks(); S_ClearSoundLocks();
// SoundToggle = 0; // SoundToggle = 0;
keystatus[KEYSC_ESC] = keystatus[KEYSC_Q] = keystatus[KEYSC_F2] = 0; keystatus[KEYSC_ESC] = keystatus[KEYSC_Q] = keystatus[KEYSC_F2] = 0;
} }
@ -2727,7 +2745,7 @@ static void ReadPaletteTable()
return; return;
} }
} }
// initprintf("Loading palette lookups... "); // initprintf("Loading palette lookups... ");
kread(fp,&num_tables,1); kread(fp,&num_tables,1);
for (j=0; j<num_tables; j++) for (j=0; j<num_tables; j++)
{ {
@ -2749,7 +2767,7 @@ static void ReadPaletteTable()
kread(fp,REALMSpalette,768); kread(fp,REALMSpalette,768);
kread(fp,BOSS1palette,768); kread(fp,BOSS1palette,768);
kclose(fp); kclose(fp);
// initprintf("success.\n"); // initprintf("success.\n");
}// end ReadPaletteTable }// end ReadPaletteTable
static void ReadGamePalette() static void ReadGamePalette()
@ -2763,10 +2781,10 @@ static void ReadGamePalette()
wm_msgbox(tempbuf,"palette.dat not found"); wm_msgbox(tempbuf,"palette.dat not found");
exit(0); exit(0);
} }
// initprintf("Loading game palette... "); // initprintf("Loading game palette... ");
kread(fp,GAMEpalette,768); kread(fp,GAMEpalette,768);
kclose(fp); kclose(fp);
// initprintf("success.\n"); // initprintf("success.\n");
ReadPaletteTable(); ReadPaletteTable();
} }
@ -2939,8 +2957,8 @@ static int32_t m32gettile(int32_t idInitialTile)
int32_t scrollmode; int32_t scrollmode;
int32_t mousedx, mousedy, mtile, omousex=searchx, omousey=searchy, moffset=0; int32_t mousedx, mousedy, mtile, omousex=searchx, omousey=searchy, moffset=0;
// Enable following line for testing. I couldn't work out how to change vidmode on the fly // Enable following line for testing. I couldn't work out how to change vidmode on the fly
// s_Zoom = NUM_ZOOMS - 1; // s_Zoom = NUM_ZOOMS - 1;
if (idInitialTile < 0) if (idInitialTile < 0)
{ {
@ -4124,7 +4142,7 @@ ENDFOR1:
printmessage256(0, 9, buffer); printmessage256(0, 9, buffer);
showframe(1); showframe(1);
// --- // ---
sp = &sprite[curspr]; sp = &sprite[curspr];
if (!doingspace) if (!doingspace)
{ {
@ -4331,7 +4349,7 @@ static void Keys3d(void)
drawtileinfo("Clipboard",3,124,temppicnum,tempshade,temppal,tempcstat,templotag,temphitag,tempextra); drawtileinfo("Clipboard",3,124,temppicnum,tempshade,temppal,tempcstat,templotag,temphitag,tempextra);
}// end if usedcount }// end if usedcount
// if (infobox&1) // if (infobox&1)
{ {
char lines[8][64]; char lines[8][64];
int32_t dax, day, dist, height1=0,height2=0,height3=0, num=0; int32_t dax, day, dist, height1=0,height2=0,height3=0, num=0;
@ -4527,7 +4545,7 @@ static void Keys3d(void)
keystatus[KEYSC_F4] = 0; keystatus[KEYSC_F4] = 0;
} }
// PK // PK
if (keystatus[KEYSC_F5]) if (keystatus[KEYSC_F5])
{ {
unrealedlook = !unrealedlook; unrealedlook = !unrealedlook;
@ -4798,8 +4816,8 @@ static void Keys3d(void)
sector[searchsector].extra = getnumber256(buffer,(int32_t)sector[searchsector].extra,65536L,1); sector[searchsector].extra = getnumber256(buffer,(int32_t)sector[searchsector].extra,65536L,1);
break; break;
case 3: case 3:
// strcpy(buffer,"Sprite extra: "); // strcpy(buffer,"Sprite extra: ");
// sprite[searchwall].extra = getnumber256(buffer,(int32_t)sprite[searchwall].extra,65536L,1); // sprite[searchwall].extra = getnumber256(buffer,(int32_t)sprite[searchwall].extra,65536L,1);
getnumberptr256("Sprite extra: ",&sprite[searchwall].extra,sizeof(sprite[searchwall].extra),1024,1,NULL); getnumberptr256("Sprite extra: ",&sprite[searchwall].extra,sizeof(sprite[searchwall].extra),1024,1,NULL);
break; break;
} }
@ -4966,13 +4984,13 @@ static void Keys3d(void)
if (!unrealedlook && (bstatus&4)) mlook = 2; if (!unrealedlook && (bstatus&4)) mlook = 2;
// if (bstatus&4) // if (bstatus&4)
if ((bstatus&(16|32) && !(bstatus&(1|2|4))) || keystatus[KEYSC_gMINUS] || keystatus[KEYSC_gPLUS]) // PK: no btn: wheel changes shade if ((bstatus&(16|32) && !(bstatus&(1|2|4))) || keystatus[KEYSC_gMINUS] || keystatus[KEYSC_gPLUS]) // PK: no btn: wheel changes shade
{ {
// if (bstatus&1) // if (bstatus&1)
// { // {
// mlook = 2; // mlook = 2;
// } // }
if (bstatus&32 || keystatus[KEYSC_gMINUS]) // - if (bstatus&32 || keystatus[KEYSC_gMINUS]) // -
{ {
keystatus[KEYSC_gMINUS]=0; keystatus[KEYSC_gMINUS]=0;
@ -5169,7 +5187,7 @@ static void Keys3d(void)
} }
} }
// if ((keystatus[KEYSC_DASH]|keystatus[KEYSC_EQUAL]|((bstatus&(16|32)) && !(bstatus&2))) > 0) // mousewheel, -, and +, cycle picnum // if ((keystatus[KEYSC_DASH]|keystatus[KEYSC_EQUAL]|((bstatus&(16|32)) && !(bstatus&2))) > 0) // mousewheel, -, and +, cycle picnum
if (keystatus[KEYSC_DASH] | keystatus[KEYSC_EQUAL] | (bstatus&(16|32) && (bstatus&1) && !(bstatus&2))) // PK: lmb only & mousewheel, -, and +, cycle picnum if (keystatus[KEYSC_DASH] | keystatus[KEYSC_EQUAL] | (bstatus&(16|32) && (bstatus&1) && !(bstatus&2))) // PK: lmb only & mousewheel, -, and +, cycle picnum
{ {
@ -5795,7 +5813,7 @@ static void Keys3d(void)
if (bstatus&4 && !(bstatus&(1|2)) && !unrealedlook) //PK if (bstatus&4 && !(bstatus&(1|2)) && !unrealedlook) //PK
{ {
Bsprintf(tempbuf,"VIEW"); Bsprintf(tempbuf,"VIEW");
// else Bsprintf(tempbuf,"SHADE"); // else Bsprintf(tempbuf,"SHADE");
} }
else if (bstatus&2 && !(bstatus&1)) else if (bstatus&2 && !(bstatus&1))
Bsprintf(tempbuf,"Z"); Bsprintf(tempbuf,"Z");
@ -7625,7 +7643,7 @@ static void Keys2d(void)
if (keystatus[KEYSC_F1] || (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_TILDE])) //F1 or ' ~ if (keystatus[KEYSC_F1] || (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_TILDE])) //F1 or ' ~
{ {
keystatus[KEYSC_F1]=0; keystatus[KEYSC_F1]=0;
// PK_ // PK_
if (numhelppages>0) IntegratedHelp(); if (numhelppages>0) IntegratedHelp();
else printmessage16("m32help.hlp invalid or not found!"); else printmessage16("m32help.hlp invalid or not found!");
} }
@ -8548,7 +8566,7 @@ int32_t ExtPreInit(int32_t argc,const char **argv)
OSD_SetLogFile("mapster32.log"); OSD_SetLogFile("mapster32.log");
OSD_SetVersionString("Mapster32"VERSION,0,2); OSD_SetVersionString("Mapster32"VERSION,0,2);
initprintf("Mapster32"VERSION BUILDDATE"\n"); initprintf("Mapster32"VERSION BUILDDATE"\n");
// initprintf("Copyright (c) 2008 EDuke32 team\n"); // initprintf("Copyright (c) 2008 EDuke32 team\n");
G_CheckCommandLine(argc,argv); G_CheckCommandLine(argc,argv);
@ -9184,7 +9202,7 @@ int32_t parsetilegroups(scriptfile *script)
if (scriptfile_getsymbol(script,&i)) break; if (scriptfile_getsymbol(script,&i)) break;
if (i >= 0 && i < MAXTILES && s_TileGroups[tile_groups].nIds < MAX_TILE_GROUP_ENTRIES) if (i >= 0 && i < MAXTILES && s_TileGroups[tile_groups].nIds < MAX_TILE_GROUP_ENTRIES)
s_TileGroups[tile_groups].pIds[s_TileGroups[tile_groups].nIds++] = i; s_TileGroups[tile_groups].pIds[s_TileGroups[tile_groups].nIds++] = i;
// OSD_Printf("added tile %d to group %d\n",i,g); // OSD_Printf("added tile %d to group %d\n",i,g);
break; break;
} }
case T_TILERANGE: case T_TILERANGE:
@ -9196,7 +9214,7 @@ int32_t parsetilegroups(scriptfile *script)
while (s_TileGroups[tile_groups].nIds < MAX_TILE_GROUP_ENTRIES && i <= j) while (s_TileGroups[tile_groups].nIds < MAX_TILE_GROUP_ENTRIES && i <= j)
{ {
s_TileGroups[tile_groups].pIds[s_TileGroups[tile_groups].nIds++] = i++; s_TileGroups[tile_groups].pIds[s_TileGroups[tile_groups].nIds++] = i++;
// OSD_Printf("added tile %d to group %d\n",i,g); // OSD_Printf("added tile %d to group %d\n",i,g);
} }
break; break;
} }
@ -9835,7 +9853,7 @@ extern int32_t graphicsmode;
void ExtPreCheckKeys(void) // just before drawrooms void ExtPreCheckKeys(void) // just before drawrooms
{ {
int32_t i = 0; int32_t i = 0, ii;
int32_t radius, xp1, yp1; int32_t radius, xp1, yp1;
int32_t col; int32_t col;
int32_t picnum, frames; int32_t picnum, frames;
@ -9912,14 +9930,15 @@ void ExtPreCheckKeys(void) // just before drawrooms
} }
begindrawing(); begindrawing();
// if (cursectornum >= 0) // if (cursectornum >= 0)
// fillsector(cursectornum, 31); // fillsector(cursectornum, 31);
if (graphicsmode && zoom >= 256) if (graphicsmode && zoom >= 256)
{ {
for (i=0; i<numsprites; i++) for (i=ii=0; i<MAXSPRITES && ii < numsprites; i++)
{ {
if ((sprite[i].cstat & 48) != 0 || sprite[i].statnum == MAXSTATUS) continue; if ((sprite[i].cstat & 48) != 0 || sprite[i].statnum == MAXSTATUS) continue;
ii++;
picnum = sprite[i].picnum; picnum = sprite[i].picnum;
ang = flags = frames = shade = 0; ang = flags = frames = shade = 0;
@ -10042,7 +10061,7 @@ void ExtPreCheckKeys(void) // just before drawrooms
drawlinepat = 0xf0f0f0f0; drawlinepat = 0xf0f0f0f0;
drawcircle16(halfxdim16+xp1, midydim16+yp1, radius, editorcolors[(int32_t)col]); drawcircle16(halfxdim16+xp1, midydim16+yp1, radius, editorcolors[(int32_t)col]);
drawlinepat = 0xffffffff; drawlinepat = 0xffffffff;
// radius = mulscale15(sprite[i].hitag,zoom); // radius = mulscale15(sprite[i].hitag,zoom);
// drawcircle16(halfxdim16+xp1, midydim16+yp1, radius, col); // drawcircle16(halfxdim16+xp1, midydim16+yp1, radius, col);
} }
@ -10084,7 +10103,7 @@ void ExtAnalyzeSprites(void)
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].horiz = SH; gamelights[gamelightcount&(PR_MAXLIGHTS-1)].horiz = SH;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].minshade = sprite[i].xoffset; gamelights[gamelightcount&(PR_MAXLIGHTS-1)].minshade = sprite[i].xoffset;
gamelights[gamelightcount&(PR_MAXLIGHTS-1)].maxshade = sprite[i].yoffset; gamelights[gamelightcount&(PR_MAXLIGHTS-1)].maxshade = sprite[i].yoffset;
// gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = SS; // gamelights[gamelightcount&(PR_MAXLIGHTS-1)].priority = SS;
if (CS & 2) if (CS & 2)
{ {
@ -10276,11 +10295,10 @@ static void Keys2d3d(void)
if (mapstate == NULL) if (mapstate == NULL)
{ {
mapstate = (mapundo_t *)Bcalloc(1, sizeof(mapundo_t)); // map_revision = 0;
map_revision = 0;
create_map_snapshot(); // initial map state create_map_snapshot(); // initial map state
Bfree(mapstate->next); // Bfree(mapstate->next);
mapstate = mapstate->prev; // mapstate = mapstate->prev;
} }
if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_A]) // ' a if (keystatus[KEYSC_QUOTE] && keystatus[KEYSC_A]) // ' a
@ -10355,11 +10373,11 @@ static void Keys2d3d(void)
lastsave=totalclock; lastsave=totalclock;
highlightcnt = -1; highlightcnt = -1;
// sectorhighlightstat = -1; // sectorhighlightstat = -1;
// newnumwalls = -1; // newnumwalls = -1;
// joinsector[0] = -1; // joinsector[0] = -1;
// circlewall = -1; // circlewall = -1;
// circlepoints = 7; // circlepoints = 7;
for (i=MAXSECTORS-1; i>=0; i--) sector[i].extra = -1; for (i=MAXSECTORS-1; i>=0; i--) sector[i].extra = -1;
for (i=MAXWALLS-1; i>=0; i--) wall[i].extra = -1; for (i=MAXWALLS-1; i>=0; i--) wall[i].extra = -1;
@ -10425,7 +10443,7 @@ static void Keys2d3d(void)
if (getmessageleng > 0) if (getmessageleng > 0)
{ {
// charsperline = 64; // charsperline = 64;
//if (dimensionmode[snum] == 2) charsperline = 80; //if (dimensionmode[snum] == 2) charsperline = 80;
/* if (qsetmode == 200) /* if (qsetmode == 200)
{ {
@ -10539,14 +10557,15 @@ void ExtCheckKeys(void)
if (asksave == 1 && (bstatus + lastbstatus) == 0 && mapstate) if (asksave == 1 && (bstatus + lastbstatus) == 0 && mapstate)
{ {
// message("Saved undo rev %d",map_revision); // message("Saved undo rev %d",map_revision);
create_map_snapshot(); create_map_snapshot();
asksave = 2; asksave++;
} }
else if (asksave == 2) asksave++;
if ((totalclock > autosavetimer) && (autosave)) if ((totalclock > autosavetimer) && (autosave))
{ {
if (asksave == 2) if (asksave == 3)
{ {
fixspritesectors(); //Do this before saving! fixspritesectors(); //Do this before saving!
// updatesector(startposx,startposy,&startsectnum); // updatesector(startposx,startposy,&startsectnum);
@ -10554,7 +10573,7 @@ void ExtCheckKeys(void)
saveboard("autosave.map",&startposx,&startposy,&startposz,&startang,&startsectnum); saveboard("autosave.map",&startposx,&startposy,&startposz,&startang,&startsectnum);
ExtSaveMap("autosave.map"); ExtSaveMap("autosave.map");
message("Board autosaved to AUTOSAVE.MAP"); message("Board autosaved to AUTOSAVE.MAP");
asksave = 3; asksave = 4;
} }
autosavetimer = totalclock+120*autosave; autosavetimer = totalclock+120*autosave;
} }
@ -11125,7 +11144,7 @@ static void EditSpriteData(int16_t spritenum)
int32_t xpos = 8, ypos = ydim-STATUS2DSIZ+48; int32_t xpos = 8, ypos = ydim-STATUS2DSIZ+48;
disptext[dispwidth] = 0; disptext[dispwidth] = 0;
// clearmidstatbar16(); // clearmidstatbar16();
col = whitecol-16; col = whitecol-16;
@ -11557,8 +11576,8 @@ static void GenSearchSprite()
} }
for (k=0; k<80; k++) disptext[k] = 0; for (k=0; k<80; k++) disptext[k] = 0;
// disptext[dispwidth[col]] = 0; // disptext[dispwidth[col]] = 0;
// showspritedata(spritenum); // showspritedata(spritenum);
wallsprite = 2; wallsprite = 2;
while (keystatus[KEYSC_ESC] == 0) while (keystatus[KEYSC_ESC] == 0)
@ -11653,10 +11672,10 @@ static void GenSearchSprite()
enddrawing(); enddrawing();
showframe(1); showframe(1);
} }
// begindrawing(); // begindrawing();
printext16(xpos[col],ypos+row*8,editorcolors[11],editorcolors[0],disptext,0); printext16(xpos[col],ypos+row*8,editorcolors[11],editorcolors[0],disptext,0);
printmessage16("Search sprite"); printmessage16("Search sprite");
// enddrawing(); // enddrawing();
showframe(1); showframe(1);
keystatus[KEYSC_ESC] = 0; keystatus[KEYSC_ESC] = 0;
} }
@ -11685,24 +11704,24 @@ static void FuncMenuOpts(void)
int32_t y = MENU_BASE_Y+16; int32_t y = MENU_BASE_Y+16;
int32_t i = 0; int32_t i = 0;
// int32_t x2 = 0; // int32_t x2 = 0;
// static int32_t x2_max = 0; // static int32_t x2_max = 0;
int32_t numopts = (sizeof(FuncMenuStrings)/sizeof(FuncMenuStrings[0])); int32_t numopts = (sizeof(FuncMenuStrings)/sizeof(FuncMenuStrings[0]));
do do
{ {
// x2 = // x2 =
printext16(x,y,editorcolors[11],editorcolors[0],FuncMenuStrings[i],0); printext16(x,y,editorcolors[11],editorcolors[0],FuncMenuStrings[i],0);
// if (x2 > x2_max) x2_max = x2; // if (x2 > x2_max) x2_max = x2;
y += MENU_Y_SPACING; y += MENU_Y_SPACING;
} }
while (++i < numopts); while (++i < numopts);
// drawline16(x-1,y,x2_max+1,y,1); // drawline16(x-1,y,x2_max+1,y,1);
// drawline16(x-1,MENU_BASE_Y-4,x-1,y,1); // drawline16(x-1,MENU_BASE_Y-4,x-1,y,1);
// x2 = // x2 =
printext16(x,MENU_BASE_Y,editorcolors[11],-1,"Special functions",0); printext16(x,MENU_BASE_Y,editorcolors[11],-1,"Special functions",0);
// drawline16(x-1,MENU_BASE_Y-4,x2+1,MENU_BASE_Y-4,1); // drawline16(x-1,MENU_BASE_Y-4,x2+1,MENU_BASE_Y-4,1);
// drawline16(x2_max+1,MENU_BASE_Y+16-4,x2_max+1,y-1,1); // drawline16(x2_max+1,MENU_BASE_Y+16-4,x2_max+1,y-1,1);
//drawline16(x2+1,MENU_BASE_Y+16-1,x2_max+1,MENU_BASE_Y+16-1,1); //drawline16(x2+1,MENU_BASE_Y+16-1,x2_max+1,MENU_BASE_Y+16-1,1);
} }
@ -11714,7 +11733,7 @@ static void FuncMenu(void)
int32_t xpos = 8, ypos = MENU_BASE_Y+16; int32_t xpos = 8, ypos = MENU_BASE_Y+16;
disptext[dispwidth] = 0; disptext[dispwidth] = 0;
// clearmidstatbar16(); // clearmidstatbar16();
col = whitecol-16; col = whitecol-16;

View file

@ -864,6 +864,7 @@ enum SpriteFlags_t {
SPRITE_BADGUY = 32, SPRITE_BADGUY = 32,
SPRITE_NOPAL = 64, SPRITE_NOPAL = 64,
SPRITE_NOEVENTCODE = 128, SPRITE_NOEVENTCODE = 128,
SPRITE_NOLIGHT = 256,
}; };
extern int16_t SpriteCacheList[MAXTILES][3]; extern int16_t SpriteCacheList[MAXTILES][3];

View file

@ -271,7 +271,7 @@ extern inline void G_AddGameLight(int32_t radius, int32_t srcsprite, int32_t zof
extern void se40code(int32_t x,int32_t y,int32_t z,int32_t a,int32_t h, int32_t smoothratio); extern void se40code(int32_t x,int32_t y,int32_t z,int32_t a,int32_t h, int32_t smoothratio);
extern void G_FreeMapState(int32_t mapnum); extern void G_FreeMapState(int32_t mapnum);
extern void G_FindLevelForFilename(const char *fn, char *volume, char *level); extern int32_t G_FindLevelForFilename(const char *fn);
extern void G_GetCrosshairColor(void); extern void G_GetCrosshairColor(void);
extern void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b); extern void G_SetCrosshairColor(int32_t r, int32_t g, int32_t b);

View file

@ -742,7 +742,7 @@ void P_ResetWeapons(int32_t snum)
p->curr_weapon = PISTOL_WEAPON; p->curr_weapon = PISTOL_WEAPON;
p->gotweapon[PISTOL_WEAPON] = 1; p->gotweapon[PISTOL_WEAPON] = 1;
p->gotweapon[KNEE_WEAPON] = 1; p->gotweapon[KNEE_WEAPON] = 1;
p->ammo_amount[PISTOL_WEAPON] = 48; p->ammo_amount[PISTOL_WEAPON] = min(p->max_ammo_amount[PISTOL_WEAPON], 48);
p->gotweapon[HANDREMOTE_WEAPON] = 1; p->gotweapon[HANDREMOTE_WEAPON] = 1;
p->last_weapon = -1; p->last_weapon = -1;
@ -1282,7 +1282,7 @@ void G_NewGame(int32_t vn,int32_t ln,int32_t sk)
{ {
p->curr_weapon = i; p->curr_weapon = i;
p->gotweapon[i] = 1; p->gotweapon[i] = 1;
p->ammo_amount[i] = 48; p->ammo_amount[i] = min(p->max_ammo_amount[i], 48);
} }
else if (aplWeaponWorksLike[i][0]==KNEE_WEAPON) else if (aplWeaponWorksLike[i][0]==KNEE_WEAPON)
p->gotweapon[i] = 1; p->gotweapon[i] = 1;
@ -1625,19 +1625,20 @@ void Net_ResetPrediction(void)
extern int32_t voting, vote_map, vote_episode; extern int32_t voting, vote_map, vote_episode;
void G_FindLevelForFilename(const char *fn, char *volume, char *level) int32_t G_FindLevelForFilename(const char *fn)
{ {
for (*volume=0; *volume<MAXVOLUMES; (*volume)++) int32_t volume, level;
for (volume=0; volume<MAXVOLUMES; volume++)
{ {
for (*level=0; *level<MAXLEVELS; (*level)++) for (level=0; level<MAXLEVELS; level++)
{ {
if (MapInfo[(*volume*MAXLEVELS)+*level].filename != NULL) if (MapInfo[(volume*MAXLEVELS)+level].filename != NULL)
if (!Bstrcasecmp(fn, MapInfo[(*volume*MAXLEVELS)+*level].filename)) if (!Bstrcasecmp(fn, MapInfo[(volume*MAXLEVELS)+level].filename))
break; return ((volume * MAXLEVELS) + level);
} }
if (*level != MAXLEVELS)
break;
} }
return MAXLEVELS;
} }
int32_t G_EnterLevel(int32_t g) int32_t G_EnterLevel(int32_t g)
@ -1669,14 +1670,17 @@ int32_t G_EnterLevel(int32_t g)
if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0) if (boardfilename[0] != 0 && ud.m_level_number == 7 && ud.m_volume_number == 0)
{ {
char volume, level; int32_t volume, level;
Bcorrectfilename(boardfilename,0); Bcorrectfilename(boardfilename,0);
G_FindLevelForFilename(boardfilename,&volume,&level); volume = level = G_FindLevelForFilename(boardfilename);
if (level != MAXLEVELS) if (level != MAXLEVELS)
{ {
level &= MAXLEVELS-1;
volume = (volume - level) / MAXLEVELS;
ud.level_number = ud.m_level_number = level; ud.level_number = ud.m_level_number = level;
ud.volume_number = ud.m_volume_number = volume; ud.volume_number = ud.m_volume_number = volume;
boardfilename[0] = 0; boardfilename[0] = 0;