1
0
forked from 0ad/0ad

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.
This commit is contained in:
Stan 2021-02-16 10:51:23 +00:00
parent 110402eae0
commit 6a3246fe93
2 changed files with 8 additions and 3 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<variant name="Base Defensive Building">
<variant>
<animations>
<!-- Note this doesn't do anything because buildings don't have dae animations
The real sound is forced by BuildingAI while it should use the C++ code. -->

View File

@ -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();