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

📄 basedefs_de.h

📁 Blood 2全套源码
💻 H
📖 第 1 页 / 共 2 页
字号:

#ifndef __BASEDEFS_H__
#define __BASEDEFS_H__


	#include <stdlib.h>
	#include <string.h>

	#ifdef __cplusplus
		#define BEGIN_EXTERNC() extern "C" \
			{
		#define END_EXTERNC() };
	#else
		#define BEGIN_EXTERNC()
		#define END_EXTERNC()
	#endif
	

	#if !defined(__cplusplus) || defined(DIRECTENGINE_COMPILE)
		#define COMPILE_WITH_C
	#endif	
	
	#ifdef COMPILE_WITH_C
		#define LPBASECLASS struct BaseClass_t * 
		#define	LPAGGREGATE struct Aggregate_t *
	#else
		class BaseClass;
		#define LPBASECLASS BaseClass*
		class Aggregate;
		#define LPAGGREGATE Aggregate*
	#endif


	// Useful...
	#define SAFE_STRCPY(dest, src) \
	{\
		if(sizeof(dest) > 4)\
		{\
			strncpy(dest, src, sizeof(dest)-1);\
			dest[sizeof(dest)-1] = 0; \
		}\
		else\
		{\
			strcpy(dest, src);\
		}\
	}


	// Used in GetFileList/FreeFileList.
	#define TYPE_FILE		1
	#define TYPE_DIRECTORY	2
	
	typedef struct FileEntry_t
	{
		int			m_Type;				// Directory or file?
		char		*m_pBaseFilename;	// pic1.pcx
		char		*m_pFullFilename;	// interface/bitmaps/pic1.pcx
		struct FileEntry_t	*m_pNext;
	} FileEntry;


	// Used in the counter functions.
	typedef struct DCounter_t
	{
		unsigned long	m_Data[4];
	} DCounter;

	

	#define DEFINE_HANDLE_TYPE(name) \
		typedef struct {int __nothing;} ##name##_t, *name;


	#define MAX_CS_FILENAME_LEN	100

	// HMESSAGE defines

	// Maximum number of bytes in a grouped of messages of a communications message.
	#define MAX_PACKET_LEN		1024

	// Maxumum number of bytes in a message of a communications message.
	#define MAX_MESSAGE_LEN		1024

	// Maximum number of bytes a single object can save into MID_SAVEOBJECT message.
	#define MAX_SAVEOBJECT_LEN	8192


	// Model state flags.
	#define MS_PLAYDONE		1	// The (nonlooping) model has finished playing the animation.


	// HDECOLOR stuff.
	typedef unsigned long HDECOLOR;
	#define COLOR_TRANSPARENCY_MASK	0x80000000

	// r, g, and b, are 0-255 integers.
	#define SETRGB(r,g,b) \
		(((unsigned long)(r) << 16) | ((unsigned long)(g) << 8) | ((unsigned long)(b)))
		
	// r, g, and b are 0-1 floats.
	#define SETRGB_F(r,g,b) \
		(((unsigned long)((r)*255.0f) << 16) | ((unsigned long)((g)*255.0f) << 8) | ((unsigned long)((b)*255.0f)))

	// Setup a color with transparency.
	#define SETRGB_T(r,g,b)		(SETRGB((r),(g),(b)) | COLOR_TRANSPARENCY_MASK)
	#define SETRGB_FT(r,g,b)	(SETRGB_F((r),(g),(b)) | COLOR_TRANSPARENCY_MASK)

	// Gets r, g, and b as 0-255 integers.
	#define GETR(val) (((val) >> 16) & 0xFF)
	#define GETG(val) (((val) >> 8) & 0xFF)
	#define GETB(val) ((val) & 0xFF)
	#define GETRGB(val, r, g, b) \
	{\
		(r) = GETR(val);\
		(g) = GETG(val);\
		(b) = GETB(val);\
	}

	// Gets translucency value (into a 0 or 1 integer).
	#define GETT(val) (!!((val) & COLOR_TRANSPARENCY_MASK))

		
	class LMessage;
	typedef LMessage*		HMESSAGEREAD;
	typedef LMessage*		HMESSAGEWRITE;



	// Handle definitions.. it defines them in this wierd way so 
	// you can't accidentally cast between them.
	DEFINE_HANDLE_TYPE(HCLASS)
	DEFINE_HANDLE_TYPE(HSURFACE)
	DEFINE_HANDLE_TYPE(HDEFONT)
	DEFINE_HANDLE_TYPE(HSTRING)
	DEFINE_HANDLE_TYPE(HSOUNDDE)
	DEFINE_HANDLE_TYPE(HCLIENT);
	DEFINE_HANDLE_TYPE(HATTACHMENT);
	DEFINE_HANDLE_TYPE(HNETSERVICE);
	DEFINE_HANDLE_TYPE(HCONSOLEVAR);


	typedef unsigned long HMODELNODE;
	#define INVALID_MODEL_NODE ((HMODELNODE)-1)

	// Object handle definition.
	class DObject;
	typedef DObject* HOBJECT;
	typedef DObject* HLOCALOBJ;


	
	
	// ---------------------------------------------------------------- //
	// Here is the layout of all message IDs.
	// ---------------------------------------------------------------- //
	
	// Server->Client (0-255):
	// DirectEngine reserves 0-15 and defines:
	#define STC_BPRINT	0	// Used for debugging.. print a message in the console.

	// Client->Server (0-255):
	// DirectEngine reserves 0-15.

	// Object->Object (0-65k)
	// 0-1000 reserved.
	// 1000-2000 shared general messages (damage, I see you, etc..)
	// 2000-2500 Riot
	// 3500-4000 Blood 2
	// 4000-4500 Dreadon


	// This is used all over to classify which side of a polygon something's on.
	typedef enum
	{
		BackSide=0,
		FrontSide=1,
		Intersect=2
	} PolySide;


	
	// Include really base stuff.
	#include "basetypes_de.h"
	#include "de_codes.h"


	
	#define MAX_FORCEUPDATE_OBJECTS	200
	typedef struct
	{
		HOBJECT	*m_Objects; // This array is MAX_FORCEUPDATE_OBJECTS large.
		DDWORD	m_nObjects;
	} ForceUpdate;



	// This structure is used when creating objects.  When you want to
	// create an object, you call ServerDE::CreateObject with one of these.
	// The structure you pass in is passed to the object's PostPropRead function,
	// where it can override whatever it wants to.
	typedef struct ObjectCreateStruct_t
	{
		// Main info.
		unsigned short	m_ObjectType;
		DDWORD			m_Flags;
		DVector			m_Pos;
		DVector			m_Scale;
		DRotation		m_Rotation;
		D_WORD			m_ContainerCode;	// Container code if it's a container.  It's in here because
											// you can only set it at creation time.

		DDWORD			m_UserData;			// User data


		char			m_Filename[MAX_CS_FILENAME_LEN+1];	// This is the model, sound, or sprite filename.
															// It also can be the WorldModel name.
															// This can be zero-length when it's not needed.
		
		char			m_SkinName[MAX_CS_FILENAME_LEN+1];	// This can be zero-length.. if you set it for an 
															// OT_MODEL, it's the skin filename.	  

		// Server only info.
		char			m_Name[MAX_CS_FILENAME_LEN+1];		// This object's name.
		float			m_NextUpdate;						// This will be the object's starting NextUpdate.
		float			m_fDeactivationTime;				// Amount of time before object deactivates self
	} ObjectCreateStruct;

	// Initialize an ObjectCreateStruct.
	#define INIT_OBJECTCREATESTRUCT(theStruct) \
	{ \
		memset(&theStruct, 0, sizeof(theStruct));\
		VEC_SET(theStruct.m_Scale, 1, 1, 1); \
		theStruct.m_Rotation.m_Spin = 1.0f; \
	}


	// Model hook.
	#define MHF_USETEXTURE		1	// Use the texture for this model (if any).
	typedef struct ModelHookData_t
	{
		HLOCALOBJ		m_hObject;
		unsigned long	m_Flags;		// Combination of MHF_ flags above.
		unsigned long	m_ObjectFlags;	// The model's object flags.  You can modify them
										// in here without changing the model's flags
										// permanently.
		DVector			*m_LightAdd;	// RGB 0-255
	} ModelHookData;


	// Render modes are what are used to describe a video mode/video card.
	typedef struct RMode_t
	{
		DBOOL			m_bHardware;

		char			m_RenderDLL[200];		// What DLL this comes from.		
		char			m_InternalName[100];	// This is what the DLLs use to identify a card.
		char			m_Description[100];		// This is a 'friendly' string describing the card.
		
		DDWORD			m_Width, m_Height, m_BitDepth;
		struct RMode_t	*m_pNext;
	} RMode;

	// The ID of the description string contained in render DLLs.
	#define RDLL_DESCRIPTION_STRINGID	5


	// Device input for device tracking
	#define MAX_INPUT_BUFFER_SIZE	32

	#define	DEVICETYPE_KEYBOARD		1
	#define DEVICETYPE_MOUSE		2
	#define DEVICETYPE_JOYSTICK		4
	#define DEVICETYPE_UNKNOWN		8
	
	#define CONTROLTYPE_UNKNOWN		0			// unknown type
	#define CONTROLTYPE_XAXIS		1			// horizontal axis, such as left-right motion of a mouse
	#define CONTROLTYPE_YAXIS		2			// vertical axis, such as forward-backward motion of a mouse
	#define CONTROLTYPE_ZAXIS		3			// z-axis, such as a wheel on a mouse or a throttle on a joystick
	#define CONTROLTYPE_RXAXIS		4			// rotation around the x-axis
	#define CONTROLTYPE_RYAXIS		5			// rotation around the y-axis
	#define CONTROLTYPE_RZAXIS		6			// rotation around the z-axis
	#define CONTROLTYPE_SLIDER		7			// a slider axis
	#define CONTROLTYPE_BUTTON		8			// a mouse button
	#define CONTROLTYPE_KEY			9			// a key on a keyboard
	#define CONTROLTYPE_POV			10			// point-of-view indicator or "hat"

	typedef struct DeviceInput_t
	{
		DDWORD			m_DeviceType;			// type of input device (DEVICETYPE_ defines above)
		char			m_DeviceName[128];		// name of input device

		DDWORD			m_ControlType;			// type of control that changed (CONTROLTYPE_ defines above)
		char			m_ControlName[64];		// name of control that changed
		DDWORD			m_InputValue;			// input value for the control
	} DeviceInput;

	// Device Object for listing objects on a particular device
	typedef struct DeviceObject_t
	{
		DDWORD		m_DeviceType;			// type of input device (DEVICETYPE_ defines above)
		char		m_DeviceName[128];		// name of input device ("Keyboard", "Mouse", etc.)

		DDWORD		m_ObjectType;			// type of object (CONTROLTYPE_ defines above)
		char		m_ObjectName[64];		// name of object ("x-axis", "button 0", etc.)

		float		m_RangeLow;				// low end of range for this object
		float		m_RangeHigh;			// high end of range for this object

		struct DeviceObject_t*	m_pNext;
	} DeviceObject;
	
	// Device Binding info for GetDeviceBindings()

	#define MAX_ACTIONNAME_LEN 30
	#define INPUTNAME_LEN 100

	typedef struct GameAction_t
	{
		int						nActionCode;						// action number from config file
		char					strActionName[MAX_ACTIONNAME_LEN];	// name of action from config file
		float					nRangeLow;							// low range if used (zero if not used)
		float					nRangeHigh;							// high range if used (zero if not used)
		struct GameAction_t*	pNext;								// next in list

	} GameAction;

	typedef struct DeviceBinding_t
	{
		char					strDeviceName[INPUTNAME_LEN];		// name of device for this trigger
		char					strTriggerName[INPUTNAME_LEN];		// name of this trigger (device object name)
		float					nScale;								// scale to multiply input by
		float					nRangeScaleMin;						// min for range scale
		float					nRangeScaleMax;						// max for range scale
		float					nRangeScalePreCenterOffset;			// offset of cent value for input data
		struct GameAction_t*	pActionHead;						// list of actions bound to this trigger
		struct DeviceBinding_t* pNext;								// next in list

	} DeviceBinding;



	// Structure used by a driver to describe a net service (such as ipx or tcp/ip).
	#define MAX_NETSERVICENAME_LEN	128
	class NetService
	{
	public:
		HNETSERVICE	m_handle;
		DDWORD		m_dwFlags; // Combination of NETSERVICE_ flags.
		DGUID		m_guidService;
		char		m_sName[MAX_NETSERVICENAME_LEN];
		NetService	*m_pNext;
	};


	// Structure used by a driver to describe a specific net session.
	#define MAX_NETSESSIONNAME_LEN	4096
	#define MAX_NETPASSWORD_LEN		64
	#define MAX_HOSTIP_LEN			32
	#define NO_HOST_PORT			0xFFFF

	class NetSession
	{
	public:
					NetSession() {Clear();}
		virtual		~NetSession() {}

		void		Clear()
		{
			m_dwFlags = 0;
			m_dwMaxPlayers = 0;
			m_dwCurPlayers = 0;
			m_Ping = 0;
			m_sName[0] = 0;
			m_sPassword[0] = 0;
			m_HostIP[0] = 0;
			m_HostPort = NO_HOST_PORT;
			m_pNext = DNULL;
		}

		DDWORD		m_dwFlags;
		DGUID		m_guidApp;
		DGUID		m_guidInst;
		DDWORD		m_dwMaxPlayers;
		DDWORD		m_dwCurPlayers;
		DDWORD		m_Ping;	// Ping time in milliseconds.
		
		// Host info.  0 length string and NO_HOST_PORT if not on TCP/IP.
		char		m_HostIP[MAX_HOSTIP_LEN];
		DDWORD		m_HostPort;

		char		m_sName[MAX_NETSESSIONNAME_LEN];
		char		m_sPassword[MAX_NETPASSWORD_LEN];
		NetSession	*m_pNext;
	};


	// Structure used by to instruct a driver to create/host a new session.
	typedef struct NetHost_t
	{
		DDWORD		m_Port; // Port if TCP/IP.  If zero, it uses the default.
		DDWORD		m_dwFlags;
		DDWORD		m_dwMaxPlayers;
		char		m_sName[MAX_NETSESSIONNAME_LEN];
		char		m_sPassword[MAX_NETPASSWORD_LEN];

	}	NetHost;




	// ---------------------------------------------------------------------- //
	// Collision info
	// 
	// Used to determine information in GetStandingOn or GetLastCollision
	// ---------------------------------------------------------------------- //

	class CollisionInfo
	{
	public:
		// The blocking plane of whatever the object collided with.  If both object's are non-solid, then this 
		// will have a normal vector of mag 0.
		DPlane		m_Plane;

		// The object collided with.
		HOBJECT		m_hObject;

⌨️ 快捷键说明

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