diff --git a/doomsday/plugins/common/include/p_mapspec.h b/doomsday/plugins/common/include/p_mapspec.h index 21c7542ee6..aa4b35bc65 100644 --- a/doomsday/plugins/common/include/p_mapspec.h +++ b/doomsday/plugins/common/include/p_mapspec.h @@ -44,10 +44,10 @@ iterlist_t *P_GetSectorIterListForTag(int tag, boolean createNewList); sector_t* P_GetNextSector(linedef_t *line, sector_t *sec); -sector_t* P_FindSectorSurroundingLowestFloor(sector_t *sec, float *val); -sector_t* P_FindSectorSurroundingHighestFloor(sector_t *sec, float *val); -sector_t* P_FindSectorSurroundingLowestCeiling(sector_t *sec, float *val); -sector_t* P_FindSectorSurroundingHighestCeiling(sector_t *sec, float *val); +sector_t* P_FindSectorSurroundingLowestFloor(sector_t *sec, float max, float *val); +sector_t* P_FindSectorSurroundingHighestFloor(sector_t *sec, float min, float *val); +sector_t* P_FindSectorSurroundingLowestCeiling(sector_t *sec, float max, float *val); +sector_t* P_FindSectorSurroundingHighestCeiling(sector_t *sec, float min, float *val); sector_t* P_FindSectorSurroundingLowestLight(sector_t *sector, float *val); sector_t* P_FindSectorSurroundingHighestLight(sector_t *sector, float *val); diff --git a/doomsday/plugins/common/src/p_ceiling.c b/doomsday/plugins/common/src/p_ceiling.c index 72d3052109..5d2b08f2a8 100644 --- a/doomsday/plugins/common/src/p_ceiling.c +++ b/doomsday/plugins/common/src/p_ceiling.c @@ -347,7 +347,7 @@ static int EV_DoCeiling2(int tag, float basespeed, ceilingtype_e type) break; case CT_RAISETOHIGHEST: - P_FindSectorSurroundingHighestCeiling(sec, &ceiling->topHeight); + P_FindSectorSurroundingHighestCeiling(sec, 0, &ceiling->topHeight); #if __JDOOM64__ ceiling->topHeight -= 8; // jd64 #endif @@ -367,7 +367,7 @@ static int EV_DoCeiling2(int tag, float basespeed, ceilingtype_e type) if(bitmipR > 0) { - P_FindSectorSurroundingHighestCeiling(sec, &ceiling->topHeight); + P_FindSectorSurroundingHighestCeiling(sec, 0, &ceiling->topHeight); ceiling->state = CS_UP; ceiling->speed *= bitmipL; ceiling->topHeight -= bitmipR; diff --git a/doomsday/plugins/common/src/p_door.c b/doomsday/plugins/common/src/p_door.c index ad661be0c9..95fb700947 100644 --- a/doomsday/plugins/common/src/p_door.c +++ b/doomsday/plugins/common/src/p_door.c @@ -356,7 +356,7 @@ static int EV_DoDoor2(int tag, float speed, int topwait, doortype_e type) { #if __JDOOM__ || __JDOOM64__ case DT_BLAZECLOSE: - P_FindSectorSurroundingLowestCeiling(sec, &door->topHeight); + P_FindSectorSurroundingLowestCeiling(sec, (float) MAXINT, &door->topHeight); door->topHeight -= 4; door->state = DS_DOWN; door->speed *= 4; @@ -364,7 +364,7 @@ static int EV_DoDoor2(int tag, float speed, int topwait, doortype_e type) break; #endif case DT_CLOSE: - P_FindSectorSurroundingLowestCeiling(sec, &door->topHeight); + P_FindSectorSurroundingLowestCeiling(sec, (float) MAXINT, &door->topHeight); door->topHeight -= 4; door->state = DS_DOWN; #if !__JHEXEN__ @@ -386,7 +386,7 @@ static int EV_DoDoor2(int tag, float speed, int topwait, doortype_e type) #if !__JHEXEN__ case DT_BLAZEOPEN: door->state = DS_UP; - P_FindSectorSurroundingLowestCeiling(sec, &door->topHeight); + P_FindSectorSurroundingLowestCeiling(sec, (float) MAXINT, &door->topHeight); door->topHeight -= 4; # if __JHERETIC__ door->speed *= 3; @@ -401,7 +401,7 @@ static int EV_DoDoor2(int tag, float speed, int topwait, doortype_e type) case DT_NORMAL: case DT_OPEN: door->state = DS_UP; - P_FindSectorSurroundingLowestCeiling(sec, &door->topHeight); + P_FindSectorSurroundingLowestCeiling(sec, (float) MAXINT, &door->topHeight); door->topHeight -= 4; #if !__JHEXEN__ @@ -856,7 +856,7 @@ boolean EV_VerticalDoor(linedef_t* line, mobj_t* mo) } // find the top and bottom of the movement range - P_FindSectorSurroundingLowestCeiling(sec, &door->topHeight); + P_FindSectorSurroundingLowestCeiling(sec, (float) MAXINT, &door->topHeight); door->topHeight -= 4; return true; } @@ -895,7 +895,7 @@ void P_SpawnDoorRaiseIn5Mins(sector_t *sec) door->state = DS_INITIALWAIT; door->type = DT_RAISEIN5MINS; door->speed = DOORSPEED; - P_FindSectorSurroundingLowestCeiling(sec, &door->topHeight); + P_FindSectorSurroundingLowestCeiling(sec, (float) MAXINT, &door->topHeight); door->topHeight -= 4; door->topWait = DOORWAIT; door->topCountDown = 5 * 60 * TICSPERSEC; diff --git a/doomsday/plugins/common/src/p_floor.c b/doomsday/plugins/common/src/p_floor.c index bc29f78662..a5d2d5dbd4 100644 --- a/doomsday/plugins/common/src/p_floor.c +++ b/doomsday/plugins/common/src/p_floor.c @@ -636,7 +636,7 @@ int EV_DoFloor(linedef_t *line, floortype_e floortype) floor->speed *= 4; # endif #endif - P_FindSectorSurroundingHighestFloor(sec, &floor->floorDestHeight); + P_FindSectorSurroundingHighestFloor(sec, -500, &floor->floorDestHeight); break; case FT_LOWERTOLOWEST: @@ -648,7 +648,8 @@ int EV_DoFloor(linedef_t *line, floortype_e floortype) floor->speed *= 4; # endif #endif - P_FindSectorSurroundingLowestFloor(sec, &floor->floorDestHeight); + P_FindSectorSurroundingLowestFloor(sec, + P_GetFloatp(sec, DMU_FLOOR_HEIGHT), &floor->floorDestHeight); break; #if __JHEXEN__ case FT_LOWERBYVALUE: @@ -671,7 +672,7 @@ int EV_DoFloor(linedef_t *line, floortype_e floortype) floor->state = FS_DOWN; floor->sector = sec; floor->speed = FLOORSPEED * 4; - P_FindSectorSurroundingHighestFloor(sec, &floor->floorDestHeight); + P_FindSectorSurroundingHighestFloor(sec, -500, &floor->floorDestHeight); # if __JHERETIC__ floor->floorDestHeight += 8; # else @@ -686,7 +687,7 @@ int EV_DoFloor(linedef_t *line, floortype_e floortype) floor->state = FS_DOWN; floor->sector = sec; floor->speed = FLOORSPEED; - P_FindSectorSurroundingHighestFloor(sec, &floor->floorDestHeight); + P_FindSectorSurroundingHighestFloor(sec, -500, &floor->floorDestHeight); if(floor->floorDestHeight != P_GetFloatp(sec, DMU_FLOOR_HEIGHT)) floor->floorDestHeight += 8; @@ -698,7 +699,7 @@ int EV_DoFloor(linedef_t *line, floortype_e floortype) floor->state = FS_DOWN; floor->sector = sec; floor->speed = FLOORSPEED * bitmipL; - P_FindSectorSurroundingHighestFloor(sec, &floor->floorDestHeight); + P_FindSectorSurroundingHighestFloor(sec, -500, &floor->floorDestHeight); if(floor->floorDestHeight != P_GetFloatp(sec, DMU_FLOOR_HEIGHT)) @@ -742,7 +743,7 @@ int EV_DoFloor(linedef_t *line, floortype_e floortype) #if __JHEXEN__ floor->floorDestHeight = P_GetFloatp(sec, DMU_CEILING_HEIGHT)-8; #else - P_FindSectorSurroundingLowestCeiling(sec, &floor->floorDestHeight); + P_FindSectorSurroundingLowestCeiling(sec, (float) MAXINT, &floor->floorDestHeight); if(floor->floorDestHeight > P_GetFloatp(sec, DMU_CEILING_HEIGHT)) floor->floorDestHeight = P_GetFloatp(sec, DMU_CEILING_HEIGHT); @@ -760,7 +761,7 @@ int EV_DoFloor(linedef_t *line, floortype_e floortype) floor->speed *= 4; # endif #endif - P_FindSectorSurroundingLowestCeiling(sec, &floor->floorDestHeight); + P_FindSectorSurroundingLowestCeiling(sec, (float) MAXINT, &floor->floorDestHeight); if(floor->floorDestHeight > P_GetFloatp(sec, DMU_CEILING_HEIGHT)) floor->floorDestHeight = P_GetFloatp(sec, DMU_CEILING_HEIGHT); @@ -909,7 +910,8 @@ int EV_DoFloor(linedef_t *line, floortype_e floortype) floor->state = FS_DOWN; floor->sector = sec; floor->speed = FLOORSPEED; - P_FindSectorSurroundingLowestFloor(sec, &floor->floorDestHeight); + P_FindSectorSurroundingLowestFloor(sec, + P_GetFloatp(sec, DMU_FLOOR_HEIGHT), &floor->floorDestHeight); floor->material = P_GetPtrp(sec, DMU_FLOOR_MATERIAL); { diff --git a/doomsday/plugins/common/src/p_mapspec.c b/doomsday/plugins/common/src/p_mapspec.c index ce7fa7ad97..c7c20319ed 100644 --- a/doomsday/plugins/common/src/p_mapspec.c +++ b/doomsday/plugins/common/src/p_mapspec.c @@ -423,13 +423,13 @@ int findExtremalPlaneHeight(void *ptr, void *context) /** * Find the sector with the lowest floor height in surrounding sectors. */ -sector_t* P_FindSectorSurroundingLowestFloor(sector_t* sec, float* val) +sector_t* P_FindSectorSurroundingLowestFloor(sector_t* sec, float max, float* val) { findextremalplaneheightparams_t params; params.baseSec = sec; params.flags = FEPHF_MIN | FEPHF_FLOOR; - params.val = DDMAXFLOAT; + params.val = max; params.foundSec = NULL; P_Iteratep(sec, DMU_LINEDEF, ¶ms, findExtremalPlaneHeight); @@ -441,13 +441,13 @@ sector_t* P_FindSectorSurroundingLowestFloor(sector_t* sec, float* val) /** * Find the sector with the highest floor height in surrounding sectors. */ -sector_t* P_FindSectorSurroundingHighestFloor(sector_t* sec, float* val) +sector_t* P_FindSectorSurroundingHighestFloor(sector_t* sec, float min, float* val) { findextremalplaneheightparams_t params; params.baseSec = sec; params.flags = FEPHF_FLOOR; - params.val = DDMINFLOAT; + params.val = min; params.foundSec = NULL; P_Iteratep(sec, DMU_LINEDEF, ¶ms, findExtremalPlaneHeight); @@ -459,13 +459,13 @@ sector_t* P_FindSectorSurroundingHighestFloor(sector_t* sec, float* val) /** * Find lowest ceiling in the surrounding sector. */ -sector_t* P_FindSectorSurroundingLowestCeiling(sector_t *sec, float *val) +sector_t* P_FindSectorSurroundingLowestCeiling(sector_t *sec, float max, float *val) { findextremalplaneheightparams_t params; params.baseSec = sec; params.flags = FEPHF_MIN; - params.val = DDMAXFLOAT; + params.val = max; params.foundSec = NULL; P_Iteratep(sec, DMU_LINEDEF, ¶ms, findExtremalPlaneHeight); @@ -477,13 +477,13 @@ sector_t* P_FindSectorSurroundingLowestCeiling(sector_t *sec, float *val) /** * Find highest ceiling in the surrounding sectors. */ -sector_t* P_FindSectorSurroundingHighestCeiling(sector_t *sec, float *val) +sector_t* P_FindSectorSurroundingHighestCeiling(sector_t *sec, float min, float *val) { findextremalplaneheightparams_t params; params.baseSec = sec; params.flags = 0; - params.val = DDMINFLOAT; + params.val = min; params.foundSec = NULL; P_Iteratep(sec, DMU_LINEDEF, ¶ms, findExtremalPlaneHeight); diff --git a/doomsday/plugins/common/src/p_plat.c b/doomsday/plugins/common/src/p_plat.c index 69a0024316..4785ebd849 100644 --- a/doomsday/plugins/common/src/p_plat.c +++ b/doomsday/plugins/common/src/p_plat.c @@ -322,7 +322,8 @@ static int doPlat(linedef_t *line, int tag, plattype_e type, int amount) break; #endif case PT_DOWNWAITUPSTAY: - P_FindSectorSurroundingLowestFloor(sec, &plat->low); + P_FindSectorSurroundingLowestFloor(sec, + P_GetFloatp(sec, DMU_FLOOR_HEIGHT), &plat->low); #if __JHEXEN__ plat->low += 8; #else @@ -345,7 +346,7 @@ static int doPlat(linedef_t *line, int tag, plattype_e type, int amount) #if __JDOOM64__ || __JHEXEN__ case PT_UPWAITDOWNSTAY: - P_FindSectorSurroundingHighestFloor(sec, &plat->high); + P_FindSectorSurroundingHighestFloor(sec, -500, &plat->high); if(plat->high < floorHeight) plat->high = floorHeight; @@ -366,7 +367,8 @@ static int doPlat(linedef_t *line, int tag, plattype_e type, int amount) #if __JDOOM64__ case PT_DOWNWAITUPDOOR: // jd64 plat->speed = PLATSPEED * 8; - P_FindSectorSurroundingLowestFloor(sec, &plat->low); + P_FindSectorSurroundingLowestFloor(sec, + P_GetFloatp(sec, DMU_FLOOR_HEIGHT), &plat->low); if(plat->low > floorHeight) plat->low = floorHeight; @@ -400,7 +402,8 @@ static int doPlat(linedef_t *line, int tag, plattype_e type, int amount) #if __JDOOM__ || __JDOOM64__ case PT_DOWNWAITUPSTAYBLAZE: plat->speed = PLATSPEED * 8; - P_FindSectorSurroundingLowestFloor(sec, &plat->low); + P_FindSectorSurroundingLowestFloor(sec, + P_GetFloatp(sec, DMU_FLOOR_HEIGHT), &plat->low); if(plat->low > floorHeight) plat->low = floorHeight; @@ -412,7 +415,8 @@ static int doPlat(linedef_t *line, int tag, plattype_e type, int amount) break; #endif case PT_PERPETUALRAISE: - P_FindSectorSurroundingLowestFloor(sec, &plat->low); + P_FindSectorSurroundingLowestFloor(sec, + P_GetFloatp(sec, DMU_FLOOR_HEIGHT), &plat->low); #if __JHEXEN__ plat->low += 8; #else @@ -421,7 +425,7 @@ static int doPlat(linedef_t *line, int tag, plattype_e type, int amount) if(plat->low > floorHeight) plat->low = floorHeight; - P_FindSectorSurroundingHighestFloor(sec, &plat->high); + P_FindSectorSurroundingHighestFloor(sec, -500, &plat->high); if(plat->high < floorHeight) plat->high = floorHeight; diff --git a/doomsday/plugins/common/src/p_xgsec.c b/doomsday/plugins/common/src/p_xgsec.c index d6512a2d00..26c404c6b8 100644 --- a/doomsday/plugins/common/src/p_xgsec.c +++ b/doomsday/plugins/common/src/p_xgsec.c @@ -1279,28 +1279,28 @@ boolean XS_GetPlane(linedef_t* actline, sector_t* sector, int ref, if(ref == SPREF_HIGHEST_CEILING) { otherSec = - P_FindSectorSurroundingHighestCeiling(sector, &otherHeight); + P_FindSectorSurroundingHighestCeiling(sector, DDMINFLOAT, &otherHeight); if(otherSec) otherMat = P_GetPtrp(otherSec, DMU_CEILING_MATERIAL); } else if(ref == SPREF_HIGHEST_FLOOR) { otherSec = - P_FindSectorSurroundingHighestFloor(sector, &otherHeight); + P_FindSectorSurroundingHighestFloor(sector, DDMINFLOAT, &otherHeight); if(otherSec) otherMat = P_GetPtrp(otherSec, DMU_CEILING_MATERIAL); } else if(ref == SPREF_LOWEST_CEILING) { otherSec = - P_FindSectorSurroundingLowestCeiling(sector, &otherHeight); + P_FindSectorSurroundingLowestCeiling(sector, DDMAXFLOAT, &otherHeight); if(otherSec) otherMat = P_GetPtrp(otherSec, DMU_CEILING_MATERIAL); } else if(ref == SPREF_LOWEST_FLOOR) { otherSec = - P_FindSectorSurroundingLowestFloor(sector, &otherHeight); + P_FindSectorSurroundingLowestFloor(sector, DDMAXFLOAT, &otherHeight); if(otherSec) otherMat = P_GetPtrp(otherSec, DMU_FLOOR_MATERIAL); } diff --git a/doomsday/plugins/jhexen/include/h2def.h b/doomsday/plugins/jhexen/include/h2def.h index f016b27f3a..64b32d349d 100644 --- a/doomsday/plugins/jhexen/include/h2def.h +++ b/doomsday/plugins/jhexen/include/h2def.h @@ -46,6 +46,37 @@ #include "version.h" #include "info.h" +// Predefined with some OS. +#ifdef UNIX + +#include + +#define MAXCHAR SCHAR_MAX +#define MAXSHORT SHRT_MAX +#define MAXINT INT_MAX +#define MAXLONG LONG_MAX + +#define MINCHAR SCHAR_MIN +#define MINSHORT SHRT_MIN +#define MININT INT_MIN +#define MINLONG LONG_MIN + +#else /* not UNIX */ + +#define MAXCHAR ((char)0x7f) +#define MAXSHORT ((short)0x7fff) + +// Max pos 32-bit int. +#define MAXINT ((int)0x7fffffff) +#define MAXLONG ((long)0x7fffffff) +#define MINCHAR ((char)0x80) +#define MINSHORT ((short)0x8000) + +// Max negative 32-bit integer. +#define MININT ((int)0x80000000) +#define MINLONG ((long)0x80000000) +#endif + #define Set DD_SetInteger #define Get DD_GetInteger diff --git a/doomsday/plugins/jhexen/src/p_pillar.c b/doomsday/plugins/jhexen/src/p_pillar.c index eb2b0e71f4..13cd9e47ea 100644 --- a/doomsday/plugins/jhexen/src/p_pillar.c +++ b/doomsday/plugins/jhexen/src/p_pillar.c @@ -179,7 +179,8 @@ int EV_OpenPillar(linedef_t *line, byte *args) pillar->sector = sec; if(!args[2]) { - P_FindSectorSurroundingLowestFloor(sec, &pillar->floorDest); + P_FindSectorSurroundingLowestFloor(sec, + P_GetFloatp(sec, DMU_FLOOR_HEIGHT), &pillar->floorDest); } else { @@ -189,7 +190,7 @@ int EV_OpenPillar(linedef_t *line, byte *args) if(!args[3]) { - P_FindSectorSurroundingHighestCeiling(sec, &pillar->ceilingDest); + P_FindSectorSurroundingHighestCeiling(sec, 0, &pillar->ceilingDest); } else {