Clean, self-contained extraction of the BattleTech-specific work from the
reverse-engineering workspace -- engine + game + content + build, with nothing
from Red Planet or the raw archive dumps. Builds green (Win32) and runs the
single-player drive->animate->target->fire->damage->destroy loop out of the box.
Layout:
engine/ MUNGA + MUNGA_L4 shared 2007 engine, carrying our BT render/loader
work (bgfload/L4D3D/L4VIDEO: BSL bit-slice decode, LOD/ground/shadow
models) + image codec; the minimal rp/ headers the audio HAL needs
game/ reconstructed BT logic + surviving-original BT source + fwd shims
+ WinMain launcher
content/ full runtime tree (BTL4.RES, VIDEO/, GAUGE/, AUDIO/, eggs, BTDPL.INI)
docs/ format specs + reconstruction ledgers
reference/ raw Ghidra pseudocode (recon source-of-truth) + decomp exporter
tools/ MP console emulator + map/resource scanners
One top-level CMake builds munga_engine lib + bt410_l4 game lib + btl4.exe.
All paths relativized (186 fwd shims + ~437 CMake abs paths -> repo-relative);
DXSDK is the one external, overridable via -DDXSDK. Verified: builds to a
byte-identical 2.27MB exe and runs combat (TARGET DESTROYED, 0 crashes) against
the bundled content.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
168 lines
3.1 KiB
C++
168 lines
3.1 KiB
C++
#include "munga.h"
|
|
#pragma hdrstop
|
|
|
|
#include "wrhous.h"
|
|
|
|
// #define LOCAL_TEST
|
|
|
|
#if defined(LOCAL_TEST)
|
|
# define Test_Tell(n) DEBUG_STREAM << n
|
|
#else
|
|
# define Test_Tell(n)
|
|
#endif
|
|
|
|
//#######################################################################
|
|
// WarehouseObject
|
|
//#######################################################################
|
|
WarehouseObject::WarehouseObject(
|
|
const char *new_name,
|
|
Logical keep_forever
|
|
):
|
|
Plug(WarehouseObject::WarehouseObjectClassID)
|
|
{
|
|
Test_Tell("WarehouseObject::WarehouseObject(" << new_name << "\n");
|
|
Str_Copy(name, new_name, sizeof(name));
|
|
resourceID = ResourceDescription::NullResourceType;
|
|
|
|
referenceCount = 1; // at least one reference exists, otherwise no obj
|
|
keepForever = keep_forever;
|
|
Check_Fpu();
|
|
}
|
|
|
|
WarehouseObject::WarehouseObject(
|
|
ResourceDescription::ResourceID new_resource_id,
|
|
Logical keep_forever
|
|
):
|
|
Plug(WarehouseObject::WarehouseObjectClassID)
|
|
{
|
|
Test_Tell("WarehouseObject::WarehouseObject(" << new_resource_id << "\n");
|
|
name[0] = '\0';
|
|
resourceID = new_resource_id;
|
|
|
|
referenceCount = 1; // at least one reference exists, otherwise no obj
|
|
keepForever = keep_forever;
|
|
Check_Fpu();
|
|
}
|
|
|
|
WarehouseObject::~WarehouseObject()
|
|
{
|
|
Check(this);
|
|
Check_Fpu();
|
|
}
|
|
|
|
Logical
|
|
WarehouseObject::TestInstance() const
|
|
{
|
|
return True;
|
|
}
|
|
|
|
//#######################################################################
|
|
// WarehouseBin
|
|
//#######################################################################
|
|
WarehouseBin::WarehouseBin() :
|
|
Node(WarehouseBin::WarehouseBinClassID),
|
|
instanceList(this)
|
|
{
|
|
Test_Tell("WarehouseBin::WarehouseBin()\n");
|
|
Check_Pointer(this);
|
|
|
|
Check_Fpu();
|
|
}
|
|
|
|
WarehouseBin::~WarehouseBin()
|
|
{
|
|
Check(this);
|
|
}
|
|
|
|
Logical
|
|
WarehouseBin::TestInstance() const
|
|
{
|
|
return True;
|
|
}
|
|
|
|
WarehouseObject *
|
|
WarehouseBin::Find(const char *old_name)
|
|
{
|
|
Check(this);
|
|
|
|
ChainIteratorOf<WarehouseObject*>
|
|
i(instanceList);
|
|
|
|
WarehouseObject
|
|
*object_instance;
|
|
|
|
while ((object_instance=i.ReadAndNext()) != NULL)
|
|
{
|
|
Check(object_instance);
|
|
if (stricmp(object_instance->name, old_name) == 0)
|
|
{
|
|
Check_Fpu();
|
|
return object_instance;
|
|
}
|
|
}
|
|
Check_Fpu();
|
|
return NULL;
|
|
}
|
|
|
|
WarehouseObject *
|
|
WarehouseBin::Find(ResourceDescription::ResourceID old_resource_id)
|
|
{
|
|
Check(this);
|
|
|
|
ChainIteratorOf<WarehouseObject*>
|
|
i(instanceList);
|
|
|
|
WarehouseObject
|
|
*object_instance;
|
|
|
|
while ((object_instance=i.ReadAndNext()) != NULL)
|
|
{
|
|
Check(object_instance);
|
|
if (object_instance->resourceID == old_resource_id)
|
|
{
|
|
Check_Fpu();
|
|
return object_instance;
|
|
}
|
|
}
|
|
Check_Fpu();
|
|
return NULL;
|
|
}
|
|
|
|
//#######################################################################
|
|
// Warehouse
|
|
//#######################################################################
|
|
Warehouse::Warehouse()
|
|
{
|
|
Test_Tell("Warehouse::Warehouse\n");
|
|
Check_Pointer(this);
|
|
}
|
|
|
|
Warehouse::~Warehouse()
|
|
{
|
|
Test_Tell("Warehouse::~Warehouse\n");
|
|
Check(this);
|
|
Purge();
|
|
Check_Fpu();
|
|
}
|
|
|
|
void
|
|
Warehouse::Purge()
|
|
{
|
|
Check(this);
|
|
|
|
bitMapBin.Purge();
|
|
pixelMap8Bin.Purge();
|
|
palette8Bin.Purge();
|
|
|
|
Check_Fpu();
|
|
}
|
|
|
|
|
|
Logical
|
|
Warehouse::TestInstance() const
|
|
{
|
|
Check_Pointer(this);
|
|
return True;
|
|
}
|
|
|