From 5bb3e70344cfafa8c09561b6d7d157026ce18b4f Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 21 Jan 2005 00:52:26 +0000 Subject: Initial checkin --- WADEntry.cs | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 WADEntry.cs (limited to 'WADEntry.cs') diff --git a/WADEntry.cs b/WADEntry.cs new file mode 100644 index 0000000..d43da68 --- /dev/null +++ b/WADEntry.cs @@ -0,0 +1,143 @@ +// Noddybox.DOOM - DOOM WAD Wrapper +// Copyright (C) 2004 Ian Cowburn +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// +using System; +using System.IO; + +namespace Noddybox.DOOM +{ + /// + /// Describes a directory entry in a WAD file + /// + public class WADEntry + { + // ==================================== + // PUBLIC + // ==================================== + + /// + /// Create an empty lump + /// + public WADEntry() + { + Name="LUMP"; + Data=null; + } + + /// + /// Create a lump + /// + /// The name + /// The data + public WADEntry(string name, byte[] data) + { + Name=name; + Data=data; + } + + /// + /// Create a lump + /// + /// The lump to copy + public WADEntry(WADEntry we) + { + Name=we.Name; + Data=(byte[])we.Data.Clone(); + } + + /// + /// Get/set the lump's name + /// + public string Name + { + get {return m_name;} + set + { + m_name=value; + + if (m_name.Length>8) + { + m_name=m_name.Substring(0,8); + } + + m_name=m_name.Trim(new char[] {'\0'}); + } + } + + /// + /// Get the length of the lump's data + /// + public int Length + { + get {return m_length;} + } + + /// + /// Get/set the lump data + /// + public byte[] Data + { + get {return m_data;} + set + { + m_data=value; + + if (m_data!=null) + { + m_length=m_data.Length; + } + else + { + m_length=0; + } + } + } + + /// + /// Index into the lump data as bytes + /// + public byte this[int index] + { + get {return m_data[index];} + set {m_data[index]=value;} + } + + /// + /// Index into the lump data as bytes + /// + public byte this[uint index] + { + get {return m_data[index];} + set {m_data[index]=value;} + } + + /// + /// Get the lump data as a MemoryStream + /// + public MemoryStream Stream + { + get {return new MemoryStream(m_data);} + } + + // ==================================== + // PRIVATE + // ==================================== + private string m_name; + private int m_length; + private byte[] m_data; + } +} -- cgit v1.2.3