MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetVariable

Function GetVariable

src/newgrf_spritegroup.cpp:54–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54static inline uint32_t GetVariable(const ResolverObject &object, ScopeResolver *scope, uint8_t variable, uint32_t parameter, bool &available)
55{
56 uint32_t value;
57 switch (variable) {
58 case 0x0C: return object.callback;
59 case 0x10: return object.callback_param1;
60 case 0x18: return object.callback_param2;
61 case 0x1C: return object.last_value;
62
63 case 0x5F: return (scope->GetRandomBits() << 8) | scope->GetRandomTriggers();
64
65 case 0x7D: return object.GetRegister(parameter);
66
67 case 0x7F:
68 if (object.grffile == nullptr) return 0;
69 return object.grffile->GetParam(parameter);
70
71 default:
72 /* First handle variables common with Action7/9/D */
73 if (variable < 0x40 && GetGlobalVariable(variable, &value, object.grffile)) return value;
74 /* Not a common variable, so evaluate the feature specific variables */
75 return scope->GetVariable(variable, parameter, available);
76 }
77}
78
79/**
80 * Get a few random bits. Default implementation has no random bits.

Callers 1

ResolveMethod · 0.85

Calls 6

GetGlobalVariableFunction · 0.85
GetRegisterMethod · 0.80
GetParamMethod · 0.80
GetRandomBitsMethod · 0.45
GetRandomTriggersMethod · 0.45
GetVariableMethod · 0.45

Tested by

no test coverage detected