codemp/cgame/cg_public.h

Go to the documentation of this file.
00001 // Copyright (C) 1999-2000 Id Software, Inc.
00002 //
00003 #ifndef __CG_PUBLIC_H
00004 #define __CG_PUBLIC_H
00005 
00006 #define CMD_BACKUP                      64      
00007 #define CMD_MASK                        (CMD_BACKUP - 1)
00008 // allow a lot of command backups for very fast systems
00009 // multiple commands may be combined into a single packet, so this
00010 // needs to be larger than PACKET_BACKUP
00011 
00012 
00013 #define MAX_ENTITIES_IN_SNAPSHOT        256
00014 
00015 // snapshots are a view of the server at a given time
00016 
00017 // Snapshots are generated at regular time intervals by the server,
00018 // but they may not be sent if a client's rate level is exceeded, or
00019 // they may be dropped by the network.
00020 typedef struct {
00021         int                             snapFlags;                      // SNAPFLAG_RATE_DELAYED, etc
00022         int                             ping;
00023 
00024         int                             serverTime;             // server time the message is valid for (in msec)
00025 
00026         byte                    areamask[MAX_MAP_AREA_BYTES];           // portalarea visibility bits
00027 
00028         playerState_t   ps;                                             // complete information about the current player at this time
00029         playerState_t   vps; //vehicle I'm riding's playerstate (if applicable) -rww
00030 
00031         int                             numEntities;                    // all of the entities that need to be presented
00032         entityState_t   entities[MAX_ENTITIES_IN_SNAPSHOT];     // at the time of this snapshot
00033 
00034         int                             numServerCommands;              // text based server commands to execute when this
00035         int                             serverCommandSequence;  // snapshot becomes current
00036 } snapshot_t;
00037 
00038 enum {
00039   CGAME_EVENT_NONE,
00040   CGAME_EVENT_TEAMMENU,
00041   CGAME_EVENT_SCOREBOARD,
00042   CGAME_EVENT_EDITHUD
00043 };
00044 
00045 
00046 /*
00047 ==================================================================
00048 
00049 functions imported from the main executable
00050 
00051 ==================================================================
00052 */
00053 
00054 #define CGAME_IMPORT_API_VERSION        5
00055 
00056 typedef enum {
00057         CG_PRINT = 0,
00058         CG_ERROR,
00059         CG_MILLISECONDS,
00060 
00061         //Also for profiling.. do not use for game related tasks.
00062         CG_PRECISIONTIMER_START,
00063         CG_PRECISIONTIMER_END,
00064 
00065         CG_CVAR_REGISTER,
00066         CG_CVAR_UPDATE,
00067         CG_CVAR_SET,
00068         CG_CVAR_VARIABLESTRINGBUFFER,
00069         CG_CVAR_GETHIDDENVALUE,
00070         CG_ARGC,
00071         CG_ARGV,
00072         CG_ARGS,
00073         CG_FS_FOPENFILE,
00074         CG_FS_READ,
00075         CG_FS_WRITE,
00076         CG_FS_FCLOSEFILE,
00077         CG_FS_GETFILELIST,
00078         CG_SENDCONSOLECOMMAND,
00079         CG_ADDCOMMAND,
00080         CG_REMOVECOMMAND,
00081         CG_SENDCLIENTCOMMAND,
00082         CG_UPDATESCREEN,
00083         CG_CM_LOADMAP,
00084         CG_CM_NUMINLINEMODELS,
00085         CG_CM_INLINEMODEL,
00086         CG_CM_TEMPBOXMODEL,
00087         CG_CM_TEMPCAPSULEMODEL,
00088         CG_CM_POINTCONTENTS,
00089         CG_CM_TRANSFORMEDPOINTCONTENTS,
00090         CG_CM_BOXTRACE,
00091         CG_CM_CAPSULETRACE,
00092         CG_CM_TRANSFORMEDBOXTRACE,
00093         CG_CM_TRANSFORMEDCAPSULETRACE,
00094         CG_CM_MARKFRAGMENTS,
00095         CG_S_GETVOICEVOLUME,
00096         CG_S_MUTESOUND,
00097         CG_S_STARTSOUND,
00098         CG_S_STARTLOCALSOUND,
00099         CG_S_CLEARLOOPINGSOUNDS,
00100         CG_S_ADDLOOPINGSOUND,
00101         CG_S_UPDATEENTITYPOSITION,
00102         CG_S_ADDREALLOOPINGSOUND,
00103         CG_S_STOPLOOPINGSOUND,
00104         CG_S_RESPATIALIZE,
00105         CG_S_SHUTUP,
00106         CG_S_REGISTERSOUND,
00107         CG_S_STARTBACKGROUNDTRACK,
00108 
00109         //rww - AS trap implem
00110         CG_S_UPDATEAMBIENTSET,
00111         CG_AS_PARSESETS,
00112         CG_AS_ADDPRECACHEENTRY,
00113         CG_S_ADDLOCALSET,
00114         CG_AS_GETBMODELSOUND,
00115 
00116         CG_R_LOADWORLDMAP,
00117         CG_R_REGISTERMODEL,
00118         CG_R_REGISTERSKIN,
00119         CG_R_REGISTERSHADER,
00120         CG_R_REGISTERSHADERNOMIP,
00121         CG_R_REGISTERFONT,
00122         CG_R_FONT_STRLENPIXELS,
00123         CG_R_FONT_STRLENCHARS,
00124         CG_R_FONT_STRHEIGHTPIXELS,
00125         CG_R_FONT_DRAWSTRING,
00126         CG_LANGUAGE_ISASIAN,
00127         CG_LANGUAGE_USESSPACES,
00128         CG_ANYLANGUAGE_READCHARFROMSTRING,
00129 
00130         CGAME_MEMSET = 100,
00131         CGAME_MEMCPY,
00132         CGAME_STRNCPY,
00133         CGAME_SIN,
00134         CGAME_COS,
00135         CGAME_ATAN2,
00136         CGAME_SQRT,
00137         CGAME_MATRIXMULTIPLY,
00138         CGAME_ANGLEVECTORS,
00139         CGAME_PERPENDICULARVECTOR,
00140         CGAME_FLOOR,
00141         CGAME_CEIL,
00142 
00143         CGAME_TESTPRINTINT,
00144         CGAME_TESTPRINTFLOAT,
00145 
00146         CGAME_ACOS,
00147         CGAME_ASIN,
00148 
00149         CG_R_CLEARSCENE = 200,
00150         CG_R_CLEARDECALS,
00151         CG_R_ADDREFENTITYTOSCENE,
00152         CG_R_ADDPOLYTOSCENE,
00153         CG_R_ADDPOLYSTOSCENE,
00154         CG_R_ADDDECALTOSCENE,
00155         CG_R_LIGHTFORPOINT,
00156         CG_R_ADDLIGHTTOSCENE,
00157         CG_R_ADDADDITIVELIGHTTOSCENE,
00158         CG_R_RENDERSCENE,
00159         CG_R_SETCOLOR,
00160         CG_R_DRAWSTRETCHPIC,
00161         CG_R_MODELBOUNDS,
00162         CG_R_LERPTAG,
00163         CG_R_DRAWROTATEPIC,
00164         CG_R_DRAWROTATEPIC2,
00165         CG_R_SETRANGEFOG, //linear fogging, with settable range -rww
00166         CG_R_SETREFRACTIONPROP, //set some properties for the draw layer for my refractive effect (here primarily for mod authors) -rww
00167         CG_R_REMAP_SHADER,
00168         CG_R_GET_LIGHT_STYLE,
00169         CG_R_SET_LIGHT_STYLE,
00170         CG_R_GET_BMODEL_VERTS,
00171         CG_R_GETDISTANCECULL,
00172 
00173         CG_R_GETREALRES,
00174         CG_R_AUTOMAPELEVADJ,
00175         CG_R_INITWIREFRAMEAUTO,
00176 
00177         CG_FX_ADDLINE,
00178 
00179         CG_GETGLCONFIG,
00180         CG_GETGAMESTATE,
00181         CG_GETCURRENTSNAPSHOTNUMBER,
00182         CG_GETSNAPSHOT,
00183         CG_GETDEFAULTSTATE,
00184         CG_GETSERVERCOMMAND,
00185         CG_GETCURRENTCMDNUMBER,
00186         CG_GETUSERCMD,
00187         CG_SETUSERCMDVALUE,
00188         CG_SETCLIENTFORCEANGLE,
00189         CG_SETCLIENTTURNEXTENT,
00190         CG_OPENUIMENU,
00191         CG_TESTPRINTINT,
00192         CG_TESTPRINTFLOAT,
00193         CG_MEMORY_REMAINING,
00194         CG_KEY_ISDOWN,
00195         CG_KEY_GETCATCHER,
00196         CG_KEY_SETCATCHER,
00197         CG_KEY_GETKEY,
00198 
00199         CG_PC_ADD_GLOBAL_DEFINE,
00200         CG_PC_LOAD_SOURCE,
00201         CG_PC_FREE_SOURCE,
00202         CG_PC_READ_TOKEN,
00203         CG_PC_SOURCE_FILE_AND_LINE,
00204         CG_PC_LOAD_GLOBAL_DEFINES,
00205         CG_PC_REMOVE_ALL_GLOBAL_DEFINES,
00206 
00207         CG_S_STOPBACKGROUNDTRACK,
00208         CG_REAL_TIME,
00209         CG_SNAPVECTOR,
00210         CG_CIN_PLAYCINEMATIC,
00211         CG_CIN_STOPCINEMATIC,
00212         CG_CIN_RUNCINEMATIC,
00213         CG_CIN_DRAWCINEMATIC,
00214         CG_CIN_SETEXTENTS,
00215 
00216         CG_GET_ENTITY_TOKEN,
00217         CG_R_INPVS,
00218 
00219         CG_FX_REGISTER_EFFECT,
00220         CG_FX_PLAY_EFFECT,
00221         CG_FX_PLAY_ENTITY_EFFECT,
00222         CG_FX_PLAY_EFFECT_ID,
00223         CG_FX_PLAY_PORTAL_EFFECT_ID,
00224         CG_FX_PLAY_ENTITY_EFFECT_ID,
00225         CG_FX_PLAY_BOLTED_EFFECT_ID,
00226         CG_FX_ADD_SCHEDULED_EFFECTS,
00227         CG_FX_INIT_SYSTEM,
00228         CG_FX_SET_REFDEF,
00229         CG_FX_FREE_SYSTEM,
00230         CG_FX_ADJUST_TIME,
00231         CG_FX_DRAW_2D_EFFECTS,
00232         CG_FX_RESET,
00233         CG_FX_ADDPOLY,
00234         CG_FX_ADDBEZIER,
00235         CG_FX_ADDPRIMITIVE,
00236         CG_FX_ADDSPRITE,
00237         CG_FX_ADDELECTRICITY,
00238 
00239 //      CG_SP_PRINT,
00240         CG_SP_GETSTRINGTEXTSTRING,
00241 
00242         CG_ROFF_CLEAN,
00243         CG_ROFF_UPDATE_ENTITIES,
00244         CG_ROFF_CACHE,
00245         CG_ROFF_PLAY,
00246         CG_ROFF_PURGE_ENT,
00247 
00248 
00249         //rww - dynamic vm memory allocation!
00250         CG_TRUEMALLOC,
00251         CG_TRUEFREE,
00252 
00253 /*
00254 Ghoul2 Insert Start
00255 */
00256         CG_G2_LISTSURFACES,
00257         CG_G2_LISTBONES,
00258         CG_G2_SETMODELS,
00259         CG_G2_HAVEWEGHOULMODELS,
00260         CG_G2_GETBOLT,
00261         CG_G2_GETBOLT_NOREC,
00262         CG_G2_GETBOLT_NOREC_NOROT,
00263         CG_G2_INITGHOUL2MODEL,
00264         CG_G2_SETSKIN,
00265         CG_G2_COLLISIONDETECT,
00266         CG_G2_COLLISIONDETECTCACHE,
00267         CG_G2_CLEANMODELS,
00268         CG_G2_ANGLEOVERRIDE,
00269         CG_G2_PLAYANIM,
00270         CG_G2_GETBONEANIM,
00271         CG_G2_GETBONEFRAME, //trimmed down version of GBA, so I don't have to pass all those unused args across the VM-exe border
00272         CG_G2_GETGLANAME,
00273         CG_G2_COPYGHOUL2INSTANCE,
00274         CG_G2_COPYSPECIFICGHOUL2MODEL,
00275         CG_G2_DUPLICATEGHOUL2INSTANCE,
00276         CG_G2_HASGHOUL2MODELONINDEX,
00277         CG_G2_REMOVEGHOUL2MODEL,
00278         CG_G2_SKINLESSMODEL,
00279         CG_G2_GETNUMGOREMARKS,
00280         CG_G2_ADDSKINGORE,
00281         CG_G2_CLEARSKINGORE,
00282         CG_G2_SIZE,
00283         CG_G2_ADDBOLT,
00284         CG_G2_ATTACHENT,
00285         CG_G2_SETBOLTON,
00286         CG_G2_SETROOTSURFACE,
00287         CG_G2_SETSURFACEONOFF,
00288         CG_G2_SETNEWORIGIN,
00289         CG_G2_DOESBONEEXIST,
00290         CG_G2_GETSURFACERENDERSTATUS,
00291 
00292         CG_G2_GETTIME,
00293         CG_G2_SETTIME,
00294 
00295         CG_G2_ABSURDSMOOTHING,
00296 
00297 /*
00298         //rww - RAGDOLL_BEGIN
00299 */
00300         CG_G2_SETRAGDOLL,
00301         CG_G2_ANIMATEG2MODELS,
00302 /*
00303         //rww - RAGDOLL_END
00304 */
00305 
00306         //additional ragdoll options -rww
00307         CG_G2_RAGPCJCONSTRAINT,
00308         CG_G2_RAGPCJGRADIENTSPEED,
00309         CG_G2_RAGEFFECTORGOAL,
00310         CG_G2_GETRAGBONEPOS,
00311         CG_G2_RAGEFFECTORKICK,
00312         CG_G2_RAGFORCESOLVE,
00313 
00314         //rww - ik move method, allows you to specify a bone and move it to a world point (within joint constraints)
00315         //by using the majority of gil's existing bone angling stuff from the ragdoll code.
00316         CG_G2_SETBONEIKSTATE,
00317         CG_G2_IKMOVE,
00318 
00319         CG_G2_REMOVEBONE,
00320 
00321         CG_G2_ATTACHINSTANCETOENTNUM,
00322         CG_G2_CLEARATTACHEDINSTANCE,
00323         CG_G2_CLEANENTATTACHMENTS,
00324         CG_G2_OVERRIDESERVER,
00325 
00326         CG_G2_GETSURFACENAME,
00327 
00328         CG_SET_SHARED_BUFFER,
00329 
00330         CG_CM_REGISTER_TERRAIN,
00331         CG_RMG_INIT,
00332         CG_RE_INIT_RENDERER_TERRAIN,
00333         CG_R_WEATHER_CONTENTS_OVERRIDE,
00334         CG_R_WORLDEFFECTCOMMAND,
00335         //Adding trap to get weather working
00336         CG_WE_ADDWEATHERZONE
00337 
00338 /*
00339 Ghoul2 Insert End
00340 */
00341 } cgameImport_t;
00342 
00343 
00344 /*
00345 ==================================================================
00346 
00347 functions exported to the main executable
00348 
00349 ==================================================================
00350 */
00351 
00352 typedef enum {
00353         CG_INIT,
00354 //      void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum )
00355         // called when the level loads or when the renderer is restarted
00356         // all media should be registered at this time
00357         // cgame will display loading status by calling SCR_Update, which
00358         // will call CG_DrawInformation during the loading process
00359         // reliableCommandSequence will be 0 on fresh loads, but higher for
00360         // demos, tourney restarts, or vid_restarts
00361 
00362         CG_SHUTDOWN,
00363 //      void (*CG_Shutdown)( void );
00364         // oportunity to flush and close any open files
00365 
00366         CG_CONSOLE_COMMAND,
00367 //      qboolean (*CG_ConsoleCommand)( void );
00368         // a console command has been issued locally that is not recognized by the
00369         // main game system.
00370         // use Cmd_Argc() / Cmd_Argv() to read the command, return qfalse if the
00371         // command is not known to the game
00372 
00373         CG_DRAW_ACTIVE_FRAME,
00374 //      void (*CG_DrawActiveFrame)( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback );
00375         // Generates and draws a game scene and status information at the given time.
00376         // If demoPlayback is set, local movement prediction will not be enabled
00377 
00378         CG_CROSSHAIR_PLAYER,
00379 //      int (*CG_CrosshairPlayer)( void );
00380 
00381         CG_LAST_ATTACKER,
00382 //      int (*CG_LastAttacker)( void );
00383 
00384         CG_KEY_EVENT, 
00385 //      void    (*CG_KeyEvent)( int key, qboolean down );
00386 
00387         CG_MOUSE_EVENT,
00388 //      void    (*CG_MouseEvent)( int dx, int dy );
00389         CG_EVENT_HANDLING,
00390 //      void (*CG_EventHandling)(int type);
00391 
00392         CG_POINT_CONTENTS,
00393 //      int     CG_PointContents( const vec3_t point, int passEntityNum );
00394 
00395         CG_GET_LERP_ORIGIN,
00396 //      void CG_LerpOrigin(int num, vec3_t result);
00397 
00398         CG_GET_LERP_DATA,
00399         CG_GET_GHOUL2,
00400         CG_GET_MODEL_LIST,
00401 
00402         CG_CALC_LERP_POSITIONS,
00403 //      void CG_CalcEntityLerpPositions(int num);
00404 
00405         CG_TRACE,
00406         CG_G2TRACE,
00407 //void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, 
00408 //                                       int skipNumber, int mask );
00409 
00410         CG_G2MARK,
00411 
00412         CG_RAG_CALLBACK,
00413 
00414         CG_INCOMING_CONSOLE_COMMAND,
00415 
00416         CG_GET_USEABLE_FORCE,
00417 
00418         CG_GET_ORIGIN,          // int entnum, vec3_t origin
00419         CG_GET_ANGLES,          // int entnum, vec3_t angle
00420 
00421         CG_GET_ORIGIN_TRAJECTORY,               // int entnum
00422         CG_GET_ANGLE_TRAJECTORY,                // int entnum
00423 
00424         CG_ROFF_NOTETRACK_CALLBACK,             // int entnum, char *notetrack
00425 
00426         CG_IMPACT_MARK,
00427 //void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir, 
00428 //                                 float orientation, float red, float green, float blue, float alpha,
00429 //                                 qboolean alphaFade, float radius, qboolean temporary )
00430 
00431         CG_MAP_CHANGE,
00432 
00433         CG_AUTOMAP_INPUT,
00434 
00435         CG_MISC_ENT, //rwwRMG - added
00436 
00437         CG_GET_SORTED_FORCE_POWER,
00438 
00439         CG_FX_CAMERASHAKE,//mcg post-gold added
00440 } cgameExport_t;
00441 
00442 typedef struct
00443 {
00444         float           up;
00445         float           down;
00446         float           yaw;
00447         float           pitch;
00448         qboolean        goToDefaults;
00449 } autoMapInput_t;
00450 
00451 // CG_POINT_CONTENTS
00452 typedef struct
00453 {
00454         vec3_t          mPoint;                 // input
00455         int                     mPassEntityNum; // input
00456 } TCGPointContents;
00457 
00458 // CG_GET_BOLT_POS
00459 typedef struct
00460 {
00461         vec3_t          mOrigin;                // output
00462         vec3_t          mAngles;                // output
00463         vec3_t          mScale;                 // output
00464         int                     mEntityNum;             // input
00465 } TCGGetBoltData;
00466 
00467 // CG_IMPACT_MARK
00468 typedef struct
00469 {
00470         int             mHandle;
00471         vec3_t  mPoint;
00472         vec3_t  mAngle;
00473         float   mRotation;
00474         float   mRed;
00475         float   mGreen;
00476         float   mBlue;
00477         float   mAlphaStart;
00478         float   mSizeStart;
00479 } TCGImpactMark;
00480 
00481 // CG_GET_LERP_ORIGIN
00482 // CG_GET_LERP_ANGLES
00483 // CG_GET_MODEL_SCALE
00484 typedef struct
00485 {
00486         int                     mEntityNum;             // input
00487         vec3_t          mPoint;                 // output
00488 } TCGVectorData;
00489 
00490 // CG_TRACE/CG_G2TRACE
00491 typedef struct
00492 {
00493         trace_t mResult;                                        // output
00494         vec3_t  mStart, mMins, mMaxs, mEnd;     // input
00495         int             mSkipNumber, mMask;                     // input
00496 } TCGTrace;
00497 
00498 // CG_G2MARK
00499 typedef struct
00500 {
00501         int                     shader;
00502         float           size;
00503         vec3_t          start, dir;
00504 } TCGG2Mark;
00505 
00506 // CG_INCOMING_CONSOLE_COMMAND
00507 typedef struct
00508 {
00509         char conCommand[1024];
00510 } TCGIncomingConsoleCommand;
00511 
00512 // CG_FX_CAMERASHAKE
00513 typedef struct
00514 {
00515         vec3_t  mOrigin;                                        // input
00516         float   mIntensity;                                     // input
00517         int             mRadius;                                        // input
00518         int             mTime;                                          // input
00519 } TCGCameraShake;
00520 
00521 // CG_MISC_ENT
00522 typedef struct
00523 {
00524         char    mModel[MAX_QPATH];                      // input
00525         vec3_t  mOrigin, mAngles, mScale;       // input
00526 } TCGMiscEnt;
00527 
00528 typedef struct
00529 {
00530         refEntity_t             ent;                            // output
00531         void                    *ghoul2;                        // input
00532         int                             modelIndex;                     // input
00533         int                             boltIndex;                      // input
00534         vec3_t                  origin;                         // input
00535         vec3_t                  angles;                         // input
00536         vec3_t                  modelScale;                     // input
00537 } TCGPositionOnBolt;
00538 
00539 //ragdoll callback structs -rww
00540 #define RAG_CALLBACK_NONE                               0
00541 #define RAG_CALLBACK_DEBUGBOX                   1
00542 typedef struct
00543 {
00544         vec3_t                  mins;
00545         vec3_t                  maxs;
00546         int                             duration;
00547 } ragCallbackDebugBox_t;
00548 
00549 #define RAG_CALLBACK_DEBUGLINE                  2
00550 typedef struct
00551 {
00552         vec3_t                  start;
00553         vec3_t                  end;
00554         int                             time;
00555         int                             color;
00556         int                             radius;
00557 } ragCallbackDebugLine_t;
00558 
00559 #define RAG_CALLBACK_BONESNAP                   3
00560 typedef struct
00561 {
00562         char                    boneName[128]; //name of the bone in question
00563         int                             entNum; //index of entity who owns the bone in question
00564 } ragCallbackBoneSnap_t;
00565 
00566 #define RAG_CALLBACK_BONEIMPACT                 4
00567 typedef struct
00568 {
00569         char                    boneName[128]; //name of the bone in question
00570         int                             entNum; //index of entity who owns the bone in question
00571 } ragCallbackBoneImpact_t;
00572 
00573 #define RAG_CALLBACK_BONEINSOLID                5
00574 typedef struct
00575 {
00576         vec3_t                  bonePos; //world coordinate position of the bone
00577         int                             entNum; //index of entity who owns the bone in question
00578         int                             solidCount; //higher the count, the longer we've been in solid (the worse off we are)
00579 } ragCallbackBoneInSolid_t;
00580 
00581 #define RAG_CALLBACK_TRACELINE                  6
00582 typedef struct
00583 {
00584         trace_t                 tr;
00585         vec3_t                  start;
00586         vec3_t                  end;
00587         vec3_t                  mins;
00588         vec3_t                  maxs;
00589         int                             ignore;
00590         int                             mask;
00591 } ragCallbackTraceLine_t;
00592 
00593 #define MAX_CG_SHARED_BUFFER_SIZE               2048
00594 
00595 //----------------------------------------------
00596 
00597 #endif // __CG_PUBLIC_H