- BORLAND/: Borland C++ 4.52 (chosen over 4.5 by byte-match: CODE/RP/CW32.LIB
is identical to 4.52's install lib). BCC32/TLINK32/TLIB/MAKE run natively on
Win11; CODE/BT/OPT.MAK is the shipped BTL4OPT.EXE's exact flag recipe
(extender = Borland PowerPack DPMI32, not Phar Lap TNT).
- restoration/source410/: the literal 1995-form reconstruction of the missing
BT game source (never mixed into CODE/). Round 1-3 state:
* 6 of 10 surviving original TUs COMPILE CLEAN under the period toolchain
(BTMSSN, BTCNSL, BTSCNRL, BTTEAM, BTL4MODE, BTL4ARND) - first builds
since 1996.
* BT_L4/BTL4APP.CPP pilot reconstruction: 12/12 functions, Fail() lands on
its binary-recorded line 400 exactly.
* BT/BTCNSL.HPP: console wire IDs recovered from the binary's ctors
(Killed=9, Damaged=10, ScoreUpdate=13, DeathWithoutHonor=15 [T1];
TeamScore=12 flagged [T4]).
* MUNGA/: 8 engine-header backfills back-dated from the BT412 WinTesla tree
(VDATA numbering decomp-verified; AUDREND's OpenAL-era virtual removed -
the period compiler is the drift detector).
* Tooling: backdate.py (WinTesla->1995 header transform), compile410.sh
(per-TU verification sweep under authentic OPT.MAK flags).
* README: corrected roadmap - MECH.HPP is the capstone grown with the mech
TU reconstructions; BTREG.CPP green = the header-family milestone.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
153 lines
3.6 KiB
C++
153 lines
3.6 KiB
C++
//----------------------------------------------------------------------------
|
|
// ObjectWindows
|
|
// (C) Copyright 1993, 1994 by Borland International, All Rights Reserved
|
|
//
|
|
// Implementation of class TXOwl.
|
|
//----------------------------------------------------------------------------
|
|
#include <owl/owlpch.h>
|
|
#include <owl/except.h>
|
|
#include <owl/module.h>
|
|
|
|
//
|
|
// mbModalFlag() determines the best MB modal flag to use in the current
|
|
// situation. Uses MB_TASKMODAL if under NT, or the task/thread has at least
|
|
// one toplevel window. Uses MB_SYSTEMMODAL for win32s/win16 when there are
|
|
// no windows.
|
|
//
|
|
#if defined(BI_PLAT_WIN32)
|
|
|
|
bool CALLBACK threadHasWnd(HWND, bool* has) { *has = true; return false; }
|
|
|
|
static unsigned mbModalFlag()
|
|
{
|
|
if (!(::GetVersion()&0x80000000)) // NT can always open task modal
|
|
return MB_TASKMODAL;
|
|
bool has = false;
|
|
::EnumThreadWindows(GetCurrentThreadId(), (WNDENUMPROC)threadHasWnd,
|
|
LPARAM(&has));
|
|
return has ? MB_TASKMODAL : MB_SYSTEMMODAL;
|
|
}
|
|
|
|
#else
|
|
|
|
bool CALLBACK taskHasWnd(HWND, bool far* has) { *has = true; return false; }
|
|
|
|
static unsigned mbModalFlag()
|
|
{
|
|
bool has = false;
|
|
::EnumTaskWindows(GetCurrentTask(), (WNDENUMPROC)taskHasWnd,
|
|
LPARAM((bool far*)&has));
|
|
return has ? MB_TASKMODAL : MB_SYSTEMMODAL;
|
|
}
|
|
|
|
#endif
|
|
|
|
//
|
|
// Global exception handler used when an application object is not available.
|
|
// May be overriden by user code by redefining this function. If a valid
|
|
// application object is found by GetApplicationObject, then the virtual
|
|
// TModule::Error(TXOwl& x, char* caption, bool canResume) is usually used
|
|
// instead.
|
|
//
|
|
int _OWLFUNC
|
|
HandleGlobalException(xmsg& x, char* caption, char* canResume)
|
|
{
|
|
char errorStr[255];
|
|
int buttons = MB_OK;
|
|
int len = x.why().length();
|
|
|
|
if (!caption)
|
|
caption = "Unhandled Exception";
|
|
if (len)
|
|
strcpy(errorStr, x.why().c_str());
|
|
else {
|
|
strcpy(errorStr, "Unknown Exception");
|
|
len = strlen(errorStr);
|
|
}
|
|
if (canResume) {
|
|
buttons = MB_YESNO;
|
|
errorStr[len] = '\n';
|
|
strcpy(errorStr+len+1, canResume);
|
|
}
|
|
return ::MessageBox(0, errorStr, caption,
|
|
mbModalFlag() | MB_ICONSTOP | buttons) == IDYES ? 0 : -1;
|
|
}
|
|
|
|
//
|
|
// Static member function used to convert a resource id to a 'string'. This
|
|
// is necessary since we must pass a string to the xmsg base class
|
|
// constructor. Sets found to true if the resource was located, otherwise
|
|
// false. In either case, the string is initialized to something
|
|
// printable.
|
|
//
|
|
string
|
|
TXOwl::ResourceIdToString(bool* found, unsigned resId, TModule* module)
|
|
{
|
|
char buf[128];
|
|
|
|
bool status = (module && module->LoadString(resId, buf, sizeof(buf)) != 0);
|
|
if (found)
|
|
*found = status;
|
|
|
|
if (!status)
|
|
wsprintf(buf, "Exception #%u (no message available).", resId);
|
|
|
|
string rscStr(buf);
|
|
return rscStr;
|
|
}
|
|
|
|
TXOwl::TXOwl(const string& msg, uint resId)
|
|
: TXBase(msg), ResId(resId)
|
|
{
|
|
}
|
|
|
|
TXOwl::TXOwl(unsigned resId, TModule* module)
|
|
: TXBase(ResourceIdToString(0, resId, module)),
|
|
ResId(resId)
|
|
{
|
|
}
|
|
|
|
TXOwl::~TXOwl()
|
|
{
|
|
}
|
|
|
|
int
|
|
TXOwl::Unhandled(TModule* app, unsigned promptResId)
|
|
{
|
|
return app->Error(*this, IDS_OWLEXCEPTION, promptResId);
|
|
}
|
|
|
|
TXOwl*
|
|
TXOwl::Clone()
|
|
{
|
|
return new TXOwl(*this);
|
|
}
|
|
|
|
void
|
|
TXOwl::Throw()
|
|
{
|
|
THROW( *this );
|
|
}
|
|
|
|
TXOutOfMemory::TXOutOfMemory()
|
|
:
|
|
TXOwl(IDS_OUTOFMEMORY)
|
|
{
|
|
}
|
|
|
|
TXOutOfMemory::~TXOutOfMemory()
|
|
{
|
|
}
|
|
|
|
TXOutOfMemory*
|
|
TXOutOfMemory::Clone()
|
|
{
|
|
return new TXOutOfMemory(*this);
|
|
}
|
|
|
|
void
|
|
TXOutOfMemory::Throw()
|
|
{
|
|
THROW( *this );
|
|
}
|