Make comm order types modder-configurable, and add separate types for fighters and bombers - #7721
Make comm order types modder-configurable, and add separate types for fighters and bombers#7721Kestrellius wants to merge 3 commits into
Conversation
|
|
||
| if ((Player_ship != NULL) && !hud_squadmsg_reinforcements_available(Player_ship->team)) { | ||
| MsgItems[TYPE_REINFORCEMENT_ITEM].active = 0; | ||
| for ( auto item : MsgItems ) { |
There was a problem hiding this comment.
I think this should be for (auto &item : MsgItems) similar to how the traitor check right above this uses for (auto &item : MsgItems)
| } else { | ||
| // in config mode, so create just the first page of the Comms Menu | ||
| // as other functions, such as hud_squadmsg_type_select() will not be run in config mode | ||
| const char* temp_comm_order_types[] = {XSTR("Ships", 293), |
There was a problem hiding this comment.
I reckon the config mode section shown on the HUD Config screen also be updated to reflect these changes so that players/mods get shown an accurate representation of what the comms menu will look like.
| int item_num; | ||
| bool isSelectedItem = (i == Selected_menu_item); | ||
| char text[256]; | ||
| mmode_item item = MsgItems[First_menu_item + i]; |
There was a problem hiding this comment.
This should possibly be guarded by the !config flag? IE since the default config screen may have a different number that could end up being out of bounds
| item.active = hud_squadmsg_exist_fighters_bombers(SmallCraftFlavor::ALL_BOMBERS); | ||
| break; | ||
| case CommOrderType::REINFORCEMENTS: | ||
| item.active = (Player_ship != nullptr) && !hud_squadmsg_reinforcements_available(Player_ship->team) && Msg_shortcut_command == -1; |
There was a problem hiding this comment.
Original logic was (Player_ship != NULL) && !hud_squadmsg_reinforcements_available(Player_ship->team) -> 0 so looks like we need to remove the ! here for the hud_squadmsg_reinforcements_available function.
Also, C++ should be smart enough to realize the returned bools are 0 or 1 but would it make sense to clearly stated it with ? 0 :1?
| void hud_init_comm_orders() | ||
| { | ||
| int i; | ||
|
|
There was a problem hiding this comment.
Old code overwrote a fixed array while the new one emplace_backs, so you may consider adding a clear() for extra safety
| switch (flavor) { | ||
| case SmallCraftFlavor::ALL_FIGHTERS_AND_BOMBERS: | ||
| return sinfop->is_fighter_bomber(); | ||
| break; |
There was a problem hiding this comment.
Minor, but may not need the 'breakif you are already usingreturn`
| } | ||
| } | ||
|
|
||
|
|
There was a problem hiding this comment.
Minor, but extra whitespace. May be on purpose though?
|
Very useful feature to have! Added some in-line comments and here are four more general ones:
Local declaration extern
"All Bombers" on a fighter-led wing = the wing's bombers get nothing, and they're unreachable by the second loop too. This was harmless when the only flavor was fighters-or-bombers, though now with the split it gets tricky. As an added complication, the greying-out check in
All three flavors call hud_add_issued_order("All Fighters", command), which maps to at line 2613. A mission using the query-orders SEXP will see an "all bombers" order as satisfying , and can't detect the new flavors at all. |
| MsgItems.push_back({Comm_order_types[i].first, 1, Comm_order_types[i].second}); // assume active | ||
| } else { | ||
| MsgItems.push_back({0, 1, lua_cat_list[i - NUM_COMM_ORDER_TYPES]}); // assume active | ||
| MsgItems.push_back({0, 1, lua_cat_list[i - sz2i(Comm_order_types.size())]}); // assume active |
There was a problem hiding this comment.
The old dispatch code compared k (index), which was correct; this PR switches to comparing instance, which Lua items leave at 0. As such, Lua category items are pushed with instance = 0, which is now CommOrderType::MSG_SHIPS. Dispatch at line 1861 tests MsgItems[k].instance == CommOrderType::MSG_SHIPS first, so selecting any Lua category opens the ship-select menu instead of SM_MODE_GENERAL: the k >= Comm_order_types.size() branch at 1877 is unreachable. Same problem in the switch at 1805: Lua items get active = hud_squadmsg_count_ships(0).
I think the best way to fix this would be to give them a sentinel instance (MAX_COMM_ORDER_TYPES, or a dedicated LUA_GENERAL value) and run the logic on that.
Comm order types (that is, the list of things that can be messaged -- ships, wings, reinforcements, etc.) are now no longer a fixed list. Of the eight possible types, the modder may specify an arbitrary list in arbitrary order, with text specified in the table.
This was to facilitate the addition of two new types,
All FightersandAll Bombers-- as distinct from the retail type typically calledAll Fighters, which is really "all fighters and bombers". (All player-facing retail naming remains as default.) My experience as a player suggests that these new options will be extremely useful.