This commit is contained in:
Robert Beckebans 2012-12-07 21:25:01 +01:00
commit 8812f6f0a4
38 changed files with 3598 additions and 3087 deletions

View file

@ -28,6 +28,10 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_definitions(-DUSE_XINPUT)
endif()
#if(NOT ANDROID)
add_definitions(-DUSE_EXCEPTIONS)
#endif()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -O1 -Wno-pragmas -fno-strict-aliasing -Wno-unused-variable -Wno-unused-but-set-variable -Wno-switch")
#set(CMAKE_C_FLAGS_DEBUGALL "${CMAKE_C_FLAGS_DEBUGALL} -g -ggdb -D_DEBUG -Wno-pragmas -fno-strict-aliasing -Wno-unused-variable -Wno-unused-but-set-variable -Wno-switch")
#set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE} -g -ggdb -D_DEBUG -O1 -fno-omit-frame-pointer -Wunknown-pragmas -fno-strict-aliasing -Wno-unused-variable -Wno-unused-but-set-variable -Wno-switch")

View file

@ -360,6 +360,8 @@ idAchievementManager::CheckDoomClassicsAchievements
Processed when the player finishes a level.
========================
*/
// RB begin
#if defined(USE_DOOMCLASSIC)
void idAchievementManager::CheckDoomClassicsAchievements( int killcount, int itemcount, int secretcount, int skill, int mission, int map, int episode, int totalkills, int totalitems, int totalsecret )
{
@ -504,6 +506,8 @@ void idAchievementManager::CheckDoomClassicsAchievements( int killcount, int ite
}
}
#endif // #if defined(USE_DOOMCLASSIC)
// RB end
/*
=================

View file

@ -193,7 +193,12 @@ public:
void RestorePersistentData( const idDict& spawnArgs );
static void LocalUser_CompleteAchievement( achievement_t id );
// RB begin
#if defined(USE_DOOMCLASSIC)
static void CheckDoomClassicsAchievements( int killcount, int itemcount, int secretcount, int skill, int mission, int map, int episode, int totalkills, int totalitems, int totalsecret );
#endif
// RB end
private:
idEntityPtr< idPlayer > owner;

View file

@ -302,7 +302,9 @@ void idGrabber::StartDrag( idEntity* grabEnt, int id )
}
else if( grabEnt->IsType( idMoveableItem::Type ) )
{
grabEnt->PostEventMS( &EV_Touch, 250, thePlayer, NULL );
// RB: 64 bit fixes, changed NULL to 0
grabEnt->PostEventMS( &EV_Touch, 250, thePlayer, 0 );
// RB end
}
// Get the current physics object to manipulate

View file

@ -337,7 +337,10 @@ void idItem::Spawn()
{
gameLocal.Error( "Item couldn't find owner '%s'", giveTo.c_str() );
}
PostEventMS( &EV_Touch, 0, ent, NULL );
// RB: 64 bit fixes, changed NULL to 0
PostEventMS( &EV_Touch, 0, ent, 0 );
// RB end
}
// idItemTeam does not rotate and bob

View file

@ -1531,12 +1531,15 @@ void idTrigger_Flag::Event_Touch( idEntity* other, trace_t* trace )
case 0 :
flag->PostEventMS( eventFlag, 0 );
break;
// RB: 64 bit fixes, changed NULL to 0
case 1 :
flag->PostEventMS( eventFlag, 0, NULL );
flag->PostEventMS( eventFlag, 0, 0 );
break;
case 2 :
flag->PostEventMS( eventFlag, 0, NULL, NULL );
flag->PostEventMS( eventFlag, 0, 0, 0 );
break;
// RB end
}
/*

File diff suppressed because it is too large Load diff

View file

@ -2750,7 +2750,10 @@ void idAI::Event_ThrowMoveable()
if( moveable )
{
moveable->Unbind();
moveable->PostEventMS( &EV_SetOwner, 200, NULL );
// RB: 64 bit fixes, changed NULL to 0
moveable->PostEventMS( &EV_SetOwner, 200, 0 );
// RB end
}
}
@ -2775,7 +2778,10 @@ void idAI::Event_ThrowAF()
if( af )
{
af->Unbind();
af->PostEventMS( &EV_SetOwner, 200, NULL );
// RB: 64 bit fixes, changed NULL to 0
af->PostEventMS( &EV_SetOwner, 200, 0 );
// RB end
}
}
@ -3393,4 +3399,4 @@ void idAI::Event_SetHomingMissileGoal()
}
homingMissileGoal = enemy->GetPhysics()->GetOrigin();
}
}

File diff suppressed because it is too large Load diff

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -877,7 +878,9 @@ bool idClass::ProcessEventArgs( const idEventDef* ev, int numargs, ... )
{
idTypeInfo* c;
int num;
int data[ D_EVENT_MAXARGS ];
// RB: 64 bit fix, changed int to intptr_t
intptr_t data[ D_EVENT_MAXARGS ];
// RB end
va_list args;
assert( ev );
@ -995,8 +998,10 @@ bool idClass::ProcessEvent( const idEventDef* ev, idEventArg arg1, idEventArg ar
idClass::ProcessEventArgPtr
================
*/
bool idClass::ProcessEventArgPtr( const idEventDef* ev, int* data )
// RB: 64 bit fixes, changed int to intptr_t
bool idClass::ProcessEventArgPtr( const idEventDef* ev, intptr_t* data )
{
// RB end
idTypeInfo* c;
int num;
eventCallback_t callback;
@ -1028,8 +1033,11 @@ bool idClass::ProcessEventArgPtr( const idEventDef* ev, int* data )
callback = c->eventMap[ num ];
// RB: I tried first to get CPU_EASYARGS switch running with x86_64
// but it caused many crashes with the Doom scripts.
// The new Callbacks.cpp was generated with intptr_t and it works fine.
#if !CPU_EASYARGS
/*
on ppc architecture, floats are passed in a seperate set of registers
the function prototypes must have matching float declaration
@ -1055,6 +1063,7 @@ bool idClass::ProcessEventArgPtr( const idEventDef* ev, int* data )
assert( D_EVENT_MAXARGS == 8 );
// RB: 64 bit fixes, changed int to intptr_t
switch( ev->GetNumArgs() )
{
case 0 :
@ -1062,42 +1071,42 @@ bool idClass::ProcessEventArgPtr( const idEventDef* ev, int* data )
break;
case 1 :
typedef void ( idClass::*eventCallback_1_t )( const int );
typedef void ( idClass::*eventCallback_1_t )( const intptr_t );
( this->*( eventCallback_1_t )callback )( data[ 0 ] );
break;
case 2 :
typedef void ( idClass::*eventCallback_2_t )( const int, const int );
typedef void ( idClass::*eventCallback_2_t )( const intptr_t, const intptr_t );
( this->*( eventCallback_2_t )callback )( data[ 0 ], data[ 1 ] );
break;
case 3 :
typedef void ( idClass::*eventCallback_3_t )( const int, const int, const int );
typedef void ( idClass::*eventCallback_3_t )( const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_3_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ] );
break;
case 4 :
typedef void ( idClass::*eventCallback_4_t )( const int, const int, const int, const int );
typedef void ( idClass::*eventCallback_4_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_4_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ] );
break;
case 5 :
typedef void ( idClass::*eventCallback_5_t )( const int, const int, const int, const int, const int );
typedef void ( idClass::*eventCallback_5_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_5_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ] );
break;
case 6 :
typedef void ( idClass::*eventCallback_6_t )( const int, const int, const int, const int, const int, const int );
typedef void ( idClass::*eventCallback_6_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_6_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] );
break;
case 7 :
typedef void ( idClass::*eventCallback_7_t )( const int, const int, const int, const int, const int, const int, const int );
typedef void ( idClass::*eventCallback_7_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_7_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ] );
break;
case 8 :
typedef void ( idClass::*eventCallback_8_t )( const int, const int, const int, const int, const int, const int, const int, const int );
typedef void ( idClass::*eventCallback_8_t )( const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t, const intptr_t );
( this->*( eventCallback_8_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ] );
break;
@ -1105,6 +1114,7 @@ bool idClass::ProcessEventArgPtr( const idEventDef* ev, int* data )
gameLocal.Warning( "Invalid formatspec on event '%s'", ev->GetName() );
break;
}
// RB end
#endif

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -59,7 +60,9 @@ class idEventArg
{
public:
int type;
int value;
// RB: 64 bit fix, changed int to intptr_t
intptr_t value;
// RB end
idEventArg()
{
@ -76,31 +79,33 @@ public:
type = D_EVENT_FLOAT;
value = *reinterpret_cast<int*>( &data );
};
// RB: 64 bit fixes, changed int to intptr_t
idEventArg( idVec3& data )
{
type = D_EVENT_VECTOR;
value = reinterpret_cast<int>( &data );
value = reinterpret_cast<intptr_t>( &data );
};
idEventArg( const idStr& data )
{
type = D_EVENT_STRING;
value = reinterpret_cast<int>( data.c_str() );
value = reinterpret_cast<intptr_t>( data.c_str() );
};
idEventArg( const char* data )
{
type = D_EVENT_STRING;
value = reinterpret_cast<int>( data );
value = reinterpret_cast<intptr_t>( data );
};
idEventArg( const class idEntity* data )
{
type = D_EVENT_ENTITY;
value = reinterpret_cast<int>( data );
value = reinterpret_cast<intptr_t>( data );
};
idEventArg( const struct trace_s* data )
{
type = D_EVENT_TRACE;
value = reinterpret_cast<int>( data );
value = reinterpret_cast<intptr_t>( data );
};
// RB end
};
class idAllocError : public idException
@ -142,6 +147,8 @@ proper superclass is indicated or the run-time type information will be
incorrect. Use this on concrete classes only.
================
*/
// RB: made exceptions optional
#if defined(USE_EXCEPTIONS)
#define CLASS_DECLARATION( nameofsuperclass, nameofclass ) \
idTypeInfo nameofclass::Type( #nameofclass, #nameofsuperclass, \
( idEventFunc<idClass> * )nameofclass::eventCallbacks, nameofclass::CreateInstance, ( void ( idClass::* )() )&nameofclass::Spawn, \
@ -160,6 +167,22 @@ incorrect. Use this on concrete classes only.
return &( nameofclass::Type ); \
} \
idEventFunc<nameofclass> nameofclass::eventCallbacks[] = {
#else
#define CLASS_DECLARATION( nameofsuperclass, nameofclass ) \
idTypeInfo nameofclass::Type( #nameofclass, #nameofsuperclass, \
( idEventFunc<idClass> * )nameofclass::eventCallbacks, nameofclass::CreateInstance, ( void ( idClass::* )() )&nameofclass::Spawn, \
( void ( idClass::* )( idSaveGame * ) const )&nameofclass::Save, ( void ( idClass::* )( idRestoreGame * ) )&nameofclass::Restore ); \
idClass *nameofclass::CreateInstance() { \
nameofclass *ptr = new nameofclass; \
ptr->FindUninitializedMemory(); \
return ptr; \
} \
idTypeInfo *nameofclass::GetType() const { \
return &( nameofclass::Type ); \
} \
idEventFunc<nameofclass> nameofclass::eventCallbacks[] = {
#endif
// RB end
/*
================
@ -258,7 +281,9 @@ public:
bool ProcessEvent( const idEventDef* ev, idEventArg arg1, idEventArg arg2, idEventArg arg3, idEventArg arg4, idEventArg arg5, idEventArg arg6, idEventArg arg7 );
bool ProcessEvent( const idEventDef* ev, idEventArg arg1, idEventArg arg2, idEventArg arg3, idEventArg arg4, idEventArg arg5, idEventArg arg6, idEventArg arg7, idEventArg arg8 );
bool ProcessEventArgPtr( const idEventDef* ev, int* data );
// RB: 64 bit fix, changed int to intptr_t
bool ProcessEventArgPtr( const idEventDef* ev, intptr_t* data );
// RB end
void CancelEvents( const idEventDef* ev );
void Event_Remove();
@ -269,6 +294,9 @@ public:
static idTypeInfo* GetClass( const char* name );
static void DisplayInfo_f( const idCmdArgs& args );
static void ListClasses_f( const idCmdArgs& args );
// RB begin
static void ExportScriptEvents_f( const idCmdArgs& args );
// RB end
static idClass* CreateInstance( const char* name );
static int GetNumTypes()
{

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -98,15 +99,21 @@ idEventDef::idEventDef( const char* command, const char* formatspec, char return
{
case D_EVENT_FLOAT :
bits |= 1 << i;
argsize += sizeof( float );
// RB: 64 bit fix, changed sizeof( float ) to sizeof( intptr_t )
argsize += sizeof( intptr_t );
// RB end
break;
case D_EVENT_INTEGER :
argsize += sizeof( int );
// RB: 64 bit fix, changed sizeof( int ) to sizeof( intptr_t )
argsize += sizeof( intptr_t );
// RB end
break;
case D_EVENT_VECTOR :
argsize += sizeof( idVec3 );
// RB: 64 bit fix, changed sizeof( idVec3 ) to E_EVENT_SIZEOF_VEC
argsize += E_EVENT_SIZEOF_VEC;
// RB end
break;
case D_EVENT_STRING :
@ -114,11 +121,15 @@ idEventDef::idEventDef( const char* command, const char* formatspec, char return
break;
case D_EVENT_ENTITY :
argsize += sizeof( idEntityPtr<idEntity> );
// RB: 64 bit fix, sizeof( idEntityPtr<idEntity> ) to sizeof( intptr_t )
argsize += sizeof( intptr_t );
// RB end
break;
case D_EVENT_ENTITY_NULL :
argsize += sizeof( idEntityPtr<idEntity> );
// RB: 64 bit fix, sizeof( idEntityPtr<idEntity> ) to sizeof( intptr_t )
argsize += sizeof( intptr_t );
// RB end
break;
case D_EVENT_TRACE :
@ -366,8 +377,10 @@ idEvent* idEvent::Alloc( const idEventDef* evdef, int numargs, va_list args )
idEvent::CopyArgs
================
*/
void idEvent::CopyArgs( const idEventDef* evdef, int numargs, va_list args, int data[ D_EVENT_MAXARGS ] )
// RB: 64 bit fixes, changed int to intptr_t
void idEvent::CopyArgs( const idEventDef* evdef, int numargs, va_list args, intptr_t data[ D_EVENT_MAXARGS ] )
{
// RB end
int i;
const char* format;
idEventArg* arg;
@ -552,7 +565,9 @@ void idEvent::ServiceEvents()
{
idEvent* event;
int num;
int args[ D_EVENT_MAXARGS ];
// RB: 64 bit fixes, changed int to intptr_t
intptr_t args[ D_EVENT_MAXARGS ];
// RB end
int offset;
int i;
int numargs;
@ -663,8 +678,10 @@ idEvent::ServiceFastEvents
void idEvent::ServiceFastEvents()
{
idEvent* event;
int num;
int args[ D_EVENT_MAXARGS ];
int num;
// RB: 64 bit fixes, changed int to intptr_t
intptr_t args[ D_EVENT_MAXARGS ];
// RB end
int offset;
int i;
int numargs;
@ -838,6 +855,9 @@ void idEvent::Save( idSaveGame* savefile )
byte* dataPtr;
bool validTrace;
const char* format;
// RB: for missing D_EVENT_STRING
idStr s;
// RB end
savefile->WriteInt( EventQueue.Num() );
@ -857,18 +877,40 @@ void idEvent::Save( idSaveGame* savefile )
{
case D_EVENT_FLOAT :
savefile->WriteFloat( *reinterpret_cast<float*>( dataPtr ) );
size += sizeof( float );
// RB: 64 bit fix, changed sizeof( float ) to sizeof( intptr_t )
size += sizeof( intptr_t );
// RB end
break;
case D_EVENT_INTEGER :
// RB: 64 bit fix, changed sizeof( int ) to sizeof( intptr_t )
savefile->WriteInt( *reinterpret_cast<int*>( dataPtr ) );
size += sizeof( intptr_t );
break;
// RB end
case D_EVENT_ENTITY :
case D_EVENT_ENTITY_NULL :
savefile->WriteInt( *reinterpret_cast<int*>( dataPtr ) );
size += sizeof( int );
// RB: 64 bit fix, changed alignment to sizeof( intptr_t )
reinterpret_cast< idEntityPtr<idEntity> * >( dataPtr )->Save( savefile );
size += sizeof( intptr_t );
// RB end
break;
case D_EVENT_VECTOR :
savefile->WriteVec3( *reinterpret_cast<idVec3*>( dataPtr ) );
size += sizeof( idVec3 );
// RB: 64 bit fix, changed sizeof( int ) to E_EVENT_SIZEOF_VEC
size += E_EVENT_SIZEOF_VEC;
// RB end
break;
#if 1
// RB: added missing D_EVENT_STRING case
case D_EVENT_STRING :
s.Clear();
s.Append( reinterpret_cast<char*>( dataPtr ) );
savefile->WriteString( s );
//size += s.Length();
size += MAX_STRING_LEN;
break;
// RB end
#endif
case D_EVENT_TRACE :
validTrace = *reinterpret_cast<bool*>( dataPtr );
savefile->WriteBool( validTrace );
@ -924,6 +966,9 @@ void idEvent::Restore( idRestoreGame* savefile )
byte* dataPtr;
idEvent* event;
const char* format;
// RB: for missing D_EVENT_STRING
idStr s;
// RB end
savefile->ReadInt( num );
@ -964,7 +1009,9 @@ void idEvent::Restore( idRestoreGame* savefile )
savefile->ReadInt( argsize );
if( argsize != ( int )event->eventdef->GetArgSize() )
{
savefile->Error( "idEvent::Restore: arg size (%d) doesn't match saved arg size(%d) on event '%s'", event->eventdef->GetArgSize(), argsize, event->eventdef->GetName() );
// RB: fixed wrong formatting
savefile->Error( "idEvent::Restore: arg size (%zd) doesn't match saved arg size(%zd) on event '%s'", event->eventdef->GetArgSize(), argsize, event->eventdef->GetName() );
// RB end
}
if( argsize )
{
@ -978,18 +1025,40 @@ void idEvent::Restore( idRestoreGame* savefile )
{
case D_EVENT_FLOAT :
savefile->ReadFloat( *reinterpret_cast<float*>( dataPtr ) );
size += sizeof( float );
// RB: 64 bit fix, changed sizeof( float ) to sizeof( intptr_t )
size += sizeof( intptr_t );
// RB end
break;
case D_EVENT_INTEGER :
// RB: 64 bit fix
savefile->ReadInt( *reinterpret_cast<int*>( dataPtr ) );
size += sizeof( intptr_t );
break;
// RB end
case D_EVENT_ENTITY :
case D_EVENT_ENTITY_NULL :
savefile->ReadInt( *reinterpret_cast<int*>( dataPtr ) );
size += sizeof( int );
// RB: 64 bit fix, changed alignment to sizeof( intptr_t )
reinterpret_cast<idEntityPtr<idEntity> *>( dataPtr )->Restore( savefile );
size += sizeof( intptr_t );
// RB end
break;
case D_EVENT_VECTOR :
savefile->ReadVec3( *reinterpret_cast<idVec3*>( dataPtr ) );
size += sizeof( idVec3 );
// RB: 64 bit fix, changed sizeof( int ) to E_EVENT_SIZEOF_VEC
size += E_EVENT_SIZEOF_VEC;
// RB end
break;
#if 1
// RB: added missing D_EVENT_STRING case
case D_EVENT_STRING :
savefile->ReadString( s );
//idStr::Copynz(reinterpret_cast<char *>( dataPtr ), s, s.Length() );
//size += s.Length();
idStr::Copynz( reinterpret_cast<char*>( dataPtr ), s, MAX_STRING_LEN );
size += MAX_STRING_LEN;
break;
// RB end
#endif
case D_EVENT_TRACE :
savefile->ReadBool( *reinterpret_cast<bool*>( dataPtr ) );
size += sizeof( bool );
@ -1132,6 +1201,8 @@ CreateEventCallbackHandler
*/
void CreateEventCallbackHandler()
{
int num;
int count;
int i, j, k;
char argString[ D_EVENT_MAXARGS + 1 ];
idStr string1;
@ -1140,7 +1211,7 @@ void CreateEventCallbackHandler()
file = fileSystem->OpenFileWrite( "Callbacks.cpp" );
file->Printf( "/*\n================================================================================================\nCONFIDENTIAL AND PROPRIETARY INFORMATION/NOT FOR DISCLOSURE WITHOUT WRITTEN PERMISSION \nCopyright 1999-2012 id Software LLC, a ZeniMax Media company. All Rights Reserved. \n================================================================================================\n*/\n\n" );
file->Printf( "// generated file - see CREATE_EVENT_CODE\n\n" );
for( i = 1; i <= D_EVENT_MAXARGS; i++ )
{
@ -1167,8 +1238,10 @@ void CreateEventCallbackHandler()
}
else
{
string1 += "void *";
string2 += va( "(void *)data[ %d ]", k );
// RB: 64 bit fix, changed int to intptr_t
string1 += "const intptr_t";
// RB end
string2 += va( "data[ %d ]", k );
}
if( k < i - 1 )

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -36,6 +37,11 @@ Event are used for scheduling tasks and for linking script commands.
#define D_EVENT_MAXARGS 8 // if changed, enable the CREATE_EVENT_CODE define in Event.cpp to generate switch statement for idClass::ProcessEventArgPtr.
// running the game will then generate c:\doom\base\events.txt, the contents of which should be copied into the switch statement.
// RB: from dhewm3
// stack size of idVec3, aligned to native pointer size
#define E_EVENT_SIZEOF_VEC ((sizeof(idVec3) + (sizeof(intptr_t) - 1)) & ~(sizeof(intptr_t) - 1))
// RB end
#define D_EVENT_VOID ( ( char )0 )
#define D_EVENT_INTEGER 'd'
#define D_EVENT_FLOAT 'f'
@ -106,7 +112,9 @@ public:
~idEvent();
static idEvent* Alloc( const idEventDef* evdef, int numargs, va_list args );
static void CopyArgs( const idEventDef* evdef, int numargs, va_list args, int data[ D_EVENT_MAXARGS ] );
// RB: 64 bit fix, changed int to intptr_t
static void CopyArgs( const idEventDef* evdef, int numargs, va_list args, intptr_t data[ D_EVENT_MAXARGS ] );
// RB end
void Free();
void Schedule( idClass* object, const idTypeInfo* cls, int time );

View file

@ -2273,7 +2273,10 @@ void idMenuScreen_HUD::UpdateChattingHud( idPlayer* player )
{
mpChatObject->StopFrame( 1 );
gui->ForceInhibitControl( false );
gui->SetGlobal( "focusWindow", NULL );
// RB: 64 bit fixes, changed NULL to 0
gui->SetGlobal( "focusWindow", 0 );
// RB end
}
}
else

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -270,11 +271,15 @@ bool idMenuScreen_Shell_PressStart::HandleAction( idWidgetAction& action, const
}
}
// RB begin
#if defined(USE_DOOMCLASSIC)
if( itemList->GetMoveToIndex() == 0 )
{
common->SwitchToGame( DOOM_CLASSIC );
}
else if( itemList->GetMoveToIndex() == 1 )
else
#endif
if( itemList->GetMoveToIndex() == 1 )
{
if( session->GetSignInManager().GetMasterLocalUser() == NULL )
{
@ -286,10 +291,13 @@ bool idMenuScreen_Shell_PressStart::HandleAction( idWidgetAction& action, const
menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
}
}
#if defined(USE_DOOMCLASSIC)
else if( itemList->GetMoveToIndex() == 2 )
{
common->SwitchToGame( DOOM2_CLASSIC );
}
#endif
// RB end
return true;
}
@ -356,4 +364,4 @@ bool idMenuScreen_Shell_PressStart::HandleAction( idWidgetAction& action, const
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
}

View file

@ -195,7 +195,10 @@ void idMenuWidget_CommandBar::Update()
idSWFScriptObject* const shortcutKeys = GetSWFObject()->GetGlobal( "shortcutKeys" ).GetObject();
if( verify( shortcutKeys != NULL ) )
{
buttonSprite->GetScriptObject()->Set( "onPress", NULL );
// RB: 64 bit fixes, changed NULL to 0
buttonSprite->GetScriptObject()->Set( "onPress", 0 );
// RB end
// bind the main action - need to use all caps here because shortcuts are stored that way
shortcutName = buttonName;
shortcutName.ToUpper();

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -39,16 +40,20 @@ If you have questions concerning this license or the applicable additional terms
#define TOP_PRIORITY 7
bool idCompiler::punctuationValid[ 256 ];
char* idCompiler::punctuation[] =
// RB begin
const char* idCompiler::punctuation[] =
{
// RB end
"+=", "-=", "*=", "/=", "%=", "&=", "|=", "++", "--",
"&&", "||", "<=", ">=", "==", "!=", "::", ";", ",",
"~", "!", "*", "/", "%", "(", ")", "-", "+",
"=", "[", "]", ".", "<", ">" , "&", "|", ":", NULL
};
opcode_t idCompiler::opcodes[] =
// RB: added const
const opcode_t idCompiler::opcodes[] =
{
// RB end
{ "<RETURN>", "RETURN", -1, false, &def_void, &def_void, &def_void },
{ "++", "UINC_F", 1, true, &def_float, &def_void, &def_void },
@ -211,12 +216,15 @@ idCompiler::idCompiler()
*/
idCompiler::idCompiler()
{
char** ptr;
// RB begin
const char** ptr;
// RB end
int id;
// make sure we have the right # of opcodes in the table
assert( ( sizeof( opcodes ) / sizeof( opcodes[ 0 ] ) ) == ( NUM_OPCODES + 1 ) );
eof = true;
parserPtr = &parser;
callthread = false;
@ -259,7 +267,11 @@ void idCompiler::Error( const char* message, ... ) const
vsprintf( string, message, argptr );
va_end( argptr );
#if defined(USE_EXCEPTIONS)
throw idCompileError( string );
#else
parserPtr->Error( "%s", string );
#endif
}
/*
@ -380,6 +392,7 @@ ID_INLINE float idCompiler::Divide( float numerator, float denominator )
if( denominator == 0 )
{
Error( "Divide by zero" );
return 0;
}
return numerator / denominator;
@ -805,8 +818,10 @@ Emits an opcode to push the variable onto the stack.
*/
bool idCompiler::EmitPush( idVarDef* expression, const idTypeDef* funcArg )
{
opcode_t* op;
opcode_t* out;
// RB: added const
const opcode_t* op;
const opcode_t* out;
// RB end
out = NULL;
for( op = &opcodes[ OP_PUSH_F ]; op->name && !strcmp( op->name, "<PUSH>" ); op++ )
@ -1458,7 +1473,9 @@ idVarDef* idCompiler::LookupDef( const char* name, const idVarDef* baseobj )
idVarDef* field;
etype_t type_b;
etype_t type_c;
opcode_t* op;
// RB: added const
const opcode_t* op;
// RB end
// check if we're accessing a field
if( baseobj && ( baseobj->Type() == ev_object ) )
@ -1810,8 +1827,10 @@ idCompiler::GetExpression
*/
idVarDef* idCompiler::GetExpression( int priority )
{
opcode_t* op;
opcode_t* oldop;
// RB: added const
const opcode_t* op;
const opcode_t* oldop;
// RB end
idVarDef* e;
idVarDef* e2;
const idVarDef* oldtype;
@ -2083,7 +2102,9 @@ void idCompiler::ParseReturnStatement()
idVarDef* e;
etype_t type_a;
etype_t type_b;
opcode_t* op;
// RB: added const
const opcode_t* op;
// RB end
if( CheckToken( ";" ) )
{
@ -3193,7 +3214,9 @@ void idCompiler::CompileFile( const char* text, const char* filename, bool toCon
token.line = 1;
error = false;
#if defined(USE_EXCEPTIONS)
try
#endif
{
// read first token
NextToken();
@ -3203,7 +3226,7 @@ void idCompiler::CompileFile( const char* text, const char* filename, bool toCon
ParseNamespace( &def_namespace );
}
}
#if defined(USE_EXCEPTIONS)
catch( idCompileError& err )
{
idStr error;
@ -3222,6 +3245,13 @@ void idCompiler::CompileFile( const char* text, const char* filename, bool toCon
throw idCompileError( error );
}
#else
// FIXME check for errors
if( error )
{
common->Printf( "Error: idCompiler::CompileFile: file %s, line %d: unknown error\n", gameLocal.program.GetFilename( currentFileNumber ), currentLineNumber );
}
#endif
parser.FreeSource();

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -32,8 +33,10 @@ const char* const RESULT_STRING = "<RESULT>";
typedef struct opcode_s
{
char* name;
char* opname;
// RB begin
const char* name;
const char* opname;
// RB end
int priority;
bool rightAssociative;
idVarDef* type_a;
@ -200,7 +203,9 @@ class idCompiler
{
private:
static bool punctuationValid[ 256 ];
static char* punctuation[];
// RB begin
static const char* punctuation[];
// RB end
idParser parser;
idParser* parserPtr;
@ -272,7 +277,9 @@ private:
void ParseNamespace( idVarDef* newScope );
public :
static opcode_t opcodes[];
// RB: added const
static const opcode_t opcodes[];
// RB end
idCompiler();
void CompileFile( const char* text, const char* filename, bool console );

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -808,7 +809,9 @@ void idInterpreter::CallEvent( const function_t* func, int argsize )
varEval_t var;
int pos;
int start;
int data[ D_EVENT_MAXARGS ];
// RB: 64 bit fixes, changed int to intptr_t
intptr_t data[ D_EVENT_MAXARGS ];
// RB end
const idEventDef* evdef;
const char* format;
@ -874,7 +877,10 @@ void idInterpreter::CallEvent( const function_t* func, int argsize )
{
case D_EVENT_INTEGER :
var.intPtr = ( int* )&localstack[ start + pos ];
data[ i ] = int( *var.floatPtr );
// RB: fixed data alignment
//data[ i ] = int( *var.floatPtr );
( *( int* )&data[ i ] ) = int( *var.floatPtr );
// RB end
break;
case D_EVENT_FLOAT :
@ -999,7 +1005,9 @@ void idInterpreter::CallSysEvent( const function_t* func, int argsize )
varEval_t source;
int pos;
int start;
int data[ D_EVENT_MAXARGS ];
// RB: 64 bit fixes, changed int to intptr_t
intptr_t data[ D_EVENT_MAXARGS ];
// RB end
const idEventDef* evdef;
const char* format;
@ -2043,9 +2051,14 @@ bool idInterpreter::Execute()
case OP_PUSH_V:
var_a = GetVariable( st->a );
Push( *reinterpret_cast<int*>( &var_a.vectorPtr->x ) );
Push( *reinterpret_cast<int*>( &var_a.vectorPtr->y ) );
Push( *reinterpret_cast<int*>( &var_a.vectorPtr->z ) );
// RB: 64 bit fix, changed individual pushes with PushVector
/*
Push( *reinterpret_cast<int *>( &var_a.vectorPtr->x ) );
Push( *reinterpret_cast<int *>( &var_a.vectorPtr->y ) );
Push( *reinterpret_cast<int *>( &var_a.vectorPtr->z ) );
*/
PushVector( *var_a.vectorPtr );
// RB end
break;
case OP_PUSH_OBJ:
@ -2068,3 +2081,41 @@ bool idInterpreter::Execute()
return threadDying;
}
// RB: moved from Script_Interpreter.h to avoid include problems with the script debugger
/*
================
idInterpreter::GetEntity
================
*/
idEntity* idInterpreter::GetEntity( int entnum ) const
{
assert( entnum <= MAX_GENTITIES );
if( ( entnum > 0 ) && ( entnum <= MAX_GENTITIES ) )
{
return gameLocal.entities[ entnum - 1 ];
}
return NULL;
}
/*
================
idInterpreter::GetScriptObject
================
*/
idScriptObject* idInterpreter::GetScriptObject( int entnum ) const
{
idEntity* ent;
assert( entnum <= MAX_GENTITIES );
if( ( entnum > 0 ) && ( entnum <= MAX_GENTITIES ) )
{
ent = gameLocal.entities[ entnum - 1 ];
if( ent && ent->scriptObject.data )
{
return &ent->scriptObject;
}
}
return NULL;
}
// RB end

View file

@ -1,305 +1,299 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __SCRIPT_INTERPRETER_H__
#define __SCRIPT_INTERPRETER_H__
#define MAX_STACK_DEPTH 64
#define LOCALSTACK_SIZE 6144
typedef struct prstack_s
{
int s;
const function_t* f;
int stackbase;
} prstack_t;
class idInterpreter
{
private:
prstack_t callStack[ MAX_STACK_DEPTH ];
int callStackDepth;
int maxStackDepth;
byte localstack[ LOCALSTACK_SIZE ];
int localstackUsed;
int localstackBase;
int maxLocalstackUsed;
const function_t* currentFunction;
int instructionPointer;
int popParms;
const idEventDef* multiFrameEvent;
idEntity* eventEntity;
idThread* thread;
void PopParms( int numParms );
void PushString( const char* string );
void Push( int value );
const char* FloatToString( float value );
void AppendString( idVarDef* def, const char* from );
void SetString( idVarDef* def, const char* from );
const char* GetString( idVarDef* def );
varEval_t GetVariable( idVarDef* def );
idEntity* GetEntity( int entnum ) const;
idScriptObject* GetScriptObject( int entnum ) const;
void NextInstruction( int position );
void LeaveFunction( idVarDef* returnDef );
void CallEvent( const function_t* func, int argsize );
void CallSysEvent( const function_t* func, int argsize );
public:
bool doneProcessing;
bool threadDying;
bool terminateOnExit;
bool debug;
idInterpreter();
// save games
void Save( idSaveGame* savefile ) const; // archives object for save game file
void Restore( idRestoreGame* savefile ); // unarchives object from save game file
void SetThread( idThread* pThread );
void StackTrace() const;
int CurrentLine() const;
const char* CurrentFile() const;
void Error( VERIFY_FORMAT_STRING const char* fmt, ... ) const;
void Warning( VERIFY_FORMAT_STRING const char* fmt, ... ) const;
void DisplayInfo() const;
bool BeginMultiFrameEvent( idEntity* ent, const idEventDef* event );
void EndMultiFrameEvent( idEntity* ent, const idEventDef* event );
bool MultiFrameEventInProgress() const;
void ThreadCall( idInterpreter* source, const function_t* func, int args );
void EnterFunction( const function_t* func, bool clearStack );
void EnterObjectFunction( idEntity* self, const function_t* func, bool clearStack );
bool Execute();
void Reset();
bool GetRegisterValue( const char* name, idStr& out, int scopeDepth );
int GetCallstackDepth() const;
const prstack_t* GetCallstack() const;
const function_t* GetCurrentFunction() const;
idThread* GetThread() const;
};
/*
====================
idInterpreter::PopParms
====================
*/
ID_INLINE void idInterpreter::PopParms( int numParms )
{
// pop our parms off the stack
if( localstackUsed < numParms )
{
Error( "locals stack underflow\n" );
}
localstackUsed -= numParms;
}
/*
====================
idInterpreter::Push
====================
*/
ID_INLINE void idInterpreter::Push( int value )
{
if( localstackUsed + sizeof( int ) > LOCALSTACK_SIZE )
{
Error( "Push: locals stack overflow\n" );
}
*( int* )&localstack[ localstackUsed ] = value;
localstackUsed += sizeof( int );
}
/*
====================
idInterpreter::PushString
====================
*/
ID_INLINE void idInterpreter::PushString( const char* string )
{
if( localstackUsed + MAX_STRING_LEN > LOCALSTACK_SIZE )
{
Error( "PushString: locals stack overflow\n" );
}
idStr::Copynz( ( char* )&localstack[ localstackUsed ], string, MAX_STRING_LEN );
localstackUsed += MAX_STRING_LEN;
}
/*
====================
idInterpreter::FloatToString
====================
*/
ID_INLINE const char* idInterpreter::FloatToString( float value )
{
static char text[ 32 ];
if( value == ( float )( int )value )
{
sprintf( text, "%d", ( int )value );
}
else
{
sprintf( text, "%f", value );
}
return text;
}
/*
====================
idInterpreter::AppendString
====================
*/
ID_INLINE void idInterpreter::AppendString( idVarDef* def, const char* from )
{
if( def->initialized == idVarDef::stackVariable )
{
idStr::Append( ( char* )&localstack[ localstackBase + def->value.stackOffset ], MAX_STRING_LEN, from );
}
else
{
idStr::Append( def->value.stringPtr, MAX_STRING_LEN, from );
}
}
/*
====================
idInterpreter::SetString
====================
*/
ID_INLINE void idInterpreter::SetString( idVarDef* def, const char* from )
{
if( def->initialized == idVarDef::stackVariable )
{
idStr::Copynz( ( char* )&localstack[ localstackBase + def->value.stackOffset ], from, MAX_STRING_LEN );
}
else
{
idStr::Copynz( def->value.stringPtr, from, MAX_STRING_LEN );
}
}
/*
====================
idInterpreter::GetString
====================
*/
ID_INLINE const char* idInterpreter::GetString( idVarDef* def )
{
if( def->initialized == idVarDef::stackVariable )
{
return ( char* )&localstack[ localstackBase + def->value.stackOffset ];
}
else
{
return def->value.stringPtr;
}
}
/*
====================
idInterpreter::GetVariable
====================
*/
ID_INLINE varEval_t idInterpreter::GetVariable( idVarDef* def )
{
if( def->initialized == idVarDef::stackVariable )
{
varEval_t val;
val.intPtr = ( int* )&localstack[ localstackBase + def->value.stackOffset ];
return val;
}
else
{
return def->value;
}
}
/*
================
idInterpreter::GetEntity
================
*/
ID_INLINE idEntity* idInterpreter::GetEntity( int entnum ) const
{
assert( entnum <= MAX_GENTITIES );
if( ( entnum > 0 ) && ( entnum <= MAX_GENTITIES ) )
{
return gameLocal.entities[ entnum - 1 ];
}
return NULL;
}
/*
================
idInterpreter::GetScriptObject
================
*/
ID_INLINE idScriptObject* idInterpreter::GetScriptObject( int entnum ) const
{
idEntity* ent;
assert( entnum <= MAX_GENTITIES );
if( ( entnum > 0 ) && ( entnum <= MAX_GENTITIES ) )
{
ent = gameLocal.entities[ entnum - 1 ];
if( ent && ent->scriptObject.data )
{
return &ent->scriptObject;
}
}
return NULL;
}
/*
====================
idInterpreter::NextInstruction
====================
*/
ID_INLINE void idInterpreter::NextInstruction( int position )
{
// Before we execute an instruction, we increment instructionPointer,
// therefore we need to compensate for that here.
instructionPointer = position - 1;
}
#endif /* !__SCRIPT_INTERPRETER_H__ */
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
===========================================================================
*/
#ifndef __SCRIPT_INTERPRETER_H__
#define __SCRIPT_INTERPRETER_H__
#define MAX_STACK_DEPTH 64
// RB: doubled local stack size
#define LOCALSTACK_SIZE (6144 * 2)
// RB end
typedef struct prstack_s
{
int s;
const function_t* f;
int stackbase;
} prstack_t;
class idInterpreter
{
private:
prstack_t callStack[ MAX_STACK_DEPTH ];
int callStackDepth;
int maxStackDepth;
byte localstack[ LOCALSTACK_SIZE ];
int localstackUsed;
int localstackBase;
int maxLocalstackUsed;
const function_t* currentFunction;
int instructionPointer;
int popParms;
const idEventDef* multiFrameEvent;
idEntity* eventEntity;
idThread* thread;
void PopParms( int numParms );
void PushString( const char* string );
// RB begin
// RB: 64 bit fix, changed int to intptr_t
void Push( intptr_t value );
// RB: added PushVector for new E_EVENT_SIZEOF_VEC
void PushVector( const idVec3& vector );
// RB end
const char* FloatToString( float value );
void AppendString( idVarDef* def, const char* from );
void SetString( idVarDef* def, const char* from );
const char* GetString( idVarDef* def );
varEval_t GetVariable( idVarDef* def );
idEntity* GetEntity( int entnum ) const;
idScriptObject* GetScriptObject( int entnum ) const;
void NextInstruction( int position );
void LeaveFunction( idVarDef* returnDef );
void CallEvent( const function_t* func, int argsize );
void CallSysEvent( const function_t* func, int argsize );
public:
bool doneProcessing;
bool threadDying;
bool terminateOnExit;
bool debug;
idInterpreter();
// save games
void Save( idSaveGame* savefile ) const; // archives object for save game file
void Restore( idRestoreGame* savefile ); // unarchives object from save game file
void SetThread( idThread* pThread );
void StackTrace() const;
int CurrentLine() const;
const char* CurrentFile() const;
void Error( VERIFY_FORMAT_STRING const char* fmt, ... ) const;
void Warning( VERIFY_FORMAT_STRING const char* fmt, ... ) const;
void DisplayInfo() const;
bool BeginMultiFrameEvent( idEntity* ent, const idEventDef* event );
void EndMultiFrameEvent( idEntity* ent, const idEventDef* event );
bool MultiFrameEventInProgress() const;
void ThreadCall( idInterpreter* source, const function_t* func, int args );
void EnterFunction( const function_t* func, bool clearStack );
void EnterObjectFunction( idEntity* self, const function_t* func, bool clearStack );
bool Execute();
void Reset();
bool GetRegisterValue( const char* name, idStr& out, int scopeDepth );
int GetCallstackDepth() const;
const prstack_t* GetCallstack() const;
const function_t* GetCurrentFunction() const;
idThread* GetThread() const;
};
/*
====================
idInterpreter::PopParms
====================
*/
ID_INLINE void idInterpreter::PopParms( int numParms )
{
// pop our parms off the stack
if( localstackUsed < numParms )
{
Error( "locals stack underflow\n" );
}
localstackUsed -= numParms;
}
/*
====================
idInterpreter::Push
====================
*/
// RB: 64 bit fix, changed int to intptr_t
ID_INLINE void idInterpreter::Push( intptr_t value )
{
if( localstackUsed + sizeof( intptr_t ) > LOCALSTACK_SIZE )
{
Error( "Push: locals stack overflow\n" );
}
*( intptr_t* )&localstack[ localstackUsed ] = value;
localstackUsed += sizeof( intptr_t );
}
// RB end
// RB begin
/*
====================
idInterpreter::PushVector
====================
*/
ID_INLINE void idInterpreter::PushVector( const idVec3& vector )
{
if( localstackUsed + E_EVENT_SIZEOF_VEC > LOCALSTACK_SIZE )
{
Error( "Push: locals stack overflow\n" );
}
*( idVec3* )&localstack[ localstackUsed ] = vector;
localstackUsed += E_EVENT_SIZEOF_VEC;
}
// RB end
/*
====================
idInterpreter::PushString
====================
*/
ID_INLINE void idInterpreter::PushString( const char* string )
{
if( localstackUsed + MAX_STRING_LEN > LOCALSTACK_SIZE )
{
Error( "PushString: locals stack overflow\n" );
}
idStr::Copynz( ( char* )&localstack[ localstackUsed ], string, MAX_STRING_LEN );
localstackUsed += MAX_STRING_LEN;
}
/*
====================
idInterpreter::FloatToString
====================
*/
ID_INLINE const char* idInterpreter::FloatToString( float value )
{
static char text[ 32 ];
if( value == ( float )( int )value )
{
sprintf( text, "%d", ( int )value );
}
else
{
sprintf( text, "%f", value );
}
return text;
}
/*
====================
idInterpreter::AppendString
====================
*/
ID_INLINE void idInterpreter::AppendString( idVarDef* def, const char* from )
{
if( def->initialized == idVarDef::stackVariable )
{
idStr::Append( ( char* )&localstack[ localstackBase + def->value.stackOffset ], MAX_STRING_LEN, from );
}
else
{
idStr::Append( def->value.stringPtr, MAX_STRING_LEN, from );
}
}
/*
====================
idInterpreter::SetString
====================
*/
ID_INLINE void idInterpreter::SetString( idVarDef* def, const char* from )
{
if( def->initialized == idVarDef::stackVariable )
{
idStr::Copynz( ( char* )&localstack[ localstackBase + def->value.stackOffset ], from, MAX_STRING_LEN );
}
else
{
idStr::Copynz( def->value.stringPtr, from, MAX_STRING_LEN );
}
}
/*
====================
idInterpreter::GetString
====================
*/
ID_INLINE const char* idInterpreter::GetString( idVarDef* def )
{
if( def->initialized == idVarDef::stackVariable )
{
return ( char* )&localstack[ localstackBase + def->value.stackOffset ];
}
else
{
return def->value.stringPtr;
}
}
/*
====================
idInterpreter::GetVariable
====================
*/
ID_INLINE varEval_t idInterpreter::GetVariable( idVarDef* def )
{
if( def->initialized == idVarDef::stackVariable )
{
varEval_t val;
val.intPtr = ( int* )&localstack[ localstackBase + def->value.stackOffset ];
return val;
}
else
{
return def->value;
}
}
/*
====================
idInterpreter::NextInstruction
====================
*/
ID_INLINE void idInterpreter::NextInstruction( int position )
{
// Before we execute an instruction, we increment instructionPointer,
// therefore we need to compensate for that here.
instructionPointer = position - 1;
}
#endif /* !__SCRIPT_INTERPRETER_H__ */

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -34,20 +35,23 @@ If you have questions concerning this license or the applicable additional terms
// simple types. function types are dynamically allocated
idTypeDef type_void( ev_void, &def_void, "void", 0, NULL );
idTypeDef type_scriptevent( ev_scriptevent, &def_scriptevent, "scriptevent", sizeof( void* ), NULL );
idTypeDef type_namespace( ev_namespace, &def_namespace, "namespace", sizeof( void* ), NULL );
// RB: 64 bit fixes, changed all pointer types to intptr_t
idTypeDef type_scriptevent( ev_scriptevent, &def_scriptevent, "scriptevent", sizeof( intptr_t ), NULL );
idTypeDef type_namespace( ev_namespace, &def_namespace, "namespace", sizeof( intptr_t ), NULL );
idTypeDef type_string( ev_string, &def_string, "string", MAX_STRING_LEN, NULL );
idTypeDef type_float( ev_float, &def_float, "float", sizeof( float ), NULL );
idTypeDef type_vector( ev_vector, &def_vector, "vector", sizeof( idVec3 ), NULL );
idTypeDef type_entity( ev_entity, &def_entity, "entity", sizeof( int* ), NULL ); // stored as entity number pointer
idTypeDef type_field( ev_field, &def_field, "field", sizeof( void* ), NULL );
idTypeDef type_function( ev_function, &def_function, "function", sizeof( void* ), &type_void );
idTypeDef type_virtualfunction( ev_virtualfunction, &def_virtualfunction, "virtual function", sizeof( int ), NULL );
idTypeDef type_pointer( ev_pointer, &def_pointer, "pointer", sizeof( void* ), NULL );
idTypeDef type_object( ev_object, &def_object, "object", sizeof( int* ), NULL ); // stored as entity number pointer
idTypeDef type_jumpoffset( ev_jumpoffset, &def_jumpoffset, "<jump>", sizeof( int ), NULL ); // only used for jump opcodes
idTypeDef type_argsize( ev_argsize, &def_argsize, "<argsize>", sizeof( int ), NULL ); // only used for function call and thread opcodes
idTypeDef type_boolean( ev_boolean, &def_boolean, "boolean", sizeof( int ), NULL );
idTypeDef type_float( ev_float, &def_float, "float", sizeof( intptr_t ), NULL );
idTypeDef type_vector( ev_vector, &def_vector, "vector", E_EVENT_SIZEOF_VEC, NULL );
idTypeDef type_entity( ev_entity, &def_entity, "entity", sizeof( intptr_t ), NULL ); // stored as entity number pointer
idTypeDef type_field( ev_field, &def_field, "field", sizeof( intptr_t ), NULL );
idTypeDef type_function( ev_function, &def_function, "function", sizeof( intptr_t ), &type_void );
idTypeDef type_virtualfunction( ev_virtualfunction, &def_virtualfunction, "virtual function", sizeof( intptr_t ), NULL );
idTypeDef type_pointer( ev_pointer, &def_pointer, "pointer", sizeof( intptr_t ), NULL );
idTypeDef type_object( ev_object, &def_object, "object", sizeof( intptr_t ), NULL ); // stored as entity number pointer
idTypeDef type_jumpoffset( ev_jumpoffset, &def_jumpoffset, "<jump>", sizeof( intptr_t ), NULL ); // only used for jump opcodes
idTypeDef type_argsize( ev_argsize, &def_argsize, "<argsize>", sizeof( intptr_t ), NULL ); // only used for function call and thread opcodes
idTypeDef type_boolean( ev_boolean, &def_boolean, "boolean", sizeof( intptr_t ), NULL );
// RB end
idVarDef def_void( &type_void );
idVarDef def_scriptevent( &type_scriptevent );
@ -324,7 +328,11 @@ void idTypeDef::AddFunctionParm( idTypeDef* parmtype, const char* name )
{
if( type != ev_function )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::AddFunctionParm : tried to add parameter on non-function type" );
#else
gameLocal.Error( "idTypeDef::AddFunctionParm : tried to add parameter on non-function type" );
#endif
}
parmTypes.Append( parmtype );
@ -343,7 +351,11 @@ void idTypeDef::AddField( idTypeDef* fieldtype, const char* name )
{
if( type != ev_object )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::AddField : tried to add field to non-object type" );
#else
gameLocal.Error( "idTypeDef::AddField : tried to add field to non-object type" );
#endif
}
parmTypes.Append( fieldtype );
@ -411,7 +423,11 @@ idTypeDef* idTypeDef::SuperClass() const
{
if( type != ev_object )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::SuperClass : tried to get superclass of a non-object type" );
#else
gameLocal.Error( "idTypeDef::SuperClass : tried to get superclass of a non-object type" );
#endif
}
return auxType;
@ -428,7 +444,11 @@ idTypeDef* idTypeDef::ReturnType() const
{
if( type != ev_function )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::ReturnType: tried to get return type on non-function type" );
#else
gameLocal.Error( "idTypeDef::ReturnType: tried to get return type on non-function type" );
#endif
}
return auxType;
@ -445,7 +465,11 @@ void idTypeDef::SetReturnType( idTypeDef* returntype )
{
if( type != ev_function )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::SetReturnType: tried to set return type on non-function type" );
#else
gameLocal.Error( "idTypeDef::SetReturnType: tried to set return type on non-function type" );
#endif
}
auxType = returntype;
@ -462,7 +486,11 @@ idTypeDef* idTypeDef::FieldType() const
{
if( type != ev_field )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::FieldType: tried to get field type on non-field type" );
#else
gameLocal.Error( "idTypeDef::FieldType: tried to get field type on non-field type" );
#endif
}
return auxType;
@ -479,7 +507,11 @@ void idTypeDef::SetFieldType( idTypeDef* fieldtype )
{
if( type != ev_field )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::SetFieldType: tried to set return type on non-function type" );
#else
gameLocal.Error( "idTypeDef::SetFieldType: tried to set return type on non-function type" );
#endif
}
auxType = fieldtype;
@ -496,7 +528,11 @@ idTypeDef* idTypeDef::PointerType() const
{
if( type != ev_pointer )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::PointerType: tried to get pointer type on non-pointer" );
#else
gameLocal.Error( "idTypeDef::PointerType: tried to get pointer type on non-pointer" );
#endif
}
return auxType;
@ -513,7 +549,11 @@ void idTypeDef::SetPointerType( idTypeDef* pointertype )
{
if( type != ev_pointer )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::SetPointerType: tried to set type on non-pointer" );
#else
gameLocal.Error( "idTypeDef::SetPointerType: tried to set type on non-pointer" );
#endif
}
auxType = pointertype;
@ -793,7 +833,11 @@ void idVarDef::SetValue( const eval_t& _value, bool constant )
break;
default :
#if defined(USE_EXCEPTIONS)
throw idCompileError( va( "weird type on '%s'", Name() ) );
#else
gameLocal.Error( "weird type on '%s'", Name() );
#endif
break;
}
}
@ -1017,7 +1061,9 @@ idScriptObject::Save
*/
void idScriptObject::Save( idSaveGame* savefile ) const
{
size_t size;
// RB: 64 bit fix, changed size_t to int
int size;
// RB end
if( type == &type_object && data == NULL )
{
@ -1041,7 +1087,9 @@ idScriptObject::Restore
void idScriptObject::Restore( idRestoreGame* savefile )
{
idStr typeName;
// RB: 64 bit fix, changed size_t to int
int size;
// RB end
savefile->ReadString( typeName );
@ -1056,7 +1104,9 @@ void idScriptObject::Restore( idRestoreGame* savefile )
savefile->Error( "idScriptObject::Restore: failed to restore object of type '%s'.", typeName.c_str() );
}
// RB: 64 bit fix, changed size_t to int
savefile->ReadInt( size );
// RB end
if( size != type->Size() )
{
savefile->Error( "idScriptObject::Restore: size of object '%s' doesn't match size in save game.", typeName.c_str() );
@ -1383,6 +1433,43 @@ void idProgram::AddDefToNameList( idVarDef* def, const char* name )
varDefNames[i]->AddDef( def );
}
// RB: moved from AllocDef
byte* idProgram::ReserveDefMemory( int size )
{
byte* mem = &variables[ numVariables ];
numVariables += size;
if( numVariables > sizeof( variables ) )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( va( "Exceeded global memory size (%zd bytes)", sizeof( variables ) ) );
#else
gameLocal.Error( "Exceeded global memory size (%zd bytes)", sizeof( variables ) );
#endif
}
memset( mem, 0, size );
return mem;
}
// RB end
// RB: moved from AllocDef
idVarDef* idProgram::AllocVarDef( idTypeDef* type, const char* name, idVarDef* scope )
{
// allocate a new def
idVarDef* def = new( TAG_SCRIPT ) idVarDef( type );
def->scope = scope;
def->numUsers = 1;
def->num = varDefs.Append( def );
// add the def to the list with defs with this name and set the name pointer
AddDefToNameList( def, name );
return def;
}
// RB end
/*
============
idProgram::AllocDef
@ -1397,13 +1484,7 @@ idVarDef* idProgram::AllocDef( idTypeDef* type, const char* name, idVarDef* scop
idVarDef* def_z;
// allocate a new def
def = new( TAG_SCRIPT ) idVarDef( type );
def->scope = scope;
def->numUsers = 1;
def->num = varDefs.Append( def );
// add the def to the list with defs with this name and set the name pointer
AddDefToNameList( def, name );
def = AllocVarDef( type, name, scope );
if( ( type->Type() == ev_vector ) || ( ( type->Type() == ev_field ) && ( type->FieldType()->Type() == ev_vector ) ) )
{
@ -1421,7 +1502,9 @@ idVarDef* idProgram::AllocDef( idTypeDef* type, const char* name, idVarDef* scop
else if( scope->TypeDef()->Inherits( &type_object ) )
{
idTypeDef newtype( ev_field, NULL, "float field", 0, &type_float );
idTypeDef* type = GetType( newtype, true );
// RB: changed local type to ftype
idTypeDef* ftype = GetType( newtype, true );
// set the value to the variable's position in the object
def->value.ptrOffset = scope->TypeDef()->Size();
@ -1429,32 +1512,60 @@ idVarDef* idProgram::AllocDef( idTypeDef* type, const char* name, idVarDef* scop
// make automatic defs for the vectors elements
// origin can be accessed as origin_x, origin_y, and origin_z
sprintf( element, "%s_x", def->Name() );
def_x = AllocDef( type, element, scope, constant );
def_x = AllocDef( ftype, element, scope, constant );
sprintf( element, "%s_y", def->Name() );
def_y = AllocDef( type, element, scope, constant );
def_y->value.ptrOffset = def_x->value.ptrOffset + type_float.Size();
def_y = AllocDef( ftype, element, scope, constant );
def_y->value.ptrOffset = def_x->value.ptrOffset + sizeof( float );
sprintf( element, "%s_z", def->Name() );
def_z = AllocDef( type, element, scope, constant );
def_z->value.ptrOffset = def_y->value.ptrOffset + type_float.Size();
def_z = AllocDef( ftype, element, scope, constant );
def_z->value.ptrOffset = def_y->value.ptrOffset + sizeof( float );
// RB end
}
else
{
// RB: from dhewm3
idTypeDef newtype( ev_float, &def_float, "vector float", 0, NULL );
idTypeDef* ftype = GetType( newtype, true );
// make automatic defs for the vectors elements
// origin can be accessed as origin_x, origin_y, and origin_z
sprintf( element, "%s_x", def->Name() );
def_x = AllocDef( &type_float, element, scope, constant );
def_x = AllocVarDef( ftype, element, scope );
sprintf( element, "%s_y", def->Name() );
def_y = AllocDef( &type_float, element, scope, constant );
def_y = AllocVarDef( ftype, element, scope );
sprintf( element, "%s_z", def->Name() );
def_z = AllocDef( &type_float, element, scope, constant );
def_z = AllocVarDef( ftype, element, scope );
// point the vector def to the x coordinate
def->value = def_x->value;
def->initialized = def_x->initialized;
// get the memory for the full vector and point the _x, _y and _z
// defs at the vector member offsets
if( scope->Type() == ev_function )
{
// vector on stack
def->value.stackOffset = scope->value.functionPtr->locals;
def->initialized = idVarDef::stackVariable;
scope->value.functionPtr->locals += type->Size();
def_x->value.stackOffset = def->value.stackOffset;
def_y->value.stackOffset = def_x->value.stackOffset + sizeof( float );
def_z->value.stackOffset = def_y->value.stackOffset + sizeof( float );
}
else
{
// global vector
def->value.bytePtr = ReserveDefMemory( type->Size() );
def_x->value.bytePtr = def->value.bytePtr;
def_y->value.bytePtr = def_x->value.bytePtr + sizeof( float );
def_z->value.bytePtr = def_y->value.bytePtr + sizeof( float );
}
def_x->initialized = def->initialized;
def_y->initialized = def->initialized;
def_z->initialized = def->initialized;
// RB end
}
}
else if( scope->TypeDef()->Inherits( &type_object ) )
@ -1490,14 +1601,11 @@ idVarDef* idProgram::AllocDef( idTypeDef* type, const char* name, idVarDef* scop
//
// global variable
//
def->value.bytePtr = &variables[ numVariables ];
numVariables += def->TypeDef()->Size();
if( numVariables > sizeof( variables ) )
{
throw idCompileError( va( "Exceeded global memory size (%d bytes)", sizeof( variables ) ) );
}
// RB begin
def->value.bytePtr = ReserveDefMemory( def->TypeDef()->Size() );
// RB end
memset( def->value.bytePtr, 0, def->TypeDef()->Size() );
//memset( def->value.bytePtr, 0, def->TypeDef()->Size() );
}
return def;
@ -1550,7 +1658,11 @@ idVarDef* idProgram::GetDef( const idTypeDef* type, const char* name, const idVa
// see if the name is already in use for another type
if( bestDef && type && ( bestDef->TypeDef() != type ) )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( va( "Type mismatch on redeclaration of %s", name ) );
#else
gameLocal.Error( "Type mismatch on redeclaration of %s", name );
#endif
}
return bestDef;
@ -1734,7 +1846,11 @@ function_t& idProgram::AllocFunction( idVarDef* def )
{
if( functions.Num() >= functions.Max() )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( va( "Exceeded maximum allowed number of functions (%d)", functions.Max() ) );
#else
gameLocal.Error( "Exceeded maximum allowed number of functions (%d)", functions.Max() );
#endif
}
// fill in the dfunction
@ -1791,7 +1907,11 @@ statement_t* idProgram::AllocStatement()
{
if( statements.Num() >= statements.Max() )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( va( "Exceeded maximum allowed number of statements (%d)", statements.Max() ) );
#else
gameLocal.Error( "Exceeded maximum allowed number of statements (%d)", statements.Max() );
#endif
}
return statements.Alloc();
}
@ -1809,7 +1929,9 @@ void idProgram::BeginCompilation()
FreeData();
#if defined(USE_EXCEPTIONS)
try
#endif
{
// make the first statement a return for a "NULL" function
statement = AllocStatement();
@ -1832,11 +1954,12 @@ void idProgram::BeginCompilation()
// define the sys object
sysDef = AllocDef( &type_void, "sys", &def_namespace, true );
}
#if defined(USE_EXCEPTIONS)
catch( idCompileError& err )
{
gameLocal.Error( "%s", err.GetError() );
}
#endif
}
/*
@ -1846,7 +1969,9 @@ idProgram::DisassembleStatement
*/
void idProgram::DisassembleStatement( idFile* file, int instructionPointer ) const
{
opcode_t* op;
// RB: added const
const opcode_t* op;
// RB end
const statement_t* statement;
statement = &statements[ instructionPointer ];
@ -2012,7 +2137,9 @@ bool idProgram::CompileText( const char* source, const char* text, bool console
ospath = fileSystem->RelativePathToOSPath( source );
filenum = GetFilenum( ospath );
#if defined(USE_EXCEPTIONS)
try
#endif
{
compiler.CompileFile( text, filename, console );
@ -2024,12 +2151,16 @@ bool idProgram::CompileText( const char* source, const char* text, bool console
{
if( !def->value.functionPtr->eventdef && !def->value.functionPtr->firstStatement )
{
#if defined(USE_EXCEPTIONS)
throw idCompileError( va( "function %s was not defined\n", def->GlobalName() ) );
#else
gameLocal.Error( "function %s was not defined\n", def->GlobalName() );
#endif
}
}
}
}
#if defined(USE_EXCEPTIONS)
catch( idCompileError& err )
{
if( console )
@ -2042,6 +2173,7 @@ bool idProgram::CompileText( const char* source, const char* text, bool console
gameLocal.Error( "%s\n", err.GetError() );
}
};
#endif
if( !console )
{

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -543,6 +544,13 @@ public:
idTypeDef* GetType( idTypeDef& type, bool allocate );
idTypeDef* FindType( const char* name );
// RB begin
private:
byte* ReserveDefMemory( int size );
idVarDef* AllocVarDef( idTypeDef* type, const char* name, idVarDef* scope );
public:
// RB end
idVarDef* AllocDef( idTypeDef* type, const char* name, idVarDef* scope, bool constant );
idVarDef* GetDef( const idTypeDef* type, const char* name, const idVarDef* scope ) const;
void FreeDef( idVarDef* d, const idVarDef* scope );

View file

@ -175,9 +175,17 @@ void idCommonLocal::VPrintf( const char* fmt, va_list args )
}
}
#endif
if( !idLib::IsMainThread() )
{
// RB: printf should be thread-safe on Linux
#if defined(_WIN32)
OutputDebugString( msg );
#else
printf( msg );
#endif
// RB end
return;
}
@ -448,7 +456,9 @@ void idCommonLocal::DumpWarnings()
fileSystem->CloseFile( warningFile );
#ifndef ID_DEBUG
// RB begin
#if defined(_WIN32) && !defined(_DEBUG)
// RB end
idStr osPath;
osPath = fileSystem->RelativePathToOSPath( "warnings.txt", "fs_savepath" );
WinExec( va( "Notepad.exe %s", osPath.c_str() ), SW_SHOW );

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -369,6 +370,8 @@ idKeyInput::LocalizedKeyName
*/
const char* idKeyInput::LocalizedKeyName( keyNum_t keynum )
{
// RB: FIXME
#if defined(_WIN32)
if( keynum < K_JOY1 )
{
// On the PC, we want to turn the scan code in to a key label that matches the currently selected keyboard layout
@ -400,6 +403,10 @@ const char* idKeyInput::LocalizedKeyName( keyNum_t keynum )
}
}
return "????";
#else
return KeyNumToString( keynum );
#endif
// RB end
}
/*

View file

@ -1479,6 +1479,8 @@ idZipBuilder::GetFileTime
*/
bool idZipBuilder::GetFileTime( const idStr& filename, unsigned long* dostime ) const
{
// RB: FIXME
#if defined(_WIN32)
{
FILETIME filetime;
WIN32_FIND_DATA fileData;
@ -1492,6 +1494,9 @@ bool idZipBuilder::GetFileTime( const idStr& filename, unsigned long* dostime )
}
FindClose( findHandle );
}
#endif
// RB end
return false;
}

View file

@ -143,6 +143,8 @@ If you have questions concerning this license or the applicable additional terms
// DG end
#define ID_HDRSTOP
#define CALLBACK
#define __cdecl
#endif
// RB end

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -35,6 +36,8 @@ idCVar r_showBuffers( "r_showBuffers", "0", CVAR_INTEGER, "" );
//static const GLenum bufferUsage = GL_STATIC_DRAW_ARB;
static const GLenum bufferUsage = GL_DYNAMIC_DRAW_ARB;
// RB begin
#if defined(_WIN32)
/*
==================
IsWriteCombined
@ -53,7 +56,8 @@ bool IsWriteCombined( void* base )
bool isWriteCombined = ( ( info.AllocationProtect & PAGE_WRITECOMBINE ) != 0 );
return isWriteCombined;
}
#endif
// RB end
/*
@ -237,8 +241,10 @@ void idVertexBuffer::FreeBufferObject()
idLib::Printf( "vertex buffer free %p, api %p (%i bytes)\n", this, GetAPIObject(), GetSize() );
}
GLuint bufferObject = reinterpret_cast< GLuint >( apiObject );
qglDeleteBuffersARB( 1, & bufferObject );
// RB: 64 bit fixes, changed GLuint to GLintptrARB
GLintptrARB bufferObject = reinterpret_cast< GLintptrARB >( apiObject );
qglDeleteBuffersARB( 1, (const unsigned int*) & bufferObject );
// RB end
ClearWithoutFreeing();
}
@ -302,7 +308,10 @@ void idVertexBuffer::Update( const void* data, int updateSize ) const
int numBytes = ( updateSize + 15 ) & ~15;
GLuint bufferObject = reinterpret_cast< GLuint >( apiObject );
// RB: 64 bit fixes, changed GLuint to GLintptrARB
GLintptrARB bufferObject = reinterpret_cast< GLintptrARB >( apiObject );
// RB end
qglBindBufferARB( GL_ARRAY_BUFFER_ARB, bufferObject );
qglBufferSubDataARB( GL_ARRAY_BUFFER_ARB, GetOffset(), ( GLsizeiptrARB )numBytes, data );
/*
@ -324,7 +333,10 @@ void* idVertexBuffer::MapBuffer( bufferMapType_t mapType ) const
void* buffer = NULL;
GLuint bufferObject = reinterpret_cast< GLuint >( apiObject );
// RB: 64 bit fixes, changed GLuint to GLintptrARB
GLintptrARB bufferObject = reinterpret_cast< GLintptrARB >( apiObject );
// RB end
qglBindBufferARB( GL_ARRAY_BUFFER_ARB, bufferObject );
if( mapType == BM_READ )
{
@ -369,7 +381,10 @@ void idVertexBuffer::UnmapBuffer() const
assert( apiObject != NULL );
assert( IsMapped() );
GLuint bufferObject = reinterpret_cast< GLuint >( apiObject );
// RB: 64 bit fixes, changed GLuint to GLintptrARB
GLintptrARB bufferObject = reinterpret_cast< GLintptrARB >( apiObject );
// RB end
qglBindBufferARB( GL_ARRAY_BUFFER_ARB, bufferObject );
if( !qglUnmapBufferARB( GL_ARRAY_BUFFER_ARB ) )
{
@ -511,8 +526,10 @@ void idIndexBuffer::FreeBufferObject()
idLib::Printf( "index buffer free %p, api %p (%i bytes)\n", this, GetAPIObject(), GetSize() );
}
GLuint bufferObject = reinterpret_cast< GLuint >( apiObject );
qglDeleteBuffersARB( 1, & bufferObject );
// RB: 64 bit fixes, changed GLuint to GLintptrARB
GLintptrARB bufferObject = reinterpret_cast< GLintptrARB >( apiObject );
qglDeleteBuffersARB( 1, ( const unsigned int* )& bufferObject );
// RB end
ClearWithoutFreeing();
}
@ -577,7 +594,10 @@ void idIndexBuffer::Update( const void* data, int updateSize ) const
int numBytes = ( updateSize + 15 ) & ~15;
GLuint bufferObject = reinterpret_cast< GLuint >( apiObject );
// RB: 64 bit fixes, changed GLuint to GLintptrARB
GLintptrARB bufferObject = reinterpret_cast< GLintptrARB >( apiObject );
// RB end
qglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, bufferObject );
qglBufferSubDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, GetOffset(), ( GLsizeiptrARB )numBytes, data );
/*
@ -600,7 +620,10 @@ void* idIndexBuffer::MapBuffer( bufferMapType_t mapType ) const
void* buffer = NULL;
GLuint bufferObject = reinterpret_cast< GLuint >( apiObject );
// RB: 64 bit fixes, changed GLuint to GLintptrARB
GLintptrARB bufferObject = reinterpret_cast< GLintptrARB >( apiObject );
// RB end
qglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, bufferObject );
if( mapType == BM_READ )
{
@ -645,7 +668,10 @@ void idIndexBuffer::UnmapBuffer() const
assert( apiObject != NULL );
assert( IsMapped() );
GLuint bufferObject = reinterpret_cast< GLuint >( apiObject );
// RB: 64 bit fixes, changed GLuint to GLintptrARB
GLintptrARB bufferObject = reinterpret_cast< GLintptrARB >( apiObject );
// RB end
qglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, bufferObject );
if( !qglUnmapBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB ) )
{
@ -769,9 +795,12 @@ void idJointBuffer::FreeBufferObject()
idLib::Printf( "joint buffer free %p, api %p (%i joints)\n", this, GetAPIObject(), GetNumJoints() );
}
GLuint buffer = reinterpret_cast< GLuint >( apiObject );
// RB: 64 bit fixes, changed GLuint to GLintptrARB
GLintptrARB buffer = reinterpret_cast< GLintptrARB >( apiObject );
qglBindBufferARB( GL_UNIFORM_BUFFER, 0 );
qglDeleteBuffersARB( 1, & buffer );
qglDeleteBuffersARB( 1, (const GLuint*)& buffer );
// RB end
ClearWithoutFreeing();
}
@ -836,7 +865,10 @@ void idJointBuffer::Update( const float* joints, int numUpdateJoints ) const
const int numBytes = numUpdateJoints * 3 * 4 * sizeof( float );
qglBindBufferARB( GL_UNIFORM_BUFFER, reinterpret_cast< GLuint >( apiObject ) );
// RB: 64 bit fixes, changed GLuint to GLintptrARB
qglBindBufferARB( GL_UNIFORM_BUFFER, reinterpret_cast< GLintptrARB >( apiObject ) );
// RB end
qglBufferSubDataARB( GL_UNIFORM_BUFFER, GetOffset(), ( GLsizeiptrARB )numBytes, joints );
}
@ -855,7 +887,10 @@ float* idJointBuffer::MapBuffer( bufferMapType_t mapType ) const
void* buffer = NULL;
qglBindBufferARB( GL_UNIFORM_BUFFER, reinterpret_cast< GLuint >( apiObject ) );
// RB: 64 bit fixes, changed GLuint to GLintptrARB
qglBindBufferARB( GL_UNIFORM_BUFFER, reinterpret_cast< GLintptrARB >( apiObject ) );
// RB end
numBytes = numBytes;
assert( GetOffset() == 0 );
//buffer = qglMapBufferARB( GL_UNIFORM_BUFFER, GL_WRITE_ONLY_ARB );
@ -884,7 +919,10 @@ void idJointBuffer::UnmapBuffer() const
assert( apiObject != NULL );
assert( IsMapped() );
qglBindBufferARB( GL_UNIFORM_BUFFER, reinterpret_cast< GLuint >( apiObject ) );
// RB: 64 bit fixes, changed GLuint to GLintptrARB
qglBindBufferARB( GL_UNIFORM_BUFFER, reinterpret_cast< GLintptrARB >( apiObject ) );
// RB end
if( !qglUnmapBufferARB( GL_UNIFORM_BUFFER ) )
{
idLib::Printf( "idJointBuffer::UnmapBuffer failed\n" );

View file

@ -2835,7 +2835,7 @@ int lwResolvePolySurfaces( lwPolygonList* polygon, lwTagList* tlist,
lwSurface** surf, int* nsurfs )
{
lwSurface** s, *st;
int i, index;
int i;
if( tlist->count == 0 ) return 1;
@ -2855,10 +2855,13 @@ int lwResolvePolySurfaces( lwPolygonList* polygon, lwTagList* tlist,
st = st->next;
}
}
// RB: 64 bit fixes
uintptr_t index;
for( i = 0; i < polygon->count; i++ )
{
index = ( int ) polygon->pol[ i ].surf;
index = ( uintptr_t ) polygon->pol[ i ].surf;
// RB end
if( index < 0 || index > tlist->count ) return 0;
if( !s[ index ] )
{

View file

@ -488,12 +488,24 @@ void idImage::AllocImage()
// As of 2011-10-6 using NVIDIA hardware and drivers we have to allocate the memory with HeapAlloc
// with the exact size otherwise large image allocation (for instance for physical page textures)
// may fail on Vista 32-bit.
// RB begin
#if defined(_WIN32)
void* data = HeapAlloc( GetProcessHeap(), 0, compressedSize );
qglCompressedTexImage2DARB( uploadTarget + side, level, internalFormat, w, h, 0, compressedSize, data );
if( data != NULL )
{
HeapFree( GetProcessHeap(), 0, data );
}
#else
byte* data = ( byte* )Mem_Alloc( compressedSize, TAG_TEMP );
qglCompressedTexImage2DARB( uploadTarget + side, level, internalFormat, w, h, 0, compressedSize, data );
if( data != NULL )
{
Mem_Free( data );
}
#endif
// RB end
}
else
{

View file

@ -733,7 +733,10 @@ void idRenderSystemLocal::SwapCommandBuffers_FinishRendering(
// read back the start and end timer queries from the previous frame
if( glConfig.timerQueryAvailable )
{
uint64 drawingTimeNanoseconds = 0;
// RB: 64 bit fixes, changed int64 to GLuint64EXT
GLuint64EXT drawingTimeNanoseconds = 0;
// RB end
if( tr.timerQueryId != 0 )
{
qglGetQueryObjectui64vEXT( tr.timerQueryId, GL_QUERY_RESULT, &drawingTimeNanoseconds );

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -31,8 +32,13 @@ If you have questions concerning this license or the applicable additional terms
#include "tr_local.h"
// RB begin
#if defined(_WIN32)
// Vista OpenGL wrapper check
#include "../sys/win32/win_local.h"
#endif
// RB end
// DeviceContext bypasses RenderSystem to work directly with this
idGuiModel* tr_guiModel;
@ -195,7 +201,9 @@ idCVar stereoRender_deGhost( "stereoRender_deGhost", "0.05", CVAR_FLOAT | CVAR_A
// GL_ARB_multitexture
PFNGLACTIVETEXTUREPROC qglActiveTextureARB;
PFNGLCLIENTACTIVETEXTUREPROC qglClientActiveTextureARB;
// RB: deprecated
//PFNGLCLIENTACTIVETEXTUREPROC qglClientActiveTextureARB;
// RB end
// GL_EXT_direct_state_access
PFNGLBINDMULTITEXTUREEXTPROC qglBindMultiTextureEXT;
@ -319,7 +327,9 @@ void APIENTRY glBindMultiTextureEXT( GLenum texunit, GLenum target, GLuint textu
R_CheckExtension
=================
*/
bool R_CheckExtension( char* name )
// RB begin
static bool R_CheckExtension( const char* name )
// RB end
{
if( !strstr( glConfig.extensions_string, name ) )
{
@ -343,8 +353,15 @@ static void CALLBACK DebugCallback( unsigned int source, unsigned int type,
unsigned int id, unsigned int severity, int length, const char* message, void* userParam )
{
// it probably isn't safe to do an idLib::Printf at this point
// RB begin
#if defined(_WIN32)
OutputDebugString( message );
OutputDebugString( "\n" );
#else
printf( "%s\n", message );
#endif
// RB end
}
/*
@ -379,7 +396,9 @@ static void R_CheckPortableExtensions()
if( glConfig.multitextureAvailable )
{
qglActiveTextureARB = ( void( APIENTRY* )( GLenum ) )GLimp_ExtensionPointer( "glActiveTextureARB" );
qglClientActiveTextureARB = ( void( APIENTRY* )( GLenum ) )GLimp_ExtensionPointer( "glClientActiveTextureARB" );
// RB: deprecated
//qglClientActiveTextureARB = ( void( APIENTRY* )( GLenum ) )GLimp_ExtensionPointer( "glClientActiveTextureARB" );
// RB end
}
// GL_EXT_direct_state_access
@ -919,6 +938,8 @@ void R_InitOpenGL()
// Reset our gamma
R_SetColorMappings();
// RB begin
#if defined(_WIN32)
static bool glCheck = false;
if( !glCheck && win32.osversion.dwMajorVersion == 6 )
{
@ -943,6 +964,8 @@ void R_InitOpenGL()
}
}
}
#endif
// RB end
}
/*
@ -1849,6 +1872,8 @@ void GfxInfo_f( const idCmdArgs& args )
common->Printf( "-------\n" );
// RB begin
#if defined(_WIN32)
// WGL_EXT_swap_interval
typedef BOOL ( WINAPI * PFNWGLSWAPINTERVALEXTPROC )( int interval );
extern PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
@ -1861,6 +1886,8 @@ void GfxInfo_f( const idCmdArgs& args )
{
common->Printf( "swapInterval not forced\n" );
}
#endif
// RB end
if( glConfig.stereoPixelFormatAvailable && glConfig.isStereoPixelFormat )
{

View file

@ -170,7 +170,9 @@ void RB_DrawElementsWithCounters( const drawSurf_t* surf )
}
indexBuffer = &vertexCache.frameData[vertexCache.drawListNum].indexBuffer;
}
const int indexOffset = ( int )( ibHandle >> VERTCACHE_OFFSET_SHIFT ) & VERTCACHE_OFFSET_MASK;
// RB: 64 bit fixes, changed int to GLintptrARB
const GLintptrARB indexOffset = ( GLintptrARB )( ibHandle >> VERTCACHE_OFFSET_SHIFT ) & VERTCACHE_OFFSET_MASK;
// RB end
RENDERLOG_PRINTF( "Binding Buffers: %p:%i %p:%i\n", vertexBuffer, vertOffset, indexBuffer, indexOffset );
@ -200,22 +202,26 @@ void RB_DrawElementsWithCounters( const drawSurf_t* surf )
}
assert( ( jointBuffer.GetOffset() & ( glConfig.uniformBufferOffsetAlignment - 1 ) ) == 0 );
const GLuint ubo = reinterpret_cast< GLuint >( jointBuffer.GetAPIObject() );
// RB: 64 bit fixes, changed GLuint to GLintptrARB
const GLintptrARB ubo = reinterpret_cast< GLintptrARB >( jointBuffer.GetAPIObject() );
// RB end
qglBindBufferRange( GL_UNIFORM_BUFFER, 0, ubo, jointBuffer.GetOffset(), jointBuffer.GetNumJoints() * sizeof( idJointMat ) );
}
renderProgManager.CommitUniforms();
if( backEnd.glState.currentIndexBuffer != ( GLuint )indexBuffer->GetAPIObject() || !r_useStateCaching.GetBool() )
// RB: 64 bit fixes, changed GLuint to GLintptrARB
if( backEnd.glState.currentIndexBuffer != ( GLintptrARB )indexBuffer->GetAPIObject() || !r_useStateCaching.GetBool() )
{
qglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, ( GLuint )indexBuffer->GetAPIObject() );
backEnd.glState.currentIndexBuffer = ( GLuint )indexBuffer->GetAPIObject();
qglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, ( GLintptrARB )indexBuffer->GetAPIObject() );
backEnd.glState.currentIndexBuffer = ( GLintptrARB )indexBuffer->GetAPIObject();
}
if( ( backEnd.glState.vertexLayout != LAYOUT_DRAW_VERT ) || ( backEnd.glState.currentVertexBuffer != ( GLuint )vertexBuffer->GetAPIObject() ) || !r_useStateCaching.GetBool() )
if( ( backEnd.glState.vertexLayout != LAYOUT_DRAW_VERT ) || ( backEnd.glState.currentVertexBuffer != ( GLintptrARB )vertexBuffer->GetAPIObject() ) || !r_useStateCaching.GetBool() )
{
qglBindBufferARB( GL_ARRAY_BUFFER_ARB, ( GLuint )vertexBuffer->GetAPIObject() );
backEnd.glState.currentVertexBuffer = ( GLuint )vertexBuffer->GetAPIObject();
qglBindBufferARB( GL_ARRAY_BUFFER_ARB, ( GLintptrARB )vertexBuffer->GetAPIObject() );
backEnd.glState.currentVertexBuffer = ( GLintptrARB )vertexBuffer->GetAPIObject();
qglEnableVertexAttribArrayARB( PC_ATTRIB_INDEX_VERTEX );
qglEnableVertexAttribArrayARB( PC_ATTRIB_INDEX_NORMAL );
@ -233,6 +239,7 @@ void RB_DrawElementsWithCounters( const drawSurf_t* surf )
backEnd.glState.vertexLayout = LAYOUT_DRAW_VERT;
}
// RB end
qglDrawElementsBaseVertex( GL_TRIANGLES,
r_singleTriangle.GetBool() ? 3 : surf->numIndexes,
@ -1713,11 +1720,11 @@ static void RB_StencilShadowPass( const drawSurf_t* drawSurfs, const viewLight_t
RENDERLOG_PRINTF( "Binding Buffers: %p %p\n", vertexBuffer, indexBuffer );
if( backEnd.glState.currentIndexBuffer != ( GLuint )indexBuffer->GetAPIObject() || !r_useStateCaching.GetBool() )
// RB: 64 bit fixes, changed GLuint to GLintptrARB
if( backEnd.glState.currentIndexBuffer != ( GLintptrARB )indexBuffer->GetAPIObject() || !r_useStateCaching.GetBool() )
{
qglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, ( GLuint )indexBuffer->GetAPIObject() );
backEnd.glState.currentIndexBuffer = ( GLuint )indexBuffer->GetAPIObject();
qglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, ( GLintptrARB )indexBuffer->GetAPIObject() );
backEnd.glState.currentIndexBuffer = ( GLintptrARB )indexBuffer->GetAPIObject();
}
if( drawSurf->jointCache )
@ -1732,13 +1739,13 @@ static void RB_StencilShadowPass( const drawSurf_t* drawSurfs, const viewLight_t
}
assert( ( jointBuffer.GetOffset() & ( glConfig.uniformBufferOffsetAlignment - 1 ) ) == 0 );
const GLuint ubo = reinterpret_cast< GLuint >( jointBuffer.GetAPIObject() );
const GLintptrARB ubo = reinterpret_cast< GLintptrARB >( jointBuffer.GetAPIObject() );
qglBindBufferRange( GL_UNIFORM_BUFFER, 0, ubo, jointBuffer.GetOffset(), jointBuffer.GetNumJoints() * sizeof( idJointMat ) );
if( ( backEnd.glState.vertexLayout != LAYOUT_DRAW_SHADOW_VERT_SKINNED ) || ( backEnd.glState.currentVertexBuffer != ( GLuint )vertexBuffer->GetAPIObject() ) || !r_useStateCaching.GetBool() )
if( ( backEnd.glState.vertexLayout != LAYOUT_DRAW_SHADOW_VERT_SKINNED ) || ( backEnd.glState.currentVertexBuffer != ( GLintptrARB )vertexBuffer->GetAPIObject() ) || !r_useStateCaching.GetBool() )
{
qglBindBufferARB( GL_ARRAY_BUFFER_ARB, ( GLuint )vertexBuffer->GetAPIObject() );
backEnd.glState.currentVertexBuffer = ( GLuint )vertexBuffer->GetAPIObject();
qglBindBufferARB( GL_ARRAY_BUFFER_ARB, ( GLintptrARB )vertexBuffer->GetAPIObject() );
backEnd.glState.currentVertexBuffer = ( GLintptrARB )vertexBuffer->GetAPIObject();
qglEnableVertexAttribArrayARB( PC_ATTRIB_INDEX_VERTEX );
qglDisableVertexAttribArrayARB( PC_ATTRIB_INDEX_NORMAL );
@ -1758,10 +1765,10 @@ static void RB_StencilShadowPass( const drawSurf_t* drawSurfs, const viewLight_t
else
{
if( ( backEnd.glState.vertexLayout != LAYOUT_DRAW_SHADOW_VERT ) || ( backEnd.glState.currentVertexBuffer != ( GLuint )vertexBuffer->GetAPIObject() ) || !r_useStateCaching.GetBool() )
if( ( backEnd.glState.vertexLayout != LAYOUT_DRAW_SHADOW_VERT ) || ( backEnd.glState.currentVertexBuffer != ( GLintptrARB )vertexBuffer->GetAPIObject() ) || !r_useStateCaching.GetBool() )
{
qglBindBufferARB( GL_ARRAY_BUFFER_ARB, ( GLuint )vertexBuffer->GetAPIObject() );
backEnd.glState.currentVertexBuffer = ( GLuint )vertexBuffer->GetAPIObject();
qglBindBufferARB( GL_ARRAY_BUFFER_ARB, ( GLintptrARB )vertexBuffer->GetAPIObject() );
backEnd.glState.currentVertexBuffer = ( GLintptrARB )vertexBuffer->GetAPIObject();
qglEnableVertexAttribArrayARB( PC_ATTRIB_INDEX_VERTEX );
qglDisableVertexAttribArrayARB( PC_ATTRIB_INDEX_NORMAL );
@ -1775,6 +1782,7 @@ static void RB_StencilShadowPass( const drawSurf_t* drawSurfs, const viewLight_t
backEnd.glState.vertexLayout = LAYOUT_DRAW_SHADOW_VERT;
}
}
// RB end
renderProgManager.CommitUniforms();

View file

@ -796,8 +796,10 @@ static void RB_ShowSilhouette()
continue;
}
qglBindBufferARB( GL_ARRAY_BUFFER_ARB, ( GLuint )vertexBuffer.GetAPIObject() );
int vertOffset = vertexBuffer.GetOffset();
// RB: 64 bit fixes, changed GLuint to GLintptrARB
qglBindBufferARB( GL_ARRAY_BUFFER_ARB, ( GLintptrARB )vertexBuffer.GetAPIObject() );
GLintptrARB vertOffset = vertexBuffer.GetOffset();
// RB end
qglVertexPointer( 3, GL_FLOAT, sizeof( idShadowVert ), ( void* )vertOffset );
qglBegin( GL_LINES );

View file

@ -79,7 +79,11 @@ void R_ToggleSmpFrame()
frameData = &smpFrameData[smpFrame % NUM_FRAME_DATA];
// reset the memory allocation
const unsigned int bytesNeededForAlignment = FRAME_ALLOC_ALIGNMENT - ( ( unsigned int )frameData->frameMemory & ( FRAME_ALLOC_ALIGNMENT - 1 ) );
// RB: 64 bit fixes, changed unsigned int to uintptr_t
const uintptr_t bytesNeededForAlignment = FRAME_ALLOC_ALIGNMENT - ( ( uintptr_t )frameData->frameMemory & ( FRAME_ALLOC_ALIGNMENT - 1 ) );
// RB end
frameData->frameMemoryAllocated.SetValue( bytesNeededForAlignment );
frameData->frameMemoryUsed.SetValue( 0 );

View file

@ -645,9 +645,12 @@ struct glstate_t
int faceCulling;
vertexLayoutType_t vertexLayout;
unsigned int currentVertexBuffer;
unsigned int currentIndexBuffer;
// RB: 64 bit fixes, changed unsigned int to uintptr_t
uintptr_t currentVertexBuffer;
uintptr_t currentIndexBuffer;
// RB end
float polyOfsScale;
float polyOfsBias;

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -292,40 +293,42 @@ int idSimpleWindow::GetWinVarOffset( idWinVar* wv, drawWin_t* owner )
{
int ret = -1;
// RB: 64 bit fixes, changed oldschool offsets using ptrdiff_t
if( wv == &rect )
{
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->rect;
ret = ( ptrdiff_t )&rect - ( ptrdiff_t )this;
}
if( wv == &backColor )
{
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->backColor;
ret = ( ptrdiff_t )&backColor - ( ptrdiff_t )this;
}
if( wv == &matColor )
{
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->matColor;
ret = ( ptrdiff_t )&matColor - ( ptrdiff_t )this;
}
if( wv == &foreColor )
{
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->foreColor;
ret = ( ptrdiff_t )&foreColor - ( ptrdiff_t )this;
}
if( wv == &borderColor )
{
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->borderColor;
ret = ( ptrdiff_t )&borderColor - ( ptrdiff_t )this;
}
if( wv == &textScale )
{
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->textScale;
ret = ( ptrdiff_t )&textScale - ( ptrdiff_t )this;
}
if( wv == &rotate )
{
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->rotate;
ret = ( ptrdiff_t )&rotate - ( ptrdiff_t )this;
}
// RB end
if( ret != -1 )
{

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
Copyright (C) 2012 Robert Beckebans
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
@ -2027,47 +2028,58 @@ idWindow::GetWinVarOffset
*/
int idWindow::GetWinVarOffset( idWinVar* wv, drawWin_t* owner )
{
// RB: 64 bit fixes, changed oldschool offsets using ptrdiff_t
int ret = -1;
if( wv == &rect )
{
ret = ( int ) & ( ( idWindow* ) 0 )->rect;
//ret = (intptr_t)&( ( idWindow * ) 0 )->rect;
//ret = offsetof( idWindow, rect );
ret = ( ptrdiff_t )&rect - ( ptrdiff_t )this;
}
if( wv == &backColor )
{
ret = ( int ) & ( ( idWindow* ) 0 )->backColor;
//ret = (int)&( ( idWindow * ) 0 )->backColor;
ret = ( ptrdiff_t )&backColor - ( ptrdiff_t )this;
}
if( wv == &matColor )
{
ret = ( int ) & ( ( idWindow* ) 0 )->matColor;
//ret = (int)&( ( idWindow * ) 0 )->matColor;
ret = ( ptrdiff_t )&matColor - ( ptrdiff_t )this;
}
if( wv == &foreColor )
{
ret = ( int ) & ( ( idWindow* ) 0 )->foreColor;
//ret = (int)&( ( idWindow * ) 0 )->foreColor;
ret = ( ptrdiff_t )&foreColor - ( ptrdiff_t )this;
}
if( wv == &hoverColor )
{
ret = ( int ) & ( ( idWindow* ) 0 )->hoverColor;
//ret = (int)&( ( idWindow * ) 0 )->hoverColor;
ret = ( ptrdiff_t )&hoverColor - ( ptrdiff_t )this;
}
if( wv == &borderColor )
{
ret = ( int ) & ( ( idWindow* ) 0 )->borderColor;
//ret = (int)&( ( idWindow * ) 0 )->borderColor;
ret = ( ptrdiff_t )&borderColor - ( ptrdiff_t )this;
}
if( wv == &textScale )
{
ret = ( int ) & ( ( idWindow* ) 0 )->textScale;
//ret = (int)&( ( idWindow * ) 0 )->textScale;
ret = ( ptrdiff_t )&textScale - ( ptrdiff_t )this;
}
if( wv == &rotate )
{
ret = ( int ) & ( ( idWindow* ) 0 )->rotate;
//ret = (int)&( ( idWindow * ) 0 )->rotate;
ret = ( ptrdiff_t )&rotate - ( ptrdiff_t )this;
}
// RB end
if( ret != -1 )
{
@ -3183,7 +3195,9 @@ Returns a register index
int idWindow::ParseTerm( idTokenParser* src, idWinVar* var, int component )
{
idToken token;
int a, b;
// RB: 64 bit fixes, changed int to intptr_t
intptr_t a, b;
// RB end
src->ReadToken( &token );
@ -3234,7 +3248,10 @@ int idWindow::ParseTerm( idTokenParser* src, idWinVar* var, int component )
}
if( var )
{
a = ( int )var;
// RB: 64 bit fixes, changed int to intptr_t
a = ( intptr_t )var;
// RB end
//assert(dynamic_cast<idWinVec4*>(var));
var->Init( token, this );
b = component;
@ -3281,7 +3298,9 @@ int idWindow::ParseTerm( idTokenParser* src, idWinVar* var, int component )
// ugly but used for post parsing to fixup named vars
char* p = new( TAG_OLD_UI ) char[token.Length() + 1];
strcpy( p, token );
a = ( int )p;
// RB: 64 bit fixes, changed int to intptr_t
a = ( intptr_t )p;
// RB: 64 bit fixes, changed int to intptr_t
b = -2;
return EmitOp( a, b, WOP_TYPE_VAR );
}
@ -4305,68 +4324,70 @@ void idWindow::FixupTransitions()
transitions[i].data = NULL;
if( dw != NULL && ( dw->win != NULL || dw->simp != NULL ) )
{
// RB: 64 bit fixes, changed oldschool offsets using ptrdiff_t
if( dw->win != NULL )
{
if( transitions[i].offset == ( int ) & ( ( idWindow* ) 0 )->rect )
if( transitions[i].offset == ( ptrdiff_t )&rect - ( ptrdiff_t )this )
{
transitions[i].data = &dw->win->rect;
}
else if( transitions[i].offset == ( int ) & ( ( idWindow* ) 0 )->backColor )
else if( transitions[i].offset == ( ptrdiff_t )&backColor - ( ptrdiff_t )this )
{
transitions[i].data = &dw->win->backColor;
}
else if( transitions[i].offset == ( int ) & ( ( idWindow* ) 0 )->matColor )
else if( transitions[i].offset == ( ptrdiff_t )&matColor - ( ptrdiff_t )this )
{
transitions[i].data = &dw->win->matColor;
}
else if( transitions[i].offset == ( int ) & ( ( idWindow* ) 0 )->foreColor )
else if( transitions[i].offset == ( ptrdiff_t )&foreColor - ( ptrdiff_t )this )
{
transitions[i].data = &dw->win->foreColor;
}
else if( transitions[i].offset == ( int ) & ( ( idWindow* ) 0 )->borderColor )
else if( transitions[i].offset == ( ptrdiff_t )&borderColor - ( ptrdiff_t )this )
{
transitions[i].data = &dw->win->borderColor;
}
else if( transitions[i].offset == ( int ) & ( ( idWindow* ) 0 )->textScale )
else if( transitions[i].offset == ( ptrdiff_t )&textScale - ( ptrdiff_t )this )
{
transitions[i].data = &dw->win->textScale;
}
else if( transitions[i].offset == ( int ) & ( ( idWindow* ) 0 )->rotate )
else if( transitions[i].offset == ( ptrdiff_t )&rotate - ( ptrdiff_t )this )
{
transitions[i].data = &dw->win->rotate;
}
}
else
{
if( transitions[i].offset == ( int ) & ( ( idSimpleWindow* ) 0 )->rect )
if( transitions[i].offset == ( ptrdiff_t )&rect - ( ptrdiff_t )this )
{
transitions[i].data = &dw->simp->rect;
}
else if( transitions[i].offset == ( int ) & ( ( idSimpleWindow* ) 0 )->backColor )
else if( transitions[i].offset == ( ptrdiff_t )&backColor - ( ptrdiff_t )this )
{
transitions[i].data = &dw->simp->backColor;
}
else if( transitions[i].offset == ( int ) & ( ( idSimpleWindow* ) 0 )->matColor )
else if( transitions[i].offset == ( ptrdiff_t )&matColor - ( ptrdiff_t )this )
{
transitions[i].data = &dw->simp->matColor;
}
else if( transitions[i].offset == ( int ) & ( ( idSimpleWindow* ) 0 )->foreColor )
else if( transitions[i].offset == ( ptrdiff_t )&foreColor - ( ptrdiff_t )this )
{
transitions[i].data = &dw->simp->foreColor;
}
else if( transitions[i].offset == ( int ) & ( ( idSimpleWindow* ) 0 )->borderColor )
else if( transitions[i].offset == ( ptrdiff_t )&borderColor - ( ptrdiff_t )this )
{
transitions[i].data = &dw->simp->borderColor;
}
else if( transitions[i].offset == ( int ) & ( ( idSimpleWindow* ) 0 )->textScale )
else if( transitions[i].offset == ( ptrdiff_t )&textScale - ( ptrdiff_t )this )
{
transitions[i].data = &dw->simp->textScale;
}
else if( transitions[i].offset == ( int ) & ( ( idSimpleWindow* ) 0 )->rotate )
else if( transitions[i].offset == ( ptrdiff_t )&rotate - ( ptrdiff_t )this )
{
transitions[i].data = &dw->simp->rotate;
}
}
// RB end
}
if( transitions[i].data == NULL )
{
@ -4434,7 +4455,9 @@ void idWindow::FixupParms()
const char* p = ( const char* )( ops[i].a );
idWinVar* var = GetWinVarByName( p, true );
delete []p;
ops[i].a = ( int )var;
// RB: 64 bit fix, changed int to intptr_t
ops[i].a = ( intptr_t )var;
// RB end
ops[i].b = -1;
}
}

View file

@ -109,7 +109,9 @@ typedef enum
typedef struct
{
wexpOpType_t opType;
int a, b, c, d;
// RB: 64 bit fixes, changed int to intptr_t
intptr_t a, b, c, d;
// RB end
} wexpOp_t;
struct idRegEntry