Skip to content

Commit

Permalink
Warn about non-transport FerryBoat units
Browse files Browse the repository at this point in the history
The FerryBoat flag is only meaningful for units that can transport. Warn when
the flag is set for non-transport units, and unset it. This prevents an
assertion failure later on.

Closes #2238.
  • Loading branch information
lmoureaux committed Mar 26, 2024
1 parent 8316edf commit 2bacd06
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions server/ruleset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include "script_server.h"

#include "ruleset.h"
#include "unittype.h"

// RULESET_SUFFIX already used, no leading dot here
#define RULES_SUFFIX "ruleset"
Expand Down Expand Up @@ -2303,6 +2304,15 @@ static bool load_ruleset_units(struct section_file *file,
ok = false;
break;
}

// L_FERRYBOAT makes the AI consider the unit as a transport.
// Ensure it can actually transport something.
if (utype_has_role(u, L_FERRYBOAT) && u->transport_capacity == 0) {
qCWarning(ruleset_category,
"\"%s\": Unit %s has FerryBoat flag but cannot transport",
filename, utype_rule_name(u));
BV_CLR(u->roles, L_FERRYBOAT - L_FIRST);
}
}
unit_type_iterate_end;
}
Expand Down

0 comments on commit 2bacd06

Please sign in to comment.