Changeset - r1019:90da3857ff29
[Not reviewed]
master
0 20 0
tron - 19 years ago 2005-01-15 08:58:31
tron@openttd.org
(svn r1520) Trim 134 (!) lines with trailing whitespace ):
20 files changed with 114 insertions and 114 deletions:
0 comments (0 inline, 0 general)
aircraft_cmd.c
Show inline comments
 
@@ -502,27 +502,27 @@ static void CheckIfAircraftNeedsService(
 
		v->current_order.flags = OF_NON_STOP;
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 
	} else if (v->current_order.type == OT_GOTO_DEPOT) {
 
		v->current_order.type = OT_DUMMY;
 
		v->current_order.flags = 0;
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 
	}
 
}
 

	
 
void InvalidateAircraftWindows(Vehicle *v)
 
{
 
	Order *o;
 
	
 

	
 
	InvalidateWindow(WC_AIRCRAFT_LIST, v->owner);
 
	
 

	
 
	for ( o = v->schedule_ptr; o->type != OT_NOTHING; o++, i++) {
 
		if (o->type == OT_GOTO_STATION ) {
 
			InvalidateWindow(WC_AIRCRAFT_LIST, o->station << 16 | v->owner);
 
		}
 
	}
 
}
 

	
 
void OnNewDay_Aircraft(Vehicle *v)
 
{
 
	int32 cost;
 

	
 
	if (v->subtype > 2)
 
@@ -539,25 +539,25 @@ void OnNewDay_Aircraft(Vehicle *v)
 

	
 
	if (v->vehstatus & VS_STOPPED)
 
		return;
 

	
 
	cost = AircraftVehInfo(v->engine_type)->running_cost * _price.aircraft_running / 364;
 

	
 
	v->profit_this_year -= cost >> 8;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
 
	SubtractMoneyFromPlayerFract(v->owner, cost);
 

	
 
	InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
	
 

	
 
	InvalidateAircraftWindows(v);
 
}
 

	
 
void AircraftYearlyLoop()
 
{
 
	Vehicle *v;
 

	
 
	FOR_ALL_VEHICLES(v) {
 
		if (v->type == VEH_Aircraft && v->subtype <= 2) {
 
			v->profit_last_year = v->profit_this_year;
 
			v->profit_this_year = 0;
 
			InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
@@ -1705,28 +1705,28 @@ static bool FreeTerminal(Vehicle *v, byt
 
			// TERMINAL# HELIPAD#
 
			v->u.air.state = i + TERM1; // start moving to that terminal/helipad
 
			SETBIT(st->airport_flags, i); // occupy terminal/helipad
 
			return true;
 
		}
 
	}
 
	return false;
 
}
 

	
 
static int GetNumTerminals(const AirportFTAClass *Airport)
 
{
 
	int i, num = 0;
 
	
 

	
 
	for (i = Airport->terminals[0]; i > 0; i--)
 
		num += Airport->terminals[i];
 
		
 

	
 
	return num;
 
}
 

	
 
static bool AirportFindFreeTerminal(Vehicle *v, const AirportFTAClass *Airport)
 
{
 
	AirportFTA *temp;
 
	Station *st;
 

	
 
	/* example of more terminalgroups
 
		{0,HANGAR,NOTHING_block,1}, {0,255,TERM_GROUP1_block,0}, {0,255,TERM_GROUP2_ENTER_block,1}, {0,0,N,1},
 
		Heading 255 denotes a group. We see 2 groups here:
 
		1. group 0 -- TERM_GROUP1_block (check block)
 
@@ -1764,28 +1764,28 @@ static bool AirportFindFreeTerminal(Vehi
 
			else {return false;} // once the heading isn't 255, we've exhausted the possible blocks. So we cannot move
 
			temp = temp->next_in_chain;
 
		}
 
	}
 

	
 
	// if there is only 1 terminalgroup, all terminals are checked (starting from 0 to max)
 
	return FreeTerminal(v, 0, GetNumTerminals(Airport));
 
}
 

	
 
static int GetNumHelipads(const AirportFTAClass *Airport)
 
{
 
	int i, num = 0;
 
	
 

	
 
	for (i = Airport->helipads[0]; i > 0; i--)
 
		num += Airport->helipads[i];
 
		
 

	
 
	return num;
 
}
 

	
 

	
 
static bool AirportFindFreeHelipad(Vehicle *v, const AirportFTAClass *Airport)
 
{
 
  Station *st;
 
  AirportFTA *temp;
 

	
 
	// if an airport doesn't have helipads, use terminals
 
	if (Airport->helipads == NULL) {return AirportFindFreeTerminal(v, Airport);}
 

	
 
@@ -1873,25 +1873,25 @@ void Aircraft_Tick(Vehicle *v)
 
	AgeAircraftCargo(v);
 

	
 
	for(i=0; i!=6; i++) {
 
		AircraftEventHandler(v, i);
 
		if (v->type != VEH_Aircraft) // In case it was deleted
 
			break;
 
	}
 
}
 

	
 
void UpdateOilRig( void )
 
{
 
	Station *st;
 
	
 

	
 
	FOR_ALL_STATIONS(st) {
 
		if (st->airport_type == 5) st->airport_type = AT_OILRIG;
 
	}
 
}
 

	
 
// need to be called to load aircraft from old version
 
void UpdateOldAircraft()
 
{
 
	Station *st;
 
	Vehicle *v_oldstyle;
 
	GetNewVehiclePosResult gp;
 

	
aircraft_gui.c
Show inline comments
 
@@ -195,50 +195,50 @@ static void ShowBuildAircraftWindow(uint
 

	
 
	w->resize.step_height = 24;
 

	
 
	if (tile != 0) {
 
		w->caption_color = _map_owner[tile];
 
	} else {
 
		w->caption_color = _local_player;
 
	}
 
}
 

	
 
#define MAX_REFIT 0xFF
 

	
 
const byte _aircraft_refit_normal[] = { 
 
const byte _aircraft_refit_normal[] = {
 
	CT_PASSENGERS,
 
	CT_MAIL,
 
	CT_GOODS,
 
	CT_VALUABLES,
 
	MAX_REFIT 
 
	MAX_REFIT
 
};
 

	
 
const byte _aircraft_refit_arctic[] = { 
 
const byte _aircraft_refit_arctic[] = {
 
	CT_PASSENGERS,
 
	CT_MAIL,
 
	CT_GOODS,
 
	CT_FOOD,
 
	MAX_REFIT 
 
	MAX_REFIT
 
};
 

	
 
const byte _aircraft_refit_desert[] = { 
 
const byte _aircraft_refit_desert[] = {
 
	CT_PASSENGERS,
 
	CT_MAIL,
 
	CT_FRUIT,
 
	CT_GOODS,
 
	CT_DIAMONDS,
 
	MAX_REFIT 
 
	MAX_REFIT
 
};
 

	
 
const byte _aircraft_refit_candy[] = { 
 
const byte _aircraft_refit_candy[] = {
 
	CT_PASSENGERS,
 
	CT_SUGAR,
 
	CT_TOYS,
 
	CT_CANDY,
 
	CT_COLA,
 
	CT_COTTON_CANDY,
 
	CT_BUBBLES,
 
	CT_TOFFEE,
 
	CT_BATTERIES,
 
	CT_PLASTIC,
 
	CT_FIZZY_DRINKS,
 
	MAX_REFIT
airport.c
Show inline comments
 
@@ -17,142 +17,142 @@ static void AirportFTAClass_Constructor(
 
static void AirportFTAClass_Destructor(AirportFTAClass *Airport);
 

	
 
static uint16 AirportGetNofElements(const AirportFTAbuildup *FA);
 
static void AirportBuildAutomata(AirportFTAClass *Airport, const AirportFTAbuildup *FA);
 
static byte AirportTestFTA(const AirportFTAClass *Airport);
 
/*static void AirportPrintOut(const AirportFTAClass *Airport, const bool full_report);
 
static byte AirportBlockToString(uint32 block);*/
 

	
 
void InitializeAirports()
 
{
 
	// country airport
 
	CountryAirport = malloc(sizeof(AirportFTAClass));
 
	
 

	
 
	AirportFTAClass_Constructor(
 
		CountryAirport, 
 
		_airport_terminal_country, 
 
		NULL, 
 
		16, 
 
		ALL, 
 
		_airport_fta_country, 
 
		_airport_depots_country, 
 
		CountryAirport,
 
		_airport_terminal_country,
 
		NULL,
 
		16,
 
		ALL,
 
		_airport_fta_country,
 
		_airport_depots_country,
 
		lengthof(_airport_depots_country)
 
	);
 

	
 
	// city airport
 
	CityAirport = malloc(sizeof(AirportFTAClass));
 
	
 

	
 
	AirportFTAClass_Constructor(
 
		CityAirport, 
 
		_airport_terminal_city, 
 
		NULL, 
 
		19, 
 
		ALL, 
 
		_airport_fta_city, 
 
		_airport_depots_city, 
 
		CityAirport,
 
		_airport_terminal_city,
 
		NULL,
 
		19,
 
		ALL,
 
		_airport_fta_city,
 
		_airport_depots_city,
 
		lengthof(_airport_depots_city)
 
	);
 

	
 
	// metropolitan airport
 
	MetropolitanAirport = malloc(sizeof(AirportFTAClass));
 
	
 

	
 
	AirportFTAClass_Constructor(
 
		MetropolitanAirport, 
 
		_airport_terminal_metropolitan, 
 
		NULL, 
 
		20, 
 
		ALL, 
 
		_airport_fta_metropolitan, 
 
		_airport_depots_metropolitan, 
 
		MetropolitanAirport,
 
		_airport_terminal_metropolitan,
 
		NULL,
 
		20,
 
		ALL,
 
		_airport_fta_metropolitan,
 
		_airport_depots_metropolitan,
 
		lengthof(_airport_depots_metropolitan)
 
	);
 

	
 
	// international airport
 
	InternationalAirport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
 
	
 

	
 
	AirportFTAClass_Constructor(
 
		InternationalAirport, 
 
		_airport_terminal_international, 
 
		_airport_helipad_international, 
 
		37, 
 
		ALL, 
 
		_airport_fta_international, 
 
		_airport_depots_international, 
 
		InternationalAirport,
 
		_airport_terminal_international,
 
		_airport_helipad_international,
 
		37,
 
		ALL,
 
		_airport_fta_international,
 
		_airport_depots_international,
 
		lengthof(_airport_depots_international)
 
	);
 

	
 
	// heliport, oilrig
 
	Heliport = (AirportFTAClass *)malloc(sizeof(AirportFTAClass));
 
	
 

	
 
	AirportFTAClass_Constructor(
 
		Heliport, 
 
		NULL, 
 
		_airport_helipad_heliport_oilrig, 
 
		7, 
 
		HELICOPTERS_ONLY, 
 
		_airport_fta_heliport_oilrig, 
 
		NULL, 
 
		Heliport,
 
		NULL,
 
		_airport_helipad_heliport_oilrig,
 
		7,
 
		HELICOPTERS_ONLY,
 
		_airport_fta_heliport_oilrig,
 
		NULL,
 
		0
 
	);
 
	
 

	
 
	Oilrig = Heliport;  // exactly the same structure for heliport/oilrig, so share state machine
 
}
 

	
 
void UnInitializeAirports()
 
{
 
	AirportFTAClass_Destructor(CountryAirport);
 
	AirportFTAClass_Destructor(CityAirport);
 
	AirportFTAClass_Destructor(Heliport);
 
	AirportFTAClass_Destructor(MetropolitanAirport);
 
	AirportFTAClass_Destructor(InternationalAirport);
 
}
 

	
 
static void AirportFTAClass_Constructor(AirportFTAClass *Airport,
 
																				const byte *terminals, const byte *helipads,
 
																				const byte entry_point, const byte acc_planes,
 
																				const AirportFTAbuildup *FA,
 
																				const TileIndexDiffC *depots, const byte nof_depots)
 
{
 
	byte nofterminals, nofhelipads;
 
	byte nofterminalgroups = 0;
 
	byte nofhelipadgroups = 0;
 
	const byte * curr;
 
	int i;
 
	nofterminals = nofhelipads = 0;
 
	
 

	
 
	//now we read the number of terminals we have
 
	if (terminals != NULL) {
 
		i = terminals[0];
 
		nofterminalgroups = i;
 
		curr = terminals;
 
		while (i-- > 0) {
 
			curr++;
 
			assert(*curr != 0);	//we don't want to have an empty group
 
			nofterminals += *curr;
 
		}
 
	
 

	
 
	}
 
	Airport->terminals = terminals;
 

	
 
	//read helipads	
 
	//read helipads
 
	if (helipads != NULL) {
 
		i = helipads[0];
 
		nofhelipadgroups = i;
 
		curr = helipads;
 
		while (i-- > 0) {
 
			curr++;
 
			assert(*curr != 0); //no empty groups please
 
			nofhelipads += *curr;
 
		}
 
	
 

	
 
	}
 
	Airport->helipads = helipads;
 

	
 
	// if there are more terminals than 6, internal variables have to be changed, so don't allow that
 
	// same goes for helipads
 
	if (nofterminals > MAX_TERMINALS) { printf("Currently only maximum of %2d terminals are supported (you wanted %2d)\n", MAX_TERMINALS, nofterminals);}
 
	if (nofhelipads > MAX_HELIPADS) { printf("Currently only maximum of %2d helipads are supported (you wanted %2d)\n", MAX_HELIPADS, nofhelipads);}
 
	// terminals/helipads are divided into groups. Groups are computed by dividing the number
 
	// of terminals by the number of groups. Half in half. If #terminals is uneven, first group
 
	// will get the less # of terminals
 

	
 
	assert(nofterminals <= MAX_TERMINALS);
airport_gui.c
Show inline comments
 
@@ -60,25 +60,25 @@ static OnButtonClick * const _build_air_
 

	
 
static void BuildAirToolbWndProc(Window *w, WindowEvent *e)
 
{
 
	switch(e->event) {
 
	case WE_PAINT:
 
		DrawWindowWidgets(w);
 
		break;
 

	
 
	case WE_CLICK:
 
		if (e->click.widget - 3 >= 0)
 
			_build_air_button_proc[e->click.widget - 3](w);
 
		break;
 
		
 

	
 
	case WE_KEYPRESS: {
 
		switch (e->keypress.keycode) {
 
			case '1': BuildAirClick_Airport(w); break;
 
			case '2': BuildAirClick_Demolish(w); break;
 
			case 'l': BuildAirClick_Landscaping(w); break;
 
			default:
 
				return;
 
		}
 
	} break;
 

	
 
	case WE_PLACE_OBJ:
 
		_place_proc(e->place.tile);
console_cmds.c
Show inline comments
 
@@ -208,54 +208,54 @@ DEF_CONSOLE_CMD(ConListFiles)
 
	return NULL;
 
}
 

	
 
/* Get an Specific file */
 
DEF_CONSOLE_CMD(ConScanFiles)
 
{
 
	const FiosItem *item;
 
	int pos = 0;
 
	_iconsole_var* result;
 

	
 

	
 
	result = IConsoleVarAlloc(ICONSOLE_VAR_STRING);
 
	
 

	
 
	if (argc <= 1) {
 
		IConsoleVarSetString(result, "0");
 
		return result; // return an zero
 
	}
 

	
 
	/* Build the file-list */
 
	BuildFileList();
 

	
 
	/* As long as we have files */
 
	while (pos < _fios_num) {
 
		item = _fios_list + pos;
 
		pos++;		
 
		pos++;
 
		if (strcmp(argv[1], "..") == 0) {
 
			if (item->type == FIOS_TYPE_PARENT) {
 
				// huh we are searching for the parent directory
 
				char buffer[10];
 
				sprintf(buffer, "%d", pos);
 
				IConsoleVarSetString(result, buffer);
 
				return result;
 
			}
 
		} else 
 
		} else
 
			// file records ?
 
			if (item->type == FIOS_TYPE_FILE) {
 
				if (strcmp(argv[1], item->name) == 0) {
 
					char buffer[10];
 
					sprintf(buffer, "%d", pos);
 
					IConsoleVarSetString(result, buffer);
 
					return result;
 
				}			
 
				}
 
			}
 
	}
 

	
 
	/* Destroy the file list */
 
	FiosFreeSavegameList();
 

	
 
	return NULL;
 
}
 

	
 
/* Change the dir via console */
 
DEF_CONSOLE_CMD(ConGotoDir)
 
{
dock_gui.c
Show inline comments
 
@@ -109,35 +109,35 @@ static OnButtonClick * const _build_dock
 
};
 

	
 
static void BuildDocksToolbWndProc(Window *w, WindowEvent *e)
 
{
 
	switch(e->event) {
 
	case WE_PAINT:
 
		DrawWindowWidgets(w);
 
		break;
 

	
 
	case WE_CLICK: {
 
		if (e->click.widget - 3 >= 0 && e->click.widget != 5) _build_docks_button_proc[e->click.widget - 3](w);
 
	} break;
 
	
 

	
 
	case WE_KEYPRESS: {
 
		switch(e->keypress.keycode) {
 
			case '1': BuildDocksClick_Canal(w); break;
 
			case '2': BuildDocksClick_Lock(w); break;
 
			case '3': BuildDocksClick_Demolish(w); break;
 
			case '4': BuildDocksClick_Depot(w); break;
 
			case '5': BuildDocksClick_Dock(w); break;
 
			case '6': BuildDocksClick_Buoy(w); break;
 
			case 'l': BuildDocksClick_Landscaping(w); break;
 
			default: 
 
			default:
 
				return;
 
		}
 
	} break;
 

	
 
	case WE_PLACE_OBJ:
 
		_place_proc(e->place.tile);
 
		break;
 

	
 
	case WE_PLACE_DRAG: {
 
		VpSelectTilesWithMethod(e->place.pt.x, e->place.pt.y, e->place.userdata);
 
		return;
 
	}
economy.c
Show inline comments
 
@@ -97,25 +97,25 @@ int64 CalculateCompanyValue(Player *p) {
 
			if (v->owner != owner)
 
				continue;
 
			if (v->type == VEH_Train ||
 
					v->type == VEH_Road ||
 
					(v->type == VEH_Aircraft && v->subtype<=2) ||
 
					v->type == VEH_Ship) {
 
				value += v->value * 3 >> 1;
 
			}
 
		}
 
	}
 

	
 
	value += p->money64 - p->current_loan; // add real money value
 
	
 

	
 
	return max(value, 1);
 
}
 

	
 
// if update is set to true, the economy is updated with this score
 
//  (also the house is updated, should only be true in the on-tick event)
 
int UpdateCompanyRatingAndValue(Player *p, bool update)
 
{
 
	byte owner = p->index;
 
	int score = 0;
 

	
 
	memset(_score_part[owner], 0, sizeof(_score_part[owner]));
 

	
 
@@ -1523,43 +1523,43 @@ static void DoAcquireCompany(Player *p)
 

	
 
extern int GetAmountOwnedBy(Player *p, byte owner);
 

	
 
int32 CmdBuyShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Player *p;
 
	int64 cost;
 
	byte *b;
 
	int i;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_OTHER);
 
	p = DEREF_PLAYER(p1);
 
	
 
	
 

	
 

	
 
	if (_cur_year - p->inaugurated_year < 6) {
 
		_error_message = STR_7080_PROTECTED;
 
		return CMD_ERROR;
 
	}
 

	
 
	/* Check if buying shares is allowed (protection against modified clients */
 
	if (!_patches.allow_shares)
 
		return CMD_ERROR;
 

	
 
	/* Those lines are here for network-protection (clients can be slow) */
 
	if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 0)
 
		return 0;
 

	
 
	/* We can not buy out a real player in networking */
 
	if (GetAmountOwnedBy(p, OWNER_SPECTATOR) == 1 && !p->is_ai)
 
		return 0;
 
	
 

	
 
	cost = CalculateCompanyValue(p) >> 2;
 
	if (flags & DC_EXEC) {
 
		b = p->share_owners;
 
		while (*b != 0xFF) b++; /* share owners is guaranteed to contain at least one 0xFF */
 
		*b = _current_player;
 

	
 
		for(i=0;p->share_owners[i] == _current_player;) {
 
			if (++i == 4) {
 
				p->bankrupt_value = 0;
 
				DoAcquireCompany(p);
 
				break;
 
			}
 
@@ -1572,25 +1572,25 @@ int32 CmdBuyShareInCompany(int x, int y,
 
int32 CmdSellShareInCompany(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Player *p;
 
	int64 cost;
 
	byte *b;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_OTHER);
 
	p = DEREF_PLAYER(p1);
 

	
 
	/* Check if selling shares is allowed (protection against modified clients */
 
	if (!_patches.allow_shares)
 
		return CMD_ERROR;
 
		
 

	
 
	/* Those lines are here for network-protection (clients can be slow) */
 
	if (GetAmountOwnedBy(p, _current_player) == 0)
 
		return 0;
 

	
 
	/* adjust it a little to make it less profitable to sell and buy */
 
	cost = CalculateCompanyValue(p) >> 2;
 
	cost = -(cost - (cost >> 7));
 

	
 
	if (flags & DC_EXEC) {
 
		b = p->share_owners;
 
		while (*b != _current_player) b++; /* share owners is guaranteed to contain player */
 
		*b = 0xFF;
industry_cmd.c
Show inline comments
 
@@ -1367,26 +1367,26 @@ static bool CheckIfTooCloseToIndustry(ui
 
	const IndustrySpec *spec;
 
	spec = &_industry_spec[type];
 

	
 
	// accepting industries won't be close, not even with patch
 
	if (_patches.same_industry_close && (spec->accepts_cargo[0] == 0xFF) )
 
		return true;
 

	
 
	FOR_ALL_INDUSTRIES(i) {
 
		// check if an industry that accepts the same goods is nearby
 
		if (i->xy != 0 &&
 
				(GetTileDist1D(tile, i->xy) <= 14) &&
 
				spec->accepts_cargo[0] != 0xFF &&
 
				spec->accepts_cargo[0] == i->accepts_cargo[0] && 
 
				!(_game_mode == GM_EDITOR && 
 
				spec->accepts_cargo[0] == i->accepts_cargo[0] &&
 
				!(_game_mode == GM_EDITOR &&
 
					_patches.same_industry_close &&
 
					_patches.multiple_industry_per_town)) {
 
				_error_message = STR_INDUSTRY_TOO_CLOSE;
 
				return false;
 
				}
 

	
 
		// check "not close to" field.
 
		if (i->xy != 0 &&
 
				(i->type == spec->a || i->type == spec->b || i->type == spec->c) &&
 
				GetTileDist1D(tile, i->xy) <= 14) {
 
			_error_message = STR_INDUSTRY_TOO_CLOSE;
 
			return false;
industry_gui.c
Show inline comments
 
@@ -324,70 +324,70 @@ static void IndustryViewWndProc(Window *
 
			}
 
		}
 

	
 
		DrawWindowViewport(w);
 
		}
 
		break;
 

	
 
	case WE_CLICK: {
 
		Industry *i;
 

	
 
		switch(e->click.widget) {
 
		case 5: {
 
			int line; 
 
			int line;
 
			int x;
 
			byte b;
 

	
 
			i = GetIndustry(w->window_number);
 

	
 
			// We should only work in editor
 
			if (_game_mode != GM_EDITOR)
 
				return;
 

	
 
			// And if the industry is raw-material producer
 
			if (i->accepts_cargo[0] != CT_INVALID)
 
				return;
 

	
 
			x = e->click.pt.x;
 
			line = (e->click.pt.y - 127) / 10;
 
			if (e->click.pt.y >= 127 && IS_INT_INSIDE(line, 0, 2) && i->produced_cargo[line]) {
 
				if (IS_INT_INSIDE(x, 5, 25) ) { 
 
				if (IS_INT_INSIDE(x, 5, 25) ) {
 
					// clicked buttons
 
					if (x < 15) {				
 
					if (x < 15) {
 
						// decrease
 
						i->production_rate[line] /= 2;
 
						if (i->production_rate[line] < 4)
 
							i->production_rate[line] = 4;
 
					} else {
 
						// increase
 
						b = i->production_rate[line] * 2;
 
						if (i->production_rate[line] >= 128) 
 
						if (i->production_rate[line] >= 128)
 
							b=255;
 
						i->production_rate[line] = b;
 
					}
 
					UpdateIndustryProduction(i);
 
					SetWindowDirty(w);
 
					w->flags4 |= 5 << WF_TIMEOUT_SHL;
 
					WP(w,vp2_d).data_2 = line+1;
 
					WP(w,vp2_d).data_3 = (x < 15 ? 1 : 2);
 
				} else if (IS_INT_INSIDE(x, 34, 160)) {
 
					// clicked the text
 
					WP(w,vp2_d).data_1 = line;
 
					SetDParam(0, i->production_rate[line] * 8);
 
					ShowQueryString(STR_CONFIG_PATCHES_INT32, 
 
							STR_CONFIG_GAME_PRODUCTION, 
 
							10, 100, w->window_class, 
 
					ShowQueryString(STR_CONFIG_PATCHES_INT32,
 
							STR_CONFIG_GAME_PRODUCTION,
 
							10, 100, w->window_class,
 
							w->window_number);
 
				}
 
			}	
 
			}
 
			}
 
			break;
 
		case 6:
 
			i = GetIndustry(w->window_number);
 
			ScrollMainWindowToTile(i->xy + TILE_XY(1,1));
 
			break;
 
		case 7:
 
			// Destroy Industry button costing money removed per request of dominik
 
			//i = GetIndustry(w->window_number);
 
			/*	passing only i->xy is not safe if industry has a weird shape like:
 
					_ X X
 
					X X X
main_gui.c
Show inline comments
 
@@ -1089,25 +1089,25 @@ static void AskResetLandscapeWndProc(Win
 
	case WE_PAINT:
 
		DrawWindowWidgets(w);
 
		DrawStringMultiCenter(90, 38, mode?STR_022D_ARE_YOU_SURE_YOU_WANT_TO:STR_GENERATE_RANDOM_LANDSCAPE , 168);
 
	case WE_CLICK:
 
		switch(e->click.widget) {
 
		case 3:
 
			DeleteWindow(w);
 
			break;
 
		case 4:
 
			DeleteWindow(w);
 
			DeleteWindowByClass(WC_INDUSTRY_VIEW);
 
			DeleteWindowByClass(WC_TOWN_VIEW);
 
			DeleteWindowByClass(WC_LAND_INFO);			
 
			DeleteWindowByClass(WC_LAND_INFO);
 

	
 
			if (mode) { // reset landscape
 
				ResetLandscape();
 
			} else { // make random landscape
 
				SndPlayFx(SND_15_BEEP);
 
				_switch_mode = SM_GENRANDLAND;
 
			}
 

	
 
			break;
 
		}
 
	}
 
}
 
@@ -1255,25 +1255,25 @@ static const int8 _multi_terraform_coord
 
	{-12,  0},{ -8, -2},{ -4, -4},{  0, -6},{  4, -4},{  8, -2},{ 12,  0},
 
	{-16,  2},{-12,  4},{ -8,  6},{ -4,  8},{  0, 10},{  4,  8},{  8,  6},{ 12,  4},{ 16,  2},
 
	{-20,  0},{-16, -2},{-12, -4},{ -8, -6},{ -4, -8},{  0,-10},{  4, -8},{  8, -6},{ 12, -4},{ 16, -2},{ 20,  0},
 
	{-24,  2},{-20,  4},{-16,  6},{-12,  8},{ -8, 10},{ -4, 12},{  0, 14},{  4, 12},{  8, 10},{ 12,  8},{ 16,  6},{ 20,  4},{ 24,  2},
 
	{-28,  0},{-24, -2},{-20, -4},{-16, -6},{-12, -8},{ -8,-10},{ -4,-12},{  0,-14},{  4,-12},{  8,-10},{ 12, -8},{ 16, -6},{ 20, -4},{ 24, -2},{ 28,  0},
 
};
 

	
 
static void ScenEditLandGenWndProc(Window *w, WindowEvent *e)
 
{
 
	switch(e->event) {
 
	case WE_PAINT:
 
		// XXX - lighthouse button is widget 11!! Don't forget when changing
 
		w->widget[11].tooltips = (_opt.landscape == LT_DESERT) ? STR_028F_DEFINE_DESERT_AREA : STR_028D_PLACE_LIGHTHOUSE; 
 
		w->widget[11].tooltips = (_opt.landscape == LT_DESERT) ? STR_028F_DEFINE_DESERT_AREA : STR_028D_PLACE_LIGHTHOUSE;
 
		DrawWindowWidgets(w);
 

	
 
		{
 
			int n = _terraform_size * _terraform_size;
 
			const int8 *coords = &_multi_terraform_coords[0][0];
 

	
 
			assert(n != 0);
 
			do {
 
				DrawSprite(0xFEF, 77 + coords[0], 55 + coords[1]);
 
				coords += 2;
 
			} while (--n);
 
		}
 
@@ -2418,25 +2418,25 @@ void ShowVitalWindows(void)
 
{
 
	Window *w;
 

	
 
	w = AllocateWindowDesc(&_toolb_normal_desc);
 
	w->disabled_state = 1 << 17; // disable zoom-in button (by default game is zoomed in)
 
	CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
 

	
 
	if (_networking) { // if networking, disable fast-forward button
 
		SETBIT(w->disabled_state, 1);
 
		if (!_network_server) // if not server, disable pause button
 
			SETBIT(w->disabled_state, 0);
 
	}
 
	
 

	
 
	PositionMainToolbar(w); // already WC_MAIN_TOOLBAR passed (&_toolb_normal_desc)
 

	
 
	_main_status_desc.top = _screen.height - 12;
 
	w = AllocateWindowDesc(&_main_status_desc);
 
	CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
 

	
 
	WP(w,def_d).data_1 = -1280;
 
}
 

	
 
void GameSizeChanged()
 
{
 
	RelocateAllWindows(_screen.width, _screen.height);
network_gui.c
Show inline comments
 
@@ -716,27 +716,27 @@ static void NetworkLobbyWindowWndProc(Wi
 
		pos = w->vscroll.pos;
 
		while (pos < _network_lobby_company_count) {
 
			byte index = NetworkLobbyFindCompanyIndex(pos);
 
			bool income = false;
 
			if (_selected_company_item == index)
 
				GfxFillRect(11, y - 1, 139, y + 10, 155); // show highlighted item with a different colour
 

	
 
			DoDrawString(_network_player_info[index].company_name, 13, y, 2);
 
			if(_network_player_info[index].use_password != 0)
 
				DrawSprite(SPR_LOCK, 120, y);
 

	
 
			/* If the company's income was positive puts a green dot else a red dot */
 
			if ((_network_player_info[index].income) > 0) 
 
			if ((_network_player_info[index].income) > 0)
 
				income = true;
 
			DrawSprite(SPR_BLOT | (income?0x30d8000:0x30b8000), 130, y); 
 
			DrawSprite(SPR_BLOT | (income?0x30d8000:0x30b8000), 130, y);
 

	
 
			pos++;
 
			y += NET_PRC__SIZE_OF_ROW_COMPANY;
 
			if (pos >= w->vscroll.cap)
 
				break;
 
		}
 

	
 
		// draw info about selected company
 
		DrawStringMultiCenter(270, 48, STR_NETWORK_COMPANY_INFO, 0);
 
		if (_selected_company_item != -1) { // if a company is selected...
 
			// show company info
 
			const uint x = 168;
network_udp.c
Show inline comments
 
@@ -165,26 +165,26 @@ DEF_UDP_RECEIVE_COMMAND(PACKET_UDP_CLIEN
 
		NetworkSend_string(packet, _network_player_info[player->index].company_name);
 
		NetworkSend_uint8 (packet, _network_player_info[player->index].inaugurated_year);
 
		NetworkSend_uint64(packet, _network_player_info[player->index].company_value);
 
		NetworkSend_uint64(packet, _network_player_info[player->index].money);
 
		NetworkSend_uint64(packet, _network_player_info[player->index].income);
 
		NetworkSend_uint16(packet, _network_player_info[player->index].performance);
 

	
 
                /* Send 1 if there is a passord for the company else send 0 */
 
		if (_network_player_info[player->index].password[0] != '\0') {
 
			NetworkSend_uint8 (p, 1);
 
		} else {
 
			NetworkSend_uint8 (p, 0);
 
		}		
 
		
 
		}
 

	
 
		for (i = 0; i < NETWORK_VEHICLE_TYPES; i++)
 
			NetworkSend_uint16(packet, _network_player_info[player->index].num_vehicle[i]);
 

	
 
		for (i = 0; i < NETWORK_STATION_TYPES; i++)
 
			NetworkSend_uint16(packet, _network_player_info[player->index].num_station[i]);
 

	
 
		/* Find the clients that are connected to this player */
 
		FOR_ALL_CLIENTS(cs) {
 
			ci = DEREF_CLIENT_INFO(cs);
 
			if ((ci->client_playas - 1) == player->index) {
 
				/* The uint8 == 1 indicates that a client is following */
 
				NetworkSend_uint8(packet, 1);
order_gui.c
Show inline comments
 
@@ -42,25 +42,25 @@ static void DrawOrdersWindow(Window *w)
 
	bool shared_schedule;
 

	
 
	v = GetVehicle(w->window_number);
 

	
 
	w->disabled_state = (v->owner == _local_player) ? 0 : (
 
		1 << 4 |   //skip
 
		1 << 5 |   //delete
 
		1 << 6 |   //non-stop
 
		1 << 7 |   //go-to
 
		1 << 8 |   //full load
 
		1 << 9     //unload
 
		);
 
		
 

	
 
	//disable non-stop for non-trains
 
	if (v->type != VEH_Train) {
 
		w->disabled_state |= 1 << 6;
 
	}
 

	
 
	shared_schedule = IsScheduleShared(v) != NULL;
 

	
 
	sched = v->schedule_ptr;
 
	num=0;
 
	while (sched->type != OT_NOTHING) {
 
		sched++;
 
		num++;
 
@@ -426,48 +426,48 @@ static void OrdersWndProc(Window *w, Win
 

	
 
		case 4: /* skip button */
 
			OrderClick_Skip(w, v);
 
			break;
 

	
 
		case 5: /* delete button */
 
			OrderClick_Delete(w, v);
 
			break;
 

	
 
		case 6: /* non stop button */
 
			OrderClick_Nonstop(w, v);
 
			break;
 
			
 

	
 
		case 7: /* goto button */
 
			OrderClick_Goto(w, v);
 
			break;
 

	
 
		case 8: /* full load button */
 
			OrderClick_FullLoad(w, v);
 
			break;
 

	
 
		case 9: /* unload button */
 
			OrderClick_Unload(w, v);
 
			break;
 

	
 
		}
 
	} break;
 
	
 

	
 
	case WE_KEYPRESS: {
 
		Vehicle *v = GetVehicle(w->window_number);
 
		uint i;
 

	
 
		for(i = 0; i < lengthof(_order_keycodes); i++) {
 
			if (e->keypress.keycode == _order_keycodes[i]) {
 
				e->keypress.cont = false;
 
				//see if the button is disabled 
 
				//see if the button is disabled
 
				if (!(HASBIT(w->disabled_state, (i + 4)))) {
 
					_order_button_proc[i](w, v);
 
				}
 
				break;
 
			}
 
		}
 
		break;
 
	}
 

	
 

	
 

	
 
	case WE_RCLICK: {
 
@@ -552,20 +552,20 @@ static const WindowDesc _other_orders_de
 
	OrdersWndProc
 
};
 

	
 
void ShowOrdersWindow(Vehicle *v)
 
{
 
	Window *w;
 
	VehicleID veh = v->index;
 

	
 
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
 
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
 

	
 
	_alloc_wnd_parent_num = veh;
 
	
 

	
 
	w = AllocateWindowDesc( (v->owner == _local_player) ? &_orders_desc : &_other_orders_desc);
 

	
 
	w->window_number = veh;
 
	w->caption_color = v->owner;
 
	w->vscroll.cap = 6;
 
	WP(w,order_d).sel = -1;
 
}
player_gui.c
Show inline comments
 
@@ -824,28 +824,28 @@ static void HighScoreWndProc(Window *w, 
 
			SetDParam(0, i + 1);
 
			DrawString(x + 40, y + 140 + (i * 55), STR_0212, 0x10);
 

	
 
			if (hs[i].company[0] != '\0') {
 
				uint16 colour = (WP(w, highscore_d).rank == (int8)i) ? 0x3 : 0x10; // draw new highscore in red
 

	
 
				DoDrawString(hs[i].company, x + 71, y + 140 + (i * 55), colour);
 
				SetDParam(0, hs[i].title);
 
				SetDParam(1, hs[i].score);
 
				DrawString(x + 71, y + 160 + (i * 55), STR_HIGHSCORE_STATS, colour);
 
			}
 
		}
 
	} break;	
 
	} break;
 

	
 
	case WE_CLICK: /* Onclick get back all hidden windows */
 
		if (_game_mode != GM_MENU && !_networking)				
 
		if (_game_mode != GM_MENU && !_networking)
 
			ShowVitalWindows();
 

	
 
		DoCommandP(0, 0, 0, NULL, CMD_PAUSE);
 
		DeleteWindow(w);
 
		break;
 
	}
 
}
 

	
 
static const Widget _highscore_widgets[] = {
 
{      WWT_PANEL, RESIZE_NONE, 16, 0, 640, 0, 480, 0x0, STR_NULL},
 
{   WIDGETS_END},
 
};
players.c
Show inline comments
 
@@ -743,47 +743,47 @@ static const StringID _endgame_performan
 
StringID EndGameGetPerformanceTitleFromValue(uint value)
 
{
 
	return _endgame_performance_titles[minu(value, 1000) >> 6];
 
}
 

	
 
/* Return true if any cheat has been used, false otherwise */
 
static CheatHasBeenUsed(void)
 
{
 
	const Cheat* cht = (Cheat*) &_cheats;
 
	const Cheat* cht_last = &cht[sizeof(_cheats) / sizeof(Cheat)];
 

	
 
	for (; cht != cht_last; cht++) {
 
		if (cht->been_used) 
 
		if (cht->been_used)
 
			return true;
 
	}
 

	
 
	return false;	
 
	return false;
 
}
 

	
 
/* Save the highscore for the player */
 
int8 SaveHighScoreValue(const Player *p)
 
{
 
	HighScore *hs = _highscore_table[_opt.diff_level];
 
	uint i;
 
	uint16 score = p->old_economy[0].performance_history;
 

	
 
	/* Exclude cheaters from the honour of being in the highscore table */
 
	if (CheatHasBeenUsed())
 
		return -1;
 

	
 
	for (i = 0; i < lengthof(_highscore_table[0]); i++) {
 
		/* You are in the TOP5. Move all values one down and save us there */
 
		if (hs[i].score <= score) {
 
			byte buf[sizeof(hs[i].company)];
 
			
 

	
 
			// move all elements one down starting from the replaced one
 
			memmove(&hs[i + 1], &hs[i], sizeof(HighScore) * (lengthof(_highscore_table[0]) - i - 1));
 
			SetDParam(0, p->president_name_1);
 
			SetDParam(1, p->president_name_2);
 
			SetDParam(2, p->name_1);
 
			SetDParam(3, p->name_2);
 
			GetString(buf, STR_HIGHSCORE_NAME); // get manager/company name string
 
			ttd_strlcpy(hs[i].company, buf, sizeof(buf));
 
			hs[i].score = score;
 
			hs[i].title = EndGameGetPerformanceTitleFromValue(score);
 
			return i;
 
		}
 
@@ -829,25 +829,25 @@ int8 SaveHighScoreValueNetwork(void)
 
			hs = &_highscore_table[LAST_HS_ITEM][i];
 
			SetDParam(0, (*p_cur)->president_name_1);
 
			SetDParam(1, (*p_cur)->president_name_2);
 
			SetDParam(2, (*p_cur)->name_1);
 
			SetDParam(3, (*p_cur)->name_2);
 
			GetString(buf, STR_HIGHSCORE_NAME); // get manager/company name string
 

	
 
			ttd_strlcpy(hs->company, buf, sizeof(buf));
 
			hs->score = (*p_cur)->old_economy[0].performance_history;
 
			hs->title = EndGameGetPerformanceTitleFromValue(hs->score);
 

	
 
			// get the ranking of the local player
 
			if ((*p_cur)->index == (int8)_local_player) 
 
			if ((*p_cur)->index == (int8)_local_player)
 
				player = i;
 

	
 
			p_cur++;
 
		}
 
	}
 

	
 
	/* Add top5 players to highscore table */
 
	return player;
 
}
 

	
 
/* Save HighScore table to file */
 
void SaveToHighScore(void)
 
@@ -865,47 +865,47 @@ void SaveToHighScore(void)
 

	
 
				fwrite(&length, sizeof(length), 1, fp); // write away string length
 
				fwrite(hs->company, length, 1, fp);
 
				fwrite(&hs->score, sizeof(hs->score), 1, fp);
 
				fwrite(&hs->title, sizeof(hs->title), 1, fp);
 
			}
 
		}
 
		fclose(fp);
 
	}
 
}
 

	
 
/* Initialize the highscore table to 0 and if any file exists, load in values */
 
void LoadFromHighScore(void) 
 
void LoadFromHighScore(void)
 
{
 
	FILE *fp = fopen(_highscore_file, "r");
 

	
 
	memset(_highscore_table, 0, sizeof(_highscore_table));
 

	
 
	if (fp != NULL) {
 
		uint i;
 
		HighScore *hs;
 

	
 
		for (i = 0; i < LAST_HS_ITEM; i++) { // don't load network highscores
 
			for (hs = _highscore_table[i]; hs != endof(_highscore_table[i]); hs++) {
 
				byte length;
 
				fread(&length, sizeof(length), 1, fp);
 

	
 
				fread(hs->company, 1, length, fp);
 
				fread(&hs->score, sizeof(hs->score), 1, fp);
 
				fread(&hs->title, sizeof(hs->title), 1, fp);
 
			}
 
		}
 
		fclose(fp);
 
	}
 
	
 

	
 
	/* Initialize end of game variable (when to show highscore chart) */
 
	 _patches.ending_date = 2051;
 
}
 

	
 
// Save/load of players
 
static const byte _player_desc[] = {
 
	SLE_VAR(Player,name_2,					SLE_UINT32),
 
	SLE_VAR(Player,name_1,					SLE_STRINGID),
 

	
 
	SLE_VAR(Player,president_name_1,SLE_UINT16),
 
	SLE_VAR(Player,president_name_2,SLE_UINT32),
 

	
spritecache.c
Show inline comments
 
@@ -759,25 +759,25 @@ static bool CheckMD5Digest(const MD5File
 
			matching_bytes++;
 
	};
 

	
 
		/* If all bytes of the MD5's match (i.e. the MD5's match)... */
 
	if (matching_bytes == 16) {
 
		return true;
 
	} else {
 
		if (warn) printf("MD5 of %s is ****INCORRECT**** - File Corrupt.\n", file.filename);
 
		return false;
 
	};
 
}
 

	
 
/* Calculate and check the MD5 hash of the supplied filename. 
 
/* Calculate and check the MD5 hash of the supplied filename.
 
 * returns true if the checksum is correct */
 
static bool FileMD5(const MD5File file, bool warn)
 
{
 
	FILE *f;
 
	char buf[MAX_PATH];
 

	
 
	md5_state_t filemd5state;
 
	int len=0;
 
	md5_byte_t buffer[1024], digest[16];
 

	
 
	// open file
 
	sprintf(buf, "%s%s", _path.data_dir, file.filename);
 
@@ -792,35 +792,35 @@ static bool FileMD5(const MD5File file, 
 
		f = fopen(buf, "rb");
 
	}
 
#endif
 

	
 
	if (f != NULL) {
 
		md5_init(&filemd5state);
 
		while ( (len = fread (buffer, 1, 1024, f)) )
 
			md5_append(&filemd5state, buffer, len);
 

	
 
		if (ferror(f))
 
			if (warn) printf ("Error Reading from %s \n", buf);
 
		fclose(f);
 
  
 

	
 
		md5_finish(&filemd5state, digest);
 
	  return CheckMD5Digest(file, digest, warn);
 
	} else { // file not found
 
		return false;
 
	}	
 
	}
 
}
 

	
 
/* Checks, if either the Windows files exist (TRG1R.GRF) or the DOS files (TRG1.GRF)
 
 * by comparing the MD5 checksums of the files. _use_dos_palette is set accordingly.
 
 * If neither are found, Windows palette is assumed. 
 
 * If neither are found, Windows palette is assumed.
 
 *
 
 * (Note: Also checks sample.cat for corruption) */
 
void CheckExternalFiles()
 
{
 
	int i;
 
	int dos=0, win=0; // count of files from this version
 

	
 
	for (i=0; i<2; i++)
 
	  if ( FileMD5(files_dos.basic[i], true) )
 
			dos++;
 
	for (i=0; i<3; i++)
 
	  if ( FileMD5(files_dos.landscape[i], true) )
table/namegen.h
Show inline comments
 
@@ -1923,25 +1923,25 @@ static const char *name_norwegian_1[] = 
 
	"Svens",
 
	"Svin",
 
	"Sylte",
 
	"Syn",
 
	"Tran",
 
	"Vass",
 
	"Ved",
 
	"Vest",
 
	"Vesle",
 
	"Vik",
 
	"Våg"
 
};
 
	
 

	
 
static const char *name_norwegian_2[] = {
 
	"aker",
 
	"anger",
 
	"bakken",
 
	"bekk",
 
	"berg",
 
	"botn",
 
	"breen",
 
	"bu",
 
	"bugen",
 
	"by",
 
	"bygd",
 
@@ -1993,25 +1993,25 @@ static const char *name_norwegian_2[] = 
 
	"sætra",
 
	"tinden",
 
	"tun",
 
	"vang",
 
	"vatn",
 
	"veid",
 
	"vik",
 
	"voll",
 
	"våg",
 
	"um",
 
	"åsen"
 
};
 
	
 

	
 
static const char *name_norwegian_real[] = {
 
	"Alta",
 
	"Arendal",
 
	"Askim",
 
	"Bergen",
 
	"Bodø",
 
	"Brevik",
 
	"Bryne",
 
	"Brønnøysund",
 
	"Drammen",
 
	"Drøbak",
 
	"Egersund",
town.h
Show inline comments
 
@@ -113,25 +113,25 @@ enum {
 
	RATING_TUNNEL_BRIDGE_DOWN_STEP = -250,
 
	RATING_TUNNEL_BRIDGE_MINIMUM = 0,
 

	
 
	RATING_INDUSTRY_DOWN_STEP = -1500,
 
	RATING_INDUSTRY_MINIMUM = RATING_MINIMUM,
 

	
 
	RATING_ROAD_DOWN_STEP = -50,
 
	RATING_ROAD_MINIMUM = -100,
 
	RATING_HOUSE_MINIMUM = RATING_MINIMUM,
 

	
 
	RATING_BRIBE_UP_STEP = 200,
 
	RATING_BRIBE_MAXIMUM = 800,
 
	RATING_BRIBE_DOWN_TO = -50 					// XXX SHOULD BE SOMETHING LOWER?	
 
	RATING_BRIBE_DOWN_TO = -50 					// XXX SHOULD BE SOMETHING LOWER?
 
};
 

	
 
bool CheckforTownRating(uint tile, uint32 flags, Town *t, byte type);
 

	
 
VARDEF Town _towns[70];
 
VARDEF uint _towns_size;
 

	
 
VARDEF uint16 *_town_sort;
 

	
 
static inline Town *GetTown(uint index)
 
{
 
	assert(index < _towns_size);
train_gui.c
Show inline comments
 
@@ -349,51 +349,51 @@ static void DrawTrainDepotWindow(Window 
 
	// draw all trains
 
	FOR_ALL_VEHICLES(v) {
 
		if (v->type == VEH_Train &&
 
				v->subtype == 0 &&
 
				v->tile == (TileIndex)tile &&
 
				v->u.rail.track == 0x80 &&
 
				--num < 0 && num >= -w->vscroll.cap) {
 

	
 
			DrawTrainImage(v, x+21, y, w->hscroll.cap, w->hscroll.pos, WP(w,traindepot_d).sel);
 
			/* Draw the train number */
 
			SetDParam(0, v->unitnumber);
 
			DrawString(x, y, (v->max_age - 366 < v->age) ? STR_00E3 : STR_00E2, 0);
 
			
 

	
 
			/*Draw the train counter */
 
			i = 0;
 
			u = v;
 
			do i++; while ( (u=u->next) != NULL);		//Determine length of train
 
			SetDParam(0, i);				//Set the counter
 
			i = (w->hscroll.cap * 29) + (x + 26);		//Calculate position of text according to window size
 
			DrawStringCentered(i, y+5, STR_TINY_BLACK, 0);	//Draw the counter
 
			
 

	
 
			/* Draw the pretty flag */
 
			DrawSprite(v->vehstatus&VS_STOPPED ? 0xC12 : 0xC13, x+15, y);
 

	
 
			y += 14;
 
		}
 
	}
 

	
 
	// draw all remaining vehicles
 
	FOR_ALL_VEHICLES(v) {
 
		if (v->type == VEH_Train &&
 
				v->subtype == 4 &&
 
				v->tile == (TileIndex)tile &&
 
				v->u.rail.track == 0x80 &&
 
				--num < 0 && num >= -w->vscroll.cap) {
 

	
 
			DrawTrainImage(v, x+50, y, w->hscroll.cap - 1, 0, WP(w,traindepot_d).sel);
 
			DrawString(x, y+2, STR_8816, 0);
 
			
 

	
 
			/*Draw the train counter */
 
			i = 0;
 
			u = v;
 
			do i++; while ( (u=u->next) != NULL);		//Determine length of train
 
			SetDParam(0, i);				//Set the counter
 
			i = (w->hscroll.cap * 29) + (x + 26);		//Calculate position of text according to window size
 
			DrawStringCentered(i, y+5, STR_TINY_BLACK, 0);	//Draw the counter
 
			y += 14;
 
		}
 
	}
 
}
 

	
window.c
Show inline comments
 
@@ -95,28 +95,28 @@ void DispatchRightClickEvent(Window *w, 
 
	e.click.pt.y = y;
 
	w->wndproc(w, &e);
 
}
 

	
 

	
 
void DispatchMouseWheelEvent(Window *w, uint widget, int wheel)
 
{
 
	const Widget *wi1 = &w->widget[widget];
 
	const Widget *wi2 = &w->widget[widget + 1];
 
	Scrollbar *sb;
 

	
 
	/* The listbox can only scroll if scrolling was done on the scrollbar itself,
 
	 * or on the listbox (and the next item is (must be) the scrollbar) 
 
	 * or on the listbox (and the next item is (must be) the scrollbar)
 
	 * XXX - should be rewritten as a widget-dependent scroller but that's
 
	 * not happening until someone rewrites the whole widget-code */
 
	if ((sb = &w->vscroll,  wi1->type == WWT_SCROLLBAR)  || (sb = &w->vscroll2, wi1->type == WWT_SCROLL2BAR)  || 
 
	if ((sb = &w->vscroll,  wi1->type == WWT_SCROLLBAR)  || (sb = &w->vscroll2, wi1->type == WWT_SCROLL2BAR)  ||
 
			(sb = &w->vscroll2, wi2->type == WWT_SCROLL2BAR) || (sb = &w->vscroll, wi2->type == WWT_SCROLLBAR) ) {
 

	
 
		if (sb->count > sb->cap) {
 
			int pos = clamp(sb->pos + wheel, 0, sb->count - sb->cap);
 
			if (pos != sb->pos) {
 
				sb->pos = pos;
 
				SetWindowDirty(w);
 
			}
 
		}
 
	}
 
}
 

	
0 comments (0 inline, 0 general)