Debug: Show all town persistent storage registers, not just the caller GRFID

This commit is contained in:
Jonathan G Rennison
2020-12-29 21:33:51 +00:00
parent aa46bf3a2b
commit 77bf073939
2 changed files with 43 additions and 19 deletions

View File

@@ -200,6 +200,11 @@ public:
return nullptr;
}
virtual std::vector<uint32> GetPSAGRFIDs(uint index) const
{
return {};
}
virtual void ExtraInfo(uint index, std::function<void(const char *)> print) const {}
virtual bool ShowExtraInfoOnly(uint index) const { return false; };
@@ -508,11 +513,13 @@ struct NewGRFInspectWindow : Window {
}
}
uint psa_size = nih->GetPSASize(index, this->caller_grfid);
const int32 *psa = nih->GetPSAFirstPosition(index, this->caller_grfid);
std::vector<uint32> psa_grfids = nih->GetPSAGRFIDs(index);
for (const uint32 grfid : psa_grfids) {
uint psa_size = nih->GetPSASize(index, grfid);
const int32 *psa = nih->GetPSAFirstPosition(index, grfid);
if (psa_size != 0 && psa != nullptr) {
if (nih->PSAWithParameter()) {
this->DrawString(r, i++, "Persistent storage [%08X]:", BSWAP32(this->caller_grfid));
this->DrawString(r, i++, "Persistent storage [%08X]:", BSWAP32(grfid));
} else {
this->DrawString(r, i++, "Persistent storage:");
}
@@ -529,6 +536,7 @@ struct NewGRFInspectWindow : Window {
this->DrawString(r, i++, " %i to %i are all 0", psa_limit, psa_size - 1);
}
}
}
if (nif->properties != nullptr) {
this->DrawString(r, i++, "Properties:");

View File

@@ -543,6 +543,11 @@ class NIHIndustry : public NIHelper {
return (int32 *)(&i->psa->storage);
}
std::vector<uint32> GetPSAGRFIDs(uint index) const override
{
return { 0 };
}
void ExtraInfo(uint index, std::function<void(const char *)> print) const override
{
char buffer[1024];
@@ -866,6 +871,17 @@ class NIHTown : public NIHelper {
return nullptr;
}
virtual std::vector<uint32> GetPSAGRFIDs(uint index) const
{
Town *t = Town::Get(index);
std::vector<uint32> output;
for (const auto &iter : t->psa_list) {
output.push_back(iter->grfid);
}
return output;
}
void ExtraInfo(uint index, std::function<void(const char *)> print) const override
{
const Town *t = Town::Get(index);