@@ -19,7 +19,7 @@
|
||||
|
||||
struct GRFFile;
|
||||
|
||||
enum CommandCostIntlFlags : uint8 {
|
||||
enum CommandCostIntlFlags : uint8_t {
|
||||
CCIF_NONE = 0,
|
||||
CCIF_SUCCESS = 1 << 0,
|
||||
CCIF_INLINE_EXTRA_MSG = 1 << 1,
|
||||
@@ -39,18 +39,18 @@ class CommandCost {
|
||||
CommandCostIntlFlags flags; ///< Flags: see CommandCostIntlFlags
|
||||
StringID message; ///< Warning message for when success is unset
|
||||
union {
|
||||
uint32 result = 0;
|
||||
uint32_t result = 0;
|
||||
StringID extra_message; ///< Additional warning message for when success is unset
|
||||
TileIndex tile;
|
||||
} inl;
|
||||
|
||||
struct CommandCostAuxiliaryData {
|
||||
uint32 textref_stack[16] = {};
|
||||
uint32_t textref_stack[16] = {};
|
||||
const GRFFile *textref_stack_grffile = nullptr; ///< NewGRF providing the #TextRefStack content.
|
||||
uint textref_stack_size = 0; ///< Number of uint32 values to put on the #TextRefStack for the error message.
|
||||
uint textref_stack_size = 0; ///< Number of uint32_t values to put on the #TextRefStack for the error message.
|
||||
StringID extra_message = INVALID_STRING_ID; ///< Additional warning message for when success is unset
|
||||
TileIndex tile = INVALID_TILE;
|
||||
uint32 result = 0;
|
||||
uint32_t result = 0;
|
||||
};
|
||||
std::unique_ptr<CommandCostAuxiliaryData> aux_data;
|
||||
|
||||
@@ -160,8 +160,8 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of uint32 values for the #TextRefStack of the error message.
|
||||
* @return number of uint32 values.
|
||||
* Returns the number of uint32_t values for the #TextRefStack of the error message.
|
||||
* @return number of uint32_t values.
|
||||
*/
|
||||
uint GetTextRefStackSize() const
|
||||
{
|
||||
@@ -170,9 +170,9 @@ public:
|
||||
|
||||
/**
|
||||
* Returns a pointer to the values for the #TextRefStack of the error message.
|
||||
* @return uint32 values for the #TextRefStack
|
||||
* @return uint32_t values for the #TextRefStack
|
||||
*/
|
||||
const uint32 *GetTextRefStack() const
|
||||
const uint32_t *GetTextRefStack() const
|
||||
{
|
||||
return this->aux_data != nullptr ? this->aux_data->textref_stack : nullptr;
|
||||
}
|
||||
@@ -254,13 +254,13 @@ public:
|
||||
return (this->flags & CCIF_VALID_RESULT);
|
||||
}
|
||||
|
||||
uint32 GetResultData() const
|
||||
uint32_t GetResultData() const
|
||||
{
|
||||
if (this->flags & CCIF_INLINE_RESULT) return this->inl.result;
|
||||
return this->aux_data != nullptr ? this->aux_data->result : 0;
|
||||
}
|
||||
|
||||
void SetResultData(uint32 result);
|
||||
void SetResultData(uint32_t result);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -651,8 +651,8 @@ struct CommandAuxiliaryBase;
|
||||
* @param text Additional text
|
||||
* @return The CommandCost of the command, which can be succeeded or failed.
|
||||
*/
|
||||
typedef CommandCost CommandProc(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text);
|
||||
typedef CommandCost CommandProcEx(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data);
|
||||
typedef CommandCost CommandProc(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text);
|
||||
typedef CommandCost CommandProcEx(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data);
|
||||
|
||||
/**
|
||||
* Define a command with the flags which belongs to it.
|
||||
@@ -674,7 +674,7 @@ struct Command {
|
||||
Command(CommandProcEx *procex, const char *name, CommandFlags flags, CommandType type)
|
||||
: procex(procex), name(name), flags(flags | CMD_PROCEX), type(type) {}
|
||||
|
||||
inline CommandCost Execute(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) const {
|
||||
inline CommandCost Execute(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) const {
|
||||
if (this->flags & CMD_PROCEX) {
|
||||
return this->procex(tile, flags, p1, p2, p3, text, aux_data);
|
||||
} else {
|
||||
@@ -697,7 +697,7 @@ struct Command {
|
||||
* @param p3 Additional data of the command
|
||||
* @see CommandProc
|
||||
*/
|
||||
typedef void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd);
|
||||
typedef void CommandCallback(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd);
|
||||
|
||||
#define MAX_CMD_TEXT_LENGTH 32000
|
||||
|
||||
@@ -708,7 +708,7 @@ struct CommandAuxiliaryBase {
|
||||
|
||||
virtual CommandAuxiliaryBase *Clone() const = 0;
|
||||
|
||||
virtual std::optional<span<const uint8>> GetDeserialisationSrc() const = 0;
|
||||
virtual std::optional<span<const uint8_t>> GetDeserialisationSrc() const = 0;
|
||||
|
||||
virtual void Serialise(CommandSerialisationBuffer &buffer) const = 0;
|
||||
};
|
||||
@@ -740,16 +740,16 @@ private:
|
||||
*/
|
||||
struct CommandContainer {
|
||||
TileIndex tile; ///< tile command being executed on.
|
||||
uint32 p1; ///< parameter p1.
|
||||
uint32 p2; ///< parameter p2.
|
||||
uint32 cmd; ///< command being executed.
|
||||
uint64 p3; ///< parameter p3. (here for alignment)
|
||||
uint32_t p1; ///< parameter p1.
|
||||
uint32_t p2; ///< parameter p2.
|
||||
uint32_t cmd; ///< command being executed.
|
||||
uint64_t p3; ///< parameter p3. (here for alignment)
|
||||
CommandCallback *callback; ///< any callback function executed upon successful completion of the command.
|
||||
std::string text; ///< possible text sent for name changes etc.
|
||||
CommandAuxiliaryPtr aux_data; ///< Auxiliary command data
|
||||
};
|
||||
|
||||
inline CommandContainer NewCommandContainerBasic(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = nullptr)
|
||||
inline CommandContainer NewCommandContainerBasic(TileIndex tile, uint32_t p1, uint32_t p2, uint32_t cmd, CommandCallback *callback = nullptr)
|
||||
{
|
||||
return { tile, p1, p2, cmd, 0, callback, {}, nullptr };
|
||||
}
|
||||
|
Reference in New Issue
Block a user