Initial import of Red Planet v4.10 Win32 source
Imports the current Win32 source for the pod-racing game 'Red Planet', built on the MUNGA engine and its L4 (Win32/DirectX) platform layer: - MUNGA / MUNGA_L4: cross-platform engine core and Win32 backend - RP / RP_L4: Red Planet game logic and Win32 application - DivLoader, Setup1: asset loader and installer project - lib, MUNGA_L4/openal, MUNGA_L4/sos: third-party audio dependencies Removed stale Subversion metadata and added .gitignore/.gitattributes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+311
@@ -0,0 +1,311 @@
|
||||
#pragma once
|
||||
|
||||
#include "cmpnnt.h"
|
||||
#include "slot.h"
|
||||
#include "memstrm.h"
|
||||
|
||||
class PlugStream;
|
||||
class Simulation;
|
||||
class Entity;
|
||||
|
||||
//##########################################################################
|
||||
//########################### AttributeWatcher #######################
|
||||
//##########################################################################
|
||||
|
||||
class AttributeWatcher:
|
||||
public Component
|
||||
{
|
||||
public:
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// Destructor
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
~AttributeWatcher();
|
||||
|
||||
Logical
|
||||
TestInstance() const;
|
||||
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// DidAttributeChange
|
||||
//
|
||||
// Returns True if attribute has changed since the last time
|
||||
// DidAttributeChange was called.
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
Logical
|
||||
DidAttributeChange();
|
||||
|
||||
protected:
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// Constructor
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
AttributeWatcher(
|
||||
PlugStream *stream,
|
||||
Entity *entity
|
||||
);
|
||||
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// SendNotificationOfChange
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
virtual void
|
||||
SendNotificationOfChange();
|
||||
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// BuildFromPage
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
static void
|
||||
BuildFromPage(
|
||||
PlugStream *stream,
|
||||
NameList *name_list,
|
||||
ClassID class_ID,
|
||||
ObjectID object_ID
|
||||
);
|
||||
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// Protected data
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
Simulation*
|
||||
simulation;
|
||||
void*
|
||||
attributePointer;
|
||||
Logical
|
||||
attributeChanged;
|
||||
Logical
|
||||
sendNotificationOnChange;
|
||||
};
|
||||
|
||||
//##########################################################################
|
||||
//########################### AttributeWatcherOf #####################
|
||||
//##########################################################################
|
||||
|
||||
template <class T> class AttributeWatcherOf:
|
||||
public AttributeWatcher
|
||||
{
|
||||
public:
|
||||
~AttributeWatcherOf();
|
||||
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// Accessors
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
T
|
||||
GetCurrentValue()
|
||||
{return currentValue;}
|
||||
T*
|
||||
GetCurrentPointer()
|
||||
{return ¤tValue;}
|
||||
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// Execute
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
void
|
||||
Execute();
|
||||
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// PrimeWatcher
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
void
|
||||
PrimeWatcher();
|
||||
|
||||
protected:
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// Constructor
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
AttributeWatcherOf(
|
||||
PlugStream *stream,
|
||||
Entity *entity
|
||||
);
|
||||
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// BuildFromPage
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
static void
|
||||
BuildFromPage(
|
||||
PlugStream *stream,
|
||||
NameList *name_list,
|
||||
ClassID class_ID,
|
||||
ObjectID object_ID
|
||||
);
|
||||
|
||||
private:
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// InitializeCurrentValue
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
void
|
||||
InitializeCurrentValue();
|
||||
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// GrabCurrentValue
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
void
|
||||
GrabCurrentValue();
|
||||
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// DumpValue
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
virtual void
|
||||
DumpValue(const T *attribute_ptr);
|
||||
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
// Private data
|
||||
//-----------------------------------------------------------------------
|
||||
//
|
||||
T
|
||||
currentValue;
|
||||
#if DEBUG_LEVEL>0
|
||||
Logical
|
||||
dumpValue;
|
||||
#endif
|
||||
};
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~ AttributeWatcherOf templates ~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
template <class T>
|
||||
AttributeWatcherOf<T>::~AttributeWatcherOf()
|
||||
{
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
template <class T>
|
||||
AttributeWatcherOf<T>::AttributeWatcherOf(
|
||||
PlugStream *stream,
|
||||
Entity *entity
|
||||
):
|
||||
AttributeWatcher(stream, entity)
|
||||
{
|
||||
Check_Pointer(this);
|
||||
|
||||
Logical dump_value;
|
||||
|
||||
MemoryStream_Read(stream, &dump_value);
|
||||
|
||||
#if DEBUG_LEVEL>0
|
||||
dumpValue = dump_value;
|
||||
if (dumpValue)
|
||||
{
|
||||
Tell(
|
||||
"AttributeWatcherOf<T>::AttributeWatcherOf - " <<
|
||||
*(T*)attributePointer <<
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
InitializeCurrentValue();
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
template <class T> void
|
||||
AttributeWatcherOf<T>::BuildFromPage(
|
||||
PlugStream *stream,
|
||||
NameList *name_list,
|
||||
ClassID class_ID,
|
||||
ObjectID object_ID
|
||||
)
|
||||
{
|
||||
Check(stream);
|
||||
Check(name_list);
|
||||
|
||||
AttributeWatcher::BuildFromPage(stream, name_list, class_ID, object_ID);
|
||||
|
||||
//
|
||||
// Store dump_value
|
||||
//
|
||||
MEM_STRM_WRITE_ENTRY(*stream, name_list, Logical, dump_value);
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
template <class T> void
|
||||
AttributeWatcherOf<T>::PrimeWatcher()
|
||||
{
|
||||
Check(this);
|
||||
#if DEBUG_LEVEL>0
|
||||
if (dumpValue)
|
||||
{
|
||||
DumpValue((T*)attributePointer);
|
||||
}
|
||||
#endif
|
||||
GrabCurrentValue();
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
template <class T> void
|
||||
AttributeWatcherOf<T>::Execute()
|
||||
{
|
||||
Check(this);
|
||||
|
||||
Check_Pointer(attributePointer);
|
||||
if (!(currentValue == *(T*)attributePointer))
|
||||
{
|
||||
#if DEBUG_LEVEL>0
|
||||
if (dumpValue)
|
||||
{
|
||||
DumpValue((T*)attributePointer);
|
||||
}
|
||||
#endif
|
||||
GrabCurrentValue();
|
||||
}
|
||||
Check_Fpu();
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
template <class T> void
|
||||
AttributeWatcherOf<T>::InitializeCurrentValue()
|
||||
{
|
||||
Check_Pointer(attributePointer);
|
||||
currentValue = *(T*)attributePointer;
|
||||
Verify(currentValue == *(T*)attributePointer);
|
||||
Check_Fpu();
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
template <class T> void
|
||||
AttributeWatcherOf<T>::GrabCurrentValue()
|
||||
{
|
||||
InitializeCurrentValue();
|
||||
attributeChanged = True;
|
||||
if (sendNotificationOnChange)
|
||||
{
|
||||
SendNotificationOfChange();
|
||||
}
|
||||
}
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
#if DEBUG_LEVEL>0
|
||||
template <class T> void
|
||||
AttributeWatcherOf<T>::DumpValue(const T *attribute_ptr)
|
||||
#else
|
||||
template <class T> void
|
||||
AttributeWatcherOf<T>::DumpValue(const T*)
|
||||
#endif
|
||||
{
|
||||
Check_Pointer(attribute_ptr);
|
||||
Tell((void *)attribute_ptr << " = " << *attribute_ptr << "\n");
|
||||
}
|
||||
Reference in New Issue
Block a user