Remove unnecessary type conversation.

Add override attributes.
Changed GameActionResult data storage to union, happy compilers.
This commit is contained in:
ZehMatt 2017-07-20 02:07:04 +02:00 committed by Michał Janiszewski
parent c73665a003
commit 5283804b37
4 changed files with 29 additions and 18 deletions

View File

@ -42,12 +42,12 @@ public:
{ {
} }
virtual void SetPlayer(uint32 playerId) override virtual void SetPlayer(uint32 playerId) override final
{ {
_playerId = playerId; _playerId = playerId;
} }
virtual uint32 GetPlayer() const override virtual uint32 GetPlayer() const override final
{ {
return _playerId; return _playerId;
} }
@ -55,7 +55,7 @@ public:
/** /**
* Gets the GA_FLAGS flags that are enabled for this game action. * Gets the GA_FLAGS flags that are enabled for this game action.
*/ */
virtual uint16 GetActionFlags() const override virtual uint16 GetActionFlags() const override final
{ {
return ActionFlags; return ActionFlags;
} }
@ -63,42 +63,42 @@ public:
/** /**
* Currently used for GAME_COMMAND_FLAGS, needs refactoring once everything is replaced. * Currently used for GAME_COMMAND_FLAGS, needs refactoring once everything is replaced.
*/ */
virtual uint32 GetFlags() const override virtual uint32 GetFlags() const override final
{ {
return _flags; return _flags;
} }
virtual uint32 SetFlags(uint32 flags) override virtual uint32 SetFlags(uint32 flags) override final
{ {
return _flags = flags; return _flags = flags;
} }
virtual uint32 GetType() const override virtual uint32 GetType() const override final
{ {
return Type; return Type;
} }
virtual void SetCallback(const GameActionCallback_t& cb) virtual void SetCallback(const GameActionCallback_t& cb) override final
{ {
_callback = cb; _callback = cb;
} }
virtual const GameActionCallback_t& GetCallback() const virtual const GameActionCallback_t& GetCallback() const override final
{ {
return _callback; return _callback;
} }
virtual void SetNetworkId(uint32_t id) virtual void SetNetworkId(uint32_t id) override final
{ {
_networkId = id; _networkId = id;
} }
virtual uint32 GetNetworkId() const virtual uint32 GetNetworkId() const override final
{ {
return _networkId; return _networkId;
} }
virtual void Serialise(DataSerialiser& stream) virtual void Serialise(DataSerialiser& stream) override
{ {
stream << _networkId; stream << _networkId;
stream << _flags; stream << _flags;
@ -108,12 +108,12 @@ public:
/** /**
* Query the result of the game action without changing the game state. * Query the result of the game action without changing the game state.
*/ */
virtual GameActionResult Query() const abstract; virtual GameActionResult Query() const override abstract;
/** /**
* Apply the game action and change the game state. * Apply the game action and change the game state.
*/ */
virtual GameActionResult Execute() const abstract; virtual GameActionResult Execute() const override abstract;
}; };
namespace GameActions namespace GameActions

View File

@ -69,7 +69,18 @@ struct GameActionResult
rct_xyz32 Position = { 0 }; rct_xyz32 Position = { 0 };
money32 Cost = 0; money32 Cost = 0;
uint16 ExpenditureType = 0; uint16 ExpenditureType = 0;
uint64 Results[4];
union
{
sint8 _sint8;
sint16 _sint16;
sint32 _sint32;
sint64 _sint64;
uint8 _uint8;
uint16 _uint16;
uint32 _uint32;
uint64 _uint64;
} Results[4];
GameActionResult(); GameActionResult();
GameActionResult(GA_ERROR error, rct_string_id message); GameActionResult(GA_ERROR error, rct_string_id message);

View File

@ -37,12 +37,12 @@ struct RideCreateGameActionResult : public GameActionResult {
sint32& RideIndex() sint32& RideIndex()
{ {
return reinterpret_cast<sint32&>(Results[0]); return Results[0]._sint32;
} }
uint32& RideColor() uint32& RideColor()
{ {
return reinterpret_cast<uint32&>(Results[1]); return Results[1]._uint32;
} }
}; };

View File

@ -56,9 +56,9 @@ public:
DataSerialiser& operator<<(T& data) DataSerialiser& operator<<(T& data)
{ {
if (_isSaving) if (_isSaving)
DataSerializerTraits<std::remove_const<T>::type>::encode(_activeStream, data); DataSerializerTraits<T>::encode(_activeStream, data);
else else
DataSerializerTraits<std::remove_const<T>::type>::decode(_activeStream, data); DataSerializerTraits<T>::decode(_activeStream, data);
return *this; return *this;
} }
}; };