/// <summary> /// Get lump type (by name and id) /// </summary> public Rott2DMarkerType isASCIIType(string name, int id) { Rott2DMarkerType mkrType = Rott2DMarkerType.mtUnknown; /* * Remarks: * Since c# doesn't support ranges in a switch-case statement, * we'll have to do it with slower processing if-then statements. * */ if ((name == "VENDOR") || (name == "TABLES") || (name == "GUSMIDI") || (name == "SHARTITL") || (name == "SHARTIT2") || (name == "LICENSE")) { mkrType = Rott2DMarkerType.mtASCII; //text } return(mkrType); }
/// <summary> /// Get lump type (by data) /// </summary> public Rott2DMarkerType getLumpType(byte[] data) { Rott2DMarkerType mkrType = Rott2DMarkerType.mtUnknown; /* * If data is larger then zero, start processing. * * First we process all simple data structure = fast * Then, we also keep in mind what data types are most common (in WAD and for loading). * * Remarks: * Since c# doesn't support ranges in a switch-case statement, * we'll have to do it with slower processing if-then statements. * */ if (data.Length > 0) { //okay, larger the zero -> start processing //sky if (Rott2DSky.isSkyTexture(data)) { mkrType = Rott2DMarkerType.mtSky; } else { //pic_t if (Rott2DPic.isPicTexture(data)) { mkrType = Rott2DMarkerType.mtPic; } else { //patch (lpic_t) if (Rott2DPatch.isPatchTexture(data)) { mkrType = Rott2DMarkerType.mtPatch; } else { //colormap if (Rott2DColormap.isColormap(data)) { mkrType = Rott2DMarkerType.mtColormap; } else { //masked if (Rott2DMasked.isMaskedTexture(data)) { mkrType = Rott2DMarkerType.mtMasked; } else { //transmasked if (Rott2DTransMasked.isTransMaskedTexture(data)) { mkrType = Rott2DMarkerType.mtTransMasked; } else { //flat (moved checking of flat and palette after // all header type lumps, to prevent incorrect checking.) if (Rott2DFlat.isFlatTexture(data)) { mkrType = Rott2DMarkerType.mtFlat; } else { //palette if (Rott2DPalette.isPalette(data)) { mkrType = Rott2DMarkerType.mtPalette; } else { //sound (voc data) if (Rott2DVoc.isSoundLump(data)) { mkrType = Rott2DMarkerType.mtSound; } else { //music (midi data) if (Rott2DMidi.isMidiLump(data)) { mkrType = Rott2DMarkerType.mtMusic; } //midi } //sound } //palette } //flat } //trans masked } //masked } //colormap } //patch } //pic } //sky } //else unknown (unknown = ascii, pcspeaker, fonts, ...) #if DEBUG MessageBox.Show(mkrType.ToString()); //fast dirty DEBUG #endif return(mkrType); }