Changeset - r12077:baf868e4baf0
[Not reviewed]
src/ai/api/ai_order.cpp
Show inline comments
 
@@ -116,24 +116,24 @@ static const Order *ResolveOrder(Vehicle
 

	
 

	
 
/* static */ bool AIOrder::AreOrderFlagsValid(TileIndex destination, AIOrderFlags order_flags)
 
{
 
	switch (::GetOrderTypeByTile(destination)) {
 
		case OT_GOTO_STATION:
 
			return ((order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_UNLOAD_FLAGS | AIOF_LOAD_FLAGS)) == 0) &&
 
			return (order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_UNLOAD_FLAGS | AIOF_LOAD_FLAGS)) == 0 &&
 
					/* Test the different mutual exclusive flags. */
 
					(((order_flags & AIOF_TRANSFER)      == 0) || ((order_flags & AIOF_UNLOAD)    == 0)) &&
 
					(((order_flags & AIOF_TRANSFER)      == 0) || ((order_flags & AIOF_NO_UNLOAD) == 0)) &&
 
					(((order_flags & AIOF_UNLOAD)        == 0) || ((order_flags & AIOF_NO_UNLOAD) == 0)) &&
 
					(((order_flags & AIOF_UNLOAD)        == 0) || ((order_flags & AIOF_NO_UNLOAD) == 0)) &&
 
					(((order_flags & AIOF_NO_UNLOAD)     == 0) || ((order_flags & AIOF_NO_LOAD)   == 0)) &&
 
					(((order_flags & AIOF_FULL_LOAD_ANY) == 0) || ((order_flags & AIOF_NO_LOAD)   == 0));
 
					((order_flags & AIOF_TRANSFER)      == 0 || (order_flags & AIOF_UNLOAD)    == 0) &&
 
					((order_flags & AIOF_TRANSFER)      == 0 || (order_flags & AIOF_NO_UNLOAD) == 0) &&
 
					((order_flags & AIOF_UNLOAD)        == 0 || (order_flags & AIOF_NO_UNLOAD) == 0) &&
 
					((order_flags & AIOF_UNLOAD)        == 0 || (order_flags & AIOF_NO_UNLOAD) == 0) &&
 
					((order_flags & AIOF_NO_UNLOAD)     == 0 || (order_flags & AIOF_NO_LOAD)   == 0) &&
 
					((order_flags & AIOF_FULL_LOAD_ANY) == 0 || (order_flags & AIOF_NO_LOAD)   == 0);
 

	
 
		case OT_GOTO_DEPOT:
 
			return ((order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_DEPOT_FLAGS)) == 0) &&
 
					(((order_flags & AIOF_SERVICE_IF_NEEDED) == 0) || ((order_flags & AIOF_STOP_IN_DEPOT) == 0));
 
			return (order_flags & ~(AIOF_NON_STOP_FLAGS | AIOF_DEPOT_FLAGS)) == 0 &&
 
					((order_flags & AIOF_SERVICE_IF_NEEDED) == 0 || (order_flags & AIOF_STOP_IN_DEPOT) == 0);
 

	
 
		case OT_GOTO_WAYPOINT: return (order_flags & ~(AIOF_NON_STOP_FLAGS)) == 0;
 
		default:               return false;
 
	}
 
}
 

	
src/ai/api/ai_town.cpp
Show inline comments
 
@@ -180,13 +180,13 @@
 
		return t->MaxTownNoise() - t->noise_reached;
 
	}
 

	
 
	int num = 0;
 
	const Station *st;
 
	FOR_ALL_STATIONS(st) {
 
		if (st->town == t && st->facilities & FACIL_AIRPORT && st->airport_type != AT_OILRIG) num++;
 
		if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport_type != AT_OILRIG) num++;
 
	}
 
	return max(0, 2 - num);
 
}
 

	
 
/* static */ AITown::RoadLayout AITown::GetRoadLayout(TownID town_id)
 
{
src/aircraft_cmd.cpp
Show inline comments
 
@@ -107,16 +107,15 @@ static StationID FindNearestHangar(const
 
	FOR_ALL_STATIONS(st) {
 
		if (st->owner != v->owner || !(st->facilities & FACIL_AIRPORT)) continue;
 

	
 
		const AirportFTAClass *afc = st->Airport();
 
		if (afc->nof_depots == 0 || (
 
					/* don't crash the plane if we know it can't land at the airport */
 
					afc->flags & AirportFTAClass::SHORT_STRIP &&
 
					AircraftVehInfo(v->engine_type)->subtype & AIR_FAST &&
 
					!_cheats.no_jetcrash.value
 
				)) {
 
					(afc->flags & AirportFTAClass::SHORT_STRIP) &&
 
					(AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
 
					!_cheats.no_jetcrash.value)) {
 
			continue;
 
		}
 

	
 
		/* v->tile can't be used here, when aircraft is flying v->tile is set to 0 */
 
		uint distance = DistanceSquare(vtile, st->airport_tile);
 
		if (distance < best || index == INVALID_STATION) {
 
@@ -134,13 +133,13 @@ static StationID FindNearestHangar(const
 
static bool HaveHangarInOrderList(Aircraft *v)
 
{
 
	const Order *order;
 

	
 
	FOR_VEHICLE_ORDERS(v, order) {
 
		const Station *st = Station::Get(order->station);
 
		if (st->owner == v->owner && st->facilities & FACIL_AIRPORT) {
 
		if (st->owner == v->owner && (st->facilities & FACIL_AIRPORT)) {
 
			/* If an airport doesn't have a hangar, skip it */
 
			if (st->Airport()->nof_depots != 0)
 
				return true;
 
		}
 
	}
 

	
 
@@ -1054,13 +1053,13 @@ static bool AircraftController(Aircraft 
 
	if (v->load_unload_time_rem != 0) v->load_unload_time_rem--;
 

	
 
	do {
 

	
 
		GetNewVehiclePosResult gp;
 

	
 
		if (dist < 4 || amd->flag & AMED_LAND) {
 
		if (dist < 4 || (amd->flag & AMED_LAND)) {
 
			/* move vehicle one pixel towards target */
 
			gp.x = (v->x_pos != (x + amd->x)) ?
 
					v->x_pos + ((x + amd->x > v->x_pos) ? 1 : -1) :
 
					v->x_pos;
 
			gp.y = (v->y_pos != (y + amd->y)) ?
 
					v->y_pos + ((y + amd->y > v->y_pos) ? 1 : -1) :
 
@@ -1331,14 +1330,14 @@ static void CrashAirplane(Aircraft *v)
 
static void MaybeCrashAirplane(Aircraft *v)
 
{
 
	Station *st = Station::Get(v->targetairport);
 

	
 
	/* FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports */
 
	uint16 prob = 0x10000 / 1500;
 
	if (st->Airport()->flags & AirportFTAClass::SHORT_STRIP &&
 
			AircraftVehInfo(v->engine_type)->subtype & AIR_FAST &&
 
	if ((st->Airport()->flags & AirportFTAClass::SHORT_STRIP) &&
 
			(AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
 
			!_cheats.no_jetcrash.value) {
 
		prob = 0x10000 / 20;
 
	}
 

	
 
	if (GB(Random(), 0, 16) > prob) return;
 

	
 
@@ -1614,13 +1613,13 @@ static void AircraftEventHandler_HeliTak
 

	
 
static void AircraftEventHandler_Flying(Aircraft *v, const AirportFTAClass *apc)
 
{
 
	Station *st = Station::Get(v->targetairport);
 

	
 
	/* runway busy or not allowed to use this airstation, circle */
 
	if (apc->flags & (v->subtype == AIR_HELICOPTER ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES) &&
 
	if ((apc->flags & (v->subtype == AIR_HELICOPTER ? AirportFTAClass::HELICOPTERS : AirportFTAClass::AIRPLANES)) &&
 
			st->airport_tile != INVALID_TILE &&
 
			(st->owner == OWNER_NONE || st->owner == v->owner)) {
 
		/* {32,FLYING,NOTHING_block,37}, {32,LANDING,N,33}, {32,HELILANDING,N,41},
 
		 * if it is an airplane, look for LANDING, for helicopter HELILANDING
 
		 * it is possible to choose from multiple landing runways, so loop until a free one is found */
 
		byte landingtype = (v->subtype == AIR_HELICOPTER) ? HELILANDING : LANDING;
src/economy.cpp
Show inline comments
 
@@ -1122,13 +1122,13 @@ void VehiclePayment(Vehicle *front_v)
 
	/* Collect delivered industries */
 
	static SmallIndustryList industry_set;
 
	industry_set.Clear();
 

	
 
	for (Vehicle *v = front_v; v != NULL; v = v->Next()) {
 
		/* No cargo to unload */
 
		if (v->cargo_cap == 0 || v->cargo.Empty() || front_v->current_order.GetUnloadType() & OUFB_NO_UNLOAD) continue;
 
		if (v->cargo_cap == 0 || v->cargo.Empty() || (front_v->current_order.GetUnloadType() & OUFB_NO_UNLOAD)) continue;
 

	
 
		/* All cargo has already been paid for, no need to pay again */
 
		if (!v->cargo.UnpaidCargo()) {
 
			SetBit(v->vehicle_flags, VF_CARGO_UNLOADING);
 
			continue;
 
		}
 
@@ -1277,13 +1277,13 @@ static void LoadUnloadVehicle(Vehicle *v
 

	
 
			/* The !accepted || v->cargo.Count == cargo_count clause is there
 
			 * to make it possible to force unload vehicles at the station where
 
			 * they were loaded, but to not force unload the vehicle when the
 
			 * station is still accepting the cargo in the vehicle. It doesn't
 
			 * accept cargo that was loaded at the same station. */
 
			if (u->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER) && (!accepted || v->cargo.Count() == cargo_count)) {
 
			if ((u->current_order.GetUnloadType() & (OUFB_UNLOAD | OUFB_TRANSFER)) && (!accepted || v->cargo.Count() == cargo_count)) {
 
				remaining = v->cargo.MoveTo(&ge->cargo, amount_unloaded);
 
				SetBit(ge->acceptance_pickup, GoodsEntry::PICKUP);
 

	
 
				result |= 2;
 
			} else if (!accepted) {
 
				/* The order changed while unloading (unset unload/transfer) or the
src/engine.cpp
Show inline comments
 
@@ -689,13 +689,13 @@ static void NewVehicleAvailable(Engine *
 
void EnginesMonthlyLoop()
 
{
 
	if (_cur_year < _year_engine_aging_stops) {
 
		Engine *e;
 
		FOR_ALL_ENGINES(e) {
 
			/* Age the vehicle */
 
			if (e->flags & ENGINE_AVAILABLE && e->age != 0xFFFF) {
 
			if ((e->flags & ENGINE_AVAILABLE) && e->age != 0xFFFF) {
 
				e->age++;
 
				CalcEngineReliability(e);
 
			}
 

	
 
			if (!(e->flags & ENGINE_AVAILABLE) && _date >= (e->intro_date + DAYS_IN_YEAR)) {
 
				/* Introduce it to all companies */
src/industry_cmd.cpp
Show inline comments
 
@@ -1196,16 +1196,16 @@ bool IsSlopeRefused(Slope current, Slope
 
	if (IsSteepSlope(current)) return true;
 
	if (current != SLOPE_FLAT) {
 
		if (IsSteepSlope(refused)) return true;
 

	
 
		Slope t = ComplementSlope(current);
 

	
 
		if (refused & SLOPE_W && (t & SLOPE_NW)) return true;
 
		if (refused & SLOPE_S && (t & SLOPE_NE)) return true;
 
		if (refused & SLOPE_E && (t & SLOPE_SW)) return true;
 
		if (refused & SLOPE_N && (t & SLOPE_SE)) return true;
 
		if ((refused & SLOPE_W) && (t & SLOPE_NW)) return true;
 
		if ((refused & SLOPE_S) && (t & SLOPE_NE)) return true;
 
		if ((refused & SLOPE_E) && (t & SLOPE_SW)) return true;
 
		if ((refused & SLOPE_N) && (t & SLOPE_SE)) return true;
 
	}
 

	
 
	return false;
 
}
 

	
 
static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, uint itspec_index, int type, bool *custom_shape_check = NULL)
 
@@ -1683,13 +1683,13 @@ CommandCost CmdBuildIndustry(TileIndex t
 
		} while (!CheckIfIndustryTilesAreFree(tile, itt[num], num, p1));
 

	
 
		ind = CreateNewIndustryHelper(tile, p1, flags, indspec, num, p2, _current_company);
 
		if (ind == NULL) return CMD_ERROR;
 
	}
 

	
 
	if (flags & DC_EXEC && _game_mode != GM_EDITOR && ind != NULL) {
 
	if ((flags & DC_EXEC) && _game_mode != GM_EDITOR && ind != NULL) {
 
		SetDParam(0, indspec->name);
 
		if (indspec->new_industry_text > STR_LAST_STRINGID) {
 
			SetDParam(1, STR_TOWN);
 
			SetDParam(2, ind->town->index);
 
		} else {
 
			SetDParam(1, ind->town->index);
 
@@ -1913,13 +1913,13 @@ static void MaybeNewIndustry()
 
 */
 
static bool CheckIndustryCloseDownProtection(IndustryType type)
 
{
 
	const IndustrySpec *indspec = GetIndustrySpec(type);
 

	
 
	/* oil wells (or the industries with that flag set) are always allowed to closedown */
 
	if (indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD && _settings_game.game_creation.landscape == LT_TEMPERATE) return false;
 
	if ((indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD) && _settings_game.game_creation.landscape == LT_TEMPERATE) return false;
 
	return (indspec->behaviour & INDUSTRYBEH_CANCLOSE_LASTINSTANCE) == 0 && GetIndustryTypeCount(type) <= 1;
 
}
 

	
 
/**
 
 * Can given cargo type be accepted or produced by the industry?
 
 * @param cargo: Cargo type
 
@@ -2171,13 +2171,13 @@ static void ChangeIndustryProduction(Ind
 
					div = 1; // Decrease production
 
				}
 
			}
 
		}
 
	}
 

	
 
	if (!callback_enabled && indspec->life_type & INDUSTRYLIFE_PROCESSING) {
 
	if (!callback_enabled && (indspec->life_type & INDUSTRYLIFE_PROCESSING)) {
 
		if ( (byte)(_cur_year - i->last_prod_year) >= 5 && Chance16(1, smooth_economy ? 180 : 2)) {
 
			closeit = true;
 
		}
 
	}
 

	
 
	/* Increase if needed */
src/network/core/host.cpp
Show inline comments
 
@@ -170,13 +170,13 @@ static void NetworkFindBroadcastIPsInter
 

	
 
		if (req->ifr_addr.sa_family == AF_INET) {
 
			struct ifreq r;
 

	
 
			strecpy(r.ifr_name, req->ifr_name, lastof(r.ifr_name));
 
			if (ioctl(sock, SIOCGIFFLAGS, &r) != -1 &&
 
					r.ifr_flags & IFF_BROADCAST &&
 
					(r.ifr_flags & IFF_BROADCAST) &&
 
					ioctl(sock, SIOCGIFBRDADDR, &r) != -1) {
 
				NetworkAddress addr(&r.ifr_broadaddr, sizeof(sockaddr));
 
				if (!broadcast->Contains(addr)) *broadcast->Append() = addr;
 
			}
 
		}
 

	
src/network/network.cpp
Show inline comments
 
@@ -459,13 +459,13 @@ void NetworkCloseClient(NetworkClientSoc
 
				SEND_COMMAND(PACKET_SERVER_ERROR_QUIT)(new_cs, cs->client_id, NETWORK_ERROR_CONNECTION_LOST);
 
			}
 
		}
 
	}
 

	
 
	/* When the client was PRE_ACTIVE, the server was in pause mode, so unpause */
 
	if (cs->status == STATUS_PRE_ACTIVE && _pause_mode & PM_PAUSED_JOIN) {
 
	if (cs->status == STATUS_PRE_ACTIVE && (_pause_mode & PM_PAUSED_JOIN)) {
 
		DoCommandP(0, PM_PAUSED_JOIN, 0, CMD_PAUSE);
 
		NetworkServerSendChat(NETWORK_ACTION_SERVER_MESSAGE, DESTTYPE_BROADCAST, 0, "", CLIENT_ID_SERVER, NETWORK_SERVER_MESSAGE_GAME_UNPAUSED_CONNECT_FAIL);
 
	}
 

	
 
	if (_network_server) {
 
		/* We just lost one client :( */
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -93,13 +93,13 @@ void CDECL NetworkAddChatMessage(TextCol
 
	for (bufp = buf; lines != 0; lines--) {
 
		ChatMessage *cmsg = &_chatmsg_list[msg_count++];
 
		strecpy(cmsg->message, bufp, lastof(cmsg->message));
 

	
 
		/* The default colour for a message is company colour. Replace this with
 
		 * white for any additional lines */
 
		cmsg->colour = (bufp == buf && colour & IS_PALETTE_COLOUR) ? colour : TC_WHITE;
 
		cmsg->colour = (bufp == buf && (colour & IS_PALETTE_COLOUR)) ? colour : TC_WHITE;
 
		cmsg->end_date = _date + duration;
 

	
 
		bufp += strlen(bufp) + 1; // jump to 'next line' in the formatted string
 
	}
 

	
 
	_chatmessage_dirty = true;
src/network/network_server.cpp
Show inline comments
 
@@ -863,14 +863,14 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT
 
		IConsolePrintF(CC_ERROR, "WARNING: %s from client %d (IP: %s).", err, ci->client_id, GetClientIP(ci));
 
		SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_NOT_EXPECTED);
 
		return;
 
	}
 

	
 

	
 
	if (GetCommandFlags(cp.cmd) & CMD_SERVER && ci->client_id != CLIENT_ID_SERVER) {
 
		IConsolePrintF(CC_ERROR, "WARNING: server only command from client %d (IP: %s), kicking...", ci->client_id, GetClientIP(ci));
 
	if ((GetCommandFlags(cp.cmd) & CMD_SERVER) && ci->client_id != CLIENT_ID_SERVER) {
 
		IConsolePrintF(CC_ERROR, "WARNING: server only command from: client %d (IP: %s), kicking...", ci->client_id, GetClientIP(ci));
 
		SEND_COMMAND(PACKET_SERVER_ERROR)(cs, NETWORK_ERROR_KICKED);
 
		return;
 
	}
 

	
 
	if ((GetCommandFlags(cp.cmd) & CMD_SPECTATOR) == 0 && !Company::IsValidID(cp.company) && ci->client_id != CLIENT_ID_SERVER) {
 
		IConsolePrintF(CC_ERROR, "WARNING: spectator issueing command from client %d (IP: %s), kicking...", ci->client_id, GetClientIP(ci));
src/order_cmd.cpp
Show inline comments
 
@@ -1199,13 +1199,13 @@ CommandCost CmdOrderRefit(TileIndex tile
 

	
 
		for (Vehicle *u = v->FirstShared(); u != NULL; u = u->NextShared()) {
 
			/* Update any possible open window of the vehicle */
 
			InvalidateVehicleOrder(u, 0);
 

	
 
			/* If the vehicle already got the current depot set as current order, then update current order as well */
 
			if (u->cur_order_index == order_number && u->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) {
 
			if (u->cur_order_index == order_number && (u->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS)) {
 
				u->current_order.SetRefit(cargo, subtype);
 
			}
 
		}
 
	}
 

	
 
	return CommandCost();
 
@@ -1376,13 +1376,13 @@ void CheckOrders(const Vehicle *v)
 
	if (_settings_client.gui.order_review_system == 0) return;
 

	
 
	/* Do nothing for crashed vehicles */
 
	if (v->vehstatus & VS_CRASHED) return;
 

	
 
	/* Do nothing for stopped vehicles if setting is '1' */
 
	if (_settings_client.gui.order_review_system == 1 && v->vehstatus & VS_STOPPED)
 
	if (_settings_client.gui.order_review_system == 1 && (v->vehstatus & VS_STOPPED))
 
		return;
 

	
 
	/* do nothing we we're not the first vehicle in a share-chain */
 
	if (v->FirstShared() != v) return;
 

	
 
	/* Only check every 20 days, so that we don't flood the message log */
src/rail_cmd.cpp
Show inline comments
 
@@ -131,13 +131,13 @@ static bool CheckTrackCombination(TileIn
 
		/* Nothing new is being built */
 
		_error_message = STR_ERROR_ALREADY_BUILT;
 
		return false;
 
	}
 

	
 
	/* Let's see if we may build this */
 
	if (flags & DC_NO_RAIL_OVERLAP || HasSignals(tile)) {
 
	if ((flags & DC_NO_RAIL_OVERLAP) || HasSignals(tile)) {
 
		/* If we are not allowed to overlap (flag is on for ai companies or we have
 
		 * signals on the tile), check that */
 
		return future == TRACK_BIT_HORZ || future == TRACK_BIT_VERT;
 
	} else {
 
		/* Normally, we may overlap and any combination is valid */
 
		return true;
src/road_cmd.cpp
Show inline comments
 
@@ -134,16 +134,16 @@ bool CheckAllowRemoveRoad(TileIndex tile
 
	 * removal allowance depends on difficulty setting */
 
	if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return false;
 

	
 
	/* Get a bitmask of which neighbouring roads has a tile */
 
	RoadBits n = ROAD_NONE;
 
	RoadBits present = GetAnyRoadBits(tile, rt);
 
	if (present & ROAD_NE && GetAnyRoadBits(TILE_ADDXY(tile, -1,  0), rt) & ROAD_SW) n |= ROAD_NE;
 
	if (present & ROAD_SE && GetAnyRoadBits(TILE_ADDXY(tile,  0,  1), rt) & ROAD_NW) n |= ROAD_SE;
 
	if (present & ROAD_SW && GetAnyRoadBits(TILE_ADDXY(tile,  1,  0), rt) & ROAD_NE) n |= ROAD_SW;
 
	if (present & ROAD_NW && GetAnyRoadBits(TILE_ADDXY(tile,  0, -1), rt) & ROAD_SE) n |= ROAD_NW;
 
	if ((present & ROAD_NE) && (GetAnyRoadBits(TILE_ADDXY(tile, -1,  0), rt) & ROAD_SW)) n |= ROAD_NE;
 
	if ((present & ROAD_SE) && (GetAnyRoadBits(TILE_ADDXY(tile,  0,  1), rt) & ROAD_NW)) n |= ROAD_SE;
 
	if ((present & ROAD_SW) && (GetAnyRoadBits(TILE_ADDXY(tile,  1,  0), rt) & ROAD_NE)) n |= ROAD_SW;
 
	if ((present & ROAD_NW) && (GetAnyRoadBits(TILE_ADDXY(tile,  0, -1), rt) & ROAD_SE)) n |= ROAD_NW;
 

	
 
	int rating_decrease = RATING_ROAD_DOWN_STEP_EDGE;
 
	/* If 0 or 1 bits are set in n, or if no bits that match the bits to remove,
 
	 * then allow it */
 
	if (KillFirstBit(n) != ROAD_NONE && (n & remove) != ROAD_NONE) {
 
		/* you can remove all kind of roads with extra dynamite */
 
@@ -491,13 +491,13 @@ CommandCost CmdBuildRoad(TileIndex tile,
 
						if (toggle_drd != DRD_NONE && rt != ROADTYPE_TRAM && IsRoadOwner(tile, ROADTYPE_ROAD, _current_company)) {
 
							if (crossing) return_cmd_error(STR_ERROR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION);
 

	
 
							if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 

	
 
							/* Ignore half built tiles */
 
							if (flags & DC_EXEC && rt != ROADTYPE_TRAM && IsStraightRoad(existing)) {
 
							if ((flags & DC_EXEC) && rt != ROADTYPE_TRAM && IsStraightRoad(existing)) {
 
								SetDisallowedRoadDirections(tile, GetDisallowedRoadDirections(tile) ^ toggle_drd);
 
								MarkTileDirtyByTile(tile);
 
							}
 
							return CommandCost();
 
						}
 
						return_cmd_error(STR_ERROR_ALREADY_BUILT);
src/roadveh_cmd.cpp
Show inline comments
 
@@ -437,14 +437,14 @@ CommandCost CmdSendRoadVehToDepot(TileIn
 
 */
 
CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	RoadVehicle *v = RoadVehicle::GetIfValid(p1);
 
	if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
 

	
 
	if (v->vehstatus & VS_STOPPED ||
 
			v->vehstatus & VS_CRASHED ||
 
	if ((v->vehstatus & VS_STOPPED) ||
 
			(v->vehstatus & VS_CRASHED) ||
 
			v->breakdown_ctr != 0 ||
 
			v->overtaking != 0 ||
 
			v->state == RVSB_WORMHOLE ||
 
			v->IsInDepot() ||
 
			v->cur_speed < 5) {
 
		return CMD_ERROR;
 
@@ -932,13 +932,13 @@ static void RoadVehCheckOvertake(RoadVeh
 
	od.tile = v->tile;
 
	if (CheckRoadBlockedForOvertaking(&od)) return;
 

	
 
	od.tile = v->tile + TileOffsByDiagDir(DirToDiagDir(v->direction));
 
	if (CheckRoadBlockedForOvertaking(&od)) return;
 

	
 
	if (od.u->cur_speed == 0 || od.u->vehstatus& VS_STOPPED) {
 
	if (od.u->cur_speed == 0 || (od.u->vehstatus & VS_STOPPED)) {
 
		v->overtaking_ctr = 0x11;
 
		v->overtaking = 0x10;
 
	} else {
 
//		if (CheckRoadBlockedForOvertaking(&od)) return;
 
		v->overtaking_ctr = 0;
 
		v->overtaking = 0x10;
 
@@ -1129,13 +1129,13 @@ static Trackdir RoadFindPathToDest(RoadV
 
					dir = GetRoadStopDir(desttile);
 
do_it:;
 
					/* When we are heading for a depot or station, we just
 
					 * pretend we are heading for the tile in front, we'll
 
					 * see from there */
 
					desttile += TileOffsByDiagDir(dir);
 
					if (desttile == tile && trackdirs & _road_exit_dir_to_incoming_trackdirs[dir]) {
 
					if (desttile == tile && (trackdirs & _road_exit_dir_to_incoming_trackdirs[dir])) {
 
						/* If we are already in front of the
 
						 * station/depot and we can get in from here,
 
						 * we enter */
 
						return_track(FindFirstBit2x64(trackdirs & _road_exit_dir_to_incoming_trackdirs[dir]));
 
					}
 
				}
src/saveload/oldloader.cpp
Show inline comments
 
@@ -102,14 +102,14 @@ byte ReadByte(LoadgameState *ls)
 
 */
 
bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks)
 
{
 
	byte *base_ptr = (byte*)base;
 

	
 
	for (const OldChunks *chunk = chunks; chunk->type != OC_END; chunk++) {
 
		if (((chunk->type & OC_TTD) && (_savegame_type == SGT_TTO)) ||
 
				((chunk->type & OC_TTO) && (_savegame_type != SGT_TTO))) {
 
		if (((chunk->type & OC_TTD) && _savegame_type == SGT_TTO) ||
 
				((chunk->type & OC_TTO) && _savegame_type != SGT_TTO)) {
 
			/* TTD(P)-only chunk, but TTO savegame || TTO-only chunk, but TTD/TTDP savegame */
 
			continue;
 
		}
 

	
 
		byte *ptr = (byte*)chunk->ptr;
 
		if (chunk->type & OC_DEREFERENCE_POINTER) ptr = *(byte**)ptr;
src/saveload/vehicle_sl.cpp
Show inline comments
 
@@ -162,13 +162,13 @@ void UpdateOldAircraft()
 
	Aircraft *a;
 
	FOR_ALL_AIRCRAFT(a) {
 
		/* airplane has another vehicle with subtype 4 (shadow), helicopter also has 3 (rotor)
 
		 * skip those */
 
		if (IsNormalAircraft(a)) {
 
			/* airplane in terminal stopped doesn't hurt anyone, so goto next */
 
			if (a->vehstatus & VS_STOPPED && a->state == 0) {
 
			if ((a->vehstatus & VS_STOPPED) && a->state == 0) {
 
				a->state = HANGAR;
 
				continue;
 
			}
 

	
 
			AircraftLeaveHangar(a); // make airplane visible if it was in a depot for example
 
			a->vehstatus &= ~VS_STOPPED; // make airplane moving
src/signal.cpp
Show inline comments
 
@@ -338,13 +338,13 @@ static SigFlags ExploreSegment(Owner own
 

	
 
						continue;
 
					}
 
				}
 

	
 
				for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { // test all possible exit directions
 
					if (dir != enterdir && tracks & _enterdir_to_trackbits[dir]) { // any track incidating?
 
					if (dir != enterdir && (tracks & _enterdir_to_trackbits[dir])) { // any track incidating?
 
						TileIndex newtile = tile + TileOffsByDiagDir(dir);  // new tile to check
 
						DiagDirection newdir = ReverseDiagDir(dir); // direction we are entering from
 
						if (!MaybeAddToTodoSet(newtile, newdir, tile, dir)) return flags | SF_FULL;
 
					}
 
				}
 

	
 
@@ -422,21 +422,21 @@ static void UpdateSignalsAroundSegment(S
 
			/* train in the segment */
 
			newstate = SIGNAL_STATE_RED;
 
		} else {
 
			/* is it a bidir combo? - then do not count its other signal direction as exit */
 
			if (sig == SIGTYPE_COMBO && HasSignalOnTrackdir(tile, ReverseTrackdir(trackdir))) {
 
				/* at least one more exit */
 
				if (flags & SF_EXIT2 &&
 
				if ((flags & SF_EXIT2) &&
 
						/* no green exit */
 
						(!(flags & SF_GREEN) ||
 
						/* only one green exit, and it is this one - so all other exits are red */
 
						(!(flags & SF_GREEN2) && GetSignalStateByTrackdir(tile, ReverseTrackdir(trackdir)) == SIGNAL_STATE_GREEN))) {
 
					newstate = SIGNAL_STATE_RED;
 
				}
 
			} else { // entry, at least one exit, no green exit
 
				if (IsPresignalEntry(tile, TrackdirToTrack(trackdir)) && flags & SF_EXIT && !(flags & SF_GREEN)) newstate = SIGNAL_STATE_RED;
 
				if (IsPresignalEntry(tile, TrackdirToTrack(trackdir)) && (flags & SF_EXIT) && !(flags & SF_GREEN)) newstate = SIGNAL_STATE_RED;
 
			}
 
		}
 

	
 
		/* only when the state changes */
 
		if (newstate != GetSignalStateByTrackdir(tile, trackdir)) {
 
			if (IsPresignalExit(tile, TrackdirToTrack(trackdir))) {
 
@@ -532,13 +532,13 @@ static SigSegState UpdateSignalsInBuffer
 

	
 
		if (first) {
 
			first = false;
 
			/* SIGSEG_FREE is set by default */
 
			if (flags & SF_PBS) {
 
				state = SIGSEG_PBS;
 
			} else if (flags & SF_TRAIN || (flags & SF_EXIT && !(flags & SF_GREEN)) || flags & SF_FULL) {
 
			} else if ((flags & SF_TRAIN) || ((flags & SF_EXIT) && !(flags & SF_GREEN)) || (flags & SF_FULL)) {
 
				state = SIGSEG_FULL;
 
			}
 
		}
 

	
 
		/* do not do anything when some buffer was full */
 
		if (flags & SF_FULL) {
src/station_cmd.cpp
Show inline comments
 
@@ -380,13 +380,13 @@ static Station *GetClosestDeletedStation
 
 */
 
static void UpdateStationVirtCoord(Station *st)
 
{
 
	Point pt = RemapCoords2(TileX(st->xy) * TILE_SIZE, TileY(st->xy) * TILE_SIZE);
 

	
 
	pt.y -= 32;
 
	if (st->facilities & FACIL_AIRPORT && st->airport_type == AT_OILRIG) pt.y -= 16;
 
	if ((st->facilities & FACIL_AIRPORT) && st->airport_type == AT_OILRIG) pt.y -= 16;
 

	
 
	SetDParam(0, st->index);
 
	SetDParam(1, st->facilities);
 
	UpdateViewportSignPos(&st->sign, pt.x, pt.y, STR_STATION_SIGN);
 
}
 

	
 
@@ -1846,13 +1846,13 @@ CommandCost CmdBuildAirport(TileIndex ti
 
			authority_refuse_message = STR_LOCAL_AUTHORITY_REFUSES_NOISE;
 
		}
 
	} else {
 
		uint num = 0;
 
		const Station *st;
 
		FOR_ALL_STATIONS(st) {
 
			if (st->town == t && st->facilities & FACIL_AIRPORT && st->airport_type != AT_OILRIG) num++;
 
			if (st->town == t && (st->facilities & FACIL_AIRPORT) && st->airport_type != AT_OILRIG) num++;
 
		}
 
		if (num >= 2) {
 
			authority_refuse_message = STR_ERROR_LOCAL_AUTHORITY_REFUSES_AIRPORT;
 
		}
 
	}
 

	
src/town_cmd.cpp
Show inline comments
 
@@ -484,13 +484,13 @@ static void TileLoop_Town(TileIndex tile
 
			t->new_act_mail += MoveGoodsToStation(tile, 1, 1, CT_MAIL, amt);
 
		}
 
	}
 

	
 
	_current_company = OWNER_TOWN;
 

	
 
	if (hs->building_flags & BUILDING_HAS_1_TILE &&
 
	if ((hs->building_flags & BUILDING_HAS_1_TILE) &&
 
			HasBit(t->flags12, TOWN_IS_FUNDED) &&
 
			CanDeleteHouse(tile) &&
 
			GetHouseAge(tile) >= hs->minimum_life &&
 
			--t->time_until_rebuild == 0) {
 
		t->time_until_rebuild = GB(r, 16, 8) + 192;
 

	
src/train_cmd.cpp
Show inline comments
 
@@ -1540,13 +1540,13 @@ CommandCost CmdSellRailWagon(TileIndex t
 
					first = UnlinkWagon(v, first);
 
					delete v;
 
				}
 
			}
 

	
 
			/* 3. If it is still a valid train after selling, update its acceleration and cached values */
 
			if (flags & DC_EXEC && first != NULL) {
 
			if ((flags & DC_EXEC) && first != NULL) {
 
				NormaliseTrainConsist(first);
 
				TrainConsistChanged(first, false);
 
				UpdateTrainGroupID(first);
 
				InvalidateWindow(WC_VEHICLE_REFIT, first->index);
 
			}
 
		} break;
 
@@ -1702,13 +1702,13 @@ static Vehicle *TrainOnTileEnum(Vehicle 
 
 * @param data tile with crossing we are testing
 
 * @return v if it is approaching a crossing, NULL otherwise
 
 */
 
static Vehicle *TrainApproachingCrossingEnum(Vehicle *v, void *data)
 
{
 
	/* not a train || not front engine || crashed */
 
	if (v->type != VEH_TRAIN || !IsFrontEngine(v) || v->vehstatus & VS_CRASHED) return NULL;
 
	if (v->type != VEH_TRAIN || !IsFrontEngine(v) || (v->vehstatus & VS_CRASHED)) return NULL;
 

	
 
	TileIndex tile = *(TileIndex*)data;
 

	
 
	if (TrainApproachingCrossingTile((Train *)v) != tile) return NULL;
 

	
 
	return v;
 
@@ -1971,13 +1971,13 @@ CommandCost CmdReverseTrainDirection(Til
 
			ToggleBit(v->flags, VRF_REVERSE_DIRECTION);
 
			InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
			InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		}
 
	} else {
 
		/* turn the whole train around */
 
		if (v->vehstatus & VS_CRASHED || v->breakdown_ctr != 0) return CMD_ERROR;
 
		if ((v->vehstatus & VS_CRASHED) || v->breakdown_ctr != 0) return CMD_ERROR;
 

	
 
		if (flags & DC_EXEC) {
 
			/* Properly leave the station if we are loading and won't be loading anymore */
 
			if (v->current_order.IsType(OT_LOADING)) {
 
				const Vehicle *last = v;
 
				while (last->Next() != NULL) last = last->Next();
 
@@ -2254,13 +2254,13 @@ static const int8 _vehicle_smoke_pos[8] 
 
};
 

	
 
static void HandleLocomotiveSmokeCloud(const Train *v)
 
{
 
	bool sound = false;
 

	
 
	if (v->vehstatus & VS_TRAIN_SLOWING || v->load_unload_time_rem != 0 || v->cur_speed < 2) {
 
	if ((v->vehstatus & VS_TRAIN_SLOWING) || v->load_unload_time_rem != 0 || v->cur_speed < 2) {
 
		return;
 
	}
 

	
 
	const Train *u = v;
 

	
 
	do {
 
@@ -2350,13 +2350,13 @@ void Train::PlayLeaveStationSound() cons
 
static void CheckNextTrainTile(Train *v)
 
{
 
	/* Don't do any look-ahead if path_backoff_interval is 255. */
 
	if (_settings_game.pf.path_backoff_interval == 255) return;
 

	
 
	/* Exit if we reached our destination depot or are inside a depot. */
 
	if ((v->tile == v->dest_tile && v->current_order.IsType(OT_GOTO_DEPOT)) || v->track & TRACK_BIT_DEPOT) return;
 
	if ((v->tile == v->dest_tile && v->current_order.IsType(OT_GOTO_DEPOT)) || (v->track & TRACK_BIT_DEPOT)) return;
 
	/* Exit if we are on a station tile and are going to stop. */
 
	if (IsRailwayStationTile(v->tile) && v->current_order.ShouldStopAtStation(v, GetStationIndex(v->tile))) return;
 
	/* Exit if the current order doesn't have a destination, but the train has orders. */
 
	if ((v->current_order.IsType(OT_NOTHING) || v->current_order.IsType(OT_LEAVESTATION) || v->current_order.IsType(OT_LOADING)) && v->GetNumOrders() > 0) return;
 

	
 
	Trackdir td = v->GetVehicleTrackdir();
 
@@ -3302,13 +3302,13 @@ void Train::MarkDirty()
 
 * @return distance to drive.
 
 */
 
static int UpdateTrainSpeed(Train *v)
 
{
 
	uint accel;
 

	
 
	if (v->vehstatus & VS_STOPPED || HasBit(v->flags, VRF_REVERSING) || HasBit(v->flags, VRF_TRAIN_STUCK)) {
 
	if ((v->vehstatus & VS_STOPPED) || HasBit(v->flags, VRF_REVERSING) || HasBit(v->flags, VRF_TRAIN_STUCK)) {
 
		switch (_settings_game.vehicle.train_acceleration_model) {
 
			default: NOT_REACHED();
 
			case TAM_ORIGINAL:  accel = v->acceleration * -4; break;
 
			case TAM_REALISTIC: accel = GetTrainAcceleration(v, AM_BRAKE); break;
 
		}
 
	} else {
 
@@ -3701,13 +3701,13 @@ static void TrainController(Train *v, Ve
 
					/* Currently the locomotive is active. Determine which one of the
 
					 * available tracks to choose */
 
					chosen_track = TrackToTrackBits(ChooseTrainTrack(v, gp.new_tile, enterdir, bits, false, NULL, true));
 
					assert(chosen_track & (bits | GetReservedTrackbits(gp.new_tile)));
 

	
 
					/* Check if it's a red signal and that force proceed is not clicked. */
 
					if (red_signals & chosen_track && v->force_proceed == 0) {
 
					if ((red_signals & chosen_track) && v->force_proceed == 0) {
 
						/* In front of a red signal */
 
						Trackdir i = FindFirstTrackdir(trackdirbits);
 

	
 
						/* Don't handle stuck trains here. */
 
						if (HasBit(v->flags, VRF_TRAIN_STUCK)) return;
 

	
 
@@ -4282,13 +4282,13 @@ static bool TrainLocoHandler(Train *v, b
 

	
 
	if (HasBit(v->flags, VRF_REVERSING) && v->cur_speed == 0) {
 
		ReverseTrainDirection(v);
 
	}
 

	
 
	/* exit if train is stopped */
 
	if (v->vehstatus & VS_STOPPED && v->cur_speed == 0) return true;
 
	if ((v->vehstatus & VS_STOPPED) && v->cur_speed == 0) return true;
 

	
 
	bool valid_order = !v->current_order.IsType(OT_NOTHING) && v->current_order.GetType() != OT_CONDITIONAL;
 
	if (ProcessOrders(v) && CheckReverseTrain(v)) {
 
		v->load_unload_time_rem = 0;
 
		v->cur_speed = 0;
 
		v->subspeed = 0;
 
@@ -4347,13 +4347,13 @@ static bool TrainLocoHandler(Train *v, b
 
		return true;
 
	}
 

	
 
	int j = UpdateTrainSpeed(v);
 

	
 
	/* we need to invalidate the widget if we are stopping from 'Stopping 0 km/h' to 'Stopped' */
 
	if (v->cur_speed == 0 && v->tcache.last_speed == 0 && v->vehstatus & VS_STOPPED) {
 
	if (v->cur_speed == 0 && v->tcache.last_speed == 0 && (v->vehstatus & VS_STOPPED)) {
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
 
	}
 

	
 
	int adv_spd = (v->direction & 1) ? 192 : 256;
 
	if (j < adv_spd) {
 
		/* if the vehicle has speed 0, update the last_speed field. */
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -429,13 +429,13 @@ not_valid_below:;
 
		if (flags & DC_EXEC) {
 
			SetBridgeMiddle(tile, direction);
 
			MarkTileDirtyByTile(tile);
 
		}
 
	}
 

	
 
	if (flags & DC_EXEC && transport_type == TRANSPORT_RAIL) {
 
	if ((flags & DC_EXEC) && transport_type == TRANSPORT_RAIL) {
 
		Track track = AxisToTrack(direction);
 
		AddSideToSignalBuffer(tile_start, INVALID_DIAGDIR, _current_company);
 
		YapfNotifyTrackLayoutChange(tile_start, track);
 
	}
 

	
 
	/* for human player that builds the bridge he gets a selection to choose from bridges (DC_QUERY_COST)
src/unmovable_cmd.cpp
Show inline comments
 
@@ -270,13 +270,13 @@ static CommandCost ClearTile_Unmovable(T
 

	
 
	if (IsOwnedLand(tile)) {
 
		return DoCommand(tile, 0, 0, flags, CMD_SELL_LAND_AREA);
 
	}
 

	
 
	/* checks if you're allowed to remove unmovable things */
 
	if (_game_mode != GM_EDITOR && _current_company != OWNER_WATER && ((flags & DC_AUTO || !_cheats.magic_bulldozer.value)) )
 
	if (_game_mode != GM_EDITOR && _current_company != OWNER_WATER && ((flags & DC_AUTO) || !_cheats.magic_bulldozer.value) )
 
		return_cmd_error(flags & DC_AUTO ? STR_ERROR_OBJECT_IN_THE_WAY : INVALID_STRING_ID);
 

	
 
	if (IsStatue(tile)) {
 
		if (flags & DC_AUTO) return_cmd_error(STR_ERROR_OBJECT_IN_THE_WAY);
 

	
 
		TownID town = GetStatueTownID(tile);
src/vehicle.cpp
Show inline comments
 
@@ -861,13 +861,13 @@ void CheckVehicleBreakdown(Vehicle *v)
 
	int rel, rel_old;
 

	
 
	/* decrease reliability */
 
	v->reliability = rel = max((rel_old = v->reliability) - v->reliability_spd_dec, 0);
 
	if ((rel_old >> 8) != (rel >> 8)) InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 

	
 
	if (v->breakdown_ctr != 0 || v->vehstatus & VS_STOPPED ||
 
	if (v->breakdown_ctr != 0 || (v->vehstatus & VS_STOPPED) ||
 
			_settings_game.difficulty.vehicle_breakdowns < 1 ||
 
			v->cur_speed < 5 || _game_mode == GM_MENU) {
 
		return;
 
	}
 

	
 
	uint32 r = Random();
src/vehicle_cmd.cpp
Show inline comments
 
@@ -64,13 +64,13 @@ CommandCost CmdStartStopVehicle(TileInde
 

	
 
	Vehicle *v = Vehicle::GetIfValid(p1);
 
	if (v == NULL || !CheckOwnership(v->owner) || !v->IsPrimaryVehicle()) return CMD_ERROR;
 

	
 
	switch (v->type) {
 
		case VEH_TRAIN:
 
			if (v->vehstatus & VS_STOPPED && ((Train *)v)->tcache.cached_power == 0) return_cmd_error(STR_TRAIN_START_NO_CATENARY);
 
			if ((v->vehstatus & VS_STOPPED) && ((Train *)v)->tcache.cached_power == 0) return_cmd_error(STR_TRAIN_START_NO_CATENARY);
 
			break;
 

	
 
		case VEH_SHIP:
 
		case VEH_ROAD:
 
			break;
 

	
 
@@ -402,13 +402,13 @@ CommandCost CmdCloneVehicle(TileIndex ti
 
				w->service_interval = v->service_interval;
 
			}
 
			w_rear = w; // trains needs to know the last car in the train, so they can add more in next loop
 
		}
 
	} while (v->type == VEH_TRAIN && (v = GetNextVehicle((Train *)v)) != NULL);
 

	
 
	if (flags & DC_EXEC && v_front->type == VEH_TRAIN) {
 
	if ((flags & DC_EXEC) && v_front->type == VEH_TRAIN) {
 
		/* for trains this needs to be the front engine due to the callback function */
 
		_new_vehicle_id = w_front->index;
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		/* Cloned vehicles belong to the same group */
src/video/allegro_v.cpp
Show inline comments
 
@@ -324,13 +324,13 @@ static void PollEvent()
 
		uint diff = prev_button_state ^ mouse_b;
 
		while (diff != 0) {
 
			int button = FindFirstBit(diff);
 
			ClrBit(diff, button);
 
			if (HasBit(mouse_b, button)) {
 
				/* Pressed mouse button */
 
				if (_rightclick_emulate && key_shifts & KB_CTRL_FLAG) {
 
				if (_rightclick_emulate && (key_shifts & KB_CTRL_FLAG)) {
 
					button = RIGHT_BUTTON;
 
					ClrBit(diff, RIGHT_BUTTON);
 
				}
 
				switch (button) {
 
					case LEFT_BUTTON:
 
						_left_button_down = true;
 
@@ -388,13 +388,13 @@ static void PollEvent()
 
		mouse_action = true;
 
	}
 

	
 
	if (mouse_action) HandleMouseEvents();
 

	
 
	poll_keyboard();
 
	if (key_shifts & KB_ALT_FLAG && (key[KEY_ENTER] || key[KEY_F])) {
 
	if ((key_shifts & KB_ALT_FLAG) && (key[KEY_ENTER] || key[KEY_F])) {
 
		ToggleFullScreen(!_fullscreen);
 
	} else if (keypressed()) {
 
		HandleKeypress(ConvertAllegroKeyIntoMy());
 
	}
 
}
 

	
src/widget.cpp
Show inline comments
 
@@ -138,18 +138,16 @@ void ScrollbarClickHandler(Window *w, co
 
 * @param  x The Window client X coordinate
 
 * @param  y The Window client y coordinate
 
 * @return A widget index, or -1 if no widget was found.
 
 */
 
int GetWidgetFromPos(const Window *w, int x, int y)
 
{
 
	uint index;
 
	int found_index = -1;
 

	
 
	/* Go through the widgets and check if we find the widget that the coordinate is
 
	 * inside. */
 
	for (index = 0; index < w->widget_count; index++) {
 
	/* Go through the widgets and check if we find the widget that the coordinate is inside. */
 
	for (uint index = 0; index < w->widget_count; index++) {
 
		const Widget *wi = &w->widget[index];
 
		if (wi->type == WWT_EMPTY || wi->type == WWT_FRAME) continue;
 

	
 
		if (x >= wi->left && x <= wi->right && y >= wi->top &&  y <= wi->bottom &&
 
				!w->IsWidgetHidden(index)) {
 
			found_index = index;
src/window.cpp
Show inline comments
 
@@ -323,21 +323,21 @@ static void DispatchLeftClickEvent(Windo
 
			if (widget_type == WWT_CAPTION) { // 'Title bar'
 
				StartWindowDrag(w);
 
				return;
 
			}
 
		}
 

	
 
		if (w->desc_flags & WDF_RESIZABLE && widget_type == WWT_RESIZEBOX) {
 
		if ((w->desc_flags & WDF_RESIZABLE) && widget_type == WWT_RESIZEBOX) {
 
			/* When the resize widget is on the left size of the window
 
			 * we assume that that button is used to resize to the left. */
 
			StartWindowSizing(w, wi->left < (w->width / 2));
 
			w->InvalidateWidget(widget_index);
 
			return;
 
		}
 

	
 
		if (w->desc_flags & WDF_STICKY_BUTTON && widget_type == WWT_STICKYBOX) {
 
		if ((w->desc_flags & WDF_STICKY_BUTTON) && widget_type == WWT_STICKYBOX) {
 
			w->flags4 ^= WF_STICKY;
 
			w->InvalidateWidget(widget_index);
 
			return;
 
		}
 
	}
 

	
 
@@ -1237,13 +1237,13 @@ static void DecreaseWindowCounters()
 
			w->SetDirty();
 
		}
 
		w->OnMouseLoop();
 
	}
 

	
 
	FOR_ALL_WINDOWS_FROM_FRONT(w) {
 
		if (w->flags4 & WF_TIMEOUT_MASK && !(--w->flags4 & WF_TIMEOUT_MASK)) {
 
		if ((w->flags4 & WF_TIMEOUT_MASK) && !(--w->flags4 & WF_TIMEOUT_MASK)) {
 
			w->OnTimeout();
 
			if (w->desc_flags & WDF_UNCLICK_BUTTONS) w->RaiseButtons();
 
		}
 
	}
 
}
 

	
 
@@ -1548,13 +1548,13 @@ static bool HandleWindowDragging()
 

	
 
			/* Window already on size */
 
			if (x == 0 && y == 0) return false;
 

	
 
			/* Now find the new cursor pos.. this is NOT _cursor, because we move in steps. */
 
			_drag_delta.y += y;
 
			if (w->flags4 & WF_SIZING_LEFT && x != 0) {
 
			if ((w->flags4 & WF_SIZING_LEFT) && x != 0) {
 
				_drag_delta.x -= x; // x > 0 -> window gets longer -> left-edge moves to left -> subtract x to get new position.
 
				w->SetDirty();
 
				w->left -= x;  // If dragging left edge, move left window edge in opposite direction by the same amount.
 
				/* ResizeWindow() below ensures marking new position as dirty. */
 
			} else {
 
				_drag_delta.x += x;
0 comments (0 inline, 0 general)