Quake 4 integrated with DoomRTX

This commit is contained in:
Justin Marshall
2026-05-09 22:10:40 -07:00
parent 8c4a087aa9
commit d37f87e493
436 changed files with 277587 additions and 10254 deletions
+64
View File
@@ -0,0 +1,64 @@
#ifndef __AUTOPTR_H__
#define __AUTOPTR_H__
// this class is NOT safe for array new's. It will not properly call
// the destructor for each element and you will silently leak memory.
// it does work for classes requiring no destructor however(base types)
template<typename type>
class idAutoPtr
{
public:
explicit idAutoPtr(type* ptr = 0)
: mPtr(ptr)
{
}
~idAutoPtr()
{
delete mPtr;
}
type& operator*() const
{
return *mPtr;
}
type* operator->() const
{
return &**this;
}
type* get() const
{
return mPtr;
}
type* release()
{
type* ptr = mPtr;
mPtr = NULL;
return ptr;
}
void reset(type* ptr = NULL)
{
if (ptr != mPtr)
delete mPtr;
mPtr = ptr;
}
operator type* ()
{
return get();
}
private:
// disallow copies
idAutoPtr<type>& operator=(idAutoPtr<type>& ptr);
idAutoPtr(idAutoPtr<type>& ptr);
type* mPtr;
};
#endif
+53
View File
@@ -0,0 +1,53 @@
#include "precompiled.h"
#pragma hdrstop
#include "LexerFactory.h"
LexerFactory::~LexerFactory()
{
}
Lexer *LexerFactory::MakeLexer(char const * const filename, int flags, bool OSPath)
{
return new Lexer(filename, flags | GetReadBinary() | GetWriteBinary(), OSPath);
}
Lexer *LexerFactory::MakeLexer(int flags)
{
return new Lexer(flags | GetReadBinary() | GetWriteBinary());
}
Lexer *LexerFactory::MakeLexer( char const * const ptr, int length, char const * const name, int flags)
{
return new Lexer(ptr, length, name, flags | GetWriteBinary() | GetReadBinary());
}
int LexerFactory::GetReadBinary()
{
if(cvarSystem->GetCVarBool("com_binaryRead"))
{
return LEXFL_READBINARY;
}
else
{
return 0;
}
}
int LexerFactory::GetWriteBinary()
{
int ret=0;
int writeBinary = cvarSystem->GetCVarInteger("com_binaryWrite");
switch(writeBinary)
{
case 0:
break;
case 1:
ret = LEXFL_WRITEBINARY;
break;
case 2:
ret = LEXFL_WRITEBINARY | LEXFL_BYTESWAP;
break;
}
return ret;
}
+21
View File
@@ -0,0 +1,21 @@
#ifndef __LEXERFACTORY_H__
#define __LEXERFACTORY_H__
class LexerFactory
{
public:
static Lexer *MakeLexer( int flags );
static Lexer *MakeLexer( char const * const filename, int flags = 0, bool OSPath = false );
static Lexer *MakeLexer( char const * const ptr, int length, char const * const name, int flags = 0 );
private:
static int GetReadBinary();
static int GetWriteBinary();
// disallow default constructor
LexerFactory();
~LexerFactory();
};
#endif
+51
View File
@@ -0,0 +1,51 @@
#pragma once
#include "../framework/DeclMatType.h"
#include "../framework/DeclPlayback.h"
#include "../framework/DeclPlayerModel.h"
#include "../framework/DeclLipSync.h"
class ThreadedAlloc;
#define RV_USE_CRITICALSECTION
#include "containers/Pair.h"
#include "LexerFactory.h"
#include "AutoPtr.h"
#include "threads/AutoCrit.h"
#define RV_PUSH_SYS_HEAP_ID(sysHeapID)
#define RV_PUSH_SYS_HEAP_ID_AUTO(varName,sysHeapID)
#define RV_PUSH_HEAP_MEM(memPtr)
#define RV_PUSH_HEAP_MEM_AUTO(varName,memPtr)
#define RV_PUSH_HEAP_PTR(heapPtr)
#define RV_POP_HEAP()
#define RV_PUSH_SYS_HEAP_ENTER_CRIT_SECT(sysHeapID)
#define RV_PUSH_HEAP_ENTER_CRIT_SECT(heapPtr)
#define RV_POP_HEAP_EXIT_CRIT_SECT()
#define STRINGIZE_INDIRECT(F, X) F(X)
#define STRINGIZE(X) #X
#define __LINESTR__ STRINGIZE_INDIRECT(STRINGIZE, __LINE__)
#define __FILELINEFUNC__ (__FILE__ " " __LINESTR__ " " __FUNCTION__)
#define __FUNCLINE__ ( __FUNCTION__ " " __LINESTR__ )
#define TIME_THIS_SCOPE(name)
#define MemScopedTag_GetTopTag() MA_OPNEW
#define MEM_SCOPED_TAG(var, tag)
#define MEM_SCOPED_TAG_SET(var, tag)
#define PC_CVAR_ARCHIVE CVAR_ARCHIVE
#if defined(_DEBUG)
#define GAME_BUILD_TYPE "Debug"
#elif defined(_MPBETA)
#define GAME_BUILD_TYPE "MPBeta"
#elif defined(_FINAL)
#define GAME_BUILD_TYPE ""
#elif defined(_RELEASE)
#define GAME_BUILD_TYPE ""
#endif
+33
View File
@@ -0,0 +1,33 @@
#ifndef __LIST_GAME_H__
#define __LIST_GAME_H__
#if 0
// GCC 4 compiles templates when they are encountered in a source file,
// not when they are used. Therefore all references, must be resolved.
// RemoveContents() from idLib\List.h references global variables only
// available in the GAME DLL.
/*
================
idList<type>::RemoveContents
================
*/
template< class type >
ID_INLINE void idList<type>::RemoveContents( bool clear ) {
RemoveNull();
for( int ix = Num() - 1; ix >= 0; --ix ) {
list[ ix ]->PostEventMS( &EV_Remove, 0 );
list[ ix ] = NULL;
}
if ( clear ) {
Clear();
} else {
memset( list, 0, Allocated() );
}
}
#endif
#endif // __LIST_GAME_H__
+58
View File
@@ -0,0 +1,58 @@
//----------------------------------------------------------------
// Pair.cpp
//
// Copyright 2002-2004 Raven Software
//----------------------------------------------------------------
#ifndef __PAIR_H__
#define __PAIR_H__
template< class type1, class type2 >
class rvPair {
public:
rvPair() {};
rvPair( const type1& T1, const type2& T2 ) { first = T1; second = T2; };
const type1& First( void ) const { return first; };
const type2& Second( void ) const { return second; };
static int rvPairFirstCompare( const rvPair< type1, type2 > *a, const rvPair< type1, type2 > *b ) {
return b->First() - a->First();
}
static int rvPairSecondCompare( const rvPair< type1, type2 > *a, const rvPair< type1, type2 > *b ) {
return b->Second() - a->Second();
}
static int rvPairFirstCompareDirect( const rvPair< type1, type2 > *a, const rvPair< type1, type2 > *b ) {
if( b->First() - a->First() < 0.001f || b->First() - a->First() < -0.001f ) {
return 0;
}
if( a->First() > b->First() ) {
return -1;
} else if( a->First() < b->First() ) {
return 1;
}
return 0;
}
static int rvPairSecondCompareDirect( const rvPair< type1, type2 > *a, const rvPair< type1, type2 > *b ) {
if( b->Second() - a->Second() < 0.001f || b->Second() - a->Second() < -0.001f ) {
return 0;
}
if( a->Second() > b->Second() ) {
return -1;
} else if( a->Second() < b->Second() ) {
return 1;
}
return 0;
}
private:
type1 first;
type2 second;
};
#endif
+222
View File
@@ -0,0 +1,222 @@
#ifndef __AUTOCRIT_H__
#define __AUTOCRIT_H__
#ifdef RV_USE_CRITICALSECTION
// This class eliminates the need to figure out where to call InitializeCriticalSection
// and DeleteCriticalSection. It makes critical sections into a meaningful class. More
// importantly, now when they are created as statics, they are already initialized, so
// the AutoCrit doesn't have to worry about checking to see if they've been initialized yet
class CriticalSection
{
public:
ID_INLINE CriticalSection()
{
InitializeCriticalSection(&mCrit);
}
ID_INLINE ~CriticalSection()
{
DeleteCriticalSection(&mCrit);
}
ID_INLINE void Enter()
{
while(!Try())
{
Sleep(0); // give another thread a chance to run to try to eliminate deadlock
}
}
ID_INLINE void Leave()
{
LeaveCriticalSection(&mCrit);
}
ID_INLINE bool Try()
{
return TryEnterCriticalSection(&mCrit) != 0;
}
private:
CRITICAL_SECTION mCrit;
};
#endif
#ifdef RV_USE_AUTOCRIT
// Enters a critical section unique to the type of object t on construction
// Exits that critical section on destruction. Effectively synchronizes calls
// to ANY instance of type t
template <typename t>
class AutoCrit
{
public:
ID_INLINE AutoCrit()
{
sCrit.Enter();
}
ID_INLINE ~AutoCrit()
{
sCrit.Leave();
}
private:
static CriticalSection sCrit;
};
template<typename t>
CriticalSection AutoCrit<t>::sCrit;
template <typename t>
class ConditionalAutoCrit
{
public:
ID_INLINE ConditionalAutoCrit()
{
if(sThreading)
{
sCrit.Enter();
mMustLeave = true;
}
else
{
mMustLeave = false;
}
}
ID_INLINE ~ConditionalAutoCrit()
{
if(mMustLeave)
{
sCrit.Leave();
}
}
static ID_INLINE SetThreading(bool threading)
{
// not threadsafe...must be called BEFORE entering and AFTER leaving a threaded section, not during
sThreading = threading;
}
static ID_INLINE bool IsThreading()
{
return sThreading;
}
private:
static bool sThreading;
static CriticalSection sCrit;
bool mMustLeave;
};
template<typename t>
CriticalSection ConditionalAutoCrit<t>::sCrit;
template<typename t>
bool ConditionalAutoCrit<t>::sThreading=false;
#else
// these compile out completely in release and removes the need
// for ifdefs all over the code
template <typename t>
class AutoCrit
{
public:
AutoCrit() { }
~AutoCrit() { }
};
template <typename t>
class ConditionalAutoCrit
{
public:
ConditionalAutoCrit() { }
~ConditionalAutoCrit() { }
};
#endif
#ifdef RV_USE_AUTOINSTANCECRIT
class CritInfo
{
public:
ID_INLINE CritInfo() { refCount = 0; }
int refCount;
CriticalSection crit;
};
// Enters a critical section unique to the specific instance of an object of type t on construction
// Exits that critical section on destruction. This is templated instead of using void * in order
// to reduce search time when entering and leaving. Effectively synchronizes on a single instance
// of an object. This would allow containers for example to not be synchronized to other containers
// of the same type.
template<typename t>
class AutoInstanceCrit
{
public:
ID_INLINE AutoInstanceCrit(t *ptr)
{
CritInfo *critPtr = NULL;
//AutoCrit<AutoInstanceCrit<t> > crit; // protect access to the map
critSect.Enter();
mPtr = ptr;
int i = sPtrs.FindIndex(mPtr);
if(i == -1) // not found
{
i = sPtrs.Num();
sPtrs.Append(mPtr);
sInfos.Append(CritInfo());
}
critPtr = &(sInfos[i]);
critPtr->refCount++;
critSect.Leave();
critPtr->crit.Enter();
}
ID_INLINE ~AutoInstanceCrit()
{
CritInfo *critPtr = NULL;
{
//AutoCrit<AutoInstanceCrit<t> > crit; // protect access to the map
critSect.Enter();
int i = sPtrs.FindIndex(mPtr);
assert(i != -1);
critPtr = &(sInfos[i]);
critPtr->refCount--; // decrement refcount
critSect.Leave();
}
critPtr->crit.Leave();
/*
if(critPtr->refCount == 0)
{
sPtrs.RemoveIndex(i);
sInfos.RemoveIndex(i);
}*/
}
private:
t *mPtr; // the pointer we're protecting
static CriticalSection critSect;
static idList<t *> sPtrs;
static idList<CritInfo> sInfos;
};
template<typename t>
idList<t *> AutoInstanceCrit<t>::sPtrs;
template<typename t>
idList<CritInfo> AutoInstanceCrit<t>::sInfos;
template<typename t>
CriticalSection AutoInstanceCrit<t>::critSect;
#else
// this compiles out completely in release and removes the need
// for ifdefs all over the code
template <typename t>
class AutoInstanceCrit
{
public:
ID_INLINE AutoInstanceCrit(t *ptr) { }
};
#endif
#endif