FSO doesn't appear to use this any longer. And even when it was enabled the
requirements made it largely useless anyway. Removing to clean up cfile a
bit and so we don't have to keep maintaining it.
When an orientation matrix is constructed using one or more vectors, all such vectors must be normalized. Previously, the code did not enforce this for matrices parsed from a mission or table file. Although FRED will use correct matrices, it also truncates floating point values to six decimal places, so non-normalized vectors might be written to the mission file as happened in #6632. And there is always the possibility that someone could manually edit the mission file to corrupt the matrices.
While we're at it, per suggestions from Asteroth and qazwsxal, make sure the matrix is orthogonal as well. The `vm_fix_matrix` function handles all relevant calculations.
Fixes#6632. Follow-up to #6596.
Use `std::unique_ptr` rather than `vm_malloc` and `vm_free` to handle optional strings in ship classes. This makes the code more robust and increases memory safety. This also allows several string variables to be consolidated in the ship class and weapon class script APIs.
Also add new `stuff_string()` overloads and a new `F_TRIMMED` string parsing type to handle the new fields and the string trimming done inside `stuff_malloc_string()`.
Upgrade `parse_get_line` to detect all three EOL types: CR, LF, and CRLF. The function is now more robust against line ending mismatches and will now also warn the modder if a file contains mixed line endings.
Fixes#6395.
1. Trim trailing whitespace on any property values, just as leading whitespace is trimmed. All places where `get_user_prop_value()` is used implicitly or explicitly require this.
2. Warn the user if an invalid `$special` value is parsed. This would have caught #1, and will now catch related errors, such as misspellings, in the future.
3. Enhance `string_lookup()` with the ability to print the list being searched, if desired. Remove an unused version of `string_lookup()`.
4. Check for lower-detail submodels being recognized as subsystems.
This type for subsystems is analogous to the shipname type for ships. Sometimes it is useful to refer to a subsystem even if its parent ship is not present. Whereas the subsystem object would be invalid, the subsystemname string still contains the string that the mission designer specified.
Relatedly, upgrade the parsing of `+Parent Parameter Index:` to be checked on both parented and non-parented parameters. This will help both modders who put the field in the wrong place and programmers who may want to add a parented parameter in the future.
* fix some usages of std::transform
* change parse_string_flag_list to use a reference
* add a variant of parse_string_flag_list that can use a SCP_set, and make a templated version of flag_def_list
1. Tweak the API of `error_display` so that an error level of 2 displays a `ReleaseWarning`.
2. Use this error level for the malformed XSTR warnings in the localization code.
Resolves#6374.
* coverity - using `std::move` instead of copying, and change some parameters from value to reference
* coverity - fix or mark potential copy-paste mistakes
* coverity - various checking of parameter and return values
* coverity - miscellaneous fixes, and change some 'intentional' markers to 'false positive' markers
As requested by Event Horizon, this removes the limit on fireball types. The fixed array has been replaced with a vector and the relevant code updated accordingly. There is also a new version of `stuff_int_list()` to parse ints into a vector.
This also adds bounds checking for explosion animations that are parsed for ship classes, ship types, and asteroids, since previously there was no guarantee that the indexes would be in range.
As reported by Colt, there was a crash in the in-mission jump sequence in Shepherds where the mission previously worked. The proximate cause was a handwritten SEXP called via script that omitted whitespace before an opening parenthesis. This was incorrectly recognized by the upgraded SEXP parser as an invalid SEXP. Unfortunately, a separate bug in `get_line_num()` caused a crash when the parser tried to display a warning, because the function tried to calculate the line number of a SEXP that did not come from a parsed file.
This commit fixes the parser to recognize opening parentheses even when no whitespace precedes them, moves the output to the 'unexpected end of sexp' warnings will they will now be seen, and fixes `get_line_num()` to work when there is no parsed text.
Follow-up to #5520.
Supercaps use a physics flag on warpin that makes them slow down faster than they would under the normal physics code. This adds that flag as an option for custom warp parameters.
Since flags are not yet parsed when warp parameters are parsed, the code needs to skip ahead and peek at the flags in the same way as the weapon override.
In at least two instances, `split_str_once()` can be called with width values derived from mod-supplied values that can be 0 or less (specifically, two hud gauges: if `+Messages:` has a `Max Width:` that's too small, or `+Directives:` has a `Max Line Width:` of 0 or less). Since user-supplied code shouldn't be tripping assertions, I looked into adding security around the calling sites when I realized that the assertion wasn't actually protecting against anything; the function would run just fine with a negative pixel width, it would just break with every whitespace. Since both calling sites that could trip the assertion already treat getting `src` back as output as an "I can't split this" error condition, it's perfectly fine (and skips iterating through the string) to just `return src` if the maximum pixel width is 0 or less, so let's just do that instead. Technically this is a behavior change in Release code, but the result of the old code would've been to spam the message log with every individual word in every message (if `Max Width:` was too small), and for directives to seemingly-randomly split only after the first word (if `Max Line Width:` was 0 or less). Not splitting at all is at least as correct, saves some pointless processing, and *should* still be obviously wrong if there was supposed to be a reasonable width value.
In retail, number parsing picked up immediately at the character after the number parsed, so parsing `0.50` as an int would yield 0, and then the next available characters would be `.50`. Even though parsing has been tightened up and made stricter, we can still "fail gracefully" by simulating the old behavior. And when failing gracefully, the message can be a warning.
When parsing a list of numbers, such as in the $uvec or $fvec of models, a bug was reported where whitespace before the comma caused the number parsing to fail. This change checks for a comma after whitespace instead of checking for a comma as the very next character.