I have a problem concerning global variables declared in the scripts on PS3. At first it breaks in as_scriptfunction.cpp (459) :
// Global variables case asBC_PGA: case asBC_LDG: case asBC_PshG4: case asBC_LdGRdR4: case asBC_CpyGtoV4: case asBC_CpyVtoG4: case asBC_SetG4: // Need to increase the reference for each global variable { void *gvarPtr = (void*)(size_t)asBC_PTRARG(&byteCode[n]); asCGlobalProperty *prop = GetPropertyByGlobalVarPtr(gvarPtr); // Only addref the properties once if( !ptrs.Exists(gvarPtr) ) { prop->AddRef(); ptrs.PushLast(gvarPtr); } asCConfigGroup *group = engine->FindConfigGroupForGlobalVar(prop->id); if( group != 0 ) group->AddRef(); } break;
It appears that gvarPtr is NULL (and thus prop as well) and I was able to track this down to the bytecode instruction asBC_SetG4.
This is my script and the generate debug output on PC :
float ttf = 42.42f;Temps: 1 0 0 * PshC4 0x0 (i:0, f:0) 2 1 * SetG4 55911208, 1110027796 5 0 * RET 0
On PC, it works well and the "arg" variable of the bytecode instruction is correctly set but on PS3 this same arg is 0 as you can see here :
I don't know why it does that but here is the faulty code, where the "arg" value is modified and set to 0 somehow in as_bytecode.cpp (547) :
// The constant is copied to a global variable and then never used again if( curr->op == asBC_SetV4 && curr->next && curr->next->op == asBC_CpyVtoG4 && curr->wArg[0] == curr->next->wArg[0] && IsTemporary(curr->wArg[0]) && !IsTempVarRead(curr->next, curr->wArg[0]) ) { curr->op = asBC_SetG4; curr->size = asBCTypeSize[asBCInfo[asBC_SetG4].type]; *(((asDWORD*)&curr->arg) + AS_PTR_SIZE) = (asDWORD)curr->arg; *(asPTRWORD*)&curr->arg = (asPTRWORD)curr->next->arg; DeleteInstruction(curr->next); *next = GoBack(curr); return true; }
If anyone has any idea why that might happen. I tried to set AS_64BIT_PTR and it seemed to work but it crashed elsewhere (in string factory actually) because PS3 is 32 bits for pointers.
Thanks!
Remi Gillig.