📄 server_de.h
字号:
// server_de defines the ServerDE structure, which consists of all the
// server-side DirectEngine functionality.
#ifndef __SERVER_DE_H__
#define __SERVER_DE_H__
#include "basedefs_de.h"
#include "serverobj_de.h"
#include "common_de.h"
#include "CSBase.h"
DEFINE_HANDLE_TYPE(HCONVAR);
DEFINE_HANDLE_TYPE(HCLIENTREF);
// Load world flags.
#define LOADWORLD_LOADWORLDOBJECTS (1<<0) // Load objects from the world file?
#define LOADWORLD_RUNWORLD (1<<1) // Start running world immediately?
#define LOADWORLD_NORELOADGEOMETRY (1<<2) // Don't reload geometry if the world filename
// is the same as the currently loaded one.
// ---------------------------------------------------------------------- //
// Load/Save objects flags.
// ---------------------------------------------------------------------- //
#define RESTOREOBJECTS_RESTORETIME 1 // Restore time information?
#define SAVEOBJECTS_SAVEGAMECONSOLE 1 // Save the game console state?
#define SAVEOBJECTS_SAVEPORTALS 2 // Save the portal states?
// ---------------------------------------------------------------------- //
// Client info flags.
//
// CIF_LOCAL and CIF_PLAYBACK are not settable with SetClientInfoFlags.
// ---------------------------------------------------------------------- //
#define CIF_LOCAL (1<<0) // Client is local (non-network) connection.
#define CIF_PLAYBACK (1<<1) // Virtual client from a demo playback.
#define CIF_FULLRES (1<<2) // Client object is sent with full position resolution.
#define CIF_SENDCOBJROTATION (1<<3) // Client object rotations are sent to client.
#define CIF_FORCENEXTUPDATE (1<<4) // Force the server to update the client on the state
// of the world as soon as it can. In multiplayer
// games, it doesn't update the clients every frame
// and this can be used if you send a message to the client
// that needs to arrive in sync with object changes (like
// animation changes).
// ---------------------------------------------------------------------- //
// Object states.
//
// OBJSTATE_INACTIVE and OBJSTATE_INACTIVE_TOUCH override the effect of
// PingObjects. OBJSTATE_ACTIVE clears the effect of OBJSTATE_INACTIVE
// or OBJSTATE_INACTIVE_TOUCH, but the object can be autodeactivated.
// ---------------------------------------------------------------------- //
#define OBJSTATE_ACTIVE 0 // Normal healthy object.
#define OBJSTATE_INACTIVE 1 // Inactive (no updates, physics, or touch notifies).
#define OBJSTATE_INACTIVE_TOUCH 2 // Inactive, but gets touch notifies.
#define OBJSTATE_AUTODEACTIVATE_NOW 3 // Autodeactivate now, can reactivate thru PingObjects call.
// ---------------------------------------------------------------------- //
// Server state flags.
// ---------------------------------------------------------------------- //
#define SS_PAUSED (1<<0) // Server is paused.
#define SS_DEMOPLAYBACK (1<<1) // We're running in 'demo playback' mode (read only).
#define SS_CACHING (1<<2) // Server can pre-cache files.
#define SS_LASTFLAG SS_DEMOPLAYBACK
// ---------------------------------------------------------------------- //
// Object lists.
// ---------------------------------------------------------------------- //
typedef struct ObjectLink_t
{
HOBJECT m_hObject;
struct ObjectLink_t *m_pNext;
} ObjectLink;
typedef struct ObjectList_t
{
ObjectLink *m_pFirstLink;
int m_nInList;
} ObjectList;
// ---------------------------------------------------------------------- //
// GenericProp -
// Here's a list of which property types map to which variables:
// PT_STRING - m_Vec and m_Color if it's formatted like '1 2 3', m_String, m_Long, m_Float, m_Bool.
// - if this is 'true' or 'false', it'll set m_Long, m_Float, and m_Bool to 0 or 1.
// PT_VECTOR - m_Vec, m_String ('1 2 3')
// PT_COLOR - m_Color, m_String ('1 2 3')
// PT_REAL - m_String, m_Long, m_Float, m_Bool
// PT_FLAGS - m_String, m_Long, m_Float, m_Bool
// PT_BOOL - m_String, m_Long, m_Float, m_Bool
// PT_LONGINT - m_String, m_Long, m_Float, m_Bool
// PT_ROTATION - m_Rotation and m_Vec (with euler rotation).
// ---------------------------------------------------------------------- //
#define MAX_GP_STRING_LEN 200
typedef struct GenericProp_t
{
DVector m_Vec;
DVector m_Color;
char m_String[MAX_GP_STRING_LEN+1];
DRotation m_Rotation;
long m_Long;
float m_Float;
DBOOL m_Bool;
} GenericProp;
class PhysicsLT;
// ---------------------------------------------------------------------- //
// CServerDE interface. This is your interface to most DirectEngine
// functionality.
// ---------------------------------------------------------------------- //
class ServerDE : public CSBase
{
friend class CServerMgr;
protected:
virtual ~ServerDE() {}
public:
// Access to the smaller interfaces.
CommonLT* Common() {return m_pCommonLT;}
PhysicsLT* Physics() {return m_pPhysicsLT;}
// Main functions.
// Gives you access to the m_pGameInfo from the StartGameRequest structure.
// Note: this is a copy of the data and the pointer filled in can be NULL
// if there is no game info data.
DRESULT (*GetGameInfo)(void **ppData, DDWORD *pLen);
// Returns DNULL if the class doesn't exist.
HCLASS (*GetClass)(char *pName);
// Get a class's static object. Returns DE_NOTFOUND if the server
// doesn't have a static object of this class.
DRESULT (*GetStaticObject)(HCLASS hClass, HOBJECT *obj);
// OBSOLETE. Use PhysicsLT.
virtual HOBJECT GetWorldObject()=0;
// Get an object's class.
HCLASS (*GetObjectClass)(HOBJECT hObject);
// Tells if hClass is the class of hTest (or is derived from hTest).
// If you pass in DNULL for hTest (like if GetClass returns DNULL in
// IsKindOf(hClass, GetClass("TestClass"))), it will return FALSE.
DBOOL (*IsKindOf)(HCLASS hClass, HCLASS hTest);
// Creates an object using the object's default object type.
LPBASECLASS (*CreateObject)(HCLASS hClass, struct ObjectCreateStruct_t *pStruct);
// Creates an object using string to specify properties.
LPBASECLASS (*CreateObjectProps)(HCLASS hClass, struct ObjectCreateStruct_t *pStruct, char *pszProps );
// Remove the object from the world. Note: the object won't be removed
// or deleted until the end of the frame.
void (*RemoveObject)(HOBJECT hObject);
// Returns the current time, in seconds, since the server started up.
DFLOAT (*GetTime)();
// Returns the time since the last server shell update.
DFLOAT (*GetFrameTime)();
// OBSOLETE. Use PhysicsLT functions.
virtual DRESULT GetGlobalForce(DVector *pVec)=0;
virtual DRESULT SetGlobalForce(DVector *pVec)=0;
// Server state flags. (Combination of the SS_ flags above).
// SetServerFlags returns the new flags (some may not be accepted).
DDWORD (*GetServerFlags)();
DDWORD (*SetServerFlags)(DDWORD flags);
// Cache in the given file. Only call this from ServerShell::CacheFiles.
// fileType is one of the FT_ defines in de_codes.
// Returns DE_NOTFOUND if it can't find the file.
DRESULT (*CacheFile)(DDWORD fileType, char *pFilename);
// Helpers..
// Use this to iterate over all the polies in the world.
// Returns DE_FINISHED when there are no more polies to look at.
// Returns LT_NOTINITIALIZED if there is no world loaded.
// Iterate like this:
// HPOLY hPoly = INVALID_HPOLY;
// while(pServerDE->GetNextPoly(&hPoly) == LT_OK)
// {
// ... do something with hPoly ...
// }
DRESULT (*GetNextPoly)(HPOLY *hPoly);
// Use these to time sections of code. Timing is done in microseconds
// (1,000,000 counts per second).
void (*StartCounter)(struct DCounter_t *pCounter);
DDWORD (*EndCounter)(struct DCounter_t *pCounter);
// Returns a random number in the given range.
DFLOAT (*Random)(DFLOAT min, DFLOAT max);
// Returns an integer number in the given range.
int (*IntRandom)(int min, int max);
// Returns a number from 0 to scale.
DFLOAT (*RandomScale)(DFLOAT scale);
// Only use this for debugging.. sends an STC_BPRINT message
// with the string in it.
void (*BPrint)(char *pMsg, ...);
// A better BPrint.. prints right to the console (doesn't do any network stuff) and
// doesn't matter if you're connected yet.
void (*CPrint)(char *pMsg, ...);
// Used to output a TRACE message to the Debug Output window. Newlines must be explicitly used.
void (*DebugOut)( char *pMsg, ... );
// Get/Set the sky definition.
DRESULT (*GetSkyDef)(struct SkyDef_t *pDef);
DRESULT (*SetSkyDef)(struct SkyDef_t *pDef);
// Add/Remove objects from the sky list.
// Each object should have a unique index.
DRESULT (*AddObjectToSky)(HOBJECT hObj, DDWORD index);
DRESULT (*RemoveObjectFromSky)(HOBJECT hObj);
// String functions. Strings are reference counted objects that cannot
// be manipulated. When you create one with FormatString or CreateString,
// the reference count is 1. When you copy a string with CopyString, the
// reference count is incremented. When you free one with FreeString,
// it decrements the reference count.. when the reference count goes to
// zero, it deletes the string. If you forget to free up any strings,
// LithTech will spit out a message telling you about it..
// In Windows, messageCode comes from your resource DLL. The messages
// need to be formatted with %1!s! %2!s! (the number is the argument
// number and the !s! says its a string). You can also use !f! and !d!
// for floating point and whole number.
HSTRING (*FormatString)(int messageCode, ...);
// Copy a string.. much more efficient than CreateString().
HSTRING (*CopyString)(HSTRING hString);
HSTRING (*CreateString)(char *pString);
void (*FreeString)(HSTRING hString);
DBOOL (*CompareStrings)(HSTRING hString1, HSTRING hString2);
DBOOL (*CompareStringsUpper)(HSTRING hString1, HSTRING hString2);
// Get the string's data.. you really should only use this for strings
// that you stored off and want to pass to the engine for a filename
// or something.. Most strings could be in some format other than ANSI.
char* (*GetStringData)(HSTRING hString);
// World control.
// Portal flags are a combination of PORTAL_ flags in de_codes.
// Returns DE_OK, DE_NOTFOUND, or DE_NOTINWORLD. This is
// case sensitive.
DRESULT (*GetPortalFlags)(char *pPortalName, DDWORD *pFlags);
DRESULT (*SetPortalFlags)(char *pPortalName, DDWORD flags);
// Intersect a line segment.. (used to be raycast, but line segments are WAY faster).
// Returns TRUE and fills in pInfo if it hit something.
DBOOL (*IntersectSegment)(IntersectQuery *pQuery, IntersectInfo *pInfo);
// Same as IntersectSegment, except for it casts a ray from pQuery->m_From
// in the direction of pQuery->m_Dir.
DBOOL (*CastRay)(IntersectQuery *pQuery, IntersectInfo *pInfo);
///////////////// NOT IMPLEMENTED YET /////////////////
// Find out what's at a given point (is it inside the world, outside, what
// area brushes is it inside..) You must give back the list to the engine
// with RelinquishList()!
ObjectList* (*GetPointAreas)(DVector *pPoint);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -