Compare commits

...

5 Commits

Author SHA1 Message Date
Jonathan G Rennison 9a07f14f56 Show running costs in calendar years by default 2024-04-29 22:57:02 +01:00
Jonathan G Rennison c5cd598217 Debug: Log number of GRFs at level sl=2 when loading a game
Add helper to get the number of non-static GRFs in a GRF config
2024-04-29 20:14:37 +01:00
Jonathan G Rennison adc7840f01 Scheduled dispatch: Caveat text for number of vehicles required 2024-04-29 18:31:37 +01:00
Jonathan G Rennison a14f850f33 Debug: Show unreachable error groups in sprite dump when show details enabled 2024-04-29 17:27:22 +01:00
Peter Nelson 96ddabb30c Codechange: Remove write-only spec_id from RoadStopSpec. (#12582)
Comment is incorrect about its value too.

(cherry picked from commit 72c55128d2)
2024-04-29 17:13:11 +01:00
12 changed files with 39 additions and 22 deletions

View File

@ -2168,7 +2168,7 @@ STR_SCHDISPATCH_SLOT_TOOLTIP_TAG :{}Tag {NUM}
STR_SCHDISPATCH_SUMMARY_NO_LAST_DEPARTURE :{BLACK}No previous departures.
STR_SCHDISPATCH_SUMMARY_LAST_DEPARTURE_PAST :{BLACK}Last departure at {TT_TIME}.
STR_SCHDISPATCH_SUMMARY_LAST_DEPARTURE_FUTURE :{BLACK}Last departure has not left yet, it will depart at {TT_TIME}.
STR_SCHDISPATCH_SUMMARY_L1 :{BLACK}This schedule requires {COMMA} vehicle{P "" s}.
STR_SCHDISPATCH_SUMMARY_L1 :{BLACK}This schedule is estimated to require at least {COMMA} vehicle{P "" s}.
STR_SCHDISPATCH_SUMMARY_L2 :{BLACK}This schedule repeats every {STRING1}.
STR_SCHDISPATCH_SUMMARY_L3 :{BLACK}This schedule began at {TT_TIME}, and ends at {TT_TIME}.
STR_SCHDISPATCH_SUMMARY_L4 :{BLACK}Maximum delay of {STRING1} is allowed before the slot is skipped.

View File

@ -499,15 +499,8 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGRFCheck()
return this->SendNeedGamePassword();
}
const GRFConfig *c;
uint grf_count = 0;
for (c = _grfconfig; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC)) grf_count++;
}
p->Send_uint32(grf_count);
for (c = _grfconfig; c != nullptr; c = c->next) {
p->Send_uint32(GetGRFConfigListNonStaticCount(_grfconfig));
for (const GRFConfig *c = _grfconfig; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC)) SerializeGRFIdentifier(*p, c->ident);
}

View File

@ -5145,7 +5145,6 @@ static ChangeInfoResult RoadStopChangeInfo(uint id, int numinfo, int prop, const
uint32_t classid = buf->ReadDWord();
rs->cls_id = RoadStopClass::Allocate(BSWAP32(classid));
rs->spec_id = id + i;
break;
}

View File

@ -540,6 +540,15 @@ void ResetGRFConfig(bool defaults)
AppendStaticGRFConfigs(&_grfconfig);
}
/** Get the count of non-static GRFs in a GRF config list */
uint GetGRFConfigListNonStaticCount(const GRFConfig *config)
{
uint grf_count = 0;
for (const GRFConfig *c = config; c != nullptr; c = c->next) {
if (!HasBit(c->flags, GCF_STATIC)) grf_count++;
}
return grf_count;
}
/**
* Check if all GRFs in the GRF config from a savegame can be loaded.

View File

@ -233,6 +233,7 @@ void AppendStaticGRFConfigs(GRFConfig **dst);
void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el);
void ClearGRFConfigList(GRFConfig **config);
void ResetGRFConfig(bool defaults);
uint GetGRFConfigListNonStaticCount(const GRFConfig *config);
GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig);
bool FillGRFDetails(GRFConfig *config, bool is_static, Subdirectory subdir = NEWGRF_DIR);
std::string GRFBuildParamList(const GRFConfig *c);

View File

@ -145,7 +145,6 @@ struct RoadStopSpec {
*/
GRFFilePropsBase<NUM_CARGO + 3> grf_prop;
RoadStopClassID cls_id; ///< The class to which this spec belongs.
int spec_id; ///< The ID of this spec inside the class.
StringID name; ///< Name of this stop
RoadStopAvailabilityType stop_type = ROADSTOPTYPE_ALL;

View File

@ -753,6 +753,7 @@ void SpriteGroupDumper::DumpSpriteGroup(const SpriteGroup *sg, const char *paddi
} else {
std::string subgroup_padding(padding);
subgroup_padding += " ";
bool found_error_group = false;
for (const auto &range : (*ranges)) {
char *p = this->buffer;
p += seprintf(p, lastof(this->buffer), "%srange: %X -> %X", padding, range.low, range.high);
@ -767,6 +768,7 @@ void SpriteGroupDumper::DumpSpriteGroup(const SpriteGroup *sg, const char *paddi
}
print();
this->DumpSpriteGroup(range.group, subgroup_padding.c_str(), SGDF_RANGE);
if (range.group == dsg->error_group) found_error_group = true;
}
if (default_group != nullptr) {
char *p = this->buffer;
@ -776,6 +778,13 @@ void SpriteGroupDumper::DumpSpriteGroup(const SpriteGroup *sg, const char *paddi
}
print();
this->DumpSpriteGroup(default_group, subgroup_padding.c_str(), SGDF_DEFAULT);
if (default_group == dsg->error_group) found_error_group = true;
}
if (this->more_details && !found_error_group && dsg->error_group != nullptr) {
char *p = this->buffer;
p += seprintf(p, lastof(this->buffer), "%sunreachable error group", padding);
print();
this->DumpSpriteGroup(dsg->error_group, subgroup_padding.c_str(), SGDF_DEFAULT);
}
}
break;

View File

@ -15,6 +15,7 @@
#include "newgrf_sl.h"
#include "../fios.h"
#include "../load_check.h"
#include "../debug.h"
#include "../safeguards.h"
@ -98,6 +99,8 @@ struct NGRFChunkHandler : ChunkHandler {
if (IsSavegameVersionBefore(SLV_101)) c->SetSuitablePalette();
AppendToGRFConfigList(&grfconfig, c);
}
DEBUG(sl, 2, "Loaded %u NewGRFs", GetGRFConfigListNonStaticCount(grfconfig));
}
void Load() const override

View File

@ -850,14 +850,6 @@ struct SchdispatchWindow : GeneralVehicleWindow {
DrawString(ir.left, ir.right, y, STR_SCHDISPATCH_SUMMARY_REUSE_SLOTS_ENABLED);
extra_lines++;
y += GetCharacterHeight(FS_NORMAL);
} else if (!have_conditional) {
const int required_vehicle = CalculateMaxRequiredVehicle(v->orders->GetTimetableTotalDuration(), ds.GetScheduledDispatchDuration(), ds.GetScheduledDispatch());
if (required_vehicle > 0) {
SetDParam(0, required_vehicle);
DrawString(ir.left, ir.right, y, STR_SCHDISPATCH_SUMMARY_L1);
extra_lines++;
y += GetCharacterHeight(FS_NORMAL);
}
}
SetTimetableParams(0, ds.GetScheduledDispatchDuration(), true);
@ -873,6 +865,16 @@ struct SchdispatchWindow : GeneralVehicleWindow {
DrawString(ir.left, ir.right, y, STR_SCHDISPATCH_SUMMARY_L4);
y += GetCharacterHeight(FS_NORMAL);
if (!ds.GetScheduledDispatchReuseSlots() && !have_conditional) {
const int required_vehicle = CalculateMaxRequiredVehicle(v->orders->GetTimetableTotalDuration(), ds.GetScheduledDispatchDuration(), ds.GetScheduledDispatch());
if (required_vehicle > 0) {
SetDParam(0, required_vehicle);
DrawString(ir.left, ir.right, y, STR_SCHDISPATCH_SUMMARY_L1);
extra_lines++;
y += GetCharacterHeight(FS_NORMAL);
}
}
uint32_t duration = ds.GetScheduledDispatchDuration();
for (const DispatchSlot &slot : ds.GetScheduledDispatch()) {
if (slot.offset >= duration) {

View File

@ -11,6 +11,7 @@
#include "../fios.h"
#include "../load_check.h"
#include "../string_func.h"
#include "../debug.h"
#include "saveload.h"
#include "newgrf_sl.h"
@ -118,6 +119,7 @@ static void Load_NGRF_common(GRFConfig *&grfconfig)
if (IsSavegameVersionBefore(SLV_101)) c->SetSuitablePalette();
AppendToGRFConfigList(&grfconfig, c);
}
DEBUG(sl, 2, "Loaded %u NewGRFs", GetGRFConfigListNonStaticCount(grfconfig));
}
static void Load_NGRF()

View File

@ -2472,7 +2472,7 @@ class NIHRoadStop : public NIHelper {
const RoadStopSpec *spec = GetRoadStopSpec(index);
if (spec) {
uint class_id = RoadStopClass::Get(spec->cls_id)->global_id;
char *b = buffer + seprintf(buffer, lastof(buffer), " class ID: %c%c%c%c, spec ID: %u", class_id >> 24, class_id >> 16, class_id >> 8, class_id, spec->spec_id);
char *b = buffer + seprintf(buffer, lastof(buffer), " class ID: %c%c%c%c", class_id >> 24, class_id >> 16, class_id >> 8, class_id);
if (spec->grf_prop.grffile != nullptr) {
b += seprintf(b, lastof(buffer), " (local ID: %u)", spec->grf_prop.local_id);
}

View File

@ -1634,7 +1634,7 @@ post_cb = [](auto) { InvalidateWindowData(WC_BUILD_TOOLBAR, TRANSPORT_RAIL); }
[SDTC_BOOL]
var = gui.show_running_costs_calendar_year
flags = SF_NOT_IN_SAVE | SF_NO_NETWORK_SYNC | SF_PATCH
def = false
def = true
str = STR_CONFIG_SHOW_VEHICLE_RUNNING_COSTS_CALENDAR_YEAR
strhelp = STR_CONFIG_SHOW_VEHICLE_RUNNING_COSTS_CALENDAR_YEAR_HELPTEXT
post_cb = [](auto) { MarkWholeScreenDirty(); }