File diff r12404:d58b2d050240 → r12405:ba094e765533
src/misc_gui.cpp
Show inline comments
 
@@ -219,52 +219,52 @@ public:
 
			line_nr++;
 
		}
 

	
 
		assert(line_nr < LAND_INFO_CENTERED_LINES);
 

	
 
		/* Mark last line empty */
 
		this->landinfo_data[line_nr][0] = '\0';
 

	
 
		/* Cargo acceptance is displayed in a extra multiline */
 
		char *strp = GetString(this->landinfo_data[LAND_INFO_MULTICENTER_LINE], STR_LAND_AREA_INFORMATION_CARGO_ACCEPTED, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
 
		bool found = false;
 

	
 
		for (CargoID i = 0; i < NUM_CARGO; ++i) {
 
			if (acceptance[i] > 0) {
 
				/* Add a comma between each item. */
 
				if (found) {
 
					*strp++ = ',';
 
					*strp++ = ' ';
 
				}
 
				found = true;
 

	
 
				/* If the accepted value is less than 8, show it in 1/8:ths */
 
				if (acceptance[i] < 8) {
 
					SetDParam(0, acceptance[i]);
 
					SetDParam(1, GetCargo(i)->name);
 
					SetDParam(1, CargoSpec::Get(i)->name);
 
					strp = GetString(strp, STR_LAND_AREA_INFORMATION_CARGO_EIGHTS, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
 
				} else {
 
					strp = GetString(strp, GetCargo(i)->name, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
 
					strp = GetString(strp, CargoSpec::Get(i)->name, lastof(this->landinfo_data[LAND_INFO_MULTICENTER_LINE]));
 
				}
 
			}
 
		}
 
		if (!found) this->landinfo_data[LAND_INFO_MULTICENTER_LINE][0] = '\0';
 

	
 
		if (found) line_nr += 2;
 

	
 
		if (line_nr > 6) ResizeWindow(this, 0, 12 * (line_nr - 6));
 

	
 
		this->FindWindowPlacementAndResize(&_land_info_desc);
 

	
 
#if defined(_DEBUG)
 
#	define LANDINFOD_LEVEL 0
 
#else
 
#	define LANDINFOD_LEVEL 1
 
#endif
 
		DEBUG(misc, LANDINFOD_LEVEL, "TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile));
 
		DEBUG(misc, LANDINFOD_LEVEL, "type_height  = %#x", _m[tile].type_height);
 
		DEBUG(misc, LANDINFOD_LEVEL, "m1           = %#x", _m[tile].m1);
 
		DEBUG(misc, LANDINFOD_LEVEL, "m2           = %#x", _m[tile].m2);
 
		DEBUG(misc, LANDINFOD_LEVEL, "m3           = %#x", _m[tile].m3);
 
		DEBUG(misc, LANDINFOD_LEVEL, "m4           = %#x", _m[tile].m4);
 
		DEBUG(misc, LANDINFOD_LEVEL, "m5           = %#x", _m[tile].m5);
 
		DEBUG(misc, LANDINFOD_LEVEL, "m6           = %#x", _m[tile].m6);
 
@@ -813,49 +813,49 @@ void GuiShowTooltips(StringID str, uint 
 
static int DrawStationCoverageText(const CargoArray &cargos,
 
	int left, int right, int top, StationCoverageType sct, bool supplies)
 
{
 
	bool first = true;
 

	
 
	char string[512];
 
	char *b = InlineString(string, supplies ? STR_STATION_BUILD_SUPPLIES_CARGO : STR_STATION_BUILD_ACCEPTS_CARGO);
 

	
 
	for (CargoID i = 0; i < NUM_CARGO; i++) {
 
		if (b >= lastof(string) - (1 + 2 * 4)) break; // ',' or ' ' and two calls to Utf8Encode()
 
		switch (sct) {
 
			case SCT_PASSENGERS_ONLY: if (!IsCargoInClass(i, CC_PASSENGERS)) continue; break;
 
			case SCT_NON_PASSENGERS_ONLY: if (IsCargoInClass(i, CC_PASSENGERS)) continue; break;
 
			case SCT_ALL: break;
 
			default: NOT_REACHED();
 
		}
 
		if (cargos[i] >= (supplies ? 1U : 8U)) {
 
			if (first) {
 
				first = false;
 
			} else {
 
				/* Add a comma if this is not the first item */
 
				*b++ = ',';
 
				*b++ = ' ';
 
			}
 
			b = InlineString(b, GetCargo(i)->name);
 
			b = InlineString(b, CargoSpec::Get(i)->name);
 
		}
 
	}
 

	
 
	/* If first is still true then no cargo is accepted */
 
	if (first) b = InlineString(b, STR_JUST_NOTHING);
 

	
 
	*b = '\0';
 

	
 
	/* Make sure we detect any buffer overflow */
 
	assert(b < endof(string));
 

	
 
	SetDParamStr(0, string);
 
	return DrawStringMultiLine(left, right, top, INT32_MAX, STR_JUST_RAW_STRING);
 
}
 

	
 
/**
 
 * Calculates and draws the accepted or supplied cargo around the selected tile(s)
 
 * @param left x position where the string is to be drawn
 
 * @param right the right most position to draw on
 
 * @param top y position where the string is to be drawn
 
 * @param sct which type of cargo is to be displayed (passengers/non-passengers)
 
 * @param rad radius around selected tile(s) to be searched
 
 * @param supplies if supplied cargos should be drawn, else accepted cargos
 
 * @return Returns the y value below the string that was drawn