Fixed x64 script/class connections and added material flags that are needed.

This commit is contained in:
Justin Marshall
2026-05-05 16:20:05 -07:00
parent 8d5f678b25
commit d06356e042
12 changed files with 2437 additions and 2202 deletions
+26 -7
View File
@@ -672,7 +672,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;
@@ -686,6 +688,9 @@ void idInterpreter::CallEvent( const function_t *func, int argsize ) {
start = localstackUsed - argsize;
var.intPtr = ( int * )&localstack[ start ];
eventEntity = GetEntity( *var.entityNumberPtr );
static int testme;
testme = *var.entityNumberPtr;
if ( !eventEntity || !eventEntity->RespondsTo( *evdef ) ) {
if ( eventEntity && developer.GetBool() ) {
@@ -703,10 +708,11 @@ void idInterpreter::CallEvent( const function_t *func, int argsize ) {
// always return a safe value when an object doesn't exist
switch( evdef->GetReturnType() ) {
case D_EVENT_INTEGER :
gameLocal.program.ReturnInteger( 0 );
case D_EVENT_INTEGER:
gameLocal.program.ReturnInteger(0);
break;
case D_EVENT_FLOAT :
gameLocal.program.ReturnFloat( 0 );
break;
@@ -739,13 +745,18 @@ void idInterpreter::CallEvent( const function_t *func, int argsize ) {
for( j = 0, i = 0, pos = type_object.Size(); ( pos < argsize ) || ( format[ i ] != 0 ); i++ ) {
switch( format[ i ] ) {
case D_EVENT_INTEGER :
var.intPtr = ( int * )&localstack[ start + pos ];
data[ i ] = int( *var.floatPtr );
var.intPtr = (int*)&localstack[start + pos];
// RB: fixed data alignment
//data[ i ] = int( *var.floatPtr );
(*(int*)&data[i]) = int(*var.floatPtr);
// RB end
break;
case D_EVENT_FLOAT :
var.intPtr = ( int * )&localstack[ start + pos ];
( *( float * )&data[ i ] ) = *var.floatPtr;
static float value;
value = (*(float*)&data[i]);
break;
case D_EVENT_VECTOR :
@@ -869,7 +880,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;
@@ -1988,10 +2001,15 @@ bool idInterpreter::Execute( void ) {
break;
case OP_PUSH_V:
var_a = GetVariable( st->a );
var_a = GetVariable(st->a);
// 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:
@@ -2014,3 +2032,4 @@ bool idInterpreter::Execute( void ) {
return threadDying;
}
+16 -5
View File
@@ -5,7 +5,7 @@
#define __SCRIPT_INTERPRETER_H__
#define MAX_STACK_DEPTH 64
#define LOCALSTACK_SIZE 6144
#define LOCALSTACK_SIZE (6144 * 2)
typedef struct prstack_s {
int s;
@@ -33,10 +33,11 @@ private:
idThread *thread;
void PushVector(const idVec3& vector);
void PopParms( int numParms );
void PushString( const char *string );
public://HUMANHEAD: aob - so we can pass parms in manually
void Push( int value );
void Push( intptr_t value );
private://HUMANHEAD: aob - undo the public declaration
const char *FloatToString( float value );
void AppendString( idVarDef *def, const char *from );
@@ -115,12 +116,12 @@ ID_INLINE void idInterpreter::PopParms( int numParms ) {
idInterpreter::Push
====================
*/
ID_INLINE void idInterpreter::Push( int value ) {
ID_INLINE void idInterpreter::Push(intptr_t value ) {
if ( localstackUsed + sizeof( int ) > LOCALSTACK_SIZE ) {
Error( "Push: locals stack overflow\n" );
}
*( int * )&localstack[ localstackUsed ] = value;
localstackUsed += sizeof( int );
*(intptr_t*)&localstack[localstackUsed] = value;
localstackUsed += sizeof(intptr_t);
}
/*
@@ -248,4 +249,14 @@ ID_INLINE void idInterpreter::NextInstruction( int position ) {
instructionPointer = position - 1;
}
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;
}
#endif /* !__SCRIPT_INTERPRETER_H__ */
+44 -45
View File
@@ -16,23 +16,23 @@ static int globalOutputRunningSize = 0;
// 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 );
idTypeDef type_scriptevent(ev_scriptevent, &def_scriptevent, "scriptevent", sizeof(intptr_t), NULL);
idTypeDef type_namespace(ev_namespace, &def_namespace, "namespace", sizeof(intptr_t), NULL);
//HUMANHEAD: aob - changed types to inherited types
idTypeDefString type_string( ev_string, &def_string, "string", MAX_STRING_LEN, NULL );
idTypeDefFloat type_float( ev_float, &def_float, "float", sizeof( float ), NULL );
idTypeDefVector type_vector( ev_vector, &def_vector, "vector", sizeof( idVec3 ), NULL );
idTypeDefEntity type_entity( ev_entity, &def_entity, "entity", sizeof( int * ), NULL ); // stored as entity number pointer
idTypeDefFloat type_float( ev_float, &def_float, "float", sizeof(intptr_t), NULL );
idTypeDefVector type_vector( ev_vector, &def_vector, "vector", E_EVENT_SIZEOF_VEC, NULL );
idTypeDefEntity type_entity( ev_entity, &def_entity, "entity", sizeof(intptr_t), NULL ); // stored as entity number pointer
//HUMANHEAD END
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_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
//HUMANHEAD: aob - changed types to inherited types
idTypeDefBool type_boolean( ev_boolean, &def_boolean, "boolean", sizeof( int ), NULL );
idTypeDefBool type_boolean( ev_boolean, &def_boolean, "boolean", sizeof(intptr_t), NULL );
//HUMANHEAD END
idVarDef def_void( &type_void );
@@ -1341,24 +1341,22 @@ idVarDef *idProgram::AllocDef( idTypeDef *type, const char *name, idVarDef *scop
def->initialized = idVarDef::stackVariable;
scope->value.functionPtr->locals += type->Size();
} else if ( scope->TypeDef()->Inherits( &type_object ) ) {
idTypeDef newtype( ev_field, NULL, "float field", 0, &type_float );
idTypeDef *type = GetType( newtype, true );
// set the value to the variable's position in the object
idTypeDef newtype(ev_field, NULL, "float field", 0, &type_float);
// 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();
// 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 );
sprintf( element, "%s_y", def->Name() );
def_y = AllocDef( type, element, scope, constant );
def_y->value.ptrOffset = def_x->value.ptrOffset + type_float.Size();
sprintf( element, "%s_z", def->Name() );
def_z = AllocDef( type, element, scope, constant );
def_z->value.ptrOffset = def_y->value.ptrOffset + type_float.Size();
// 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(ftype, element, scope, constant);
sprintf(element, "%s_y", def->Name());
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(ftype, element, scope, constant);
def_z->value.ptrOffset = def_y->value.ptrOffset + sizeof(float);
// RB end
} else {
// make automatic defs for the vectors elements
// origin can be accessed as origin_x, origin_y, and origin_z
@@ -1718,29 +1716,29 @@ idProgram::DisassembleStatement
==============
*/
void idProgram::DisassembleStatement( idFile *file, int instructionPointer ) const {
opcode_t *op;
const statement_t *statement;
opcode_t* op;
const statement_t* statement;
statement = &statements[ instructionPointer ];
op = &idCompiler::opcodes[ statement->op ];
file->Printf( "%20s(%d):\t%6d: %15s\t", fileList[ statement->file ].c_str(), statement->linenumber, instructionPointer, op->opname );
statement = &statements[instructionPointer];
op = &idCompiler::opcodes[statement->op];
file->Printf("%20s(%d):\t%6d: %15s\t", fileList[statement->file].c_str(), statement->linenumber, instructionPointer, op->opname);
if ( statement->a ) {
file->Printf( "\ta: " );
statement->a->PrintInfo( file, instructionPointer );
if (statement->a) {
file->Printf("\ta: ");
statement->a->PrintInfo(file, instructionPointer);
}
if ( statement->b ) {
file->Printf( "\tb: " );
statement->b->PrintInfo( file, instructionPointer );
if (statement->b) {
file->Printf("\tb: ");
statement->b->PrintInfo(file, instructionPointer);
}
if ( statement->c ) {
file->Printf( "\tc: " );
statement->c->PrintInfo( file, instructionPointer );
if (statement->c) {
file->Printf("\tc: ");
statement->c->PrintInfo(file, instructionPointer);
}
file->Printf( "\n" );
file->Printf("\n");
}
/*
@@ -2257,6 +2255,7 @@ idProgram::ReturnEntity
*/
void idProgram::ReturnEntity( idEntity *ent ) {
if ( ent ) {
assert(ent->entityNumber + 1 <= MAX_GENTITIES);
*returnDef->value.entityNumberPtr = ent->entityNumber + 1;
} else {
*returnDef->value.entityNumberPtr = 0;
+1
View File
@@ -346,6 +346,7 @@ typedef union varEval_s {
int argSize;
varEval_s *evalPtr;
int ptrOffset;
INT_PTR highPtr;
} varEval_t;
class idVarDef {