Cleanup: Remove some unused functions. (#11429)

These were picked up with cppcheck.
This commit is contained in:
Peter Nelson 2023-11-03 21:21:00 +00:00 committed by GitHub
parent 4c58df75fd
commit 7d4a91ef9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 0 additions and 157 deletions

View File

@ -225,20 +225,6 @@ CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial
return union_mask;
}
/**
* Ands the refit_masks of all articulated parts.
* @param engine the first part
* @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask
* @return bit mask of CargoIDs which are a refit option for every articulated part (with default capacity > 0)
*/
CargoTypes GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type)
{
CargoTypes union_mask, intersection_mask;
GetArticulatedRefitMasks(engine, include_initial_cargo_type, &union_mask, &intersection_mask);
return intersection_mask;
}
/**
* Tests if all parts of an articulated vehicle are refitted to the same cargo.
* Note: Vehicles not carrying anything are ignored

View File

@ -18,7 +18,6 @@ CargoArray GetCapacityOfArticulatedParts(EngineID engine);
void AddArticulatedParts(Vehicle *first);
void GetArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type, CargoTypes *union_mask, CargoTypes *intersection_mask);
CargoTypes GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type);
CargoTypes GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type);
bool IsArticulatedVehicleCarryingDifferentCargoes(const Vehicle *v, CargoID *cargo_type);
bool IsArticulatedVehicleRefittable(EngineID engine);
bool IsArticulatedEngine(EngineID engine_type);

View File

@ -110,7 +110,6 @@ Money GetGroupProfitLastYearMinAge(CompanyID company, GroupID id_g, VehicleType
void SetTrainGroupID(Train *v, GroupID grp);
void UpdateTrainGroupID(Train *v);
void RemoveVehicleFromGroup(const Vehicle *v);
void RemoveAllGroupsForCompany(const CompanyID company);
bool GroupIsInGroup(GroupID search, GroupID group);

View File

@ -714,19 +714,6 @@ CommandCost CmdSetGroupFlag(DoCommandFlag flags, GroupID group_id, GroupFlags fl
return CommandCost();
}
/**
* Decrease the num_vehicle variable before delete an front engine from a group
* @note Called in CmdSellRailWagon and DeleteLasWagon,
* @param v FrontEngine of the train we want to remove.
*/
void RemoveVehicleFromGroup(const Vehicle *v)
{
if (!v->IsPrimaryVehicle()) return;
if (!IsDefaultGroupID(v->group_id)) GroupStatistics::CountVehicle(v, -1);
}
/**
* Affect the groupID of a train to new_g.
* @note called in CmdAddVehicleGroup and CmdMoveRailVehicle

View File

@ -744,8 +744,6 @@ struct TextRefStack {
this->grffile = grffile;
this->used = true;
}
void RewindStack() { this->position = 0; }
};
/** The stack that is used for TTDP compatible string code parsing */
@ -819,11 +817,6 @@ void StopTextRefStackUsage()
_newgrf_textrefstack.used = false;
}
void RewindTextRefStack()
{
_newgrf_textrefstack.RewindStack();
}
/**
* FormatString for NewGRF specific "magic" string control codes
* @param scc the string control code that has been read

View File

@ -45,7 +45,6 @@ bool CheckGrfLangID(byte lang_id, byte grf_version);
void StartTextRefStackUsage(const struct GRFFile *grffile, byte numEntries, const uint32_t *values = nullptr);
void StopTextRefStackUsage();
void RewindTextRefStack();
bool UsingNewGRFTextStack();
struct TextRefStack *CreateTextRefStackBackup();
void RestoreTextRefStackBackup(struct TextRefStack *backup);

View File

@ -87,16 +87,6 @@ class BuildObjectWindow : public Window {
return objclass->GetSpec(_selected_object_index)->IsAvailable();
}
/**
* Calculate the number of columns of the #WID_BO_SELECT_MATRIX widget.
* @return Number of columns in the matrix.
*/
uint GetMatrixColumnCount()
{
const NWidgetBase *matrix = this->GetWidget<NWidgetBase>(WID_BO_SELECT_MATRIX);
return 1 + (matrix->current_x - matrix->smallest_x) / matrix->resize_x;
}
public:
BuildObjectWindow(WindowDesc *desc, WindowNumber number) : Window(desc), info_height(1), filter_editbox(EDITBOX_MAX_SIZE * MAX_CHAR_LENGTH, EDITBOX_MAX_SIZE)
{

View File

@ -350,9 +350,6 @@ public:
*/
inline uint GetNumVehicles() const { return this->num_vehicles; }
bool IsVehicleInSharedOrdersList(const Vehicle *v) const;
int GetPositionInSharedOrderList(const Vehicle *v) const;
/**
* Adds the given vehicle to this shared order list.
* @note This is supposed to be called after the vehicle has been inserted

View File

@ -571,31 +571,6 @@ void OrderList::RemoveVehicle(Vehicle *v)
if (v == this->first_shared) this->first_shared = v->NextShared();
}
/**
* Checks whether a vehicle is part of the shared vehicle chain.
* @param v is the vehicle to search in the shared vehicle chain.
*/
bool OrderList::IsVehicleInSharedOrdersList(const Vehicle *v) const
{
for (const Vehicle *v_shared = this->first_shared; v_shared != nullptr; v_shared = v_shared->NextShared()) {
if (v_shared == v) return true;
}
return false;
}
/**
* Gets the position of the given vehicle within the shared order vehicle list.
* @param v is the vehicle of which to get the position
* @return position of v within the shared vehicle chain.
*/
int OrderList::GetPositionInSharedOrderList(const Vehicle *v) const
{
int count = 0;
for (const Vehicle *v_shared = v->PreviousShared(); v_shared != nullptr; v_shared = v_shared->PreviousShared()) count++;
return count;
}
/**
* Checks whether all orders of the list have a filled timetable.
* @return whether all orders have a filled timetable.

View File

@ -427,12 +427,6 @@ public:
return next_trackdir;
}
static uint stDistanceToTile(const RoadVehicle *v, TileIndex tile)
{
Tpf pf;
return pf.DistanceToTile(v, tile);
}
inline uint DistanceToTile(const RoadVehicle *v, TileIndex dst_tile)
{
/* handle special case - when current tile is the destination tile */

View File

@ -270,39 +270,3 @@ RoadType GetRoadTypeByLabel(RoadTypeLabel label, bool allow_alternate_labels)
/* No matching label was found, so it is invalid */
return INVALID_ROADTYPE;
}
/**
* Returns the available RoadSubTypes for the provided RoadType
* If the given company is valid then will be returned a list of the available sub types at the current date, while passing
* a deity company will make all the sub types available
* @param rt the RoadType to filter
* @param c the company ID to check the roadtype against
* @param any_date whether to return only currently introduced roadtypes or also future ones
* @returns the existing RoadSubTypes
*/
RoadTypes ExistingRoadTypes(CompanyID c)
{
/* Check only players which can actually own vehicles, editor and gamescripts are considered deities */
if (c < OWNER_END) {
const Company *company = Company::GetIfValid(c);
if (company != nullptr) return company->avail_roadtypes;
}
RoadTypes known_roadtypes = ROADTYPES_NONE;
/* Find used roadtypes */
for (Engine *e : Engine::IterateType(VEH_ROAD)) {
/* Check if the roadtype can be used in the current climate */
if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue;
/* Check whether available for all potential companies */
if (e->company_avail != MAX_UVALUE(CompanyMask)) continue;
known_roadtypes |= GetRoadTypeInfo(e->u.road.roadtype)->introduces_roadtypes;
}
/* Get the date introduced roadtypes as well. */
known_roadtypes = AddDateIntroducedRoadTypes(known_roadtypes, CalendarTime::MAX_DATE);
return known_roadtypes;
}

View File

@ -1957,14 +1957,6 @@ const char *GetCurrentLocale(const char *param)
const char *GetCurrentLocale(const char *param);
#endif /* !(defined(_WIN32) || defined(__APPLE__)) */
bool StringIDSorter(const StringID &a, const StringID &b)
{
std::string stra = GetString(a);
std::string strb = GetString(b);
return StrNaturalCompare(stra, strb) < 0;
}
/**
* Get the language with the given NewGRF language ID.
* @param newgrflangid NewGRF languages ID to check.

View File

@ -110,8 +110,6 @@ extern TextDirection _current_text_dir; ///< Text direction of the currently sel
void InitializeLanguagePacks();
const char *GetCurrentLanguageIsoCode();
bool StringIDSorter(const StringID &a, const StringID &b);
/**
* A searcher for missing glyphs.
*/

View File

@ -2353,32 +2353,6 @@ void Vehicle::HandleLoading(bool mode)
this->IncrementImplicitOrderIndex();
}
/**
* Get a map of cargoes and free capacities in the consist.
* @param capacities Map to be filled with cargoes and capacities.
*/
void Vehicle::GetConsistFreeCapacities(std::map<CargoID, uint> &capacities) const
{
for (const Vehicle *v = this; v != nullptr; v = v->Next()) {
if (v->cargo_cap == 0) continue;
auto pair = capacities.find(v->cargo_type);
if (pair == capacities.end()) {
capacities[v->cargo_type] = v->cargo_cap - v->cargo.StoredCount();
} else {
pair->second += v->cargo_cap - v->cargo.StoredCount();
}
}
}
uint Vehicle::GetConsistTotalCapacity() const
{
uint result = 0;
for (const Vehicle *v = this; v != nullptr; v = v->Next()) {
result += v->cargo_cap;
}
return result;
}
/**
* Send this vehicle to the depot using the given command(s).
* @param flags the command flags (like execute and such).

View File

@ -391,10 +391,6 @@ public:
void HandleLoading(bool mode = false);
void GetConsistFreeCapacities(std::map<CargoID, uint> &capacities) const;
uint GetConsistTotalCapacity() const;
/**
* Marks the vehicles to be redrawn and updates cached variables
*