28 Commits
Author SHA1 Message Date
Goober5000andClaude Opus 5.5 2f131db53a propagate POF load failures through virtual POFs
A virtual POF ignored the load status of its base POF, so a base that
failed to load (missing, bad version, or rejected after parsing) was
still built upon and reported as a successful load.  Likewise, every
operation that copies from another POF used it even if that POF had
failed to load.

Return FAIL from read_virtual_model_file when the base POF fails, and
have the operations skip, with a warning, any source POF that failed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-08 03:02:24 -04:00
Goober5000andClaude Opus 5.5 7f71b169dd map appended-submodel textures before changing the virtual POF
When appending submodels would take the combined POF past
MAX_MODEL_TEXTURES, the limit was only noticed partway through, after the
submodel array had been grown, subsystems copied, and n_textures
incremented past the limit, which later loops over maps[] then overran.
Work out the texture mapping first, and give up before touching the model.

Also skip the -1 texture id of untextured flat polygons, which was being
assigned a texture slot, and which replace_textures_used then used to
index Num_verts and Num_polies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-08 03:02:23 -04:00
Shivansps d8afb71d41 Clear bsp_data from bsp_info after it has been used (#7754)
* clear bsp_data from bsp_info after has been used

* fix redundant redeclaration

* remove continue on null bsp_data
2026-09-08 10:47:55 -04:00
Goober5000andClaude Opus 5 086c553339 fix copying multiple glow point banks into a virtual POF
Every copied bank was written to the same array slot, so all but the last
were lost, and the slots left behind kept their zero-initialized contents.
A zeroed bitmap handle is slot 0 rather than -1, so the paging code would
then page out an unrelated bitmap.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-09-06 00:49:33 -04:00
Goober5000 246213a4be first part of comm node fix
Fix #4089, part 1:
- give the `my_replacement` and `i_replace` fields clearer names
- for submodels with the `Is_damaged` flag (representing -destroyed variants or debris), initialize them to blown-off (the true fix for #3078, fixing a regression introduced in the model instance refactor)
- roll back the de-parenting of live debris from #3089 (726ce953c7), because it was a wrong fix to the initialization bug and introduced its own subtle bug when positioning live debris
- roll back the `Can_move` flag skipping from #4138 (063d7afcfe), because it was another wrong fix to the initialization bug
- add some clarifying comments
2026-05-14 00:04:31 -04:00
Goober5000andClaude Opus 4.6 3f85d6172a use std::move() for local variables that are copied but not reused (#7308)
* use std::move() for local variables that are copied but not reused

Addresses ~140 Coverity "Variable copied when it could be moved"
defects across 74 files.  Every std::move() targets a local variable
whose value is consumed by push_back, emplace, assignment, lambda
capture, or a function call and is never read again afterward.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* clang: use std::make_shared

* clang: use std::make_unique

* address feedback

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
2026-05-07 14:40:38 +09:00
BMagnu 1f5525e04f Fix virtual POF crashes (#7327)
* Ensure model data isn't deleted twice

* shared_ptr-ify model data

* fix virtual pof filename issue

* Fix tests

* remove redundant memsets

* Clang Tid
2026-03-31 10:02:24 -04:00
BMagnu 7c37e9932d Merge pull request #6564 from BMagnu/cpp_17_cleanup
C++17 cleanup followup
2025-02-02 18:31:14 +09:00
Birk Magnussen 540d841f06 Remove any and variant libs 2025-02-01 13:26:28 +01:00
Birk Magnussen 1f2a8dce2a remove optional 2025-02-01 13:17:26 +01:00
Goober5000 ca624f86e2 a few pstypes changes and refinements
Several changes related to the volumetrics model fix:
1. Update the `model_load()` prototype with better parameter names, including a new `ErrorType` enum defined in pstypes.h
2. Update the `MIN`, `MAX`, and `CLAMP` macros, all of which were susceptible to performance issues because they duplicated their tokens.  This could cause functions or calculations to be re-run unnecessarily.  Since the codebase is now on C++17, `std::clamp()` can be used.
3. Update the rest of the codebase to fix any associated issues.
2025-01-30 21:35:03 -05:00
BMagnu 68f3fa6d8c Actually compile with proper optimizations in a release build. (#6336)
* Change optimization to O3 and enable LTO

* Remove ODR violations

# Conflicts:
#	code/menuui/playermenu.cpp
#	code/osapi/osregistry.cpp

* Fix uninitialized structs

* Remove negative alloc warning

* O3 for mac

* Remove GCC13 warnings

* Fix warning

* Properly fix weapon alloc size

* Try to placate GCC9's Psnet_socket estimation

* remove warnin

* Fix safe fd set check
2024-11-25 20:10:38 +01:00
BMagnu 5066e498a3 Virtual POF fixes (#5984)
* Fix wrong filename being used

* Fix replacement map not used for collision check

* Fix poly count and incorrect submodel numbers
2024-02-09 23:10:39 +01:00
Goober5000 17d36156cb add const where appropriate to the modelrender API
See title.  There were some cascade effects, but the changes are mostly contained to the model code.  The calls to `gr_render_model` and `g3_render_primitives` use `const_cast` because constifying that API would require a whole other PR.
2023-06-18 14:05:46 -04:00
Birk Magnussen f4b6a4af61 Property Append Mode proper 2023-05-25 20:55:22 +02:00
Birk Magnussen f8220ccd60 Property Append Mode 2023-05-25 20:54:04 +02:00
Birk Magnussen be29fc9eaa fix warning 2023-05-25 12:15:18 +02:00
Birk Magnussen 4d25b34c1b Add Subsystem data change 2023-05-25 12:12:55 +02:00
Goober5000 3e0c7f0721 add lcase_equal and lcase_lessthan
The `SCP_string_lcase_equal_to()()` and `SCP_string_lcase_less_than()()` functors are rather unwieldy to use in non-functor situations, so this adds conventional function equivalents.
2023-05-20 18:21:37 -04:00
Goober5000 8aa5a22f5d Merge pull request #5399 from BMagnu/modularpof_parent_subsystem
Fix modular pof handling of dock / path parent names
2023-05-12 14:19:16 -04:00
BMagnu 26cfc8d017 Make check case insensitive 2023-05-13 01:52:40 +09:00
Birk Magnussen 6f8c8e802a fix modular pof handling of dock / path parent names 2023-05-12 10:26:13 +02:00
Goober5000 712a70444b update type_flags when dock name changes
The `type_flags` on a model's dockpoints are determined by the dockpoint name.  If the name changes, the flags should be updated accordingly.

This fixes a bug in Scroll where a dockpoint that was imported and renamed to start with the word "cargo" was not compatible with cargo docking as expected.
2023-05-12 04:08:38 -04:00
BMagnu e2b205ffaa Modular POF Features 2 (#5209)
* Add weapon bank copy

* Add Path / Dock point copying

* cleanup

* Fix dock points

* Fix copy paste error

* Incorporate feedback

* Incorporate feedback 2

* delete copy assignment
2023-04-07 08:12:20 +09:00
BMagnu 2116d1fe66 Modular POF Features (#4713)
* Add turret copying

* Ad addturret parsing

* Fix gun_nr error

* Fix strncpy_s

* Fix strings better

* Cleanup submodel / turret copying

* Add 'Add Engine'

* Add Glowpoints, add Special Subsys

* Remember to keep the glowpoint texture

* Fix unused param
2022-10-24 18:35:51 +09:00
BMagnu d186aefa92 Adds a cache for modular POFs (#4690)
* cleanup submodel index replacement

* Add modelreplace cache

* Move RenameSubobjects to new API

* Fix and tidyup

* Fix GCC error

* fix macro

* Appease Clang

* Properly skip reading non-final leaves from the cache

* fix warning

* Safe-stringify, incorporate comments
2022-09-23 18:38:50 +09:00
BMagnu 565047e93b Implement a proper std::optional alternative (#4619)
* Add optional lib

* Replace modelreplace optionals

* Replace Animation Optional

* rework modelanimationdata constructors
2022-09-06 17:05:05 +09:00
BMagnu 74ba7899fd Virtual / Modular POFs (#4590)
* Integrate Barebones Framework

* further integration

* Add brak in read

* Defer subsystem generation

* Unentangle pof parsing and subsystem info writing

* finalize modelreplace skeleton

* Begin submodel copying

* First prototype of modular pofs demonstratable

* Allow Submodel Renaming

* Add copy children and set offset

* properly handle depth

* Add header modification

* Fix issues with parsing

* Fix Warnings

* incorporate feedback

* de std-ify

* Incorporate Feedback 2

* Fix macro

* Remove ref

* Enhance error messages
2022-09-03 22:15:56 +09:00