⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gameerrors.h

📁 这是一个屠宰场游戏,此游戏很休闲的请大家下载来看看.
💻 H
字号:
/*******************************************************************
 *         Advanced 3D Game Programming using DirectX 7.0
 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 *   Title: GameErrors.h
 *    Desc: errors that game functions can have
 *          
 * copyright (c) 1999 by Adrian Perez
 * See license.txt for modification and distribution information
 ******************************************************************/

#ifndef _GAMEERRORS_H
#define _GAMEERRORS_H

#include <string>
#include "GameGlobals.h"

//==========--------------------------  

/**
 * This code is slow, using dynamic memory, but since we only use them
 * when something Really Bad happens, the user won't notice that their
 * application exits abmornally a few nanoseconds slower than usual
 */
class cGameError
{
	std::string m_errorText;
public:
	cGameError( const char* errorText )
	{
		DP1("***\n*** [ERROR] cGameError thrown! text: [%s]\n***\n", errorText );
		m_errorText = std::string( errorText );
	}

	const char* GetText()
	{
		return m_errorText.c_str();
	}
};

//==========--------------------------  

enum eResult
{
	resAllGood		= 0, // function passed with flying colors
	resFalse		= 1, // function worked and returns value 'false'
	resFailed		= -1, // function failed miserably
	resNotImpl		= -2, // function has not been implemented
	resForceDWord = 0x7FFFFFFF
};

inline bool Succeeded( eResult in )
{
	if( in >= 0 )
		return true;
	return false;
}

inline bool Failed( eResult in )
{
	if( in < 0 )
		return true;
	return false;
}

/**
 * The Right Way to release our COM interfaces.
 * If they're still valid, release them, then
 * invalidate them.
 */
template <class T>
inline void SafeRelease( T& iface )
{
	if( iface )
	{
		iface->Release();
		iface = NULL;
	}
}


/**
 * Make sure the release brings our refcount to 0.
 */
template <class T>
inline void ExtraSafeRelease( T& iface )
{
	long refCount = 0;

	if( iface )
	{
		if( 0 < ( refCount = iface->Release() ) )
		{
			DP0("[ExtraSafeRelease]: ERROR: Interface was not released enough!");
		}
		iface = NULL;
	}
}

#endif //_GAMEERRORS_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -