//mxd private static bool SectorIsSecret(Sector s) { SectorEffectData data = General.Map.Config.GetSectorEffectData(s.Effect); if (General.Map.DOOM) { // Sector is secret when it's Special is 9 or it has generalized flag 128 if (data.Effect == 9 || data.GeneralizedBits.Contains(128)) { return(true); } } else { //Hexen/UDMF: sector is secret when it has generalized flag 1024 if (data.GeneralizedBits.Contains(1024)) { return(true); } } return(false); }
public static bool PropertiesMatch(SectorPropertiesCopySettings flags, Sector source, Sector target) { // Built-in properties if (flags.FloorHeight && source.FloorHeight != target.FloorHeight) { return(false); } if (flags.CeilingHeight && source.CeilHeight != target.CeilHeight) { return(false); } if (flags.FloorTexture && source.FloorTexture != target.FloorTexture) { return(false); } if (flags.CeilingTexture && source.CeilTexture != target.CeilTexture) { return(false); } if (flags.Brightness && source.Brightness != target.Brightness) { return(false); } if (flags.Tag && !TagsMatch(source.Tags, target.Tags)) { return(false); } if (flags.Flags && !FlagsMatch(source.GetEnabledFlags(), target.GetEnabledFlags())) { return(false); } // Generalized effects require more tender loving care... if (flags.Special && source.Effect != target.Effect) { if (!General.Map.Config.GeneralizedEffects || source.Effect == 0 || target.Effect == 0) { return(false); } // Get effect bits... SectorEffectData sourcedata = General.Map.Config.GetSectorEffectData(source.Effect); SectorEffectData targetdata = General.Map.Config.GetSectorEffectData(target.Effect); // No bits match when at least one effect is not generalized, or when bits don't overlap if (sourcedata.Effect != targetdata.Effect || sourcedata.GeneralizedBits.Count != targetdata.GeneralizedBits.Count || !sourcedata.GeneralizedBits.Overlaps(targetdata.GeneralizedBits)) { return(false); } } if (!General.Map.UDMF) { return(true); } // UI fields if (!UIFieldsMatch(flags, source, target)) { return(false); } // Custom fields return(!flags.Fields || UniFields.CustomFieldsMatch(source.Fields, target.Fields)); }
// This is called to perform a search (and replace) // Returns a list of items to show in the results list // replacewith is null when not replacing public override FindReplaceObject[] Find(string value, bool withinselection, bool replace, string replacewith, bool keepselection) { List <FindReplaceObject> objs = new List <FindReplaceObject>(); // Interpret the replacement int replaceeffect = 0; if (replace) { // If it cannot be interpreted, set replacewith to null (not replacing at all) if (!int.TryParse(replacewith, out replaceeffect)) { replacewith = null; } if (replaceeffect < 0) { replacewith = null; } if (replaceeffect > Int16.MaxValue) { replacewith = null; } if (replacewith == null) { MessageBox.Show("Invalid replace value for this search type!", "Find and Replace", MessageBoxButtons.OK, MessageBoxIcon.Error); return(objs.ToArray()); } } // Interpret the number given int effect; if (int.TryParse(value, out effect)) { //mxd SectorEffectData sd = General.Map.Config.GetSectorEffectData(effect); // Where to search? ICollection <Sector> list = (withinselection ? General.Map.Map.GetSelectedSectors(true) : General.Map.Map.Sectors); // Go for all sectors foreach (Sector s in list) { bool match = false; //mxd. Effect matches? -1 means any effect if (effect == -1) { match = s.Effect > 0; } else if (effect == s.Effect) { match = true; } else if (General.Map.Config.GeneralizedEffects && effect != 0 && s.Effect != 0) { SectorEffectData sdo = General.Map.Config.GetSectorEffectData(s.Effect); match = (sd.Effect == sdo.Effect || (sd.GeneralizedBits.Count == sdo.GeneralizedBits.Count && sd.GeneralizedBits.Overlaps(sdo.GeneralizedBits))); } if (match) { // Replace if (replace) { s.Effect = replaceeffect; } SectorEffectInfo info = General.Map.Config.GetSectorEffectInfo(s.Effect); if (!info.IsNull) { objs.Add(new FindReplaceObject(s, "Sector " + s.Index + " (" + info.Title + ")")); } else { objs.Add(new FindReplaceObject(s, "Sector " + s.Index)); } } } } return(objs.ToArray()); }