File diff r11916:e3a8d08bf479 → r11917:612c11f7ab47
src/autoreplace_gui.cpp
Show inline comments
 
@@ -66,20 +66,20 @@ static int CDECL EngineNumberSorter(cons
 
 *   - when a new vehicle is build, but before it's counted in num_engines
 
 *   - when a vehicle is deleted and after it's substracted from num_engines
 
 *   - when not changing the count (used when changing replace orders)
 
 */
 
void InvalidateAutoreplaceWindow(EngineID e, GroupID id_g)
 
{
 
	Company *c = GetCompany(_local_company);
 
	Company *c = Company::Get(_local_company);
 
	uint num_engines = GetGroupNumEngines(_local_company, id_g, e);
 

	
 
	if (num_engines == 0 || c->num_engines[e] == 0) {
 
		/* We don't have any of this engine type.
 
		 * Either we just sold the last one, we build a new one or we stopped replacing it.
 
		 * In all cases, we need to update the left list */
 
		InvalidateWindowData(WC_REPLACE_VEHICLE, GetEngine(e)->type, true);
 
		InvalidateWindowData(WC_REPLACE_VEHICLE, Engine::Get(e)->type, true);
 
	}
 
}
 

	
 
/** When an engine is made buildable or is removed from being buildable, add/remove it from the build/autoreplace lists
 
 * @param type The type of engine
 
 */
 
@@ -145,13 +145,13 @@ class ReplaceVehicleWindow : public Wind
 

	
 
			if (draw_left) {
 
				const GroupID selected_group = this->sel_group;
 
				const uint num_engines = GetGroupNumEngines(_local_company, selected_group, eid);
 

	
 
				/* Skip drawing the engines we don't have any of and haven't set for replacement */
 
				if (num_engines == 0 && EngineReplacementForCompany(GetCompany(_local_company), eid, selected_group) == INVALID_ENGINE) continue;
 
				if (num_engines == 0 && EngineReplacementForCompany(Company::Get(_local_company), eid, selected_group) == INVALID_ENGINE) continue;
 
			} else {
 
				if (!CheckAutoreplaceValidity(this->sel_engine[0], eid, _local_company)) continue;
 
			}
 

	
 
			*list->Append() = eid;
 
			if (eid == this->sel_engine[i]) selected_engine = eid; // The selected engine is still in the list
 
@@ -235,13 +235,13 @@ public:
 
	}
 

	
 
	virtual void OnPaint()
 
	{
 
		if (this->update_left || this->update_right) this->GenerateLists();
 

	
 
		Company *c = GetCompany(_local_company);
 
		Company *c = Company::Get(_local_company);
 
		EngineID selected_id[2];
 
		const GroupID selected_group = this->sel_group;
 

	
 
		selected_id[0] = this->sel_engine[0];
 
		selected_id[1] = this->sel_engine[1];
 

	
 
@@ -331,26 +331,26 @@ public:
 
				this->update_left = true;
 
				this->init_lists  = true;
 
				this->SetDirty();
 
				break;
 

	
 
			case RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN: { // Railtype selection dropdown menu
 
				const Company *c = GetCompany(_local_company);
 
				const Company *c = Company::Get(_local_company);
 
				DropDownList *list = new DropDownList();
 
				for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) {
 
					const RailtypeInfo *rti = GetRailTypeInfo(rt);
 
					/* Skip rail type if it has no label */
 
					if (rti->label == 0) continue;
 
					list->push_back(new DropDownListStringItem(rti->strings.replace_text, rt, !HasBit(c->avail_railtypes, rt)));
 
				}
 
				ShowDropDownList(this, list, sel_railtype, RVW_WIDGET_TRAIN_RAILTYPE_DROPDOWN);
 
				break;
 
			}
 

	
 
			case RVW_WIDGET_TRAIN_WAGONREMOVE_TOGGLE: // toggle renew_keep_length
 
				DoCommandP(0, 5, GetCompany(_local_company)->settings.renew_keep_length ? 0 : 1, CMD_SET_AUTOREPLACE);
 
				DoCommandP(0, 5, Company::Get(_local_company)->settings.renew_keep_length ? 0 : 1, CMD_SET_AUTOREPLACE);
 
				break;
 

	
 
			case RVW_WIDGET_START_REPLACE: { // Start replacing
 
				EngineID veh_from = this->sel_engine[0];
 
				EngineID veh_to = this->sel_engine[1];
 
				DoCommandP(0, 3 + (this->sel_group << 16) , veh_from + (veh_to << 16), CMD_SET_AUTOREPLACE);