MCPcopy Create free account
hub / github.com/TurningWheel/Barony / generatePolyModels

Function generatePolyModels

src/files.cpp:4091–5151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4089#endif
4090
4091void generatePolyModels(int start, int end, bool forceCacheRebuild)
4092{
4093 const bool generateAll = start == 0 && end == nummodels;
4094 constexpr auto LARGEST_POLYMODEL_FACES_ALLOWED = (1<<17); // 131072
4095
4096 if ( generateAll )
4097 {
4098 if (polymodels) {
4099 for (int c = 0; c < nummodels; ++c) {
4100 if (polymodels[c].faces) {
4101 free(polymodels[c].faces);
4102 polymodels[c].faces = nullptr;
4103 }
4104 }
4105 free(polymodels);
4106 polymodels = nullptr;
4107 }
4108 polymodels = (polymodel_t*)malloc(sizeof(polymodel_t) * nummodels);
4109 memset(polymodels, 0, sizeof(polymodel_t) * nummodels);
4110 if ( useModelCache && !forceCacheRebuild )
4111 {
4112#ifndef NINTENDO
4113 std::string cache_path;
4114 if (isCurrentHoliday()) {
4115 const auto holiday = getCurrentHoliday();
4116 switch (holiday) {
4117 case HolidayTheme::THEME_NONE:
4118 cache_path = std::string(outputdir) + "/models.cache";
4119 break;
4120 default:
4121 cache_path = "models.cache";
4122 break;
4123 }
4124 } else {
4125 cache_path = std::string(outputdir) + "/models.cache";
4126 }
4127#else
4128 std::string cache_path = "models.cache";
4129#endif
4130 auto model_cache = openDataFile(cache_path.c_str(), "rb");
4131 if ( model_cache )
4132 {
4133 printlog("loading model cache...\n");
4134 char polymodelsVersionStr[7] = "v0.0.0";
4135 char modelsCacheHeader[7] = "000000";
4136 model_cache->read(&modelsCacheHeader, sizeof(char), strlen("BARONY"));
4137
4138 if ( !strcmp(modelsCacheHeader, "BARONY") )
4139 {
4140 // we're using the new polymodels file.
4141 model_cache->read(&polymodelsVersionStr, sizeof(char), strlen(VERSION));
4142 printlog("[MODEL CACHE]: Using updated version format %s.", polymodelsVersionStr);
4143 if ( strncmp(polymodelsVersionStr, VERSION, strlen(VERSION)) )
4144 {
4145 // different version.
4146 printlog("[MODEL CACHE]: Detected outdated version number %s - current is %s. Upgrading cache...", polymodelsVersionStr, VERSION);
4147 FileIO::close(model_cache);
4148 goto generate;

Callers 6

loadModelsMethod · 0.85
unloadModsMethod · 0.85
loadModsMethod · 0.85
reloadModelsFunction · 0.85
initAppFunction · 0.85
handleMainMenuFunction · 0.85

Calls 12

isCurrentHolidayFunction · 0.85
getCurrentHolidayFunction · 0.85
openDataFileFunction · 0.85
printlogFunction · 0.85
updateLoadingScreenFunction · 0.85
list_RemoveNodeFunction · 0.85
list_AddNodeLastFunction · 0.85
list_NodeFunction · 0.85
list_FreeAllFunction · 0.85
saveModelCacheFunction · 0.85
c_strMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected