(svn r12346) -Fix [FS#1748, FS#1825](r9874, r11872): Remove duplicated and inconsistent code wrt. autoreplace with rules in both vehicles' group and ALL_GROUP.
/* $Id$ *//** @file group.h */#ifndef GROUP_H#define GROUP_H#include"oldpool.h"#include"player_type.h"#include"vehicle_type.h"#include"engine.h"enum{ALL_GROUP=0xFFFD,DEFAULT_GROUP=0xFFFE,///< ungrouped vehicles are in this group.INVALID_GROUP=0xFFFF,};structGroup;DECLARE_OLD_POOL(Group,Group,5,2047)structGroup:PoolItem<Group,GroupID,&_Group_pool>{char*name;///< Group Nameuint16num_vehicle;///< Number of vehicles wich belong to the groupPlayerByteowner;///< Group OwnerVehicleTypeBytevehicle_type;///< Vehicle type of the groupboolreplace_protection;///< If set to true, the global autoreplace have no effect on the groupuint16num_engines[TOTAL_NUM_ENGINES];///< Caches the number of engines of each type the player owns (no need to save this)Group(PlayerIDowner=INVALID_PLAYER);virtual~Group();boolIsValid()const;};staticinlineboolIsValidGroupID(GroupIDindex){returnindex<GetGroupPoolSize()&&GetGroup(index)->IsValid();}staticinlineboolIsDefaultGroupID(GroupIDindex){returnindex==DEFAULT_GROUP;}/** * Checks if a GroupID stands for all vehicles of a player * @param id_g The GroupID to check * @return true is id_g is identical to ALL_GROUP */staticinlineboolIsAllGroupID(GroupIDid_g){returnid_g==ALL_GROUP;}#define FOR_ALL_GROUPS_FROM(g, start) for (g = GetGroup(start); g != NULL; g = (g->index + 1U < GetGroupPoolSize()) ? GetGroup(g->index + 1) : NULL) if (g->IsValid())#define FOR_ALL_GROUPS(g) FOR_ALL_GROUPS_FROM(g, 0)/** * Get the current size of the GroupPool */staticinlineuintGetGroupArraySize(void){constGroup*g;uintnum=0;FOR_ALL_GROUPS(g)num++;returnnum;}/** * Get the number of engines with EngineID id_e in the group with GroupID * id_g * @param id_g The GroupID of the group used * @param id_e The EngineID of the engine to count * @return The number of engines with EngineID id_e in the group */uintGetGroupNumEngines(PlayerIDp,GroupIDid_g,EngineIDid_e);staticinlinevoidIncreaseGroupNumVehicle(GroupIDid_g){if(IsValidGroupID(id_g))GetGroup(id_g)->num_vehicle++;}staticinlinevoidDecreaseGroupNumVehicle(GroupIDid_g){if(IsValidGroupID(id_g))GetGroup(id_g)->num_vehicle--;}voidInitializeGroup();voidSetTrainGroupID(Vehicle*v,GroupIDgrp);voidUpdateTrainGroupID(Vehicle*v);voidRemoveVehicleFromGroup(constVehicle*v);voidRemoveAllGroupsForPlayer(constPlayerIDp);#endif /* GROUP_H */