src/group_cmd.cpp
changeset 8749 33c19f20a5db
parent 8733 9e2d2a2619ff
child 8750 fdd6054e7bae
equal deleted inserted replaced
8748:b8883e9894b9 8749:33c19f20a5db
    43 
    43 
    44 
    44 
    45 DEFINE_OLD_POOL_GENERIC(Group, Group)
    45 DEFINE_OLD_POOL_GENERIC(Group, Group)
    46 
    46 
    47 
    47 
    48 Group::Group(StringID str)
    48 Group::Group(PlayerID owner)
    49 {
    49 {
    50 	this->string_id = str;
    50 	this->owner = owner;
    51 }
    51 }
    52 
    52 
    53 Group::~Group()
    53 Group::~Group()
    54 {
    54 {
    55 	DeleteName(this->string_id);
    55 	DeleteName(this->string_id);
    56 	this->string_id = STR_NULL;
    56 	this->owner = INVALID_PLAYER;
    57 }
    57 }
    58 
    58 
    59 bool Group::IsValid() const
    59 bool Group::IsValid() const
    60 {
    60 {
    61 	return this->string_id != STR_NULL;
    61 	return this->owner != INVALID_PLAYER;
    62 }
    62 }
    63 
    63 
    64 void InitializeGroup(void)
    64 void InitializeGroup(void)
    65 {
    65 {
    66 	_Group_pool.CleanPool();
    66 	_Group_pool.CleanPool();
    91 	VehicleType vt = (VehicleType)p1;
    91 	VehicleType vt = (VehicleType)p1;
    92 	if (!IsPlayerBuildableVehicleType(vt)) return CMD_ERROR;
    92 	if (!IsPlayerBuildableVehicleType(vt)) return CMD_ERROR;
    93 
    93 
    94 	AutoPtrT<Group> g_auto_delete;
    94 	AutoPtrT<Group> g_auto_delete;
    95 
    95 
    96 	Group *g = new Group(STR_EMPTY);
    96 	Group *g = new Group(_current_player);
    97 	if (g == NULL) return CMD_ERROR;
    97 	if (g == NULL) return CMD_ERROR;
    98 
    98 
    99 	g_auto_delete = g;
    99 	g_auto_delete = g;
   100 
   100 
   101 	if (flags & DC_EXEC) {
   101 	if (flags & DC_EXEC) {
   102 		g->owner = _current_player;
       
   103 		g->replace_protection = false;
   102 		g->replace_protection = false;
   104 		g->vehicle_type = vt;
   103 		g->vehicle_type = vt;
   105 
   104 
   106 		InvalidateWindowData(GetWCForVT(vt), (vt << 11) | VLW_GROUP_LIST | _current_player);
   105 		InvalidateWindowData(GetWCForVT(vt), (vt << 11) | VLW_GROUP_LIST | _current_player);
   107 
   106