src/group_cmd.cpp
branchgamebalance
changeset 9913 e79cd19772dd
parent 9912 1ac8aac92385
equal deleted inserted replaced
9912:1ac8aac92385 9913:e79cd19772dd
    91  * Add a vehicle to a group
    91  * Add a vehicle to a group
    92  * @param tile unused
    92  * @param tile unused
    93  * @param p1   vehicle type
    93  * @param p1   vehicle type
    94  * @param p2   unused
    94  * @param p2   unused
    95  */
    95  */
    96 int32 CmdCreateGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
    96 CommandCost CmdCreateGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
    97 {
    97 {
    98 	VehicleType vt = (VehicleType)p1;
    98 	VehicleType vt = (VehicleType)p1;
    99 	if (!IsPlayerBuildableVehicleType(vt)) return CMD_ERROR;
    99 	if (!IsPlayerBuildableVehicleType(vt)) return CMD_ERROR;
   100 
   100 
   101 	Group *g = AllocateGroup();
   101 	Group *g = AllocateGroup();
   119  * @param tile unused
   119  * @param tile unused
   120  * @param p1   index of array group
   120  * @param p1   index of array group
   121  *      - p1 bit 0-15 : GroupID
   121  *      - p1 bit 0-15 : GroupID
   122  * @param p2   unused
   122  * @param p2   unused
   123  */
   123  */
   124 int32 CmdDeleteGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   124 CommandCost CmdDeleteGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   125 {
   125 {
   126 	if (!IsValidGroupID(p1)) return CMD_ERROR;
   126 	if (!IsValidGroupID(p1)) return CMD_ERROR;
   127 
   127 
   128 	Group *g = GetGroup(p1);
   128 	Group *g = GetGroup(p1);
   129 	if (g->owner != _current_player) return CMD_ERROR;
   129 	if (g->owner != _current_player) return CMD_ERROR;
   165  * @param tile unused
   165  * @param tile unused
   166  * @param p1   index of array group
   166  * @param p1   index of array group
   167  *   - p1 bit 0-15 : GroupID
   167  *   - p1 bit 0-15 : GroupID
   168  * @param p2   unused
   168  * @param p2   unused
   169  */
   169  */
   170 int32 CmdRenameGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   170 CommandCost CmdRenameGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   171 {
   171 {
   172 	if (!IsValidGroupID(p1) || StrEmpty(_cmd_text)) return CMD_ERROR;
   172 	if (!IsValidGroupID(p1) || StrEmpty(_cmd_text)) return CMD_ERROR;
   173 
   173 
   174 	Group *g = GetGroup(p1);
   174 	Group *g = GetGroup(p1);
   175 	if (g->owner != _current_player) return CMD_ERROR;
   175 	if (g->owner != _current_player) return CMD_ERROR;
   197  * @param p1   index of array group
   197  * @param p1   index of array group
   198  *   - p1 bit 0-15 : GroupID
   198  *   - p1 bit 0-15 : GroupID
   199  * @param p2   vehicle to add to a group
   199  * @param p2   vehicle to add to a group
   200  *   - p2 bit 0-15 : VehicleID
   200  *   - p2 bit 0-15 : VehicleID
   201  */
   201  */
   202 int32 CmdAddVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   202 CommandCost CmdAddVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   203 {
   203 {
   204 	GroupID new_g = p1;
   204 	GroupID new_g = p1;
   205 
   205 
   206 	if (!IsValidVehicleID(p2) || (!IsValidGroupID(new_g) && !IsDefaultGroupID(new_g))) return CMD_ERROR;
   206 	if (!IsValidVehicleID(p2) || (!IsValidGroupID(new_g) && !IsDefaultGroupID(new_g))) return CMD_ERROR;
   207 
   207 
   243  * @param tile unused
   243  * @param tile unused
   244  * @param p1   index of group array
   244  * @param p1   index of group array
   245  *  - p1 bit 0-15 : GroupID
   245  *  - p1 bit 0-15 : GroupID
   246  * @param p2   type of vehicles
   246  * @param p2   type of vehicles
   247  */
   247  */
   248 int32 CmdAddSharedVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   248 CommandCost CmdAddSharedVehicleGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   249 {
   249 {
   250 	VehicleType type = (VehicleType)p2;
   250 	VehicleType type = (VehicleType)p2;
   251 	if (!IsValidGroupID(p1) || !IsPlayerBuildableVehicleType(type)) return CMD_ERROR;
   251 	if (!IsValidGroupID(p1) || !IsPlayerBuildableVehicleType(type)) return CMD_ERROR;
   252 
   252 
   253 	if (flags & DC_EXEC) {
   253 	if (flags & DC_EXEC) {
   280  * @param tile unused
   280  * @param tile unused
   281  * @param p1   index of group array
   281  * @param p1   index of group array
   282  * - p1 bit 0-15 : GroupID
   282  * - p1 bit 0-15 : GroupID
   283  * @param p2   type of vehicles
   283  * @param p2   type of vehicles
   284  */
   284  */
   285 int32 CmdRemoveAllVehiclesGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   285 CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   286 {
   286 {
   287 	VehicleType type = (VehicleType)p2;
   287 	VehicleType type = (VehicleType)p2;
   288 	if (!IsValidGroupID(p1) || !IsPlayerBuildableVehicleType(type)) return CMD_ERROR;
   288 	if (!IsValidGroupID(p1) || !IsPlayerBuildableVehicleType(type)) return CMD_ERROR;
   289 
   289 
   290 	Group *g = GetGroup(p1);
   290 	Group *g = GetGroup(p1);
   317  * @param p1   index of group array
   317  * @param p1   index of group array
   318  * - p1 bit 0-15 : GroupID
   318  * - p1 bit 0-15 : GroupID
   319  * @param p2
   319  * @param p2
   320  * - p2 bit 0    : 1 to set or 0 to clear protection.
   320  * - p2 bit 0    : 1 to set or 0 to clear protection.
   321  */
   321  */
   322 int32 CmdSetGroupReplaceProtection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   322 CommandCost CmdSetGroupReplaceProtection(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
   323 {
   323 {
   324 	if (!IsValidGroupID(p1)) return CMD_ERROR;
   324 	if (!IsValidGroupID(p1)) return CMD_ERROR;
   325 
   325 
   326 	Group *g = GetGroup(p1);
   326 	Group *g = GetGroup(p1);
   327 	if (g->owner != _current_player) return CMD_ERROR;
   327 	if (g->owner != _current_player) return CMD_ERROR;