src/command.h
changeset 7439 0c0e2945c890
parent 7328 8ac64204c17f
child 7442 a4f7989f27d4
equal deleted inserted replaced
7438:45e90ff7c97a 7439:0c0e2945c890
   182 enum {
   182 enum {
   183 	CMD_SERVER  = 0x1, ///< the command can only be initiated by the server
   183 	CMD_SERVER  = 0x1, ///< the command can only be initiated by the server
   184 	CMD_OFFLINE = 0x2, ///< the command cannot be executed in a multiplayer game; single-player only
   184 	CMD_OFFLINE = 0x2, ///< the command cannot be executed in a multiplayer game; single-player only
   185 };
   185 };
   186 
   186 
   187 typedef int32 CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);
   187 typedef CommandCost CommandProc(TileIndex tile, uint32 flags, uint32 p1, uint32 p2);
   188 
   188 
   189 struct Command {
   189 struct Command {
   190 	CommandProc *proc;
   190 	CommandProc *proc;
   191 	byte flags;
   191 	byte flags;
   192 };
   192 };
   197 /**
   197 /**
   198  * Check the return value of a DoCommand*() function
   198  * Check the return value of a DoCommand*() function
   199  * @param res the resulting value from the command to be checked
   199  * @param res the resulting value from the command to be checked
   200  * @return Return true if the command failed, false otherwise
   200  * @return Return true if the command failed, false otherwise
   201  */
   201  */
   202 static inline bool CmdFailed(int32 res)
   202 static inline bool CmdFailed(CommandCost res)
   203 {
   203 {
   204 	/* lower 16bits are the StringID of the possible error */
   204 	/* lower 16bits are the StringID of the possible error */
   205 	return res <= (CMD_ERROR | INVALID_STRING_ID);
   205 	return res <= (CMD_ERROR | INVALID_STRING_ID);
   206 }
   206 }
   207 
   207 
   208 /* command.cpp */
   208 /* command.cpp */
   209 typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
   209 typedef void CommandCallback(bool success, TileIndex tile, uint32 p1, uint32 p2);
   210 int32 DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
   210 CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
   211 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd);
   211 bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback, uint32 cmd);
   212 
   212 
   213 #ifdef ENABLE_NETWORK
   213 #ifdef ENABLE_NETWORK
   214 
   214 
   215 void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);
   215 void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback);