iltserver.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826
  1. // server_de defines the ILTServer interface, which consists of all the
  2. // server-side DirectEngine functionality.
  3. #ifndef __ILTSERVER_H__
  4. #define __ILTSERVER_H__
  5. #include "ltbasedefs.h"
  6. #include "ltserverobj.h"
  7. #include "iltcommon.h"
  8. #include "iltcsbase.h"
  9. #include "iltmath.h"
  10. #include "iltsoundmgr.h"
  11. // Typedef to deal with the fact that there were two different versions of a console variable handle
  12. typedef HCONSOLEVAR HCONVAR;
  13. DEFINE_HANDLE_TYPE(HCLIENTREF);
  14. // Load world flags.
  15. #define LOADWORLD_LOADWORLDOBJECTS (1<<0) // Load objects from the world file?
  16. #define LOADWORLD_RUNWORLD (1<<1) // Start running world immediately?
  17. #define LOADWORLD_NORELOADGEOMETRY (1<<2) // Don't reload geometry if the world filename
  18. // is the same as the currently loaded one.
  19. // ---------------------------------------------------------------------- //
  20. // Load/Save objects flags.
  21. // ---------------------------------------------------------------------- //
  22. #define RESTOREOBJECTS_RESTORETIME 1 // Restore time information?
  23. #define SAVEOBJECTS_SAVEGAMECONSOLE 1 // Save the game console state?
  24. #define SAVEOBJECTS_SAVEPORTALS 2 // Save the portal states?
  25. // ---------------------------------------------------------------------- //
  26. // Client info flags.
  27. //
  28. // CIF_LOCAL and CIF_PLAYBACK are not settable with SetClientInfoFlags.
  29. // ---------------------------------------------------------------------- //
  30. #define CIF_LOCAL (1<<0) // Client is local (non-network) connection.
  31. #define CIF_PLAYBACK (1<<1) // Virtual client from a demo playback.
  32. #define CIF_FULLRES (1<<2) // Client object is sent with full position resolution.
  33. #define CIF_SENDCOBJROTATION (1<<3) // Client object rotations are sent to client.
  34. #define CIF_FORCENEXTUPDATE (1<<4) // Force the server to update the client on the state
  35. // of the world as soon as it can. In multiplayer
  36. // games, it doesn't update the clients every frame
  37. // and this can be used if you send a message to the client
  38. // that needs to arrive in sync with object changes (like
  39. // animation changes).
  40. #define CIF_AUTOACTIVATEOBJECTS (1<<5) // Use this instead of PingObjectsFromObject whenever possible.
  41. // This activates objects from the client's view position
  42. // when determining what to send to the client (so activating
  43. // objects is free).
  44. // ---------------------------------------------------------------------- //
  45. // Object states.
  46. //
  47. // OBJSTATE_INACTIVE and OBJSTATE_INACTIVE_TOUCH override the effect of
  48. // PingObjects. OBJSTATE_ACTIVE clears the effect of OBJSTATE_INACTIVE
  49. // or OBJSTATE_INACTIVE_TOUCH, but the object can be autodeactivated.
  50. // ---------------------------------------------------------------------- //
  51. #define OBJSTATE_ACTIVE 0 // Normal healthy object.
  52. #define OBJSTATE_INACTIVE 1 // Inactive (no updates, physics, or touch notifies).
  53. #define OBJSTATE_INACTIVE_TOUCH 2 // Inactive, but gets touch notifies.
  54. #define OBJSTATE_AUTODEACTIVATE_NOW 3 // Autodeactivate now, can reactivate thru PingObjects call.
  55. // ---------------------------------------------------------------------- //
  56. // Server state flags.
  57. // ---------------------------------------------------------------------- //
  58. #define SS_PAUSED (1<<0) // Server is paused.
  59. #define SS_DEMOPLAYBACK (1<<1) // We're running in 'demo playback' mode (read only).
  60. #define SS_CACHING (1<<2) // Server can pre-cache files.
  61. #define SS_LASTFLAG SS_DEMOPLAYBACK
  62. // ---------------------------------------------------------------------- //
  63. // Object lists.
  64. // ---------------------------------------------------------------------- //
  65. struct ObjectLink
  66. {
  67. HOBJECT m_hObject;
  68. ObjectLink *m_pNext;
  69. };
  70. struct ObjectList
  71. {
  72. ObjectLink *m_pFirstLink;
  73. int m_nInList;
  74. };
  75. #define MAX_CLASSPROPINFONAME_LEN 128
  76. // Used by ILTServer::GetClassProp.
  77. class ClassPropInfo
  78. {
  79. public:
  80. char m_PropName[MAX_CLASSPROPINFONAME_LEN];
  81. short m_PropType; // PT_ define from serverobj_de.h.
  82. };
  83. class ILTPhysics;
  84. class ILTModel;
  85. class ILTTransform;
  86. class ILTLightAnim;
  87. class ILTSoundMgr;
  88. // ---------------------------------------------------------------------- //
  89. // ILTServer interface. This is your interface to most DirectEngine
  90. // functionality.
  91. // ---------------------------------------------------------------------- //
  92. class ILTServer : public ILTCSBase
  93. {
  94. friend class CServerMgr;
  95. protected:
  96. virtual ~ILTServer() {}
  97. public:
  98. // Main functions.
  99. // Gives you access to the m_pGameInfo from the StartGameRequest structure.
  100. // Note: this is a copy of the data and the pointer filled in can be NULL
  101. // if there is no game info data.
  102. LTRESULT (*GetGameInfo)(void **ppData, uint32 *pLen);
  103. // Returns LTNULL if the class doesn't exist.
  104. HCLASS (*GetClass)(char *pName);
  105. // Get the ClassDef info from a class. This is useful if you want to
  106. // get at the class's property names.
  107. virtual LTRESULT GetNumClassProps(const HCLASS hClass,
  108. uint32 &count)=0;
  109. virtual LTRESULT GetClassProp(const HCLASS hClass,
  110. const uint32 iProp, ClassPropInfo &info)=0;
  111. // Get a class's name.
  112. virtual LTRESULT GetClassName(const HCLASS hClass,
  113. char *pName, uint32 maxNameBytes)=0;
  114. // Get a class's static object. Returns LT_NOTFOUND if the server
  115. // doesn't have a static object of this class.
  116. LTRESULT (*GetStaticObject)(HCLASS hClass, HOBJECT *obj);
  117. // Get an object's class.
  118. HCLASS (*GetObjectClass)(HOBJECT hObject);
  119. // Tells if hClass is the class of hTest (or is derived from hTest).
  120. // If you pass in LTNULL for hTest (like if GetClass returns LTNULL in
  121. // IsKindOf(hClass, GetClass("TestClass"))), it will return FALSE.
  122. LTBOOL (*IsKindOf)(HCLASS hClass, HCLASS hTest);
  123. // Creates an object using the object's default object type.
  124. LPBASECLASS (*CreateObject)(HCLASS hClass, ObjectCreateStruct *pStruct);
  125. // Creates an object using string to specify properties.
  126. LPBASECLASS (*CreateObjectProps)(HCLASS hClass, ObjectCreateStruct *pStruct, char *pszProps );
  127. // OBSOLETE. Use PhysicsLT functions.
  128. virtual LTRESULT GetGlobalForce(LTVector *pVec)=0;
  129. virtual LTRESULT SetGlobalForce(LTVector *pVec)=0;
  130. // Server state flags. (Combination of the SS_ flags above).
  131. // SetServerFlags returns the new flags (some may not be accepted).
  132. uint32 (*GetServerFlags)();
  133. uint32 (*SetServerFlags)(uint32 flags);
  134. // Cache in the given file. Only call this from ServerShell::CacheFiles.
  135. // fileType is one of the FT_ defines in de_codes.
  136. // Returns LT_NOTFOUND if it can't find the file.
  137. LTRESULT (*CacheFile)(uint32 fileType, char *pFilename);
  138. // Load the specified file in the loader thread.
  139. // Also sends a message to clients saying to do the same. When the
  140. // operation is completed it calls IServerShell::FileLoadNotify with a result
  141. // (which can be an error if the file is missing). Objects can be created
  142. // using this file but they won't be visible until all files they need are loaded.
  143. // Types currently supported are FT_MODEL and FT_TEXTURE.
  144. // (Textures aren't loaded on the server. A message is sent to the clients
  145. // to load the texture in their thread).
  146. // LT_UNSUPPORTED is returned if you pass an invalid type.
  147. // LT_MISSINGFILE is returned if the file is missing.
  148. // LT_ALREADYEXISTS is returned if the file is already in memory.
  149. // LT_INPROGRESS is returned if it's already loading in the thread.
  150. // (Note: a lot of these returns don't signify errors...)
  151. virtual LTRESULT ThreadLoadFile(char *pFilename, uint32 type)=0;
  152. // Unload the data. Returns LT_ERROR if the file is being used and can't be
  153. // unloaded. Returns LT_NOTFOUND if the file isn't currently loaded.
  154. virtual LTRESULT UnloadFile(char *pFilename, uint32 type)=0;
  155. // Helpers..
  156. // Use this to iterate over all the polies in the world.
  157. // Returns LT_FINISHED when there are no more polies to look at.
  158. // Returns LT_NOTINITIALIZED if there is no world loaded.
  159. // Iterate like this:
  160. // HPOLY hPoly = INVALID_HPOLY;
  161. // while(pServerLT->GetNextPoly(&hPoly) == LT_OK)
  162. // {
  163. // ... do something with hPoly ...
  164. // }
  165. LTRESULT (*GetNextPoly)(HPOLY *hPoly);
  166. // Get the world object that a particular HPOLY comes from.
  167. // NOTE: This will NOT work on terrains because one HPOLY may be shared
  168. // among multiple TerrainSection WorldModels.
  169. virtual LTRESULT GetHPolyObject(
  170. const HPOLY hPoly,
  171. HOBJECT &hObject
  172. )=0;
  173. // Use these to time sections of code. Timing is done in microseconds
  174. // (1,000,000 counts per second).
  175. void (*StartCounter)(LTCounter *pCounter);
  176. uint32 (*EndCounter)(LTCounter *pCounter);
  177. // Returns a random number in the given range.
  178. LTFLOAT (*Random)(LTFLOAT min, LTFLOAT max);
  179. // Returns an integer number in the given range.
  180. int (*IntRandom)(int min, int max);
  181. // Returns a number from 0 to scale.
  182. LTFLOAT (*RandomScale)(LTFLOAT scale);
  183. // Only use this for debugging.. sends an STC_BPRINT message
  184. // with the string in it.
  185. void (*BPrint)(char *pMsg, ...);
  186. // Used to output a TRACE message to the Debug Output window. Newlines must be explicitly used.
  187. void (*DebugOut)( char *pMsg, ... );
  188. // Get/Set the sky definition.
  189. LTRESULT (*GetSkyDef)(SkyDef *pDef);
  190. LTRESULT (*SetSkyDef)(SkyDef *pDef);
  191. // Add/Remove objects from the sky list.
  192. // Each object should have a unique index.
  193. LTRESULT (*AddObjectToSky)(HOBJECT hObj, uint32 index);
  194. LTRESULT (*RemoveObjectFromSky)(HOBJECT hObj);
  195. // Get/set the global light object
  196. LTRESULT (*GetGlobalLightObject)(HOBJECT *hObj);
  197. LTRESULT (*SetGlobalLightObject)(HOBJECT hObj);
  198. // World control.
  199. // Portal flags are a combination of PORTAL_ flags in de_codes.
  200. // Returns LT_OK, LT_NOTFOUND, or LT_NOTINWORLD. This is
  201. // case sensitive.
  202. LTRESULT (*GetPortalFlags)(char *pPortalName, uint32 *pFlags);
  203. LTRESULT (*SetPortalFlags)(char *pPortalName, uint32 flags);
  204. // Intersect a line segment.. (used to be raycast, but line segments are WAY faster).
  205. // Returns TRUE and fills in pInfo if it hit something.
  206. LTBOOL (*IntersectSegment)(IntersectQuery *pQuery, IntersectInfo *pInfo);
  207. // Same as IntersectSegment, except for it casts a ray from pQuery->m_From
  208. // in the direction of pQuery->m_Dir.
  209. LTBOOL (*CastRay)(IntersectQuery *pQuery, IntersectInfo *pInfo);
  210. // Find out what's at a given point (is it inside the world, outside, what
  211. // area brushes is it inside..) You must give back the list to the engine
  212. // with RelinquishList()!
  213. ObjectList* (*GetPointAreas)(LTVector *pPoint);
  214. // Find the objects intersecting this box.
  215. ObjectList* (*GetBoxIntersecters)(LTVector *pMin, LTVector *pMax);
  216. // Get the shade (RGB, 0-255) at the point you specify.
  217. // Returns DFALSE if the point is outside the world.
  218. LTBOOL (*GetPointShade)(LTVector *pPoint, LTVector *pColor);
  219. // Gets all the objects with the given name.
  220. virtual LTRESULT FindNamedObjects(char *pName,
  221. BaseObjArray<HOBJECT> &objArray,
  222. uint32 *nTotalFound=NULL)=0;
  223. // Find all the objects that interesect the passed in world model
  224. // if the world model is moved/rotated to the new position/rotation.
  225. virtual LTRESULT FindWorldModelObjectIntersections(
  226. HOBJECT hWorldModel,
  227. LTVector vNewPos, LTRotation rNewRot,
  228. BaseObjArray<HOBJECT> &objArray)=0;
  229. // Find all the objects touching the given sphere.
  230. // Don't forget to relinquish the list you get!
  231. // Be VERY careful of using a large radius. This function can take
  232. // tons of cycles if the radius is too large.
  233. ObjectList* (*FindObjectsTouchingSphere)(LTVector *pPosition, float radius);
  234. // Any time the engine gives you a list, you must 'give it back' with this,
  235. // or else you'll have tons of memory leaks.
  236. void (*RelinquishList)(ObjectList *pList);
  237. // Get the bounding box for the current world.
  238. virtual LTRESULT GetWorldBox(LTVector &min, LTVector &max)=0;
  239. // Object list management.
  240. // Allocate a list (free it with RelinquishList).
  241. ObjectList* (*CreateObjectList)();
  242. // Add objects to a list.
  243. ObjectLink* (*AddObjectToList)(ObjectList *pList, HOBJECT hObj);
  244. // Remove an object from the list given the handle.
  245. // Note: LithTech will just do a search over all the objects in the
  246. // list for this, so be warned.
  247. void (*RemoveObjectFromList)(ObjectList *pList, HOBJECT hObj);
  248. // OBSOLETE messaging functions. Use CommonLT::CreateMessage, ILTMessage::Release,
  249. // and ILTServer::SendToX.
  250. virtual HMESSAGEWRITE StartSpecialEffectMessage(LPBASECLASS pObject)=0;
  251. virtual HMESSAGEWRITE StartInstantSpecialEffectMessage(LTVector *pPos)=0;
  252. virtual HMESSAGEWRITE StartMessageToObject(LPBASECLASS pSender, HOBJECT hSendTo, uint32 messageID)=0;
  253. virtual LTRESULT StartMessageToServer(LPBASECLASS pSender, uint32 messageID, HMESSAGEWRITE *hWrite)=0;
  254. virtual HMESSAGEWRITE StartMessage(HCLIENT hSendTo, uint8 messageID)=0;
  255. virtual LTRESULT EndMessage2(HMESSAGEWRITE hMessage, uint32 flags)=0;
  256. virtual LTRESULT EndMessage(HMESSAGEWRITE hMessage)=0; // Just calls EndMessage2 with MESSAGE_GUARANTEED.
  257. // NEW message functions. The main difference between these and the functions above is
  258. // that these don't free the message for you so you can send it multiple times.
  259. // Use this to setup a special effect message. If your object has
  260. // a special effect message, the client shell's SpecialEffectNotify()
  261. // will be called. An object can only have ONE special effect message.
  262. // If the object already has a special effect message, then it
  263. // clears out the current one.
  264. virtual LTRESULT SetObjectSFXMessage(HOBJECT hObject, ILTMessage &msg)=0;
  265. // Send a message to an object. hSender can be NULL.
  266. virtual LTRESULT SendToObject(ILTMessage &msg, uint32 msgID, HOBJECT hSender, HOBJECT hSendTo, uint32 flags)=0;
  267. // Send the message to the server shell. hSender can be NULL.
  268. virtual LTRESULT SendToServer(ILTMessage &msg, uint32 msgID, HOBJECT hSender, uint32 flags)=0;
  269. // Send the message to the client. If hSendTo is NULL, it sends to them all.
  270. virtual LTRESULT SendToClient(ILTMessage &msg, uint8 msgID, HCLIENT hSendTo, uint32 flags)=0;
  271. // Sends the sfx message to all the clients who can see pos.
  272. virtual LTRESULT SendSFXMessage(ILTMessage &msg, LTVector &pos, uint32 flags)=0;
  273. // Send a packet thru tcp/ip if we're using tcp/ip.
  274. virtual LTRESULT SendTo(const void *pData, uint32 len, const char *sAddr, uint32 port)=0;
  275. // Client Functions.
  276. // Attach one client to another. This means that messages sent to hParent
  277. // will also go to hClient, and hClient's client object will be reported
  278. // as hParent's object. This is useful for demo playback when you want
  279. // to watch another player's view.
  280. LTRESULT (*AttachClient)(HCLIENT hParent, HCLIENT hChild);
  281. // Detach a client from its parent attachment.
  282. LTRESULT (*DetachClient)(HCLIENT hClient);
  283. // Iterate over the clients. Pass in NULL to start. Returns NULL
  284. // when there are no more.
  285. HCLIENT (*GetNextClient)(HCLIENT hPrev);
  286. // Iterate over the saved client references. These come from when
  287. // a world is saved. Pass in DNULL to start. See the Client Functions
  288. // section for the functions to look at these.
  289. HCLIENTREF (*GetNextClientRef)(HCLIENTREF hRef);
  290. // HCLIENTREFs are used for comparison to HCLIENTs.
  291. uint32 (*GetClientRefInfoFlags)(HCLIENTREF hClient);
  292. LTBOOL (*GetClientRefName)(HCLIENTREF hClient, char *pName, int maxLen);
  293. HOBJECT (*GetClientRefObject)(HCLIENTREF hClient);
  294. // Get a client's (unique) ID.
  295. uint32 (*GetClientID)(HCLIENT hClient);
  296. // Get a client's ping time.
  297. virtual LTRESULT GetClientPing(HCLIENT hClient, float &ping)=0;
  298. // Get a client's name.
  299. LTBOOL (*GetClientName)(HCLIENT hClient, char *pName, int maxLen);
  300. // A combination of the CIF_ flags above.
  301. void (*SetClientInfoFlags)(HCLIENT hClient, uint32 dwClientFlags );
  302. uint32 (*GetClientInfoFlags)(HCLIENT hClient);
  303. // User data for HCLIENTs.
  304. void (*SetClientUserData)(HCLIENT hClient, void *pData);
  305. void* (*GetClientUserData)(HCLIENT hClient);
  306. // Kick a client off the server.
  307. // OnRemoveClient will be called.
  308. void (*KickClient)(HCLIENT hClient, uint32 nReasonCode = 0);
  309. // Set where the client is seeing/hearing from. This controls what the
  310. // server sends the client. You should set this every frame.
  311. LTRESULT (*SetClientViewPos)(HCLIENT hClient, LTVector *pPos);
  312. // The 'game console state'. This is a set of console variables and functions
  313. // that is used internally by the application DLLs. The user can't access this
  314. // at all. It's very useful for tracking global game variables and triggering
  315. // them through game objects.
  316. // Run a string through the game console. The syntax is the same as any
  317. // other console string (semicolons separate commands, and new variable names
  318. // create new HCONVARs).
  319. void (*RunGameConString)(char *pString);
  320. // Sets a console variable. Creates a new one if it doesn't exist.
  321. void (*SetGameConVar)(char *pName, char *pVal);
  322. // Get a handle to a console variable.
  323. HCONVAR (*GetGameConVar)(char *pName);
  324. // Helpers.
  325. // These are used to get the property values from the world file.
  326. // The property names are case sensitive. If the property doesn't exist,
  327. // it will return LT_NOTFOUND.
  328. LTRESULT (*GetPropString)(char *pPropName, char *pRet, int maxLen);
  329. LTRESULT (*GetPropVector)(char *pPropName, LTVector *pRet);
  330. LTRESULT (*GetPropColor)(char *pPropName, LTVector *pRet);
  331. LTRESULT (*GetPropReal)(char *pPropName, float *pRet);
  332. LTRESULT (*GetPropFlags)(char *pPropName, uint32 *pRet);
  333. LTRESULT (*GetPropBool)(char *pPropName, LTBOOL *pRet);
  334. LTRESULT (*GetPropLongInt)(char *pPropName, long *pRet);
  335. LTRESULT (*GetPropRotation)(char *pPropName, LTRotation *pRet);
  336. LTRESULT (*GetPropRotationEuler)(char *pPropName, LTVector *pAngles); // pAngles = (pitch, yaw, roll)
  337. // Fills in the GenericProp for the different data types. For a list
  338. // of which property types map to which GenericProp variable, see
  339. // the GenericProp structure.
  340. // Note: if the property exists, it always initializes the members in the prop first,
  341. // so if the GenericProp variable doesn't support that property type,
  342. // it'll be zero
  343. LTRESULT (*GetPropGeneric)(char *pPropName, GenericProp *pProp);
  344. // See if a property exists. If so, pPropType is filled in (if it's non-NULL) with
  345. // on of the PT_ defines. Returns LT_NOTFOUND if it doesn't exist.
  346. LTRESULT (*DoesPropExist)(char *pPropName, int *pPropType);
  347. // Get handles from objects and objects from handles. Note: HandleToObject will return
  348. // NULL if the given object doesn't reside on this server (it's controlled remotely).
  349. HOBJECT (*ObjectToHandle)(LPBASECLASS pObject);
  350. LPBASECLASS (*HandleToObject)(HOBJECT hObject);
  351. // Tests if a command is on for this client.
  352. LTBOOL (*IsCommandOn)(HCLIENT hClient, int command);
  353. // Does a (fast) upper-case string comparison of the 2 strings.
  354. LTBOOL (*UpperStrcmp)(char *pStr1, char *pStr2);
  355. // Parse a string for arguments. Works similar to command line parser.
  356. // args within quotation marks are considered one arg.
  357. // Returns the all args after pCommand and before end of string or semi-colon.
  358. // pCommand - Beginning of string.
  359. // pNewCommandPos - Parse fills this in with the ending position
  360. // argBuffer - memory Parse can use as scratchpad
  361. // argPointers - Parse fills these pointers in to point to args found.
  362. // nArgs - Parse fills in the number of arguments found.
  363. // Return - LTTRUE, semicolon found, more args in string. LTFALSE, no more args.
  364. int (*Parse)(char *pCommand, char **pNewCommandPos, char *argBuffer, char **argPointers, int *nArgs);
  365. // Sound functions.
  366. // Play a sound with full control
  367. // Arguments:
  368. // pPlaySoundInfo - sound control structure
  369. // Returns:
  370. // LT_OK if successful.
  371. // LT_ERROR on error.
  372. LTRESULT (*PlaySound)( PlaySoundInfo *pPlaySoundInfo );
  373. // Get total length in seconds of sound.
  374. // Arguments:
  375. // hSound - Handle to sound.
  376. // fDuration - Duration of sound.
  377. // Returns:
  378. // LT_OK if successful.
  379. // LT_INVALIDPARAMS if hSound not available or not tracking time.
  380. LTRESULT (*GetSoundDuration)( HLTSOUND hSound, LTFLOAT *fDuration );
  381. // IsSoundDone
  382. // Arguments:
  383. // hSound - Handle to sound.
  384. // bDone - Indicates sound is completed.
  385. // Returns:
  386. // LT_OK if successful.
  387. // LT_INVALIDPARAMS if hSound not available or not tracking time.
  388. LTRESULT (*IsSoundDone)( HLTSOUND hSound, LTBOOL *bDone );
  389. // Kill a sound.
  390. // Arguments:
  391. // hSoundHandle - Handle to sound.
  392. // Returns:
  393. // LT_OK if successful.
  394. // LT_ERROR on error.
  395. LTRESULT (*KillSound)( HLTSOUND hSound );
  396. // Kills a looping sound. Sound will continue to play until it reaches
  397. // the end, then remove itself.
  398. // Arguments:
  399. // hSoundHandle - handle to client side sound.
  400. LTRESULT (*KillSoundLoop)( HLTSOUND hSound );
  401. // Inter-object link manipulation.
  402. // If you want to hold on to an HOBJECT and get notification when the
  403. // object is removed from the world, you can create an inter-object link
  404. // between the two. The owner will get MID_LINKBROKEN notification when
  405. // the link is being broken (by either the owner or linked object being removed).
  406. // If a link between the two objects already exists, the function will not
  407. // create another link and return LT_OK.
  408. // An object cannot make a link to itself. This will return LT_ERROR.
  409. LTRESULT (*CreateInterObjectLink)(HOBJECT hOwner, HOBJECT hLinked);
  410. // Breaks an inter-object link between the owner and linked object
  411. // (if one exists..) You can only break a link from the owner, since
  412. // the linked object doesn't even know it's linked to the owner..
  413. // Note: MID_LINKBROKEN will NOT be called.
  414. void (*BreakInterObjectLink)(HOBJECT hOwner, HOBJECT hLinked);
  415. // Object manipulation.
  416. // Attaches hChild to hParent. If pSocketName is set, it'll attach hChild to a
  417. // specific node on hParent.
  418. // DE will automatically detach if you remove hParent,
  419. // but it will NOT automatically detach if you remove hChild. If you remove the
  420. // child without removing the attachment, the results are undefined.
  421. // Returns LT_OK, LT_NODENOTFOUND, or LT_INVALIDPARAMS.
  422. LTRESULT (*CreateAttachment)(HOBJECT hParent, HOBJECT hChild, char *pSocketName,
  423. LTVector *pOffset, LTRotation *pRotationOffset, HATTACHMENT *pAttachment);
  424. // Removes an attachment. Note: an attachment becomes invalid when you remove the parent
  425. // so it'll crash if you call it with an attachment with a parent you've removed.
  426. LTRESULT (*RemoveAttachment)(HATTACHMENT hAttachment);
  427. // Look for an attachment on the parent. Returns LT_ERROR, LT_NOTFOUND,
  428. // or LT_OK if it found it. hAttachment is set to NULL if there's an error.
  429. LTRESULT (*FindAttachment)(HOBJECT hParent, HOBJECT hChild, HATTACHMENT *hAttachment);
  430. // Get/Set object color info (RGBA 0-1).
  431. // All objects default to (0,0,0,1)
  432. // For lights, this changes the light's color.
  433. // For models, this brightens a model's shading.
  434. LTBOOL (*GetObjectColor)(HOBJECT hObject, float *r, float *g, float *b, float *a);
  435. LTBOOL (*SetObjectColor)(HOBJECT hObject, float r, float g, float b, float a);
  436. // Get/Set an object's user-defined flags.
  437. uint32 (*GetObjectUserFlags)(HOBJECT hObj);
  438. LTRESULT (*SetObjectUserFlags)(HOBJECT hObj, uint32 flags);
  439. // OBSOLETE: use the CommonLT ones.
  440. virtual float GetObjectMass(HOBJECT hObj)=0;
  441. virtual void SetObjectMass(HOBJECT hObj, float mass)=0;
  442. // OBSOLETE: Use PhysicsLT.
  443. virtual float GetForceIgnoreLimit(HOBJECT hObj, float &limit)=0;
  444. virtual void SetForceIgnoreLimit(HOBJECT hObj, float limit)=0;
  445. // Use this to iterate thru all the objects in the world.
  446. // Pass in NULL to start off with. It'll return NULL when
  447. // you have iterated through all the objects.
  448. // This is generally a bad idea, but sometimes you have to.
  449. HOBJECT (*GetNextObject)(HOBJECT hObj);
  450. // Same as GetNextObject, but this iterates over all the inactive objects.
  451. HOBJECT (*GetNextInactiveObject)(HOBJECT hObj);
  452. // OBSOLETE. Use the GetObjectName below.
  453. virtual char* GetObjectName(HOBJECT hObject)=0;
  454. // Get an object's name.
  455. virtual LTRESULT GetObjectName(HOBJECT hObject, char *pName, uint32 nameBufSize)=0;
  456. // Set an object's friction coefficient.
  457. virtual LTRESULT SetFrictionCoefficient(HOBJECT hObj, float coeff)=0;
  458. // This is a counter that controls when each object gets its Update()
  459. // function called. This is set to 0.0001 when an object is created
  460. // so by default, Update() gets called right away.
  461. void (*SetNextUpdate)(HOBJECT hObj, LTFLOAT nextUpdate);
  462. // Sets the time which the engine will automatically deactivate an object. If object
  463. // is currently autodeactivated, then this call will activate the object
  464. void (*SetDeactivationTime)(HOBJECT hObj, LTFLOAT fDeactivationTime);
  465. // Activates any objects seen by this object
  466. void (*PingObjects)(HOBJECT hObj);
  467. // Object data accessors.
  468. void (*GetObjectPos)(HOBJECT hObj, LTVector *pos);
  469. void (*SetObjectPos)(HOBJECT hObj, LTVector *pos); // Exactly the same as calling Teleport().
  470. // Scale the object (only works on models and sprites).
  471. void (*ScaleObject)(HOBJECT hObj, LTVector *pNewScale);
  472. LTRESULT (*GetObjectScale)(HOBJECT hObj, LTVector *pScale);
  473. // OBSOLETE. Use PhysicsLT::MoveObject.
  474. virtual LTRESULT MoveObject(HOBJECT hObj, LTVector *pNewPos)=0;
  475. // Teleports the object directly to the position.
  476. LTRESULT (*TeleportObject)(HOBJECT hObj, LTVector *pNewPos);
  477. // OBSOLETE. Use PhysicsLT::GetStandingOn.
  478. virtual LTRESULT GetStandingOn(HOBJECT hObj, CollisionInfo *pInfo)=0;
  479. // Get information about the last collision. Only valid during MID_TOUCHNOTIFY or MID_CRUSH messages.
  480. LTRESULT (*GetLastCollision)(CollisionInfo *pInfo);
  481. // Get/Set the object's rotation.
  482. LTRESULT (*GetObjectRotation)(HOBJECT hObj, LTRotation *pRotation);
  483. LTRESULT (*SetObjectRotation)(HOBJECT hObj, LTRotation *pRotation);
  484. // This rotates the object to the new rotation with possible client side interpolation
  485. LTRESULT (*RotateObject)(HOBJECT hObj, LTRotation *pRotation);
  486. // Tilt their acceleration to be along the plane they're standing on.
  487. void (*TiltToPlane)(HOBJECT hObj, LTVector *pNormal);
  488. // OBSOLETE: Use ILTCommon::GetObjectFlags/SetObjectFlags.
  489. virtual uint32 GetObjectFlags(HOBJECT hObj)=0;
  490. virtual void SetObjectFlags(HOBJECT hObj, uint32 flags)=0;
  491. // Get/set an object's net flags. Net flags are a combination of NETFLAG_ defines.
  492. virtual LTRESULT GetNetFlags(HOBJECT hObj, uint32 &flags)=0;
  493. virtual LTRESULT SetNetFlags(HOBJECT hObj, uint32 flags)=0;
  494. // Get/Set the object's state. State is one of the OBJSTATE_ defines above.
  495. void (*SetObjectState)(HOBJECT hObj, int state);
  496. int (*GetObjectState)(HOBJECT hObj);
  497. // OBSOLETE. Use ILTPhysics.
  498. virtual void GetObjectDims(HOBJECT hObj, LTVector *pNewDims)=0;
  499. virtual LTRESULT SetObjectDims(HOBJECT hObj, LTVector *pNewDims)=0;
  500. virtual LTRESULT SetObjectDims2(HOBJECT hObj, LTVector *pNewDims)=0;
  501. // OBSOLETE: use ILTCommon functions.
  502. virtual LTRESULT GetVelocity(HOBJECT hObj, LTVector *pVel)=0;
  503. virtual LTRESULT SetVelocity(HOBJECT hObj, LTVector *pVel)=0;
  504. virtual LTRESULT GetAcceleration(HOBJECT hObj, LTVector *pAccel)=0;
  505. virtual LTRESULT SetAcceleration(HOBJECT hObj, LTVector *pAccel)=0;
  506. // Get/Set blocking priority (defaults to 0).
  507. // See FAQ for a description of how this works.
  508. void (*SetBlockingPriority)(HOBJECT hObj, uint8 pri);
  509. uint8 (*GetBlockingPriority)(HOBJECT hObj);
  510. // Sprite manipulation.
  511. // This clips the sprite on the poly.
  512. // Returns LT_OK or LT_ERROR if not a sprite.
  513. // Pass in INVALID_HPOLY to un-clip the sprite.
  514. LTRESULT (*ClipSprite)(HOBJECT hObj, HPOLY hPoly);
  515. // Light manipulation.
  516. // Get/Set a light's color (RGB, 0.0f to 1.0f).
  517. // When you create a light, its color defaults to (0,0,0).
  518. // Note: a light's color is snapped to 256 different values, so if
  519. // you want to do any fancy interpolation or anything, you'll need
  520. // to store your own, higher precision, color values.
  521. // Note: this just calls GetObjectColor/SetObjectColor.
  522. void (*GetLightColor)(HOBJECT hObj, float *r, float *g, float *b);
  523. void (*SetLightColor)(HOBJECT hObj, float r, float g, float b);
  524. // Get/Set a light's radius.
  525. // When you create a light, its radius defaults to 100.
  526. float (*GetLightRadius)(HOBJECT hObj);
  527. void (*SetLightRadius)(HOBJECT hObj, float radius);
  528. // Model manipulation.
  529. // Iterate through the model's nodes. Returns LT_FINISHED when there are no more.
  530. // hCurNode = INVALID_MODEL_NODE;
  531. // while(interface->GetNextModelNode(hModel, hCurNode, &hCurNode) == LT_OK)
  532. // { ... }
  533. LTRESULT (*GetNextModelNode)(HOBJECT hObject, HMODELNODE hNode, HMODELNODE *pNext);
  534. // Get a model node's name.
  535. LTRESULT (*GetModelNodeName)(HOBJECT hObject, HMODELNODE hNode, char *pName, uint32 maxLen);
  536. // Get a model's command string.
  537. LTRESULT (*GetModelCommandString)(HOBJECT hObj, char *pStr, uint32 maxLen);
  538. // Hide/unhide a node on the model (they're all unhidden by default).
  539. // Returns LT_OK, LT_ERROR, LT_NOCHANGE, or LT_NODENOTFOUND.
  540. LTRESULT (*SetModelNodeHideStatus)(HOBJECT hObj, char *pNodeName, LTBOOL bHidden);
  541. LTRESULT (*GetModelNodeHideStatus)(HOBJECT hObj, char *pNodeName, /* out */LTBOOL *bHidden);
  542. // Get the animation name from an animation.
  543. // Returns LTNULL if the handle is invalid
  544. const char *(*GetAnimName)(HOBJECT hObject, HMODELANIM hAnim);
  545. // Get/Set the Playing state of the model. The default state is FALSE.
  546. void (*SetModelPlaying)(HOBJECT hObj, LTBOOL bPlaying);
  547. LTBOOL (*GetModelPlaying)(HOBJECT hObj);
  548. // Get the model filenames. You can pass in LTNULL for pFilename and pSkinName.
  549. // Returns LTFALSE if the object is not a model.
  550. // Initializes pFilename or pSkinName to zero length if the model doesn't have
  551. // a filename or skin.
  552. LTBOOL (*GetModelFilenames)(HOBJECT hObj, char *pFilename, int fileBufLen, char *pSkinName, int skinBufLen);
  553. // OBSOLETE: use ILTCommon::SetObjectFilenames.
  554. virtual LTRESULT SetModelFilenames(HOBJECT hObj, char *pFilename, char *pSkinName)=0;
  555. virtual LTRESULT SetObjectFilenames(HOBJECT hObj, char *pFilename, char *pSkinName)=0;
  556. // OBSOLETE: use ILTCommon.
  557. virtual LTRESULT GetModelAnimUserDims(HOBJECT hObj, LTVector *pDims, HMODELANIM hAnim)=0;
  558. // Container manipulation.
  559. // Gets the list of containers the object is inside.
  560. // pFlagList must be the same size as pContainerList.
  561. // Returns the number of elements in pList filled in.
  562. uint32 (*GetObjectContainers)(HOBJECT hObj,
  563. HOBJECT *pContainerList, uint32 *pFlagList, uint32 maxListSize);
  564. // Gets the list of objects inside the container.
  565. // Returns the number of elements in pList filled in.
  566. uint32 (*GetContainedObjects)(HOBJECT hContainer,
  567. HOBJECT *pObjectList, uint32 *pFlagList, uint32 maxListSize);
  568. // Surface manipulation.
  569. // OBSOLETE: use ILTCommon.
  570. virtual LTRESULT GetPolyTextureFlags(HPOLY hPoly, uint32 *pFlags)=0;
  571. // Save game
  572. // dwParam gets passed into MID_SAVEOBJECT as fData.
  573. // Flags is a SAVEOBJECTS_ define.
  574. LTRESULT (*SaveObjects)(char *pszSaveFileName, ObjectList *pList, uint32 dwParam, uint32 flags);
  575. // dwParam gets passed into MID_LOADOBJECT as fData.
  576. // Flags is a combination of RESTOREOBJECTS_ defines.
  577. LTRESULT (*RestoreObjects)( char *pszRestoreFileName, uint32 dwParam, uint32 flags );
  578. // Load world
  579. // Flags is a combination of the LOADWORLD_ flags.
  580. LTRESULT (*LoadWorld)(char *pszWorldFileName, uint32 flags);
  581. LTRESULT (*RunWorld)();
  582. // Network session manipulation
  583. // Updates the sessions' name.
  584. LTRESULT (*UpdateSessionName)(const char* sName);
  585. // Gets the sessions' name.
  586. LTRESULT (*GetSessionName)(char* sName, uint32 dwBufferSize);
  587. // Send a message to the standalone server app. Returns LT_NOTFOUND
  588. // if there is no server app or if it isn't setup to receive the message.
  589. LTRESULT (*SendToServerApp)( char *pMsg, uint32 nLen );
  590. // Gets the tcp/ip address of the main driver if available.
  591. // If you're hosting a game, hostPort is filled in with the port you're hosting on.
  592. // If not, it's set to 0xFFFF.
  593. LTRESULT (*GetTcpIpAddress)(char* sAddress, uint32 dwBufferSize, uint16 &hostPort);
  594. // Get a list of files/directories in a directory (pass in "" to start with).
  595. // The list is a noncircular linked list with DNULL terminating it.
  596. FileEntry* (*GetFileList)(char *pDirName);
  597. // Use FreeFileList when you're done with each list you get.
  598. void (*FreeFileList)(FileEntry *pHead);
  599. virtual LTRESULT GetClientData(HCLIENT hClient, void *&pData, uint32 &nLength) = 0;
  600. };
  601. #endif // __ILTSERVER_H__