Skip to content

Instantly share code, notes, and snippets.

@IntelOrca
Created May 31, 2016 12:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntelOrca/ffe2601888682fa55f30473ad5fd9b2b to your computer and use it in GitHub Desktop.
Save IntelOrca/ffe2601888682fa55f30473ad5fd9b2b to your computer and use it in GitHub Desktop.
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