private bool ApplychkAll(BinaryReader br) { cHKTokens = new List <CHKToken>(); br.BaseStream.Position = 0; while (br.BaseStream.Position < br.BaseStream.Length) { if (!Applychk(br)) { return(false); } } if (TILE == null) { TILE = (ushort[])MTXM.Clone(); } if (BYTESTRx == null) { BYTESTRx = BYTESTR; } if (LOADSTRx == null) { LOADSTRx = (string[])LOADSTR.Clone(); } if (IOWN == null) { //IOWN = (byte[])OWNR.Clone(); throw new Exception(""); } //만약 인코딩이 없을 경우 if (ENCODING == null) { ENCODING = System.Text.Encoding.UTF8; EncodingSelectDialog encodingSelectDialog = new EncodingSelectDialog(this); encodingSelectDialog.ShowDialog(); } for (int i = 0; i < BYTESTRx.Count; i++) { //여기서 작업해준다. string s = ENCODING.GetString(BYTESTRx[i]); LOADSTRx[i] = UseMapEditor.Tools.StringTool.ReadRawString(s); } for (int i = 0; i < DD2.Count; i++) { DoodadPallet pallete = UseMapEditor.Global.WindowTool.MapViewer.tileSet.DoodadPallets[TILETYPE][DD2[i].ID];; if (THG2.Exists(x => (x.X == DD2[i].X) & (x.Y == DD2[i].Y))) { CTHG2 s = THG2.Find(x => (x.X == DD2[i].X) & (x.Y == DD2[i].Y)); if (s.ID == pallete.dddOverlayID) { THG2.Remove(s); } } } TriggerLoad(); //soundDatas uint hmpq = OpenArchive(); soundDatas.Clear(); for (int i = 0; i < WAV.Length; i++) { string d = WAV[i].String; if (WAV[i].IsLoaded) { SoundData soundData = new SoundData(); soundData.path = d; soundData.bytes = ReadMPQFileC(hmpq, d); if (soundData.bytes.Length != 0) { soundDatas.Add(soundData); } } } CloseArchive(hmpq); return(true); }
private bool Applychk(BinaryReader br) { CHKToken cHKToken = GetNextCHK(br); br.BaseStream.Position = cHKToken.start; //Byte로부터 에디터로 넣는 함수 switch (cHKToken.tokentype) { case TOKENTYPE.ENCD: SetEncoding(br.ReadInt32()); break; case TOKENTYPE.IOWN: IOWN = br.ReadBytes(12); break; case TOKENTYPE.OWNR: //넘기기 OWNR = br.ReadBytes(12); break; case TOKENTYPE.SIDE: SIDE = br.ReadBytes(12); break; case TOKENTYPE.ERA: ushort tile = br.ReadUInt16(); if (tile > 7) { throw new Exception(""); } TILETYPE = (TileType)tile; break; case TOKENTYPE.COLR: COLR = br.ReadBytes(8); for (int i = 0; i < 8; i++) { if (COLR[i] >= ColorName.Count()) { COLR[i] = 0; } CRGB[i] = new Microsoft.Xna.Framework.Color(0, 0, COLR[i]); } break; case TOKENTYPE.CRGB: for (int i = 0; i < 8; i++) { byte[] colors = br.ReadBytes(3); CRGB[i] = new Microsoft.Xna.Framework.Color(colors[0], colors[1], colors[2]); } CRGBIND = br.ReadBytes(8); break; case TOKENTYPE.UNIT: UNIT.Clear(); for (int i = 0; i < cHKToken.size / 36; i++) { CUNIT cUNIT = new CUNIT(br); cUNIT.SetMapEditor(mapEditor); UNIT.Add(cUNIT); } break; case TOKENTYPE.DIM: WIDTH = br.ReadUInt16(); HEIGHT = br.ReadUInt16(); break; case TOKENTYPE.TILE: TILE = new ushort[cHKToken.size / 2]; for (int i = 0; i < cHKToken.size / 2; i++) { TILE[i] = br.ReadUInt16(); } break; case TOKENTYPE.MTXM: MTXM = new ushort[cHKToken.size / 2]; for (int i = 0; i < cHKToken.size / 2; i++) { MTXM[i] = br.ReadUInt16(); } break; case TOKENTYPE.DD2: for (int i = 0; i < cHKToken.size / 8; i++) { CDD2 cDD2 = new CDD2(br, this); DD2.Add(cDD2); } break; case TOKENTYPE.THG2: for (int i = 0; i < cHKToken.size / 10; i++) { CTHG2 cTHG2 = new CTHG2(br); THG2.Add(cTHG2); } break; case TOKENTYPE.MASK: MASK = br.ReadBytes((int)cHKToken.size); break; case TOKENTYPE.STR: { long startpoint = br.BaseStream.Position; LOADSTR = new string[br.ReadUInt16()]; BYTESTR = new List <byte[]>(); ushort[] ptrs = new ushort[LOADSTR.Length]; for (int i = 0; i < ptrs.Length; i++) { ptrs[i] = br.ReadUInt16(); } for (int i = 0; i < ptrs.Length; i++) { br.BaseStream.Position = startpoint + ptrs[i]; List <byte> strs = new List <byte>(); byte readbyte = br.ReadByte(); if (readbyte != 0) { strs.Add(readbyte); while (true) { readbyte = br.ReadByte(); if (readbyte == 0) { break; } strs.Add(readbyte); } } BYTESTR.Add(strs.ToArray()); //LOADSTR[i] = System.Text.Encoding.GetEncoding(949).GetString(strs.ToArray()); } } break; case TOKENTYPE.STRx: { long startpoint = br.BaseStream.Position; LOADSTRx = new string[br.ReadUInt32()]; BYTESTRx = new List <byte[]>(); uint[] ptrs = new uint[LOADSTRx.Length]; for (int i = 0; i < ptrs.Length; i++) { ptrs[i] = br.ReadUInt32(); } for (int i = 0; i < ptrs.Length; i++) { br.BaseStream.Position = startpoint + ptrs[i]; List <byte> strs = new List <byte>(); byte readbyte = br.ReadByte(); if (readbyte != 0) { strs.Add(readbyte); while (true) { readbyte = br.ReadByte(); if (readbyte == 0) { break; } strs.Add(readbyte); } } BYTESTRx.Add(strs.ToArray()); //LOADSTRx[i] = System.Text.Encoding.UTF8.GetString(strs.ToArray()); } } break; case TOKENTYPE.SPRP: SCEARIONAME = new StringData(this, br.ReadUInt16()); SCEARIODES = new StringData(this, br.ReadUInt16()); break; case TOKENTYPE.FORC: FORCE = br.ReadBytes(8); FORCENAME = new StringData[4]; FORCENAME[0] = new StringData(this, br.ReadUInt16()); FORCENAME[1] = new StringData(this, br.ReadUInt16()); FORCENAME[2] = new StringData(this, br.ReadUInt16()); FORCENAME[3] = new StringData(this, br.ReadUInt16()); FORCEFLAG = br.ReadBytes(4); break; case TOKENTYPE.MRGN: LocationDatas.Clear(); LocationDatas.Add(new LocationData(mapEditor)); for (int i = 0; i < 255; i++) { LocationData locationData = new LocationData(mapEditor); locationData.INDEX = i + 1; locationData.L = br.ReadUInt32(); locationData.T = br.ReadUInt32(); locationData.R = br.ReadUInt32(); locationData.B = br.ReadUInt32(); locationData.STRING = new StringData(this, br.ReadUInt16()); locationData.FLAG = br.ReadUInt16(); if (locationData.L == 0 & locationData.T == 0 & locationData.L == 0 & locationData.T == 0 & locationData.STRING.LoadedIndex == -1 & locationData.FLAG == 0) { continue; } LocationDatas.Add(locationData); } //u32: Left(X1) coordinate of location, in pixels(usually 32 pt grid aligned) //u32: Top(Y1) coordinate of location, in pixels //u32: Right(X2) coordinate of location, in pixels //u32: Bottom(Y2) coordinate of location, in pixels //u16: String number of the name of this location //u16: Location elevation flags.If an elevation is disabled in the location, it's bit will be on (1) //Bit 0 - Low elevation //Bit 1 - Medium elevation //Bit 2 - High elevation //Bit 3 - Low air //Bit 4 - Medium air //Bit 5 - High air //Bit 6 - 15 - Unused break; case TOKENTYPE.UPRP: UPRP = new CUPRP[64]; for (int i = 0; i < 64; i++) { CUPRP cUPRP = new CUPRP(); cUPRP.STATUSVALID = br.ReadUInt16(); cUPRP.POINTVALID = br.ReadUInt16(); cUPRP.PLAYER = br.ReadByte(); cUPRP.HITPOINT = br.ReadByte(); cUPRP.SHIELDPOINT = br.ReadByte(); cUPRP.ENERGYPOINT = br.ReadByte(); cUPRP.RESOURCE = br.ReadUInt32(); cUPRP.HANGAR = br.ReadUInt16(); cUPRP.STATUSFLAG = br.ReadUInt16(); cUPRP.UNUSED = br.ReadUInt32(); UPRP[i] = cUPRP; } break; case TOKENTYPE.UPUS: UPUS = br.ReadBytes(64); break; case TOKENTYPE.WAV: WAV = new StringData[512]; for (int i = 0; i < 512; i++) { WAV[i] = new StringData(this, br.ReadInt32()); } break; case TOKENTYPE.SWNM: SWNM = new StringData[256]; for (int i = 0; i < 256; i++) { SWNM[i] = new StringData(this, br.ReadInt32()); } break; case TOKENTYPE.PUNI: PUNI = new CPUNI(); for (int i = 0; i < 12; i++) { PUNI.UNITENABLED[i] = br.ReadBytes(228); } PUNI.DEFAULT = br.ReadBytes(228); for (int i = 0; i < 12; i++) { PUNI.USEDEFAULT[i] = br.ReadBytes(228); } break; case TOKENTYPE.PUPx: PUPx = new CPUPx(); for (int i = 0; i < 12; i++) { PUPx.MAXLEVEL[i] = br.ReadBytes(61); } for (int i = 0; i < 12; i++) { PUPx.STARTLEVEL[i] = br.ReadBytes(61); } PUPx.DEFAULTMAXLEVEL = br.ReadBytes(61); PUPx.DEFAULTSTARTLEVEL = br.ReadBytes(61); for (int i = 0; i < 12; i++) { PUPx.USEDEFAULT[i] = br.ReadBytes(61); } break; case TOKENTYPE.PTEx: PTEx = new CPTEx(); for (int i = 0; i < 12; i++) { PTEx.MAXLEVEL[i] = br.ReadBytes(44); } for (int i = 0; i < 12; i++) { PTEx.STARTLEVEL[i] = br.ReadBytes(44); } PTEx.DEFAULTMAXLEVEL = br.ReadBytes(44); PTEx.DEFAULTSTARTLEVEL = br.ReadBytes(44); for (int i = 0; i < 12; i++) { PTEx.USEDEFAULT[i] = br.ReadBytes(44); } break; case TOKENTYPE.UNIx: UNIx = new CUNIx(); for (int i = 0; i < 228; i++) { UNIx.USEDEFAULT[i] = br.ReadByte(); } for (int i = 0; i < 228; i++) { UNIx.HIT[i] = br.ReadUInt32(); } for (int i = 0; i < 228; i++) { UNIx.SHIELD[i] = br.ReadUInt16(); } for (int i = 0; i < 228; i++) { UNIx.ARMOR[i] = br.ReadByte(); } for (int i = 0; i < 228; i++) { UNIx.BUILDTIME[i] = br.ReadUInt16(); } for (int i = 0; i < 228; i++) { UNIx.MIN[i] = br.ReadUInt16(); } for (int i = 0; i < 228; i++) { UNIx.GAS[i] = br.ReadUInt16(); } for (int i = 0; i < 228; i++) { UNIx.STRING[i] = new StringData(this, br.ReadUInt16()); } for (int i = 0; i < 130; i++) { UNIx.DMG[i] = br.ReadUInt16(); } for (int i = 0; i < 130; i++) { UNIx.BONUSDMG[i] = br.ReadUInt16(); } break; case TOKENTYPE.UPGx: UPGx = new CUPGx(); for (int i = 0; i < 61; i++) { UPGx.USEDEFAULT[i] = br.ReadByte(); } br.ReadByte(); for (int i = 0; i < 61; i++) { UPGx.BASEMIN[i] = br.ReadUInt16(); } for (int i = 0; i < 61; i++) { UPGx.BONUSMIN[i] = br.ReadUInt16(); } for (int i = 0; i < 61; i++) { UPGx.BASEGAS[i] = br.ReadUInt16(); } for (int i = 0; i < 61; i++) { UPGx.BONUSGAS[i] = br.ReadUInt16(); } for (int i = 0; i < 61; i++) { UPGx.BASETIME[i] = br.ReadUInt16(); } for (int i = 0; i < 61; i++) { UPGx.BONUSTIME[i] = br.ReadUInt16(); } break; case TOKENTYPE.TECx: TECx = new CTECx(); for (int i = 0; i < 44; i++) { TECx.USEDEFAULT[i] = br.ReadByte(); } for (int i = 0; i < 44; i++) { TECx.MIN[i] = br.ReadUInt16(); } for (int i = 0; i < 44; i++) { TECx.GAS[i] = br.ReadUInt16(); } for (int i = 0; i < 44; i++) { TECx.BASETIME[i] = br.ReadUInt16(); } for (int i = 0; i < 44; i++) { TECx.ENERGY[i] = br.ReadUInt16(); } break; case TOKENTYPE.TRIG: TRIG.Clear(); for (int i = 0; i < cHKToken.size / 2400; i++) { RAWTRIGMBRF trig = new RAWTRIGMBRF(br); TRIG.Add(trig); } break; case TOKENTYPE.MBRF: MBRF.Clear(); for (int i = 0; i < cHKToken.size / 2400; i++) { RAWTRIGMBRF mbrf = new RAWTRIGMBRF(br); MBRF.Add(mbrf); } break; } for (int i = 0; i < cHKTokens.Count; i++) { if (cHKTokens[i].code == cHKToken.code) { cHKTokens.RemoveAt(i); break; } } cHKTokens.Add(cHKToken); br.BaseStream.Position = cHKToken.end; return(true); }
public void MapDataReset() { cHKTokens = new List <CHKToken>(); for (int i = 0; i < 8; i++) { CRGB[i] = new Microsoft.Xna.Framework.Color(0, 0, 0); CRGBIND[i] = (byte)CRGBINDTYPE.UseCOLRselection; COLR[i] = (byte)i; } UNIT.Clear(); FORCE = new byte[8]; FORCENAME = new StringData[4]; FORCENAME[0] = new StringData(this, "세력 1"); FORCENAME[1] = new StringData(this, "세력 2"); FORCENAME[2] = new StringData(this, "세력 3"); FORCENAME[3] = new StringData(this, "세력 4"); SIDE = new byte[12]; FORCEFLAG = new byte[4]; WIDTH = 0; HEIGHT = 0; MASK = null; MTXM = null; TILE = null; BYTESTR = null; BYTESTRx = null; LOADSTR = null; LOADSTRx = null; IOWN = null; OWNR = null; //LocationDatas.Add(new LocationData()); SCEARIONAME = new StringData(this, "제목 없음"); SCEARIODES = new StringData(this, "시나리오 설명이 없습니다."); ENCODING = null;// System.Text.Encoding. DD2.Clear(); THG2.Clear(); DDDTHG2.Clear(); LocationDatas.Clear(); LocationDatas.Add(new LocationData(mapEditor)); UPRP = new CUPRP[64]; for (int i = 0; i < 64; i++) { UPRP[i] = new CUPRP(); } UPUS = new byte[64]; WAV = new StringData[512]; for (int i = 0; i < 512; i++) { WAV[i] = new StringData(this); } SWNM = new StringData[256]; for (int i = 0; i < 256; i++) { SWNM[i] = new StringData(this); } TRIG.Clear(); MBRF.Clear(); PUNI = new CPUNI(true); PUPx = new CPUPx(true); PTEx = new CPTEx(true); UNIx = new CUNIx(this, true); UPGx = new CUPGx(true); TECx = new CTECx(true); soundDatas = new List <SoundData>(); Triggers.Clear(); Brifings.Clear(); }