Repository navigation
Remove the MAX_MISSIONS and MAX_CAMPAIGNS limits - #7824
Draft
Goober5000 wants to merge 3 commits into
Draft
Goober5000 wants to merge 3 commits into
Goober5000 wants to merge 3 commits into
Conversation
Goober5000
force-pushed
the
feature/max_missions_bump
branch
from
October 5, 2026 07:07
052217e to
46dc010
Compare
Campaigns were limited to 100 missions by a fixed-size array in the campaign struct, and the campaign parser did not check that limit, so a campaign file with more missions overflowed the array into the vectors that follow it. Campaign.missions is now an SCP_vector sized by the parser, and the separate num_missions count is replaced by the vector's size. cmission members now have default initializers so that resized entries start out valid. The other arrays sized by MAX_CAMPAIGN_MISSIONS are vectors as well: the mission name lists in the mission load menu and the ready room. In FRED2, the campaign tree's Sorted, Elements, Level_counts, and Links arrays are vectors too, which removes the MAX_LEVELS and MAX_CAMPAIGN_TREE_LINKS limits and the separate Total_links count. Removing a mission from the tree now pops the vacated last slot. The multiplayer client sizes its mission list from the count the server sends. Multiplayer campaigns are still limited to 255 missions, since the protocol sends the count as a ubyte. When reading a campaign save file, data for a stored mission index that is out of range is now discarded, where it was previously written into the array without a check. The Lua campaign mission accessors, the loop brief stage handle, the debriefing persona lookup, and the main hall lookups also check the index against the mission list, and the main hall falls back to its defaults when the campaign has no missions. Since a save file's mission data is stored by index, it only applies to the campaign it was saved from. The barracks and pilot selection screens can load a pilot's save file while a different campaign is loaded, so mission data from a save file for another campaign is now discarded, and saving is skipped until a matching save file is loaded or the save data is cleared, so that the mixed data is not written to the campaign's save file. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Goober5000
force-pushed
the
feature/max_missions_bump
branch
2 times, most recently
from
October 7, 2026 20:17
9255280 to
7ba172c
Compare
The sim room listed standalone and campaign missions through fixed arrays of 1024 entries. These arrays are now vectors, and the separate Num_standalone_missions and Num_campaign_missions counts are replaced by the vectors' sizes. mission_campaign_get_mission_list now appends to an SCP_vector of strings instead of filling a caller-sized char* array. The sim room's mission name vectors now own their strings through SCP_vm_unique_ptr and are cleared unconditionally. Previously they were freed only when the *_inited flags were set, which leaked the names when a listing was cancelled partway and in api_sim_room_build_mission_list, which reset the flags before freeing. The standalone and campaign mission flag arrays are removed; they were written but never read, back to the original source release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The campaign list (Campaign_names, Campaign_file_names, and Campaign_descs) was held in fixed arrays of 128 owned char* strings. These are now SCP_vector<SCP_string>, filled through the SCP_vector overload of cf_get_file_list, and Num_campaigns is replaced by the vectors' size. An empty name or description now means absent. mission_campaign_get_info returns the description and first mission through SCP_string out-parameters, which also fixes a leak of the description when parsing failed partway. pilot_set_start_campaign no longer writes into the global Campaign_names with a counter that was never reset. It now checks the default campaign first, and only if that is missing or not a valid single-player campaign does it parse the rest and pick the one whose title sorts first, replacing the file list filter, its static name list, and the shell sort. The debug mission load menu builds its campaign filter list from vectors, which also lines the names up with the Campaign_filter_index-2 lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Goober5000
force-pushed
the
feature/max_missions_bump
branch
from
October 7, 2026 20:47
7ba172c to
4281b92
Compare
This was referenced Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR builds on #7823 and is in draft until it is merged.
Remove the MAX_MISSIONS limit
The sim room built its standalone and campaign mission lists in fixed arrays of
MAX_MISSIONS(1024) entries. A mod with more mission files, or a campaign with more missions, overflowedCampaign_mission_flags.SCP_vectors, and their sizes replace the separateNum_standalone_missionsandNum_campaign_missionscounts.mission_campaign_get_mission_listnow appends to anSCP_vector<SCP_string>instead of filling achar*array sized by the caller.SCP_vm_unique_ptrand are cleared unconditionally. Before, the names leaked in two cases:*_initedflags were setapi_sim_room_build_mission_listran, because it reset those flags before freeingRemove the MAX_CAMPAIGNS limit
The campaign list was held in fixed arrays of
MAX_CAMPAIGNS(128)char*strings, and the filters wrote into them without checking the bound.Campaign_names,Campaign_file_namesandCampaign_descsare nowSCP_vector<SCP_string>, filled through the vector overload ofcf_get_file_list.Num_campaignsis gone.ui.CampaignRoom.getCampaignListstill returns""for a campaign without a description.mission_campaign_get_infonow returns the description and first mission throughSCP_string*out-parameters, which fixes a leak of the description when parsing failed partway.pilot_set_start_campaignused to write into the globalCampaign_nameswith a counter that was never reset. It also never freed its file list, and sorted the file names by names that didn't match them. It now checks the default campaign first, and only if that fails does it pick the single-player campaign whose title sorts first.Campaign_filter_index-2lookup.🤖 Generated with Claude Code