File diff r18763:938cba34d55a → r18764:f6e8611401f3
src/roadveh_cmd.cpp
Show inline comments
 
@@ -18,24 +18,25 @@
 
#include "company_func.h"
 
#include "vehicle_gui.h"
 
#include "articulated_vehicles.h"
 
#include "newgrf_sound.h"
 
#include "pathfinder/yapf/yapf.h"
 
#include "strings_func.h"
 
#include "tunnelbridge_map.h"
 
#include "window_func.h"
 
#include "date_func.h"
 
#include "vehicle_func.h"
 
#include "sound_func.h"
 
#include "ai/ai.hpp"
 
#include "game/game.hpp"
 
#include "depot_map.h"
 
#include "effectvehicle_func.h"
 
#include "roadstop_base.h"
 
#include "spritecache.h"
 
#include "core/random_func.hpp"
 
#include "company_base.h"
 
#include "core/backup_type.hpp"
 
#include "newgrf.h"
 
#include "zoom_func.h"
 

	
 
#include "table/strings.h"
 

	
 
@@ -512,24 +513,25 @@ uint RoadVehicle::Crash(bool flooded)
 
			RoadStop::GetByTile(this->tile, GetRoadStopType(this->tile))->Leave(this);
 
		}
 
	}
 
	this->crashed_ctr = flooded ? 2000 : 1; // max 2220, disappear pretty fast when flooded
 
	return pass;
 
}
 

	
 
static void RoadVehCrash(RoadVehicle *v)
 
{
 
	uint pass = v->Crash();
 

	
 
	AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING));
 
	Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING));
 

	
 
	SetDParam(0, pass);
 
	AddVehicleNewsItem(
 
		(pass == 1) ?
 
			STR_NEWS_ROAD_VEHICLE_CRASH_DRIVER : STR_NEWS_ROAD_VEHICLE_CRASH,
 
		NS_ACCIDENT,
 
		v->index
 
	);
 

	
 
	ModifyStationRatingAround(v->tile, v->owner, -160, 22);
 
	SndPlayVehicleFx(SND_12_EXPLOSION, v);
 
}
 
@@ -660,37 +662,39 @@ static void RoadVehArrivesAt(const RoadV
 
	if (v->IsBus()) {
 
		/* Check if station was ever visited before */
 
		if (!(st->had_vehicle_of_type & HVOT_BUS)) {
 
			st->had_vehicle_of_type |= HVOT_BUS;
 
			SetDParam(0, st->index);
 
			AddVehicleNewsItem(
 
				v->roadtype == ROADTYPE_ROAD ? STR_NEWS_FIRST_BUS_ARRIVAL : STR_NEWS_FIRST_PASSENGER_TRAM_ARRIVAL,
 
				(v->owner == _local_company) ? NS_ARRIVAL_COMPANY : NS_ARRIVAL_OTHER,
 
				v->index,
 
				st->index
 
			);
 
			AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
 
			Game::NewEvent(new ScriptEventStationFirstVehicle(st->index, v->index));
 
		}
 
	} else {
 
		/* Check if station was ever visited before */
 
		if (!(st->had_vehicle_of_type & HVOT_TRUCK)) {
 
			st->had_vehicle_of_type |= HVOT_TRUCK;
 
			SetDParam(0, st->index);
 
			AddVehicleNewsItem(
 
				v->roadtype == ROADTYPE_ROAD ? STR_NEWS_FIRST_TRUCK_ARRIVAL : STR_NEWS_FIRST_CARGO_TRAM_ARRIVAL,
 
				(v->owner == _local_company) ? NS_ARRIVAL_COMPANY : NS_ARRIVAL_OTHER,
 
				v->index,
 
				st->index
 
			);
 
			AI::NewEvent(v->owner, new ScriptEventStationFirstVehicle(st->index, v->index));
 
			Game::NewEvent(new ScriptEventStationFirstVehicle(st->index, v->index));
 
		}
 
	}
 
}
 

	
 
/**
 
 * This function looks at the vehicle and updates its speed (cur_speed
 
 * and subspeed) variables. Furthermore, it returns the distance that
 
 * the vehicle can drive this tick. #Vehicle::GetAdvanceDistance() determines
 
 * the distance to drive before moving a step on the map.
 
 * @return distance to drive.
 
 */
 
int RoadVehicle::UpdateSpeed()