Fix CTD when object blueprint is missing

This commit is contained in:
Vsevolod Kremianskii 2021-04-20 08:23:21 +07:00
parent 38932c9aef
commit ea783f0f33
9 changed files with 22 additions and 9 deletions

View file

@ -75,8 +75,10 @@ void Creature::loadFromGIT(const GffStruct &gffs) {
void Creature::loadFromBlueprint(const string &resRef) {
shared_ptr<GffStruct> utc(Resources::instance().getGFF(resRef, ResourceType::Utc));
loadUTC(*utc);
loadAppearance();
if (utc) {
loadUTC(*utc);
loadAppearance();
}
}
void Creature::loadAppearance() {

View file

@ -63,6 +63,8 @@ void Door::loadFromGIT(const GffStruct &gffs) {
void Door::loadFromBlueprint(const string &resRef) {
shared_ptr<GffStruct> utd(Resources::instance().getGFF(resRef, ResourceType::Utd));
if (!utd) return;
loadUTD(*utd);
shared_ptr<TwoDA> doors(Resources::instance().get2DA("genericdoors"));

View file

@ -49,7 +49,6 @@ private:
};
bool _active { false };
int _difficulty { 0 };
int _difficultyIndex { 0 };
Faction _faction { Faction::Invalid };
int _maxCreatures { 0 };

View file

@ -36,8 +36,7 @@ void Encounter::loadUTE(const GffStruct &ute) {
_name = Strings::instance().get(ute.getInt("LocalizedName"));
_blueprintResRef = boost::to_lower_copy(ute.getString("TemplateResRef"));
_active = ute.getBool("Active");
_difficulty = ute.getInt("Difficulty");
_difficultyIndex = ute.getInt("DifficultyIndex");
_difficultyIndex = ute.getInt("DifficultyIndex"); // index into encdifficulty.2da
_faction = ute.getEnum("Faction", Faction::Invalid);
_maxCreatures = ute.getInt("MaxCreatures");
_playerOnly = ute.getBool("PlayerOnly");
@ -55,6 +54,7 @@ void Encounter::loadUTE(const GffStruct &ute) {
// Unused fields:
//
// - Difficulty (obsolete)
// - SpawnOption (always 1)
// - PaletteID (toolset only)
// - Comment (toolset only)

View file

@ -37,7 +37,9 @@ Item::Item(uint32_t id) : Object(id, ObjectType::Item) {
void Item::loadFromBlueprint(const string &resRef) {
shared_ptr<GffStruct> uti(Resources::instance().getGFF(resRef, ResourceType::Uti));
loadUTI(*uti);
if (uti) {
loadUTI(*uti);
}
}
void Item::playShotSound(int variant, glm::vec3 position) {

View file

@ -58,6 +58,8 @@ void Placeable::loadFromGIT(const GffStruct &gffs) {
void Placeable::loadFromBlueprint(const string &resRef) {
shared_ptr<GffStruct> utp(Resources::instance().getGFF(resRef, ResourceType::Utp));
if (!utp) return;
loadUTP(*utp);
shared_ptr<TwoDA> placeables(Resources::instance().get2DA("placeables"));

View file

@ -58,7 +58,9 @@ void Sound::loadFromGIT(const GffStruct &gffs) {
void Sound::loadFromBlueprint(const string &resRef) {
shared_ptr<GffStruct> uts(Resources::instance().getGFF(resRef, ResourceType::Uts));
loadUTS(*uts);
if (uts) {
loadUTS(*uts);
}
}
void Sound::loadTransformFromGIT(const GffStruct &gffs) {

View file

@ -86,7 +86,9 @@ void Trigger::loadGeometryFromGIT(const GffStruct &gffs) {
void Trigger::loadFromBlueprint(const string &resRef) {
shared_ptr<GffStruct> utt(Resources::instance().getGFF(resRef, ResourceType::Utt));
loadUTT(*utt);
if (utt) {
loadUTT(*utt);
}
}
void Trigger::update(float dt) {

View file

@ -63,7 +63,9 @@ void Waypoint::loadFromGIT(const GffStruct &gffs) {
void Waypoint::loadFromBlueprint(const string &resRef) {
shared_ptr<GffStruct> utw(Resources::instance().getGFF(resRef, ResourceType::Utw));
loadUTW(*utw);
if (utw) {
loadUTW(*utw);
}
}
void Waypoint::loadTransformFromGIT(const GffStruct &gffs) {