Files
CydandClaude Fable 5 fdd9ac9d97 Initial import: Tesla Release 4.10 (Tesla:BattleTech & Tesla:Red Planet)
Archival snapshot of the Virtual World Entertainment Tesla cockpit
software, 1994-1996: MUNGA engine and L4 pod layer source (Borland
C++ 5.0), BT/RP game code, and game content (models, audio, maps,
gauges, Division renderer data). Includes third-party libraries:
Division dVS/DPL graphics, HMI SOS audio, WATTCP networking.

Files are preserved byte-for-byte (.gitattributes disables all
line-ending conversion). README.md documents the layout, target
hardware, and toolchain.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-02 13:21:58 -05:00

355 lines
9.7 KiB
C++

//===========================================================================//
// File: hash.hh //
// Project: MUNGA Brick: Connection Library //
// Contents: //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// 12/15/94 ECH Initial coding. //
//---------------------------------------------------------------------------//
// Copyright (C) 1994-1995, Virtual World Entertainment, Inc. //
// PROPRIETARY AND CONFIDENTIAL //
//===========================================================================//
#if !defined(HASH_HPP)
# define HASH_HPP
# if !defined(SRTSKT_HPP)
# include <srtskt.hpp>
# endif
# if !defined(VCHAIN_HPP)
# include <vchain.hpp>
# endif
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ Hash ~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Hash:
public SortedSocket
{
friend class HashIterator;
public:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Public interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
//
//--------------------------------------------------------------------
// Constructor, Destructor and Testing
//--------------------------------------------------------------------
//
Hash(
CollectionSize size,
Node *node,
Logical has_unique_entries
);
~Hash();
Logical
TestInstance() const;
static Logical
TestClass();
static Logical
ProfileClass();
protected:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Protected interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
void
AddImplementation(Plug *plug);
void
AddValueImplementation(
Plug *plug,
const void *value
);
Plug
*FindImplementation(const void *value);
//
//--------------------------------------------------------------------
// Protected data
//--------------------------------------------------------------------
//
VChain **hashTable;
CollectionSize hashTableSize;
private:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Private interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
virtual VChain*
MakeVChain();
virtual IteratorPosition
GetHashIndex(const void *value);
void
BuildHashTable();
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ HashOf ~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class T, class V> class HashOf:
public Hash
{
public:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Public interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
HashOf(
CollectionSize size,
Node *node,
Logical has_unique_entries
);
~HashOf();
//
//--------------------------------------------------------------------
// Socket methods (see Socket for full listing)
//--------------------------------------------------------------------
//
void
AddValue(
T plug,
const V &value
)
{AddValueImplementation(Cast_Object(Plug*,plug), &value);}
T
Find(const V &value)
{return (T)FindImplementation(&value);}
private:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Private interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
VChain*
MakeVChain();
IteratorPosition
GetHashIndex(const void *value);
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ HashOf templates ~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class T, class V>
HashOf<T, V>::HashOf(
CollectionSize size,
Node *node,
Logical has_unique_entries
):
Hash(
size,
node,
has_unique_entries
)
{
}
template <class T, class V>
HashOf<T, V>::~HashOf()
{
}
template <class T, class V> VChain*
HashOf<T, V>::MakeVChain()
{
return new VChainOf<T, V>(GetReleaseNode(), HasUniqueEntries());
}
template <class T, class V> IteratorPosition
HashOf<T, V>::GetHashIndex(const void *value)
{
Check_Pointer(value);
return (IteratorPosition(*(V*)value) % hashTableSize);
// return ((IteratorPosition)*(V*)value % hashTableSize);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ HashIterator ~~~~~~~~~~~~~~~~~~~~~~~~~~~
class HashIterator:
public SortedIterator
{
public:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Public interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
//
//--------------------------------------------------------------------
// Constructors, Destructor and testing
//--------------------------------------------------------------------
//
HashIterator(Hash *hash);
~HashIterator();
Logical
TestInstance() const;
//
//--------------------------------------------------------------------
// Iterator methods (see Iterator for full listing)
//--------------------------------------------------------------------
//
void
First();
void
Last();
void
Next();
void
Previous();
CollectionSize
GetSize();
void
Remove();
protected:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Protected interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
#if 0
void*
ReadAndNextImplementation();
void*
ReadAndPreviousImplementation();
#endif
void*
GetCurrentImplementation();
#if 0
void*
GetNthImplementation(CollectionSize index);
#endif
Plug*
FindImplementation(const void *value);
private:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Private interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
void
ReceiveMemo(
IteratorMemo memo,
void *content
);
void
DeleteVChainIterator();
void
NextVChainIterator(IteratorPosition index);
//
//--------------------------------------------------------------------
// Private data
//--------------------------------------------------------------------
//
VChain
**hashTable;
CollectionSize
hashTableSize;
IteratorPosition
currentPosition;
VChainIterator
*vchainIterator;
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ HashIteratorOf ~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class T, class V> class HashIteratorOf:
public HashIterator
{
public:
//
//--------------------------------------------------------------------
//--------------------------------------------------------------------
// Public interface
//--------------------------------------------------------------------
//--------------------------------------------------------------------
//
//
//--------------------------------------------------------------------
// Constructors and Destructor
//--------------------------------------------------------------------
//
HashIteratorOf(HashOf<T, V> *hash);
HashIteratorOf(HashOf<T, V> &hash);
~HashIteratorOf();
//
//--------------------------------------------------------------------
// Iterator methods (see Iterator for full listing)
//--------------------------------------------------------------------
//
T
ReadAndNext()
{return (T)ReadAndNextImplementation();}
T
ReadAndPrevious()
{return (T)ReadAndPreviousImplementation();}
T
GetCurrent()
{return (T)GetCurrentImplementation();}
T
GetNth(CollectionSize index)
{return (T)GetNthImplementation(index);}
T
Find(const V &value)
{return (T)FindImplementation(&value);}
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ HashIteratorOf templates ~~~~~~~~~~~~~~~~~~~~~~~~~~~
template <class T, class V>
HashIteratorOf<T, V>::HashIteratorOf(HashOf<T, V> *hash):
HashIterator(hash)
{
}
template <class T, class V>
HashIteratorOf<T, V>::HashIteratorOf(HashOf<T, V> &hash):
HashIterator(&hash)
{
}
template <class T, class V>
HashIteratorOf<T, V>::~HashIteratorOf()
{
}
#endif