Move Pof_names to d_level_shared_polygon_model_state

This commit is contained in:
Kp 2020-08-24 01:31:28 +00:00
parent dca3c6cdca
commit c96671f763
3 changed files with 6 additions and 8 deletions

View file

@ -34,6 +34,7 @@ struct bitmap_index;
#include <cstddef>
#include <memory>
#include <physfs.h>
#include "inferno.h"
#include "pack.h"
#ifdef dsx
@ -46,9 +47,6 @@ constexpr std::integral_constant<unsigned, 85> MAX_POLYGON_MODELS{};
constexpr std::integral_constant<unsigned, 200> MAX_POLYGON_MODELS{};
#endif
// array of names of currently-loaded models
extern std::array<char[13], MAX_POLYGON_MODELS> Pof_names;
//for each model, a model number for dying & dead variants, or -1 if none
extern std::array<int, MAX_POLYGON_MODELS> Dying_modelnums, Dead_modelnums;
}
@ -118,6 +116,8 @@ namespace dsx {
struct d_level_shared_polygon_model_state : ::dcx::d_level_shared_polygon_model_state
{
std::array<polymodel, MAX_POLYGON_MODELS> Polygon_models;
// array of names of currently-loaded models
std::array<char[FILENAME_LEN], MAX_POLYGON_MODELS> Pof_names;
#if defined(DXX_BUILD_DESCENT_II)
//the model number of the marker object
uint32_t Marker_model_num = UINT32_MAX;

View file

@ -262,7 +262,7 @@ static void verify_object(const d_vclip_array &Vclip, object &obj, const savegam
if (obj.render_type == RT_POLYOBJ)
{
const auto name = Save_pof_names[obj.rtype.pobj_info.model_num];
for (auto &&[candidate_name, i] : enumerate(partial_range(Pof_names, LevelSharedPolygonModelState.N_polygon_models)))
for (auto &&[candidate_name, i] : enumerate(partial_range(LevelSharedPolygonModelState.Pof_names, LevelSharedPolygonModelState.N_polygon_models)))
if (!d_stricmp(candidate_name, name)) { //found it!
obj.rtype.pobj_info.model_num = i;
break;
@ -1731,7 +1731,7 @@ static int save_game_data(
{
const auto N_polygon_models = LevelSharedPolygonModelState.N_polygon_models;
PHYSFS_writeSLE16(SaveFile, N_polygon_models);
range_for (auto &i, partial_const_range(Pof_names, N_polygon_models))
range_for (auto &i, partial_const_range(LevelSharedPolygonModelState.Pof_names, N_polygon_models))
PHYSFS_write(SaveFile, &i, sizeof(i), 1);
}

View file

@ -573,8 +573,6 @@ void init_polygon_models(d_level_shared_polygon_model_state &LevelSharedPolygonM
namespace dsx {
std::array<char[FILENAME_LEN], MAX_POLYGON_MODELS> Pof_names;
//returns the number of this model
int load_polygon_model(const char *filename,int n_textures,int first_texture,robot_info *r)
{
@ -582,7 +580,7 @@ int load_polygon_model(const char *filename,int n_textures,int first_texture,rob
Assert(strlen(filename) <= 12);
const auto n_models = LevelSharedPolygonModelState.N_polygon_models;
strcpy(Pof_names[n_models], filename);
strcpy(LevelSharedPolygonModelState.Pof_names[n_models], filename);
auto &Polygon_models = LevelSharedPolygonModelState.Polygon_models;
auto &model = Polygon_models[n_models];