src/autoreplace_gui.cpp
changeset 7481 7d8d1dd8da4c
parent 7341 02515d0d4ced
child 7824 5a63d41b59ea
equal deleted inserted replaced
7480:1ae973d5f341 7481:7d8d1dd8da4c
    47  */
    47  */
    48 void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
    48 void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
    49 {
    49 {
    50 	Player *p = GetPlayer(_local_player);
    50 	Player *p = GetPlayer(_local_player);
    51 	byte type = GetEngine(e)->type;
    51 	byte type = GetEngine(e)->type;
    52 	uint num_engines = GetGroupNumEngines(id_g, e);
    52 	uint num_engines = GetGroupNumEngines(_local_player, id_g, e);
    53 
    53 
    54 	if (num_engines == 0 || p->num_engines[e] == 0) {
    54 	if (num_engines == 0 || p->num_engines[e] == 0) {
    55 		/* We don't have any of this engine type.
    55 		/* We don't have any of this engine type.
    56 		 * Either we just sold the last one, we build a new one or we stopped replacing it.
    56 		 * Either we just sold the last one, we build a new one or we stopped replacing it.
    57 		 * In all cases, we need to update the left list */
    57 		 * In all cases, we need to update the left list */
   152 	FOR_ALL_ENGINEIDS_OF_TYPE(e, type) {
   152 	FOR_ALL_ENGINEIDS_OF_TYPE(e, type) {
   153 		if (type == VEH_TRAIN && !GenerateReplaceRailList(e, draw_left, WP(w, replaceveh_d).wagon_btnstate)) continue; // special rules for trains
   153 		if (type == VEH_TRAIN && !GenerateReplaceRailList(e, draw_left, WP(w, replaceveh_d).wagon_btnstate)) continue; // special rules for trains
   154 
   154 
   155 		if (draw_left) {
   155 		if (draw_left) {
   156 			const GroupID selected_group = WP(w, replaceveh_d).sel_group;
   156 			const GroupID selected_group = WP(w, replaceveh_d).sel_group;
   157 			const uint num_engines = GetGroupNumEngines(selected_group, e);
   157 			const uint num_engines = GetGroupNumEngines(_local_player, selected_group, e);
   158 
   158 
   159 			/* Skip drawing the engines we don't have any of and haven't set for replacement */
   159 			/* Skip drawing the engines we don't have any of and haven't set for replacement */
   160 			if (num_engines == 0 && EngineReplacementForPlayer(GetPlayer(_local_player), e, selected_group) == INVALID_ENGINE) continue;
   160 			if (num_engines == 0 && EngineReplacementForPlayer(GetPlayer(_local_player), e, selected_group) == INVALID_ENGINE) continue;
   161 		} else {
   161 		} else {
   162 			/* This is for engines we can replace to and they should depend on what we selected to replace from */
   162 			/* This is for engines we can replace to and they should depend on what we selected to replace from */