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>
157 lines
3.5 KiB
C++
157 lines
3.5 KiB
C++
#pragma once
|
|
|
|
#include "node.h"
|
|
#include "memblock.h"
|
|
|
|
class Chain;
|
|
class ChainIterator;
|
|
|
|
#define CHAINLINK_MEMORYBLOCK_ALLOCATION (100)
|
|
|
|
class ChainLink : public Link
|
|
{
|
|
friend class Chain;
|
|
friend class ChainIterator;
|
|
|
|
public:
|
|
~ChainLink();
|
|
Logical TestInstance() const;
|
|
|
|
private:
|
|
ChainLink(Chain *chain, Plug *plug, ChainLink *nextChainLink, ChainLink *prevChainLink);
|
|
|
|
ChainLink *nextChainLink;
|
|
ChainLink *prevChainLink;
|
|
|
|
private:
|
|
static MemoryBlock* GetAllocatedMemory();
|
|
|
|
void *operator new(size_t) { return GetAllocatedMemory()->New(); }
|
|
void operator delete(void *where) { GetAllocatedMemory()->Delete(where); }
|
|
};
|
|
|
|
class Chain : public Socket
|
|
{
|
|
friend class ChainLink;
|
|
friend class ChainIterator;
|
|
|
|
public:
|
|
Chain(Node *node);
|
|
~Chain();
|
|
|
|
Logical TestInstance() const;
|
|
static Logical TestClass();
|
|
static Logical ProfileClass();
|
|
|
|
protected:
|
|
void AddImplementation(Plug *plug);
|
|
|
|
private:
|
|
ChainLink *InsertChainLink(Plug *plug, ChainLink *current_link);
|
|
|
|
ChainLink *head, *tail;
|
|
};
|
|
|
|
template <class T> class ChainOf : public Chain
|
|
{
|
|
public:
|
|
ChainOf(Node *node);
|
|
~ChainOf();
|
|
|
|
void Add(T plug)
|
|
{
|
|
Chain::AddImplementation(Cast_Object(Plug*, plug));
|
|
}
|
|
};
|
|
|
|
template <class T> ChainOf<T>::ChainOf(Node *node) : Chain(node)
|
|
{
|
|
}
|
|
|
|
template <class T> ChainOf<T>::~ChainOf()
|
|
{
|
|
}
|
|
|
|
class ChainIterator : public SocketIterator
|
|
{
|
|
public:
|
|
ChainIterator(Chain *chain);
|
|
ChainIterator(const ChainIterator &iterator);
|
|
~ChainIterator();
|
|
|
|
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*);
|
|
|
|
ChainLink *currentLink;
|
|
};
|
|
|
|
template <class T> class ChainIteratorOf : public ChainIterator
|
|
{
|
|
public:
|
|
ChainIteratorOf(ChainOf<T> *chain);
|
|
ChainIteratorOf(ChainOf<T> &chain);
|
|
ChainIteratorOf(const ChainIteratorOf<T> &iterator);
|
|
~ChainIteratorOf();
|
|
|
|
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)); }
|
|
|
|
ChainIteratorOf<T>& Begin() { return (ChainIteratorOf<T>&)BeginImplementation(); }
|
|
ChainIteratorOf<T>& End() { return (ChainIteratorOf<T>&)EndImplementation(); }
|
|
ChainIteratorOf<T>& Forward() { return (ChainIteratorOf<T>&)ForwardImplementation(); }
|
|
ChainIteratorOf<T>& Backward() { return (ChainIteratorOf<T>&)BackwardImplementation(); }
|
|
|
|
#if 0
|
|
Logical operator!() { return currentLink == NULL; }
|
|
operator T*() { return GetCurrent(); }
|
|
T* operator->() { return GetCurrent(); }
|
|
T& operator*() { return *GetCurrent(); }
|
|
|
|
ChainIteratorOf<T>& operator++()
|
|
{
|
|
Next();
|
|
return *this;
|
|
}
|
|
|
|
ChainIteratorOf<T>& operator--()
|
|
{
|
|
Previous();
|
|
return *this;
|
|
}
|
|
|
|
T* operator++(int) { return ReadAndNext(); }
|
|
T* operator--(int) { return ReadAndPrevious(); }
|
|
#endif
|
|
};
|
|
|
|
template <class T> ChainIteratorOf<T>::ChainIteratorOf(ChainOf<T> *chain) : ChainIterator(chain)
|
|
{
|
|
}
|
|
|
|
template <class T> ChainIteratorOf<T>::ChainIteratorOf(ChainOf<T> &chain) : ChainIterator(&chain)
|
|
{
|
|
}
|
|
|
|
template <class T> ChainIteratorOf<T>::ChainIteratorOf(const ChainIteratorOf<T> &iterator) : ChainIterator(iterator)
|
|
{
|
|
}
|
|
|
|
template <class T> ChainIteratorOf<T>::~ChainIteratorOf()
|
|
{
|
|
} |