mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- Fixed: Redefining a decal did not rebind any old references to the decal, so
they would be left pointing at invalid data. SVN r594 (trunk)
This commit is contained in:
parent
e666cde418
commit
acbe3a191e
4 changed files with 48 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
|||
December 10, 2007
|
||||
- Fixed: Redefining a decal did not rebind any old references to the decal, so
|
||||
they would be left pointing at invalid data.
|
||||
- Fixed some more GCC warnings.
|
||||
- Updated project files for nasm 2.0, which is now named nasm.exe for the
|
||||
Windows version, rather than nasmw.exe. Also fixed the annoying new warnings
|
||||
|
|
|
@ -66,6 +66,10 @@ class FDecalGroup : public FDecalBase
|
|||
public:
|
||||
FDecalGroup () : Choices (pr_decalchoice) {}
|
||||
const FDecalTemplate *GetDecal () const;
|
||||
void ReplaceDecalRef (FDecalBase *from, FDecalBase *to)
|
||||
{
|
||||
Choices.ReplaceValues(from, to);
|
||||
}
|
||||
void AddDecal (FDecalBase *decal, WORD weight)
|
||||
{
|
||||
Choices.AddEntry (decal, weight);
|
||||
|
@ -301,6 +305,14 @@ const FDecalTemplate *FDecalBase::GetDecal () const
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void FDecalTemplate::ReplaceDecalRef(FDecalBase *from, FDecalBase *to)
|
||||
{
|
||||
if (LowerDecal == from)
|
||||
{
|
||||
LowerDecal = to;
|
||||
}
|
||||
}
|
||||
|
||||
FDecalLib::FDecalLib ()
|
||||
{
|
||||
Root = NULL;
|
||||
|
@ -828,6 +840,17 @@ void FDecalLib::ParseCombiner ()
|
|||
}
|
||||
}
|
||||
|
||||
void FDecalLib::ReplaceDecalRef (FDecalBase *from, FDecalBase *to, FDecalBase *root)
|
||||
{
|
||||
if (root == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ReplaceDecalRef (from, to, root->Left);
|
||||
ReplaceDecalRef (from, to, root->Right);
|
||||
root->ReplaceDecalRef (from, to);
|
||||
}
|
||||
|
||||
void FDecalLib::AddDecal (const char *name, BYTE num, const FDecalTemplate &decal)
|
||||
{
|
||||
FDecalTemplate *newDecal = new FDecalTemplate;
|
||||
|
@ -873,6 +896,10 @@ void FDecalLib::AddDecal (FDecalBase *decal)
|
|||
}
|
||||
else
|
||||
{ // Yes, replace the old one.
|
||||
// If this decal has been used as the lowerdecal for another decal,
|
||||
// be sure and update the lowerdecal to use the new decal.
|
||||
ReplaceDecalRef(node, decal, Root);
|
||||
|
||||
decal->Left = node->Left;
|
||||
decal->Right = node->Right;
|
||||
*prev = decal;
|
||||
|
|
|
@ -52,6 +52,7 @@ class FDecalBase
|
|||
friend class FDecalLib;
|
||||
public:
|
||||
virtual const FDecalTemplate *GetDecal () const;
|
||||
virtual void ReplaceDecalRef (FDecalBase *from, FDecalBase *to) = 0;
|
||||
|
||||
protected:
|
||||
FDecalBase ();
|
||||
|
@ -71,6 +72,7 @@ public:
|
|||
|
||||
void ApplyToDecal (DBaseDecal *actor, side_s *wall) const;
|
||||
const FDecalTemplate *GetDecal () const;
|
||||
void ReplaceDecalRef (FDecalBase *from, FDecalBase *to);
|
||||
|
||||
fixed_t ScaleX, ScaleY;
|
||||
DWORD ShadeColor;
|
||||
|
@ -104,6 +106,7 @@ private:
|
|||
static void DelTree (FDecalBase *root);
|
||||
static FDecalBase *ScanTreeForNum (const BYTE num, FDecalBase *root);
|
||||
static FDecalBase *ScanTreeForName (const char *name, FDecalBase *root);
|
||||
static void ReplaceDecalRef (FDecalBase *from, FDecalBase *to, FDecalBase *root);
|
||||
FTranslation *GenerateTranslation (DWORD start, DWORD end);
|
||||
void AddDecal (const char *name, BYTE num, const FDecalTemplate &decal);
|
||||
void AddDecal (FDecalBase *decal);
|
||||
|
|
|
@ -66,6 +66,7 @@ class TWeightedList
|
|||
|
||||
void AddEntry (T value, WORD weight);
|
||||
T PickEntry () const;
|
||||
void ReplaceValues (T oldval, T newval);
|
||||
|
||||
private:
|
||||
Choice<T> *Choices;
|
||||
|
@ -148,3 +149,18 @@ void TWeightedList<T>::RecalcRandomVals ()
|
|||
choice->RandomVal = (BYTE)(randVal * 255.0);
|
||||
}
|
||||
}
|
||||
|
||||
// Replace all values that match oldval with newval
|
||||
template<class T>
|
||||
void TWeightedList<T>::ReplaceValues(T oldval, T newval)
|
||||
{
|
||||
Choice<T> *choice;
|
||||
|
||||
for (choice = Choices; choice != NULL; choice = choice->Next)
|
||||
{
|
||||
if (choice->Value == oldval)
|
||||
{
|
||||
choice->Value = newval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue