From ad41b23506c6111d5aee63df2194854d421f892c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 8 Mar 2017 15:20:00 +0100 Subject: [PATCH] - replaced the homegrown integer types in all p* sources and headers. --- src/p_3dfloors.cpp | 2 +- src/p_3dmidtex.cpp | 8 +- src/p_acs.cpp | 276 +++++++++++++++++++------------------- src/p_acs.h | 84 ++++++------ src/p_actionfunctions.cpp | 8 +- src/p_buildmap.cpp | 128 +++++++++--------- src/p_conversation.cpp | 2 +- src/p_conversation.h | 2 +- src/p_effect.cpp | 16 +-- src/p_effect.h | 10 +- src/p_glnodes.cpp | 100 +++++++------- src/p_lights.cpp | 4 +- src/p_lnspec.cpp | 4 +- src/p_lnspec.h | 8 +- src/p_local.h | 2 +- src/p_map.cpp | 2 +- src/p_maputl.cpp | 2 +- src/p_maputl.h | 14 +- src/p_mobj.cpp | 20 +-- src/p_saveg.cpp | 10 +- src/p_setup.cpp | 102 +++++++------- src/p_setup.h | 8 +- src/p_spec.cpp | 16 +-- src/p_spec.h | 2 +- src/p_states.cpp | 2 +- src/p_switch.cpp | 8 +- src/p_terrain.cpp | 6 +- src/p_terrain.h | 22 +-- src/p_trace.cpp | 10 +- src/p_trace.h | 6 +- src/p_user.cpp | 8 +- src/p_xlat.cpp | 8 +- src/po_man.cpp | 16 +-- src/po_man.h | 2 +- src/portal.cpp | 10 +- src/portal.h | 10 +- src/r_defs.h | 36 ++--- 37 files changed, 487 insertions(+), 487 deletions(-) diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index b699fadbd..bf4966526 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -247,7 +247,7 @@ static int P_Set3DFloor(line_t * line, int param, int param2, int alpha) // The content list changed in r1783 of Vavoom to be unified // among all its supported games, so it has now ten different // values instead of just five. - static DWORD vavoomcolors[] = { VC_EMPTY, + static uint32_t vavoomcolors[] = { VC_EMPTY, VC_WATER, VC_LAVA, VC_NUKAGE, VC_SLIME, VC_HELLSLIME, VC_BLOOD, VC_SLUDGE, VC_HAZARD, VC_BOOMWATER }; flags |= FF_SWIMMABLE | FF_BOTHPLANES | FF_ALLSIDES | FF_FLOOD; diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index cb7f27a08..4cfe01f19 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -122,11 +122,11 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c extsector_t::midtex::plane &scrollplane = ceiling? sector->e->Midtex.Ceiling : sector->e->Midtex.Floor; // Bit arrays that mark whether a line or sector is to be attached. - BYTE *found_lines = new BYTE[(level.lines.Size()+7)/8]; - BYTE *found_sectors = new BYTE[(level.sectors.Size()+7)/8]; + uint8_t *found_lines = new uint8_t[(level.lines.Size()+7)/8]; + uint8_t *found_sectors = new uint8_t[(level.sectors.Size()+7)/8]; - memset(found_lines, 0, sizeof (BYTE) * ((level.lines.Size()+7)/8)); - memset(found_sectors, 0, sizeof (BYTE) * ((level.sectors.Size()+7)/8)); + memset(found_lines, 0, sizeof (uint8_t) * ((level.lines.Size()+7)/8)); + memset(found_sectors, 0, sizeof (uint8_t) * ((level.sectors.Size()+7)/8)); // mark all lines and sectors that are already attached to this one // and clear the arrays. The old data will be re-added automatically diff --git a/src/p_acs.cpp b/src/p_acs.cpp index e912a8769..8b18077e8 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -205,7 +205,7 @@ static DLevelScript *P_GetScriptGoing (AActor *who, line_t *where, int num, cons struct FBehavior::ArrayInfo { - DWORD ArraySize; + uint32_t ArraySize; int32_t *Elements; }; @@ -1563,7 +1563,7 @@ FBehavior *FBehavior::StaticGetModule (int lib) void FBehavior::StaticMarkLevelVarStrings() { // Mark map variables. - for (DWORD modnum = 0; modnum < StaticModules.Size(); ++modnum) + for (uint32_t modnum = 0; modnum < StaticModules.Size(); ++modnum) { StaticModules[modnum]->MarkMapVarStrings(); } @@ -1580,7 +1580,7 @@ void FBehavior::StaticMarkLevelVarStrings() void FBehavior::StaticLockLevelVarStrings() { // Lock map variables. - for (DWORD modnum = 0; modnum < StaticModules.Size(); ++modnum) + for (uint32_t modnum = 0; modnum < StaticModules.Size(); ++modnum) { StaticModules[modnum]->LockMapVarStrings(); } @@ -1743,7 +1743,7 @@ void FBehavior::SerializeVarSet (FSerializer &arc, int32_t *vars, int max) static int ParseLocalArrayChunk(void *chunk, ACSLocalArrays *arrays, int offset) { unsigned count = (LittleShort(static_cast(((unsigned *)chunk)[1]) - 2)) / 4; - int *sizes = (int *)((BYTE *)chunk + 10); + int *sizes = (int *)((uint8_t *)chunk + 10); arrays->Count = count; if (count > 0) { @@ -1783,7 +1783,7 @@ FBehavior::FBehavior() bool FBehavior::Init(int lumpnum, FileReader * fr, int len) { - BYTE *object; + uint8_t *object; int i; LumpNum = lumpnum; @@ -1812,7 +1812,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) return false; } - object = new BYTE[len]; + object = new uint8_t[len]; if (fr == NULL) { Wads.ReadLump (lumpnum, object); @@ -1860,8 +1860,8 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) if (Format == ACS_Old) { - DWORD dirofs = LittleLong(((DWORD *)object)[1]); - DWORD pretag = ((DWORD *)(object + dirofs))[-1]; + uint32_t dirofs = LittleLong(((uint32_t *)object)[1]); + uint32_t pretag = ((uint32_t *)(object + dirofs))[-1]; Chunks = object + len; // Check for redesigned ACSE/ACSe @@ -1870,31 +1870,31 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) pretag == MAKE_ID('A','C','S','E'))) { Format = (pretag == MAKE_ID('A','C','S','e')) ? ACS_LittleEnhanced : ACS_Enhanced; - Chunks = object + LittleLong(((DWORD *)(object + dirofs))[-2]); + Chunks = object + LittleLong(((uint32_t *)(object + dirofs))[-2]); // Forget about the compatibility cruft at the end of the lump - DataSize = LittleLong(((DWORD *)object)[1]) - 8; + DataSize = LittleLong(((uint32_t *)object)[1]) - 8; } } else { - Chunks = object + LittleLong(((DWORD *)object)[1]); + Chunks = object + LittleLong(((uint32_t *)object)[1]); } LoadScriptsDirectory (); if (Format == ACS_Old) { - StringTable = LittleLong(((DWORD *)Data)[1]); - StringTable += LittleLong(((DWORD *)(Data + StringTable))[0]) * 12 + 4; + StringTable = LittleLong(((uint32_t *)Data)[1]); + StringTable += LittleLong(((uint32_t *)(Data + StringTable))[0]) * 12 + 4; UnescapeStringTable(Data + StringTable, Data, false); } else { UnencryptStrings (); - BYTE *strings = FindChunk (MAKE_ID('S','T','R','L')); + uint8_t *strings = FindChunk (MAKE_ID('S','T','R','L')); if (strings != NULL) { - StringTable = DWORD(strings - Data + 8); + StringTable = uint32_t(strings - Data + 8); UnescapeStringTable(strings + 8, NULL, true); } else @@ -1914,15 +1914,15 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) } else { - DWORD *chunk; + uint32_t *chunk; // Load functions - BYTE *funcs; + uint8_t *funcs; Functions = NULL; funcs = FindChunk (MAKE_ID('F','U','N','C')); if (funcs != NULL) { - NumFunctions = LittleLong(((DWORD *)funcs)[1]) / 8; + NumFunctions = LittleLong(((uint32_t *)funcs)[1]) / 8; funcs += 8; FunctionProfileData = new ACSProfileInfo[NumFunctions]; Functions = new ScriptFunction[NumFunctions]; @@ -1941,12 +1941,12 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) // Load local arrays for functions if (NumFunctions > 0) { - for (chunk = (DWORD *)FindChunk(MAKE_ID('F','A','R','Y')); chunk != NULL; chunk = (DWORD *)NextChunk((BYTE *)chunk)) + for (chunk = (uint32_t *)FindChunk(MAKE_ID('F','A','R','Y')); chunk != NULL; chunk = (uint32_t *)NextChunk((uint8_t *)chunk)) { int size = LittleLong(chunk[1]); if (size >= 6) { - unsigned int func_num = LittleShort(((WORD *)chunk)[4]); + unsigned int func_num = LittleShort(((uint16_t *)chunk)[4]); if (func_num < (unsigned int)NumFunctions) { ScriptFunction *func = &Functions[func_num]; @@ -1958,7 +1958,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) } // Load JUMP points - chunk = (DWORD *)FindChunk (MAKE_ID('J','U','M','P')); + chunk = (uint32_t *)FindChunk (MAKE_ID('J','U','M','P')); if (chunk != NULL) { for (i = 0;i < (int)LittleLong(chunk[1]);i += 4) @@ -1967,7 +1967,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) // Initialize this object's map variables memset (MapVarStore, 0, sizeof(MapVarStore)); - chunk = (DWORD *)FindChunk (MAKE_ID('M','I','N','I')); + chunk = (uint32_t *)FindChunk (MAKE_ID('M','I','N','I')); while (chunk != NULL) { int numvars = LittleLong(chunk[1])/4 - 1; @@ -1976,7 +1976,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) { MapVarStore[i+firstvar] = LittleLong(chunk[3+i]); } - chunk = (DWORD *)NextChunk ((BYTE *)chunk); + chunk = (uint32_t *)NextChunk ((uint8_t *)chunk); } // Initialize this object's map variable pointers to defaults. They can be changed @@ -1987,7 +1987,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) } // Create arrays for this module - chunk = (DWORD *)FindChunk (MAKE_ID('A','R','A','Y')); + chunk = (uint32_t *)FindChunk (MAKE_ID('A','R','A','Y')); if (chunk != NULL) { NumArrays = LittleLong(chunk[1])/8; @@ -1998,12 +1998,12 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) MapVarStore[LittleLong(chunk[2+i*2])] = i; ArrayStore[i].ArraySize = LittleLong(chunk[3+i*2]); ArrayStore[i].Elements = new int32_t[ArrayStore[i].ArraySize]; - memset(ArrayStore[i].Elements, 0, ArrayStore[i].ArraySize*sizeof(DWORD)); + memset(ArrayStore[i].Elements, 0, ArrayStore[i].ArraySize*sizeof(uint32_t)); } } // Initialize arrays for this module - chunk = (DWORD *)FindChunk (MAKE_ID('A','I','N','I')); + chunk = (uint32_t *)FindChunk (MAKE_ID('A','I','N','I')); while (chunk != NULL) { int arraynum = MapVarStore[LittleLong(chunk[2])]; @@ -2019,12 +2019,12 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) elems[j] = LittleLong(chunk[3+j]); } } - chunk = (DWORD *)NextChunk((BYTE *)chunk); + chunk = (uint32_t *)NextChunk((uint8_t *)chunk); } // Start setting up array pointers NumTotalArrays = NumArrays; - chunk = (DWORD *)FindChunk (MAKE_ID('A','I','M','P')); + chunk = (uint32_t *)FindChunk (MAKE_ID('A','I','M','P')); if (chunk != NULL) { NumTotalArrays += LittleLong(chunk[2]); @@ -2041,10 +2041,10 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) // Tag the library ID to any map variables that are initialized with strings if (LibraryID != 0) { - chunk = (DWORD *)FindChunk (MAKE_ID('M','S','T','R')); + chunk = (uint32_t *)FindChunk (MAKE_ID('M','S','T','R')); if (chunk != NULL) { - for (DWORD i = 0; i < LittleLong(chunk[1])/4; ++i) + for (uint32_t i = 0; i < LittleLong(chunk[1])/4; ++i) { const char *str = LookupString(MapVarStore[LittleLong(chunk[i+2])]); if (str != NULL) @@ -2054,10 +2054,10 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) } } - chunk = (DWORD *)FindChunk (MAKE_ID('A','S','T','R')); + chunk = (uint32_t *)FindChunk (MAKE_ID('A','S','T','R')); if (chunk != NULL) { - for (DWORD i = 0; i < LittleLong(chunk[1])/4; ++i) + for (uint32_t i = 0; i < LittleLong(chunk[1])/4; ++i) { int arraynum = MapVarStore[LittleLong(chunk[i+2])]; if ((unsigned)arraynum < (unsigned)NumArrays) @@ -2077,10 +2077,10 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) } // [BL] Newer version of ASTR for structure aware compilers although we only have one array per chunk - chunk = (DWORD *)FindChunk (MAKE_ID('A','T','A','G')); + chunk = (uint32_t *)FindChunk (MAKE_ID('A','T','A','G')); while (chunk != NULL) { - const BYTE* chunkData = (const BYTE*)(chunk + 2); + const uint8_t* chunkData = (const uint8_t*)(chunk + 2); // First byte is version, it should be 0 if(*chunkData++ == 0) { @@ -2110,15 +2110,15 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) } } - chunk = (DWORD *)NextChunk ((BYTE *)chunk); + chunk = (uint32_t *)NextChunk ((uint8_t *)chunk); } } // Load required libraries. - if (NULL != (chunk = (DWORD *)FindChunk (MAKE_ID('L','O','A','D')))) + if (NULL != (chunk = (uint32_t *)FindChunk (MAKE_ID('L','O','A','D')))) { const char *const parse = (char *)&chunk[2]; - DWORD i; + uint32_t i; for (i = 0; i < LittleLong(chunk[1]); ) { @@ -2151,7 +2151,7 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) continue; // Resolve functions - chunk = (DWORD *)FindChunk(MAKE_ID('F','N','A','M')); + chunk = (uint32_t *)FindChunk(MAKE_ID('F','N','A','M')); for (j = 0; j < NumFunctions; ++j) { ScriptFunction *func = &((ScriptFunction *)Functions)[j]; @@ -2185,13 +2185,13 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) } // Resolve map variables - chunk = (DWORD *)FindChunk(MAKE_ID('M','I','M','P')); + chunk = (uint32_t *)FindChunk(MAKE_ID('M','I','M','P')); if (chunk != NULL) { char *parse = (char *)&chunk[2]; - for (DWORD j = 0; j < LittleLong(chunk[1]); ) + for (uint32_t j = 0; j < LittleLong(chunk[1]); ) { - DWORD varNum = LittleLong(*(DWORD *)&parse[j]); + uint32_t varNum = LittleLong(*(uint32_t *)&parse[j]); j += 4; int impNum = lib->FindMapVarName (&parse[j]); if (impNum >= 0) @@ -2206,13 +2206,13 @@ bool FBehavior::Init(int lumpnum, FileReader * fr, int len) // Resolve arrays if (NumTotalArrays > NumArrays) { - chunk = (DWORD *)FindChunk(MAKE_ID('A','I','M','P')); + chunk = (uint32_t *)FindChunk(MAKE_ID('A','I','M','P')); char *parse = (char *)&chunk[3]; - for (DWORD j = 0; j < LittleLong(chunk[2]); ++j) + for (uint32_t j = 0; j < LittleLong(chunk[2]); ++j) { - DWORD varNum = LittleLong(*(DWORD *)parse); + uint32_t varNum = LittleLong(*(uint32_t *)parse); parse += 4; - DWORD expectedSize = LittleLong(*(DWORD *)parse); + uint32_t expectedSize = LittleLong(*(uint32_t *)parse); parse += 4; int impNum = lib->FindMapArray (parse); if (impNum >= 0) @@ -2285,10 +2285,10 @@ void FBehavior::LoadScriptsDirectory () { union { - BYTE *b; - DWORD *dw; - WORD *w; - SWORD *sw; + uint8_t *b; + uint32_t *dw; + uint16_t *w; + int16_t *sw; ScriptPtr2 *po; // Old ScriptPtr1 *pi; // Intermediate ScriptPtr3 *pe; // LittleEnhanced @@ -2302,7 +2302,7 @@ void FBehavior::LoadScriptsDirectory () switch (Format) { case ACS_Old: - scripts.dw = (DWORD *)(Data + LittleLong(((DWORD *)Data)[1])); + scripts.dw = (uint32_t *)(Data + LittleLong(((uint32_t *)Data)[1])); NumScripts = LittleLong(scripts.dw[0]); if (NumScripts != 0) { @@ -2330,7 +2330,7 @@ void FBehavior::LoadScriptsDirectory () { // There are no scripts! } - else if (*(DWORD *)Data != MAKE_ID('A','C','S',0)) + else if (*(uint32_t *)Data != MAKE_ID('A','C','S',0)) { NumScripts = LittleLong(scripts.dw[1]) / 12; Scripts = new ScriptPtr[NumScripts]; @@ -2342,7 +2342,7 @@ void FBehavior::LoadScriptsDirectory () ScriptPtr *ptr2 = &Scripts[i]; ptr2->Number = LittleShort(ptr1->Number); - ptr2->Type = BYTE(LittleShort(ptr1->Type)); + ptr2->Type = uint8_t(LittleShort(ptr1->Type)); ptr2->ArgCount = LittleLong(ptr1->ArgCount); ptr2->Address = LittleLong(ptr1->Address); } @@ -2497,24 +2497,24 @@ int FBehavior::SortScripts (const void *a, const void *b) void FBehavior::UnencryptStrings () { - DWORD *prevchunk = NULL; - DWORD *chunk = (DWORD *)FindChunk(MAKE_ID('S','T','R','E')); + uint32_t *prevchunk = NULL; + uint32_t *chunk = (uint32_t *)FindChunk(MAKE_ID('S','T','R','E')); while (chunk != NULL) { - for (DWORD strnum = 0; strnum < LittleLong(chunk[3]); ++strnum) + for (uint32_t strnum = 0; strnum < LittleLong(chunk[3]); ++strnum) { int ofs = LittleLong(chunk[5+strnum]); - BYTE *data = (BYTE *)chunk + ofs + 8, last; - int p = (BYTE)(ofs*157135); + uint8_t *data = (uint8_t *)chunk + ofs + 8, last; + int p = (uint8_t)(ofs*157135); int i = 0; do { - last = (data[i] ^= (BYTE)(p+(i>>1))); + last = (data[i] ^= (uint8_t)(p+(i>>1))); ++i; } while (last != 0); } prevchunk = chunk; - chunk = (DWORD *)NextChunk ((BYTE *)chunk); + chunk = (uint32_t *)NextChunk ((uint8_t *)chunk); *prevchunk = MAKE_ID('S','T','R','L'); } if (prevchunk != NULL) @@ -2535,11 +2535,11 @@ void FBehavior::UnencryptStrings () // //============================================================================ -void FBehavior::UnescapeStringTable(BYTE *chunkstart, BYTE *datastart, bool has_padding) +void FBehavior::UnescapeStringTable(uint8_t *chunkstart, uint8_t *datastart, bool has_padding) { assert(chunkstart != NULL); - DWORD *chunk = (DWORD *)chunkstart; + uint32_t *chunk = (uint32_t *)chunkstart; if (datastart == NULL) { @@ -2548,7 +2548,7 @@ void FBehavior::UnescapeStringTable(BYTE *chunkstart, BYTE *datastart, bool has_ if (!has_padding) { chunk[0] = LittleLong(chunk[0]); - for (DWORD strnum = 0; strnum < chunk[0]; ++strnum) + for (uint32_t strnum = 0; strnum < chunk[0]; ++strnum) { int ofs = LittleLong(chunk[1 + strnum]); // Byte swap offset, if needed. chunk[1 + strnum] = ofs; @@ -2558,7 +2558,7 @@ void FBehavior::UnescapeStringTable(BYTE *chunkstart, BYTE *datastart, bool has_ else { chunk[1] = LittleLong(chunk[1]); - for (DWORD strnum = 0; strnum < chunk[1]; ++strnum) + for (uint32_t strnum = 0; strnum < chunk[1]; ++strnum) { int ofs = LittleLong(chunk[3 + strnum]); // Byte swap offset, if needed. chunk[3 + strnum] = ofs; @@ -2591,7 +2591,7 @@ bool FBehavior::IsGood () ScriptFunction *funcdef = (ScriptFunction *)Functions + i; if (funcdef->Address == 0 && funcdef->ImportNum == 0) { - DWORD *chunk = (DWORD *)FindChunk (MAKE_ID('F','N','A','M')); + uint32_t *chunk = (uint32_t *)FindChunk (MAKE_ID('F','N','A','M')); Printf (TEXTCOLOR_RED "Could not find ACS function %s for use in %s.\n", (char *)(chunk + 2) + chunk[3+i], ModuleName); bad = true; @@ -2630,7 +2630,7 @@ const ScriptPtr *FBehavior::FindScript (int script) const const ScriptPtr *FBehavior::StaticFindScript (int script, FBehavior *&module) { - for (DWORD i = 0; i < StaticModules.Size(); ++i) + for (uint32_t i = 0; i < StaticModules.Size(); ++i) { const ScriptPtr *code = StaticModules[i]->FindScript (script); if (code != NULL) @@ -2660,12 +2660,12 @@ ScriptFunction *FBehavior::GetFunction (int funcnum, FBehavior *&module) const int FBehavior::FindFunctionName (const char *funcname) const { - return FindStringInChunk ((DWORD *)FindChunk (MAKE_ID('F','N','A','M')), funcname); + return FindStringInChunk ((uint32_t *)FindChunk (MAKE_ID('F','N','A','M')), funcname); } int FBehavior::FindMapVarName (const char *varname) const { - return FindStringInChunk ((DWORD *)FindChunk (MAKE_ID('M','E','X','P')), varname); + return FindStringInChunk ((uint32_t *)FindChunk (MAKE_ID('M','E','X','P')), varname); } int FBehavior::FindMapArray (const char *arrayname) const @@ -2678,11 +2678,11 @@ int FBehavior::FindMapArray (const char *arrayname) const return -1; } -int FBehavior::FindStringInChunk (DWORD *names, const char *varname) const +int FBehavior::FindStringInChunk (uint32_t *names, const char *varname) const { if (names != NULL) { - DWORD i; + uint32_t i; for (i = 0; i < LittleLong(names[2]); ++i) { @@ -2734,52 +2734,52 @@ inline bool FBehavior::CopyStringToArray(int arraynum, int index, int maxLength, return !(*string); // return true if only terminating 0 was not written } -BYTE *FBehavior::FindChunk (DWORD id) const +uint8_t *FBehavior::FindChunk (uint32_t id) const { - BYTE *chunk = Chunks; + uint8_t *chunk = Chunks; while (chunk != NULL && chunk < Data + DataSize) { - if (((DWORD *)chunk)[0] == id) + if (((uint32_t *)chunk)[0] == id) { return chunk; } - chunk += LittleLong(((DWORD *)chunk)[1]) + 8; + chunk += LittleLong(((uint32_t *)chunk)[1]) + 8; } return NULL; } -BYTE *FBehavior::NextChunk (BYTE *chunk) const +uint8_t *FBehavior::NextChunk (uint8_t *chunk) const { - DWORD id = *(DWORD *)chunk; - chunk += LittleLong(((DWORD *)chunk)[1]) + 8; + uint32_t id = *(uint32_t *)chunk; + chunk += LittleLong(((uint32_t *)chunk)[1]) + 8; while (chunk != NULL && chunk < Data + DataSize) { - if (((DWORD *)chunk)[0] == id) + if (((uint32_t *)chunk)[0] == id) { return chunk; } - chunk += LittleLong(((DWORD *)chunk)[1]) + 8; + chunk += LittleLong(((uint32_t *)chunk)[1]) + 8; } return NULL; } -const char *FBehavior::StaticLookupString (DWORD index) +const char *FBehavior::StaticLookupString (uint32_t index) { - DWORD lib = index >> LIBRARYID_SHIFT; + uint32_t lib = index >> LIBRARYID_SHIFT; if (lib == STRPOOL_LIBRARYID) { return GlobalACSStrings.GetString(index); } - if (lib >= (DWORD)StaticModules.Size()) + if (lib >= (uint32_t)StaticModules.Size()) { return NULL; } return StaticModules[lib]->LookupString (index & 0xffff); } -const char *FBehavior::LookupString (DWORD index) const +const char *FBehavior::LookupString (uint32_t index) const { if (StringTable == 0) { @@ -2787,7 +2787,7 @@ const char *FBehavior::LookupString (DWORD index) const } if (Format == ACS_Old) { - DWORD *list = (DWORD *)(Data + StringTable); + uint32_t *list = (uint32_t *)(Data + StringTable); if (index >= list[0]) return NULL; // Out of range for this list; @@ -2795,7 +2795,7 @@ const char *FBehavior::LookupString (DWORD index) const } else { - DWORD *list = (DWORD *)(Data + StringTable); + uint32_t *list = (uint32_t *)(Data + StringTable); if (index >= list[1]) return NULL; // Out of range for this list @@ -2803,7 +2803,7 @@ const char *FBehavior::LookupString (DWORD index) const } } -void FBehavior::StaticStartTypedScripts (WORD type, AActor *activator, bool always, int arg1, bool runNow) +void FBehavior::StaticStartTypedScripts (uint16_t type, AActor *activator, bool always, int arg1, bool runNow) { static const char *const TypeNames[] = { @@ -2833,7 +2833,7 @@ void FBehavior::StaticStartTypedScripts (WORD type, AActor *activator, bool alwa } } -void FBehavior::StartTypedScripts (WORD type, AActor *activator, bool always, int arg1, bool runNow) +void FBehavior::StartTypedScripts (uint16_t type, AActor *activator, bool always, int arg1, bool runNow) { const ScriptPtr *ptr; int i; @@ -4425,7 +4425,7 @@ bool GetVarAddrType(AActor *self, FName varname, int index, void *&addr, PType * return false; } type = var->Type; - BYTE *baddr = reinterpret_cast(self) + var->Offset; + uint8_t *baddr = reinterpret_cast(self) + var->Offset; arraytype = dyn_cast(type); if (arraytype != NULL) { @@ -5843,7 +5843,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) actorMask = ActorFlags::FromInt(args[5]); } - DWORD wallMask = ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN; + uint32_t wallMask = ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN; if (argCount >= 7) { wallMask = args[6]; } @@ -6247,15 +6247,15 @@ enum inline int getbyte (int *&pc) { - int res = *(BYTE *)pc; - pc = (int *)((BYTE *)pc+1); + int res = *(uint8_t *)pc; + pc = (int *)((uint8_t *)pc+1); return res; } inline int getshort (int *&pc) { - int res = LittleShort( *(SWORD *)pc); - pc = (int *)((BYTE *)pc+2); + int res = LittleShort( *(int16_t *)pc); + pc = (int *)((uint8_t *)pc+2); return res; } @@ -6446,50 +6446,50 @@ int DLevelScript::RunScript () break; case PCD_PUSHBYTE: - PushToStack (*(BYTE *)pc); - pc = (int *)((BYTE *)pc + 1); + PushToStack (*(uint8_t *)pc); + pc = (int *)((uint8_t *)pc + 1); break; case PCD_PUSH2BYTES: - Stack[sp] = ((BYTE *)pc)[0]; - Stack[sp+1] = ((BYTE *)pc)[1]; + Stack[sp] = ((uint8_t *)pc)[0]; + Stack[sp+1] = ((uint8_t *)pc)[1]; sp += 2; - pc = (int *)((BYTE *)pc + 2); + pc = (int *)((uint8_t *)pc + 2); break; case PCD_PUSH3BYTES: - Stack[sp] = ((BYTE *)pc)[0]; - Stack[sp+1] = ((BYTE *)pc)[1]; - Stack[sp+2] = ((BYTE *)pc)[2]; + Stack[sp] = ((uint8_t *)pc)[0]; + Stack[sp+1] = ((uint8_t *)pc)[1]; + Stack[sp+2] = ((uint8_t *)pc)[2]; sp += 3; - pc = (int *)((BYTE *)pc + 3); + pc = (int *)((uint8_t *)pc + 3); break; case PCD_PUSH4BYTES: - Stack[sp] = ((BYTE *)pc)[0]; - Stack[sp+1] = ((BYTE *)pc)[1]; - Stack[sp+2] = ((BYTE *)pc)[2]; - Stack[sp+3] = ((BYTE *)pc)[3]; + Stack[sp] = ((uint8_t *)pc)[0]; + Stack[sp+1] = ((uint8_t *)pc)[1]; + Stack[sp+2] = ((uint8_t *)pc)[2]; + Stack[sp+3] = ((uint8_t *)pc)[3]; sp += 4; - pc = (int *)((BYTE *)pc + 4); + pc = (int *)((uint8_t *)pc + 4); break; case PCD_PUSH5BYTES: - Stack[sp] = ((BYTE *)pc)[0]; - Stack[sp+1] = ((BYTE *)pc)[1]; - Stack[sp+2] = ((BYTE *)pc)[2]; - Stack[sp+3] = ((BYTE *)pc)[3]; - Stack[sp+4] = ((BYTE *)pc)[4]; + Stack[sp] = ((uint8_t *)pc)[0]; + Stack[sp+1] = ((uint8_t *)pc)[1]; + Stack[sp+2] = ((uint8_t *)pc)[2]; + Stack[sp+3] = ((uint8_t *)pc)[3]; + Stack[sp+4] = ((uint8_t *)pc)[4]; sp += 5; - pc = (int *)((BYTE *)pc + 5); + pc = (int *)((uint8_t *)pc + 5); break; case PCD_PUSHBYTES: - temp = *(BYTE *)pc; - pc = (int *)((BYTE *)pc + temp + 1); + temp = *(uint8_t *)pc; + pc = (int *)((uint8_t *)pc + temp + 1); for (temp = -temp; temp; temp++) { - PushToStack (*((BYTE *)pc + temp)); + PushToStack (*((uint8_t *)pc + temp)); } break; @@ -6619,35 +6619,35 @@ int DLevelScript::RunScript () // Parameters for PCD_LSPEC?DIRECTB are by definition bytes so never need and-ing. case PCD_LSPEC1DIRECTB: - P_ExecuteSpecial(((BYTE *)pc)[0], activationline, activator, backSide, - ((BYTE *)pc)[1], 0, 0, 0, 0); - pc = (int *)((BYTE *)pc + 2); + P_ExecuteSpecial(((uint8_t *)pc)[0], activationline, activator, backSide, + ((uint8_t *)pc)[1], 0, 0, 0, 0); + pc = (int *)((uint8_t *)pc + 2); break; case PCD_LSPEC2DIRECTB: - P_ExecuteSpecial(((BYTE *)pc)[0], activationline, activator, backSide, - ((BYTE *)pc)[1], ((BYTE *)pc)[2], 0, 0, 0); - pc = (int *)((BYTE *)pc + 3); + P_ExecuteSpecial(((uint8_t *)pc)[0], activationline, activator, backSide, + ((uint8_t *)pc)[1], ((uint8_t *)pc)[2], 0, 0, 0); + pc = (int *)((uint8_t *)pc + 3); break; case PCD_LSPEC3DIRECTB: - P_ExecuteSpecial(((BYTE *)pc)[0], activationline, activator, backSide, - ((BYTE *)pc)[1], ((BYTE *)pc)[2], ((BYTE *)pc)[3], 0, 0); - pc = (int *)((BYTE *)pc + 4); + P_ExecuteSpecial(((uint8_t *)pc)[0], activationline, activator, backSide, + ((uint8_t *)pc)[1], ((uint8_t *)pc)[2], ((uint8_t *)pc)[3], 0, 0); + pc = (int *)((uint8_t *)pc + 4); break; case PCD_LSPEC4DIRECTB: - P_ExecuteSpecial(((BYTE *)pc)[0], activationline, activator, backSide, - ((BYTE *)pc)[1], ((BYTE *)pc)[2], ((BYTE *)pc)[3], - ((BYTE *)pc)[4], 0); - pc = (int *)((BYTE *)pc + 5); + P_ExecuteSpecial(((uint8_t *)pc)[0], activationline, activator, backSide, + ((uint8_t *)pc)[1], ((uint8_t *)pc)[2], ((uint8_t *)pc)[3], + ((uint8_t *)pc)[4], 0); + pc = (int *)((uint8_t *)pc + 5); break; case PCD_LSPEC5DIRECTB: - P_ExecuteSpecial(((BYTE *)pc)[0], activationline, activator, backSide, - ((BYTE *)pc)[1], ((BYTE *)pc)[2], ((BYTE *)pc)[3], - ((BYTE *)pc)[4], ((BYTE *)pc)[5]); - pc = (int *)((BYTE *)pc + 6); + P_ExecuteSpecial(((uint8_t *)pc)[0], activationline, activator, backSide, + ((uint8_t *)pc)[1], ((uint8_t *)pc)[2], ((uint8_t *)pc)[3], + ((uint8_t *)pc)[4], ((uint8_t *)pc)[5]); + pc = (int *)((uint8_t *)pc + 6); break; case PCD_CALLFUNC: @@ -7673,12 +7673,12 @@ int DLevelScript::RunScript () break; case PCD_DELAYDIRECTB: - statedata = *(BYTE *)pc + (fmt == ACS_Old && gameinfo.gametype == GAME_Hexen); + statedata = *(uint8_t *)pc + (fmt == ACS_Old && gameinfo.gametype == GAME_Hexen); if (statedata > 0) { state = SCRIPT_Delayed; } - pc = (int *)((BYTE *)pc + 1); + pc = (int *)((uint8_t *)pc + 1); break; case PCD_RANDOM: @@ -7692,8 +7692,8 @@ int DLevelScript::RunScript () break; case PCD_RANDOMDIRECTB: - PushToStack (Random (((BYTE *)pc)[0], ((BYTE *)pc)[1])); - pc = (int *)((BYTE *)pc + 2); + PushToStack (Random (((uint8_t *)pc)[0], ((uint8_t *)pc)[1])); + pc = (int *)((uint8_t *)pc + 2); break; case PCD_THINGCOUNT: @@ -10305,7 +10305,7 @@ static void ShowProfileData(TArray &profiles, long ilimit, // Script/function name if (functions) { - DWORD *fnames = (DWORD *)prof->Module->FindChunk(MAKE_ID('F','N','A','M')); + uint32_t *fnames = (uint32_t *)prof->Module->FindChunk(MAKE_ID('F','N','A','M')); if (prof->Index >= 0 && prof->Index < (int)LittleLong(fnames[2])) { mysnprintf(scriptname, sizeof(scriptname), "%s", @@ -10343,7 +10343,7 @@ CCMD(acsprofile) sort_by_runs }; static const char *sort_names[] = { "total", "min", "max", "avg", "runs" }; - static const BYTE sort_match_len[] = { 1, 2, 2, 1, 1 }; + static const uint8_t sort_match_len[] = { 1, 2, 2, 1, 1 }; TArray ScriptProfiles, FuncProfiles; long limit = 10; diff --git a/src/p_acs.h b/src/p_acs.h index 154c53ea8..f675338b4 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -198,11 +198,11 @@ struct ACSLocalArrays struct ScriptPtr { int Number; - DWORD Address; - BYTE Type; - BYTE ArgCount; - WORD VarCount; - WORD Flags; + uint32_t Address; + uint8_t Type; + uint8_t ArgCount; + uint16_t VarCount; + uint16_t Flags; ACSLocalArrays LocalArrays; ACSProfileInfo ProfileData; @@ -211,51 +211,51 @@ struct ScriptPtr // The present ZDoom version struct ScriptPtr3 { - SWORD Number; - BYTE Type; - BYTE ArgCount; - DWORD Address; + int16_t Number; + uint8_t Type; + uint8_t ArgCount; + uint32_t Address; }; // The intermediate ZDoom version struct ScriptPtr1 { - SWORD Number; - WORD Type; - DWORD Address; - DWORD ArgCount; + int16_t Number; + uint16_t Type; + uint32_t Address; + uint32_t ArgCount; }; // The old Hexen version struct ScriptPtr2 { - DWORD Number; // Type is Number / 1000 - DWORD Address; - DWORD ArgCount; + uint32_t Number; // Type is Number / 1000 + uint32_t Address; + uint32_t ArgCount; }; struct ScriptFlagsPtr { - WORD Number; - WORD Flags; + uint16_t Number; + uint16_t Flags; }; struct ScriptFunctionInFile { - BYTE ArgCount; - BYTE LocalCount; - BYTE HasReturnValue; - BYTE ImportNum; - DWORD Address; + uint8_t ArgCount; + uint8_t LocalCount; + uint8_t HasReturnValue; + uint8_t ImportNum; + uint32_t Address; }; struct ScriptFunction { - BYTE ArgCount; - BYTE HasReturnValue; - BYTE ImportNum; + uint8_t ArgCount; + uint8_t HasReturnValue; + uint8_t ImportNum; int LocalCount; - DWORD Address; + uint32_t Address; ACSLocalArrays LocalArrays; }; @@ -296,13 +296,13 @@ public: bool Init(int lumpnum, FileReader * fr = NULL, int len = 0); bool IsGood (); - BYTE *FindChunk (DWORD id) const; - BYTE *NextChunk (BYTE *chunk) const; + uint8_t *FindChunk (uint32_t id) const; + uint8_t *NextChunk (uint8_t *chunk) const; const ScriptPtr *FindScript (int number) const; - void StartTypedScripts (WORD type, AActor *activator, bool always, int arg1, bool runNow); - DWORD PC2Ofs (int *pc) const { return (DWORD)((BYTE *)pc - Data); } - int *Ofs2PC (DWORD ofs) const { return (int *)(Data + ofs); } - int *Jump2PC (DWORD jumpPoint) const { return Ofs2PC(JumpPoints[jumpPoint]); } + void StartTypedScripts (uint16_t type, AActor *activator, bool always, int arg1, bool runNow); + uint32_t PC2Ofs (int *pc) const { return (uint32_t)((uint8_t *)pc - Data); } + int *Ofs2PC (uint32_t ofs) const { return (int *)(Data + ofs); } + int *Jump2PC (uint32_t jumpPoint) const { return Ofs2PC(JumpPoints[jumpPoint]); } ACSFormat GetFormat() const { return Format; } ScriptFunction *GetFunction (int funcnum, FBehavior *&module) const; int GetArrayVal (int arraynum, int index) const; @@ -321,7 +321,7 @@ public: const char *GetModuleName() const { return ModuleName; } ACSProfileInfo *GetFunctionProfileData(int index) { return index >= 0 && index < NumFunctions ? &FunctionProfileData[index] : NULL; } ACSProfileInfo *GetFunctionProfileData(ScriptFunction *func) { return GetFunctionProfileData((int)(func - (ScriptFunction *)Functions)); } - const char *LookupString (DWORD index) const; + const char *LookupString (uint32_t index) const; int32_t *MapVars[NUM_MAPVARS]; @@ -336,8 +336,8 @@ public: static void StaticUnlockLevelVarStrings(); static const ScriptPtr *StaticFindScript (int script, FBehavior *&module); - static const char *StaticLookupString (DWORD index); - static void StaticStartTypedScripts (WORD type, AActor *activator, bool always, int arg1=0, bool runNow=false); + static const char *StaticLookupString (uint32_t index); + static void StaticStartTypedScripts (uint16_t type, AActor *activator, bool always, int arg1=0, bool runNow=false); static void StaticStopMyScripts (AActor *actor); private: @@ -346,9 +346,9 @@ private: ACSFormat Format; int LumpNum; - BYTE *Data; + uint8_t *Data; int DataSize; - BYTE *Chunks; + uint8_t *Chunks; ScriptPtr *Scripts; int NumScripts; ScriptFunction *Functions; @@ -358,10 +358,10 @@ private: int NumArrays; ArrayInfo **Arrays; int NumTotalArrays; - DWORD StringTable; + uint32_t StringTable; int32_t MapVarStore[NUM_MAPVARS]; TArray Imports; - DWORD LibraryID; + uint32_t LibraryID; char ModuleName[9]; TArray JumpPoints; @@ -371,8 +371,8 @@ private: static int SortScripts (const void *a, const void *b); void UnencryptStrings (); - void UnescapeStringTable(BYTE *chunkstart, BYTE *datastart, bool haspadding); - int FindStringInChunk (DWORD *chunk, const char *varname) const; + void UnescapeStringTable(uint8_t *chunkstart, uint8_t *datastart, bool haspadding); + int FindStringInChunk (uint32_t *chunk, const char *varname) const; void SerializeVars (FSerializer &arc); void SerializeVarSet (FSerializer &arc, int32_t *vars, int max); diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index c32372b4e..2556c3b24 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -4798,7 +4798,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetUserVar) PField *var = GetVar(self, varname); if (var != nullptr) { - var->Type->SetValue(reinterpret_cast(self) + var->Offset, value); + var->Type->SetValue(reinterpret_cast(self) + var->Offset, value); } return 0; } @@ -4813,7 +4813,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetUserVarFloat) PField *var = GetVar(self, varname); if (var != nullptr) { - var->Type->SetValue(reinterpret_cast(self) + var->Offset, value); + var->Type->SetValue(reinterpret_cast(self) + var->Offset, value); } return 0; } @@ -4857,7 +4857,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetUserArray) if (var != nullptr) { PArray *arraytype = static_cast(var->Type); - arraytype->ElementType->SetValue(reinterpret_cast(self) + var->Offset + arraytype->ElementSize * pos, value); + arraytype->ElementType->SetValue(reinterpret_cast(self) + var->Offset + arraytype->ElementSize * pos, value); } return 0; } @@ -4874,7 +4874,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SetUserArrayFloat) if (var != nullptr) { PArray *arraytype = static_cast(var->Type); - arraytype->ElementType->SetValue(reinterpret_cast(self) + var->Offset + arraytype->ElementSize * pos, value); + arraytype->ElementType->SetValue(reinterpret_cast(self) + var->Offset + arraytype->ElementSize * pos, value); } return 0; } diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 1be648bc2..3d4e53aa9 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -45,17 +45,17 @@ //40 bytes struct sectortype { - SWORD wallptr, wallnum; + int16_t wallptr, wallnum; int32_t ceilingZ, floorZ; - SWORD ceilingstat, floorstat; - SWORD ceilingpicnum, ceilingheinum; - SBYTE ceilingshade; - BYTE ceilingpal, ceilingxpanning, ceilingypanning; - SWORD floorpicnum, floorheinum; - SBYTE floorshade; - BYTE floorpal, floorxpanning, floorypanning; - BYTE visibility, filler; - SWORD lotag, hitag, extra; + int16_t ceilingstat, floorstat; + int16_t ceilingpicnum, ceilingheinum; + int8_t ceilingshade; + uint8_t ceilingpal, ceilingxpanning, ceilingypanning; + int16_t floorpicnum, floorheinum; + int8_t floorshade; + uint8_t floorpal, floorxpanning, floorypanning; + uint8_t visibility, filler; + int16_t lotag, hitag, extra; }; //cstat: @@ -75,11 +75,11 @@ struct sectortype struct walltype { int32_t x, y; - SWORD point2, nextwall, nextsector, cstat; - SWORD picnum, overpicnum; - SBYTE shade; - BYTE pal, xrepeat, yrepeat, xpanning, ypanning; - SWORD lotag, hitag, extra; + int16_t point2, nextwall, nextsector, cstat; + int16_t picnum, overpicnum; + int8_t shade; + uint8_t pal, xrepeat, yrepeat, xpanning, ypanning; + int16_t lotag, hitag, extra; }; //cstat: @@ -101,29 +101,29 @@ struct walltype struct spritetype { int32_t x, y, z; - SWORD cstat, picnum; - SBYTE shade; - BYTE pal, clipdist, filler; - BYTE xrepeat, yrepeat; - SBYTE xoffset, yoffset; - SWORD sectnum, statnum; - SWORD ang, owner, xvel, yvel, zvel; - SWORD lotag, hitag, extra; + int16_t cstat, picnum; + int8_t shade; + uint8_t pal, clipdist, filler; + uint8_t xrepeat, yrepeat; + int8_t xoffset, yoffset; + int16_t sectnum, statnum; + int16_t ang, owner, xvel, yvel, zvel; + int16_t lotag, hitag, extra; }; // I used to have all the Xobjects mapped out. Not anymore. // (Thanks for the great firmware, Seagate!) struct Xsprite { - BYTE NotReallyPadding[16]; - WORD Data1; - WORD Data2; - WORD Data3; - WORD ThisIsntPaddingEither; - DWORD NorThis:2; - DWORD Data4:16; - DWORD WhatIsThisIDontEven:14; - BYTE ThisNeedsToBe56Bytes[28]; + uint8_t NotReallyPadding[16]; + uint16_t Data1; + uint16_t Data2; + uint16_t Data3; + uint16_t ThisIsntPaddingEither; + uint32_t NorThis:2; + uint32_t Data4:16; + uint32_t WhatIsThisIDontEven:14; + uint8_t ThisNeedsToBe56Bytes[28]; }; struct SlopeWork @@ -142,7 +142,7 @@ void P_AdjustLine (line_t *line); // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- -static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **sprites, int *numsprites); +static bool P_LoadBloodMap (uint8_t *data, size_t len, FMapThing **sprites, int *numsprites); static void LoadSectors (sectortype *bsectors, int count); static void LoadWalls (walltype *walls, int numwalls, sectortype *bsectors); static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, sectortype *bsectors, FMapThing *mapthings); @@ -161,31 +161,31 @@ static void Decrypt (void *to, const void *from, int len, int key); bool P_IsBuildMap(MapData *map) { - DWORD len = map->Size(ML_LABEL); + uint32_t len = map->Size(ML_LABEL); if (len < 4) { return false; } - BYTE *data = new BYTE[len]; + uint8_t *data = new uint8_t[len]; map->Seek(ML_LABEL); map->Read(ML_LABEL, data); // Check for a Blood map. - if (*(DWORD *)data == MAKE_ID('B','L','M','\x1a')) + if (*(uint32_t *)data == MAKE_ID('B','L','M','\x1a')) { delete[] data; return true; } - const int numsec = LittleShort(*(WORD *)(data + 20)); + const int numsec = LittleShort(*(uint16_t *)(data + 20)); int numwalls; if (len < 26 + numsec*sizeof(sectortype) || - (numwalls = LittleShort(*(WORD *)(data + 22 + numsec*sizeof(sectortype))), + (numwalls = LittleShort(*(uint16_t *)(data + 22 + numsec*sizeof(sectortype))), len < 24 + numsec*sizeof(sectortype) + numwalls*sizeof(walltype)) || - LittleLong(*(DWORD *)data) != 7 || - LittleShort(*(WORD *)(data + 16)) >= 2048) + LittleLong(*(uint32_t *)data) != 7 || + LittleShort(*(uint16_t *)(data + 16)) >= 2048) { // Can't possibly be a version 7 BUILD map delete[] data; return false; @@ -200,7 +200,7 @@ bool P_IsBuildMap(MapData *map) // //========================================================================== -bool P_LoadBuildMap (BYTE *data, size_t len, FMapThing **sprites, int *numspr) +bool P_LoadBuildMap (uint8_t *data, size_t len, FMapThing **sprites, int *numspr) { if (len < 26) { @@ -208,20 +208,20 @@ bool P_LoadBuildMap (BYTE *data, size_t len, FMapThing **sprites, int *numspr) } // Check for a Blood map. - if (*(DWORD *)data == MAKE_ID('B','L','M','\x1a')) + if (*(uint32_t *)data == MAKE_ID('B','L','M','\x1a')) { return P_LoadBloodMap (data, len, sprites, numspr); } - const int numsec = LittleShort(*(WORD *)(data + 20)); + const int numsec = LittleShort(*(uint16_t *)(data + 20)); int numwalls; int numsprites; if (len < 26 + numsec*sizeof(sectortype) || - (numwalls = LittleShort(*(WORD *)(data + 22 + numsec*sizeof(sectortype))), + (numwalls = LittleShort(*(uint16_t *)(data + 22 + numsec*sizeof(sectortype))), len < 24 + numsec*sizeof(sectortype) + numwalls*sizeof(walltype)) || - LittleLong(*(DWORD *)data) != 7 || - LittleShort(*(WORD *)(data + 16)) >= 2048) + LittleLong(*(uint32_t *)data) != 7 || + LittleShort(*(uint16_t *)(data + 16)) >= 2048) { // Can't possibly be a version 7 BUILD map return false; } @@ -230,7 +230,7 @@ bool P_LoadBuildMap (BYTE *data, size_t len, FMapThing **sprites, int *numspr) LoadWalls ((walltype *)(data + 24 + numsec*sizeof(sectortype)), numwalls, (sectortype *)(data + 22)); - numsprites = *(WORD *)(data + 24 + numsec*sizeof(sectortype) + numwalls*sizeof(walltype)); + numsprites = *(uint16_t *)(data + 24 + numsec*sizeof(sectortype) + numwalls*sizeof(walltype)); *sprites = new FMapThing[numsprites + 1]; CreateStartSpot ((int32_t *)(data + 4), *sprites); *numspr = 1 + LoadSprites ((spritetype *)(data + 26 + numsec*sizeof(sectortype) + numwalls*sizeof(walltype)), @@ -245,11 +245,11 @@ bool P_LoadBuildMap (BYTE *data, size_t len, FMapThing **sprites, int *numspr) // //========================================================================== -static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int *numspr) +static bool P_LoadBloodMap (uint8_t *data, size_t len, FMapThing **mapthings, int *numspr) { - BYTE infoBlock[37]; + uint8_t infoBlock[37]; int mapver = data[5]; - DWORD matt; + uint32_t matt; int numRevisions, numWalls, numsprites, skyLen, visibility, parallaxType; int i; int k; @@ -259,7 +259,7 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int * return false; } - matt = *(DWORD *)(data + 28); + matt = *(uint32_t *)(data + 28); if (matt != 0 && matt != MAKE_ID('M','a','t','t') && matt != MAKE_ID('t','t','a','M')) @@ -270,13 +270,13 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **mapthings, int * { memcpy (infoBlock, data + 6, 37); } - skyLen = 2 << LittleShort(*(WORD *)(infoBlock + 16)); - visibility = LittleLong(*(DWORD *)(infoBlock + 18)); + skyLen = 2 << LittleShort(*(uint16_t *)(infoBlock + 16)); + visibility = LittleLong(*(uint32_t *)(infoBlock + 18)); parallaxType = infoBlock[26]; - numRevisions = LittleLong(*(DWORD *)(infoBlock + 27)); - int numsectors = LittleShort(*(WORD *)(infoBlock + 31)); - numWalls = LittleShort(*(WORD *)(infoBlock + 33)); - numsprites = LittleShort(*(WORD *)(infoBlock + 35)); + numRevisions = LittleLong(*(uint32_t *)(infoBlock + 27)); + int numsectors = LittleShort(*(uint16_t *)(infoBlock + 31)); + numWalls = LittleShort(*(uint16_t *)(infoBlock + 33)); + numsprites = LittleShort(*(uint16_t *)(infoBlock + 35)); Printf("Visibility: %d\n", visibility); if (mapver == 7) @@ -397,10 +397,10 @@ static void LoadSectors (sectortype *bsec, int count) for (int i = 0; i < count; ++i, ++bsec, ++sec) { - bsec->wallptr = WORD(bsec->wallptr); - bsec->wallnum = WORD(bsec->wallnum); - bsec->ceilingstat = WORD(bsec->ceilingstat); - bsec->floorstat = WORD(bsec->floorstat); + bsec->wallptr = uint16_t(bsec->wallptr); + bsec->wallnum = uint16_t(bsec->wallnum); + bsec->ceilingstat = uint16_t(bsec->ceilingstat); + bsec->floorstat = uint16_t(bsec->floorstat); sec->e = &sec->e[i]; double floorheight = -LittleLong(bsec->floorZ) / 256.; @@ -782,7 +782,7 @@ vertex_t *FindVertex (int32_t xx, int32_t yy) static void CreateStartSpot (int32_t *pos, FMapThing *start) { - short angle = LittleShort(*(WORD *)(&pos[3])); + short angle = LittleShort(*(uint16_t *)(&pos[3])); FMapThing mt = { 0, }; mt.pos.X = LittleLong(pos[0]) / 16.; @@ -844,8 +844,8 @@ static void CalcPlane (SlopeWork &slope, secplane_t &plane) static void Decrypt (void *to_, const void *from_, int len, int key) { - BYTE *to = (BYTE *)to_; - const BYTE *from = (const BYTE *)from_; + uint8_t *to = (uint8_t *)to_; + const uint8_t *from = (const uint8_t *)from_; for (int i = 0; i < len; ++i, ++key) { diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 0ac80171c..46475c04d 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -1108,7 +1108,7 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply // //============================================================================ -void P_ConversationCommand (int netcode, int pnum, BYTE **stream) +void P_ConversationCommand (int netcode, int pnum, uint8_t **stream) { player_t *player = &players[pnum]; diff --git a/src/p_conversation.h b/src/p_conversation.h index 7ee24093b..7cabc746c 100644 --- a/src/p_conversation.h +++ b/src/p_conversation.h @@ -75,7 +75,7 @@ void P_FreeStrifeConversations (); void P_StartConversation (AActor *npc, AActor *pc, bool facetalker, bool saveangle); void P_ResumeConversation (); -void P_ConversationCommand (int netcode, int player, BYTE **stream); +void P_ConversationCommand (int netcode, int player, uint8_t **stream); class FileReader; bool P_ParseUSDF(int lumpnum, FileReader *lump, int lumplen); diff --git a/src/p_effect.cpp b/src/p_effect.cpp index f6b54b34a..b2e5e99a0 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -66,11 +66,11 @@ FRandom pr_railtrail("RailTrail"); #define FADEFROMTTL(a) (1.f/(a)) // [RH] particle globals -WORD NumParticles; -WORD ActiveParticles; -WORD InactiveParticles; +uint16_t NumParticles; +uint16_t ActiveParticles; +uint16_t InactiveParticles; particle_t *Particles; -TArray ParticlesInSubsec; +TArray ParticlesInSubsec; static int grey1, grey2, grey3, grey4, red, green, blue, yellow, black, red1, green1, blue1, yellow1, purple, purple1, white, @@ -79,7 +79,7 @@ static int grey1, grey2, grey3, grey4, red, green, blue, yellow, black, static const struct ColorList { int *color; - BYTE r, g, b; + uint8_t r, g, b; } Colors[] = { {&grey1, 85, 85, 85 }, {&grey2, 171, 171, 171}, @@ -118,7 +118,7 @@ inline particle_t *NewParticle (void) result = Particles + InactiveParticles; InactiveParticles = result->tnext; result->tnext = ActiveParticles; - ActiveParticles = WORD(result - Particles); + ActiveParticles = uint16_t(result - Particles); } return result; } @@ -159,7 +159,7 @@ void P_InitParticles () num = r_maxparticles; // This should be good, but eh... - NumParticles = (WORD)clamp(num, 100, 65535); + NumParticles = (uint16_t)clamp(num, 100, 65535); P_DeinitParticles(); Particles = new particle_t[NumParticles]; @@ -205,7 +205,7 @@ void P_FindParticleSubsectors () { return; } - for (WORD i = ActiveParticles; i != NO_PARTICLE; i = Particles[i].tnext) + for (uint16_t i = ActiveParticles; i != NO_PARTICLE; i = Particles[i].tnext) { // Try to reuse the subsector from the last portal check, if still valid. if (Particles[i].subsector == NULL) Particles[i].subsector = R_PointInSubsector(Particles[i].Pos); diff --git a/src/p_effect.h b/src/p_effect.h index 6a9f5ccf9..c745a6d99 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -51,19 +51,19 @@ struct particle_t double sizestep; subsector_t * subsector; short ttl; - BYTE bright; + uint8_t bright; bool notimefreeze; float fadestep; float alpha; int color; - WORD tnext; - WORD snext; + uint16_t tnext; + uint16_t snext; }; extern particle_t *Particles; -extern TArray ParticlesInSubsec; +extern TArray ParticlesInSubsec; -const WORD NO_PARTICLE = 0xffff; +const uint16_t NO_PARTICLE = 0xffff; void P_ClearParticles (); void P_FindParticleSubsectors (); diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index d30cb812e..2da9a0457 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -74,7 +74,7 @@ void P_GetPolySpots (MapData * lump, TArray &spots, TA CVAR(Bool, gl_cachenodes, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CVAR(Float, gl_cachetime, 0.6f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) -void P_LoadZNodes (FileReader &dalump, DWORD id); +void P_LoadZNodes (FileReader &dalump, uint32_t id); static bool CheckCachedNodes(MapData *map); static void CreateCachedNodes(MapData *map); @@ -93,29 +93,29 @@ struct gl3_mapsubsector_t struct glseg_t { - WORD v1; // start vertex (16 bit) - WORD v2; // end vertex (16 bit) - WORD linedef; // linedef, or -1 for minisegs - WORD side; // side on linedef: 0 for right, 1 for left - WORD partner; // corresponding partner seg, or 0xffff on one-sided walls + uint16_t v1; // start vertex (16 bit) + uint16_t v2; // end vertex (16 bit) + uint16_t linedef; // linedef, or -1 for minisegs + uint16_t side; // side on linedef: 0 for right, 1 for left + uint16_t partner; // corresponding partner seg, or 0xffff on one-sided walls }; struct glseg3_t { int32_t v1; int32_t v2; - WORD linedef; - WORD side; + uint16_t linedef; + uint16_t side; int32_t partner; }; struct gl5_mapnode_t { - SWORD x,y,dx,dy; // partition line - SWORD bbox[2][4]; // bounding box for each child + int16_t x,y,dx,dy; // partition line + int16_t bbox[2][4]; // bounding box for each child // If NF_SUBSECTOR is or'ed in, it's a subsector, // else it's a node of another subtree. - DWORD children[2]; + uint32_t children[2]; }; @@ -181,7 +181,7 @@ bool P_CheckForGLNodes() } else { - for(DWORD j=0;jnumlines;j++) + for(uint32_t j=0;jnumlines;j++) { if (segs[j].linedef==NULL) // miniseg { @@ -221,14 +221,14 @@ static bool format5; static bool LoadGLVertexes(FileReader * lump) { - BYTE *gldata; + uint8_t *gldata; int i; firstglvertex = level.vertexes.Size(); int gllen=lump->GetLength(); - gldata = new BYTE[gllen]; + gldata = new uint8_t[gllen]; lump->Seek(0, SEEK_SET); lump->Read(gldata, gllen); @@ -377,7 +377,7 @@ static bool LoadGLSegs(FileReader * lump) segs[i].v1 = &level.vertexes[checkGLVertex3(LittleLong(ml->v1))]; segs[i].v2 = &level.vertexes[checkGLVertex3(LittleLong(ml->v2))]; - const DWORD partner = LittleLong(ml->partner); + const uint32_t partner = LittleLong(ml->partner); segs[i].PartnerSeg = DWORD_MAX == partner ? nullptr : &segs[partner]; if(ml->linedef != 0xffff) // skip minisegs @@ -533,7 +533,7 @@ static bool LoadNodes (FileReader * lump) int j; int k; node_t* no; - WORD* used; + uint16_t* used; if (!format5) { @@ -548,8 +548,8 @@ static bool LoadNodes (FileReader * lump) basemn = mn = new mapnode_t[numnodes]; lump->Read(mn, lump->GetLength()); - used = (WORD *)alloca (sizeof(WORD)*numnodes); - memset (used, 0, sizeof(WORD)*numnodes); + used = (uint16_t *)alloca (sizeof(uint16_t)*numnodes); + memset (used, 0, sizeof(uint16_t)*numnodes); no = nodes; @@ -561,7 +561,7 @@ static bool LoadNodes (FileReader * lump) no->dy = LittleShort(mn->dy)<children[j]); + uint16_t child = LittleShort(mn->children[j]); if (child & NF_SUBSECTOR) { child &= ~NF_SUBSECTOR; @@ -570,7 +570,7 @@ static bool LoadNodes (FileReader * lump) delete [] basemn; return false; } - no->children[j] = (BYTE *)&subsectors[child] + 1; + no->children[j] = (uint8_t *)&subsectors[child] + 1; } else if (child >= numnodes) { @@ -608,8 +608,8 @@ static bool LoadNodes (FileReader * lump) basemn = mn = new gl5_mapnode_t[numnodes]; lump->Read(mn, lump->GetLength()); - used = (WORD *)alloca (sizeof(WORD)*numnodes); - memset (used, 0, sizeof(WORD)*numnodes); + used = (uint16_t *)alloca (sizeof(uint16_t)*numnodes); + memset (used, 0, sizeof(uint16_t)*numnodes); no = nodes; @@ -630,7 +630,7 @@ static bool LoadNodes (FileReader * lump) delete [] basemn; return false; } - no->children[j] = (BYTE *)&subsectors[child] + 1; + no->children[j] = (uint8_t *)&subsectors[child] + 1; } else if (child >= numnodes) { @@ -808,7 +808,7 @@ static int FindGLNodesInFile(FResourceFile * f, const char * label) FString glheader; bool mustcheck=false; - DWORD numentries = f->LumpCount(); + uint32_t numentries = f->LumpCount(); glheader.Format("GL_%.8s", label); if (glheader.Len()>8) @@ -819,7 +819,7 @@ static int FindGLNodesInFile(FResourceFile * f, const char * label) if (numentries > 4) { - for(DWORD i=0;iGetLump(i)->Name, glheader, 8)) { @@ -1051,7 +1051,7 @@ bool P_CheckNodes(MapData * map, bool rebuilt, int buildtime) // //========================================================================== -typedef TArray MemFile; +typedef TArray MemFile; static FString CreateCacheName(MapData *map, bool create) @@ -1067,25 +1067,25 @@ static FString CreateCacheName(MapData *map, bool create) return path; } -static void WriteByte(MemFile &f, BYTE b) +static void WriteByte(MemFile &f, uint8_t b) { f.Push(b); } -static void WriteWord(MemFile &f, WORD b) +static void WriteWord(MemFile &f, uint16_t b) { int v = f.Reserve(2); - f[v] = (BYTE)b; - f[v+1] = (BYTE)(b>>8); + f[v] = (uint8_t)b; + f[v+1] = (uint8_t)(b>>8); } -static void WriteLong(MemFile &f, DWORD b) +static void WriteLong(MemFile &f, uint32_t b) { int v = f.Reserve(4); - f[v] = (BYTE)b; - f[v+1] = (BYTE)(b>>8); - f[v+2] = (BYTE)(b>>16); - f[v+3] = (BYTE)(b>>24); + f[v] = (uint8_t)b; + f[v+1] = (uint8_t)(b>>8); + f[v+2] = (uint8_t)(b>>16); + f[v+3] = (uint8_t)(b>>24); } static void CreateCachedNodes(MapData *map) @@ -1110,10 +1110,10 @@ static void CreateCachedNodes(MapData *map) for(int i=0;iIndex()); - WriteLong(ZNodes, segs[i].PartnerSeg == nullptr? 0xffffffffu : DWORD(segs[i].PartnerSeg - segs)); + WriteLong(ZNodes, segs[i].PartnerSeg == nullptr? 0xffffffffu : uint32_t(segs[i].PartnerSeg - segs)); if (segs[i].linedef) { - WriteLong(ZNodes, DWORD(segs[i].linedef->Index())); + WriteLong(ZNodes, uint32_t(segs[i].linedef->Index())); WriteByte(ZNodes, segs[i].sidedef == segs[i].linedef->sidedef[0]? 0:1); } else @@ -1140,21 +1140,21 @@ static void CreateCachedNodes(MapData *map) for (int j = 0; j < 2; ++j) { - DWORD child; + uint32_t child; if ((size_t)nodes[i].children[j] & 1) { - child = 0x80000000 | DWORD((subsector_t *)((BYTE *)nodes[i].children[j] - 1) - subsectors); + child = 0x80000000 | uint32_t((subsector_t *)((uint8_t *)nodes[i].children[j] - 1) - subsectors); } else { - child = DWORD((node_t *)nodes[i].children[j] - nodes); + child = uint32_t((node_t *)nodes[i].children[j] - nodes); } WriteLong(ZNodes, child); } } uLongf outlen = ZNodes.Size(); - BYTE *compressed; + uint8_t *compressed; int offset = level.lines.Size() * 8 + 12 + 16; int r; do @@ -1170,12 +1170,12 @@ static void CreateCachedNodes(MapData *map) while (r == Z_BUF_ERROR); memcpy(compressed, "CACH", 4); - DWORD len = LittleLong(level.lines.Size()); + uint32_t len = LittleLong(level.lines.Size()); memcpy(compressed+4, &len, 4); map->GetChecksum(compressed+8); for (unsigned i = 0; i < level.lines.Size(); i++) { - DWORD ndx[2] = { LittleLong(DWORD(level.lines[i].v1->Index())), LittleLong(DWORD(level.lines[i].v2->Index())) }; + uint32_t ndx[2] = { LittleLong(uint32_t(level.lines[i].v1->Index())), LittleLong(uint32_t(level.lines[i].v2->Index())) }; memcpy(compressed + 8 + 16 + 8 * i, ndx, 8); } memcpy(compressed + offset - 4, "ZGL3", 4); @@ -1204,10 +1204,10 @@ static void CreateCachedNodes(MapData *map) static bool CheckCachedNodes(MapData *map) { char magic[4] = {0,0,0,0}; - BYTE md5[16]; - BYTE md5map[16]; - DWORD numlin; - DWORD *verts = NULL; + uint8_t md5[16]; + uint8_t md5map[16]; + uint32_t numlin; + uint32_t *verts = NULL; FString path = CreateCacheName(map, false); FILE *f = fopen(path, "rb"); @@ -1224,7 +1224,7 @@ static bool CheckCachedNodes(MapData *map) map->GetChecksum(md5map); if (memcmp(md5, md5map, 16)) goto errorout; - verts = new DWORD[numlin * 8]; + verts = new uint32_t[numlin * 8]; if (fread(verts, 8, numlin, f) != numlin) goto errorout; if (fread(magic, 1, 4, f) != 4) goto errorout; @@ -1353,7 +1353,7 @@ subsector_t *P_PointInSubsector (double x, double y) } while (!((size_t)node & 1)); - return (subsector_t *)((BYTE *)node - 1); + return (subsector_t *)((uint8_t *)node - 1); } //========================================================================== @@ -1406,7 +1406,7 @@ static bool PointOnLine (int x, int y, int x1, int y1, int dx, int dy) void P_SetRenderSector() { int i; - DWORD j; + uint32_t j; TArray undetermined; subsector_t * ss; diff --git a/src/p_lights.cpp b/src/p_lights.cpp index 5442809e4..d680bfc46 100644 --- a/src/p_lights.cpp +++ b/src/p_lights.cpp @@ -155,8 +155,8 @@ public: void Serialize(FSerializer &arc); void Tick(); protected: - BYTE m_BaseLevel; - BYTE m_Phase; + uint8_t m_BaseLevel; + uint8_t m_Phase; private: DPhased(); DPhased(sector_t *sector, int baselevel); diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index ff72b3baa..9f585dc3d 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -73,7 +73,7 @@ 5 : Copy texture and type; trigger model. ( = 2) 6 : Copy texture and type; numeric model. ( = 2+4) */ -static const BYTE ChangeMap[8] = { 0, 1, 5, 3, 7, 2, 6, 0 }; +static const uint8_t ChangeMap[8] = { 0, 1, 5, 3, 7, 2, 6, 0 }; int LS_Sector_SetPlaneReflection(line_t *ln, AActor *it, bool backSide, int arg0, int arg1, int arg2, int arg3, int arg4); int LS_SetGlobalFogParameter(line_t *ln, AActor *it, bool backSide, int arg0, int arg1, int arg2, int arg3, int arg4); @@ -106,7 +106,7 @@ static FRandom pr_glass ("GlassBreak"); // There are aliases for the ACS specials that take names instead of numbers. // This table maps them onto the real number-based specials. -BYTE NamedACSToNormalACS[7] = +uint8_t NamedACSToNormalACS[7] = { ACS_Execute, ACS_Suspend, diff --git a/src/p_lnspec.h b/src/p_lnspec.h index 64b8500f7..afb42bf9f 100644 --- a/src/p_lnspec.h +++ b/src/p_lnspec.h @@ -47,9 +47,9 @@ struct FLineSpecial { const char *name; int number; - SBYTE min_args; - SBYTE max_args; - BYTE map_args; + int8_t min_args; + int8_t max_args; + uint8_t map_args; }; @@ -196,7 +196,7 @@ typedef int (*lnSpecFunc)(struct line_t *line, int arg4, int arg5); -extern BYTE NamedACSToNormalACS[7]; +extern uint8_t NamedACSToNormalACS[7]; static inline bool P_IsACSSpecial(int specnum) { return (specnum >= ACS_Execute && specnum <= ACS_LockedExecuteDoor) || diff --git a/src/p_local.h b/src/p_local.h index 9ce290be7..098c9c4ff 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -407,7 +407,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move); // // P_SETUP // -extern BYTE* rejectmatrix; // for fast sight rejection +extern uint8_t* rejectmatrix; // for fast sight rejection diff --git a/src/p_map.cpp b/src/p_map.cpp index 4d47b89c1..73cda449c 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4695,7 +4695,7 @@ DEFINE_ACTION_FUNCTION(AActor, LineAttack) // //========================================================================== -AActor *P_LinePickActor(AActor *t1, DAngle angle, double distance, DAngle pitch, ActorFlags actorMask, DWORD wallMask) +AActor *P_LinePickActor(AActor *t1, DAngle angle, double distance, DAngle pitch, ActorFlags actorMask, uint32_t wallMask) { DVector3 direction; double shootz; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 5771461bb..ec8ae181b 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -2057,6 +2057,6 @@ sector_t *P_PointInSectorBuggy(double x, double y) node = (node_t *)node->children[R_PointOnSideSlow(x, y, node)]; } while (!((size_t)node & 1)); - subsector_t *ssec = (subsector_t *)((BYTE *)node - 1); + subsector_t *ssec = (subsector_t *)((uint8_t *)node - 1); return ssec->sector; } diff --git a/src/p_maputl.h b/src/p_maputl.h index 5e869c4e6..99a9acc33 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -175,10 +175,10 @@ struct FPortalGroupArray inited = false; } - void Add(DWORD num) + void Add(uint32_t num) { - if (varused < MAX_STATIC) entry[varused++] = (WORD)num; - else data.Push((WORD)num); + if (varused < MAX_STATIC) entry[varused++] = (uint16_t)num; + else data.Push((uint16_t)num); } unsigned Size() @@ -186,7 +186,7 @@ struct FPortalGroupArray return varused + data.Size(); } - DWORD operator[](unsigned index) + uint32_t operator[](unsigned index) { return index < MAX_STATIC ? entry[index] : data[index - MAX_STATIC]; } @@ -195,9 +195,9 @@ struct FPortalGroupArray int method; private: - WORD entry[MAX_STATIC]; - BYTE varused; - TArray data; + uint16_t entry[MAX_STATIC]; + uint8_t varused; + TArray data; }; class FBlockLinesIterator diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index d7de2a18c..bfb3e3eec 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -535,12 +535,12 @@ AActor::AActor () throw() AActor::AActor (const AActor &other) throw() : DThinker() { - memcpy (&snext, &other.snext, (BYTE *)&this[1] - (BYTE *)&snext); + memcpy (&snext, &other.snext, (uint8_t *)&this[1] - (uint8_t *)&snext); } AActor &AActor::operator= (const AActor &other) { - memcpy (&snext, &other.snext, (BYTE *)&this[1] - (BYTE *)&snext); + memcpy (&snext, &other.snext, (uint8_t *)&this[1] - (uint8_t *)&snext); return *this; } @@ -3739,7 +3739,7 @@ bool AActor::IsOkayToAttack (AActor *link) return false; } -void AActor::SetShade (DWORD rgb) +void AActor::SetShade (uint32_t rgb) { PalEntry *entry = (PalEntry *)&rgb; fillcolor = rgb | (ColorMatcher.Pick (entry->r, entry->g, entry->b) << 24); @@ -3904,8 +3904,8 @@ void AActor::CheckPortalTransition(bool islinked) void AActor::Tick () { // [RH] Data for Heretic/Hexen scrolling sectors - static const SBYTE HexenCompatSpeeds[] = {-25, 0, -10, -5, 0, 5, 10, 0, 25 }; - static const SBYTE HexenScrollies[24][2] = + static const int8_t HexenCompatSpeeds[] = {-25, 0, -10, -5, 0, 5, 10, 0, 25 }; + static const int8_t HexenScrollies[24][2] = { { 0, 1 }, { 0, 2 }, { 0, 4 }, { -1, 0 }, { -2, 0 }, { -4, 0 }, @@ -3917,8 +3917,8 @@ void AActor::Tick () { 1, -1 }, { 2, -2 }, { 4, -4 } }; - static const BYTE HereticScrollDirs[4] = { 6, 9, 1, 4 }; - static const BYTE HereticSpeedMuls[5] = { 5, 10, 25, 30, 35 }; + static const uint8_t HereticScrollDirs[4] = { 6, 9, 1, 4 }; + static const uint8_t HereticSpeedMuls[5] = { 5, 10, 25, 30, 35 }; AActor *onmo; @@ -4172,7 +4172,7 @@ void AActor::Tick () scrolltype <= Carry_West35) { // Heretic scroll special scrolltype -= Carry_East5; - BYTE dir = HereticScrollDirs[scrolltype / 5]; + uint8_t dir = HereticScrollDirs[scrolltype / 5]; double carryspeed = HereticSpeedMuls[scrolltype % 5] * (1. / (32 * CARRYFACTOR)); if (scrolltype < 5 && !(i_compatflags&COMPATF_RAVENSCROLL)) { @@ -4909,7 +4909,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t a actor->SpawnPoint.Z = (actor->Z() - actor->Sector->floorplane.ZatPoint(actor)); } - if (actor->FloatBobPhase == (BYTE)-1) actor->FloatBobPhase = rng(); // Don't make everything bob in sync (unless deliberately told to do) + if (actor->FloatBobPhase == (uint8_t)-1) actor->FloatBobPhase = rng(); // Don't make everything bob in sync (unless deliberately told to do) if (actor->flags2 & MF2_FLOORCLIP) { actor->AdjustFloorClip (); @@ -5316,7 +5316,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) { player_t *p; APlayerPawn *mobj, *oldactor; - BYTE state; + uint8_t state; DVector3 spawn; DAngle SpawnAngle; diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 8f06b7809..210ded45d 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -331,7 +331,7 @@ void RecalculateDrawnSubsectors() FSerializer &Serialize(FSerializer &arc, const char *key, subsector_t *&ss, subsector_t **) { - BYTE by; + uint8_t by; const char *str; if (arc.isWriting()) @@ -526,7 +526,7 @@ void P_SerializeSounds(FSerializer &arc) S_SerializeSounds(arc); DSeqNode::SerializeSequences (arc); const char *name = NULL; - BYTE order; + uint8_t order; if (arc.isWriting()) { @@ -691,8 +691,8 @@ static void ReadMultiplePlayers(FSerializer &arc, int numPlayers, int numPlayers int i, j; const char **nametemp = new const char *[numPlayers]; player_t *playertemp = new player_t[numPlayers]; - BYTE *tempPlayerUsed = new BYTE[numPlayers]; - BYTE playerUsed[MAXPLAYERS]; + uint8_t *tempPlayerUsed = new uint8_t[numPlayers]; + uint8_t playerUsed[MAXPLAYERS]; for (i = 0; i < numPlayers; ++i) { @@ -908,7 +908,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload) // prevent bad things from happening by doing a check on the size of level arrays and the map's entire checksum. // The old code happily tried to load savegames with any mismatch here, often causing meaningless errors // deep down in the deserializer or just a crash if the few insufficient safeguards were not triggered. - BYTE chk[16] = { 0 }; + uint8_t chk[16] = { 0 }; arc.Array("checksum", chk, 16); if (arc.GetSize("linedefs") != level.lines.Size() || arc.GetSize("sidedefs") != level.sides.Size() || diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 76e8b6b34..edab7add7 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -113,7 +113,7 @@ inline bool P_IsBuildMap(MapData *map) return false; } -inline bool P_LoadBuildMap(BYTE *mapdata, size_t len, FMapThing **things, int *numthings) +inline bool P_LoadBuildMap(uint8_t *mapdata, size_t len, FMapThing **things, int *numthings) { return false; } @@ -180,7 +180,7 @@ FBlockNode** blocklinks; // for thing chains // Without special effect, this could be // used as a PVS lookup as well. // -BYTE* rejectmatrix; +uint8_t* rejectmatrix; bool ForceNodeBuild; @@ -414,7 +414,7 @@ MapData *P_OpenMapData(const char * mapname, bool justcheck) wadReader = map->resource->GetReader(); } } - DWORD id; + uint32_t id; // Although we're using the resource system, we still want to be sure we're // reading from a wad file. @@ -429,7 +429,7 @@ MapData *P_OpenMapData(const char * mapname, bool justcheck) map->MapLumps[0].Reader = map->resource->GetLump(0)->NewReader(); strncpy(map->MapLumps[0].Name, map->resource->GetLump(0)->Name, 8); - for(DWORD i = 1; i < map->resource->LumpCount(); i++) + for(uint32_t i = 1; i < map->resource->LumpCount(); i++) { const char* lumpname = map->resource->GetLump(i)->Name; @@ -534,7 +534,7 @@ bool P_CheckMapData(const char *mapname) // //=========================================================================== -void MapData::GetChecksum(BYTE cksum[16]) +void MapData::GetChecksum(uint8_t cksum[16]) { MD5Context md5; @@ -674,7 +674,7 @@ static void SummarizeMissingTextures(const FMissingTextureTracker &missing) // //=========================================================================== -static void SetTexture (side_t *side, int position, DWORD *blend, const char *name) +static void SetTexture (side_t *side, int position, uint32_t *blend, const char *name) { FTextureID texture; if ((*blend = R_ColormapNumForName (name)) == 0) @@ -702,7 +702,7 @@ static void SetTexture (side_t *side, int position, DWORD *blend, const char *na side->SetTexture(position, texture); } -static void SetTextureNoErr (side_t *side, int position, DWORD *color, const char *name, bool *validcolor, bool isFog) +static void SetTextureNoErr (side_t *side, int position, uint32_t *color, const char *name, bool *validcolor, bool isFog) { FTextureID texture; *validcolor = false; @@ -866,9 +866,9 @@ void P_LoadZSegs (FileReaderBase &data) for (int i = 0; i < numsegs; ++i) { line_t *ldef; - DWORD v1, v2; - WORD line; - BYTE side; + uint32_t v1, v2; + uint16_t line; + uint8_t side; data >> v1 >> v2 >> line >> side; @@ -904,10 +904,10 @@ void P_LoadGLZSegs (FileReaderBase &data, int type) for (size_t j = 0; j < subsectors[i].numlines; ++j) { seg_t *seg; - DWORD v1, partner; - DWORD line; - WORD lineword; - BYTE side; + uint32_t v1, partner; + uint32_t line; + uint16_t lineword; + uint8_t side; data >> v1 >> partner; if (type >= 2) @@ -969,7 +969,7 @@ void P_LoadGLZSegs (FileReaderBase &data, int type) void LoadZNodes(FileReaderBase &data, int glnodes) { // Read extra vertices added during node building - DWORD orgVerts, newVerts; + uint32_t orgVerts, newVerts; TStaticArray newvertarray; unsigned int i; @@ -1009,7 +1009,7 @@ void LoadZNodes(FileReaderBase &data, int glnodes) level.vertexes = std::move(newvertarray); // Read the subsectors - DWORD numSubs, currSeg; + uint32_t numSubs, currSeg; data >> numSubs; numsubsectors = numSubs; @@ -1018,7 +1018,7 @@ void LoadZNodes(FileReaderBase &data, int glnodes) for (i = currSeg = 0; i < numSubs; ++i) { - DWORD numsegs; + uint32_t numsegs; data >> numsegs; subsectors[i].firstline = (seg_t *)(size_t)currSeg; // Oh damn. I should have stored the seg count sooner. @@ -1027,7 +1027,7 @@ void LoadZNodes(FileReaderBase &data, int glnodes) } // Read the segs - DWORD numSegs; + uint32_t numSegs; data >> numSegs; @@ -1057,7 +1057,7 @@ void LoadZNodes(FileReaderBase &data, int glnodes) } // Read nodes - DWORD numNodes; + uint32_t numNodes; data >> numNodes; numnodes = numNodes; @@ -1068,7 +1068,7 @@ void LoadZNodes(FileReaderBase &data, int glnodes) { if (glnodes < 3) { - SWORD x, y, dx, dy; + int16_t x, y, dx, dy; data >> x >> y >> dx >> dy; nodes[i].x = x << FRACBITS; @@ -1084,18 +1084,18 @@ void LoadZNodes(FileReaderBase &data, int glnodes) { for (int k = 0; k < 4; ++k) { - SWORD coord; + int16_t coord; data >> coord; nodes[i].bbox[j][k] = coord; } } for (int m = 0; m < 2; ++m) { - DWORD child; + uint32_t child; data >> child; if (child & 0x80000000) { - nodes[i].children[m] = (BYTE *)&subsectors[child & 0x7FFFFFFF] + 1; + nodes[i].children[m] = (uint8_t *)&subsectors[child & 0x7FFFFFFF] + 1; } else { @@ -1106,7 +1106,7 @@ void LoadZNodes(FileReaderBase &data, int glnodes) } -void P_LoadZNodes (FileReader &dalump, DWORD id) +void P_LoadZNodes (FileReader &dalump, uint32_t id) { int type; bool compressed; @@ -1206,10 +1206,10 @@ template void P_LoadSegs (MapData * map) { int i; - BYTE *data; + uint8_t *data; int numvertexes = level.vertexes.Size(); - BYTE *vertchanged = new BYTE[numvertexes]; // phares 10/4/98 - DWORD segangle; + uint8_t *vertchanged = new uint8_t[numvertexes]; // phares 10/4/98 + uint32_t segangle; //int ptp_angle; // phares 10/4/98 //int delta_angle; // phares 10/4/98 int vnum1,vnum2; // phares 10/4/98 @@ -1232,7 +1232,7 @@ void P_LoadSegs (MapData * map) segs = new seg_t[numsegs]; memset (segs, 0, numsegs*sizeof(seg_t)); - data = new BYTE[lumplen]; + data = new uint8_t[lumplen]; map->Read(ML_SEGS, data); for (i = 0; i < numsubsectors; ++i) @@ -1270,7 +1270,7 @@ void P_LoadSegs (MapData * map) li->v1 = &level.vertexes[vnum1]; li->v2 = &level.vertexes[vnum2]; - segangle = (WORD)LittleShort(ml->angle); + segangle = (uint16_t)LittleShort(ml->angle); // phares 10/4/98: In the case of a lineseg that was created by splitting // another line, it appears that the line angle is inherited from the @@ -1387,7 +1387,7 @@ template void P_LoadSubsectors (MapData * map) { int i; - DWORD maxseg = map->Size(ML_SEGS) / sizeof(segtype); + uint32_t maxseg = map->Size(ML_SEGS) / sizeof(segtype); numsubsectors = map->Size(ML_SSECTORS) / sizeof(subsectortype); @@ -1561,7 +1561,7 @@ void P_LoadNodes (MapData * map) char *mnp; nodetype *mn; node_t* no; - WORD* used; + uint16_t* used; int lumplen = map->Size(ML_NODES); int maxss = map->Size(ML_SSECTORS) / sizeof(subsectortype); @@ -1574,8 +1574,8 @@ void P_LoadNodes (MapData * map) } nodes = new node_t[numnodes]; - used = (WORD *)alloca (sizeof(WORD)*numnodes); - memset (used, 0, sizeof(WORD)*numnodes); + used = (uint16_t *)alloca (sizeof(uint16_t)*numnodes); + memset (used, 0, sizeof(uint16_t)*numnodes); mnp = new char[lumplen]; mn = (nodetype*)(mnp + nodetype::NF_LUMPOFFSET); @@ -1603,7 +1603,7 @@ void P_LoadNodes (MapData * map) delete[] mnp; return; } - no->children[j] = (BYTE *)&subsectors[child] + 1; + no->children[j] = (uint8_t *)&subsectors[child] + 1; } else if (child >= numnodes) { @@ -1685,7 +1685,7 @@ static void SetMapThingUserData(AActor *actor, unsigned udi) } else { // Set the value of the specified user variable. - var->Type->SetValue(reinterpret_cast(actor) + var->Offset, value); + var->Type->SetValue(reinterpret_cast(actor) + var->Offset, value); } } } @@ -1696,9 +1696,9 @@ static void SetMapThingUserData(AActor *actor, unsigned udi) // //=========================================================================== -WORD MakeSkill(int flags) +uint16_t MakeSkill(int flags) { - WORD res = 0; + uint16_t res = 0; if (flags & 1) res |= 1+2; if (flags & 2) res |= 4; if (flags & 4) res |= 8+16; @@ -1973,7 +1973,7 @@ void P_SaveLineSpecial (line_t *ld) if (ld->sidedef[0] == NULL) return; - DWORD sidenum = ld->sidedef[0]->Index(); + uint32_t sidenum = ld->sidedef[0]->Index(); // killough 4/4/98: support special sidedef interpretation below // [RH] Save Static_Init only if it's interested in the textures if (ld->special != Static_Init || ld->args[1] == Init_Color) @@ -2068,7 +2068,7 @@ void P_FinishLoadingLineDefs () } } -static void P_SetSideNum (side_t **sidenum_p, WORD sidenum) +static void P_SetSideNum (side_t **sidenum_p, uint16_t sidenum) { if (sidenum == NO_INDEX) { @@ -2356,7 +2356,7 @@ static void P_LoopSidedefs (bool firstloop) // one that forms the smallest angle is assumed to be the right one. for (i = 0; i < numsides; ++i) { - DWORD right; + uint32_t right; line_t *line = level.sides[i].linedef; // If the side's line only exists in a single sector, @@ -2449,7 +2449,7 @@ static void P_LoopSidedefs (bool firstloop) int P_DetermineTranslucency (int lumpnum) { FWadLump tranmap = Wads.OpenLumpNum (lumpnum); - BYTE index; + uint8_t index; PalEntry newcolor; PalEntry newcolor2; @@ -2508,7 +2508,7 @@ void P_ProcessSideTextures(bool checktranmap, side_t *sd, sector_t *sec, intmaps // upper "texture" is light color // lower "texture" is fog color { - DWORD color = MAKERGB(255,255,255), fog = 0; + uint32_t color = MAKERGB(255,255,255), fog = 0; bool colorgood, foggood; SetTextureNoErr (sd, side_t::bottom, &fog, msd->bottomtexture, &foggood, true); @@ -3026,7 +3026,7 @@ void P_LoadBlockMap (MapData * map) } else { - BYTE *data = new BYTE[count]; + uint8_t *data = new uint8_t[count]; map->Read(ML_BLOCKMAP, data); const short *wadblockmaplump = (short *)data; int i; @@ -3041,13 +3041,13 @@ void P_LoadBlockMap (MapData * map) blockmaplump[0] = LittleShort(wadblockmaplump[0]); blockmaplump[1] = LittleShort(wadblockmaplump[1]); - blockmaplump[2] = (DWORD)(LittleShort(wadblockmaplump[2])) & 0xffff; - blockmaplump[3] = (DWORD)(LittleShort(wadblockmaplump[3])) & 0xffff; + blockmaplump[2] = (uint32_t)(LittleShort(wadblockmaplump[2])) & 0xffff; + blockmaplump[3] = (uint32_t)(LittleShort(wadblockmaplump[3])) & 0xffff; for (i = 4; i < count; i++) { short t = LittleShort(wadblockmaplump[i]); // killough 3/1/98 - blockmaplump[i] = t == -1 ? (DWORD)0xffffffff : (DWORD) t & 0xffff; + blockmaplump[i] = t == -1 ? (uint32_t)0xffffffff : (uint32_t) t & 0xffff; } delete[] data; @@ -3266,7 +3266,7 @@ void P_LoadReject (MapData * map, bool junk) { // Check if the reject has some actual content. If not, free it. rejectsize = MIN (rejectsize, neededsize); - rejectmatrix = new BYTE[rejectsize]; + rejectmatrix = new uint8_t[rejectsize]; map->Seek(ML_REJECT); map->file->Read (rejectmatrix, rejectsize); @@ -3354,14 +3354,14 @@ void P_GetPolySpots (MapData * map, TArray &spots, TAr static void P_PrecacheLevel() { int i; - BYTE *hitlist; + uint8_t *hitlist; TMap actorhitlist; int cnt = TexMan.NumTextures(); if (demoplayback) return; - hitlist = new BYTE[cnt]; + hitlist = new uint8_t[cnt]; memset(hitlist, 0, cnt); AActor *actor; @@ -3654,7 +3654,7 @@ void P_SetupLevel (const char *lumpname, int position) buildmap = false; if (map->Size(0) > 0) { - BYTE *mapdata = new BYTE[map->Size(0)]; + uint8_t *mapdata = new uint8_t[map->Size(0)]; map->Seek(0); map->file->Read(mapdata, map->Size(0)); times[0].Clock(); @@ -3802,7 +3802,7 @@ void P_SetupLevel (const char *lumpname, int position) { // Check for compressed nodes first, then uncompressed nodes FWadLump test; - DWORD id = MAKE_ID('X','x','X','x'), idcheck = 0, idcheck2 = 0, idcheck3 = 0, idcheck4 = 0, idcheck5 = 0, idcheck6 = 0; + uint32_t id = MAKE_ID('X','x','X','x'), idcheck = 0, idcheck2 = 0, idcheck3 = 0, idcheck4 = 0, idcheck5 = 0, idcheck6 = 0; if (map->Size(ML_ZNODES) != 0) { diff --git a/src/p_setup.h b/src/p_setup.h index 13bfad72e..1b6c1d515 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -82,7 +82,7 @@ struct MapData } } - DWORD Size(unsigned int lumpindex) + uint32_t Size(unsigned int lumpindex) { if (lumpindexspecial != Teleport_Line && @@ -749,17 +749,17 @@ class DWallLightTransfer : public DThinker DECLARE_CLASS (DWallLightTransfer, DThinker) DWallLightTransfer() {} public: - DWallLightTransfer (sector_t *srcSec, int target, BYTE flags); + DWallLightTransfer (sector_t *srcSec, int target, uint8_t flags); void Serialize(FSerializer &arc); void Tick (); protected: - static void DoTransfer (short level, int target, BYTE flags); + static void DoTransfer (short level, int target, uint8_t flags); sector_t *Source; int TargetID; short LastLight; - BYTE Flags; + uint8_t Flags; }; IMPLEMENT_CLASS(DWallLightTransfer, false, false) @@ -773,7 +773,7 @@ void DWallLightTransfer::Serialize(FSerializer &arc) ("flags", Flags); } -DWallLightTransfer::DWallLightTransfer (sector_t *srcSec, int target, BYTE flags) +DWallLightTransfer::DWallLightTransfer (sector_t *srcSec, int target, uint8_t flags) { int linenum; int wallflags; @@ -819,7 +819,7 @@ void DWallLightTransfer::Tick () } } -void DWallLightTransfer::DoTransfer (short lightlevel, int target, BYTE flags) +void DWallLightTransfer::DoTransfer (short lightlevel, int target, uint8_t flags) { int linenum; @@ -1204,7 +1204,7 @@ void P_InitSectorSpecial(sector_t *sector, int special) if (sector->special >= Scroll_North_Slow && sector->special <= Scroll_SouthWest_Fast) { // Hexen scroll special - static const SBYTE hexenScrollies[24][2] = + static const int8_t hexenScrollies[24][2] = { { 0, 1 }, { 0, 2 }, { 0, 4 }, { -1, 0 }, { -2, 0 }, { -4, 0 }, diff --git a/src/p_spec.h b/src/p_spec.h index 2dad6fb09..8d6e53a23 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -150,7 +150,7 @@ void EV_StartLightFading (int tag, int value, int tics); #define BUTTONTIME TICRATE // 1 second, in ticks. -bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *quest=NULL); +bool P_ChangeSwitchTexture (side_t *side, int useAgain, uint8_t special, bool *quest=NULL); bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *optpos = NULL); // diff --git a/src/p_states.cpp b/src/p_states.cpp index d6f43aabe..762a76896 100644 --- a/src/p_states.cpp +++ b/src/p_states.cpp @@ -439,7 +439,7 @@ FStateDefine *FStateDefinitions::FindStateAddress(const char *name) // //========================================================================== -void FStateDefinitions::SetStateLabel(const char *statename, FState *state, BYTE defflags) +void FStateDefinitions::SetStateLabel(const char *statename, FState *state, uint8_t defflags) { FStateDefine *std = FindStateAddress(statename); std->State = state; diff --git a/src/p_switch.cpp b/src/p_switch.cpp index 3e956f691..ef700b05b 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -65,12 +65,12 @@ public: void Tick (); side_t *m_Side; - SBYTE m_Part; + int8_t m_Part; bool bFlippable; bool bReturning; FSwitchDef *m_SwitchDef; int32_t m_Frame; - DWORD m_Timer; + uint32_t m_Timer; DVector2 m_Pos; protected: @@ -245,7 +245,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 * // //========================================================================== -bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *quest) +bool P_ChangeSwitchTexture (side_t *side, int useAgain, uint8_t special, bool *quest) { int texture; int sound; @@ -338,7 +338,7 @@ DActiveButton::DActiveButton (side_t *side, int Where, FSwitchDef *Switch, const DVector2 &pos, bool useagain) { m_Side = side; - m_Part = SBYTE(Where); + m_Part = int8_t(Where); m_Pos = pos; bFlippable = useagain; bReturning = false; diff --git a/src/p_terrain.cpp b/src/p_terrain.cpp index 3adc94876..bacd81da3 100644 --- a/src/p_terrain.cpp +++ b/src/p_terrain.cpp @@ -49,7 +49,7 @@ // MACROS ------------------------------------------------------------------ -#define SET_FIELD(type,val) *((type*)((BYTE *)fields + \ +#define SET_FIELD(type,val) *((type*)((uint8_t *)fields + \ parser[keyword].u.Offset)) = val; // TYPES ------------------------------------------------------------------- @@ -134,7 +134,7 @@ static void ParseDefault (FScanner &sc); FTerrainTypeArray TerrainTypes; TArray Splashes; TArray Terrains; -WORD DefaultTerrainType; +uint16_t DefaultTerrainType; // PRIVATE DATA DEFINITIONS ------------------------------------------------ @@ -546,7 +546,7 @@ static void GenericParse (FScanner &sc, FGenericParse *parser, const char **keyw case GEN_Byte: sc.MustGetNumber (); - SET_FIELD (BYTE, sc.Number); + SET_FIELD (uint8_t, sc.Number); break; case GEN_Class: diff --git a/src/p_terrain.h b/src/p_terrain.h index 694aa9f14..5bf6342e8 100644 --- a/src/p_terrain.h +++ b/src/p_terrain.h @@ -39,24 +39,24 @@ class PClass; -extern WORD DefaultTerrainType; +extern uint16_t DefaultTerrainType; class FTerrainTypeArray { public: - TArray Types; + TArray Types; - WORD operator [](FTextureID tex) const + uint16_t operator [](FTextureID tex) const { if ((unsigned)tex.GetIndex() >= Types.Size()) return DefaultTerrainType; - WORD type = Types[tex.GetIndex()]; + uint16_t type = Types[tex.GetIndex()]; return type == 0xffff? DefaultTerrainType : type; } - WORD operator [](int texnum) const + uint16_t operator [](int texnum) const { if ((unsigned)texnum >= Types.Size()) return DefaultTerrainType; - WORD type = Types[texnum]; + uint16_t type = Types[texnum]; return type == 0xffff? DefaultTerrainType : type; } void Resize(unsigned newsize) @@ -65,7 +65,7 @@ public: } void Clear() { - memset (&Types[0], 0xff, Types.Size()*sizeof(WORD)); + memset (&Types[0], 0xff, Types.Size()*sizeof(uint16_t)); } void Set(int index, int value) { @@ -73,7 +73,7 @@ public: { int oldsize = Types.Size(); Resize(index + 1); - memset(&Types[oldsize], 0xff, (index + 1 - oldsize)*sizeof(WORD)); + memset(&Types[oldsize], 0xff, (index + 1 - oldsize)*sizeof(uint16_t)); } Types[index] = value; } @@ -92,9 +92,9 @@ struct FSplashDef PClassActor *SmallSplash; PClassActor *SplashBase; PClassActor *SplashChunk; - BYTE ChunkXVelShift; - BYTE ChunkYVelShift; - BYTE ChunkZVelShift; + uint8_t ChunkXVelShift; + uint8_t ChunkYVelShift; + uint8_t ChunkZVelShift; bool NoAlert; double ChunkBaseZVel; double SmallSplashClip; diff --git a/src/p_trace.cpp b/src/p_trace.cpp index 818372e74..8522e891a 100644 --- a/src/p_trace.cpp +++ b/src/p_trace.cpp @@ -54,7 +54,7 @@ struct FTraceInfo DVector3 Start; DVector3 Vec; ActorFlags ActorMask; - DWORD WallMask; + uint32_t WallMask; AActor *IgnoreThis; FTraceResults *Results; sector_t *CurSector; @@ -62,7 +62,7 @@ struct FTraceInfo double EnterDist; ETraceStatus (*TraceCallback)(FTraceResults &res, void *data); void *TraceCallbackData; - DWORD TraceFlags; + uint32_t TraceFlags; int inshootthrough; double startfrac; double limitz; @@ -103,7 +103,7 @@ struct FTraceInfo }; -static bool EditTraceResult (DWORD flags, FTraceResults &res); +static bool EditTraceResult (uint32_t flags, FTraceResults &res); @@ -150,7 +150,7 @@ static bool isLiquid(F3DFloor *ff) //========================================================================== bool Trace(const DVector3 &start, sector_t *sector, const DVector3 &direction, double maxDist, - ActorFlags actorMask, DWORD wallMask, AActor *ignore, FTraceResults &res, DWORD flags, + ActorFlags actorMask, uint32_t wallMask, AActor *ignore, FTraceResults &res, uint32_t flags, ETraceStatus(*callback)(FTraceResults &res, void *), void *callbackdata) { FTraceInfo inf; @@ -923,7 +923,7 @@ bool FTraceInfo::CheckPlane (const secplane_t &plane) // //========================================================================== -static bool EditTraceResult (DWORD flags, FTraceResults &res) +static bool EditTraceResult (uint32_t flags, FTraceResults &res) { if (flags & TRACE_NoSky) { // Throw away sky hits diff --git a/src/p_trace.h b/src/p_trace.h index d6132d750..914eee288 100644 --- a/src/p_trace.h +++ b/src/p_trace.h @@ -77,8 +77,8 @@ struct FTraceResults AActor *Actor; // valid if hit an actor line_t *Line; // valid if hit a line - BYTE Side; - BYTE Tier; + uint8_t Side; + uint8_t Tier; bool unlinked; // passed through a portal without static offset. ETraceResult HitType; F3DFloor *ffloor; @@ -109,7 +109,7 @@ enum ETraceStatus }; bool Trace(const DVector3 &start, sector_t *sector, const DVector3 &direction, double maxDist, - ActorFlags ActorMask, DWORD WallMask, AActor *ignore, FTraceResults &res, DWORD traceFlags = 0, + ActorFlags ActorMask, uint32_t WallMask, AActor *ignore, FTraceResults &res, uint32_t traceFlags = 0, ETraceStatus(*callback)(FTraceResults &res, void *) = NULL, void *callbackdata = NULL); #endif //__P_TRACE_H__ diff --git a/src/p_user.cpp b/src/p_user.cpp index bcf816ebd..e479ad963 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -104,7 +104,7 @@ struct PredictPos static int PredictionLerptics; static player_t PredictionPlayerBackup; -static BYTE PredictionActorBackup[sizeof(APlayerPawn)]; +static uint8_t PredictionActorBackup[sizeof(APlayerPawn)]; static TArray PredictionSectorListBackup; static TArray PredictionTouchingSectorsBackup; @@ -579,7 +579,7 @@ void player_t::SetFOV(float fov) { Net_WriteByte(DEM_MYFOV); } - Net_WriteByte((BYTE)clamp(fov, 5.f, 179.f)); + Net_WriteByte((uint8_t)clamp(fov, 5.f, 179.f)); } } @@ -3048,7 +3048,7 @@ void P_PredictPlayer (player_t *player) PredictionPlayerBackup = *player; APlayerPawn *act = player->mo; - memcpy(PredictionActorBackup, &act->snext, sizeof(APlayerPawn) - ((BYTE *)&act->snext - (BYTE *)act)); + memcpy(PredictionActorBackup, &act->snext, sizeof(APlayerPawn) - ((uint8_t *)&act->snext - (uint8_t *)act)); act->flags &= ~MF_PICKUP; act->flags2 &= ~MF2_PUSHWALL; @@ -3174,7 +3174,7 @@ void P_UnPredictPlayer () act->touching_lineportallist = nullptr; act->UnlinkFromWorld(&ctx); - memcpy(&act->snext, PredictionActorBackup, sizeof(APlayerPawn) - ((BYTE *)&act->snext - (BYTE *)act)); + memcpy(&act->snext, PredictionActorBackup, sizeof(APlayerPawn) - ((uint8_t *)&act->snext - (uint8_t *)act)); // The blockmap ordering needs to remain unchanged, too. // Restore sector links and refrences. diff --git a/src/p_xlat.cpp b/src/p_xlat.cpp index 29ccf966f..6c29482d7 100644 --- a/src/p_xlat.cpp +++ b/src/p_xlat.cpp @@ -65,11 +65,11 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid) { unsigned short special = (unsigned short) LittleShort(mld->special); short tag = LittleShort(mld->tag); - DWORD flags = LittleShort(mld->flags); + uint32_t flags = LittleShort(mld->flags); INTBOOL passthrough = 0; - DWORD flags1 = flags; - DWORD newflags = 0; + uint32_t flags1 = flags; + uint32_t newflags = 0; for(int i=0;i<16;i++) { @@ -223,7 +223,7 @@ void P_TranslateLineDef (line_t *ld, maplinedef_t *mld, int lineindexforid) FBoomArg *arg = &b->Args[j]; int *destp; int flagtemp; - BYTE val = 0; // quiet, GCC + uint8_t val = 0; // quiet, GCC bool found; if (arg->ArgNum < 4) diff --git a/src/po_man.cpp b/src/po_man.cpp index ebe39ccca..a5e47401f 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -1448,7 +1448,7 @@ static void KillSideLists () // //========================================================================== -static void AddPolyVert(TArray &vnum, DWORD vert) +static void AddPolyVert(TArray &vnum, uint32_t vert) { for (unsigned int i = vnum.Size() - 1; i-- != 0; ) { @@ -1473,22 +1473,22 @@ static void AddPolyVert(TArray &vnum, DWORD vert) static void IterFindPolySides (FPolyObj *po, side_t *side) { - static TArray vnum; + static TArray vnum; unsigned int vnumat; assert(sidetemp != NULL); vnum.Clear(); - vnum.Push(DWORD(side->V1()->Index())); + vnum.Push(uint32_t(side->V1()->Index())); vnumat = 0; while (vnum.Size() != vnumat) { - DWORD sidenum = sidetemp[vnum[vnumat++]].b.first; + uint32_t sidenum = sidetemp[vnum[vnumat++]].b.first; while (sidenum != NO_SIDE) { po->Sidedefs.Push(&level.sides[sidenum]); - AddPolyVert(vnum, DWORD(level.sides[sidenum].V2()->Index())); + AddPolyVert(vnum, uint32_t(level.sides[sidenum].V2()->Index())); sidenum = sidetemp[sidenum].b.next; } } @@ -1592,7 +1592,7 @@ static void SpawnPolyobj (int index, int tag, int type) if (port && (port->mDefFlags & PORTF_PASSABLE)) { int type = port->mType == PORTT_LINKED ? 2 : 1; - if (po->bHasPortals < type) po->bHasPortals = (BYTE)type; + if (po->bHasPortals < type) po->bHasPortals = (uint8_t)type; } l->validcount = validcount; po->Linedefs.Push(l); @@ -1753,7 +1753,7 @@ void PO_Init (void) for (int i = 0; i < numsubsectors; i++) { subsector_t *ss = &subsectors[i]; - for(DWORD j=0;jnumlines; j++) + for(uint32_t j=0;jnumlines; j++) { if (ss->firstline[j].sidedef != NULL && ss->firstline[j].sidedef->Flags & WALLF_POLYOBJ) @@ -2069,7 +2069,7 @@ static void SplitPoly(FPolyNode *pnode, void *node, float bbox[4]) else { // we reached a subsector so we can link the node with this subsector - subsector_t *sub = (subsector_t *)((BYTE *)node - 1); + subsector_t *sub = (subsector_t *)((uint8_t *)node - 1); // Link node to subsector pnode->pnext = sub->polys; diff --git a/src/po_man.h b/src/po_man.h index 53ebda61e..d9e42c7fb 100644 --- a/src/po_man.h +++ b/src/po_man.h @@ -83,7 +83,7 @@ struct FPolyObj int crush; // should the polyobj attempt to crush mobjs? bool bHurtOnTouch; // should the polyobj hurt anything it touches? bool bBlocked; - BYTE bHasPortals; // 1 for any portal, 2 for a linked portal (2 must block rotations.) + uint8_t bHasPortals; // 1 for any portal, 2 for a linked portal (2 must block rotations.) int seqType; double Size; // polyobj size (area of POLY_AREAUNIT == size of FRACUNIT) FPolyNode *subsectorlinks; diff --git a/src/portal.cpp b/src/portal.cpp index 4ba334225..888038735 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -81,7 +81,7 @@ DEFINE_FIELD(FSectorPortal, mSkybox); struct FPortalBits { - TArray data; + TArray data; void setSize(int num) { @@ -91,7 +91,7 @@ struct FPortalBits void clear() { - memset(&data[0], 0, data.Size()*sizeof(DWORD)); + memset(&data[0], 0, data.Size()*sizeof(uint32_t)); } void setBit(int group) @@ -287,7 +287,7 @@ void P_SpawnLinePortal(line_t* line) memset(port, 0, sizeof(FLinePortal)); port->mOrigin = line; port->mDestination = dst; - port->mType = BYTE(line->args[2]); // range check is done above. + port->mType = uint8_t(line->args[2]); // range check is done above. if (port->mType == PORTT_LINKED) { @@ -296,7 +296,7 @@ void P_SpawnLinePortal(line_t* line) } else { - port->mAlign = BYTE(line->args[3] >= PORG_ABSOLUTE && line->args[3] <= PORG_CEILING ? line->args[3] : PORG_ABSOLUTE); + port->mAlign = uint8_t(line->args[3] >= PORG_ABSOLUTE && line->args[3] <= PORG_CEILING ? line->args[3] : PORG_ABSOLUTE); if (port->mType == PORTT_INTERACTIVE && port->mAlign != PORG_ABSOLUTE) { // Due to the way z is often handled, these pose a major issue for parts of the code that needs to transparently handle interactive portals. @@ -923,7 +923,7 @@ static void AddDisplacementForPortal(FLinePortal *portal) static bool ConnectGroups() { // Now - BYTE indirect = 1; + uint8_t indirect = 1; bool bogus = false; bool changed; do diff --git a/src/portal.h b/src/portal.h index e2b3a9f7f..d8eda7a1e 100644 --- a/src/portal.h +++ b/src/portal.h @@ -29,7 +29,7 @@ struct FDisplacement { DVector2 pos; bool isSet; - BYTE indirect; // just for illustration. + uint8_t indirect; // just for illustration. }; @@ -183,10 +183,10 @@ struct FLinePortal line_t *mOrigin; line_t *mDestination; DVector2 mDisplacement; - BYTE mType; - BYTE mFlags; - BYTE mDefFlags; - BYTE mAlign; + uint8_t mType; + uint8_t mFlags; + uint8_t mDefFlags; + uint8_t mAlign; DAngle mAngleDiff; double mSinRot; double mCosRot; diff --git a/src/r_defs.h b/src/r_defs.h index 99203c148..300ef3b8c 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -46,8 +46,8 @@ struct seg_t; #define MAXWIDTH 5760 #define MAXHEIGHT 3600 -const WORD NO_INDEX = 0xffffu; -const DWORD NO_SIDE = 0xffffffffu; +const uint16_t NO_INDEX = 0xffffu; +const uint32_t NO_SIDE = 0xffffffffu; // Silhouette, needed for clipping Segs (mainly) // and sprites representing things. @@ -80,7 +80,7 @@ enum struct vertexdata_t { double zCeiling, zFloor; - DWORD flags; + uint32_t flags; }; #ifdef USE_FLOAT @@ -1011,16 +1011,16 @@ public: int prevsec; // -1 or number of sector for previous step int nextsec; // -1 or number of next step sector - BYTE soundtraversed; // 0 = untraversed, 1,2 = sndlines -1 + uint8_t soundtraversed; // 0 = untraversed, 1,2 = sndlines -1 // jff 2/26/98 lockout machinery for stairbuilding - SBYTE stairlock; // -2 on first locked -1 after thinker done 0 normally + int8_t stairlock; // -2 on first locked -1 after thinker done 0 normally TStaticPointedArray Lines; // killough 3/7/98: support flat heights drawn at another sector's heights sector_t *heightsec; // other sector, or NULL if no other sector - DWORD bottommap, midmap, topmap; // killough 4/4/98: dynamic colormaps + uint32_t bottommap, midmap, topmap; // killough 4/4/98: dynamic colormaps // [RH] these can also be blend values if // the alpha mask is non-zero @@ -1036,9 +1036,9 @@ public: short damageinterval; // Interval for damage application short leakydamage; // chance of leaking through radiation suit - WORD ZoneNumber; // [RH] Zone this sector belongs to - WORD MoreFlags; // [RH] Internal sector flags - DWORD Flags; // Sector flags + uint16_t ZoneNumber; // [RH] Zone this sector belongs to + uint16_t MoreFlags; // [RH] Internal sector flags + uint32_t Flags; // Sector flags // [RH] Action specials for sectors. Like Skull Tag, but more // flexible in a Bloody way. SecActTarget forms a list of actors @@ -1134,16 +1134,16 @@ struct side_t DBaseDecal* AttachedDecals; // [RH] Decals bound to the wall part textures[3]; line_t *linedef; - //DWORD linenum; - DWORD LeftSide, RightSide; // [RH] Group walls into loops - WORD TexelLength; - SWORD Light; - BYTE Flags; + //uint32_t linenum; + uint32_t LeftSide, RightSide; // [RH] Group walls into loops + uint16_t TexelLength; + int16_t Light; + uint8_t Flags; int UDMFIndex; // needed to access custom UDMF fields which are stored in loading order. int GetLightLevel (bool foggy, int baselight, bool is3dlight=false, int *pfakecontrast_usedbygzdoom=NULL) const; - void SetLight(SWORD l) + void SetLight(int16_t l) { Light = l; } @@ -1413,7 +1413,7 @@ enum struct FPortalCoverage { - DWORD * subsectors; + uint32_t * subsectors; int sscount; }; @@ -1424,7 +1424,7 @@ struct subsector_t FMiniBSP *BSP; seg_t *firstline; sector_t *render_sector; - DWORD numlines; + uint32_t numlines; int flags; void BuildPolyBSP(); @@ -1482,7 +1482,7 @@ struct FMiniBSP // OTHER TYPES // -typedef BYTE lighttable_t; // This could be wider for >8 bit display. +typedef uint8_t lighttable_t; // This could be wider for >8 bit display. // This encapsulates the fields of vissprite_t that can be altered by AlterWeaponSprite struct visstyle_t