From 6a3246fe93ac0796aa2d16adbfeddcfab3a347ef Mon Sep 17 00:00:00 2001 From: Stan Date: Tue, 16 Feb 2021 10:51:23 +0000 Subject: [PATCH] Fix variant loading order file="" properties were not overriden by other things defined in the actor, which lead to weird edge cases, such as frequency="0" variants being loaded because their names="" ended up matching their parent's name="" Also remove the name because it doesn't serve a purpose Accepted by: @wraitii Differential Revision: https://code.wildfiregames.com/D3572 This was SVN commit r24929. --- .../art/variants/structures/defensive_building.xml | 2 +- source/graphics/ObjectBase.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/binaries/data/mods/public/art/variants/structures/defensive_building.xml b/binaries/data/mods/public/art/variants/structures/defensive_building.xml index e99fa8498b..a2f009136c 100644 --- a/binaries/data/mods/public/art/variants/structures/defensive_building.xml +++ b/binaries/data/mods/public/art/variants/structures/defensive_building.xml @@ -1,5 +1,5 @@ - + diff --git a/source/graphics/ObjectBase.cpp b/source/graphics/ObjectBase.cpp index 837bb82a21..31a1b6dadd 100644 --- a/source/graphics/ObjectBase.cpp +++ b/source/graphics/ObjectBase.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -80,6 +80,7 @@ void CObjectBase::LoadVariant(const CXeromyces& XeroFile, const XMBElement& vari return; } + // Load variants first, so that they can be overriden if necessary. XERO_ITER_ATTR(variant, attr) { if (attr.Name == at_file) @@ -97,7 +98,11 @@ void CObjectBase::LoadVariant(const CXeromyces& XeroFile, const XMBElement& vari LOGERROR("Could not open path %s", attr.Value); // Continue loading extra definitions in this variant to allow nested files } - else if (attr.Name == at_name) + } + + XERO_ITER_ATTR(variant, attr) + { + if (attr.Name == at_name) currentVariant.m_VariantName = attr.Value.LowerCase(); else if (attr.Name == at_frequency) currentVariant.m_Frequency = attr.Value.ToInt();