Changeset - r27231:22301bb798c3
[Not reviewed]
master
0 7 0
Peter Nelson - 19 months ago 2023-04-23 20:22:17
peter1138@openttd.org
Cleanup: Remove unnecessary VehicleRandomBits()

Simple Random() assignment to byte does the same.
7 files changed with 10 insertions and 19 deletions:
0 comments (0 inline, 0 general)
src/aircraft_cmd.cpp
Show inline comments
 
@@ -344,8 +344,8 @@ CommandCost CmdBuildAircraft(DoCommandFl
 
		v->sprite_cache.sprite_seq.Set(SPR_IMG_QUERY);
 
		u->sprite_cache.sprite_seq.Set(SPR_IMG_QUERY);
 

	
 
		v->random_bits = VehicleRandomBits();
 
		u->random_bits = VehicleRandomBits();
 
		v->random_bits = Random();
 
		u->random_bits = Random();
 

	
 
		v->vehicle_flags = 0;
 
		if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
 
@@ -375,7 +375,7 @@ CommandCost CmdBuildAircraft(DoCommandFl
 
			w->spritenum = 0xFF;
 
			w->subtype = AIR_ROTOR;
 
			w->sprite_cache.sprite_seq.Set(SPR_ROTOR_STOPPED);
 
			w->random_bits = VehicleRandomBits();
 
			w->random_bits = Random();
 
			/* Use rotor's air.state to store the rotor animation frame */
 
			w->state = HRS_ROTOR_STOPPED;
 
			w->UpdateDeltaXY();
src/articulated_vehicles.cpp
Show inline comments
 
@@ -8,6 +8,7 @@
 
/** @file articulated_vehicles.cpp Implementation of articulated vehicles. */
 

	
 
#include "stdafx.h"
 
#include "core/random_func.hpp"
 
#include "train.h"
 
#include "roadveh.h"
 
#include "vehicle_func.h"
 
@@ -405,7 +406,7 @@ void AddArticulatedParts(Vehicle *first)
 
		v->engine_type = engine_type;
 
		v->value = 0;
 
		v->sprite_cache.sprite_seq.Set(SPR_IMG_QUERY);
 
		v->random_bits = VehicleRandomBits();
 
		v->random_bits = Random();
 

	
 
		if (flip_image) v->spritenum++;
 

	
src/roadveh_cmd.cpp
Show inline comments
 
@@ -303,7 +303,7 @@ CommandCost CmdBuildRoadVehicle(DoComman
 
		v->build_year = TimerGameCalendar::year;
 

	
 
		v->sprite_cache.sprite_seq.Set(SPR_IMG_QUERY);
 
		v->random_bits = VehicleRandomBits();
 
		v->random_bits = Random();
 
		v->SetFrontEngine();
 

	
 
		v->roadtype = rt;
src/ship_cmd.cpp
Show inline comments
 
@@ -905,7 +905,7 @@ CommandCost CmdBuildShip(DoCommandFlag f
 
		v->date_of_last_service = TimerGameCalendar::date;
 
		v->build_year = TimerGameCalendar::year;
 
		v->sprite_cache.sprite_seq.Set(SPR_IMG_QUERY);
 
		v->random_bits = VehicleRandomBits();
 
		v->random_bits = Random();
 

	
 
		v->UpdateCache();
 

	
src/train_cmd.cpp
Show inline comments
 
@@ -656,7 +656,7 @@ static CommandCost CmdBuildRailWagon(DoC
 
		v->date_of_last_service = TimerGameCalendar::date;
 
		v->build_year = TimerGameCalendar::year;
 
		v->sprite_cache.sprite_seq.Set(SPR_IMG_QUERY);
 
		v->random_bits = VehicleRandomBits();
 
		v->random_bits = Random();
 

	
 
		v->group_id = DEFAULT_GROUP;
 

	
 
@@ -721,7 +721,7 @@ static void AddRearEngineToMultiheadedTr
 
	u->date_of_last_service = v->date_of_last_service;
 
	u->build_year = v->build_year;
 
	u->sprite_cache.sprite_seq.Set(SPR_IMG_QUERY);
 
	u->random_bits = VehicleRandomBits();
 
	u->random_bits = Random();
 
	v->SetMultiheaded();
 
	u->SetMultiheaded();
 
	v->SetNext(u);
 
@@ -786,7 +786,7 @@ CommandCost CmdBuildRailVehicle(DoComman
 
		v->date_of_last_service = TimerGameCalendar::date;
 
		v->build_year = TimerGameCalendar::year;
 
		v->sprite_cache.sprite_seq.Set(SPR_IMG_QUERY);
 
		v->random_bits = VehicleRandomBits();
 
		v->random_bits = Random();
 

	
 
		if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SetBit(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
 
		v->SetServiceIntervalIsPercent(Company::Get(_current_company)->settings.vehicle.servint_ispercent);
src/vehicle.cpp
Show inline comments
 
@@ -359,15 +359,6 @@ Vehicle::Vehicle(VehicleType type)
 
	this->last_loading_station = INVALID_STATION;
 
}
 

	
 
/**
 
 * Get a value for a vehicle's random_bits.
 
 * @return A random value from 0 to 255.
 
 */
 
byte VehicleRandomBits()
 
{
 
	return GB(Random(), 0, 8);
 
}
 

	
 
/* Size of the hash, 6 = 64 x 64, 7 = 128 x 128. Larger sizes will (in theory) reduce hash
 
 * lookup times at the expense of memory usage. */
 
const int HASH_BITS = 7;
src/vehicle_func.h
Show inline comments
 
@@ -50,7 +50,6 @@ uint8 CalcPercentVehicleFilled(const Veh
 

	
 
void VehicleLengthChanged(const Vehicle *u);
 

	
 
byte VehicleRandomBits();
 
void ResetVehicleHash();
 
void ResetVehicleColourMap();
 

	
0 comments (0 inline, 0 general)