diff --git a/src/openrct2/world/SpriteBase.h b/src/openrct2/world/SpriteBase.h index edf2a4af1c..ced5d89fbf 100644 --- a/src/openrct2/world/SpriteBase.h +++ b/src/openrct2/world/SpriteBase.h @@ -36,12 +36,11 @@ struct SpriteBase template bool Is() const; template T* As() { - T* result = nullptr; - if (Is()) - { - result = reinterpret_cast(this); - } - return result; + return Is() ? reinterpret_cast(this) : nullptr; + } + template const T* As() const + { + return Is() ? reinterpret_cast(this) : nullptr; } };