Commit graph

127 commits

Author SHA1 Message Date
Kp 229766e9cb Use enum class for polygon_simpler_model_index
This type is stored with an off-by-one bias from the regular model
index, so use a distinct enum type to avoid implicit conversions.
2022-10-09 23:15:20 +00:00
Kp 43e1c841f0 Pass polymodel& to polymodel_read 2022-10-09 23:15:20 +00:00
Kp acae546a90 Pass polymodel& to draw_model_picture, draw_polygon_model 2022-10-09 23:15:20 +00:00
Kp e69f219539 Pass std::span to g3_validate_polygon_model 2022-09-24 17:47:52 +00:00
Kp 928834fdf8 Pass std::span to g3_init_polygon_model 2022-09-24 17:47:52 +00:00
Kp c64a584bfd Use enum class for robot_gun_number
Validate gun numbers on loading object data.  Factor out and normalize
the logic for advancing to a robot's next gun.
2022-08-22 01:24:49 +00:00
Kp 1fb55eebc2 Use enum class for robot_animation_state 2022-08-22 01:24:49 +00:00
Kp 3ea0cc7053 Store Pof_addr at local scope
Pass it to called functions as needed.
2022-08-22 01:24:49 +00:00
Kp 6b7ba83a00 Move anim_angs into local scope, since it is copied out later 2022-08-22 01:24:49 +00:00
Kp 99577c4296 Simplify pof_read_string
The resulting string is discarded, so change it to skip without copying.
2022-08-22 01:24:49 +00:00
Kp a41908dece Move Pof_file_end to local scope
Rely on the extent in std::span for called code that needs to know
bounds.
2022-08-22 01:24:49 +00:00
Kp 3e13dcdf19 Use std::span to bound read_model_guns valid bytes 2022-08-22 01:24:49 +00:00
Kp 15e8ceeaa4 Use std::span to bound read_model_file valid bytes 2022-08-22 01:24:49 +00:00
Kp 42caec7e58 Use std::span for pof reading functions 2022-08-22 01:24:49 +00:00
Kp c5c5e8ea39 Simplify pof_read_angs
The caller passes a length of 1, so inline that and simplify the
function.
2022-08-22 01:24:49 +00:00
Kp 69579df368 Simplify pof_read_short
Use the general little-endian helper.
2022-08-22 01:24:49 +00:00
Kp 87c79206e8 Simplify pof_cfread
All callers pass a value of 1 for one of the two length terms, so inline
that and eliminate the multiplication.
2022-08-22 01:24:49 +00:00
Kp bfb7ed7efc Simplify pof_read_vecs
All callers pass a count of 1, so inline that and eliminate the loop.
2022-08-22 01:24:49 +00:00
Kp a70188e7a5 Move various static functions into anonymous namespace 2022-07-09 13:39:29 +00:00
Kp fdf5836031 Move g3 instance contexts onto the stack 2021-09-04 12:17:14 +00:00
Kp 1c13d3c8d3 Improve error reporting for PHYSFSX_openReadBuffered
Return the PHYSFS error code on failure, so that callers can report why
the open failed.
2021-07-25 23:00:56 +00:00
Dmitry Grigoryev fbd05a1592 optimize include files (include what you use) 2021-02-06 21:38:50 +01:00
Kp c96671f763 Move Pof_names to d_level_shared_polygon_model_state 2020-08-24 01:31:28 +00:00
Kp 8a1bc7f318 Move Exit_models_loaded into d_level_shared_polygon_model_state 2020-08-24 01:31:28 +00:00
Kp 0eaabdb2fb Move N_polygon_models into d_level_shared_polygon_model_state 2020-08-24 01:31:28 +00:00
Kp b814434181 Revert "fix invalid polymodels if words_need_alignment=1"
This reverts commit 60edaa7dce.

This commit was brought in through a merge to obtain a different change,
and was supposed to be suppressed in preference to the change from
dfcb0fcdc.  Revert it here, since reloading the variable suffices to fix
the problem, and this commit forces a reload on all platforms, rather
than only reloading on platforms that need it.
2020-07-07 04:09:44 +00:00
Kp 2e979c954d Merge 'refs/pull/519/head' into master 2020-07-05 23:34:33 +00:00
Kp 3f951cf45f Use A.size() or std::size instead of sizeof(A)/sizeof(A[0]) 2020-07-05 23:34:33 +00:00
Kp 7e36beb30c Move polymodel alignment code to interp.cpp
This makes the alignment data structure `chunk` private to interp.cpp,
and allows most files to ignore whether DXX_WORDS_NEED_ALIGNMENT is
enabled, thus improving the ccache hit rate.
2020-07-05 23:34:33 +00:00
Kp dfcb0fcdc1 Fix truncated polymodel data on words_need_alignment=1 systems
kajott reports that on Raspberry Pi systems, "Medium Hulk and Heavy Hulk
models were missing their heads".  This impacts all systems with
words_need_alignment=1, and was introduced by logic that tried to
truncate invalid polygon models, which was added because such models
often crashed the game.  The validation logic used the original size of
the polygon model data, which is correct on systems with
words_need_alignment=0, but can be too small on systems with
words_need_alignment=1 if the polygon model was enlarged as part of
aligning it.  Such systems would refuse to read past the original,
shorter, length, and then declare the model to be broken and truncate
it.  Fix this by reloading the length from the polymodel structure after
the alignment logic is applied.

Reported-by: kajott <https://github.com/dxx-rebirth/dxx-rebirth/pull/519>
Fixes: 42a2e3ab0b ("Avoid crash loading polymodels with invalid subcalls")
2020-07-05 23:34:33 +00:00
Kp 316a4740a6 Move words_bigendian into if constexpr
`words_bigendian` is `constexpr`, so move the tests on it behind `if
constexpr` to encourage the compiler to prune unreachable paths.
2020-07-05 23:34:33 +00:00
Martin Fiedler 60edaa7dce fix invalid polymodels if words_need_alignment=1
If compiled with words_need_alignment=1, the
model data was correctly converted and expanded,
but the old size was still used for validating
and initializing the model.

This caused funky effects on affected platforms,
e.g. some robots missing their heads on Raspberry Pi.
2020-07-02 21:56:11 +02:00
Kp 3d0f333b34 Unify object texture setup
Move the load of &GameBitmaps to the common loop used for paging in.
Add range checks on the loops.
2020-05-22 02:40:26 +00:00
Kp c1181b7be5 Move texture_list out of global scope 2020-05-22 02:40:26 +00:00
Kp db7b4b3f88 Refer to <memory> directly, not through "compiler-make_unique.h" 2020-05-02 21:18:43 +00:00
Kp cc38cdf4b8 Qualify uses of std::make_unique 2020-05-02 21:18:42 +00:00
Kp 53761500f1 Qualify uses of std::array 2020-05-02 21:18:42 +00:00
ziplantil 0a21784aa7 some changes as per comments in #479 2019-12-18 13:44:43 +02:00
ziplantil cb2b844af3 do not free extra models when loading exit stuff on D2 2019-12-12 17:25:11 +02:00
Kp 87125c5053 Fix Descent 1 laser color
Descent 1 mangles colors during `g3_init_polygon_model`, so this must
not be called on polygons not designed for mangling.  Rearrange the
logic to allow Descent 1 to verify that polygon models are well-formed
without using the functions that mangle the colors.

Fixes: 42a2e3ab0b ("Avoid crash loading polymodels with invalid subcalls")
Reported-by: derhass <https://github.com/dxx-rebirth/dxx-rebirth/issues/416>
2019-03-20 03:57:15 +00:00
Kp 42a2e3ab0b Avoid crash loading polymodels with invalid subcalls
Truncate the model at the first error.  This allows the level to load,
but makes some or all of the model invisible.
2019-03-06 05:03:48 +00:00
Kp 03fe3a6696 Move Polygon_models into LevelSharedPolygonModelState 2018-12-30 00:43:59 +00:00
Kp 1831148092 Split g3_start_instance_matrix usage
Most uses pass an orientation matrix.  All sites are deterministic about
whether a matrix is passed.  Make the matrix mandatory for sites that
passed it, and split out a separate version of g3_start_instance_matrix
for the 2 sites which do not provide orientation.
2017-08-26 19:47:51 +00:00
Kp c3a438b750 Pass draw_polygon_model orient by reference 2017-08-11 23:43:54 +00:00
Kp 1a1e669bc6 Pass vms_angvec &to draw_model_picture 2017-04-30 16:25:16 +00:00
Kp a6cd87613c Pass polymodel &to free_model 2017-02-19 19:33:44 +00:00
Kp 1a7659897a Pass canvas to draw_model_picture 2017-02-19 19:33:44 +00:00
Kp b02e2e9a3a Use range_for in draw_polygon_model 2017-02-19 19:33:44 +00:00
Kp 39071d124d Pass canvas to draw_polygon_model 2017-02-19 19:33:43 +00:00
Kp 85da2c0013 Pass canvas to g3_draw_polygon_model 2017-02-11 21:42:40 +00:00