code refactoring, still testing

some fixes all over the place
fixed all warnings from clang
This commit is contained in:
jeefo 2016-03-12 14:35:44 +03:00
commit bc2e57a7a8
22 changed files with 984 additions and 1051 deletions

View file

@ -149,7 +149,7 @@ typedef struct enginefuncs_s
void (*pfnGetAimVector) (edict_t *ent, float speed, float *rgflReturn);
void (*pfnServerCommand) (char *str);
void (*pfnServerExecute) (void);
void (*pfnClientCommand) (edict_t *ent, char *szFmt, ...);
void (*pfnClientCommand) (edict_t *ent, char const *szFmt, ...);
void (*pfnParticleEffect) (const float *org, const float *dir, float color, float count);
void (*pfnLightStyle) (int style, char *val);
int (*pfnDecalIndex) (const char *name);
@ -203,7 +203,7 @@ typedef struct enginefuncs_s
void (*pfnSetView) (const edict_t *client, const edict_t *pViewent);
float (*pfnTime) (void);
void (*pfnCrosshairAngle) (const edict_t *client, float pitch, float yaw);
byte *(*pfnLoadFileForMe) (char *szFilename, int *pLength);
byte *(*pfnLoadFileForMe) (char const *szFilename, int *pLength);
void (*pfnFreeFile) (void *buffer);
void (*pfnEndSection) (const char *pszSectionName); // trigger_endsection
int (*pfnCompareFileTime) (char *filename1, char *filename2, int *compare);
@ -215,9 +215,9 @@ typedef struct enginefuncs_s
void (*pfnRunPlayerMove) (edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec);
int (*pfnNumberOfEntities) (void);
char *(*pfnGetInfoKeyBuffer) (edict_t *e); // passing in NULL gets the serverinfo
char *(*pfnInfoKeyValue) (char *infobuffer, char *key);
char *(*pfnInfoKeyValue) (char *infobuffer, char const *key);
void (*pfnSetKeyValue) (char *infobuffer, char *key, char *value);
void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, char *key, char *value);
void (*pfnSetClientKeyValue) (int clientIndex, char *infobuffer, char const *key, char const *value);
int (*pfnIsMapValid) (char *szFilename);
void (*pfnStaticDecal) (const float *origin, int decalIndex, int entityIndex, int modelIndex);
int (*pfnPrecacheGeneric) (char *s);
@ -280,7 +280,7 @@ typedef struct enginefuncs_s
typedef struct KeyValueData_s
{
char *szClassName; // in: entity classname
char *szKeyName; // in: name of key
char const *szKeyName; // in: name of key
char *szValue; // in: value of key
int32 fHandled; // out: DLL sets to true if key-value pair was understood
} KeyValueData;

View file

@ -37,13 +37,13 @@ typedef enum
typedef struct
{
char *ifvers;
char *name;
char *version;
char *date;
char *author;
char *url;
char *logtag;
char const *ifvers;
char const *name;
char const *version;
char const *date;
char const *author;
char const *url;
char const *logtag;
PLUG_LOADTIME loadable;
PLUG_LOADTIME unloadable;
} plugin_info_t;

View file

@ -53,12 +53,6 @@ static inline edict_t *FIND_ENTITY_BY_TARGET (edict_t *entStart, const char *psz
#define ClearBits(flBitVector, bits) ((flBitVector) = (int)(flBitVector) & ~(bits))
#define FBitSet(flBitVector, bit) ((int)(flBitVector) & (bit))
// Pointer operators
#define PTR_TO_BYTE(in) *(byte *) (in)
#define PTR_TO_FLT(in) *(float *) (in)
#define PTR_TO_INT(in) *(int *) (in)
#define PTR_TO_STR(in) (char *) (in)
// Makes these more explicit, and easier to find
#define FILE_GLOBAL static
@ -82,6 +76,7 @@ typedef int BOOL;
//
// Conversion among the three types of "entity", including identity-conversions.
//
#if 0
static inline edict_t *ENT (const entvars_t *pev)
{
return pev->pContainingEntity;
@ -131,12 +126,14 @@ static inline entvars_t *VARS (EOFFSET eoffset)
{
return VARS (ENT (eoffset));
}
#endif
static inline void MESSAGE_BEGIN (int msg_dest, int msg_type, const float *pOrigin, entvars_t *ent)
{
(*g_engfuncs.pfnMessageBegin) (msg_dest, msg_type, pOrigin, ENT (ent));
(*g_engfuncs.pfnMessageBegin) (msg_dest, msg_type, pOrigin, ent->pContainingEntity);
}
#if 0
// Testing the three types of "entity" for nullity
#define eoNullEntity 0
static inline BOOL FNullEnt (EOFFSET eoffset)
@ -162,6 +159,7 @@ static inline BOOL FStringNull (int stingPtr)
#define cchMapNameMost 32
#define SAFE_FUNCTION_CALL(pfn,args) try { pfn args; } catch (...) { }
#endif
// Dot products for view cone checking
#define VIEW_FIELD_FULL (float)-1.0 // +-180 degrees
@ -176,7 +174,7 @@ static inline BOOL FStrEq (const char *sz1, const char *sz2)
}
static inline BOOL FClassnameIs (edict_t *pent, const char *szClassname)
{
return FStrEq (STRING (VARS (pent)->classname), szClassname);
return FStrEq (STRING (pent->v.classname), szClassname);
}
static inline BOOL FClassnameIs (entvars_t *pev, const char *szClassname)
{