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>
129 lines
2.8 KiB
C++
129 lines
2.8 KiB
C++
#pragma once
|
|
|
|
#include "sfeskt.h"
|
|
#include "memblock.h"
|
|
|
|
#define SCHAINLINK_MEMORYBLOCK_ALLOCATION (100)
|
|
|
|
class SChainLink : public Link
|
|
{
|
|
friend class SChain;
|
|
friend class SChainIterator;
|
|
|
|
public:
|
|
~SChainLink();
|
|
Logical TestInstance() const;
|
|
|
|
private:
|
|
SChainLink(SChain *chain, Plug *plug, SChainLink *nextSChainLink, SChainLink *prevSChainLink);
|
|
|
|
SChainLink *nextSChainLink;
|
|
SChainLink *prevSChainLink;
|
|
|
|
private:
|
|
static MemoryBlock* GetAllocatedMemory();
|
|
|
|
void* operator new(size_t) { return GetAllocatedMemory()->New(); }
|
|
void operator delete(void *where) { return GetAllocatedMemory()->Delete(where); }
|
|
};
|
|
|
|
class SChain : public SafeSocket
|
|
{
|
|
friend class SChainLink;
|
|
friend class SChainIterator;
|
|
|
|
public:
|
|
SChain(Node *node);
|
|
~SChain();
|
|
|
|
Logical TestInstance() const;
|
|
static void TestClass();
|
|
static void ProfileClass();
|
|
|
|
protected:
|
|
void AddImplementation(Plug *plug);
|
|
|
|
private:
|
|
SChainLink* InsertSChainLink(Plug *plug, SChainLink *link);
|
|
|
|
SChainLink *head;
|
|
SChainLink *tail;
|
|
};
|
|
|
|
template <class T> class SChainOf : public SChain
|
|
{
|
|
public:
|
|
SChainOf(Node *node);
|
|
~SChainOf();
|
|
|
|
void Add(T plug) { AddImplementation(Cast_Object(Plug*, plug)); }
|
|
};
|
|
|
|
template <class T> SChainOf<T>::SChainOf(Node *node) : SChain(node)
|
|
{
|
|
}
|
|
|
|
template <class T> SChainOf<T>::~SChainOf()
|
|
{
|
|
}
|
|
|
|
class SChainIterator : public SafeIterator
|
|
{
|
|
public:
|
|
SChainIterator(SChain *chain);
|
|
SChainIterator(const SChainIterator &iterator);
|
|
~SChainIterator();
|
|
|
|
Logical TestInstance() const;
|
|
|
|
void First();
|
|
void Last();
|
|
void Next();
|
|
void Previous();
|
|
CollectionSize GetSize();
|
|
void Remove();
|
|
|
|
protected:
|
|
void* ReadAndNextImplementation();
|
|
void* ReadAndPreviousImplementation();
|
|
void* GetCurrentImplementation();
|
|
void* GetNthImplementation(CollectionSize index);
|
|
void InsertImplementation(Plug *plug);
|
|
|
|
private:
|
|
void ReceiveMemo(IteratorMemo memo, void *content);
|
|
|
|
SChainLink *currentLink;
|
|
};
|
|
|
|
template <class T> class SChainIteratorOf : public SChainIterator
|
|
{
|
|
public:
|
|
SChainIteratorOf(SChainOf<T> *chain);
|
|
SChainIteratorOf(SChainOf<T> &chain);
|
|
SChainIteratorOf(const SChainIteratorOf<T> &iterator);
|
|
|
|
~SChainIteratorOf();
|
|
|
|
T ReadAndNext() { return (T)ReadAndNextImplementation(); }
|
|
T ReadAndPrevious() { return (T)ReadAndPreviousImplementation(); }
|
|
T GetCurrent() { return (T)GetCurrentImplementation(); }
|
|
T GetNth(CollectionSize index) { return (T)GetNthImplementation(index); }
|
|
void Insert(T plug) { InsertImplementation(Cast_Object(Plug*, plug)); }
|
|
};
|
|
|
|
template <class T> SChainIteratorOf<T>::SChainIteratorOf(SChainOf<T> *chain) : SChainIterator(chain)
|
|
{
|
|
}
|
|
|
|
template <class T> SChainIteratorOf<T>::SChainIteratorOf(SChainOf<T> &chain) : SChainIterator(&chain)
|
|
{
|
|
}
|
|
|
|
template <class T> SChainIteratorOf<T>::SChainIteratorOf(const SChainIteratorOf<T> &iterator) : SChainIterator(iterator)
|
|
{
|
|
}
|
|
|
|
template <class T> SChainIteratorOf<T>::~SChainIteratorOf()
|
|
{
|
|
} |