qbsp: c++ compat changes

This commit is contained in:
Eric Wasylishen 2016-03-11 19:25:55 -07:00
parent a4c24ac0fa
commit 6e94f6a1c2
7 changed files with 51 additions and 4 deletions

View File

@ -23,6 +23,10 @@
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* FIXME - put this typedef elsewhere */
typedef uint8_t byte;
@ -243,4 +247,8 @@ void WriteBSPFile(void);
void PrintBSPFileSizes(void);
void BSPX_AddLump(const char *xname, const void *xdata, size_t xsize);
#ifdef __cplusplus
}
#endif
#endif /* __BSPFILE_H__ */

View File

@ -24,6 +24,14 @@
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
size_t LoadFile(const char *filename, void *bufptr, bool nofail);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -24,6 +24,10 @@
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#define MAXTOKEN 1024
typedef enum parseflags {
@ -43,4 +47,8 @@ typedef struct parser {
bool ParseToken(parser_t *p, parseflags_t flags);
void ParserInit(parser_t *p, const char *data);
#ifdef __cplusplus
}
#endif
#endif /* PARSER_H */

View File

@ -312,7 +312,7 @@ void BSPX_Brushes_AddModel(struct bspxbrushes_s *ctx, int modelnum, brush_t *bru
if (ctx->lumpmaxsize < ctx->lumpsize + sizeof(permodel) + permodel.numbrushes*sizeof(perbrush) + permodel.numfaces*sizeof(perface))
{
ctx->lumpmaxsize = (ctx->lumpsize + sizeof(permodel) + permodel.numbrushes*sizeof(perbrush) + permodel.numfaces*sizeof(perface))*2;
ctx->lumpinfo = realloc(ctx->lumpinfo, ctx->lumpmaxsize);
ctx->lumpinfo = (byte *) realloc(ctx->lumpinfo, ctx->lumpmaxsize);
}
permodel.ver = LittleLong(1);
@ -547,7 +547,7 @@ ProcessFile(void)
if (wadstring[0])
Message(msgWarning, warnNoValidWads);
/* Try the default wad name */
defaultwad = AllocMem(OTHER, strlen(options.szMapName) + 5, false);
defaultwad = (char *) AllocMem(OTHER, strlen(options.szMapName) + 5, false);
strcpy(defaultwad, options.szMapName);
StripExtension(defaultwad);
DefaultExtension(defaultwad, ".wad");
@ -829,7 +829,7 @@ InitQBSP(int argc, char **argv)
if (argv[i][0] != '-')
length += 2; /* quotes */
}
szBuf = AllocMem(OTHER, length, true);
szBuf = (char *) AllocMem(OTHER, length, true);
for (i = 1; i < argc; i++) {
/* Quote filenames for the parsing function */
if (argv[i][0] != '-')

View File

@ -38,13 +38,16 @@
#include "file.h"
#include "warnerr.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef offsetof
#define offsetof(type, member) __builtin_offsetof(type, member)
#endif
#ifdef _MSC_VER
#define __func__ __FUNCTION__
#define inline __inline
#endif
#ifndef __GNUC__
@ -626,4 +629,8 @@ void Message(int MsgType, ...);
void Error(const char *error, ...)
__attribute__((format(printf,1,2),noreturn));
#ifdef __cplusplus
}
#endif
#endif

View File

@ -24,6 +24,10 @@
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
char identification[4]; // should be WAD2
int numlumps;
@ -67,4 +71,8 @@ void WADList_Free(wad_t *wadlist);
const texture_t *WADList_GetTexture(const char *name);
// for getting a texture width/height
#ifdef __cplusplus
}
#endif
#endif /* WAD_H */

View File

@ -20,6 +20,10 @@
*/
// warnerr.h
#ifdef __cplusplus
extern "C" {
#endif
enum {
warnNoWadKey, // 0
warnNoValidWads,
@ -49,3 +53,7 @@ enum {
warnMixedFaceContents,
cWarnings
};
#ifdef __cplusplus
}
#endif