summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2021-10-22 22:04:52 +0200
committerfrosch <github@elsenhans.name>2021-10-23 14:45:08 +0200
commit111a47af0d0bb37b421eb8a77f1f8e69d38bbe3c (patch)
tree71bbf71617b3326bb05ae29995ba7d339639aaa3 /src
parentbc984d9af52eaf55b7b76ad9e3cc5115935803b0 (diff)
downloadopenttd-111a47af0d0bb37b421eb8a77f1f8e69d38bbe3c.tar.xz
Codechange: rename 'info_view' to 'rotor_in_gui', because it is only used by helicopters.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_engine.cpp22
-rw-r--r--src/newgrf_engine.h10
2 files changed, 18 insertions, 14 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp
index 128f5639c..a8dace53f 100644
--- a/src/newgrf_engine.cpp
+++ b/src/newgrf_engine.cpp
@@ -790,7 +790,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
case 0x1C: return v->y_pos;
case 0x1D: return GB(v->y_pos, 8, 8);
case 0x1E: return v->z_pos;
- case 0x1F: return object->info_view ? DIR_W : v->direction;
+ case 0x1F: return object->rotor_in_gui ? DIR_W : v->direction; // for rotors the spriteset contains animation frames, so NewGRF need a different way to tell the helicopter orientation.
case 0x20: break; // not implemented
case 0x21: break; // not implemented
case 0x22: break; // not implemented
@@ -1041,17 +1041,17 @@ static const GRFFile *GetEngineGrfFile(EngineID engine_type)
* @param engine_type Engine type
* @param v %Vehicle being resolved.
* @param wagon_override Application of wagon overrides.
- * @param info_view Indicates if the item is being drawn in an info window.
+ * @param rotor_in_gui Helicopter rotor is drawn in GUI.
* @param callback Callback ID.
* @param callback_param1 First parameter (var 10) of the callback.
* @param callback_param2 Second parameter (var 18) of the callback.
*/
-VehicleResolverObject::VehicleResolverObject(EngineID engine_type, const Vehicle *v, WagonOverride wagon_override, bool info_view,
+VehicleResolverObject::VehicleResolverObject(EngineID engine_type, const Vehicle *v, WagonOverride wagon_override, bool rotor_in_gui,
CallbackID callback, uint32 callback_param1, uint32 callback_param2)
: ResolverObject(GetEngineGrfFile(engine_type), callback, callback_param1, callback_param2),
- self_scope(*this, engine_type, v, info_view),
- parent_scope(*this, engine_type, ((v != nullptr) ? v->First() : v), info_view),
- relative_scope(*this, engine_type, v, info_view),
+ self_scope(*this, engine_type, v, rotor_in_gui),
+ parent_scope(*this, engine_type, ((v != nullptr) ? v->First() : v), rotor_in_gui),
+ relative_scope(*this, engine_type, v, rotor_in_gui),
cached_relative_count(0)
{
if (wagon_override == WO_SELF) {
@@ -1111,10 +1111,14 @@ void GetRotorOverrideSprite(EngineID engine, const struct Aircraft *v, EngineIma
assert(e->type == VEH_AIRCRAFT);
assert(!(e->u.air.subtype & AIR_CTOL));
- bool info_view = image_type != EIT_ON_MAP;
- VehicleResolverObject object(engine, v, VehicleResolverObject::WO_SELF, info_view, CBID_NO_CALLBACK);
+ /* We differ from TTDPatch by resolving the sprite using the primary vehicle 'v', and not using the rotor vehicle 'v->Next()->Next()'.
+ * TTDPatch copies some variables between the vehicles each time, to somehow synchronize the rotor vehicle with the primary vehicle.
+ * We use 'rotor_in_gui' to replicate when the variables differ.
+ * But some other variables like 'rotor state' and 'rotor speed' are not available in OpenTTD, while they are in TTDPatch. */
+ bool rotor_in_gui = image_type != EIT_ON_MAP;
+ VehicleResolverObject object(engine, v, VehicleResolverObject::WO_SELF, rotor_in_gui, CBID_NO_CALLBACK);
result->Clear();
- uint rotor_pos = v == nullptr || info_view ? 0 : v->Next()->Next()->state;
+ uint rotor_pos = v == nullptr || rotor_in_gui ? 0 : v->Next()->Next()->state;
bool sprite_stack = HasBit(e->info.misc_flags, EF_SPRITE_STACK);
uint max_stack = sprite_stack ? lengthof(result->seq) : 1;
diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h
index 0cfbb0a76..eb6a51040 100644
--- a/src/newgrf_engine.h
+++ b/src/newgrf_engine.h
@@ -22,17 +22,17 @@
struct VehicleScopeResolver : public ScopeResolver {
const struct Vehicle *v; ///< The vehicle being resolved.
EngineID self_type; ///< Type of the vehicle.
- bool info_view; ///< Indicates if the item is being drawn in an info window.
+ bool rotor_in_gui; ///< Helicopter rotor is drawn in GUI.
/**
* Scope resolver of a single vehicle.
* @param ro Surrounding resolver.
* @param engine_type Engine type
* @param v %Vehicle being resolved.
- * @param info_view Indicates if the item is being drawn in an info window.
+ * @param rotor_in_gui Helicopter rotor is drawn in GUI.
*/
- VehicleScopeResolver(ResolverObject &ro, EngineID engine_type, const Vehicle *v, bool info_view)
- : ScopeResolver(ro), v(v), self_type(engine_type), info_view(info_view)
+ VehicleScopeResolver(ResolverObject &ro, EngineID engine_type, const Vehicle *v, bool rotor_in_gui)
+ : ScopeResolver(ro), v(v), self_type(engine_type), rotor_in_gui(rotor_in_gui)
{
}
@@ -59,7 +59,7 @@ struct VehicleResolverObject : public ResolverObject {
VehicleScopeResolver relative_scope; ///< Scope resolver for an other vehicle in the chain.
byte cached_relative_count; ///< Relative position of the other vehicle.
- VehicleResolverObject(EngineID engine_type, const Vehicle *v, WagonOverride wagon_override, bool info_view = false,
+ VehicleResolverObject(EngineID engine_type, const Vehicle *v, WagonOverride wagon_override, bool rotor_in_gui = false,
CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0);
ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override;