Skip to content
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

A couple of small bugfixes #194

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion faction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ void Faction::build_json_report(json& j, Game *game, size_t **citems) {
j["administrative"]["show_unit_attitudes"] = (showunitattitudes != 0);

if(!password_unset) j["administrative"]["password"] = password->const_str();
if(Globals->MAX_INACTIVE_TURNS) {
if(Globals->MAX_INACTIVE_TURNS != -1) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 is the signifier for ignore turn inactivity, and if(-1) evaluates to true, so this was a bug but unlikely to get caught since noone actually runs with -1 as the inactive turn setup.

int cturn = game->TurnNumber() - lastorders;
if ((cturn >= (Globals->MAX_INACTIVE_TURNS - 3)) && !is_npc) {
cturn = Globals->MAX_INACTIVE_TURNS - cturn;
Expand Down
2 changes: 1 addition & 1 deletion neworigins/rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ static GameDefs g = {
200, // MIN_DESTROY_POINTS,
34, // MAX_DESTROY_PERCENT
1, // HALF_RIDING_BONUS
GameDefs::REPORT_FORMAT_TEXT, // REPORT_FORMAT
GameDefs::REPORT_FORMAT_TEXT | GameDefs::REPORT_FORMAT_JSON, // REPORT_FORMAT
5, // BATTLE_STOP_MOVE_PERCENT
};

Expand Down
4 changes: 2 additions & 2 deletions text_report_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,9 @@ void TextReportGenerator::output(ostream& f, const json& report, bool show_regio

bool show_unit_attitudes = false;
if (report.contains("administrative")) {
if (!report["administrative"].contains("times_sent"))
if (!report["administrative"].contains("times_sent") || !report["administrative"]["times_sent"])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd initially made the assumption here that the field wouldn't be output at all if it was false, but the actual generation
code always created the field and set it's value to either true or false. For safety it will now check existence and/or the value being truthful.

In the case of times, if the value isn't set OR it's set to false then the times isn't being set. For the password, if it's set AND it's set to true then we output the warning.

Found this while testing the new website with an downloaded report for a new faction where it had a password set..
This wasn't caught in unit tests or snapshot tests as they don't set faction passwords so they (as expected) had this warning.

f << "Note: The Times is not being sent to you.\n\n";
if (report["administrative"].contains("password_unset"))
if (report["administrative"].contains("password_unset") && report["administrative"]["password_unset"])
f << "REMINDER: You have not set a password for your faction!\n\n";
if (report["administrative"].contains("inactivity_deletion_turns")) {
f << "WARNING: You have " << report["administrative"]["inactivity_deletion_turns"]
Expand Down
Loading