Fixed several cases when sector/linedef tag changes were incorrectly recorded by undo system.

This commit is contained in:
MaxED 2016-07-06 00:15:19 +00:00 committed by spherallic
parent 972d55f066
commit 6a660c7d45
3 changed files with 22 additions and 14 deletions

View file

@ -3542,18 +3542,20 @@ namespace CodeImp.DoomBuilder.Map
{ {
//mxd. Multiple tags support... //mxd. Multiple tags support...
bool changed = false; bool changed = false;
for(int i = 0; i < s.Tags.Count; i++) // Make a copy of tags, otherwise BeforePropsChange will be triggered after tag changes
List<int> tags = new List<int>(s.Tags);
for(int i = 0; i < tags.Count; i++)
{ {
int tag = s.Tags[i]; int tag = tags[i];
handler(s, false, UniversalType.SectorTag, ref tag, obj); handler(s, false, UniversalType.SectorTag, ref tag, obj);
if(tag != s.Tags[i]) if(tag != tags[i])
{ {
s.Tags[i] = tag; tags[i] = tag;
changed = true; changed = true;
} }
} }
if(changed) s.Tags = s.Tags.Distinct().ToList(); if(changed) s.Tags = tags.Distinct().ToList();
} }
} }
@ -3601,18 +3603,20 @@ namespace CodeImp.DoomBuilder.Map
{ {
//mxd. Multiple tags support... //mxd. Multiple tags support...
bool changed = false; bool changed = false;
for(int i = 0; i < l.Tags.Count; i++) // Make a copy of tags, otherwise BeforePropsChange will be triggered after tag changes
List<int> tags = new List<int>(l.Tags);
for(int i = 0; i < tags.Count; i++)
{ {
int tag = l.Tags[i]; int tag = tags[i];
handler(l, false, UniversalType.LinedefTag, ref tag, obj); handler(l, false, UniversalType.LinedefTag, ref tag, obj);
if(tag != l.Tags[i]) if(tag != tags[i])
{ {
l.Tags[i] = tag; tags[i] = tag;
changed = true; changed = true;
} }
} }
if(changed) l.Tags = l.Tags.Distinct().ToList(); if(changed) l.Tags = tags.Distinct().ToList();
} }
} }
} }

View file

@ -129,8 +129,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Replace // Replace
if(replace) if(replace)
{ {
l.Tags[index] = replacetag; //mxd //mxd. Make a copy of tags, otherwise BeforePropsChange will be triggered after tag changes
l.Tags = l.Tags.Distinct().ToList(); //mxd. We don't want duplicates List<int> tags = new List<int>(l.Tags);
tags[index] = replacetag;
l.Tags = tags.Distinct().ToList(); // We don't want duplicates
} }
// Add to list // Add to list

View file

@ -122,8 +122,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Replace // Replace
if(replace) if(replace)
{ {
s.Tags[index] = replacetag; //mxd //mxd. Make a copy of tags, otherwise BeforePropsChange will be triggered after tag changes
s.Tags = s.Tags.Distinct().ToList(); //mxd. We don't want duplicates List<int> tags = new List<int>(s.Tags);
tags[index] = replacetag;
s.Tags = tags.Distinct().ToList(); // We don't want duplicates
} }
// Add to list // Add to list