Everything compiles on Linux. Now we can fix the linker problems! :)

This commit is contained in:
Robert Beckebans 2012-12-07 18:29:47 +01:00
parent 948865123d
commit 3639ba0c7b
25 changed files with 3426 additions and 3039 deletions

View file

@ -28,6 +28,10 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_definitions(-DUSE_XINPUT) add_definitions(-DUSE_XINPUT)
endif() 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_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_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") #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. 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 ) 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 ); void RestorePersistentData( const idDict& spawnArgs );
static void LocalUser_CompleteAchievement( achievement_t id ); 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 ); 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: private:
idEntityPtr< idPlayer > owner; idEntityPtr< idPlayer > owner;

View file

@ -302,7 +302,9 @@ void idGrabber::StartDrag( idEntity* grabEnt, int id )
} }
else if( grabEnt->IsType( idMoveableItem::Type ) ) 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 // 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() ); 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 // idItemTeam does not rotate and bob

View file

@ -1531,12 +1531,15 @@ void idTrigger_Flag::Event_Touch( idEntity* other, trace_t* trace )
case 0 : case 0 :
flag->PostEventMS( eventFlag, 0 ); flag->PostEventMS( eventFlag, 0 );
break; break;
// RB: 64 bit fixes, changed NULL to 0
case 1 : case 1 :
flag->PostEventMS( eventFlag, 0, NULL ); flag->PostEventMS( eventFlag, 0, 0 );
break; break;
case 2 : case 2 :
flag->PostEventMS( eventFlag, 0, NULL, NULL ); flag->PostEventMS( eventFlag, 0, 0, 0 );
break; 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 ) if( moveable )
{ {
moveable->Unbind(); 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 ) if( af )
{ {
af->Unbind(); 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(); 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 Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 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"). 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; idTypeInfo* c;
int num; 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; va_list args;
assert( ev ); assert( ev );
@ -995,8 +998,10 @@ bool idClass::ProcessEvent( const idEventDef* ev, idEventArg arg1, idEventArg ar
idClass::ProcessEventArgPtr 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; idTypeInfo* c;
int num; int num;
eventCallback_t callback; eventCallback_t callback;
@ -1028,8 +1033,11 @@ bool idClass::ProcessEventArgPtr( const idEventDef* ev, int* data )
callback = c->eventMap[ num ]; 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 #if !CPU_EASYARGS
/* /*
on ppc architecture, floats are passed in a seperate set of registers on ppc architecture, floats are passed in a seperate set of registers
the function prototypes must have matching float declaration 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 ); assert( D_EVENT_MAXARGS == 8 );
// RB: 64 bit fixes, changed int to intptr_t
switch( ev->GetNumArgs() ) switch( ev->GetNumArgs() )
{ {
case 0 : case 0 :
@ -1062,42 +1071,42 @@ bool idClass::ProcessEventArgPtr( const idEventDef* ev, int* data )
break; break;
case 1 : 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 ] ); ( this->*( eventCallback_1_t )callback )( data[ 0 ] );
break; break;
case 2 : 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 ] ); ( this->*( eventCallback_2_t )callback )( data[ 0 ], data[ 1 ] );
break; break;
case 3 : 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 ] ); ( this->*( eventCallback_3_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ] );
break; break;
case 4 : 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 ] ); ( this->*( eventCallback_4_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ] );
break; break;
case 5 : 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 ] ); ( this->*( eventCallback_5_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ] );
break; break;
case 6 : 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 ] ); ( this->*( eventCallback_6_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ] );
break; break;
case 7 : 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 ] ); ( this->*( eventCallback_7_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ] );
break; break;
case 8 : 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 ] ); ( this->*( eventCallback_8_t )callback )( data[ 0 ], data[ 1 ], data[ 2 ], data[ 3 ], data[ 4 ], data[ 5 ], data[ 6 ], data[ 7 ] );
break; break;
@ -1105,6 +1114,7 @@ bool idClass::ProcessEventArgPtr( const idEventDef* ev, int* data )
gameLocal.Warning( "Invalid formatspec on event '%s'", ev->GetName() ); gameLocal.Warning( "Invalid formatspec on event '%s'", ev->GetName() );
break; break;
} }
// RB end
#endif #endif

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 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"). 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: public:
int type; int type;
int value; // RB: 64 bit fix, changed int to intptr_t
intptr_t value;
// RB end
idEventArg() idEventArg()
{ {
@ -76,31 +79,33 @@ public:
type = D_EVENT_FLOAT; type = D_EVENT_FLOAT;
value = *reinterpret_cast<int*>( &data ); value = *reinterpret_cast<int*>( &data );
}; };
// RB: 64 bit fixes, changed int to intptr_t
idEventArg( idVec3& data ) idEventArg( idVec3& data )
{ {
type = D_EVENT_VECTOR; type = D_EVENT_VECTOR;
value = reinterpret_cast<int>( &data ); value = reinterpret_cast<intptr_t>( &data );
}; };
idEventArg( const idStr& data ) idEventArg( const idStr& data )
{ {
type = D_EVENT_STRING; type = D_EVENT_STRING;
value = reinterpret_cast<int>( data.c_str() ); value = reinterpret_cast<intptr_t>( data.c_str() );
}; };
idEventArg( const char* data ) idEventArg( const char* data )
{ {
type = D_EVENT_STRING; type = D_EVENT_STRING;
value = reinterpret_cast<int>( data ); value = reinterpret_cast<intptr_t>( data );
}; };
idEventArg( const class idEntity* data ) idEventArg( const class idEntity* data )
{ {
type = D_EVENT_ENTITY; type = D_EVENT_ENTITY;
value = reinterpret_cast<int>( data ); value = reinterpret_cast<intptr_t>( data );
}; };
idEventArg( const struct trace_s* data ) idEventArg( const struct trace_s* data )
{ {
type = D_EVENT_TRACE; type = D_EVENT_TRACE;
value = reinterpret_cast<int>( data ); value = reinterpret_cast<intptr_t>( data );
}; };
// RB end
}; };
class idAllocError : public idException 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. incorrect. Use this on concrete classes only.
================ ================
*/ */
// RB: made exceptions optional
#if defined(USE_EXCEPTIONS)
#define CLASS_DECLARATION( nameofsuperclass, nameofclass ) \ #define CLASS_DECLARATION( nameofsuperclass, nameofclass ) \
idTypeInfo nameofclass::Type( #nameofclass, #nameofsuperclass, \ idTypeInfo nameofclass::Type( #nameofclass, #nameofsuperclass, \
( idEventFunc<idClass> * )nameofclass::eventCallbacks, nameofclass::CreateInstance, ( void ( idClass::* )() )&nameofclass::Spawn, \ ( idEventFunc<idClass> * )nameofclass::eventCallbacks, nameofclass::CreateInstance, ( void ( idClass::* )() )&nameofclass::Spawn, \
@ -160,6 +167,22 @@ incorrect. Use this on concrete classes only.
return &( nameofclass::Type ); \ return &( nameofclass::Type ); \
} \ } \
idEventFunc<nameofclass> nameofclass::eventCallbacks[] = { 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 );
bool ProcessEvent( const idEventDef* ev, idEventArg arg1, idEventArg arg2, idEventArg arg3, idEventArg arg4, idEventArg arg5, idEventArg arg6, idEventArg arg7, idEventArg arg8 ); 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 CancelEvents( const idEventDef* ev );
void Event_Remove(); void Event_Remove();
@ -269,6 +294,9 @@ public:
static idTypeInfo* GetClass( const char* name ); static idTypeInfo* GetClass( const char* name );
static void DisplayInfo_f( const idCmdArgs& args ); static void DisplayInfo_f( const idCmdArgs& args );
static void ListClasses_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 idClass* CreateInstance( const char* name );
static int GetNumTypes() static int GetNumTypes()
{ {

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 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"). 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 : case D_EVENT_FLOAT :
bits |= 1 << i; bits |= 1 << i;
argsize += sizeof( float ); // RB: 64 bit fix, changed sizeof( float ) to sizeof( intptr_t )
argsize += sizeof( intptr_t );
// RB end
break; break;
case D_EVENT_INTEGER : 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; break;
case D_EVENT_VECTOR : 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; break;
case D_EVENT_STRING : case D_EVENT_STRING :
@ -114,11 +121,15 @@ idEventDef::idEventDef( const char* command, const char* formatspec, char return
break; break;
case D_EVENT_ENTITY : 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; break;
case D_EVENT_ENTITY_NULL : 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; break;
case D_EVENT_TRACE : case D_EVENT_TRACE :
@ -366,8 +377,10 @@ idEvent* idEvent::Alloc( const idEventDef* evdef, int numargs, va_list args )
idEvent::CopyArgs 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; int i;
const char* format; const char* format;
idEventArg* arg; idEventArg* arg;
@ -552,7 +565,9 @@ void idEvent::ServiceEvents()
{ {
idEvent* event; idEvent* event;
int num; 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 offset;
int i; int i;
int numargs; int numargs;
@ -663,8 +678,10 @@ idEvent::ServiceFastEvents
void idEvent::ServiceFastEvents() void idEvent::ServiceFastEvents()
{ {
idEvent* event; idEvent* event;
int num; 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 offset;
int i; int i;
int numargs; int numargs;
@ -838,6 +855,9 @@ void idEvent::Save( idSaveGame* savefile )
byte* dataPtr; byte* dataPtr;
bool validTrace; bool validTrace;
const char* format; const char* format;
// RB: for missing D_EVENT_STRING
idStr s;
// RB end
savefile->WriteInt( EventQueue.Num() ); savefile->WriteInt( EventQueue.Num() );
@ -857,18 +877,40 @@ void idEvent::Save( idSaveGame* savefile )
{ {
case D_EVENT_FLOAT : case D_EVENT_FLOAT :
savefile->WriteFloat( *reinterpret_cast<float*>( dataPtr ) ); 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; break;
case D_EVENT_INTEGER : 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 :
case D_EVENT_ENTITY_NULL : case D_EVENT_ENTITY_NULL :
savefile->WriteInt( *reinterpret_cast<int*>( dataPtr ) ); // RB: 64 bit fix, changed alignment to sizeof( intptr_t )
size += sizeof( int ); reinterpret_cast< idEntityPtr<idEntity> * >( dataPtr )->Save( savefile );
size += sizeof( intptr_t );
// RB end
break; break;
case D_EVENT_VECTOR : case D_EVENT_VECTOR :
savefile->WriteVec3( *reinterpret_cast<idVec3*>( dataPtr ) ); 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; 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 : case D_EVENT_TRACE :
validTrace = *reinterpret_cast<bool*>( dataPtr ); validTrace = *reinterpret_cast<bool*>( dataPtr );
savefile->WriteBool( validTrace ); savefile->WriteBool( validTrace );
@ -924,6 +966,9 @@ void idEvent::Restore( idRestoreGame* savefile )
byte* dataPtr; byte* dataPtr;
idEvent* event; idEvent* event;
const char* format; const char* format;
// RB: for missing D_EVENT_STRING
idStr s;
// RB end
savefile->ReadInt( num ); savefile->ReadInt( num );
@ -964,7 +1009,9 @@ void idEvent::Restore( idRestoreGame* savefile )
savefile->ReadInt( argsize ); savefile->ReadInt( argsize );
if( argsize != ( int )event->eventdef->GetArgSize() ) 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 ) if( argsize )
{ {
@ -978,18 +1025,40 @@ void idEvent::Restore( idRestoreGame* savefile )
{ {
case D_EVENT_FLOAT : case D_EVENT_FLOAT :
savefile->ReadFloat( *reinterpret_cast<float*>( dataPtr ) ); 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; break;
case D_EVENT_INTEGER : 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 :
case D_EVENT_ENTITY_NULL : case D_EVENT_ENTITY_NULL :
savefile->ReadInt( *reinterpret_cast<int*>( dataPtr ) ); // RB: 64 bit fix, changed alignment to sizeof( intptr_t )
size += sizeof( int ); reinterpret_cast<idEntityPtr<idEntity> *>( dataPtr )->Restore( savefile );
size += sizeof( intptr_t );
// RB end
break; break;
case D_EVENT_VECTOR : case D_EVENT_VECTOR :
savefile->ReadVec3( *reinterpret_cast<idVec3*>( dataPtr ) ); 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; 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 : case D_EVENT_TRACE :
savefile->ReadBool( *reinterpret_cast<bool*>( dataPtr ) ); savefile->ReadBool( *reinterpret_cast<bool*>( dataPtr ) );
size += sizeof( bool ); size += sizeof( bool );
@ -1132,6 +1201,8 @@ CreateEventCallbackHandler
*/ */
void CreateEventCallbackHandler() void CreateEventCallbackHandler()
{ {
int num;
int count;
int i, j, k; int i, j, k;
char argString[ D_EVENT_MAXARGS + 1 ]; char argString[ D_EVENT_MAXARGS + 1 ];
idStr string1; idStr string1;
@ -1140,7 +1211,7 @@ void CreateEventCallbackHandler()
file = fileSystem->OpenFileWrite( "Callbacks.cpp" ); 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++ ) for( i = 1; i <= D_EVENT_MAXARGS; i++ )
{ {
@ -1167,8 +1238,10 @@ void CreateEventCallbackHandler()
} }
else else
{ {
string1 += "void *"; // RB: 64 bit fix, changed int to intptr_t
string2 += va( "(void *)data[ %d ]", k ); string1 += "const intptr_t";
// RB end
string2 += va( "data[ %d ]", k );
} }
if( k < i - 1 ) if( k < i - 1 )

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 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"). 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. #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. // 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_VOID ( ( char )0 )
#define D_EVENT_INTEGER 'd' #define D_EVENT_INTEGER 'd'
#define D_EVENT_FLOAT 'f' #define D_EVENT_FLOAT 'f'
@ -106,7 +112,9 @@ public:
~idEvent(); ~idEvent();
static idEvent* Alloc( const idEventDef* evdef, int numargs, va_list args ); 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 Free();
void Schedule( idClass* object, const idTypeInfo* cls, int time ); void Schedule( idClass* object, const idTypeInfo* cls, int time );

View file

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

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 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"). 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 ) if( itemList->GetMoveToIndex() == 0 )
{ {
common->SwitchToGame( DOOM_CLASSIC ); common->SwitchToGame( DOOM_CLASSIC );
} }
else if( itemList->GetMoveToIndex() == 1 ) else
#endif
if( itemList->GetMoveToIndex() == 1 )
{ {
if( session->GetSignInManager().GetMasterLocalUser() == NULL ) 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 ); menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
} }
} }
#if defined(USE_DOOMCLASSIC)
else if( itemList->GetMoveToIndex() == 2 ) else if( itemList->GetMoveToIndex() == 2 )
{ {
common->SwitchToGame( DOOM2_CLASSIC ); common->SwitchToGame( DOOM2_CLASSIC );
} }
#endif
// RB end
return true; return true;
} }
@ -356,4 +364,4 @@ bool idMenuScreen_Shell_PressStart::HandleAction( idWidgetAction& action, const
} }
return idMenuWidget::HandleAction( action, event, widget, forceHandled ); return idMenuWidget::HandleAction( action, event, widget, forceHandled );
} }

View file

@ -195,7 +195,10 @@ void idMenuWidget_CommandBar::Update()
idSWFScriptObject* const shortcutKeys = GetSWFObject()->GetGlobal( "shortcutKeys" ).GetObject(); idSWFScriptObject* const shortcutKeys = GetSWFObject()->GetGlobal( "shortcutKeys" ).GetObject();
if( verify( shortcutKeys != NULL ) ) 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 // bind the main action - need to use all caps here because shortcuts are stored that way
shortcutName = buttonName; shortcutName = buttonName;
shortcutName.ToUpper(); shortcutName.ToUpper();

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 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"). 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 #define TOP_PRIORITY 7
bool idCompiler::punctuationValid[ 256 ]; bool idCompiler::punctuationValid[ 256 ];
char* idCompiler::punctuation[] = // RB begin
const char* idCompiler::punctuation[] =
{ {
// RB end
"+=", "-=", "*=", "/=", "%=", "&=", "|=", "++", "--", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "++", "--",
"&&", "||", "<=", ">=", "==", "!=", "::", ";", ",", "&&", "||", "<=", ">=", "==", "!=", "::", ";", ",",
"~", "!", "*", "/", "%", "(", ")", "-", "+", "~", "!", "*", "/", "%", "(", ")", "-", "+",
"=", "[", "]", ".", "<", ">" , "&", "|", ":", NULL "=", "[", "]", ".", "<", ">" , "&", "|", ":", 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 }, { "<RETURN>", "RETURN", -1, false, &def_void, &def_void, &def_void },
{ "++", "UINC_F", 1, true, &def_float, &def_void, &def_void }, { "++", "UINC_F", 1, true, &def_float, &def_void, &def_void },
@ -211,12 +216,15 @@ idCompiler::idCompiler()
*/ */
idCompiler::idCompiler() idCompiler::idCompiler()
{ {
char** ptr; // RB begin
const char** ptr;
// RB end
int id; int id;
// make sure we have the right # of opcodes in the table // make sure we have the right # of opcodes in the table
assert( ( sizeof( opcodes ) / sizeof( opcodes[ 0 ] ) ) == ( NUM_OPCODES + 1 ) ); assert( ( sizeof( opcodes ) / sizeof( opcodes[ 0 ] ) ) == ( NUM_OPCODES + 1 ) );
eof = true;
parserPtr = &parser; parserPtr = &parser;
callthread = false; callthread = false;
@ -259,7 +267,11 @@ void idCompiler::Error( const char* message, ... ) const
vsprintf( string, message, argptr ); vsprintf( string, message, argptr );
va_end( argptr ); va_end( argptr );
#if defined(USE_EXCEPTIONS)
throw idCompileError( string ); 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 ) if( denominator == 0 )
{ {
Error( "Divide by zero" ); Error( "Divide by zero" );
return 0;
} }
return numerator / denominator; 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 ) bool idCompiler::EmitPush( idVarDef* expression, const idTypeDef* funcArg )
{ {
opcode_t* op; // RB: added const
opcode_t* out; const opcode_t* op;
const opcode_t* out;
// RB end
out = NULL; out = NULL;
for( op = &opcodes[ OP_PUSH_F ]; op->name && !strcmp( op->name, "<PUSH>" ); op++ ) 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; idVarDef* field;
etype_t type_b; etype_t type_b;
etype_t type_c; etype_t type_c;
opcode_t* op; // RB: added const
const opcode_t* op;
// RB end
// check if we're accessing a field // check if we're accessing a field
if( baseobj && ( baseobj->Type() == ev_object ) ) if( baseobj && ( baseobj->Type() == ev_object ) )
@ -1810,8 +1827,10 @@ idCompiler::GetExpression
*/ */
idVarDef* idCompiler::GetExpression( int priority ) idVarDef* idCompiler::GetExpression( int priority )
{ {
opcode_t* op; // RB: added const
opcode_t* oldop; const opcode_t* op;
const opcode_t* oldop;
// RB end
idVarDef* e; idVarDef* e;
idVarDef* e2; idVarDef* e2;
const idVarDef* oldtype; const idVarDef* oldtype;
@ -2083,7 +2102,9 @@ void idCompiler::ParseReturnStatement()
idVarDef* e; idVarDef* e;
etype_t type_a; etype_t type_a;
etype_t type_b; etype_t type_b;
opcode_t* op; // RB: added const
const opcode_t* op;
// RB end
if( CheckToken( ";" ) ) if( CheckToken( ";" ) )
{ {
@ -3193,7 +3214,9 @@ void idCompiler::CompileFile( const char* text, const char* filename, bool toCon
token.line = 1; token.line = 1;
error = false; error = false;
#if defined(USE_EXCEPTIONS)
try try
#endif
{ {
// read first token // read first token
NextToken(); NextToken();
@ -3203,7 +3226,7 @@ void idCompiler::CompileFile( const char* text, const char* filename, bool toCon
ParseNamespace( &def_namespace ); ParseNamespace( &def_namespace );
} }
} }
#if defined(USE_EXCEPTIONS)
catch( idCompileError& err ) catch( idCompileError& err )
{ {
idStr error; idStr error;
@ -3222,6 +3245,13 @@ void idCompiler::CompileFile( const char* text, const char* filename, bool toCon
throw idCompileError( error ); 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(); parser.FreeSource();

View file

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

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 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"). 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; varEval_t var;
int pos; int pos;
int start; 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 idEventDef* evdef;
const char* format; const char* format;
@ -874,7 +877,10 @@ void idInterpreter::CallEvent( const function_t* func, int argsize )
{ {
case D_EVENT_INTEGER : case D_EVENT_INTEGER :
var.intPtr = ( int* )&localstack[ start + pos ]; 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; break;
case D_EVENT_FLOAT : case D_EVENT_FLOAT :
@ -999,7 +1005,9 @@ void idInterpreter::CallSysEvent( const function_t* func, int argsize )
varEval_t source; varEval_t source;
int pos; int pos;
int start; 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 idEventDef* evdef;
const char* format; const char* format;
@ -2043,9 +2051,14 @@ bool idInterpreter::Execute()
case OP_PUSH_V: case OP_PUSH_V:
var_a = GetVariable( st->a ); var_a = GetVariable( st->a );
Push( *reinterpret_cast<int*>( &var_a.vectorPtr->x ) ); // RB: 64 bit fix, changed individual pushes with PushVector
Push( *reinterpret_cast<int*>( &var_a.vectorPtr->y ) ); /*
Push( *reinterpret_cast<int*>( &var_a.vectorPtr->z ) ); 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; break;
case OP_PUSH_OBJ: case OP_PUSH_OBJ:
@ -2068,3 +2081,41 @@ bool idInterpreter::Execute()
return threadDying; 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 Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 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").
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 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
the Free Software Foundation, either version 3 of the License, or it under the terms of the GNU General Public License as published by
(at your option) any later version. 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 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details. 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/>. 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.
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.
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__ #ifndef __SCRIPT_INTERPRETER_H__
#define __SCRIPT_INTERPRETER_H__
#define MAX_STACK_DEPTH 64
#define LOCALSTACK_SIZE 6144 #define MAX_STACK_DEPTH 64
typedef struct prstack_s // RB: doubled local stack size
{ #define LOCALSTACK_SIZE (6144 * 2)
int s; // RB end
const function_t* f;
int stackbase; typedef struct prstack_s
} prstack_t; {
int s;
class idInterpreter const function_t* f;
{ int stackbase;
private: } prstack_t;
prstack_t callStack[ MAX_STACK_DEPTH ];
int callStackDepth; class idInterpreter
int maxStackDepth; {
private:
byte localstack[ LOCALSTACK_SIZE ]; prstack_t callStack[ MAX_STACK_DEPTH ];
int localstackUsed; int callStackDepth;
int localstackBase; int maxStackDepth;
int maxLocalstackUsed;
byte localstack[ LOCALSTACK_SIZE ];
const function_t* currentFunction; int localstackUsed;
int instructionPointer; int localstackBase;
int maxLocalstackUsed;
int popParms;
const idEventDef* multiFrameEvent; const function_t* currentFunction;
idEntity* eventEntity; int instructionPointer;
idThread* thread; int popParms;
const idEventDef* multiFrameEvent;
void PopParms( int numParms ); idEntity* eventEntity;
void PushString( const char* string );
void Push( int value ); idThread* thread;
const char* FloatToString( float value );
void AppendString( idVarDef* def, const char* from ); void PopParms( int numParms );
void SetString( idVarDef* def, const char* from ); void PushString( const char* string );
const char* GetString( idVarDef* def ); // RB begin
varEval_t GetVariable( idVarDef* def ); // RB: 64 bit fix, changed int to intptr_t
idEntity* GetEntity( int entnum ) const; void Push( intptr_t value );
idScriptObject* GetScriptObject( int entnum ) const;
void NextInstruction( int position ); // RB: added PushVector for new E_EVENT_SIZEOF_VEC
void PushVector( const idVec3& vector );
void LeaveFunction( idVarDef* returnDef ); // RB end
void CallEvent( const function_t* func, int argsize ); const char* FloatToString( float value );
void CallSysEvent( const function_t* func, int argsize ); void AppendString( idVarDef* def, const char* from );
void SetString( idVarDef* def, const char* from );
public: const char* GetString( idVarDef* def );
bool doneProcessing; varEval_t GetVariable( idVarDef* def );
bool threadDying; idEntity* GetEntity( int entnum ) const;
bool terminateOnExit; idScriptObject* GetScriptObject( int entnum ) const;
bool debug; void NextInstruction( int position );
idInterpreter(); void LeaveFunction( idVarDef* returnDef );
void CallEvent( const function_t* func, int argsize );
// save games void CallSysEvent( const function_t* func, int argsize );
void Save( idSaveGame* savefile ) const; // archives object for save game file
void Restore( idRestoreGame* savefile ); // unarchives object from save game file public:
bool doneProcessing;
void SetThread( idThread* pThread ); bool threadDying;
bool terminateOnExit;
void StackTrace() const; bool debug;
int CurrentLine() const; idInterpreter();
const char* CurrentFile() const;
// save games
void Error( VERIFY_FORMAT_STRING const char* fmt, ... ) const; void Save( idSaveGame* savefile ) const; // archives object for save game file
void Warning( VERIFY_FORMAT_STRING const char* fmt, ... ) const; void Restore( idRestoreGame* savefile ); // unarchives object from save game file
void DisplayInfo() const;
void SetThread( idThread* pThread );
bool BeginMultiFrameEvent( idEntity* ent, const idEventDef* event );
void EndMultiFrameEvent( idEntity* ent, const idEventDef* event ); void StackTrace() const;
bool MultiFrameEventInProgress() const;
int CurrentLine() const;
void ThreadCall( idInterpreter* source, const function_t* func, int args ); const char* CurrentFile() const;
void EnterFunction( const function_t* func, bool clearStack );
void EnterObjectFunction( idEntity* self, const function_t* func, bool clearStack ); void Error( VERIFY_FORMAT_STRING const char* fmt, ... ) const;
void Warning( VERIFY_FORMAT_STRING const char* fmt, ... ) const;
bool Execute(); void DisplayInfo() const;
void Reset();
bool BeginMultiFrameEvent( idEntity* ent, const idEventDef* event );
bool GetRegisterValue( const char* name, idStr& out, int scopeDepth ); void EndMultiFrameEvent( idEntity* ent, const idEventDef* event );
int GetCallstackDepth() const; bool MultiFrameEventInProgress() const;
const prstack_t* GetCallstack() const;
const function_t* GetCurrentFunction() const; void ThreadCall( idInterpreter* source, const function_t* func, int args );
idThread* GetThread() const; void EnterFunction( const function_t* func, bool clearStack );
void EnterObjectFunction( idEntity* self, const function_t* func, bool clearStack );
};
bool Execute();
/* void Reset();
====================
idInterpreter::PopParms bool GetRegisterValue( const char* name, idStr& out, int scopeDepth );
==================== int GetCallstackDepth() const;
*/ const prstack_t* GetCallstack() const;
ID_INLINE void idInterpreter::PopParms( int numParms ) const function_t* GetCurrentFunction() const;
{ idThread* GetThread() const;
// pop our parms off the stack
if( localstackUsed < numParms ) };
{
Error( "locals stack underflow\n" ); /*
} ====================
idInterpreter::PopParms
localstackUsed -= numParms; ====================
} */
ID_INLINE void idInterpreter::PopParms( int numParms )
/* {
==================== // pop our parms off the stack
idInterpreter::Push if( localstackUsed < numParms )
==================== {
*/ Error( "locals stack underflow\n" );
ID_INLINE void idInterpreter::Push( int value ) }
{
if( localstackUsed + sizeof( int ) > LOCALSTACK_SIZE ) localstackUsed -= numParms;
{ }
Error( "Push: locals stack overflow\n" );
} /*
*( int* )&localstack[ localstackUsed ] = value; ====================
localstackUsed += sizeof( int ); idInterpreter::Push
} ====================
*/
/* // RB: 64 bit fix, changed int to intptr_t
==================== ID_INLINE void idInterpreter::Push( intptr_t value )
idInterpreter::PushString {
==================== if( localstackUsed + sizeof( intptr_t ) > LOCALSTACK_SIZE )
*/ {
ID_INLINE void idInterpreter::PushString( const char* string ) Error( "Push: locals stack overflow\n" );
{ }
if( localstackUsed + MAX_STRING_LEN > LOCALSTACK_SIZE ) *( intptr_t* )&localstack[ localstackUsed ] = value;
{ localstackUsed += sizeof( intptr_t );
Error( "PushString: locals stack overflow\n" ); }
} // RB end
idStr::Copynz( ( char* )&localstack[ localstackUsed ], string, MAX_STRING_LEN );
localstackUsed += MAX_STRING_LEN; // RB begin
} /*
====================
/* idInterpreter::PushVector
==================== ====================
idInterpreter::FloatToString */
==================== ID_INLINE void idInterpreter::PushVector( const idVec3& vector )
*/ {
ID_INLINE const char* idInterpreter::FloatToString( float value ) if( localstackUsed + E_EVENT_SIZEOF_VEC > LOCALSTACK_SIZE )
{ {
static char text[ 32 ]; Error( "Push: locals stack overflow\n" );
}
if( value == ( float )( int )value ) *( idVec3* )&localstack[ localstackUsed ] = vector;
{ localstackUsed += E_EVENT_SIZEOF_VEC;
sprintf( text, "%d", ( int )value ); }
} // RB end
else
{
sprintf( text, "%f", value ); /*
} ====================
return text; idInterpreter::PushString
} ====================
*/
/* ID_INLINE void idInterpreter::PushString( const char* string )
==================== {
idInterpreter::AppendString if( localstackUsed + MAX_STRING_LEN > LOCALSTACK_SIZE )
==================== {
*/ Error( "PushString: locals stack overflow\n" );
ID_INLINE void idInterpreter::AppendString( idVarDef* def, const char* from ) }
{ idStr::Copynz( ( char* )&localstack[ localstackUsed ], string, MAX_STRING_LEN );
if( def->initialized == idVarDef::stackVariable ) localstackUsed += MAX_STRING_LEN;
{ }
idStr::Append( ( char* )&localstack[ localstackBase + def->value.stackOffset ], MAX_STRING_LEN, from );
} /*
else ====================
{ idInterpreter::FloatToString
idStr::Append( def->value.stringPtr, MAX_STRING_LEN, from ); ====================
} */
} ID_INLINE const char* idInterpreter::FloatToString( float value )
{
/* static char text[ 32 ];
====================
idInterpreter::SetString if( value == ( float )( int )value )
==================== {
*/ sprintf( text, "%d", ( int )value );
ID_INLINE void idInterpreter::SetString( idVarDef* def, const char* from ) }
{ else
if( def->initialized == idVarDef::stackVariable ) {
{ sprintf( text, "%f", value );
idStr::Copynz( ( char* )&localstack[ localstackBase + def->value.stackOffset ], from, MAX_STRING_LEN ); }
} return text;
else }
{
idStr::Copynz( def->value.stringPtr, from, MAX_STRING_LEN ); /*
} ====================
} idInterpreter::AppendString
====================
/* */
==================== ID_INLINE void idInterpreter::AppendString( idVarDef* def, const char* from )
idInterpreter::GetString {
==================== if( def->initialized == idVarDef::stackVariable )
*/ {
ID_INLINE const char* idInterpreter::GetString( idVarDef* def ) idStr::Append( ( char* )&localstack[ localstackBase + def->value.stackOffset ], MAX_STRING_LEN, from );
{ }
if( def->initialized == idVarDef::stackVariable ) else
{ {
return ( char* )&localstack[ localstackBase + def->value.stackOffset ]; idStr::Append( def->value.stringPtr, MAX_STRING_LEN, from );
} }
else }
{
return def->value.stringPtr; /*
} ====================
} idInterpreter::SetString
====================
/* */
==================== ID_INLINE void idInterpreter::SetString( idVarDef* def, const char* from )
idInterpreter::GetVariable {
==================== if( def->initialized == idVarDef::stackVariable )
*/ {
ID_INLINE varEval_t idInterpreter::GetVariable( idVarDef* def ) idStr::Copynz( ( char* )&localstack[ localstackBase + def->value.stackOffset ], from, MAX_STRING_LEN );
{ }
if( def->initialized == idVarDef::stackVariable ) else
{ {
varEval_t val; idStr::Copynz( def->value.stringPtr, from, MAX_STRING_LEN );
val.intPtr = ( int* )&localstack[ localstackBase + def->value.stackOffset ]; }
return val; }
}
else /*
{ ====================
return def->value; idInterpreter::GetString
} ====================
} */
ID_INLINE const char* idInterpreter::GetString( idVarDef* def )
/* {
================ if( def->initialized == idVarDef::stackVariable )
idInterpreter::GetEntity {
================ return ( char* )&localstack[ localstackBase + def->value.stackOffset ];
*/ }
ID_INLINE idEntity* idInterpreter::GetEntity( int entnum ) const else
{ {
assert( entnum <= MAX_GENTITIES ); return def->value.stringPtr;
if( ( entnum > 0 ) && ( entnum <= MAX_GENTITIES ) ) }
{ }
return gameLocal.entities[ entnum - 1 ];
} /*
return NULL; ====================
} idInterpreter::GetVariable
====================
/* */
================ ID_INLINE varEval_t idInterpreter::GetVariable( idVarDef* def )
idInterpreter::GetScriptObject {
================ if( def->initialized == idVarDef::stackVariable )
*/ {
ID_INLINE idScriptObject* idInterpreter::GetScriptObject( int entnum ) const varEval_t val;
{ val.intPtr = ( int* )&localstack[ localstackBase + def->value.stackOffset ];
idEntity* ent; return val;
}
assert( entnum <= MAX_GENTITIES ); else
if( ( entnum > 0 ) && ( entnum <= MAX_GENTITIES ) ) {
{ return def->value;
ent = gameLocal.entities[ entnum - 1 ]; }
if( ent && ent->scriptObject.data ) }
{
return &ent->scriptObject; /*
} ====================
} idInterpreter::NextInstruction
return NULL; ====================
} */
ID_INLINE void idInterpreter::NextInstruction( int position )
/* {
==================== // Before we execute an instruction, we increment instructionPointer,
idInterpreter::NextInstruction // therefore we need to compensate for that here.
==================== instructionPointer = position - 1;
*/ }
ID_INLINE void idInterpreter::NextInstruction( int position )
{ #endif /* !__SCRIPT_INTERPRETER_H__ */
// 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 Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 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"). 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 // simple types. function types are dynamically allocated
idTypeDef type_void( ev_void, &def_void, "void", 0, NULL ); 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_string( ev_string, &def_string, "string", MAX_STRING_LEN, NULL );
idTypeDef type_float( ev_float, &def_float, "float", sizeof( float ), NULL ); idTypeDef type_float( ev_float, &def_float, "float", sizeof( intptr_t ), NULL );
idTypeDef type_vector( ev_vector, &def_vector, "vector", sizeof( idVec3 ), NULL ); idTypeDef type_vector( ev_vector, &def_vector, "vector", E_EVENT_SIZEOF_VEC, NULL );
idTypeDef type_entity( ev_entity, &def_entity, "entity", sizeof( int* ), NULL ); // stored as entity number pointer 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( void* ), NULL ); idTypeDef type_field( ev_field, &def_field, "field", sizeof( intptr_t ), NULL );
idTypeDef type_function( ev_function, &def_function, "function", sizeof( void* ), &type_void ); idTypeDef type_function( ev_function, &def_function, "function", sizeof( intptr_t ), &type_void );
idTypeDef type_virtualfunction( ev_virtualfunction, &def_virtualfunction, "virtual function", sizeof( int ), NULL ); idTypeDef type_virtualfunction( ev_virtualfunction, &def_virtualfunction, "virtual function", sizeof( intptr_t ), NULL );
idTypeDef type_pointer( ev_pointer, &def_pointer, "pointer", sizeof( void* ), NULL ); idTypeDef type_pointer( ev_pointer, &def_pointer, "pointer", sizeof( intptr_t ), NULL );
idTypeDef type_object( ev_object, &def_object, "object", sizeof( int* ), NULL ); // stored as entity number pointer 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( int ), NULL ); // only used for jump opcodes 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( int ), NULL ); // only used for function call and thread 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( int ), NULL ); idTypeDef type_boolean( ev_boolean, &def_boolean, "boolean", sizeof( intptr_t ), NULL );
// RB end
idVarDef def_void( &type_void ); idVarDef def_void( &type_void );
idVarDef def_scriptevent( &type_scriptevent ); idVarDef def_scriptevent( &type_scriptevent );
@ -324,7 +328,11 @@ void idTypeDef::AddFunctionParm( idTypeDef* parmtype, const char* name )
{ {
if( type != ev_function ) if( type != ev_function )
{ {
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::AddFunctionParm : tried to add parameter on non-function type" ); 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 ); parmTypes.Append( parmtype );
@ -343,7 +351,11 @@ void idTypeDef::AddField( idTypeDef* fieldtype, const char* name )
{ {
if( type != ev_object ) if( type != ev_object )
{ {
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::AddField : tried to add field to non-object type" ); 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 ); parmTypes.Append( fieldtype );
@ -411,7 +423,11 @@ idTypeDef* idTypeDef::SuperClass() const
{ {
if( type != ev_object ) if( type != ev_object )
{ {
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::SuperClass : tried to get superclass of a non-object type" ); 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; return auxType;
@ -428,7 +444,11 @@ idTypeDef* idTypeDef::ReturnType() const
{ {
if( type != ev_function ) if( type != ev_function )
{ {
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::ReturnType: tried to get return type on non-function type" ); 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; return auxType;
@ -445,7 +465,11 @@ void idTypeDef::SetReturnType( idTypeDef* returntype )
{ {
if( type != ev_function ) if( type != ev_function )
{ {
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::SetReturnType: tried to set return type on non-function type" ); 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; auxType = returntype;
@ -462,7 +486,11 @@ idTypeDef* idTypeDef::FieldType() const
{ {
if( type != ev_field ) if( type != ev_field )
{ {
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::FieldType: tried to get field type on non-field type" ); 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; return auxType;
@ -479,7 +507,11 @@ void idTypeDef::SetFieldType( idTypeDef* fieldtype )
{ {
if( type != ev_field ) if( type != ev_field )
{ {
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::SetFieldType: tried to set return type on non-function type" ); 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; auxType = fieldtype;
@ -496,7 +528,11 @@ idTypeDef* idTypeDef::PointerType() const
{ {
if( type != ev_pointer ) if( type != ev_pointer )
{ {
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::PointerType: tried to get pointer type on non-pointer" ); 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; return auxType;
@ -513,7 +549,11 @@ void idTypeDef::SetPointerType( idTypeDef* pointertype )
{ {
if( type != ev_pointer ) if( type != ev_pointer )
{ {
#if defined(USE_EXCEPTIONS)
throw idCompileError( "idTypeDef::SetPointerType: tried to set type on non-pointer" ); 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; auxType = pointertype;
@ -793,7 +833,11 @@ void idVarDef::SetValue( const eval_t& _value, bool constant )
break; break;
default : default :
#if defined(USE_EXCEPTIONS)
throw idCompileError( va( "weird type on '%s'", Name() ) ); throw idCompileError( va( "weird type on '%s'", Name() ) );
#else
gameLocal.Error( "weird type on '%s'", Name() );
#endif
break; break;
} }
} }
@ -1017,7 +1061,9 @@ idScriptObject::Save
*/ */
void idScriptObject::Save( idSaveGame* savefile ) const 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 ) if( type == &type_object && data == NULL )
{ {
@ -1041,7 +1087,9 @@ idScriptObject::Restore
void idScriptObject::Restore( idRestoreGame* savefile ) void idScriptObject::Restore( idRestoreGame* savefile )
{ {
idStr typeName; idStr typeName;
// RB: 64 bit fix, changed size_t to int
int size; int size;
// RB end
savefile->ReadString( typeName ); 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() ); 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 ); savefile->ReadInt( size );
// RB end
if( size != type->Size() ) if( size != type->Size() )
{ {
savefile->Error( "idScriptObject::Restore: size of object '%s' doesn't match size in save game.", typeName.c_str() ); 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 ); 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 idProgram::AllocDef
@ -1397,13 +1484,7 @@ idVarDef* idProgram::AllocDef( idTypeDef* type, const char* name, idVarDef* scop
idVarDef* def_z; idVarDef* def_z;
// allocate a new def // allocate a new def
def = new( TAG_SCRIPT ) idVarDef( type ); def = AllocVarDef( type, name, scope );
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 );
if( ( type->Type() == ev_vector ) || ( ( type->Type() == ev_field ) && ( type->FieldType()->Type() == ev_vector ) ) ) 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 ) ) else if( scope->TypeDef()->Inherits( &type_object ) )
{ {
idTypeDef newtype( ev_field, NULL, "float field", 0, &type_float ); 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 // set the value to the variable's position in the object
def->value.ptrOffset = scope->TypeDef()->Size(); 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 // make automatic defs for the vectors elements
// origin can be accessed as origin_x, origin_y, and origin_z // origin can be accessed as origin_x, origin_y, and origin_z
sprintf( element, "%s_x", def->Name() ); 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() ); sprintf( element, "%s_y", def->Name() );
def_y = AllocDef( type, element, scope, constant ); def_y = AllocDef( ftype, element, scope, constant );
def_y->value.ptrOffset = def_x->value.ptrOffset + type_float.Size(); def_y->value.ptrOffset = def_x->value.ptrOffset + sizeof( float );
sprintf( element, "%s_z", def->Name() ); sprintf( element, "%s_z", def->Name() );
def_z = AllocDef( type, element, scope, constant ); def_z = AllocDef( ftype, element, scope, constant );
def_z->value.ptrOffset = def_y->value.ptrOffset + type_float.Size(); def_z->value.ptrOffset = def_y->value.ptrOffset + sizeof( float );
// RB end
} }
else 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 // make automatic defs for the vectors elements
// origin can be accessed as origin_x, origin_y, and origin_z // origin can be accessed as origin_x, origin_y, and origin_z
sprintf( element, "%s_x", def->Name() ); 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() ); 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() ); 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 // get the memory for the full vector and point the _x, _y and _z
def->value = def_x->value; // defs at the vector member offsets
def->initialized = def_x->initialized; 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 ) ) else if( scope->TypeDef()->Inherits( &type_object ) )
@ -1490,14 +1601,11 @@ idVarDef* idProgram::AllocDef( idTypeDef* type, const char* name, idVarDef* scop
// //
// global variable // global variable
// //
def->value.bytePtr = &variables[ numVariables ]; // RB begin
numVariables += def->TypeDef()->Size(); def->value.bytePtr = ReserveDefMemory( def->TypeDef()->Size() );
if( numVariables > sizeof( variables ) ) // RB end
{
throw idCompileError( va( "Exceeded global memory size (%d bytes)", sizeof( variables ) ) );
}
memset( def->value.bytePtr, 0, def->TypeDef()->Size() ); //memset( def->value.bytePtr, 0, def->TypeDef()->Size() );
} }
return def; 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 // see if the name is already in use for another type
if( bestDef && type && ( bestDef->TypeDef() != type ) ) if( bestDef && type && ( bestDef->TypeDef() != type ) )
{ {
#if defined(USE_EXCEPTIONS)
throw idCompileError( va( "Type mismatch on redeclaration of %s", name ) ); throw idCompileError( va( "Type mismatch on redeclaration of %s", name ) );
#else
gameLocal.Error( "Type mismatch on redeclaration of %s", name );
#endif
} }
return bestDef; return bestDef;
@ -1734,7 +1846,11 @@ function_t& idProgram::AllocFunction( idVarDef* def )
{ {
if( functions.Num() >= functions.Max() ) if( functions.Num() >= functions.Max() )
{ {
#if defined(USE_EXCEPTIONS)
throw idCompileError( va( "Exceeded maximum allowed number of functions (%d)", functions.Max() ) ); 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 // fill in the dfunction
@ -1791,7 +1907,11 @@ statement_t* idProgram::AllocStatement()
{ {
if( statements.Num() >= statements.Max() ) if( statements.Num() >= statements.Max() )
{ {
#if defined(USE_EXCEPTIONS)
throw idCompileError( va( "Exceeded maximum allowed number of statements (%d)", statements.Max() ) ); 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(); return statements.Alloc();
} }
@ -1809,7 +1929,9 @@ void idProgram::BeginCompilation()
FreeData(); FreeData();
#if defined(USE_EXCEPTIONS)
try try
#endif
{ {
// make the first statement a return for a "NULL" function // make the first statement a return for a "NULL" function
statement = AllocStatement(); statement = AllocStatement();
@ -1832,11 +1954,12 @@ void idProgram::BeginCompilation()
// define the sys object // define the sys object
sysDef = AllocDef( &type_void, "sys", &def_namespace, true ); sysDef = AllocDef( &type_void, "sys", &def_namespace, true );
} }
#if defined(USE_EXCEPTIONS)
catch( idCompileError& err ) catch( idCompileError& err )
{ {
gameLocal.Error( "%s", err.GetError() ); gameLocal.Error( "%s", err.GetError() );
} }
#endif
} }
/* /*
@ -1846,7 +1969,9 @@ idProgram::DisassembleStatement
*/ */
void idProgram::DisassembleStatement( idFile* file, int instructionPointer ) const void idProgram::DisassembleStatement( idFile* file, int instructionPointer ) const
{ {
opcode_t* op; // RB: added const
const opcode_t* op;
// RB end
const statement_t* statement; const statement_t* statement;
statement = &statements[ instructionPointer ]; statement = &statements[ instructionPointer ];
@ -2012,7 +2137,9 @@ bool idProgram::CompileText( const char* source, const char* text, bool console
ospath = fileSystem->RelativePathToOSPath( source ); ospath = fileSystem->RelativePathToOSPath( source );
filenum = GetFilenum( ospath ); filenum = GetFilenum( ospath );
#if defined(USE_EXCEPTIONS)
try try
#endif
{ {
compiler.CompileFile( text, filename, console ); 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( !def->value.functionPtr->eventdef && !def->value.functionPtr->firstStatement )
{ {
#if defined(USE_EXCEPTIONS)
throw idCompileError( va( "function %s was not defined\n", def->GlobalName() ) ); 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 ) catch( idCompileError& err )
{ {
if( console ) if( console )
@ -2042,6 +2173,7 @@ bool idProgram::CompileText( const char* source, const char* text, bool console
gameLocal.Error( "%s\n", err.GetError() ); gameLocal.Error( "%s\n", err.GetError() );
} }
}; };
#endif
if( !console ) if( !console )
{ {

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 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"). 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* GetType( idTypeDef& type, bool allocate );
idTypeDef* FindType( const char* name ); 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* AllocDef( idTypeDef* type, const char* name, idVarDef* scope, bool constant );
idVarDef* GetDef( const idTypeDef* type, const char* name, const idVarDef* scope ) const; idVarDef* GetDef( const idTypeDef* type, const char* name, const idVarDef* scope ) const;
void FreeDef( idVarDef* d, const idVarDef* scope ); void FreeDef( idVarDef* d, const idVarDef* scope );

View file

@ -3,6 +3,7 @@
Doom 3 BFG Edition GPL Source Code Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 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"). 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; int ret = -1;
// RB: 64 bit fixes, changed oldschool offsets using ptrdiff_t
if( wv == &rect ) if( wv == &rect )
{ {
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->rect; ret = ( ptrdiff_t )&rect - ( ptrdiff_t )this;
} }
if( wv == &backColor ) if( wv == &backColor )
{ {
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->backColor; ret = ( ptrdiff_t )&backColor - ( ptrdiff_t )this;
} }
if( wv == &matColor ) if( wv == &matColor )
{ {
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->matColor; ret = ( ptrdiff_t )&matColor - ( ptrdiff_t )this;
} }
if( wv == &foreColor ) if( wv == &foreColor )
{ {
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->foreColor; ret = ( ptrdiff_t )&foreColor - ( ptrdiff_t )this;
} }
if( wv == &borderColor ) if( wv == &borderColor )
{ {
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->borderColor; ret = ( ptrdiff_t )&borderColor - ( ptrdiff_t )this;
} }
if( wv == &textScale ) if( wv == &textScale )
{ {
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->textScale; ret = ( ptrdiff_t )&textScale - ( ptrdiff_t )this;
} }
if( wv == &rotate ) if( wv == &rotate )
{ {
ret = ( int ) & ( ( idSimpleWindow* ) 0 )->rotate; ret = ( ptrdiff_t )&rotate - ( ptrdiff_t )this;
} }
// RB end
if( ret != -1 ) if( ret != -1 )
{ {

View file

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

View file

@ -109,7 +109,9 @@ typedef enum
typedef struct typedef struct
{ {
wexpOpType_t opType; 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; } wexpOp_t;
struct idRegEntry struct idRegEntry