private void ReadBehaviorCopy(Reader reader, Pointer offset, AIModel ai) { Behavior b = Behavior.Read(reader, offset); if (b != null && ai != null && ai.behaviors_normal != null) { foreach (Behavior originalBehavior in ai.behaviors_normal) { if (b.ContentEquals(originalBehavior)) { originalBehavior.copies.Add(b.offset); b = null; break; } } } if (b != null && ai != null && ai.behaviors_reflex != null) { foreach (Behavior originalBehavior in ai.behaviors_reflex) { if (b.ContentEquals(originalBehavior)) { originalBehavior.copies.Add(b.offset); b = null; break; } } } if (b != null && behaviors != null) { foreach (Behavior originalBehavior in behaviors) { if (b.ContentEquals(originalBehavior)) { originalBehavior.copies.Add(b.offset); b = null; break; } } } }
private void ReadLog(Stream logStream) { string logPattern = @"^0x(?<offset>[a-fA-F0-9]+?) : \((?<type>[^\)]+?)\)(?<name>.*?) 0x(?<offset2>[a-fA-F0-9]+?)$"; string comportNamePattern = @"^(?<family>[^\\]+?)\\(?<model>[^\\]+?)\\(?<model2>[^\\]+?)\.(?<type>...?)\^.*$"; DCDAT file = files_array[0] as DCDAT; using (StreamReader sr = new StreamReader(logStream)) { while (sr.Peek() >= 0) { string line = sr.ReadLine().Trim(); Match logMatch = Regex.Match(line, logPattern, RegexOptions.IgnoreCase); if (logMatch.Success) { string offsetStr = logMatch.Groups["offset"].Value; string type = logMatch.Groups["type"].Value; string name = logMatch.Groups["name"].Value; string offset2Str = logMatch.Groups["offset2"].Value; if (offsetStr.Length < 8) { offsetStr = new String('0', offsetStr.Length - 8) + offsetStr; } uint offsetUint = Convert.ToUInt32(offsetStr, 16); Pointer offset = file.GetUnsafePointer(offsetUint); switch (type) { case "eST_Comport": Behavior b = Behavior.FromOffset(offset); if (b == null) { Match comportMatch = Regex.Match(name, comportNamePattern, RegexOptions.IgnoreCase); if (comportMatch.Success) { string modelName = comportMatch.Groups["model"].Value; AIModel aiModel = aiModels.FirstOrDefault(ai => ai.name == modelName); Reader reader = files_array[Mem.Fix].reader; Pointer.DoAt(ref reader, offset, () => { Behavior newB = Behavior.Read(reader, offset); if (aiModel != null && newB != null) { switch (comportMatch.Groups["type"].Value) { case "rul": foreach (Behavior originalBehavior in aiModel.behaviors_normal) { if (newB.ContentEquals(originalBehavior)) { originalBehavior.copies.Add(newB.offset); b = originalBehavior; break; } } break; case "rfx": foreach (Behavior originalBehavior in aiModel.behaviors_reflex) { if (newB.ContentEquals(originalBehavior)) { originalBehavior.copies.Add(newB.offset); b = originalBehavior; break; } } break; } } }); } } if (b != null) { b.name = name; } /*if (name.Contains("piranha\\MIC_PiranhaSauteurVisible\\MIC_PiranhaSauteurVisible")) { * print("Offset: " + offset + " - " + b); * }*/ break; case "eST_State": State state = State.FromOffset(offset); if (state != null) { state.name = name; } break; case "eST_Anim3d": AnimationReference ar = FromOffset <AnimationReference>(offset); if (ar != null) { ar.name = name; } break; case "eST_Graph": Graph g = Graph.FromOffset(offset); if (g != null) { g.name = name; } break; case "eST_Sector": Sector s = Sector.FromOffset(offset); if (s != null) { s.name = name; s.Gao.name = name; } break; } } } } }