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>
186 lines
3.7 KiB
C++
186 lines
3.7 KiB
C++
#include "munga.h"
|
|
#pragma hdrstop
|
|
|
|
#include "apptask.h"
|
|
#include "renderer.h"
|
|
#include "audrend.h"
|
|
#include "app.h"
|
|
#include "nttmgr.h"
|
|
#include "gaugrend.h"
|
|
|
|
#if defined(TRACE_COMPLETE_CYCLES)
|
|
BitTrace Complete_Cycles("Complete Cycles");
|
|
#endif
|
|
|
|
#if defined(TRACE_DEATH_ROW)
|
|
BitTrace Death_Row("Death Row");
|
|
#endif
|
|
|
|
//#############################################################################
|
|
//########################### ApplicationTask ###########################
|
|
//#############################################################################
|
|
|
|
ApplicationTask::ApplicationTask(ClassID class_ID):
|
|
Component(class_ID)
|
|
{
|
|
}
|
|
|
|
ApplicationTask::~ApplicationTask()
|
|
{
|
|
}
|
|
|
|
//#############################################################################
|
|
//########################### BackgroundTasks ###########################
|
|
//#############################################################################
|
|
|
|
BackgroundTasks::BackgroundTasks():
|
|
taskSocket(NULL)
|
|
{
|
|
taskIterator = new SChainIteratorOf<ApplicationTask*>(&taskSocket);
|
|
Register_Object(taskIterator);
|
|
}
|
|
|
|
BackgroundTasks::~BackgroundTasks()
|
|
{
|
|
Check(taskIterator);
|
|
taskIterator->DeletePlugs();
|
|
Unregister_Object(taskIterator);
|
|
delete taskIterator;
|
|
}
|
|
|
|
Logical
|
|
BackgroundTasks::TestInstance() const
|
|
{
|
|
Component::TestInstance();
|
|
Check(&taskSocket);
|
|
Check(taskIterator);
|
|
return True;
|
|
}
|
|
|
|
void
|
|
BackgroundTasks::AddTask(ApplicationTask *task)
|
|
{
|
|
Check(this);
|
|
Check(task);
|
|
taskSocket.Add(task);
|
|
}
|
|
|
|
void
|
|
BackgroundTasks::Execute()
|
|
{
|
|
Check(this);
|
|
|
|
Check(taskIterator);
|
|
if (taskIterator->GetCurrent() == NULL)
|
|
{
|
|
taskIterator->First();
|
|
}
|
|
|
|
ApplicationTask *task = taskIterator->GetCurrent();
|
|
Check(task);
|
|
|
|
task->Execute();
|
|
taskIterator->Next();
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~ NetworkManagerTask ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
void
|
|
NetworkManagerTask::Execute()
|
|
{
|
|
Check(this);
|
|
Check(application);
|
|
Check(application->GetNetworkManager());
|
|
|
|
Time start = Now();
|
|
|
|
application->GetNetworkManager()->ExecuteBackground();
|
|
|
|
Time end = Now();
|
|
|
|
if (end.ticks - start.ticks > 10)
|
|
{
|
|
end = start;
|
|
}
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~ RoutePacketTask ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
void
|
|
RoutePacketTask::Execute()
|
|
{
|
|
Check(this);
|
|
|
|
Check(application);
|
|
Check(application->GetNetworkManager());
|
|
application->GetNetworkManager()->RoutePacket();
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ProcessEventTask ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
void
|
|
ProcessEventTask::Execute()
|
|
{
|
|
Check(this);
|
|
Check(application);
|
|
application->ProcessOneEvent();
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~ AudioRendererTask ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
void
|
|
AudioRendererTask::Execute()
|
|
{
|
|
Check(this);
|
|
Check(application);
|
|
if (application->GetAudioRenderer() != NULL)
|
|
{
|
|
Check(application->GetAudioRenderer());
|
|
application->GetAudioRenderer()->ExecuteBackground();
|
|
}
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~ GaugeRendererTask ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
void
|
|
GaugeRendererTask::Execute()
|
|
{
|
|
Check(this);
|
|
Check(application);
|
|
if (application->GetGaugeRenderer() != NULL)
|
|
{
|
|
Check(application->GetGaugeRenderer());
|
|
application->GetGaugeRenderer()->ExecuteBackground();
|
|
}
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ CompleteCyclesTask ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
void
|
|
CompleteCyclesTask::Execute()
|
|
{
|
|
SET_COMPLETE_CYCLES();
|
|
|
|
Check(this);
|
|
Check(application);
|
|
Check(application->GetRendererManager());
|
|
// application->GetRendererManager()->CompleteCycles();
|
|
|
|
CLEAR_COMPLETE_CYCLES();
|
|
}
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FryDeathRowTask ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
void
|
|
FryDeathRowTask::Execute()
|
|
{
|
|
SET_DEATH_ROW();
|
|
|
|
Check(this);
|
|
Check(application);
|
|
Check(application->GetEntityManager());
|
|
application->GetEntityManager()->FryDeathRow();
|
|
|
|
CLEAR_DEATH_ROW();
|
|
}
|