This commit is contained in:
Christoph Oelckers 2016-03-14 22:02:58 +01:00
commit f4f489b33d
21 changed files with 325 additions and 201 deletions

View file

@ -167,6 +167,11 @@ else()
set( ALL_C_FLAGS "" )
set( REL_C_FLAGS "" )
set( DEB_C_FLAGS "" )
# If we're compiling with a custom GCC on the Mac (which we know since g++-4.2 doesn't support C++11) statically link libgcc.
if( APPLE AND "${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" )
set( ALL_C_FLAGS "-static-libgcc" )
endif()
endif()
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${REL_LINKER_FLAGS}" )
@ -193,7 +198,7 @@ option(FORCE_INTERNAL_GME "Use internal gme" ON)
# Fast math flags, required by some subprojects
set( ZD_FASTMATH_FLAG "" )
if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
set( ZD_FASTMATH_FLAG "-ffast-math" )
set( ZD_FASTMATH_FLAG "-ffast-math -ffp-contract=fast" )
elseif( MSVC )
set( ZD_FASTMATH_FLAG "/fp:fast" )
endif()

View file

@ -494,28 +494,28 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
set( CMAKE_C_FLAGS "-Wno-unused-result ${CMAKE_C_FLAGS}" )
set( CMAKE_CXX_FLAGS "-Wno-unused-result ${CMAKE_CXX_FLAGS}" )
endif()
set( CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers ${CMAKE_C_FLAGS}" )
set( CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers ${CMAKE_CXX_FLAGS}" )
set( CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers -ffp-contract=off ${CMAKE_C_FLAGS}" )
set( CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused -Wno-unused-parameter -Wno-missing-field-initializers -ffp-contract=off ${CMAKE_CXX_FLAGS}" )
# Use the highest C++ standard available since VS2015 compiles with C++14
# but we only require C++11. The recommended way to do this in CMake is to
# probably to use target_compile_features, but I don't feel like maintaining
# a list of features we use.
CHECK_CXX_COMPILER_FLAG( "-std=c++14" CAN_DO_CPP14 )
CHECK_CXX_COMPILER_FLAG( "-std=gnu++14" CAN_DO_CPP14 )
if ( CAN_DO_CPP14 )
set ( CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}" )
set ( CMAKE_CXX_FLAGS "-std=gnu++14 ${CMAKE_CXX_FLAGS}" )
else ()
CHECK_CXX_COMPILER_FLAG( "-std=c++1y" CAN_DO_CPP1Y )
CHECK_CXX_COMPILER_FLAG( "-std=gnu++1y" CAN_DO_CPP1Y )
if ( CAN_DO_CPP1Y )
set ( CMAKE_CXX_FLAGS "-std=c++1y ${CMAKE_CXX_FLAGS}" )
set ( CMAKE_CXX_FLAGS "-std=gnu++1y ${CMAKE_CXX_FLAGS}" )
else ()
CHECK_CXX_COMPILER_FLAG( "-std=c++11" CAN_DO_CPP11 )
CHECK_CXX_COMPILER_FLAG( "-std=gnu++11" CAN_DO_CPP11 )
if ( CAN_DO_CPP11 )
set ( CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}" )
set ( CMAKE_CXX_FLAGS "-std=gnu++11 ${CMAKE_CXX_FLAGS}" )
else ()
CHECK_CXX_COMPILER_FLAG( "-std=c++0x" CAN_DO_CPP0X )
CHECK_CXX_COMPILER_FLAG( "-std=gnu++0x" CAN_DO_CPP0X )
if ( CAN_DO_CPP0X )
set ( CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}" )
set ( CMAKE_CXX_FLAGS "-std=gnu++0x ${CMAKE_CXX_FLAGS}" )
endif ()
endif ()
endif ()
@ -676,6 +676,7 @@ set( PLAT_COCOA_SOURCES
posix/cocoa/i_input.mm
posix/cocoa/i_joystick.cpp
posix/cocoa/i_main.mm
posix/cocoa/i_main_except.cpp
posix/cocoa/i_system.mm
posix/cocoa/i_timer.cpp
posix/cocoa/i_video.mm
@ -712,6 +713,7 @@ elseif( APPLE )
set_source_files_properties( posix/osx/zdoom.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
set_source_files_properties( "${FMOD_LIBRARY}" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks )
set_source_files_properties( posix/osx/iwadpicker_cocoa.mm PROPERTIES COMPILE_FLAGS -fobjc-exceptions )
else()
set( SYSTEM_SOURCES_DIR posix posix/sdl )
set( SYSTEM_SOURCES ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} )

View file

@ -121,6 +121,7 @@ CVAR (Color, am_thingcolor_monster, 0xfcfcfc, CVAR_ARCHIVE);
CVAR (Color, am_thingcolor_ncmonster, 0xfcfcfc, CVAR_ARCHIVE);
CVAR (Color, am_thingcolor_item, 0xfcfcfc, CVAR_ARCHIVE);
CVAR (Color, am_thingcolor_citem, 0xfcfcfc, CVAR_ARCHIVE);
CVAR (Color, am_portalcolor, 0x404040, CVAR_ARCHIVE);
CVAR (Color, am_ovyourcolor, 0xfce8d8, CVAR_ARCHIVE);
CVAR (Color, am_ovwallcolor, 0x00ff00, CVAR_ARCHIVE);
@ -141,6 +142,7 @@ CVAR (Color, am_ovthingcolor_monster, 0xe88800, CVAR_ARCHIVE);
CVAR (Color, am_ovthingcolor_ncmonster, 0xe88800, CVAR_ARCHIVE);
CVAR (Color, am_ovthingcolor_item, 0xe88800, CVAR_ARCHIVE);
CVAR (Color, am_ovthingcolor_citem, 0xe88800, CVAR_ARCHIVE);
CVAR (Color, am_ovportalcolor, 0x004022, CVAR_ARCHIVE);
//=============================================================================
//
@ -206,6 +208,7 @@ static const char *ColorNames[] = {
"IntraTeleportColor",
"InterTeleportColor",
"SecretSectorColor",
"PortalColor",
"AlmostBackgroundColor",
NULL
};
@ -236,6 +239,7 @@ struct AMColorset
IntraTeleportColor,
InterTeleportColor,
SecretSectorColor,
PortalColor,
AlmostBackgroundColor,
AM_NUM_COLORS
};
@ -335,7 +339,8 @@ static FColorCVar *cv_standard[] = {
&am_lockedcolor,
&am_intralevelcolor,
&am_interlevelcolor,
&am_secretsectorcolor
&am_secretsectorcolor,
&am_portalcolor
};
static FColorCVar *cv_overlay[] = {
@ -360,7 +365,8 @@ static FColorCVar *cv_overlay[] = {
&am_ovlockedcolor,
&am_ovtelecolor,
&am_ovinterlevelcolor,
&am_ovsecretsectorcolor
&am_ovsecretsectorcolor,
&am_ovportalcolor
};
CCMD(am_restorecolors)
@ -403,6 +409,7 @@ static unsigned char DoomColors[]= {
NOT_USED, // interteleport
NOT_USED, // secretsector
0x10,0x10,0x10, // almostbackground
0x40,0x40,0x40 // portal
};
static unsigned char StrifeColors[]= {
@ -429,6 +436,7 @@ static unsigned char StrifeColors[]= {
NOT_USED, // interteleport
NOT_USED, // secretsector
0x10,0x10,0x10, // almostbackground
0x40,0x40,0x40 // portal
};
static unsigned char RavenColors[]= {
@ -455,6 +463,7 @@ static unsigned char RavenColors[]= {
NOT_USED, // interteleport
NOT_USED, // secretsector
0x10,0x10,0x10, // almostbackground
0x50,0x50,0x50 // portal
};
#undef NOT_USED
@ -577,6 +586,7 @@ inline fixed_t MTOF(fixed_t x)
static int bigstate = 0;
static bool textured = 1; // internal toggle for texture mode
static int MapPortalGroup;
CUSTOM_CVAR(Bool, am_textured, false, CVAR_ARCHIVE)
{
@ -812,6 +822,7 @@ void AM_minOutWindowScale ();
CVAR(Bool, am_followplayer, true, CVAR_ARCHIVE)
CVAR(Bool, am_portaloverlay, true, CVAR_ARCHIVE)
CCMD(am_togglefollow)
@ -1925,6 +1936,12 @@ void AM_drawSubsectors()
{
continue;
}
if (am_portaloverlay && subsectors[i].render_sector->PortalGroup != MapPortalGroup && subsectors[i].render_sector->PortalGroup != 0)
{
continue;
}
// Fill the points array from the subsector.
points.Resize(subsectors[i].numlines);
for (DWORD j = 0; j < subsectors[i].numlines; ++j)
@ -2389,17 +2406,47 @@ void AM_drawWalls (bool allmap)
static mline_t l;
int lock, color;
int numportalgroups = am_portaloverlay ? Displacements.size : 0;
for (int p = numportalgroups - 1; p >= -1; p--)
{
if (p == MapPortalGroup) continue;
for (i = 0; i < numlines; i++)
{
l.a.x = lines[i].v1->x >> FRACTOMAPBITS;
l.a.y = lines[i].v1->y >> FRACTOMAPBITS;
l.b.x = lines[i].v2->x >> FRACTOMAPBITS;
l.b.y = lines[i].v2->y >> FRACTOMAPBITS;
int pg;
if (lines[i].sidedef[0]->Flags & WALLF_POLYOBJ)
{
// For polyobjects we must test the surrounding sector to get the proper group.
pg = P_PointInSector(lines[i].v1->x + lines[i].dx / 2, lines[i].v1->y + lines[i].dy / 2)->PortalGroup;
}
else
{
pg = lines[i].frontsector->PortalGroup;
}
fixedvec2 offset;
bool portalmode = numportalgroups > 0 && pg != MapPortalGroup;
if (pg == p)
{
offset = Displacements.getOffset(pg, MapPortalGroup);
}
else if (p == -1 && (pg == MapPortalGroup || !am_portaloverlay))
{
offset = { 0, 0 };
}
else continue;
l.a.x = (lines[i].v1->x + offset.x) >> FRACTOMAPBITS;
l.a.y = (lines[i].v1->y + offset.y) >> FRACTOMAPBITS;
l.b.x = (lines[i].v2->x + offset.x) >> FRACTOMAPBITS;
l.b.y = (lines[i].v2->y + offset.y) >> FRACTOMAPBITS;
if (am_rotate == 1 || (am_rotate == 2 && viewactive))
{
AM_rotatePoint (&l.a.x, &l.a.y);
AM_rotatePoint (&l.b.x, &l.b.y);
AM_rotatePoint(&l.a.x, &l.a.y);
AM_rotatePoint(&l.b.x, &l.b.y);
}
if (am_cheat != 0 || (lines[i].flags & ML_MAPPED))
@ -2412,7 +2459,11 @@ void AM_drawWalls (bool allmap)
}
}
if (AM_CheckSecret(&lines[i]))
if (portalmode)
{
AM_drawMline(&l, AMColors.PortalColor);
}
else if (AM_CheckSecret(&lines[i]))
{
// map secret sectors like Boom
AM_drawMline(&l, AMColors.SecretSectorColor);
@ -2443,11 +2494,11 @@ void AM_drawWalls (bool allmap)
if (color >= 0) c.FromRGB(RPART(color), GPART(color), BPART(color));
else c = AMColors[AMColors.LockedColor];
AM_drawMline (&l, c);
AM_drawMline(&l, c);
}
else
{
AM_drawMline (&l, AMColors.LockedColor); // locked special
AM_drawMline(&l, AMColors.LockedColor); // locked special
}
}
else if (am_showtriggerlines
@ -2491,6 +2542,7 @@ void AM_drawWalls (bool allmap)
AM_drawMline(&l, AMColors.NotSeenColor);
}
}
}
}
@ -2616,8 +2668,9 @@ void AM_drawPlayers ()
mline_t *arrow;
int numarrowlines;
pt.x = players[consoleplayer].camera->X() >> FRACTOMAPBITS;
pt.y = players[consoleplayer].camera->Y() >> FRACTOMAPBITS;
fixedvec2 pos = am_portaloverlay? players[consoleplayer].camera->GetPortalTransition(players[consoleplayer].viewheight) : (fixedvec2)players[consoleplayer].camera->Pos();
pt.x = pos.x >> FRACTOMAPBITS;
pt.y = pos.y >> FRACTOMAPBITS;
if (am_rotate == 1 || (am_rotate == 2 && viewactive))
{
angle = ANG90;
@ -2679,8 +2732,10 @@ void AM_drawPlayers ()
if (p->mo != NULL)
{
pt.x = p->mo->X() >> FRACTOMAPBITS;
pt.y = p->mo->Y() >> FRACTOMAPBITS;
fixedvec3 pos = p->mo->PosRelative(MapPortalGroup);
pt.x = pos.x >> FRACTOMAPBITS;
pt.y = pos.y >> FRACTOMAPBITS;
angle = p->mo->angle;
if (am_rotate == 1 || (am_rotate == 2 && viewactive))
@ -2711,8 +2766,10 @@ void AM_drawKeys ()
while ((key = it.Next()) != NULL)
{
p.x = key->X() >> FRACTOMAPBITS;
p.y = key->Y() >> FRACTOMAPBITS;
fixedvec3 pos = key->PosRelative(MapPortalGroup);
p.x = pos.x >> FRACTOMAPBITS;
p.y = pos.y >> FRACTOMAPBITS;
angle = key->angle;
if (am_rotate == 1 || (am_rotate == 2 && viewactive))
@ -2756,8 +2813,9 @@ void AM_drawThings ()
{
if (am_cheat > 0 || !(t->flags6 & MF6_NOTONAUTOMAP))
{
p.x = t->X() >> FRACTOMAPBITS;
p.y = t->Y() >> FRACTOMAPBITS;
fixedvec3 pos = t->PosRelative(MapPortalGroup);
p.x = pos.x >> FRACTOMAPBITS;
p.y = pos.y >> FRACTOMAPBITS;
if (am_showthingsprites > 0 && t->sprite > 0)
{
@ -3017,6 +3075,13 @@ void AM_Drawer ()
bool allmap = (level.flags2 & LEVEL2_ALLMAP) != 0;
bool allthings = allmap && players[consoleplayer].mo->FindInventory(RUNTIME_CLASS(APowerScanner), true) != NULL;
if (am_portaloverlay)
{
sector_t *sec;
players[consoleplayer].camera->GetPortalTransition(players[consoleplayer].viewheight, &sec);
MapPortalGroup = sec->PortalGroup;
}
else MapPortalGroup = 0;
AM_initColors (viewactive);
if (!viewactive)

View file

@ -123,6 +123,18 @@ typedef TMap<int, PClassActor *> FClassMap;
#define NO_SANITIZE
#endif
#if defined(__GNUC__)
// With versions of GCC newer than 4.2, it appears it was determined that the
// cost of an unaligned pointer on PPC was high enough to add padding to the
// end of packed structs. For whatever reason __packed__ and pragma pack are
// handled differently in this regard. Note that this only needs to be applied
// to types which are used in arrays or sizeof is needed. This also prevents
// code from taking references to the struct members.
#define FORCE_PACKED __attribute__((__packed__))
#else
#define FORCE_PACKED
#endif
#include "basictypes.h"
extern bool batchrun;

View file

@ -4184,12 +4184,12 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b
if (floor)
{
actor->Sector->NextLowestFloorAt(actor, actor->Z(), 0, &resultsec, &resffloor);
actor->Sector->NextLowestFloorAt(actor->X(), actor->Y(), actor->Z(), 0, actor->MaxStepHeight, &resultsec, &resffloor);
secpic = resffloor ? *resffloor->top.texture : resultsec->planes[sector_t::floor].Texture;
}
else
{
actor->Sector->NextHighestCeilingAt(actor, actor->Top(), 0, &resultsec, &resffloor);
actor->Sector->NextHighestCeilingAt(actor->X(), actor->Y(), actor->Z(), actor->Top(), 0, &resultsec, &resffloor);
secpic = resffloor ? *resffloor->bottom.texture : resultsec->planes[sector_t::ceiling].Texture;
}
return tex == TexMan[secpic];
@ -5946,8 +5946,8 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
reference = SingleActorFromTID(tid_dest, activator);
}
// If there is no actor to warp to, fail.
if (!reference)
// If there is no activator or actor to warp to, fail.
if (activator == NULL || !reference)
return false;
if (P_Thing_Warp(activator, reference, xofs, yofs, zofs, angle, flags, heightoffset, radiusoffset, pitch))

View file

@ -290,7 +290,7 @@ void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags)
sector_t *sec = (!(flags & FFCF_SAMESECTOR) || tmf.thing->Sector == NULL)? P_PointInSector(tmf.x, tmf.y) : tmf.sector;
F3DFloor *ffc, *fff;
tmf.ceilingz = sec->NextHighestCeilingAt(tmf.x, tmf.y, tmf.z + tmf.thing->height, flags, &tmf.ceilingsector, &ffc);
tmf.ceilingz = sec->NextHighestCeilingAt(tmf.x, tmf.y, tmf.z, tmf.z + tmf.thing->height, flags, &tmf.ceilingsector, &ffc);
tmf.floorz = tmf.dropoffz = sec->NextLowestFloorAt(tmf.x, tmf.y, tmf.z, flags, tmf.thing->MaxStepHeight, &tmf.floorsector, &fff);
if (fff)
@ -997,7 +997,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec
spec.oldrefpos = tm.thing->PosRelative(ld);
spechit.Push(spec);
}
if (ld->portalindex != UINT_MAX)
if (ld->isLinePortal())
{
spec.line = ld;
spec.refpos = cres.position;
@ -3793,7 +3793,7 @@ struct aim_t
intercept_t *in;
if (aimdebug)
Printf("Start AimTraverse, start = %f,%f,%f, vect = %f,%f,%f\n",
Printf("Start AimTraverse, start = %f,%f,%f, vect = %f,%f\n",
startpos.x / 65536., startpos.y / 65536., startpos.z / 65536.,
aimtrace.x / 65536., aimtrace.y / 65536.);

View file

@ -1980,6 +1980,10 @@ int P_VanillaPointOnDivlineSide(fixed_t x, fixed_t y, const divline_t* line)
sector_t *P_PointInSectorBuggy(fixed_t x, fixed_t y)
{
// single subsector is a special case
if (numgamenodes == 0)
return gamesubsectors->sector;
node_t *node = gamenodes + numgamenodes - 1;
do

View file

@ -932,7 +932,7 @@ fixed_t sector_t::LowestFloorAt(fixed_t x, fixed_t y, sector_t **resultsec)
}
fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t z, int flags, sector_t **resultsec, F3DFloor **resultffloor)
fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fixed_t topz, int flags, sector_t **resultsec, F3DFloor **resultffloor)
{
sector_t *sec = this;
fixed_t planeheight = FIXED_MIN;
@ -943,14 +943,20 @@ fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t z, int flag
fixed_t realceil = sec->ceilingplane.ZatPoint(x, y);
for (int i = sec->e->XFloor.ffloors.Size() - 1; i >= 0; --i)
{
F3DFloor *ff = sec->e->XFloor.ffloors[i];
F3DFloor *rover = sec->e->XFloor.ffloors[i];
if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue;
fixed_t ffz = ff->bottom.plane->ZatPoint(x, y);
if (ffz < realceil && ((ff->flags & (FF_EXISTS | FF_SOLID)) == (FF_EXISTS | FF_SOLID) && z <= ffz))
{ // This floor is above our eyes.
fixed_t ff_bottom = rover->bottom.plane->ZatPoint(x, y);
fixed_t ff_top = rover->top.plane->ZatPoint(x, y);
fixed_t delta1 = bottomz - (ff_bottom + ((ff_top - ff_bottom) / 2));
fixed_t delta2 = topz - (ff_bottom + ((ff_top - ff_bottom) / 2));
if (ff_bottom < realceil && abs(delta1) >= abs(delta2))
{
if (resultsec) *resultsec = sec;
if (resultffloor) *resultffloor = ff;
return ffz;
if (resultffloor) *resultffloor = rover;
return ff_bottom;
}
}
if ((flags & FFCF_NOPORTALS) || sec->PortalBlocksMovement(ceiling) || planeheight >= sec->SkyBoxes[ceiling]->threshold)

View file

@ -342,7 +342,7 @@ void FTraceInfo::Setup3DFloors()
{
CurSector->floorplane = *rover->top.plane;
CurSector->SetTexture(sector_t::floor, *rover->top.texture, false);
CurSector->SkyBoxes[sector_t::floor] == NULL;
CurSector->SkyBoxes[sector_t::floor] = nullptr;
bf = ff_top;
}
}
@ -354,7 +354,7 @@ void FTraceInfo::Setup3DFloors()
CurSector->ceilingplane = *rover->bottom.plane;
CurSector->SetTexture(sector_t::ceiling, *rover->bottom.texture, false);
bc = ff_bottom;
CurSector->SkyBoxes[sector_t::ceiling] == NULL;
CurSector->SkyBoxes[sector_t::ceiling] = nullptr;
}
}
else
@ -364,7 +364,7 @@ void FTraceInfo::Setup3DFloors()
{
CurSector->floorplane = *rover->bottom.plane;
CurSector->SetTexture(sector_t::floor, *rover->bottom.texture, false);
CurSector->SkyBoxes[sector_t::floor] == NULL;
CurSector->SkyBoxes[sector_t::floor] = nullptr;
bf = ff_bottom;
}
@ -372,7 +372,7 @@ void FTraceInfo::Setup3DFloors()
{
CurSector->ceilingplane = *rover->top.plane;
CurSector->SetTexture(sector_t::ceiling, *rover->top.texture, false);
CurSector->SkyBoxes[sector_t::ceiling] == NULL;
CurSector->SkyBoxes[sector_t::ceiling] = nullptr;
bc = ff_top;
}
inshootthrough = false;

View file

@ -955,6 +955,7 @@ void P_CreateLinkedPortals()
}
}
}
id = 1;
if (orgs.Size() != 0)
{
for (int i = 0; i < numsectors; i++)

View file

@ -149,6 +149,8 @@ static const NSOpenGLPixelFormatAttribute NSOpenGLPFAAllowOfflineRenderers = NSO
- (void)setCollectionBehavior:(NSUInteger)collectionBehavior;
@end
typedef NSUInteger NSWindowCollectionBehavior;
#endif // prior to 10.5

View file

@ -67,7 +67,6 @@ EXTERN_CVAR(Bool, fullscreen )
// ---------------------------------------------------------------------------
namespace
{
@ -78,6 +77,9 @@ void (*TermFuncs[MAX_TERMS])();
const char *TermNames[MAX_TERMS];
size_t NumTerms;
} // unnamed namespace
// Expose this for i_main_except.cpp
void call_terms()
{
while (NumTerms > 0)
@ -86,8 +88,6 @@ void call_terms()
}
}
} // unnamed namespace
void addterm(void (*func)(), const char *name)
{
@ -133,49 +133,12 @@ void Mac_I_FatalError(const char* const message)
DArgs* Args; // command line arguments
namespace
// Newer versions of GCC than 4.2 have a bug with C++ exceptions in Objective-C++ code.
// To work around we'll implement the try and catch in standard C++.
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61759
void OriginalMainExcept(int argc, char** argv);
void OriginalMainTry(int argc, char** argv)
{
const int ARGC_MAX = 64;
int s_argc;
char* s_argv[ARGC_MAX];
TArray<FString> s_argvStorage;
bool s_restartedFromWADPicker;
void NewFailure()
{
I_FatalError("Failed to allocate memory from system heap");
}
int OriginalMain(int argc, char** argv)
{
printf(GAMENAME" %s - %s - Cocoa version\nCompiled on %s\n\n",
GetVersionString(), GetGitTime(), __DATE__);
seteuid(getuid());
std::set_new_handler(NewFailure);
// Set LC_NUMERIC environment variable in case some library decides to
// clear the setlocale call at least this will be correct.
// Note that the LANG environment variable is overridden by LC_*
setenv("LC_NUMERIC", "C", 1);
setlocale(LC_ALL, "C");
// Set reasonable default values for video settings
const NSSize screenSize = [[NSScreen mainScreen] frame].size;
vid_defwidth = static_cast<int>(screenSize.width);
vid_defheight = static_cast<int>(screenSize.height);
vid_vsync = true;
fullscreen = true;
try
{
Args = new DArgs(argc, argv);
/*
@ -203,24 +166,49 @@ int OriginalMain(int argc, char** argv)
C_InitConsole(80 * 8, 25 * 8, false);
D_DoomMain();
}
catch(const CDoomError& error)
{
const char* const message = error.GetMessage();
}
if (NULL != message)
{
fprintf(stderr, "%s\n", message);
Mac_I_FatalError(message);
}
namespace
{
exit(-1);
}
catch(...)
{
call_terms();
throw;
}
const int ARGC_MAX = 64;
int s_argc;
char* s_argv[ARGC_MAX];
TArray<FString> s_argvStorage;
bool s_restartedFromWADPicker;
void NewFailure()
{
I_FatalError("Failed to allocate memory from system heap");
}
int OriginalMain(int argc, char** argv)
{
printf(GAMENAME" %s - %s - Cocoa version\nCompiled on %s\n\n",
GetVersionString(), GetGitTime(), __DATE__);
seteuid(getuid());
std::set_new_handler(NewFailure);
// Set LC_NUMERIC environment variable in case some library decides to
// clear the setlocale call at least this will be correct.
// Note that the LANG environment variable is overridden by LC_*
setenv("LC_NUMERIC", "C", 1);
setlocale(LC_ALL, "C");
// Set reasonable default values for video settings
const NSSize screenSize = [[NSScreen mainScreen] frame].size;
vid_defwidth = static_cast<int>(screenSize.width);
vid_defheight = static_cast<int>(screenSize.height);
vid_vsync = true;
fullscreen = true;
OriginalMainExcept(argc, argv);
return 0;
}

View file

@ -0,0 +1,34 @@
// Workaround for GCC Objective-C++ with C++ exceptions bug.
#include "doomerrors.h"
#include <stdlib.h>
// Import some functions from i_main.mm
void call_terms();
void Mac_I_FatalError(const char* const message);
void OriginalMainTry(int argc, char** argv);
void OriginalMainExcept(int argc, char** argv)
{
try
{
OriginalMainTry(argc, argv);
}
catch(const CDoomError& error)
{
const char* const message = error.GetMessage();
if (NULL != message)
{
fprintf(stderr, "%s\n", message);
Mac_I_FatalError(message);
}
exit(-1);
}
catch(...)
{
call_terms();
throw;
}
}

View file

@ -873,19 +873,9 @@ struct sector_t
return LowestFloorAt(a->X(), a->Y(), resultsec);
}
fixed_t NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t z, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
fixed_t NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fixed_t topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
fixed_t NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags = 0, fixed_t steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL);
fixed_t NextHighestCeilingAt(AActor *a, fixed_t z, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL)
{
return NextHighestCeilingAt(a->X(), a->Y(), z, flags, resultsec, resultffloor);
}
fixed_t NextLowestFloorAt(AActor *a, fixed_t z, int flags, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL)
{
return NextLowestFloorAt(a->X(), a->Y(), z, flags, a->MaxStepHeight, resultsec, resultffloor);
}
// Member variables
fixed_t CenterFloor () const { return floorplane.ZatPoint (centerspot); }
fixed_t CenterCeiling () const { return ceilingplane.ZatPoint (centerspot); }

View file

@ -100,14 +100,14 @@ typedef struct tagITFILEHEADER
DWORD reserved2;
BYTE chnpan[64];
BYTE chnvol[64];
} ITFILEHEADER, *PITFILEHEADER;
} FORCE_PACKED ITFILEHEADER, *PITFILEHEADER;
typedef struct MODMIDICFG
{
char szMidiGlb[9*32]; // changed from CHAR
char szMidiSFXExt[16*32]; // changed from CHAR
char szMidiZXXExt[128*32]; // changed from CHAR
} MODMIDICFG, *LPMODMIDICFG;
} FORCE_PACKED MODMIDICFG, *LPMODMIDICFG;
#pragma pack()

View file

@ -72,7 +72,7 @@ struct PCXHeader
BYTE padding[54];
};
} FORCE_PACKED;
#pragma pack()
//==========================================================================

View file

@ -13,7 +13,7 @@ struct FZipEndOfCentralDirectory
DWORD DirectorySize;
DWORD DirectoryOffset;
WORD ZipCommentLength;
};
} FORCE_PACKED;
// FZipFileInfo
struct FZipCentralDirectoryInfo
@ -36,7 +36,7 @@ struct FZipCentralDirectoryInfo
DWORD ExternalAttributes;
DWORD LocalHeaderOffset;
// file name and other variable length info follows
};
} FORCE_PACKED;
// FZipLocalHeader
struct FZipLocalFileHeader
@ -53,7 +53,7 @@ struct FZipLocalFileHeader
WORD NameLength;
WORD ExtraLength;
// file name and other variable length info follows
};
} FORCE_PACKED;
#pragma pack()

View file

@ -60,6 +60,17 @@
#define __cdecl
#endif
#ifdef __GNUC__
// With versions of GCC newer than 4.2, it appears it was determined that the
// cost of an unaligned pointer on PPC was high enough to add padding to the
// end of packed structs. For whatever reason __packed__ and pragma pack are
// handled differently in this regard. Note that this only needs to be applied
// to types which are used in arrays.
#define FORCE_PACKED __attribute__((__packed__))
#else
#define FORCE_PACKED
#endif
#ifndef __BIG_ENDIAN__
#define MAKE_ID(a,b,c,d) ((a)|((b)<<8)|((c)<<16)|((d)<<24))
#define LittleShort(x) (x)
@ -150,7 +161,7 @@ typedef struct
UINT32 UncompressedSize; // 22
WORD NameLength; // 26
WORD ExtraLength; // 28
} LocalFileHeader;
} FORCE_PACKED LocalFileHeader;
typedef struct
{
@ -171,7 +182,7 @@ typedef struct
WORD InternalAttributes;
UINT32 ExternalAttributes;
UINT32 LocalHeaderOffset;
} CentralDirectoryEntry;
} FORCE_PACKED CentralDirectoryEntry;
typedef struct
{
@ -183,7 +194,7 @@ typedef struct
UINT32 DirectorySize;
UINT32 DirectoryOffset;
WORD ZipCommentLength;
} EndOfCentralDirectory;
} FORCE_PACKED EndOfCentralDirectory;
//#pragma pack(pop)
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------

View file

@ -108,4 +108,3 @@ CMPTMNU_SECTORSOUNDS = "Sector sounds use centre as source";
OPTVAL_MAPDEFINEDCOLORSONLY = "Map defined colours only";
C_GRAY = "\ccgrey";
C_DARKGRAY = "\cudark grey";
MNU_COLORPICKER = "SELECT COLOUR";

View file

@ -1880,6 +1880,7 @@ AUTOMAPMNU_DRAWMAPBACK = "Draw map background";
AUTOMAPMNU_SHOWKEYS = "Show keys (cheat)";
AUTOMAPMNU_SHOWTRIGGERLINES = "Show trigger lines";
AUTOMAPMNU_SHOWTHINGSPRITES = "Show things as sprites";
AUTOMAPMNU_PTOVERLAY = "Overlay portals";
// Automap Controls
MAPCNTRLMNU_TITLE = "CUSTOMIZE MAP CONTROLS";
@ -1925,6 +1926,7 @@ MAPCOLORMNU_ITEMCOLOR = "Items";
MAPCOLORMNU_COUNTITEMCOLOR = "Count Items";
MAPCOLORMNU_OVERLAY = "Overlay Mode";
MAPCOLORMNU_OVCHEATMODE = "Overlay Cheat Mode";
MAPCOLORMNU_PORTAL = "Portal Overlays";
// Message Options
MSGMNU_TITLE = "MESSAGES";

View file

@ -982,6 +982,7 @@ OptionMenu AutomapOptions
Option "$AUTOMAPMNU_OVERLAY", "am_overlay", "OverlayTypes"
Option "$AUTOMAPMNU_TEXTURED", "am_textured", "OnOff"
Option "$AUTOMAPMNU_FOLLOW", "am_followplayer", "OnOff"
Option "$AUTOMAPMNU_PTOVERLAY", "am_portaloverlay", "OnOff"
StaticText " "
Option "$AUTOMAPMNU_SHOWITEMS", "am_showitems", "OnOff"
Option "$AUTOMAPMNU_SHOWMONSTERS", "am_showmonsters", "OnOff"
@ -1048,6 +1049,7 @@ OptionMenu MapColorMenu
ColorPicker "$MAPCOLORMNU_INTERLEVELCOLOR", "am_interlevelcolor"
ColorPicker "$MAPCOLORMNU_SECRETSECTORCOLOR", "am_secretsectorcolor"
ColorPicker "$MAPCOLORMNU_SPECIALWALLCOLOR", "am_specialwallcolor"
ColorPicker "$MAPCOLORMNU_PORTAL", "am_portalcolor"
StaticText " "
StaticText "$MAPCOLORMNU_CHEATMODE", 1
ColorPicker "$MAPCOLORMNU_TSWALLCOLOR", "am_tswallcolor"
@ -1071,6 +1073,7 @@ OptionMenu MapColorMenu
ColorPicker "$MAPCOLORMNU_INTERLEVELCOLOR", "am_ovinterlevelcolor"
ColorPicker "$MAPCOLORMNU_SECRETSECTORCOLOR", "am_ovsecretsectorcolor"
ColorPicker "$MAPCOLORMNU_SPECIALWALLCOLOR", "am_ovspecialwallcolor"
ColorPicker "$MAPCOLORMNU_PORTAL", "am_ovportalcolor"
StaticText " "
StaticText "$MAPCOLORMNU_OVCHEATMODE", 1
ColorPicker "$MAPCOLORMNU_TSWALLCOLOR", "am_ovotherwallscolor"