Click here to Skip to main content
15,894,179 members
Articles / Desktop Programming / Win32

Half Life Game Level Viewer

Rate me:
Please Sign up or sign in to vote.
4.61/5 (23 votes)
7 Feb 2009CPOL26 min read 80K   2.3K   60  
DirectX based application to open and view Half Life 1 game files
//
//	EntityParse.h
//
//	Copyright 2005 Paul Higinbotham
//

#ifndef __ENTITYPARSE_H_
#define __ENTITYPARSE_H_


#include "..\..\collections\String.h"


namespace ZGraphics
{

class NVPair;

class EntityParse
{
public:
	EntityParse()
	{
		_initMembers();
	}
	EntityParse(char * pBuf, int nBufSize)
	{
		_initMembers();

		assert(pBuf);
		assert(nBufSize > -1);
		m_pBuf = pBuf;
		m_nBufSize = nBufSize;
	}
	~EntityParse() {}


	int GetFirstEntity();
	int GetNextEntity();
	bool GetFirstNVPair(NVPair & rNV);
	bool GetNextNVPair(NVPair & rNV);

private:
	void _initMembers()
	{
		m_pBuf = 0;
		m_nBufSize = 0;
		m_nEntityIndex = 0;
		m_nNVIndex = 0;
	}
	bool _getNextString(cString & rString);

private:
	char *				m_pBuf;
	int					m_nBufSize;
	int					m_nEntityIndex;
	int					m_nNVIndex;
	//
	static const char	s_charOpenBracket;
	static const char	s_charCloseBracket;
	static const char	s_charQuote;
	static const char	s_charLF;
};


class NVPair
{
public:
	NVPair() : m_ulNameTag(0) {}
	~NVPair() {}

	cString			m_Name;
	cString			m_Value;
	unsigned long	m_ulNameTag;
};


} /* namespace ZGraphics */


#endif /* __ENTITYPARSE_H_ */

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
I am a senior software developer currently doing contract work for Microsoft. My educational background is in electrical engineering and I hold a masters degree from the University of Washington. I have experience in hardware and systems design but have done primarily software development for the last two decades. I have worked for various small companies as well as start-up companies, and have worked as a full time employee SDE at Microsoft Corporation.

Comments and Discussions