diff --git a/src/blockmapbuilder/blockmapbuilder.cpp b/src/blockmapbuilder/blockmapbuilder.cpp index bd8de5a..b7e9a11 100644 --- a/src/blockmapbuilder/blockmapbuilder.cpp +++ b/src/blockmapbuilder/blockmapbuilder.cpp @@ -72,7 +72,7 @@ int BoxOnSide (int bx1, int by1, int bx2, int by2, } #endif -WORD *FBlockmapBuilder::GetBlockmap (int &size) +uint16_t *FBlockmapBuilder::GetBlockmap (int &size) { #ifdef BLOCK_TEST FILE *f = fopen ("blockmap.lmp", "rb"); @@ -86,10 +86,10 @@ WORD *FBlockmapBuilder::GetBlockmap (int &size) fread (stuff, 2, fsize/2, f); fclose (f); - if ((WORD)stuff[0] != BlockMap[0] || - (WORD)stuff[1] != BlockMap[1] || - (WORD)stuff[2] != BlockMap[2] || - (WORD)stuff[3] != BlockMap[3]) + if ((uint16_t)stuff[0] != BlockMap[0] || + (uint16_t)stuff[1] != BlockMap[1] || + (uint16_t)stuff[2] != BlockMap[2] || + (uint16_t)stuff[3] != BlockMap[3]) { printf ("different blockmap sizes\n"); goto notest; @@ -98,7 +98,7 @@ WORD *FBlockmapBuilder::GetBlockmap (int &size) for (i = 0; i < stuff[2] * stuff[3]; ++i) { - WORD i1, i2; + uint16_t i1, i2; i1 = stuff[4+i] + 1; while (stuff[i1] != -1) { @@ -138,7 +138,7 @@ WORD *FBlockmapBuilder::GetBlockmap (int &size) i2 = stuff[4+i] + 1; while (stuff[i2] != -1) { - if ((WORD)stuff[i2] == BlockMap[i1]) + if ((uint16_t)stuff[i2] == BlockMap[i1]) break; i2++; } @@ -172,11 +172,11 @@ notest: void FBlockmapBuilder::BuildBlockmap () { - TArray *BlockLists, *block, *endblock; - WORD adder; + TArray *BlockLists, *block, *endblock; + uint16_t adder; int bmapwidth, bmapheight; int minx, maxx, miny, maxy; - WORD line; + uint16_t line; if (Level.NumVertices <= 0) return; @@ -203,12 +203,12 @@ void FBlockmapBuilder::BuildBlockmap () bmapwidth = ((maxx - minx) >> BLOCKBITS) + 1; bmapheight = ((maxy - miny) >> BLOCKBITS) + 1; - adder = WORD(minx); BlockMap.Push (adder); - adder = WORD(miny); BlockMap.Push (adder); - adder = WORD(bmapwidth); BlockMap.Push (adder); - adder = WORD(bmapheight); BlockMap.Push (adder); + adder = uint16_t(minx); BlockMap.Push (adder); + adder = uint16_t(miny); BlockMap.Push (adder); + adder = uint16_t(bmapwidth); BlockMap.Push (adder); + adder = uint16_t(bmapheight); BlockMap.Push (adder); - BlockLists = new TArray[bmapwidth * bmapheight]; + BlockLists = new TArray[bmapwidth * bmapheight]; for (line = 0; line < Level.NumLines(); ++line) { @@ -331,15 +331,15 @@ void FBlockmapBuilder::BuildBlockmap () delete[] BlockLists; } -void FBlockmapBuilder::CreateUnpackedBlockmap (TArray *blocks, int bmapwidth, int bmapheight) +void FBlockmapBuilder::CreateUnpackedBlockmap (TArray *blocks, int bmapwidth, int bmapheight) { - TArray *block; - WORD zero = 0; - WORD terminator = 0xffff; + TArray *block; + uint16_t zero = 0; + uint16_t terminator = 0xffff; for (int i = 0; i < bmapwidth * bmapheight; ++i) { - BlockMap[4+i] = WORD(BlockMap.Size()); + BlockMap[4+i] = uint16_t(BlockMap.Size()); BlockMap.Push (zero); block = &blocks[i]; for (unsigned int j = 0; j < block->Size(); ++j) @@ -350,10 +350,10 @@ void FBlockmapBuilder::CreateUnpackedBlockmap (TArray *blocks, int bmapwid } } -static unsigned int BlockHash (TArray *block) +static unsigned int BlockHash (TArray *block) { int hash = 0; - WORD *ar = &(*block)[0]; + uint16_t *ar = &(*block)[0]; for (size_t i = 0; i < block->Size(); ++i) { hash = hash * 12235 + ar[i]; @@ -361,7 +361,7 @@ static unsigned int BlockHash (TArray *block) return hash & 0x7fffffff; } -static bool BlockCompare (TArray *block1, TArray *block2) +static bool BlockCompare (TArray *block1, TArray *block2) { size_t size = block1->Size(); @@ -373,8 +373,8 @@ static bool BlockCompare (TArray *block1, TArray *block2) { return true; } - WORD *ar1 = &(*block1)[0]; - WORD *ar2 = &(*block2)[0]; + uint16_t *ar1 = &(*block1)[0]; + uint16_t *ar2 = &(*block2)[0]; for (size_t i = 0; i < size; ++i) { if (ar1[i] != ar2[i]) @@ -385,20 +385,20 @@ static bool BlockCompare (TArray *block1, TArray *block2) return true; } -void FBlockmapBuilder::CreatePackedBlockmap (TArray *blocks, int bmapwidth, int bmapheight) +void FBlockmapBuilder::CreatePackedBlockmap (TArray *blocks, int bmapwidth, int bmapheight) { - WORD buckets[4096]; - WORD *hashes, hashblock; - TArray *block; - WORD zero = 0; - WORD terminator = 0xffff; - WORD *array; + uint16_t buckets[4096]; + uint16_t *hashes, hashblock; + TArray *block; + uint16_t zero = 0; + uint16_t terminator = 0xffff; + uint16_t *array; int i, hash; int hashed = 0, nothashed = 0; - hashes = new WORD[bmapwidth * bmapheight]; + hashes = new uint16_t[bmapwidth * bmapheight]; - memset (hashes, 0xff, sizeof(WORD)*bmapwidth*bmapheight); + memset (hashes, 0xff, sizeof(uint16_t)*bmapwidth*bmapheight); memset (buckets, 0xff, sizeof(buckets)); for (i = 0; i < bmapwidth * bmapheight; ++i) @@ -422,8 +422,8 @@ void FBlockmapBuilder::CreatePackedBlockmap (TArray *blocks, int bmapwidth else { hashes[i] = buckets[hash]; - buckets[hash] = WORD(i); - BlockMap[4+i] = WORD(BlockMap.Size()); + buckets[hash] = uint16_t(i); + BlockMap[4+i] = uint16_t(BlockMap.Size()); BlockMap.Push (zero); array = &(*block)[0]; for (size_t j = 0; j < block->Size(); ++j) diff --git a/src/blockmapbuilder/blockmapbuilder.h b/src/blockmapbuilder/blockmapbuilder.h index 045ec21..8ebee31 100644 --- a/src/blockmapbuilder/blockmapbuilder.h +++ b/src/blockmapbuilder/blockmapbuilder.h @@ -9,13 +9,13 @@ class FBlockmapBuilder { public: FBlockmapBuilder (FLevel &level); - WORD *GetBlockmap (int &size); + uint16_t *GetBlockmap (int &size); private: FLevel &Level; - TArray BlockMap; + TArray BlockMap; void BuildBlockmap (); - void CreateUnpackedBlockmap (TArray *blocks, int bmapwidth, int bmapheight); - void CreatePackedBlockmap (TArray *blocks, int bmapwidth, int bmapheight); + void CreateUnpackedBlockmap (TArray *blocks, int bmapwidth, int bmapheight); + void CreatePackedBlockmap (TArray *blocks, int bmapwidth, int bmapheight); }; diff --git a/src/framework/zdray.h b/src/framework/zdray.h index d21ebf1..84207b7 100644 --- a/src/framework/zdray.h +++ b/src/framework/zdray.h @@ -45,22 +45,14 @@ extern int SSELevel; #define FRACBITS 16 typedef int fixed_t; -typedef unsigned char BYTE; -typedef unsigned short WORD; -typedef signed short SWORD; -#ifdef _WIN32 -typedef unsigned long DWORD; -#else -typedef uint32_t DWORD; -#endif typedef uint32_t angle_t; angle_t PointToAngle (fixed_t x, fixed_t y); -static const WORD NO_MAP_INDEX = 0xffff; -static const DWORD NO_INDEX = 0xffffffff; +static const uint16_t NO_MAP_INDEX = 0xffff; +static const uint32_t NO_INDEX = 0xffffffff; static const angle_t ANGLE_MAX = 0xffffffff; -static const DWORD DWORD_MAX = 0xffffffff; +static const uint32_t DWORD_MAX = 0xffffffff; static const angle_t ANGLE_180 = (1u<<31); static const angle_t ANGLE_EPSILON = 5000; diff --git a/src/level/doomdata.h b/src/level/doomdata.h index ad496c8..9dcf2eb 100644 --- a/src/level/doomdata.h +++ b/src/level/doomdata.h @@ -37,7 +37,7 @@ struct MapSideDef char toptexture[8]; char bottomtexture[8]; char midtexture[8]; - WORD sector; + uint16_t sector; }; struct IntLineDef; @@ -60,32 +60,32 @@ struct IntSideDef struct MapLineDef { - WORD v1; - WORD v2; + uint16_t v1; + uint16_t v2; short flags; short special; short tag; - WORD sidenum[2]; + uint16_t sidenum[2]; }; struct MapLineDef2 { - WORD v1; - WORD v2; + uint16_t v1; + uint16_t v2; short flags; unsigned char special; unsigned char args[5]; - WORD sidenum[2]; + uint16_t sidenum[2]; }; struct IntLineDef { - DWORD v1; - DWORD v2; + uint32_t v1; + uint32_t v2; int flags; int special; int args[5]; - DWORD sidenum[2]; + uint32_t sidenum[2]; TArray props; }; @@ -120,52 +120,52 @@ struct IntSector struct MapSubsector { - WORD numlines; - WORD firstline; + uint16_t numlines; + uint16_t firstline; }; struct MapSubsectorEx { - DWORD numlines; - DWORD firstline; + uint32_t numlines; + uint32_t firstline; }; struct MapSeg { - WORD v1; - WORD v2; - WORD angle; - WORD linedef; + uint16_t v1; + uint16_t v2; + uint16_t angle; + uint16_t linedef; short side; short offset; }; struct MapSegEx { - DWORD v1; - DWORD v2; - WORD angle; - WORD linedef; + uint32_t v1; + uint32_t v2; + uint16_t angle; + uint16_t linedef; short side; short offset; }; struct MapSegGL { - WORD v1; - WORD v2; - WORD linedef; - WORD side; - WORD partner; + uint16_t v1; + uint16_t v2; + uint16_t linedef; + uint16_t side; + uint16_t partner; }; struct MapSegGLEx { - DWORD v1; - DWORD v2; - DWORD linedef; - WORD side; - DWORD partner; + uint32_t v1; + uint32_t v2; + uint32_t linedef; + uint16_t side; + uint32_t partner; }; #define NF_SUBSECTOR 0x8000 @@ -175,21 +175,21 @@ struct MapNode { short x,y,dx,dy; short bbox[2][4]; - WORD children[2]; + uint16_t children[2]; }; struct MapNodeExO { short x,y,dx,dy; short bbox[2][4]; - DWORD children[2]; + uint32_t children[2]; }; struct MapNodeEx { int x,y,dx,dy; short bbox[2][4]; - DWORD children[2]; + uint32_t children[2]; }; struct MapThing @@ -319,18 +319,18 @@ struct FLevel MapSubsectorEx *Subsectors; int NumSubsectors; MapSegEx *Segs; int NumSegs; MapNodeEx *Nodes; int NumNodes; - WORD *Blockmap; int BlockmapSize; - BYTE *Reject; int RejectSize; + uint16_t *Blockmap; int BlockmapSize; + uint8_t *Reject; int RejectSize; MapSubsectorEx *GLSubsectors; int NumGLSubsectors; MapSegGLEx *GLSegs; int NumGLSegs; MapNodeEx *GLNodes; int NumGLNodes; WideVertex *GLVertices; int NumGLVertices; - BYTE *GLPVS; int GLPVSSize; + uint8_t *GLPVS; int GLPVSSize; int NumOrgVerts; - DWORD *OrgSectorMap; int NumOrgSectors; + uint32_t *OrgSectorMap; int NumOrgSectors; fixed_t MinX, MinY, MaxX, MaxY; diff --git a/src/level/level.cpp b/src/level/level.cpp index a7e1cc1..797bca9 100644 --- a/src/level/level.cpp +++ b/src/level/level.cpp @@ -325,7 +325,7 @@ void FLevel::RemoveExtraLines () void FLevel::RemoveExtraSides () { - BYTE *used; + uint8_t *used; int *remap; int i, newNumSides; @@ -333,7 +333,7 @@ void FLevel::RemoveExtraSides () // They just waste space, so get rid of them. int NumSides = this->NumSides(); - used = new BYTE[NumSides]; + used = new uint8_t[NumSides]; memset (used, 0, NumSides*sizeof(*used)); remap = new int[NumSides]; @@ -397,22 +397,22 @@ void FLevel::RemoveExtraSides () void FLevel::RemoveExtraSectors () { - BYTE *used; - DWORD *remap; + uint8_t *used; + uint32_t *remap; int i, newNumSectors; // Extra sectors are those that aren't referenced by any sides. // They just waste space, so get rid of them. NumOrgSectors = NumSectors(); - used = new BYTE[NumSectors()]; + used = new uint8_t[NumSectors()]; memset (used, 0, NumSectors()*sizeof(*used)); - remap = new DWORD[NumSectors()]; + remap = new uint32_t[NumSectors()]; // Mark all used sectors for (i = 0; i < NumSides(); ++i) { - if ((DWORD)Sides[i].sector != NO_INDEX) + if ((uint32_t)Sides[i].sector != NO_INDEX) { used[Sides[i].sector] = 1; } @@ -447,13 +447,13 @@ void FLevel::RemoveExtraSectors () // Renumber sector references in sides for (i = 0; i < NumSides(); ++i) { - if ((DWORD)Sides[i].sector != NO_INDEX) + if ((uint32_t)Sides[i].sector != NO_INDEX) { Sides[i].sector = remap[Sides[i].sector]; } } // Make a reverse map for fixing reject lumps - OrgSectorMap = new DWORD[newNumSectors]; + OrgSectorMap = new uint32_t[newNumSectors]; for (i = 0; i < NumSectors(); ++i) { if (remap[i] != NO_INDEX) @@ -667,8 +667,8 @@ void FProcessor::Write (FWadWriter &out) #ifdef BLOCK_TEST int size; - BYTE *blockmap; - ReadLump (Wad, Wad.FindMapLump ("BLOCKMAP", Lump), blockmap, size); + uint8_t *blockmap; + ReadLump (Wad, Wad.FindMapLump ("BLOCKMAP", Lump), blockmap, size); if (blockmap) { FILE *f = fopen ("blockmap.lmp", "wb"); @@ -684,9 +684,9 @@ void FProcessor::Write (FWadWriter &out) if (!isUDMF) { FBlockmapBuilder bbuilder (Level); - WORD *blocks = bbuilder.GetBlockmap (Level.BlockmapSize); - Level.Blockmap = new WORD[Level.BlockmapSize]; - memcpy (Level.Blockmap, blocks, Level.BlockmapSize*sizeof(WORD)); + uint16_t *blocks = bbuilder.GetBlockmap (Level.BlockmapSize); + Level.Blockmap = new uint16_t[Level.BlockmapSize]; + memcpy (Level.Blockmap, blocks, Level.BlockmapSize*sizeof(uint16_t)); Level.RejectSize = (Level.NumSectors()*Level.NumSectors() + 7) / 8; Level.Reject = NULL; @@ -705,7 +705,7 @@ void FProcessor::Write (FWadWriter &out) if (lump >= 0) { - ReadLump (Wad, lump, Level.Reject, Level.RejectSize); + ReadLump (Wad, lump, Level.Reject, Level.RejectSize); if (Level.RejectSize != (Level.NumOrgSectors*Level.NumOrgSectors + 7) / 8) { // If the reject is the wrong size, don't use it. @@ -720,7 +720,7 @@ void FProcessor::Write (FWadWriter &out) else if (Level.NumOrgSectors != Level.NumSectors()) { // Some sectors have been removed, so fix the reject. - BYTE *newreject = FixReject (Level.Reject); + uint8_t *newreject = FixReject (Level.Reject); delete[] Level.Reject; Level.Reject = newreject; Level.RejectSize = (Level.NumSectors() * Level.NumSectors() + 7) / 8; @@ -733,7 +733,7 @@ void FProcessor::Write (FWadWriter &out) break; case ERM_CreateZeroes: - Level.Reject = new BYTE[Level.RejectSize]; + Level.Reject = new uint8_t[Level.RejectSize]; memset (Level.Reject, 0, Level.RejectSize); break; } @@ -848,11 +848,11 @@ void FProcessor::Write (FWadWriter &out) } // -BYTE *FProcessor::FixReject (const BYTE *oldreject) +uint8_t *FProcessor::FixReject (const uint8_t *oldreject) { int x, y, ox, oy, pnum, opnum; int rejectSize = (Level.NumSectors()*Level.NumSectors() + 7) / 8; - BYTE *newreject = new BYTE[rejectSize]; + uint8_t *newreject = new uint8_t[rejectSize]; memset (newreject, 0, rejectSize); @@ -886,12 +886,12 @@ MapNodeEx *FProcessor::NodesToEx (const MapNode *nodes, int count) for (x = 0; x < count; ++x) { - WORD child; + uint16_t child; int i; for (i = 0; i < 4+2*4; ++i) { - *((WORD *)&Nodes[x] + i) = LittleShort(*((WORD *)&nodes[x] + i)); + *((uint16_t *)&Nodes[x] + i) = LittleShort(*((uint16_t *)&nodes[x] + i)); } for (i = 0; i < 2; ++i) { @@ -986,11 +986,11 @@ void FProcessor::WriteLines (FWadWriter &out) Lines[i].args[2] = Level.Lines[i].args[2]; Lines[i].args[3] = Level.Lines[i].args[3]; Lines[i].args[4] = Level.Lines[i].args[4]; - Lines[i].v1 = LittleShort(WORD(Level.Lines[i].v1)); - Lines[i].v2 = LittleShort(WORD(Level.Lines[i].v2)); - Lines[i].flags = LittleShort(WORD(Level.Lines[i].flags)); - Lines[i].sidenum[0] = LittleShort(WORD(Level.Lines[i].sidenum[0])); - Lines[i].sidenum[1] = LittleShort(WORD(Level.Lines[i].sidenum[1])); + Lines[i].v1 = LittleShort(uint16_t(Level.Lines[i].v1)); + Lines[i].v2 = LittleShort(uint16_t(Level.Lines[i].v2)); + Lines[i].flags = LittleShort(uint16_t(Level.Lines[i].flags)); + Lines[i].sidenum[0] = LittleShort(uint16_t(Level.Lines[i].sidenum[0])); + Lines[i].sidenum[1] = LittleShort(uint16_t(Level.Lines[i].sidenum[1])); } out.WriteLump ("LINEDEFS", Lines, Level.NumLines()*sizeof(*Lines)); delete[] Lines; @@ -1001,13 +1001,13 @@ void FProcessor::WriteLines (FWadWriter &out) for (i = 0; i < Level.NumLines(); ++i) { - ld[i].v1 = LittleShort(WORD(Level.Lines[i].v1)); - ld[i].v2 = LittleShort(WORD(Level.Lines[i].v2)); - ld[i].flags = LittleShort(WORD(Level.Lines[i].flags)); - ld[i].sidenum[0] = LittleShort(WORD(Level.Lines[i].sidenum[0])); - ld[i].sidenum[1] = LittleShort(WORD(Level.Lines[i].sidenum[1])); - ld[i].special = LittleShort(WORD(Level.Lines[i].args[0])); - ld[i].tag = LittleShort(WORD(Level.Lines[i].args[1])); + ld[i].v1 = LittleShort(uint16_t(Level.Lines[i].v1)); + ld[i].v2 = LittleShort(uint16_t(Level.Lines[i].v2)); + ld[i].flags = LittleShort(uint16_t(Level.Lines[i].flags)); + ld[i].sidenum[0] = LittleShort(uint16_t(Level.Lines[i].sidenum[0])); + ld[i].sidenum[1] = LittleShort(uint16_t(Level.Lines[i].sidenum[1])); + ld[i].special = LittleShort(uint16_t(Level.Lines[i].args[0])); + ld[i].tag = LittleShort(uint16_t(Level.Lines[i].args[1])); } out.WriteLump ("LINEDEFS", ld, Level.NumLines()*sizeof(*ld)); delete[] ld; @@ -1056,8 +1056,8 @@ void FProcessor::WriteSegs (FWadWriter &out) for (i = 0; i < Level.NumSegs; ++i) { - segdata[i].v1 = LittleShort(WORD(Level.Segs[i].v1)); - segdata[i].v2 = LittleShort(WORD(Level.Segs[i].v2)); + segdata[i].v1 = LittleShort(uint16_t(Level.Segs[i].v1)); + segdata[i].v2 = LittleShort(uint16_t(Level.Segs[i].v2)); segdata[i].angle = LittleShort(Level.Segs[i].angle); segdata[i].linedef = LittleShort(Level.Segs[i].linedef); segdata[i].side = LittleShort(Level.Segs[i].side); @@ -1089,8 +1089,8 @@ void FProcessor::WriteSSectors2 (FWadWriter &out, const char *name, const MapSub for (i = 0; i < count; ++i) { - ssec[i].firstline = LittleShort((WORD)subs[i].firstline); - ssec[i].numlines = LittleShort((WORD)subs[i].numlines); + ssec[i].firstline = LittleShort((uint16_t)subs[i].firstline); + ssec[i].numlines = LittleShort((uint16_t)subs[i].numlines); } out.WriteLump (name, ssec, sizeof(*ssec)*count); delete[] ssec; @@ -1144,14 +1144,14 @@ void FProcessor::WriteNodes2 (FWadWriter &out, const char *name, const MapNodeEx nodes += j; for (j = 0; j < 2; ++j) { - DWORD child = zaNodes[i].children[j]; + uint32_t child = zaNodes[i].children[j]; if (child & NFX_SUBSECTOR) { - *nodes++ = LittleShort(WORD(child - (NFX_SUBSECTOR + NF_SUBSECTOR))); + *nodes++ = LittleShort(uint16_t(child - (NFX_SUBSECTOR + NF_SUBSECTOR))); } else { - *nodes++ = LittleShort((WORD)child); + *nodes++ = LittleShort((uint16_t)child); } } } @@ -1199,7 +1199,7 @@ void FProcessor::WriteBlockmap (FWadWriter &out) } size_t i, count; - WORD *blocks; + uint16_t *blocks; count = Level.BlockmapSize; blocks = Level.Blockmap; @@ -1289,25 +1289,25 @@ void FProcessor::WriteGLSegs (FWadWriter &out, bool v5) for (i = 0; i < count; ++i) { - if (Level.GLSegs[i].v1 < (DWORD)Level.NumOrgVerts) + if (Level.GLSegs[i].v1 < (uint32_t)Level.NumOrgVerts) { - segdata[i].v1 = LittleShort((WORD)Level.GLSegs[i].v1); + segdata[i].v1 = LittleShort((uint16_t)Level.GLSegs[i].v1); } else { - segdata[i].v1 = LittleShort(0x8000 | (WORD)(Level.GLSegs[i].v1 - Level.NumOrgVerts)); + segdata[i].v1 = LittleShort(0x8000 | (uint16_t)(Level.GLSegs[i].v1 - Level.NumOrgVerts)); } - if (Level.GLSegs[i].v2 < (DWORD)Level.NumOrgVerts) + if (Level.GLSegs[i].v2 < (uint32_t)Level.NumOrgVerts) { - segdata[i].v2 = (WORD)LittleShort(Level.GLSegs[i].v2); + segdata[i].v2 = (uint16_t)LittleShort(Level.GLSegs[i].v2); } else { - segdata[i].v2 = LittleShort(0x8000 | (WORD)(Level.GLSegs[i].v2 - Level.NumOrgVerts)); + segdata[i].v2 = LittleShort(0x8000 | (uint16_t)(Level.GLSegs[i].v2 - Level.NumOrgVerts)); } - segdata[i].linedef = LittleShort((WORD)Level.GLSegs[i].linedef); + segdata[i].linedef = LittleShort((uint16_t)Level.GLSegs[i].linedef); segdata[i].side = LittleShort(Level.GLSegs[i].side); - segdata[i].partner = LittleShort((WORD)Level.GLSegs[i].partner); + segdata[i].partner = LittleShort((uint16_t)Level.GLSegs[i].partner); } out.WriteLump ("GL_SEGS", segdata, sizeof(MapSegGL)*count); delete[] segdata; @@ -1332,7 +1332,7 @@ void FProcessor::WriteGLSegs5 (FWadWriter &out) for (i = 0; i < count; ++i) { - if (Level.GLSegs[i].v1 < (DWORD)Level.NumOrgVerts) + if (Level.GLSegs[i].v1 < (uint32_t)Level.NumOrgVerts) { segdata[i].v1 = LittleLong(Level.GLSegs[i].v1); } @@ -1340,7 +1340,7 @@ void FProcessor::WriteGLSegs5 (FWadWriter &out) { segdata[i].v1 = LittleLong(0x80000000u | ((int)Level.GLSegs[i].v1 - Level.NumOrgVerts)); } - if (Level.GLSegs[i].v2 < (DWORD)Level.NumOrgVerts) + if (Level.GLSegs[i].v2 < (uint32_t)Level.NumOrgVerts) { segdata[i].v2 = LittleLong(Level.GLSegs[i].v2); } @@ -1432,7 +1432,7 @@ void FProcessor::WriteGLBSPZ (FWadWriter &out, const char *label) void FProcessor::WriteVerticesZ (ZLibOut &out, const WideVertex *verts, int orgverts, int newverts) { - out << (DWORD)orgverts << (DWORD)newverts; + out << (uint32_t)orgverts << (uint32_t)newverts; for (int i = 0; i < newverts; ++i) { @@ -1442,82 +1442,82 @@ void FProcessor::WriteVerticesZ (ZLibOut &out, const WideVertex *verts, int orgv void FProcessor::WriteSubsectorsZ (ZLibOut &out, const MapSubsectorEx *subs, int numsubs) { - out << (DWORD)numsubs; + out << (uint32_t)numsubs; for (int i = 0; i < numsubs; ++i) { - out << (DWORD)subs[i].numlines; + out << (uint32_t)subs[i].numlines; } } void FProcessor::WriteSegsZ (ZLibOut &out, const MapSegEx *segs, int numsegs) { - out << (DWORD)numsegs; + out << (uint32_t)numsegs; for (int i = 0; i < numsegs; ++i) { - out << (DWORD)segs[i].v1 - << (DWORD)segs[i].v2 - << (WORD)segs[i].linedef - << (BYTE)segs[i].side; + out << (uint32_t)segs[i].v1 + << (uint32_t)segs[i].v2 + << (uint16_t)segs[i].linedef + << (uint8_t)segs[i].side; } } void FProcessor::WriteGLSegsZ (ZLibOut &out, const MapSegGLEx *segs, int numsegs, int nodever) { - out << (DWORD)numsegs; + out << (uint32_t)numsegs; if (nodever < 2) { for (int i = 0; i < numsegs; ++i) { - out << (DWORD)segs[i].v1 - << (DWORD)segs[i].partner - << (WORD)segs[i].linedef - << (BYTE)segs[i].side; + out << (uint32_t)segs[i].v1 + << (uint32_t)segs[i].partner + << (uint16_t)segs[i].linedef + << (uint8_t)segs[i].side; } } else { for (int i = 0; i < numsegs; ++i) { - out << (DWORD)segs[i].v1 - << (DWORD)segs[i].partner - << (DWORD)segs[i].linedef - << (BYTE)segs[i].side; + out << (uint32_t)segs[i].v1 + << (uint32_t)segs[i].partner + << (uint32_t)segs[i].linedef + << (uint8_t)segs[i].side; } } } void FProcessor::WriteNodesZ (ZLibOut &out, const MapNodeEx *nodes, int numnodes, int nodever) { - out << (DWORD)numnodes; + out << (uint32_t)numnodes; for (int i = 0; i < numnodes; ++i) { if (nodever < 3) { - out << (SWORD)(nodes[i].x >> 16) - << (SWORD)(nodes[i].y >> 16) - << (SWORD)(nodes[i].dx >> 16) - << (SWORD)(nodes[i].dy >> 16); + out << (int16_t)(nodes[i].x >> 16) + << (int16_t)(nodes[i].y >> 16) + << (int16_t)(nodes[i].dx >> 16) + << (int16_t)(nodes[i].dy >> 16); } else { - out << (DWORD)nodes[i].x - << (DWORD)nodes[i].y - << (DWORD)nodes[i].dx - << (DWORD)nodes[i].dy; + out << (uint32_t)nodes[i].x + << (uint32_t)nodes[i].y + << (uint32_t)nodes[i].dx + << (uint32_t)nodes[i].dy; } for (int j = 0; j < 2; ++j) { for (int k = 0; k < 4; ++k) { - out << (SWORD)nodes[i].bbox[j][k]; + out << (int16_t)nodes[i].bbox[j][k]; } } - out << (DWORD)nodes[i].children[0] - << (DWORD)nodes[i].children[1]; + out << (uint32_t)nodes[i].children[0] + << (uint32_t)nodes[i].children[1]; } } @@ -1570,7 +1570,7 @@ void FProcessor::WriteGLBSPX (FWadWriter &out, const char *label) void FProcessor::WriteVerticesX (FWadWriter &out, const WideVertex *verts, int orgverts, int newverts) { - out << (DWORD)orgverts << (DWORD)newverts; + out << (uint32_t)orgverts << (uint32_t)newverts; for (int i = 0; i < newverts; ++i) { @@ -1580,82 +1580,82 @@ void FProcessor::WriteVerticesX (FWadWriter &out, const WideVertex *verts, int o void FProcessor::WriteSubsectorsX (FWadWriter &out, const MapSubsectorEx *subs, int numsubs) { - out << (DWORD)numsubs; + out << (uint32_t)numsubs; for (int i = 0; i < numsubs; ++i) { - out << (DWORD)subs[i].numlines; + out << (uint32_t)subs[i].numlines; } } void FProcessor::WriteSegsX (FWadWriter &out, const MapSegEx *segs, int numsegs) { - out << (DWORD)numsegs; + out << (uint32_t)numsegs; for (int i = 0; i < numsegs; ++i) { - out << (DWORD)segs[i].v1 - << (DWORD)segs[i].v2 - << (WORD)segs[i].linedef - << (BYTE)segs[i].side; + out << (uint32_t)segs[i].v1 + << (uint32_t)segs[i].v2 + << (uint16_t)segs[i].linedef + << (uint8_t)segs[i].side; } } void FProcessor::WriteGLSegsX (FWadWriter &out, const MapSegGLEx *segs, int numsegs, int nodever) { - out << (DWORD)numsegs; + out << (uint32_t)numsegs; if (nodever < 2) { for (int i = 0; i < numsegs; ++i) { - out << (DWORD)segs[i].v1 - << (DWORD)segs[i].partner - << (WORD)segs[i].linedef - << (BYTE)segs[i].side; + out << (uint32_t)segs[i].v1 + << (uint32_t)segs[i].partner + << (uint16_t)segs[i].linedef + << (uint8_t)segs[i].side; } } else { for (int i = 0; i < numsegs; ++i) { - out << (DWORD)segs[i].v1 - << (DWORD)segs[i].partner - << (DWORD)segs[i].linedef - << (BYTE)segs[i].side; + out << (uint32_t)segs[i].v1 + << (uint32_t)segs[i].partner + << (uint32_t)segs[i].linedef + << (uint8_t)segs[i].side; } } } void FProcessor::WriteNodesX (FWadWriter &out, const MapNodeEx *nodes, int numnodes, int nodever) { - out << (DWORD)numnodes; + out << (uint32_t)numnodes; for (int i = 0; i < numnodes; ++i) { if (nodever < 3) { - out << (SWORD)(nodes[i].x >> 16) - << (SWORD)(nodes[i].y >> 16) - << (SWORD)(nodes[i].dx >> 16) - << (SWORD)(nodes[i].dy >> 16); + out << (int16_t)(nodes[i].x >> 16) + << (int16_t)(nodes[i].y >> 16) + << (int16_t)(nodes[i].dx >> 16) + << (int16_t)(nodes[i].dy >> 16); } else { - out << (DWORD)nodes[i].x - << (DWORD)nodes[i].y - << (DWORD)nodes[i].dx - << (DWORD)nodes[i].dy; + out << (uint32_t)nodes[i].x + << (uint32_t)nodes[i].y + << (uint32_t)nodes[i].dx + << (uint32_t)nodes[i].dy; } for (int j = 0; j < 2; ++j) { for (int k = 0; k < 4; ++k) { - out << (SWORD)nodes[i].bbox[j][k]; + out << (int16_t)nodes[i].bbox[j][k]; } } - out << (DWORD)nodes[i].children[0] - << (DWORD)nodes[i].children[1]; + out << (uint32_t)nodes[i].children[0] + << (uint32_t)nodes[i].children[1]; } } @@ -1719,7 +1719,7 @@ ZLibOut::~ZLibOut () Out.AddToLump (Buffer, BUFFER_SIZE - Stream.avail_out); } -void ZLibOut::Write (BYTE *data, int len) +void ZLibOut::Write (uint8_t *data, int len) { int err; @@ -1742,36 +1742,36 @@ void ZLibOut::Write (BYTE *data, int len) } } -ZLibOut &ZLibOut::operator << (BYTE val) +ZLibOut &ZLibOut::operator << (uint8_t val) { Write (&val, 1); return *this; } -ZLibOut &ZLibOut::operator << (WORD val) +ZLibOut &ZLibOut::operator << (uint16_t val) { val = LittleShort(val); - Write ((BYTE *)&val, 2); + Write ((uint8_t *)&val, 2); return *this; } -ZLibOut &ZLibOut::operator << (SWORD val) +ZLibOut &ZLibOut::operator << (int16_t val) { val = LittleShort(val); - Write ((BYTE *)&val, 2); + Write ((uint8_t *)&val, 2); return *this; } -ZLibOut &ZLibOut::operator << (DWORD val) +ZLibOut &ZLibOut::operator << (uint32_t val) { val = LittleLong(val); - Write ((BYTE *)&val, 4); + Write ((uint8_t *)&val, 4); return *this; } ZLibOut &ZLibOut::operator << (fixed_t val) { val = LittleLong(val); - Write ((BYTE *)&val, 4); + Write ((uint8_t *)&val, 4); return *this; } diff --git a/src/level/level.h b/src/level/level.h index abcbf0e..6b8527e 100644 --- a/src/level/level.h +++ b/src/level/level.h @@ -16,18 +16,18 @@ public: ZLibOut(FWadWriter &out); ~ZLibOut(); - ZLibOut &operator << (BYTE); - ZLibOut &operator << (WORD); - ZLibOut &operator << (SWORD); - ZLibOut &operator << (DWORD); + ZLibOut &operator << (uint8_t); + ZLibOut &operator << (uint16_t); + ZLibOut &operator << (int16_t); + ZLibOut &operator << (uint32_t); ZLibOut &operator << (fixed_t); - void Write(BYTE *data, int len); + void Write(uint8_t *data, int len); private: enum { BUFFER_SIZE = 8192 }; z_stream Stream; - BYTE Buffer[BUFFER_SIZE]; + uint8_t Buffer[BUFFER_SIZE]; FWadWriter &Out; }; @@ -54,7 +54,7 @@ private: MapSubsectorEx *SubsectorsToEx(const MapSubsector *ssec, int count); MapSegGLEx *SegGLsToEx(const MapSegGL *segs, int count); - BYTE *FixReject(const BYTE *oldreject); + uint8_t *FixReject(const uint8_t *oldreject); bool CheckForFracSplitters(const MapNodeEx *nodes, int count); void WriteLines(FWadWriter &out); diff --git a/src/level/workdata.h b/src/level/workdata.h index d145a29..4b496f8 100644 --- a/src/level/workdata.h +++ b/src/level/workdata.h @@ -17,6 +17,6 @@ struct node_t struct subsector_t { - DWORD numlines; - DWORD firstline; + uint32_t numlines; + uint32_t firstline; }; diff --git a/src/nodebuilder/nodebuild.cpp b/src/nodebuilder/nodebuild.cpp index bd51469..034f88d 100644 --- a/src/nodebuilder/nodebuild.cpp +++ b/src/nodebuilder/nodebuild.cpp @@ -73,11 +73,11 @@ void FNodeBuilder::BuildTree () fprintf (stderr, " BSP: 100.0%%\n"); } -DWORD FNodeBuilder::CreateNode (DWORD set, unsigned int count, fixed_t bbox[4]) +uint32_t FNodeBuilder::CreateNode (uint32_t set, unsigned int count, fixed_t bbox[4]) { node_t node; int skip, selstat; - DWORD splitseg; + uint32_t splitseg; // When building GL nodes, count may not be an exact count of the number of segs // in this set. That's okay, because we just use it to get a skip count, so an @@ -91,7 +91,7 @@ DWORD FNodeBuilder::CreateNode (DWORD set, unsigned int count, fixed_t bbox[4]) CheckSubsector (set, node, splitseg)) { // Create a normal node - DWORD set1, set2; + uint32_t set1, set2; unsigned int count1, count2; SplitSegs (set, node, splitseg, set1, set2, count1, count2); @@ -112,7 +112,7 @@ DWORD FNodeBuilder::CreateNode (DWORD set, unsigned int count, fixed_t bbox[4]) } } -DWORD FNodeBuilder::CreateSubsector (DWORD set, fixed_t bbox[4]) +uint32_t FNodeBuilder::CreateSubsector (uint32_t set, fixed_t bbox[4]) { int ssnum, count; @@ -125,7 +125,7 @@ DWORD FNodeBuilder::CreateSubsector (DWORD set, fixed_t bbox[4]) #if defined(_DEBUG)// || 1 // Check for segs with duplicate start/end vertices - DWORD s1, s2; + uint32_t s1, s2; for (s1 = set; s1 != DWORD_MAX; s1 = Segs[s1].next) { @@ -181,9 +181,9 @@ void FNodeBuilder::CreateSubsectorsForReal () for (i = 0; i < SubsectorSets.Size(); ++i) { subsector_t sub; - DWORD set = SubsectorSets[i]; + uint32_t set = SubsectorSets[i]; - sub.firstline = (DWORD)SegList.Size(); + sub.firstline = (uint32_t)SegList.Size(); while (set != DWORD_MAX) { USegPtr ptr; @@ -192,7 +192,7 @@ void FNodeBuilder::CreateSubsectorsForReal () SegList.Push (ptr); set = ptr.SegPtr->next; } - sub.numlines = (DWORD)(SegList.Size() - sub.firstline); + sub.numlines = (uint32_t)(SegList.Size() - sub.firstline); // Sort segs by linedef for special effects qsort (&SegList[sub.firstline], sub.numlines, sizeof(USegPtr), SortSegs); @@ -215,7 +215,7 @@ void FNodeBuilder::CreateSubsectorsForReal () Vertices[SegList[i].SegPtr->v2].y>>16, Vertices[SegList[i].SegPtr->v1].x, Vertices[SegList[i].SegPtr->v1].y, Vertices[SegList[i].SegPtr->v2].x, Vertices[SegList[i].SegPtr->v2].y)); - SegList[i].SegNum = DWORD(SegList[i].SegPtr - &Segs[0]); + SegList[i].SegNum = uint32_t(SegList[i].SegPtr - &Segs[0]); } Subsectors.Push (sub); } @@ -286,10 +286,10 @@ int STACK_ARGS FNodeBuilder::SortSegs (const void *a, const void *b) // a splitter is synthesized, and true is returned to continue processing // down this branch of the tree. -bool FNodeBuilder::CheckSubsector (DWORD set, node_t &node, DWORD &splitseg) +bool FNodeBuilder::CheckSubsector (uint32_t set, node_t &node, uint32_t &splitseg) { int sec; - DWORD seg; + uint32_t seg; sec = -1; seg = set; @@ -347,10 +347,10 @@ bool FNodeBuilder::CheckSubsector (DWORD set, node_t &node, DWORD &splitseg) // When creating GL nodes, we need to check for segs with the same start and // end vertices and split them into two subsectors. -bool FNodeBuilder::CheckSubsectorOverlappingSegs (DWORD set, node_t &node, DWORD &splitseg) +bool FNodeBuilder::CheckSubsectorOverlappingSegs (uint32_t set, node_t &node, uint32_t &splitseg) { int v1, v2; - DWORD seg1, seg2; + uint32_t seg1, seg2; for (seg1 = set; seg1 != DWORD_MAX; seg1 = Segs[seg1].next) { @@ -390,7 +390,7 @@ bool FNodeBuilder::CheckSubsectorOverlappingSegs (DWORD set, node_t &node, DWORD // seg in front of the splitter is partnered with a new miniseg on // the back so that the back will have two segs. -bool FNodeBuilder::ShoveSegBehind (DWORD set, node_t &node, DWORD seg, DWORD mate) +bool FNodeBuilder::ShoveSegBehind (uint32_t set, node_t &node, uint32_t seg, uint32_t mate) { SetNodeFromSeg (node, &Segs[seg]); HackSeg = seg; @@ -412,12 +412,12 @@ bool FNodeBuilder::ShoveSegBehind (DWORD set, node_t &node, DWORD seg, DWORD mat // each unique plane needs to be considered as a splitter. A result of 0 means // this set is a convex region. A result of -1 means that there were possible // splitters, but they all split segs we want to keep intact. -int FNodeBuilder::SelectSplitter (DWORD set, node_t &node, DWORD &splitseg, int step, bool nosplit) +int FNodeBuilder::SelectSplitter (uint32_t set, node_t &node, uint32_t &splitseg, int step, bool nosplit) { int stepleft; int bestvalue; - DWORD bestseg; - DWORD seg; + uint32_t bestseg; + uint32_t seg; bool nosplitters = false; bestvalue = 0; @@ -494,7 +494,7 @@ int FNodeBuilder::SelectSplitter (DWORD set, node_t &node, DWORD &splitseg, int // true. A score of 0 means that the splitter does not split any of the segs // in the set. -int FNodeBuilder::Heuristic (node_t &node, DWORD set, bool honorNoSplit) +int FNodeBuilder::Heuristic (node_t &node, uint32_t set, bool honorNoSplit) { // Set the initial score above 0 so that near vertex anti-weighting is less likely to produce a negative score. int score = 1000000; @@ -502,7 +502,7 @@ int FNodeBuilder::Heuristic (node_t &node, DWORD set, bool honorNoSplit) int counts[2] = { 0, 0 }; int realSegs[2] = { 0, 0 }; int specialSegs[2] = { 0, 0 }; - DWORD i = set; + uint32_t i = set; int sidev[2]; int side; bool splitter = false; @@ -733,7 +733,7 @@ int FNodeBuilder::Heuristic (node_t &node, DWORD set, bool honorNoSplit) return score; } -void FNodeBuilder::SplitSegs (DWORD set, node_t &node, DWORD splitseg, DWORD &outset0, DWORD &outset1, unsigned int &count0, unsigned int &count1) +void FNodeBuilder::SplitSegs (uint32_t set, node_t &node, uint32_t splitseg, uint32_t &outset0, uint32_t &outset1, unsigned int &count0, unsigned int &count1) { unsigned int _count0 = 0; unsigned int _count1 = 0; @@ -865,7 +865,7 @@ void FNodeBuilder::SplitSegs (DWORD set, node_t &node, DWORD splitseg, DWORD &ou } if (hack && GLNodes) { - DWORD newback, newfront; + uint32_t newback, newfront; newback = AddMiniseg (seg->v2, seg->v1, DWORD_MAX, set, splitseg); if (HackMate == DWORD_MAX) @@ -917,7 +917,7 @@ void FNodeBuilder::SetNodeFromSeg (node_t &node, const FPrivSeg *pseg) const } } -DWORD FNodeBuilder::SplitSeg (DWORD segnum, int splitvert, int v1InFront) +uint32_t FNodeBuilder::SplitSeg (uint32_t segnum, int splitvert, int v1InFront) { double dx, dy; FPrivSeg newseg; @@ -970,7 +970,7 @@ DWORD FNodeBuilder::SplitSeg (DWORD segnum, int splitvert, int v1InFront) return newnum; } -void FNodeBuilder::RemoveSegFromVert1 (DWORD segnum, int vertnum) +void FNodeBuilder::RemoveSegFromVert1 (uint32_t segnum, int vertnum) { FPrivVert *v = &Vertices[vertnum]; @@ -980,7 +980,7 @@ void FNodeBuilder::RemoveSegFromVert1 (DWORD segnum, int vertnum) } else { - DWORD prev, curr; + uint32_t prev, curr; prev = 0; curr = v->segs; while (curr != DWORD_MAX && curr != segnum) @@ -995,7 +995,7 @@ void FNodeBuilder::RemoveSegFromVert1 (DWORD segnum, int vertnum) } } -void FNodeBuilder::RemoveSegFromVert2 (DWORD segnum, int vertnum) +void FNodeBuilder::RemoveSegFromVert2 (uint32_t segnum, int vertnum) { FPrivVert *v = &Vertices[vertnum]; @@ -1005,7 +1005,7 @@ void FNodeBuilder::RemoveSegFromVert2 (DWORD segnum, int vertnum) } else { - DWORD prev, curr; + uint32_t prev, curr; prev = 0; curr = v->segs2; while (curr != DWORD_MAX && curr != segnum) @@ -1041,7 +1041,7 @@ double FNodeBuilder::InterceptVector (const node_t &splitter, const FPrivSeg &se return num / den; } -void FNodeBuilder::PrintSet (int l, DWORD set) +void FNodeBuilder::PrintSet (int l, uint32_t set) { Printf ("set %d:\n", l); for (; set != DWORD_MAX; set = Segs[set].next) @@ -1078,7 +1078,7 @@ int ClassifyLineBackpatchC (node_t &node, const FSimpleVert *v1, const FSimpleVe int *calleroffset; int diff; int (*func)(node_t &, const FSimpleVert *, const FSimpleVert *, int[2]); - DWORD oldprotect; + uint32_t oldprotect; #ifdef __GNUC__ calleroffset = (int *)__builtin_return_address(0); diff --git a/src/nodebuilder/nodebuild.h b/src/nodebuilder/nodebuild.h index 05fa784..64db581 100644 --- a/src/nodebuilder/nodebuild.h +++ b/src/nodebuilder/nodebuild.h @@ -9,7 +9,7 @@ struct FEventInfo { int Vertex; - DWORD FrontSeg; + uint32_t FrontSeg; }; struct FEvent @@ -74,16 +74,16 @@ class FNodeBuilder struct FPrivSeg { int v1, v2; - DWORD sidedef; + uint32_t sidedef; int linedef; int frontsector; int backsector; - DWORD next; - DWORD nextforvert; - DWORD nextforvert2; + uint32_t next; + uint32_t nextforvert; + uint32_t nextforvert2; int loopnum; // loop number for split avoidance (0 means splitting is okay) - DWORD partner; // seg on back side - DWORD storedseg; // seg # in the GL_SEGS lump + uint32_t partner; // seg on back side + uint32_t storedseg; // seg # in the GL_SEGS lump angle_t angle; fixed_t offset; @@ -93,8 +93,8 @@ class FNodeBuilder }; struct FPrivVert : FSimpleVert { - DWORD segs; // segs that use this vertex as v1 - DWORD segs2; // segs that use this vertex as v2 + uint32_t segs; // segs that use this vertex as v1 + uint32_t segs2; // segs that use this vertex as v2 int index; int pad; // This structure must be 8-byte aligned. @@ -109,13 +109,13 @@ class FNodeBuilder }; union USegPtr { - DWORD SegNum; + uint32_t SegNum; FPrivSeg *SegPtr; }; struct FSplitSharer { double Distance; - DWORD Seg; + uint32_t Seg; bool Forward; }; @@ -185,11 +185,11 @@ private: TArray Nodes; TArray Subsectors; - TArray SubsectorSets; + TArray SubsectorSets; TArray Segs; TArray Vertices; TArray SegList; - TArray PlaneChecked; + TArray PlaneChecked; TArray Planes; size_t InitialVertices; // Number of vertices in a map that are connected to linedefs @@ -198,8 +198,8 @@ private: FEventTree Events; // Vertices intersected by the current splitter TArray SplitSharers; // Segs collinear with the current splitter - DWORD HackSeg; // Seg to force to back of splitter - DWORD HackMate; // Seg to use in front of hack seg + uint32_t HackSeg; // Seg to force to back of splitter + uint32_t HackMate; // Seg to use in front of hack seg FLevel &Level; bool GLNodes; @@ -214,18 +214,18 @@ private: void GroupSegPlanes (); void FindPolyContainers (TArray &spots, TArray &anchors); bool GetPolyExtents (int polynum, fixed_t bbox[4]); - int MarkLoop (DWORD firstseg, int loopnum); + int MarkLoop (uint32_t firstseg, int loopnum); void AddSegToBBox (fixed_t bbox[4], const FPrivSeg *seg); - DWORD CreateNode (DWORD set, unsigned int count, fixed_t bbox[4]); - DWORD CreateSubsector (DWORD set, fixed_t bbox[4]); + uint32_t CreateNode (uint32_t set, unsigned int count, fixed_t bbox[4]); + uint32_t CreateSubsector (uint32_t set, fixed_t bbox[4]); void CreateSubsectorsForReal (); - bool CheckSubsector (DWORD set, node_t &node, DWORD &splitseg); - bool CheckSubsectorOverlappingSegs (DWORD set, node_t &node, DWORD &splitseg); - bool ShoveSegBehind (DWORD set, node_t &node, DWORD seg, DWORD mate); - int SelectSplitter (DWORD set, node_t &node, DWORD &splitseg, int step, bool nosplit); - void SplitSegs (DWORD set, node_t &node, DWORD splitseg, DWORD &outset0, DWORD &outset1, unsigned int &count0, unsigned int &count1); - DWORD SplitSeg (DWORD segnum, int splitvert, int v1InFront); - int Heuristic (node_t &node, DWORD set, bool honorNoSplit); + bool CheckSubsector (uint32_t set, node_t &node, uint32_t &splitseg); + bool CheckSubsectorOverlappingSegs (uint32_t set, node_t &node, uint32_t &splitseg); + bool ShoveSegBehind (uint32_t set, node_t &node, uint32_t seg, uint32_t mate); + int SelectSplitter (uint32_t set, node_t &node, uint32_t &splitseg, int step, bool nosplit); + void SplitSegs (uint32_t set, node_t &node, uint32_t splitseg, uint32_t &outset0, uint32_t &outset1, unsigned int &count0, unsigned int &count1); + uint32_t SplitSeg (uint32_t segnum, int splitvert, int v1InFront); + int Heuristic (node_t &node, uint32_t set, bool honorNoSplit); // Returns: // 0 = seg is in front @@ -236,19 +236,19 @@ private: void FixSplitSharers (); double AddIntersection (const node_t &node, int vertex); - void AddMinisegs (const node_t &node, DWORD splitseg, DWORD &fset, DWORD &rset); - DWORD CheckLoopStart (fixed_t dx, fixed_t dy, int vertex1, int vertex2); - DWORD CheckLoopEnd (fixed_t dx, fixed_t dy, int vertex2); - void RemoveSegFromVert1 (DWORD segnum, int vertnum); - void RemoveSegFromVert2 (DWORD segnum, int vertnum); - DWORD AddMiniseg (int v1, int v2, DWORD partner, DWORD seg1, DWORD splitseg); + void AddMinisegs (const node_t &node, uint32_t splitseg, uint32_t &fset, uint32_t &rset); + uint32_t CheckLoopStart (fixed_t dx, fixed_t dy, int vertex1, int vertex2); + uint32_t CheckLoopEnd (fixed_t dx, fixed_t dy, int vertex2); + void RemoveSegFromVert1 (uint32_t segnum, int vertnum); + void RemoveSegFromVert2 (uint32_t segnum, int vertnum); + uint32_t AddMiniseg (int v1, int v2, uint32_t partner, uint32_t seg1, uint32_t splitseg); void SetNodeFromSeg (node_t &node, const FPrivSeg *pseg) const; int RemoveMinisegs (MapNodeEx *nodes, TArray &segs, MapSubsectorEx *subs, int node, short bbox[4]); int StripMinisegs (TArray &segs, int subsector, short bbox[4]); void AddSegToShortBBox (short bbox[4], const FPrivSeg *seg); int CloseSubsector (TArray &segs, int subsector); - DWORD PushGLSeg (TArray &segs, const FPrivSeg *seg); + uint32_t PushGLSeg (TArray &segs, const FPrivSeg *seg); void PushConnectingGLSeg (int subsector, TArray &segs, int v1, int v2); int OutputDegenerateSubsector (TArray &segs, int subsector, bool bForward, double lastdot, FPrivSeg *&prev); @@ -256,7 +256,7 @@ private: double InterceptVector (const node_t &splitter, const FPrivSeg &seg); - void PrintSet (int l, DWORD set); + void PrintSet (int l, uint32_t set); void DumpNodes(MapNodeEx *outNodes, int nodeCount); }; diff --git a/src/nodebuilder/nodebuild_extract.cpp b/src/nodebuilder/nodebuild_extract.cpp index eea5c34..3d79147 100644 --- a/src/nodebuilder/nodebuild_extract.cpp +++ b/src/nodebuilder/nodebuild_extract.cpp @@ -317,7 +317,7 @@ int FNodeBuilder::OutputDegenerateSubsector (TArray &segs, int subse return count; } -DWORD FNodeBuilder::PushGLSeg (TArray &segs, const FPrivSeg *seg) +uint32_t FNodeBuilder::PushGLSeg (TArray &segs, const FPrivSeg *seg) { MapSegGLEx newseg; diff --git a/src/nodebuilder/nodebuild_gl.cpp b/src/nodebuilder/nodebuild_gl.cpp index 271e385..8055089 100644 --- a/src/nodebuilder/nodebuild_gl.cpp +++ b/src/nodebuilder/nodebuild_gl.cpp @@ -67,7 +67,7 @@ void FNodeBuilder::FixSplitSharers () D(Events.PrintTree()); for (unsigned int i = 0; i < SplitSharers.Size(); ++i) { - DWORD seg = SplitSharers[i].Seg; + uint32_t seg = SplitSharers[i].Seg; int v2 = Segs[seg].v2; FEvent *event = Events.FindEvent (SplitSharers[i].Distance); FEvent *next; @@ -119,12 +119,12 @@ void FNodeBuilder::FixSplitSharers () Vertices[event->Info.Vertex].y>>16, event->Distance)); - DWORD newseg = SplitSeg (seg, event->Info.Vertex, 1); + uint32_t newseg = SplitSeg (seg, event->Info.Vertex, 1); Segs[newseg].next = Segs[seg].next; Segs[seg].next = newseg; - DWORD partner = Segs[seg].partner; + uint32_t partner = Segs[seg].partner; if (partner != DWORD_MAX) { int endpartner = SplitSeg (partner, event->Info.Vertex, 1); @@ -159,7 +159,7 @@ void FNodeBuilder::FixSplitSharers () } } -void FNodeBuilder::AddMinisegs (const node_t &node, DWORD splitseg, DWORD &fset, DWORD &bset) +void FNodeBuilder::AddMinisegs (const node_t &node, uint32_t splitseg, uint32_t &fset, uint32_t &bset) { FEvent *event = Events.GetMinimum (), *prev = NULL; @@ -167,8 +167,8 @@ void FNodeBuilder::AddMinisegs (const node_t &node, DWORD splitseg, DWORD &fset, { if (prev != NULL) { - DWORD fseg1, bseg1, fseg2, bseg2; - DWORD fnseg, bnseg; + uint32_t fseg1, bseg1, fseg2, bseg2; + uint32_t fnseg, bnseg; // Minisegs should only be added when they can create valid loops on both the front and // back of the splitter. This means some subsectors could be unclosed if their sectors @@ -225,9 +225,9 @@ void FNodeBuilder::AddMinisegs (const node_t &node, DWORD splitseg, DWORD &fset, } } -DWORD FNodeBuilder::AddMiniseg (int v1, int v2, DWORD partner, DWORD seg1, DWORD splitseg) +uint32_t FNodeBuilder::AddMiniseg (int v1, int v2, uint32_t partner, uint32_t seg1, uint32_t splitseg) { - DWORD nseg; + uint32_t nseg; FPrivSeg *seg = &Segs[seg1]; FPrivSeg newseg; @@ -279,13 +279,13 @@ DWORD FNodeBuilder::AddMiniseg (int v1, int v2, DWORD partner, DWORD seg1, DWORD return nseg; } -DWORD FNodeBuilder::CheckLoopStart (fixed_t dx, fixed_t dy, int vertex, int vertex2) +uint32_t FNodeBuilder::CheckLoopStart (fixed_t dx, fixed_t dy, int vertex, int vertex2) { FPrivVert *v = &Vertices[vertex]; angle_t splitAngle = PointToAngle (dx, dy); - DWORD segnum; + uint32_t segnum; angle_t bestang; - DWORD bestseg; + uint32_t bestseg; // Find the seg ending at this vertex that forms the smallest angle // to the splitter. @@ -338,13 +338,13 @@ DWORD FNodeBuilder::CheckLoopStart (fixed_t dx, fixed_t dy, int vertex, int vert return bestseg; } -DWORD FNodeBuilder::CheckLoopEnd (fixed_t dx, fixed_t dy, int vertex) +uint32_t FNodeBuilder::CheckLoopEnd (fixed_t dx, fixed_t dy, int vertex) { FPrivVert *v = &Vertices[vertex]; angle_t splitAngle = PointToAngle (dx, dy) + ANGLE_180; - DWORD segnum; + uint32_t segnum; angle_t bestang; - DWORD bestseg; + uint32_t bestseg; // Find the seg starting at this vertex that forms the smallest angle // to the splitter. diff --git a/src/nodebuilder/nodebuild_utility.cpp b/src/nodebuilder/nodebuild_utility.cpp index d668830..9144e10 100644 --- a/src/nodebuilder/nodebuild_utility.cpp +++ b/src/nodebuilder/nodebuild_utility.cpp @@ -108,7 +108,7 @@ void FNodeBuilder::MakeSegsFromSides () int FNodeBuilder::CreateSeg (int linenum, int sidenum) { FPrivSeg seg; - DWORD backside; + uint32_t backside; int segnum; seg.next = DWORD_MAX; @@ -287,7 +287,7 @@ void FNodeBuilder::FindPolyContainers (TArray &spots, TArrayx>>16, spot->y>>16, center.x>>16, center.y>>16)); @@ -333,7 +333,7 @@ void FNodeBuilder::FindPolyContainers (TArray &spots, TArrayv1].x>>16, Vertices[s1->v1].y>>16, Vertices[s1->v2].x>>16, Vertices[s1->v2].y>>16)); - DWORD bestseg = DWORD_MAX; - DWORD tryseg = Vertices[s1->v2].segs; + uint32_t bestseg = DWORD_MAX; + uint32_t tryseg = Vertices[s1->v2].segs; angle_t bestang = ANGLE_MAX; angle_t ang1 = s1->angle; diff --git a/src/viewer/view.cpp b/src/viewer/view.cpp index aa700f6..428287f 100644 --- a/src/viewer/view.cpp +++ b/src/viewer/view.cpp @@ -234,7 +234,7 @@ static TArray DesiredHistory; static void DrawSubsector (HDC dc, int ssec) { - for (DWORD i = 0; i < Level->Subsectors[ssec].numlines; ++i) + for (uint32_t i = 0; i < Level->Subsectors[ssec].numlines; ++i) { int seg = Level->Subsectors[ssec].firstline + i; if (Level->Segs[seg].side == 0) @@ -256,7 +256,7 @@ static void DrawSubsectorGL (HDC dc, int ssec, HPEN miniPen, HPEN badPen) seg = Level->GLSubsectors[ssec].firstline; MoveToEx (dc, GLVERTX(Level->GLSegs[seg].v1), GLVERTY(Level->GLSegs[seg].v1), NULL); - for (DWORD i = 0; i < Level->GLSubsectors[ssec].numlines; ++i) + for (uint32_t i = 0; i < Level->GLSubsectors[ssec].numlines; ++i) { HPEN oldPen = NULL; seg = Level->GLSubsectors[ssec].firstline + i; diff --git a/src/wad/wad.cpp b/src/wad/wad.cpp index 5986c3f..7609738 100644 --- a/src/wad/wad.cpp +++ b/src/wad/wad.cpp @@ -415,10 +415,10 @@ void FWadWriter::WriteLump (const char *name, const void *data, int len) void FWadWriter::CopyLump (FWadReader &wad, int lump) { - BYTE *data; + uint8_t *data; int size; - ReadLump (wad, lump, data, size); + ReadLump (wad, lump, data, size); if (data != NULL) { WriteLump (wad.LumpName (lump), data, size); @@ -449,37 +449,37 @@ void FWadWriter::SafeWrite (const void *buffer, size_t size) } } -FWadWriter &FWadWriter::operator << (BYTE val) +FWadWriter &FWadWriter::operator << (uint8_t val) { AddToLump (&val, 1); return *this; } -FWadWriter &FWadWriter::operator << (WORD val) +FWadWriter &FWadWriter::operator << (uint16_t val) { val = LittleShort(val); - AddToLump ((BYTE *)&val, 2); + AddToLump ((uint8_t *)&val, 2); return *this; } -FWadWriter &FWadWriter::operator << (SWORD val) +FWadWriter &FWadWriter::operator << (int16_t val) { val = LittleShort(val); - AddToLump ((BYTE *)&val, 2); + AddToLump ((uint8_t *)&val, 2); return *this; } -FWadWriter &FWadWriter::operator << (DWORD val) +FWadWriter &FWadWriter::operator << (uint32_t val) { val = LittleLong(val); - AddToLump ((BYTE *)&val, 4); + AddToLump ((uint8_t *)&val, 4); return *this; } FWadWriter &FWadWriter::operator << (fixed_t val) { val = LittleLong(val); - AddToLump ((BYTE *)&val, 4); + AddToLump ((uint8_t *)&val, 4); return *this; } diff --git a/src/wad/wad.h b/src/wad/wad.h index 8b6ae05..2e4ec39 100644 --- a/src/wad/wad.h +++ b/src/wad/wad.h @@ -94,10 +94,10 @@ public: void StartWritingLump (const char *name); void AddToLump (const void *data, int len); - FWadWriter &operator << (BYTE); - FWadWriter &operator << (WORD); - FWadWriter &operator << (SWORD); - FWadWriter &operator << (DWORD); + FWadWriter &operator << (uint8_t); + FWadWriter &operator << (uint16_t); + FWadWriter &operator << (int16_t); + FWadWriter &operator << (uint32_t); FWadWriter &operator << (fixed_t); private: diff --git a/zlib/gzguts.h b/zlib/gzguts.h index ee3f281..c2d2a49 100644 --- a/zlib/gzguts.h +++ b/zlib/gzguts.h @@ -102,7 +102,7 @@ /* get errno and strerror definition */ #if defined UNDER_CE # include -# define zstrerror() gz_strwinerror((DWORD)GetLastError()) +# define zstrerror() gz_strwinerror((uint32_t)GetLastError()) #else # ifndef NO_STRERROR # include @@ -179,7 +179,7 @@ typedef gz_state FAR *gz_statep; /* shared functions */ void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); #if defined UNDER_CE -char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); +char ZLIB_INTERNAL *gz_strwinerror OF((uint32_t error)); #endif /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t