-
-
Save IntelOrca/ffe2601888682fa55f30473ad5fd9b2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef unsigned char uint8; | |
typedef unsigned short StringId; | |
typedef unsigned int money32; | |
class IStream; | |
struct xyz32 | |
{ | |
int X, Y, Z; | |
}; | |
enum GA_ERROR : uint16 | |
{ | |
GA_ERROR_OK, | |
GA_ERROR_INSUFFICIENT_FUNDS, | |
GA_ERROR_NOT_OWNED, | |
GA_ERROR_TOO_LOW, | |
GA_ERROR_TOO_HIGH, | |
GA_ERROR_UNKNOWN = -1, | |
}; | |
struct GameActionResult | |
{ | |
money32 Cost; | |
xyz32 Position; | |
GA_ERROR Error; | |
StringId ErrorMessage; | |
}; | |
class IGameAction | |
{ | |
public: | |
virtual void Deserialise(IStream * stream) = 0; | |
virtual void Serialise(IStream * stream) = 0; | |
virtual GameActionResult Query() = 0; | |
virtual GameActionResult Execute() = 0; | |
}; | |
class SetRideStatusGameAction : IGameCommand | |
{ | |
private: | |
RideId _rideId; | |
RIDE_STATUS _rideStatus | |
public: | |
SetRideStatusGameAction(RideId rideId, RIDE_STATUS rideStatus) | |
{ | |
OpenRideGameAction action; | |
action._rideId = rideId; | |
action._rideStatus = rideStatus; | |
return action; | |
} | |
void Serialise(IStream * stream) override | |
{ | |
stream->Write(_rideId); | |
stream->Write(_rideStatus); | |
} | |
void Deserialise(IStream * stream) override | |
{ | |
_rideId = stream->Read<RideId>(); | |
_rideStatus = stream->Read<RIDE_STATUS>(); | |
} | |
GameActionResult Query() override | |
{ | |
return GameActionResult(); | |
} | |
GameActionResult Execute() override | |
{ | |
return GameActionResult(); | |
} | |
}; | |
RegisterGameAction(SetRideStatusGameAction); | |
typedef IGameCommand * (*GameCommandFactory)(); | |
std::vector<GameCommandFactory> Factories; | |
template<typename T> | |
void RegisterGameAction() | |
{ | |
GameCommandFactory factory = []() -> IGameCommand * | |
{ | |
return new T(); | |
}; | |
Factories.push_back(factory); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment