Changeset - r12254:2375853718ac
[Not reviewed]
master
0 7 0
frosch - 15 years ago 2009-06-27 21:36:04
frosch@openttd.org
(svn r16679) -Codechange: Let GetCapacityOfArticulatedParts() return a CargoArray instead of a pointer to a static array.
7 files changed with 13 insertions and 15 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_engine.cpp
Show inline comments
 
@@ -70,7 +70,7 @@
 
	switch (e->type) {
 
		case VEH_ROAD:
 
		case VEH_TRAIN: {
 
			uint16 *capacities = GetCapacityOfArticulatedParts(engine_id, e->type);
 
			CargoArray capacities = GetCapacityOfArticulatedParts(engine_id, e->type);
 
			for (CargoID c = 0; c < NUM_CARGO; c++) {
 
				if (capacities[c] == 0) continue;
 
				return capacities[c];
src/ai/api/ai_event_types.cpp
Show inline comments
 
@@ -35,7 +35,7 @@ int32 AIEventEnginePreview::GetCapacity(
 
	switch (e->type) {
 
		case VEH_ROAD:
 
		case VEH_TRAIN: {
 
			uint16 *capacities = GetCapacityOfArticulatedParts(engine, e->type);
 
			CargoArray capacities = GetCapacityOfArticulatedParts(engine, e->type);
 
			for (CargoID c = 0; c < NUM_CARGO; c++) {
 
				if (capacities[c] == 0) continue;
 
				return capacities[c];
src/articulated_vehicles.cpp
Show inline comments
 
@@ -78,10 +78,9 @@ static inline uint32 GetAvailableVehicle
 
	return cargos;
 
}
 

	
 
uint16 *GetCapacityOfArticulatedParts(EngineID engine, VehicleType type)
 
CargoArray GetCapacityOfArticulatedParts(EngineID engine, VehicleType type)
 
{
 
	static uint16 capacity[NUM_CARGO];
 
	memset(capacity, 0, sizeof(capacity));
 
	CargoArray capacity;
 

	
 
	CargoID cargo_type;
 
	uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, type, &cargo_type);
 
@@ -239,12 +238,11 @@ void CheckConsistencyOfArticulatedVehicl
 

	
 
	uint32 purchase_refit_union = GetUnionOfArticulatedRefitMasks(v->engine_type, v->type, true);
 
	uint32 purchase_refit_intersection = GetIntersectionOfArticulatedRefitMasks(v->engine_type, v->type, true);
 
	uint16 *purchase_default_capacity = GetCapacityOfArticulatedParts(v->engine_type, v->type);
 
	CargoArray purchase_default_capacity = GetCapacityOfArticulatedParts(v->engine_type, v->type);
 

	
 
	uint32 real_refit_union = 0;
 
	uint32 real_refit_intersection = UINT_MAX;
 
	uint16 real_default_capacity[NUM_CARGO];
 
	memset(real_default_capacity, 0, sizeof(real_default_capacity));
 
	CargoArray real_default_capacity;
 

	
 
	do {
 
		uint32 refit_mask = GetAvailableVehicleCargoTypes(v->engine_type, v->type, true);
src/articulated_vehicles.h
Show inline comments
 
@@ -9,7 +9,7 @@
 
#include "engine_type.h"
 

	
 
uint CountArticulatedParts(EngineID engine_type, bool purchase_window);
 
uint16 *GetCapacityOfArticulatedParts(EngineID engine, VehicleType type);
 
CargoArray GetCapacityOfArticulatedParts(EngineID engine, VehicleType type);
 
void AddArticulatedParts(Vehicle *first, VehicleType type);
 
uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type);
 
uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type);
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -182,7 +182,7 @@ static CargoID GetNewCargoTypeForReplace
 
			/* Now we found a cargo type being carried on the train and we will see if it is possible to carry to this one */
 
			if (HasBit(available_cargo_types, v->cargo_type)) {
 
				/* Do we have to refit the vehicle, or is it already carrying the right cargo? */
 
				uint16 *default_capacity = GetCapacityOfArticulatedParts(engine_type, v->type);
 
				CargoArray default_capacity = GetCapacityOfArticulatedParts(engine_type, v->type);
 
				for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
 
					if (cid != v->cargo_type && default_capacity[cid] > 0) return v->cargo_type;
 
				}
 
@@ -198,7 +198,7 @@ static CargoID GetNewCargoTypeForReplace
 
		if (part_of_chain && !VerifyAutoreplaceRefitForOrders(v, engine_type)) return CT_INVALID; // Some refit orders lose their effect
 

	
 
		/* Do we have to refit the vehicle, or is it already carrying the right cargo? */
 
		uint16 *default_capacity = GetCapacityOfArticulatedParts(engine_type, v->type);
 
		CargoArray default_capacity = GetCapacityOfArticulatedParts(engine_type, v->type);
 
		for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
 
			if (cid != cargo_type && default_capacity[cid] > 0) return cargo_type;
 
		}
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -414,9 +414,9 @@ static GUIEngineList::FilterFunction * c
 

	
 
static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine, VehicleType type, bool refittable)
 
{
 
	uint16 *cap = GetCapacityOfArticulatedParts(engine, type);
 
	CargoArray cap = GetCapacityOfArticulatedParts(engine, type);
 

	
 
	for (uint c = 0; c < NUM_CARGO; c++) {
 
	for (CargoID c = 0; c < NUM_CARGO; c++) {
 
		if (cap[c] == 0) continue;
 

	
 
		SetDParam(0, c);
src/engine_gui.cpp
Show inline comments
 
@@ -139,8 +139,8 @@ uint GetTotalCapacityOfArticulatedParts(
 
{
 
	uint total = 0;
 

	
 
	uint16 *cap = GetCapacityOfArticulatedParts(engine, type);
 
	for (uint c = 0; c < NUM_CARGO; c++) {
 
	CargoArray cap = GetCapacityOfArticulatedParts(engine, type);
 
	for (CargoID c = 0; c < NUM_CARGO; c++) {
 
		total += cap[c];
 
	}
 

	
0 comments (0 inline, 0 general)