Skip to content

Commit

Permalink
Added option for blockmap bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
JadingTsunami committed Sep 19, 2023
1 parent 56274ce commit 439c033
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This is my own personal fork of PrBoom-Plus. It contains quality-of-play upgrade
* Option to organize save games based on loaded content (WAD, DEH, etc.)
* Note the order in which content is loaded matters
* Option to skip QuickSave/QuickLoad confirmation prompt
* Option to fix the Blockmap bug (uses blockmap bug fix from Terry Hearst, adapted from similar PR for Woof)
* Note-taking console command
* Jot down quick notes while playtesting. Notes go into a dated text file in the current working directory.
* Each note lists the time, all loaded WAD files, player position, and an optional user-supplied message on the console.
Expand Down
4 changes: 4 additions & 0 deletions prboom2/src/doomstat.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ int /*comperr[COMPERR_NUM], */default_comperr[COMPERR_NUM];
// [FG] allow MBF sky transfers in all complevels
int comp_skytransfers;

// Fix blockmap bug where objects don't extend into nearby
// blockmap chunks despite their bounding box being inside
int comp_fix_blockmap;

// v1.1-like pitched sounds
int pitched_sounds; // killough

Expand Down
2 changes: 2 additions & 0 deletions prboom2/src/doomstat.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ extern int /*comperr[COMPERR_NUM], */default_comperr[COMPERR_NUM];
// [FG] allow MBF sky transfers in all complevels
extern int comp_skytransfers;

extern int comp_fix_blockmap;

// -------------------------------------------
// Language.
extern Language_t language;
Expand Down
6 changes: 6 additions & 0 deletions prboom2/src/m_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3334,6 +3334,7 @@ setup_menu_t gen_settings_prboomx[] = { // prboomX General Settings
{"Enhanced allmap power up" ,S_YESNO ,m_null,G_X,G_Y+3*8, {"map_enhanced_allmap"}},
{"Skip QuickSave/Load confirmation" ,S_YESNO ,m_null,G_X,G_Y+4*8, {"skip_quicksaveload_confirmation"}},
{"Enable Time Warping" ,S_YESNO ,m_null,G_X,G_Y+5*8, {"enable_time_warping"}},
{"Fix Blockmap bug" ,S_YESNO ,m_null,G_X,G_Y+6*8, {"comp_fix_blockmap"}},

{"<- PREV",S_SKIP|S_PREV, m_null,KB_PREV, KB_Y+20*8, {gen_settings1}},
{"NEXT ->",S_SKIP|S_NEXT,m_null,KB_NEXT,KB_Y+20*8, {gen_settings2}},
Expand Down Expand Up @@ -3688,6 +3689,7 @@ enum
compat_maxhealth,
compat_translucency,
compat_skytransfers,
compat_fixblockmap
};

setup_menu_t comp_settings1[] = // Compatibility Settings screen #1
Expand Down Expand Up @@ -3799,6 +3801,10 @@ setup_menu_t comp_settings3[] = // Compatibility Settings screen #3
// [FG]
{"allow MBF sky transfers in all complevels", S_YESNO, m_null, C_X,
C_Y + compat_skytransfers * COMP_SPC, {"comp_skytransfers"}},

{"fix blockmap bug", S_YESNO, m_null, C_X,
C_Y + compat_fixblockmap * COMP_SPC, {"comp_fix_blockmap"}},

{"<- PREV", S_SKIP|S_PREV, m_null, KB_PREV, C_Y+C_NEXTPREV,{comp_settings2}},
{0,S_SKIP|S_END,m_null}
};
Expand Down
1 change: 1 addition & 0 deletions prboom2/src/m_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,7 @@ default_t defaults[] =
{"comp_translucency",{&default_comp[comp_translucency]},{0},0,1,def_bool,ss_comp,&comp[comp_translucency]},
// [FG] allow MBF sky transfers in all complevels
{"comp_skytransfers",{&comp_skytransfers},{0},0,1,def_bool,ss_comp},
{"comp_fix_blockmap",{&comp_fix_blockmap},{0},0,1,def_bool,ss_comp},

{"Sound settings",{NULL},{0},UL,UL,def_none,ss_none},
{"snd_pcspeaker",{&snd_pcspeaker},{0}, 0, 1, def_bool,ss_none},
Expand Down
114 changes: 114 additions & 0 deletions prboom2/src/p_maputl.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ dboolean P_BlockLinesIterator(int x, int y, dboolean func(line_t*))
// P_BlockThingsIterator
//
// killough 5/3/98: reformatted, cleaned up
extern dboolean PIT_RadiusAttack(mobj_t* thing);
extern dboolean PIT_ChangeSector(mobj_t* thing);

dboolean P_BlockThingsIterator(int x, int y, dboolean func(mobj_t*))
{
Expand All @@ -409,6 +411,118 @@ dboolean P_BlockThingsIterator(int x, int y, dboolean func(mobj_t*))
for (mobj = blocklinks[y*bmapwidth+x]; mobj; mobj = mobj->bnext)
if (!func(mobj))
return false;

// Blockmap bug fix by Terry Hearst
// Adapted from Woof, PR:
// https://github.com/fabiangreffrath/crispy-doom/pull/723
// Adds other mobjs from surrounding blocks that overlap this one
if (comp_fix_blockmap &&
!netgame &&
!demorecording &&
!demoplayback) {

if (x<0 || y<0 || x>=bmapwidth || y>=bmapheight)
return true;

// Don't do for explosions and crashers
if (func == PIT_RadiusAttack || func == PIT_ChangeSector)
return true;

// Unwrapped for least number of bounding box checks
// (-1, -1)
if (x > 0 && y > 0)
{
for (mobj = blocklinks[(y-1)*bmapwidth+(x-1)]; mobj; mobj = mobj->bnext)
{
const int xx = (mobj->x + mobj->radius - bmaporgx)>>MAPBLOCKSHIFT;
const int yy = (mobj->y + mobj->radius - bmaporgy)>>MAPBLOCKSHIFT;
if (xx == x && yy == y)
if (!func(mobj))
return false;
}
}
// (0, -1)
if (y > 0)
{
for (mobj = blocklinks[(y-1)*bmapwidth+x]; mobj; mobj = mobj->bnext)
{
const int yy = (mobj->y + mobj->radius - bmaporgy)>>MAPBLOCKSHIFT;
if (yy == y)
if (!func(mobj))
return false;
}
}
// (1, -1)
if (x < (bmapwidth-1) && y > 0)
{
for (mobj = blocklinks[(y-1)*bmapwidth+(x+1)]; mobj; mobj = mobj->bnext)
{
const int xx = (mobj->x - mobj->radius - bmaporgx)>>MAPBLOCKSHIFT;
const int yy = (mobj->y + mobj->radius - bmaporgy)>>MAPBLOCKSHIFT;
if (xx == x && yy == y)
if (!func(mobj))
return false;
}
}
// (1, 0)
if (x < (bmapwidth-1))
{
for (mobj = blocklinks[y*bmapwidth+(x+1)]; mobj; mobj = mobj->bnext)
{
const int xx = (mobj->x - mobj->radius - bmaporgx)>>MAPBLOCKSHIFT;
if (xx == x)
if (!func(mobj))
return false;
}
}
// (1, 1)
if (x < (bmapwidth-1) && y < (bmapheight-1))
{
for (mobj = blocklinks[(y+1)*bmapwidth+(x+1)]; mobj; mobj = mobj->bnext)
{
const int xx = (mobj->x - mobj->radius - bmaporgx)>>MAPBLOCKSHIFT;
const int yy = (mobj->y - mobj->radius - bmaporgy)>>MAPBLOCKSHIFT;
if (xx == x && yy == y)
if (!func( mobj ) )
return false;
}
}
// (0, 1)
if (y < (bmapheight-1))
{
for (mobj = blocklinks[(y+1)*bmapwidth+x]; mobj; mobj = mobj->bnext)
{
const int yy = (mobj->y - mobj->radius - bmaporgy)>>MAPBLOCKSHIFT;
if (yy == y)
if (!func(mobj))
return false;
}
}
// (-1, 1)
if (x > 0 && y < (bmapheight-1))
{
for (mobj = blocklinks[(y+1)*bmapwidth+(x-1)]; mobj; mobj = mobj->bnext)
{
const int xx = (mobj->x + mobj->radius - bmaporgx)>>MAPBLOCKSHIFT;
const int yy = (mobj->y - mobj->radius - bmaporgy)>>MAPBLOCKSHIFT;
if (xx == x && yy == y)
if (!func(mobj))
return false;
}
}
// (-1, 0)
if (x > 0)
{
for (mobj = blocklinks[y*bmapwidth+(x-1)]; mobj; mobj = mobj->bnext)
{
const int xx = (mobj->x + mobj->radius - bmaporgx)>>MAPBLOCKSHIFT;
if (xx == x)
if (!func(mobj))
return false;
}
}
}

return true;
}

Expand Down

0 comments on commit 439c033

Please sign in to comment.