forked from OpenTTD/OpenTTD
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Group vehicle list #12
Draft
SamuXarick
wants to merge
29
commits into
master
Choose a base branch
from
group-vehicle-list
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bb8f4bd
to
38f0bdc
Compare
* dummy orders. They should just vanish. Also check the actual order | ||
* type as ot is currently OT_GOTO_STATION. */ | ||
if (order->IsType(OT_IMPLICIT)) { | ||
order = order->next; // DeleteOrder() invalidates current order |
Check notice
Code scanning / CodeQL
For loop variable changed in body Note
Loop counters should not be modified in the body of the .
loop
Error loading related location
Loading
src/strings.cpp
Outdated
Comment on lines
924
to
1711
case VEH_AIRCRAFT: string_id = STR_SV_AIRCRAFT_NAME; break; | ||
case SCC_WAYPOINT_NAME: { // {WAYPOINT} | ||
Waypoint *wp = Waypoint::GetIfValid(args.GetNextParameter<StationID>()); | ||
if (wp == nullptr) break; | ||
|
||
if (!wp->name.empty()) { | ||
auto tmp_params = MakeParameters(wp->name); | ||
GetStringWithArgs(builder, STR_JUST_RAW_STRING, tmp_params); | ||
} else { | ||
auto tmp_params = MakeParameters(wp->town->index, wp->town_cn + 1); | ||
StringID string_id = ((wp->string_id == STR_SV_STNAME_BUOY) ? STR_FORMAT_BUOY_NAME : STR_FORMAT_WAYPOINT_NAME); | ||
if (wp->town_cn != 0) string_id++; | ||
GetStringWithArgs(builder, string_id, tmp_params); | ||
} | ||
break; | ||
} | ||
|
||
GetStringWithArgs(builder, string_id, tmp_params); | ||
case SCC_VEHICLE_NAME: { // {VEHICLE} | ||
const Vehicle *v = Vehicle::GetIfValid(args.GetNextParameter<VehicleID>()); | ||
if (v == nullptr) break; | ||
|
||
if (!v->name.empty()) { | ||
auto tmp_params = MakeParameters(v->name); | ||
GetStringWithArgs(builder, STR_JUST_RAW_STRING, tmp_params); | ||
} else if (v->group_id != DEFAULT_GROUP) { | ||
/* The vehicle has no name, but is member of a group, so print group name */ | ||
auto tmp_params = MakeParameters(v->group_id, v->unitnumber); | ||
GetStringWithArgs(builder, STR_FORMAT_GROUP_VEHICLE_NAME, tmp_params); | ||
} else { | ||
auto tmp_params = MakeParameters(v->unitnumber); | ||
|
||
StringID string_id; | ||
switch (v->type) { | ||
default: string_id = STR_INVALID_VEHICLE; break; | ||
case VEH_TRAIN: string_id = STR_SV_TRAIN_NAME; break; | ||
case VEH_ROAD: string_id = STR_SV_ROAD_VEHICLE_NAME; break; | ||
case VEH_SHIP: string_id = STR_SV_SHIP_NAME; break; | ||
case VEH_AIRCRAFT: string_id = STR_SV_AIRCRAFT_NAME; break; | ||
} | ||
|
||
GetStringWithArgs(builder, string_id, tmp_params); | ||
} | ||
break; | ||
} | ||
break; | ||
} | ||
|
||
case SCC_SIGN_NAME: { // {SIGN} | ||
const Sign *si = Sign::GetIfValid(args.GetNextParameter<SignID>()); | ||
if (si == nullptr) break; | ||
case SCC_SIGN_NAME: { // {SIGN} | ||
const Sign *si = Sign::GetIfValid(args.GetNextParameter<SignID>()); | ||
if (si == nullptr) break; | ||
|
||
if (!si->name.empty()) { | ||
auto tmp_params = MakeParameters(si->name); | ||
GetStringWithArgs(builder, STR_JUST_RAW_STRING, tmp_params); | ||
} else { | ||
auto tmp_params = ArrayStringParameters<0>(); | ||
GetStringWithArgs(builder, STR_DEFAULT_SIGN_NAME, tmp_params); | ||
if (!si->name.empty()) { | ||
auto tmp_params = MakeParameters(si->name); | ||
GetStringWithArgs(builder, STR_JUST_RAW_STRING, tmp_params); | ||
} else { | ||
auto tmp_params = ArrayStringParameters<0>(); | ||
GetStringWithArgs(builder, STR_DEFAULT_SIGN_NAME, tmp_params); | ||
} | ||
break; | ||
} | ||
break; | ||
} | ||
|
||
case SCC_STATION_FEATURES: { // {STATIONFEATURES} | ||
StationGetSpecialString(builder, args.GetNextParameter<StationFacility>()); | ||
break; | ||
} | ||
case SCC_STATION_FEATURES: { // {STATIONFEATURES} | ||
StationGetSpecialString(builder, args.GetNextParameter<StationFacility>()); | ||
break; | ||
} | ||
|
||
case SCC_COLOUR: { // {COLOUR} | ||
StringControlCode scc = (StringControlCode)(SCC_BLUE + args.GetNextParameter<Colours>()); | ||
if (IsInsideMM(scc, SCC_BLUE, SCC_COLOUR)) builder.Utf8Encode(scc); | ||
break; | ||
} | ||
case SCC_COLOUR: { // {COLOUR} | ||
StringControlCode scc = (StringControlCode)(SCC_BLUE + args.GetNextParameter<Colours>()); | ||
if (IsInsideMM(scc, SCC_BLUE, SCC_COLOUR)) builder.Utf8Encode(scc); | ||
break; | ||
} | ||
|
||
default: | ||
builder.Utf8Encode(b); | ||
break; | ||
default: | ||
builder.Utf8Encode(b); | ||
break; | ||
} |
Check notice
Code scanning / CodeQL
Long switch case Note
Switch has at least one case that is too long: .
Switch has at least one case that is too long: .
Switch has at least one case that is too long: .
Switch has at least one case that is too long: .
Switch has at least one case that is too long: .
SCC_ENCODED (81 lines)
Error loading related location
Loading Switch has at least one case that is too long:
SCC_GENDER_LIST (32 lines)
Error loading related location
Loading Switch has at least one case that is too long:
SCC_CARGO_SHORT (33 lines)
Error loading related location
Loading Switch has at least one case that is too long:
SCC_ENGINE_NAME (31 lines)
Error loading related location
Loading Switch has at least one case that is too long:
SCC_STATION_NAME (39 lines)
Error loading related location
Loading 3777fed
to
892a6e8
Compare
e3aaf82
to
0d88873
Compare
Use std::vector<const Vehicle *> VehicleList for these lists.
This commit prefaces the next incoming set of commit changes in order to have the vehicle lists already generated as an attempt to prevent AfterLoad actions accessing them empty.
…, ScriptVehicleList_Depot, ScriptVehicleList_Group and ScriptVehicleList_DefaultGroup
…Tick_Big_Ufo As a compromise, the result of this change differs from the original. The iteration order changed from lowest to highest vehicle index to lowest to highest company index plus the order at which each vehicle was added to each list regardless of their indexes.
…cleAvailable As a compromise, the result of this change differs from the original. Since the list only contains primary vehicles, free wagons aren't taken into consideration.
Additionally make the function receive one parameter more with the owner of the destination, to help it perform faster.
…Year and ScriptGroup::GetCurrentUsage
…UpdateServiceInterval, TrainAccelerationModelChanged, TrainSlopeSteepnessChanged, RoadVehAccelerationModelChanged, RoadVehSlopeSteepnessChanged, CheckFreeformEdges and InvalidateShipPathCache
As a compromise, the result of this change differs from the original. The VehiclePool was being iterated twice. Do it only once and assume only primary vehicles make use of last_station_visited and last_loading_station.
…ort and HasStationInUse
…lendar> _vehicles_yearly
0d88873
to
3a8236f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation / Problem
Description
Limitations
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.