game.h

Go to the documentation of this file.
00001 
00006 /*
00007 All original material Copyright (C) 2002-2010 UFO: Alien Invasion.
00008 
00009 Original file from Quake 2 v3.21: quake2-2.31/game/game.h
00010 Copyright (C) 1997-2001 Id Software, Inc.
00011 
00012 This program is free software; you can redistribute it and/or
00013 modify it under the terms of the GNU General Public License
00014 as published by the Free Software Foundation; either version 2
00015 of the License, or (at your option) any later version.
00016 
00017 This program is distributed in the hope that it will be useful,
00018 but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00020 
00021 See the GNU General Public License for more details.
00022 
00023 You should have received a copy of the GNU General Public License
00024 along with this program; if not, write to the Free Software
00025 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00026 
00027 */
00028 
00029 #ifndef GAME_GAME_H
00030 #define GAME_GAME_H
00031 
00032 #include "../shared/defines.h"
00033 #include "../shared/typedefs.h"
00034 #include "../common/tracing.h"
00035 #include "../common/cvar.h"
00036 
00037 #define GAME_API_VERSION    8
00038 
00040 typedef enum {
00041     SOLID_NOT,                  
00042     SOLID_TRIGGER,              
00043     SOLID_BBOX,                 
00044     SOLID_BSP                   
00045 } solid_t;
00046 
00047 /*=============================================================== */
00048 
00049 typedef struct edict_s edict_t;
00050 typedef struct player_s player_t;
00051 
00052 
00053 #ifndef GAME_INCLUDE
00054 
00055 struct player_s {
00056     qboolean inuse;
00057     int num;                    
00058     qboolean isReady;
00059 
00062 };
00063 
00065 struct edict_s {
00066     qboolean inuse;
00067     int linkcount;      
00070     int number;         
00072     vec3_t origin;      
00073     vec3_t angles;      
00076     solid_t solid;
00077 
00078     vec3_t mins, maxs; 
00079     vec3_t absmin, absmax; 
00080     vec3_t size;
00081 
00082     edict_t *child; 
00083     edict_t *owner; 
00084     int modelindex; 
00085 };
00086 
00087 
00088 #endif  /* GAME_INCLUDE */
00089 
00090 /*=============================================================== */
00091 
00093 typedef struct {
00094     /* client/server information */
00095     int seed; 
00096     csi_t *csi;
00097     routing_t *routingMap;  
00099     /* special messages */
00100 
00102     void (IMPORT *BroadcastPrintf) (int printlevel, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
00104     void (IMPORT *DPrintf) (const char *fmt, ...) __attribute__((format(printf, 1, 2)));
00106     void (IMPORT *PlayerPrintf) (const player_t * player, int printlevel, const char *fmt, va_list ap);
00107 
00108     void (IMPORT *PositionedSound) (int mask, const vec3_t origin, const edict_t *ent, const char *sound);
00109 
00113     void (IMPORT *ConfigString) (int num, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
00114 
00116     void (IMPORT *Error) (const char *fmt, ...) __attribute__((noreturn, format(printf, 1, 2)));
00117 
00119     int (IMPORT *ModelIndex) (const char *name);
00120 
00122     void (IMPORT *SetInlineModelOrientation) (const char *name, const vec3_t origin, const vec3_t angles);
00123 
00124     void (IMPORT *SetModel) (edict_t * ent, const char *name);
00125 
00131     trace_t (IMPORT *Trace) (const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, const edict_t * passent, int contentmask);
00132 
00133     int (IMPORT *PointContents) (vec3_t point);
00134     const char* (IMPORT *GetFootstepSound) (const char* texture);
00135     float (IMPORT *GetBounceFraction) (const char *texture);
00136     qboolean (IMPORT *LoadModelMinsMaxs) (const char *model, int frame, vec3_t mins, vec3_t maxs);
00137 
00140     void (IMPORT *LinkEdict) (edict_t * ent);
00142     void (IMPORT *UnlinkEdict) (edict_t * ent);
00143     int (IMPORT *BoxEdicts) (const vec3_t mins, const vec3_t maxs, edict_t **list, int maxcount);
00144     int (IMPORT *TouchEdicts) (const vec3_t mins, const vec3_t maxs, edict_t **list, int maxcount, edict_t *skip);
00145 
00147     qboolean (IMPORT *TestLine) (const vec3_t start, const vec3_t stop, const int levelmask);
00149     qboolean (IMPORT *TestLineWithEnt) (const vec3_t start, const vec3_t stop, const int levelmask, const char **entlist);
00150     float (IMPORT *GrenadeTarget) (const vec3_t from, const vec3_t at, float speed, qboolean launched, qboolean rolled, vec3_t v0);
00151 
00152     void (IMPORT *MoveCalc) (const routing_t * map, actorSizeEnum_t actorSize, pathing_t * path, const pos3_t from, byte crouchingState, int distance, pos_t ** forbiddenList, int forbiddenListLength);
00153     void (IMPORT *MoveStore) (pathing_t * path);
00154     pos_t (IMPORT *MoveLength) (const pathing_t * path, const pos3_t to, byte crouchingState, qboolean stored);
00155     int (IMPORT *MoveNext) (const pathing_t *path, const pos3_t from, byte crouchingState);
00156     int (IMPORT *GridFloor) (const routing_t * map, actorSizeEnum_t actorSize, const pos3_t pos);
00157     int (IMPORT *GetTUsForDirection) (int dir);
00158     pos_t (IMPORT *GridFall) (const routing_t * map, actorSizeEnum_t actorSize, const pos3_t pos);
00159     void (IMPORT *GridPosToVec) (const routing_t * map, actorSizeEnum_t actorSize, const pos3_t pos, vec3_t vec);
00160     void (IMPORT *GridRecalcRouting) (routing_t * map, const char *name, const char **list);
00161 
00162     /* filesystem functions */
00163     const char *(IMPORT *FS_Gamedir) (void);
00164     int (IMPORT *FS_LoadFile) (const char *path, byte **buffer);
00165     void (IMPORT *FS_FreeFile) (void *buffer);
00166 
00167     /* network messaging (writing) */
00168     void (IMPORT *WriteChar) (char c);
00169 
00170     void (IMPORT *WriteByte) (byte c);
00171     byte* (IMPORT *WriteDummyByte) (byte c);
00172     void (IMPORT *WriteShort) (int c);
00173 
00174     void (IMPORT *WriteLong) (int c);
00175     void (IMPORT *WriteString) (const char *s);
00176     void (IMPORT *WritePos) (const vec3_t pos); 
00177     void (IMPORT *WriteGPos) (const pos3_t pos);
00178     void (IMPORT *WriteDir) (const vec3_t pos); 
00179     void (IMPORT *WriteAngle) (float f);
00180     void (IMPORT *WriteFormat) (const char *format, ...);
00181 
00182     void (IMPORT *AbortEvents) (void);
00183     void (IMPORT *EndEvents) (void);
00184     void (IMPORT *AddEvent) (unsigned int mask, int eType);
00185     int (IMPORT *GetEvent) (void);
00186 
00187     /* network messaging (reading) */
00188     int (IMPORT *ReadChar) (void);
00189     int (IMPORT *ReadByte) (void);
00190     int (IMPORT *ReadShort) (void);
00191     int (IMPORT *ReadLong) (void);
00192     int (IMPORT *ReadString) (char *str, size_t length);
00193     void (IMPORT *ReadPos) (vec3_t pos);
00194     void (IMPORT *ReadGPos) (pos3_t pos);
00195     void (IMPORT *ReadDir) (vec3_t vector);
00196     float (IMPORT *ReadAngle) (void);
00197     void (IMPORT *ReadData) (void *buffer, int size);
00198     void (IMPORT *ReadFormat) (const char *format, ...);
00199 
00200     qboolean (IMPORT *GetConstInt) (const char *name, int *value);
00201     qboolean (IMPORT *GetConstIntFromNamespace) (const char *space, const char *name, int *value);
00202     const char* (IMPORT *GetConstVariable) (const char *space, int value);
00203     void (IMPORT *RegisterConstInt) (const char *name, int value);
00204     qboolean (IMPORT *UnregisterConstVariable) (const char *name);
00205 
00206     /* misc functions */
00207     void (IMPORT *GetCharacterValues) (const char *teamDefinition, character_t *chr);
00208 
00209     /* managed memory allocation */
00210     void *(IMPORT *TagMalloc) (int size, int tag, const char *file, int line);
00211     void (IMPORT *TagFree) (void *block, const char *file, int line);
00212     void (IMPORT *FreeTags) (int tag, const char *file, int line);
00213 
00214     /* console variable interaction */
00215     cvar_t *(IMPORT *Cvar_Get) (const char *varName, const char *value, int flags, const char* desc);
00216     cvar_t *(IMPORT *Cvar_Set) (const char *varName, const char *value);
00217     const char *(IMPORT *Cvar_String) (const char *varName);
00218 
00219     /* ClientCommand and ServerCommand parameter access */
00220     int (IMPORT *Cmd_Argc) (void);
00221     const char *(IMPORT *Cmd_Argv) (int n);
00222     const char *(IMPORT *Cmd_Args) (void);      
00226     void (IMPORT *AddCommandString) (const char *text);
00227 } game_import_t;
00228 
00230 typedef struct {
00231     int apiversion;
00232 
00236     void (EXPORT *Init) (void);
00237     void (EXPORT *Shutdown) (void);
00238 
00239     /* each new level entered will cause a call to G_SpawnEntities */
00240     void (EXPORT *SpawnEntities) (const char *mapname, qboolean day, const char *entstring);
00241 
00242     qboolean (EXPORT *ClientConnect) (player_t * client, char *userinfo, size_t userinfoSize);
00243     qboolean (EXPORT *ClientBegin) (player_t * client);
00244     void (EXPORT *ClientSpawn) (player_t * client);
00245     void (EXPORT *ClientUserinfoChanged) (player_t * client, char *userinfo);
00246     void (EXPORT *ClientDisconnect) (player_t * client);
00247     void (EXPORT *ClientCommand) (player_t * client);
00248 
00249     int (EXPORT *ClientAction) (player_t * client);
00250     void (EXPORT *ClientEndRound) (player_t * client);
00251     void (EXPORT *ClientTeamInfo) (const player_t * client);
00252     void (EXPORT *ClientInitActorStates) (const player_t * client);
00253     int (EXPORT *ClientGetTeamNum) (const player_t * client);
00254     int (EXPORT *ClientGetTeamNumPref) (const player_t * client);
00255     qboolean (EXPORT *ClientIsReady) (const player_t * client);
00256 
00257     int (EXPORT *ClientGetActiveTeam) (void);
00258     const char* (EXPORT *ClientGetName) (int pnum);
00259 
00260     qboolean (EXPORT *RunFrame) (void);
00261 
00266     void (EXPORT *ServerCommand) (void);
00267 
00268     /* global variables shared between game and server */
00269 
00270     /* The edict array is allocated in the game dll so it */
00271     /* can vary in size from one game to another. */
00272 
00274     struct edict_s *edicts;
00275     int edict_size;
00276     int num_edicts;             
00277     int max_edicts;
00278 
00279     struct player_s *players;
00280     int player_size;
00281     int maxplayersperteam;
00282 } game_export_t;
00283 
00284 game_export_t *GetGameAPI(game_import_t * import);
00285 
00286 #endif /* GAME_GAME_H */

Generated by  doxygen 1.6.2