@@ -164,6 +164,11 @@ static char _scratchStr[40];
164
164
// 0x631E78
165
165
static char _map_path[COMPAT_MAX_PATH];
166
166
167
+ // CE: Basically the same problem described in |gMapLocalPointers|, but this
168
+ // time Olympus folks use global map variables to store objects (looks like
169
+ // only `self_obj`).
170
+ static std::vector<void *> gMapGlobalPointers ;
171
+
167
172
// CE: There is a bug in the user-space scripting where they want to store
168
173
// pointers to |Object| instances in local vars. This is obviously wrong as it's
169
174
// meaningless to save these pointers in file. As a workaround use second array
@@ -390,27 +395,41 @@ int mapSetElevation(int elevation)
390
395
}
391
396
392
397
// 0x482220
393
- int mapSetGlobalVar (int var, int value)
398
+ int mapSetGlobalVar (int var, ProgramValue& value)
394
399
{
395
400
if (var < 0 || var >= gMapGlobalVarsLength ) {
396
401
debugPrint (" ERROR: attempt to reference map var out of range: %d" , var);
397
402
return -1 ;
398
403
}
399
404
400
- gMapGlobalVars [var] = value;
405
+ if (value.opcode == VALUE_TYPE_PTR) {
406
+ gMapGlobalVars [var] = 0 ;
407
+ gMapGlobalPointers [var] = value.pointerValue ;
408
+ } else {
409
+ gMapGlobalVars [var] = value.integerValue ;
410
+ gMapGlobalPointers [var] = nullptr ;
411
+ }
401
412
402
413
return 0 ;
403
414
}
404
415
405
416
// 0x482250
406
- int mapGetGlobalVar (int var)
417
+ int mapGetGlobalVar (int var, ProgramValue& value )
407
418
{
408
419
if (var < 0 || var >= gMapGlobalVarsLength ) {
409
420
debugPrint (" ERROR: attempt to reference map var out of range: %d" , var);
410
- return 0 ;
421
+ return -1 ;
422
+ }
423
+
424
+ if (gMapGlobalPointers [var] != nullptr ) {
425
+ value.opcode = VALUE_TYPE_PTR;
426
+ value.pointerValue = gMapGlobalPointers [var];
427
+ } else {
428
+ value.opcode = VALUE_TYPE_INT;
429
+ value.integerValue = gMapGlobalVars [var];
411
430
}
412
431
413
- return gMapGlobalVars [var] ;
432
+ return 0 ;
414
433
}
415
434
416
435
// 0x482280
@@ -1521,6 +1540,8 @@ static int mapGlobalVariablesInit(int count)
1521
1540
if (gMapGlobalVars == NULL ) {
1522
1541
return -1 ;
1523
1542
}
1543
+
1544
+ gMapGlobalPointers .resize (count);
1524
1545
}
1525
1546
1526
1547
gMapGlobalVarsLength = count;
@@ -1536,6 +1557,8 @@ static void mapGlobalVariablesFree()
1536
1557
gMapGlobalVars = NULL ;
1537
1558
gMapGlobalVarsLength = 0 ;
1538
1559
}
1560
+
1561
+ gMapGlobalPointers .clear ();
1539
1562
}
1540
1563
1541
1564
// NOTE: Inlined.
0 commit comments