Skip to content

Commit

Permalink
Introduced new type; typedef int lumpnum_t - To be used at all times …
Browse files Browse the repository at this point in the history
…when representing indices to lumps (and lump infos).

Further cleanup, got rid of some garbage in dd_main.c
  • Loading branch information
danij committed Mar 20, 2008
1 parent 58b9075 commit 72cdf8c
Show file tree
Hide file tree
Showing 35 changed files with 811 additions and 795 deletions.
1 change: 1 addition & 0 deletions doomsday/engine/api/dd_types.h
Expand Up @@ -112,6 +112,7 @@ typedef unsigned int size_t;
typedef int fixed_t;
typedef unsigned int angle_t;
typedef int spritenum_t;
typedef int lumpnum_t;
typedef uint32_t ident_t;
typedef unsigned short nodeindex_t;
typedef unsigned short thid_t;
Expand Down
56 changes: 28 additions & 28 deletions doomsday/engine/api/doomsday.h
Expand Up @@ -89,28 +89,28 @@ extern "C" {
int DD_GetKeyCode(const char *name);

// Base: WAD.
int W_CheckNumForName(const char *name);
int W_GetNumForName(const char *name);
size_t W_LumpLength(int lump);
const char *W_LumpName(int lump);
void W_ReadLump(int lump, void *dest);
void W_ReadLumpSection(int lump, void *dest, int startoffset,
size_t length);
void *W_CacheLumpNum(int lump, int tag);
lumpnum_t W_CheckNumForName(const char *name);
lumpnum_t W_GetNumForName(const char *name);
size_t W_LumpLength(lumpnum_t lump);
const char *W_LumpName(lumpnum_t lump);
void W_ReadLump(lumpnum_t lump, void *dest);
void W_ReadLumpSection(lumpnum_t lump, void *dest,
size_t startOffset, size_t length);
void *W_CacheLumpNum(lumpnum_t lump, int tag);
void *W_CacheLumpName(char *name, int tag);
void W_ChangeCacheTag(int lump, int tag);
const char *W_LumpSourceFile(int lump);
void W_ChangeCacheTag(lumpnum_t lump, int tag);
const char *W_LumpSourceFile(lumpnum_t lump);
uint W_CRCNumber(void);
boolean W_IsFromIWAD(int lump);
int W_OpenAuxiliary(const char *filename);
boolean W_IsFromIWAD(lumpnum_t lump);
lumpnum_t W_OpenAuxiliary(const char *fileName);

// Base: Zone.
void *_DECALL Z_Malloc(size_t size, int tag, void *ptr);
void *Z_Calloc(size_t size, int tag, void *user);
void *Z_Realloc(void *ptr, size_t n, int malloctag);
void *Z_Recalloc(void *ptr, size_t n, int calloctag);
void *Z_Realloc(void *ptr, size_t n, int mallocTag);
void *Z_Recalloc(void *ptr, size_t n, int callocTag);
void _DECALL Z_Free(void *ptr);
void Z_FreeTags(int lowtag, int hightag);
void Z_FreeTags(int lowTag, int highTag);
void Z_ChangeTag2(void *ptr, int tag);
void Z_CheckHeap(void);

Expand Down Expand Up @@ -378,14 +378,14 @@ extern "C" {
void R_SetDataPath(const char *path);
void R_SetupLevel(int mode, int flags);
void R_PrecacheLevel(void);
void R_PrecachePatch(int lumpnum);
void R_PrecachePatch(lumpnum_t lump);
void R_PrecacheSkinsForState(int stateIndex);
void R_RenderPlayerView(ddplayer_t *player);
void R_ViewWindow(int x, int y, int w, int h);
void R_SetBorderGfx(char *lumps[9]);
void R_GetSpriteInfo(int sprite, int frame,
spriteinfo_t *sprinfo);
void R_GetPatchInfo(int lump, spriteinfo_t *info);
void R_GetPatchInfo(lumpnum_t lump, spriteinfo_t *info);

int R_CheckMaterialNumForName(const char *name, materialtype_t type);
const char *R_MaterialNameForNum(int num, materialtype_t type);
Expand Down Expand Up @@ -463,24 +463,24 @@ extern "C" {
void GL_SetColorAndAlpha(float r, float g, float b, float a);
void GL_BlendMode(blendmode_t mode);
void GL_SetNoTexture(void);
void GL_SetPatch(int lump, int wrapS, int wrapT);
void GL_SetPatch(lumpnum_t lump, int wrapS, int wrapT);
void GL_SetSprite(int pnum);
void GL_SetPSprite(int pnum);
void GL_SetTranslatedSprite(int pnum, int tmap, int tclass);
void GL_SetMaterial(int idx, materialtype_t type);
unsigned int GL_SetRawImage(unsigned int lump, boolean part2, int wrapS, int wrapT);
unsigned int GL_SetRawImage(lumpnum_t lump, boolean part2, int wrapS, int wrapT);
unsigned int GL_LoadGraphics(const char *name, int mode);

// Graphics: 2D drawing.
void GL_DrawPatch(int x, int y, int lumpnum);
void GL_DrawPatch_CS(int x, int y, int lumpnum);
void GL_DrawPatch(int x, int y, lumpnum_t lump);
void GL_DrawPatch_CS(int x, int y, lumpnum_t lump);
void GL_DrawPatchLitAlpha(int x, int y, float light,
float alpha, int lumpnum);
void GL_DrawFuzzPatch(int x, int y, int lumpnum);
void GL_DrawAltFuzzPatch(int x, int y, int lumpnum);
void GL_DrawShadowedPatch(int x, int y, int lumpnum);
void GL_DrawRawScreen(int lump, float offx, float offy);
void GL_DrawRawScreen_CS(int lump, float offx, float offy,
float alpha, lumpnum_t lump);
void GL_DrawFuzzPatch(int x, int y, lumpnum_t lump);
void GL_DrawAltFuzzPatch(int x, int y, lumpnum_t lump);
void GL_DrawShadowedPatch(int x, int y, lumpnum_t lump);
void GL_DrawRawScreen(lumpnum_t lump, float offx, float offy);
void GL_DrawRawScreen_CS(lumpnum_t lump, float offx, float offy,
float scalex, float scaley);
void GL_DrawLine(float x1, float y1, float x2, float y2,
float r, float g, float b, float a);
Expand All @@ -492,7 +492,7 @@ extern "C" {
int th, int txoff, int tyoff, int cx,
int cy, int cw, int ch);
void GL_DrawPSprite(float x, float y, float scale, int flip,
int lump);
lumpnum_t lump);
void GL_SetFilter(int filter_rgba);

// Graphics: PCX.
Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/include/cl_world.h
Expand Up @@ -4,7 +4,7 @@
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2007 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2007 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2006-2008 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -37,7 +37,7 @@ typedef enum {
void Cl_InitTranslations(void);
void Cl_InitMovers(void);
void Cl_RemoveMovers(void);
short Cl_TranslateLump(short lump);
lumpnum_t Cl_TranslateLump(lumpnum_t lump);
void Cl_SetPolyMover(uint number, int move, int rotate);
void Cl_AddMover(uint sectornum, clmovertype_t type, float dest,
float speed);
Expand Down
6 changes: 1 addition & 5 deletions doomsday/engine/portable/include/dd_main.h
Expand Up @@ -36,11 +36,7 @@
#define VERBOSE2(code) { if(verbose >= 2) { code; } }

extern int verbose;
extern int maxzone;
extern int shareware; // true if only episode 1 present
extern boolean cdrom; // true if cd-rom mode active ("-cdrom")
extern boolean debugmode; // checkparm of -debug
extern boolean singletics; // debug flag to cancel adaptiveness
extern int maxZone;
extern FILE *outFile; // Output file for console messages.
extern int isDedicated;
extern char ddBasePath[];
Expand Down
54 changes: 27 additions & 27 deletions doomsday/engine/portable/include/dd_wad.h
Expand Up @@ -22,7 +22,7 @@
* Boston, MA 02110-1301 USA
*/

/*
/**
* dd_wad.h: WAD Files and Data Lump Cache
*/

Expand All @@ -35,11 +35,11 @@
#define RECORD_FILENAMELEN 256

// File record flags.
#define FRF_RUNTIME 0x1 // Loaded at runtime (for reset).
#define FRF_RUNTIME 0x1 // Loaded at runtime (for reset).

#define AUXILIARY_BASE 100000000
#define AUXILIARY_BASE 100000000

enum // Lump Grouping Tags
enum // Lump Grouping Tags
{
LGT_NONE = 0,
LGT_FLATS,
Expand All @@ -48,47 +48,47 @@ enum // Lump Grouping Tags
};

typedef struct {
char filename[RECORD_FILENAMELEN]; // Full filename (every '\' -> '/').
int numlumps; // Number of lumps.
char fileName[RECORD_FILENAMELEN]; // Full filename (every '\' -> '/').
int numLumps; // Number of lumps.
int flags;
DFILE *handle; // File handle.
DFILE *handle; // File handle.
char iwad;
} filerecord_t;

typedef struct {
char name[9]; // End in \0.
char name[9]; // End in \0.
DFILE *handle;
int position;
size_t size;
int sent;
char group; // Lump grouping tag (LGT_*).
char group; // Lump grouping tag (LGT_*).
} lumpinfo_t;

extern char *defaultWads; // A list of wad names, whitespace in between (in .cfg).
extern lumpinfo_t *lumpinfo;
extern int numlumps;
extern char *defaultWads; // A list of wad names, whitespace in between (in .cfg).
extern lumpinfo_t *lumpInfo;
extern int numLumps;

void DD_RegisterVFS(void);

void W_InitMultipleFiles(char **filenames);
void W_InitMultipleFiles(char **fileNames);
void W_EndStartup(void);
int W_CheckNumForName(const char *name);
int W_GetNumForName(const char *name);
size_t W_LumpLength(int lump);
const char *W_LumpName(int lump);
void W_ReadLump(int lump, void *dest);
void W_ReadLumpSection(int lump, void *dest, int startoffset,
size_t length);
void *W_CacheLumpNum(int lump, int tag);
lumpnum_t W_CheckNumForName(const char *name);
lumpnum_t W_GetNumForName(const char *name);
size_t W_LumpLength(lumpnum_t lump);
const char *W_LumpName(lumpnum_t lump);
void W_ReadLump(lumpnum_t lump, void *dest);
void W_ReadLumpSection(lumpnum_t lump, void *dest,
size_t startOffset, size_t length);
void *W_CacheLumpNum(lumpnum_t lump, int tag);
void *W_CacheLumpName(char *name, int tag);
boolean W_AddFile(const char *filename, boolean allowDuplicate);
boolean W_RemoveFile(char *filename);
boolean W_AddFile(const char *fileName, boolean allowDuplicate);
boolean W_RemoveFile(char *fileName);
void W_Reset(void);
int W_OpenAuxiliary(const char *filename);
void W_ChangeCacheTag(int lump, int tag);
lumpnum_t W_OpenAuxiliary(const char *fileName);
void W_ChangeCacheTag(lumpnum_t lump, int tag);
void W_CheckIWAD(void);
boolean W_IsFromIWAD(int lump);
const char *W_LumpSourceFile(int lump);
boolean W_IsFromIWAD(lumpnum_t lump);
const char *W_LumpSourceFile(lumpnum_t lump);
unsigned int W_CRCNumberForRecord(int idx);
unsigned int W_CRCNumber(void);
void W_GetIWADFileName(char *buf, int bufSize);
Expand Down
18 changes: 9 additions & 9 deletions doomsday/engine/portable/include/gl_draw.h
Expand Up @@ -32,15 +32,15 @@
void GL_UsePatchOffset(boolean enable);

// 2D drawing routines:
void GL_DrawPatch_CS(int x, int y, int lumpnum);
void GL_DrawPatch(int x, int y, int lumpnum);
void GL_DrawPatch_CS(int x, int y, lumpnum_t lump);
void GL_DrawPatch(int x, int y, lumpnum_t lump);
void GL_DrawPatchLitAlpha(int x, int y, float light, float alpha,
int lumpnum);
void GL_DrawFuzzPatch(int x, int y, int lumpnum);
void GL_DrawAltFuzzPatch(int x, int y, int lumpnum);
void GL_DrawShadowedPatch(int x, int y, int lumpnum);
void GL_DrawRawScreen(int lump, float offx, float offy);
void GL_DrawRawScreen_CS(int lump, float offx, float offy,
lumpnum_t lump);
void GL_DrawFuzzPatch(int x, int y, lumpnum_t lump);
void GL_DrawAltFuzzPatch(int x, int y, lumpnum_t lump);
void GL_DrawShadowedPatch(int x, int y, lumpnum_t lump);
void GL_DrawRawScreen(lumpnum_t lump, float offx, float offy);
void GL_DrawRawScreen_CS(lumpnum_t lump, float offx, float offy,
float scalex, float scaley);
void GL_DrawLine(float x1, float y1, float x2, float y2, float r,
float g, float b, float a);
Expand All @@ -53,7 +53,7 @@ void GL_SetColor(int palidx);
void GL_SetColor2(int palidx, float alpha);
void GL_SetColorAndAlpha(float r, float g, float b, float a);
void GL_DrawPSprite(float x, float y, float scale, int flip,
int lump);
lumpnum_t lump);

// Filters:
void GL_SetFilter(int filterRGBA);
Expand Down
18 changes: 9 additions & 9 deletions doomsday/engine/portable/include/gl_texmanager.h
Expand Up @@ -92,11 +92,11 @@ void GL_ResetLumpTexData(void);
void GL_BindTexture(DGLuint texname);
void GL_TextureFilterMode(int target, int parm);
DGLuint GL_BindTexPatch(struct patch_s *p);
DGLuint GL_GetPatchOtherPart(int lump, texinfo_t **info);
void GL_SetPatch(int lump, int wrapS, int wrapT); // No mipmaps are generated.
DGLuint GL_GetPatchOtherPart(lumpnum_t lump, texinfo_t **info);
void GL_SetPatch(lumpnum_t lump, int wrapS, int wrapT); // No mipmaps are generated.
DGLuint GL_BindTexRaw(struct rawtex_s *r);
DGLuint GL_GetRawOtherPart(int lump, texinfo_t **info);
void GL_SetRawTex(int lump, int part);
DGLuint GL_GetRawOtherPart(lumpnum_t lump, texinfo_t **info);
void GL_SetRawTex(lumpnum_t lump, int part);

void GL_LowRes(void);
void TranslatePatch(lumppatch_t *patch, byte *transTable);
Expand Down Expand Up @@ -136,9 +136,9 @@ DGLuint GL_PrepareSky2(int idx, boolean zeroMask, boolean translate,
texinfo_t **info);

DGLuint GL_GetPatchInfo(int idx, boolean part2, texinfo_t **info);
DGLuint GL_GetRawTexInfo(uint idx, boolean part2, texinfo_t **texinfo);
DGLuint GL_PreparePatch(int idx, texinfo_t **info);
DGLuint GL_PrepareRawTex(uint idx, boolean part2, texinfo_t **info);
DGLuint GL_GetRawTexInfo(lumpnum_t lump, boolean part2, texinfo_t **texinfo);
DGLuint GL_PreparePatch(lumpnum_t lump, texinfo_t **info);
DGLuint GL_PrepareRawTex(lumpnum_t lump, boolean part2, texinfo_t **info);
DGLuint GL_PrepareLSTexture(lightingtexid_t which, texinfo_t **info);
DGLuint GL_PrepareFlareTexture(flaretexid_t flare, texinfo_t **info);
void GL_BufferSkyTexture(int idx, byte **outbuffer, int *width,
Expand All @@ -149,11 +149,11 @@ byte *GL_GetPal18to8(void);

void GL_SetMaterial(int idx, materialtype_t type);

unsigned int GL_SetRawImage(unsigned int lump, boolean part2, int wrapS, int wrapT);
unsigned int GL_SetRawImage(lumpnum_t lump, boolean part2, int wrapS, int wrapT);
void GL_SetSprite(int pnum);
void GL_SetPSprite(int pnum);
void GL_SetTranslatedSprite(int pnum, int tmap, int tclass);
void GL_NewSplitTex(int lump, DGLuint part2name);
void GL_NewSplitTex(lumpnum_t lump, DGLuint part2name);
void GL_SetNoTexture(void);
void GL_UpdateTexParams(int mipmode);
void GL_UpdateRawScreenParams(int smoothing);
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/include/m_gridmap.h
Expand Up @@ -4,7 +4,7 @@
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2007 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2007 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2006-2008 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -40,14 +40,14 @@ void *M_GridmapGetBlock(gridmap_t *gridmap, uint x, uint y,

// Iteration
boolean M_GridmapIterator(gridmap_t *gridmap,
boolean (*func) (void *p, void *ctx),
boolean (*callback) (void* p, void *ctx),
void *param);
boolean M_GridmapBoxIterator(gridmap_t *gridmap,
uint xl, uint xh, uint yl, uint yh,
boolean (*func) (void *p, void *ctx),
boolean (*callback) (void* p, void *ctx),
void *param);
boolean M_GridmapBoxIteratorv(gridmap_t *gridmap, const uint box[4],
boolean (*func) (void *p, void *ctx),
boolean (*callback) (void* p, void *ctx),
void *param);

#endif
18 changes: 9 additions & 9 deletions doomsday/engine/portable/include/r_data.h
Expand Up @@ -253,12 +253,12 @@ typedef struct flat_s {
// if any.
struct ded_reflection_s *reflection; // Surface reflection definition.

int lump;
lumpnum_t lump;
struct ded_ptcgen_s *ptcGen; // Particle generator for the flat.
} flat_t;

typedef struct {
int lump; // Real lump number.
lumpnum_t lump; // Real lump number.
short width;
short height;
short offset;
Expand All @@ -274,7 +274,7 @@ typedef struct {

// a patch is a lumppatch that has been prepared for render.
typedef struct patch_s {
int lump;
lumpnum_t lump;
short offX, offY;

// Part 1
Expand All @@ -290,7 +290,7 @@ typedef struct patch_s {

// A rawtex is a lump raw graphic that has been prepared for render.
typedef struct rawtex_s {
int lump;
lumpnum_t lump;
// Part 1
DGLuint tex; // Name of the associated DGL texture.
texinfo_t info;
Expand Down Expand Up @@ -400,7 +400,7 @@ void R_ShutdownData(void);
void R_UpdateSector(struct sector_s *sec, boolean forceUpdate);

void R_PrecacheLevel(void);
void R_PrecachePatch(int lumpnum);
void R_PrecachePatch(lumpnum_t lump);

void R_DestroyAnimGroups(void);
void R_InitAnimGroup(ded_group_t *def);
Expand All @@ -411,11 +411,11 @@ void R_AnimateAnimGroups(void);
void R_InitSpriteLumps(void);
int R_NewSpriteLump(int lump);

patch_t *R_FindPatch(int lumpnum); // May return NULL.
patch_t *R_GetPatch(int lumpnum); // Creates new entries.
patch_t *R_FindPatch(lumpnum_t lump); // May return NULL.
patch_t *R_GetPatch(lumpnum_t lump); // Creates new entries.
patch_t **R_CollectPatches(int *count);
rawtex_t *R_FindRawTex(int lumpnum); // May return NULL.
rawtex_t *R_GetRawTex(int lumpnum); // Creates new entries.
rawtex_t *R_FindRawTex(lumpnum_t lump); // May return NULL.
rawtex_t *R_GetRawTex(lumpnum_t lump); // Creates new entries.

boolean R_IsAllowedDecoration(ded_decor_t *def, int index,
boolean hasExternal);
Expand Down

0 comments on commit 72cdf8c

Please sign in to comment.