diff --git a/.appveyor.yml b/.appveyor.yml index 608f8d0fc..ef64bce49 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -4,7 +4,7 @@ branches: except: - /^travis.*$/ -clone_depth: 1 +clone_depth: 10 os: Visual Studio 2015 @@ -52,3 +52,9 @@ build: project: build\GZDoom.sln parallel: true verbosity: minimal + +notifications: + - provider: Email + on_build_success: false + on_build_failure: false + on_build_status_changed: false diff --git a/.travis.yml b/.travis.yml index 50de0fd1c..97211cc76 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ branches: - /^appveyor.*$/ git: - depth: 3 + depth: 10 matrix: include: @@ -85,6 +85,7 @@ before_install: - if [ -n "$CLANG_VERSION" ]; then export CC="clang-${CLANG_VERSION}" CXX="clang++-${CLANG_VERSION}"; fi - $CC --version - $CXX --version + # Update dependencies here: https://github.com/coelckers/gzdoom/releases/tag/ci_deps - export FMOD_FILENAME=fmod-4.44.64-${TRAVIS_OS_NAME}.tar.bz2 - curl -LO "https://github.com/coelckers/gzdoom/releases/download/ci_deps/${FMOD_FILENAME}" - tar -xf "${FMOD_FILENAME}" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 950cfe9c0..732f53147 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -756,6 +756,8 @@ file( GLOB HEADER_FILES scripting/decorate/*.h scripting/zscript/*.h scripting/vm/*.h + timidity/*.h + wildmidi/*.h xlat/*.h swrenderer/*.h swrenderer/drawers/*.h @@ -935,6 +937,7 @@ set( FASTMATH_SOURCES sound/music_timidity_mididevice.cpp sound/music_wildmidi_mididevice.cpp sound/music_win_mididevice.cpp + sound/music_audiotoolbox_mididevice.cpp sound/oalsound.cpp sound/sndfile_decoder.cpp sound/music_pseudo_mididevice.cpp @@ -1387,7 +1390,7 @@ endif() if( APPLE ) set_target_properties(zdoom PROPERTIES - LINK_FLAGS "-framework Carbon -framework Cocoa -framework IOKit -framework OpenGL" + LINK_FLAGS "-framework AudioToolbox -framework AudioUnit -framework Carbon -framework Cocoa -framework IOKit -framework OpenGL" MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/posix/osx/zdoom-info.plist" ) if( NOT NO_FMOD ) diff --git a/src/actor.h b/src/actor.h index e435a1fb7..b5f4472b9 100644 --- a/src/actor.h +++ b/src/actor.h @@ -511,7 +511,7 @@ typedef TFlags ActorFlags5; typedef TFlags ActorFlags6; typedef TFlags ActorFlags7; typedef TFlags ActorRenderFlags; -typedef TFlags ActorBounceFlags; +typedef TFlags ActorBounceFlags; DEFINE_TFLAGS_OPERATORS (ActorFlags) DEFINE_TFLAGS_OPERATORS (ActorFlags2) DEFINE_TFLAGS_OPERATORS (ActorFlags3) @@ -746,7 +746,7 @@ public: void DestroyAllInventory (); // Set the alphacolor field properly - void SetShade (DWORD rgb); + void SetShade (uint32_t rgb); void SetShade (int r, int g, int b); // Plays a conversation animation @@ -991,8 +991,8 @@ public: uint8_t fountaincolor; // Split out of 'effect' to have easier access. FRenderStyle RenderStyle; // Style to draw this actor with FTextureID picnum; // Draw this instead of sprite if valid - DWORD fillcolor; // Color to draw when STYLE_Shaded - DWORD Translation; + uint32_t fillcolor; // Color to draw when STYLE_Shaded + uint32_t Translation; ActorRenderFlags renderflags; // Different rendering flags ActorFlags flags; @@ -1045,7 +1045,7 @@ public: int projectileKickback; // [BB] If 0, everybody can see the actor, if > 0, only members of team (VisibleToTeam-1) can see it. - DWORD VisibleToTeam; + uint32_t VisibleToTeam; int special1; // Special info int special2; // Special info @@ -1054,32 +1054,32 @@ public: int weaponspecial; // Special info for weapons. int health; - BYTE movedir; // 0-7 - SBYTE visdir; - SWORD movecount; // when 0, select a new dir - SWORD strafecount; // for MF3_AVOIDMELEE - TObjPtr target; // thing being chased/attacked (or NULL) + uint8_t movedir; // 0-7 + int8_t visdir; + int16_t movecount; // when 0, select a new dir + int16_t strafecount; // for MF3_AVOIDMELEE + TObjPtr target; // thing being chased/attacked (or NULL) // also the originator for missiles - TObjPtr lastenemy; // Last known enemy -- killough 2/15/98 - TObjPtr LastHeard; // [RH] Last actor this one heard + TObjPtr lastenemy; // Last known enemy -- killough 2/15/98 + TObjPtr LastHeard; // [RH] Last actor this one heard int32_t reactiontime; // if non 0, don't attack yet; used by // player to freeze a bit after teleporting int32_t threshold; // if > 0, the target will be chased int32_t DefThreshold; // [MC] Default threshold which the actor will reset its threshold to after switching targets // no matter what (even if shot) player_t *player; // only valid if type of APlayerPawn - TObjPtr LastLookActor; // Actor last looked for (if TIDtoHate != 0) + TObjPtr LastLookActor; // Actor last looked for (if TIDtoHate != 0) DVector3 SpawnPoint; // For nightmare respawn - WORD SpawnAngle; + uint16_t SpawnAngle; int StartHealth; - BYTE WeaveIndexXY; // Separated from special2 because it's used by globally accessible functions. - BYTE WeaveIndexZ; + uint8_t WeaveIndexXY; // Separated from special2 because it's used by globally accessible functions. + uint8_t WeaveIndexZ; int skillrespawncount; int TIDtoHate; // TID of things to hate (0 if none) FNameNoInit Species; // For monster families - TObjPtr alternative; // (Un)Morphed actors stored here. Those with the MF_UNMORPHED flag are the originals. - TObjPtr tracer; // Thing being chased/attacked for tracers - TObjPtr master; // Thing which spawned this one (prevents mutual attacks) + TObjPtr alternative; // (Un)Morphed actors stored here. Those with the MF_UNMORPHED flag are the originals. + TObjPtr tracer; // Thing being chased/attacked for tracers + TObjPtr master; // Thing which spawned this one (prevents mutual attacks) int tid; // thing identifier int special; // special @@ -1088,13 +1088,13 @@ public: int accuracy, stamina; // [RH] Strife stats -- [XA] moved here for DECORATE/ACS access. AActor *inext, **iprev;// Links to other mobjs in same bucket - TObjPtr goal; // Monster's goal if not chasing anything + TObjPtr goal; // Monster's goal if not chasing anything int waterlevel; // 0=none, 1=feet, 2=waist, 3=eyes - BYTE boomwaterlevel; // splash information for non-swimmable water sectors - BYTE MinMissileChance;// [RH] If a random # is > than this, then missile attack. - SBYTE LastLookPlayerNumber;// Player number last looked for (if TIDtoHate == 0) + uint8_t boomwaterlevel; // splash information for non-swimmable water sectors + uint8_t MinMissileChance;// [RH] If a random # is > than this, then missile attack. + int8_t LastLookPlayerNumber;// Player number last looked for (if TIDtoHate == 0) ActorBounceFlags BounceFlags; // which bouncing type? - DWORD SpawnFlags; // Increased to DWORD because of Doom 64 + uint32_t SpawnFlags; // Increased to uint32_t because of Doom 64 double meleerange; // specifies how far a melee attack reaches. double meleethreshold; // Distance below which a monster doesn't try to shoot missiles anynore // but instead tries to come closer for a melee attack. @@ -1126,7 +1126,7 @@ public: FNameNoInit PoisonDamageTypeReceived; // Damage type received by poison. int PoisonDurationReceived; // Duration left for receiving poison damage. int PoisonPeriodReceived; // How often poison damage is applied. (Every X tics.) - TObjPtr Poisoner; // Last source of received poison damage. + TObjPtr Poisoner; // Last source of received poison damage. // a linked list of sectors where this object appears struct msecnode_t *touching_sectorlist; // phares 3/14/98 @@ -1136,14 +1136,14 @@ public: int validcount; - TObjPtr Inventory; // [RH] This actor's inventory - DWORD InventoryID; // A unique ID to keep track of inventory items + TObjPtr Inventory; // [RH] This actor's inventory + uint32_t InventoryID; // A unique ID to keep track of inventory items - BYTE smokecounter; - BYTE FloatBobPhase; - BYTE FriendPlayer; // [RH] Player # + 1 this friendly monster works for (so 0 is no player, 1 is player 0, etc) + uint8_t smokecounter; + uint8_t FloatBobPhase; + uint8_t FriendPlayer; // [RH] Player # + 1 this friendly monster works for (so 0 is no player, 1 is player 0, etc) PalEntry BloodColor; - DWORD BloodTranslation; + uint32_t BloodTranslation; // [RH] Stuff that used to be part of an Actor Info FSoundIDNoInit SeeSound; @@ -1160,7 +1160,7 @@ public: double MaxStepHeight; int32_t Mass; - SWORD PainChance; + int16_t PainChance; int PainThreshold; FNameNoInit DamageType; FNameNoInit DamageTypeReceived; @@ -1434,7 +1434,7 @@ public: // begin of GZDoom specific additions - TArray > dynamiclights; + TArray > dynamiclights; void * lightassociations; bool hasmodel; // end of GZDoom specific additions @@ -1545,7 +1545,7 @@ template inline T *Spawn() // for inventory items we do not need coordi } void PrintMiscActorInfo(AActor * query); -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); // If we want to make P_AimLineAttack capable of handling arbitrary portals, it needs to pass a lot more info than just the linetarget actor. struct FTranslatedLineTarget diff --git a/src/am_map.cpp b/src/am_map.cpp index a6aa36e84..797569da8 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -256,7 +256,7 @@ struct AMColorset c[i].FromCVar(*values[i]); } - DWORD ba = *(values[0]); + uint32_t ba = *(values[0]); int r = RPART(ba) - 16; int g = GPART(ba) - 16; @@ -791,7 +791,7 @@ static bool stopped = true; static void AM_calcMinMaxMtoF(); static void DrawMarker (FTexture *tex, double x, double y, int yadjust, - INTBOOL flip, double xscale, double yscale, int translation, double alpha, DWORD fillcolor, FRenderStyle renderstyle); + INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle); void AM_rotatePoint (double *x, double *y); void AM_rotate (double *x, double *y, DAngle an); @@ -1920,7 +1920,7 @@ void AM_drawSubsectors() // Fill the points array from the subsector. points.Resize(subsectors[i].numlines); - for (DWORD j = 0; j < subsectors[i].numlines; ++j) + for (uint32_t j = 0; j < subsectors[i].numlines; ++j) { mpoint_t pt = { subsectors[i].firstline[j].v1->fX(), subsectors[i].firstline[j].v1->fY() }; @@ -2911,7 +2911,7 @@ void AM_drawThings () //============================================================================= static void DrawMarker (FTexture *tex, double x, double y, int yadjust, - INTBOOL flip, double xscale, double yscale, int translation, double alpha, DWORD fillcolor, FRenderStyle renderstyle) + INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle) { if (tex == NULL || tex->UseType == FTexture::TEX_Null) { @@ -2932,7 +2932,7 @@ static void DrawMarker (FTexture *tex, double x, double y, int yadjust, DTA_TranslationIndex, translation, DTA_Alpha, alpha, DTA_FillColor, fillcolor, - DTA_RenderStyle, DWORD(renderstyle), + DTA_RenderStyle, uint32_t(renderstyle), TAG_DONE); } @@ -2977,7 +2977,7 @@ void AM_drawAuthorMarkers () FTextureID picnum; FTexture *tex; - WORD flip = 0; + uint16_t flip = 0; if (mark->picnum.isValid()) { diff --git a/src/autosegs.h b/src/autosegs.h index f38e3628e..9cba04ad2 100644 --- a/src/autosegs.h +++ b/src/autosegs.h @@ -35,7 +35,15 @@ #ifndef AUTOSEGS_H #define AUTOSEGS_H -#include "doomtype.h" +#if defined(__clang__) +#if defined(__has_feature) && __has_feature(address_sanitizer) +#define NO_SANITIZE __attribute__((no_sanitize("address"))) +#else +#define NO_SANITIZE +#endif +#else +#define NO_SANITIZE +#endif #define REGMARKER(x) (x) typedef void * const REGINFO; diff --git a/src/b_bot.h b/src/b_bot.h index 58a9b7640..fd3ad3c94 100644 --- a/src/b_bot.h +++ b/src/b_bot.h @@ -91,7 +91,7 @@ public: void Init (); void End(); bool SpawnBot (const char *name, int color = NOCOLOR); - void TryAddBot (BYTE **stream, int player); + void TryAddBot (uint8_t **stream, int player); void RemoveAllBots (bool fromlist); bool LoadBots (); void ForgetBots (); @@ -110,21 +110,21 @@ public: bool IsDangerous (sector_t *sec); TArray getspawned; //Array of bots (their names) which should be spawned when starting a game. - BYTE freeze; //Game in freeze mode. - BYTE changefreeze; //Game wants to change freeze mode. + uint8_t freeze; //Game in freeze mode. + uint8_t changefreeze; //Game wants to change freeze mode. int botnum; botinfo_t *botinfo; int spawn_tries; int wanted_botnum; - TObjPtr firstthing; - TObjPtr body1; - TObjPtr body2; + TObjPtr firstthing; + TObjPtr body1; + TObjPtr body2; bool m_Thinking; private: //(b_game.cpp) - bool DoAddBot (BYTE *info, botskill_t skill); + bool DoAddBot (uint8_t *info, botskill_t skill); protected: bool ctf; @@ -152,12 +152,12 @@ public: player_t *player; DAngle Angle; // The wanted angle that the bot try to get every tic. // (used to get a smooth view movement) - TObjPtr dest; // Move Destination. - TObjPtr prev; // Previous move destination. - TObjPtr enemy; // The dead meat. - TObjPtr missile; // A threatening missile that needs to be avoided. - TObjPtr mate; // Friend (used for grouping in teamplay or coop). - TObjPtr last_mate; // If bots mate disappeared (not if died) that mate is + TObjPtr dest; // Move Destination. + TObjPtr prev; // Previous move destination. + TObjPtr enemy; // The dead meat. + TObjPtr missile; // A threatening missile that needs to be avoided. + TObjPtr mate; // Friend (used for grouping in teamplay or coop). + TObjPtr last_mate; // If bots mate disappeared (not if died) that mate is // pointed to by this. Allows bot to roam to it if // necessary. diff --git a/src/b_game.cpp b/src/b_game.cpp index 38fbfafcb..c388c0538 100644 --- a/src/b_game.cpp +++ b/src/b_game.cpp @@ -309,7 +309,7 @@ bool FCajunMaster::SpawnBot (const char *name, int color) return true; } -void FCajunMaster::TryAddBot (BYTE **stream, int player) +void FCajunMaster::TryAddBot (uint8_t **stream, int player) { int botshift = ReadByte (stream); char *info = ReadString (stream); @@ -332,7 +332,7 @@ void FCajunMaster::TryAddBot (BYTE **stream, int player) } } - if (DoAddBot ((BYTE *)info, skill)) + if (DoAddBot ((uint8_t *)info, skill)) { //Increment this. botnum++; @@ -353,7 +353,7 @@ void FCajunMaster::TryAddBot (BYTE **stream, int player) delete[] info; } -bool FCajunMaster::DoAddBot (BYTE *info, botskill_t skill) +bool FCajunMaster::DoAddBot (uint8_t *info, botskill_t skill) { int bnum; @@ -564,7 +564,7 @@ bool FCajunMaster::LoadBots () case BOTCFG_TEAM: { char teamstr[16]; - BYTE teamnum; + uint8_t teamnum; sc.MustGetString (); if (IsNum (sc.String)) diff --git a/src/basictypes.h b/src/basictypes.h index acb499c0d..ac267f558 100644 --- a/src/basictypes.h +++ b/src/basictypes.h @@ -8,7 +8,6 @@ typedef uint8_t BYTE; typedef int16_t SWORD; typedef uint16_t WORD; typedef uint32_t uint32; -typedef int64_t SQWORD; typedef uint64_t QWORD; // windef.h, included by windows.h, has its own incompatible definition @@ -23,23 +22,14 @@ typedef uint32 DWORD; typedef uint32 BITFIELD; typedef int INTBOOL; -// a 64-bit constant -#ifdef __GNUC__ -#define CONST64(v) (v##LL) -#define UCONST64(v) (v##ULL) -#else -#define CONST64(v) ((SQWORD)(v)) -#define UCONST64(v) ((QWORD)(v)) -#endif - #if !defined(GUID_DEFINED) #define GUID_DEFINED typedef struct _GUID { DWORD Data1; - WORD Data2; - WORD Data3; - BYTE Data4[8]; + uint16_t Data2; + uint16_t Data3; + uint8_t Data4[8]; } GUID; #endif diff --git a/src/c_bind.cpp b/src/c_bind.cpp index c21e200d3..8d27c38bd 100644 --- a/src/c_bind.cpp +++ b/src/c_bind.cpp @@ -158,7 +158,7 @@ FKeyBindings DoubleBindings; FKeyBindings AutomapBindings; static unsigned int DClickTime[NUM_KEYS]; -static BYTE DClicked[(NUM_KEYS+7)/8]; +static uint8_t DClicked[(NUM_KEYS+7)/8]; //============================================================================= // @@ -724,7 +724,7 @@ bool C_DoKey (event_t *ev, FKeyBindings *binds, FKeyBindings *doublebinds) FString binding; bool dclick; int dclickspot; - BYTE dclickmask; + uint8_t dclickmask; unsigned int nowtime; if (ev->type != EV_KeyDown && ev->type != EV_KeyUp) diff --git a/src/c_console.cpp b/src/c_console.cpp index a28d6c19e..b2dbf8edf 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -94,7 +94,7 @@ CVAR(Bool, con_notablist, false, CVAR_ARCHIVE) static FTextureID conback; -static DWORD conshade; +static uint32_t conshade; static bool conline; extern int gametic; diff --git a/src/c_cvars.cpp b/src/c_cvars.cpp index 6430d95ad..fa4b8d148 100644 --- a/src/c_cvars.cpp +++ b/src/c_cvars.cpp @@ -74,7 +74,7 @@ FBaseCVar::FBaseCVar (const FBaseCVar &var) I_FatalError ("Use of cvar copy constructor"); } -FBaseCVar::FBaseCVar (const char *var_name, DWORD flags, void (*callback)(FBaseCVar &)) +FBaseCVar::FBaseCVar (const char *var_name, uint32_t flags, void (*callback)(FBaseCVar &)) { FBaseCVar *var; @@ -481,9 +481,9 @@ UCVarValue FBaseCVar::FromFloat (float value, ECVarType type) return ret; } -static BYTE HexToByte (const char *hex) +static uint8_t HexToByte (const char *hex) { - BYTE v = 0; + uint8_t v = 0; for (int i = 0; i < 2; ++i) { v <<= 4; @@ -573,8 +573,8 @@ UCVarValue FBaseCVar::FromString (const char *value, ECVarType type) if (i == 38 && value[i] == 0) { cGUID.Data1 = strtoul (value + 1, NULL, 16); - cGUID.Data2 = (WORD)strtoul (value + 10, NULL, 16); - cGUID.Data3 = (WORD)strtoul (value + 15, NULL, 16); + cGUID.Data2 = (uint16_t)strtoul (value + 10, NULL, 16); + cGUID.Data3 = (uint16_t)strtoul (value + 15, NULL, 16); cGUID.Data4[0] = HexToByte (value + 20); cGUID.Data4[1] = HexToByte (value + 22); cGUID.Data4[2] = HexToByte (value + 25); @@ -690,7 +690,7 @@ DEFINE_ACTION_FUNCTION(_CVar, GetRealType) // Boolean cvar implementation // -FBoolCVar::FBoolCVar (const char *name, bool def, DWORD flags, void (*callback)(FBoolCVar &)) +FBoolCVar::FBoolCVar (const char *name, bool def, uint32_t flags, void (*callback)(FBoolCVar &)) : FBaseCVar (name, flags, reinterpret_cast(callback)) { DefaultValue = def; @@ -748,7 +748,7 @@ void FBoolCVar::DoSet (UCVarValue value, ECVarType type) // Integer cvar implementation // -FIntCVar::FIntCVar (const char *name, int def, DWORD flags, void (*callback)(FIntCVar &)) +FIntCVar::FIntCVar (const char *name, int def, uint32_t flags, void (*callback)(FIntCVar &)) : FBaseCVar (name, flags, reinterpret_cast(callback)) { DefaultValue = def; @@ -806,7 +806,7 @@ void FIntCVar::DoSet (UCVarValue value, ECVarType type) // Floating point cvar implementation // -FFloatCVar::FFloatCVar (const char *name, float def, DWORD flags, void (*callback)(FFloatCVar &)) +FFloatCVar::FFloatCVar (const char *name, float def, uint32_t flags, void (*callback)(FFloatCVar &)) : FBaseCVar (name, flags, reinterpret_cast(callback)) { DefaultValue = def; @@ -874,7 +874,7 @@ void FFloatCVar::DoSet (UCVarValue value, ECVarType type) // String cvar implementation // -FStringCVar::FStringCVar (const char *name, const char *def, DWORD flags, void (*callback)(FStringCVar &)) +FStringCVar::FStringCVar (const char *name, const char *def, uint32_t flags, void (*callback)(FStringCVar &)) : FBaseCVar (name, flags, reinterpret_cast(callback)) { DefaultValue = copystring (def); @@ -943,7 +943,7 @@ void FStringCVar::DoSet (UCVarValue value, ECVarType type) // Color cvar implementation // -FColorCVar::FColorCVar (const char *name, int def, DWORD flags, void (*callback)(FColorCVar &)) +FColorCVar::FColorCVar (const char *name, int def, uint32_t flags, void (*callback)(FColorCVar &)) : FIntCVar (name, def, flags, reinterpret_cast(callback)) { } @@ -1024,7 +1024,7 @@ int FColorCVar::ToInt2 (UCVarValue value, ECVarType type) // GUID cvar implementation // -FGUIDCVar::FGUIDCVar (const char *name, const GUID *def, DWORD flags, void (*callback)(FGUIDCVar &)) +FGUIDCVar::FGUIDCVar (const char *name, const GUID *def, uint32_t flags, void (*callback)(FGUIDCVar &)) : FBaseCVar (name, flags, reinterpret_cast(callback)) { if (def != NULL) @@ -1141,7 +1141,7 @@ DEFINE_ACTION_FUNCTION(_CVar, ResetToDefault) // the network. The "host" cvar is responsible for that. // -FFlagCVar::FFlagCVar (const char *name, FIntCVar &realvar, DWORD bitval) +FFlagCVar::FFlagCVar (const char *name, FIntCVar &realvar, uint32_t bitval) : FBaseCVar (name, 0, NULL), ValueVar (realvar), BitVal (bitval) @@ -1246,7 +1246,7 @@ void FFlagCVar::DoSet (UCVarValue value, ECVarType type) // Similar to FFlagCVar but can have multiple bits // -FMaskCVar::FMaskCVar (const char *name, FIntCVar &realvar, DWORD bitval) +FMaskCVar::FMaskCVar (const char *name, FIntCVar &realvar, uint32_t bitval) : FBaseCVar (name, 0, NULL), ValueVar (realvar), BitVal (bitval) @@ -1354,7 +1354,7 @@ static int sortcvars (const void *a, const void *b) return strcmp (((*(FBaseCVar **)a))->GetName(), ((*(FBaseCVar **)b))->GetName()); } -void FilterCompactCVars (TArray &cvars, DWORD filter) +void FilterCompactCVars (TArray &cvars, uint32_t filter) { // Accumulate all cvars that match the filter flags. for (FBaseCVar *cvar = CVars; cvar != NULL; cvar = cvar->m_Next) @@ -1370,7 +1370,7 @@ void FilterCompactCVars (TArray &cvars, DWORD filter) } } -void C_WriteCVars (BYTE **demo_p, DWORD filter, bool compact) +void C_WriteCVars (uint8_t **demo_p, uint32_t filter, bool compact) { FString dump = C_GetMassCVarString(filter, compact); size_t dumplen = dump.Len() + 1; // include terminating \0 @@ -1378,7 +1378,7 @@ void C_WriteCVars (BYTE **demo_p, DWORD filter, bool compact) *demo_p += dumplen; } -FString C_GetMassCVarString (DWORD filter, bool compact) +FString C_GetMassCVarString (uint32_t filter, bool compact) { FBaseCVar *cvar; FString dump; @@ -1408,7 +1408,7 @@ FString C_GetMassCVarString (DWORD filter, bool compact) return dump; } -void C_ReadCVars (BYTE **demo_p) +void C_ReadCVars (uint8_t **demo_p) { char *ptr = *((char **)demo_p); char *breakpt; @@ -1420,7 +1420,7 @@ void C_ReadCVars (BYTE **demo_p) { // compact mode TArray cvars; FBaseCVar *cvar; - DWORD filter; + uint32_t filter; ptr++; breakpt = strchr (ptr, '\\'); @@ -1613,7 +1613,7 @@ FBaseCVar *GetUserCVar(int playernum, const char *cvarname) // //=========================================================================== -FBaseCVar *C_CreateCVar(const char *var_name, ECVarType var_type, DWORD flags) +FBaseCVar *C_CreateCVar(const char *var_name, ECVarType var_type, uint32_t flags) { assert(FindCVar(var_name, NULL) == NULL); flags |= CVAR_AUTO; @@ -1634,7 +1634,7 @@ void UnlatchCVars (void) while (LatchedValues.Pop (var)) { - DWORD oldflags = var.Variable->Flags; + uint32_t oldflags = var.Variable->Flags; var.Variable->Flags &= ~(CVAR_LATCH | CVAR_SERVERINFO); var.Variable->SetGenericRep (var.Value, var.Type); if (var.Type == CVAR_String) @@ -1643,7 +1643,7 @@ void UnlatchCVars (void) } } -void DestroyCVarsFlagged (DWORD flags) +void DestroyCVarsFlagged (uint32_t flags) { FBaseCVar *cvar = CVars; FBaseCVar *next = cvar; @@ -1808,7 +1808,7 @@ void FBaseCVar::ListVars (const char *filter, bool plain) { if (CheckWildcards (filter, var->GetName())) { - DWORD flags = var->GetFlags(); + uint32_t flags = var->GetFlags(); if (plain) { // plain formatting does not include user-defined cvars if (!(flags & CVAR_UNSETTABLE)) diff --git a/src/c_cvars.h b/src/c_cvars.h index 98dc71915..5a918bc63 100644 --- a/src/c_cvars.h +++ b/src/c_cvars.h @@ -160,12 +160,12 @@ private: static bool m_DoNoSet; friend FString C_GetMassCVarString (uint32 filter, bool compact); - friend void C_ReadCVars (BYTE **demo_p); + friend void C_ReadCVars (uint8_t **demo_p); friend void C_BackupCVars (void); friend FBaseCVar *FindCVar (const char *var_name, FBaseCVar **prev); friend FBaseCVar *FindCVarSub (const char *var_name, int namelen); friend void UnlatchCVars (void); - friend void DestroyCVarsFlagged (DWORD flags); + friend void DestroyCVarsFlagged (uint32_t flags); friend void C_ArchiveCVars (FConfigFile *f, uint32 filter); friend void C_SetCVarsToDefaults (void); friend void FilterCompactCVars (TArray &cvars, uint32 filter); @@ -178,10 +178,10 @@ FString C_GetMassCVarString (uint32 filter, bool compact=false); // Writes all cvars that could effect demo sync to *demo_p. These are // cvars that have either CVAR_SERVERINFO or CVAR_DEMOSAVE set. -void C_WriteCVars (BYTE **demo_p, uint32 filter, bool compact=false); +void C_WriteCVars (uint8_t **demo_p, uint32 filter, bool compact=false); // Read all cvars from *demo_p and set them appropriately. -void C_ReadCVars (BYTE **demo_p); +void C_ReadCVars (uint8_t **demo_p); // Backup demo cvars. Called before a demo starts playing to save all // cvars the demo might change. @@ -196,13 +196,13 @@ FBaseCVar *GetCVar(AActor *activator, const char *cvarname); FBaseCVar *GetUserCVar(int playernum, const char *cvarname); // Create a new cvar with the specified name and type -FBaseCVar *C_CreateCVar(const char *var_name, ECVarType var_type, DWORD flags); +FBaseCVar *C_CreateCVar(const char *var_name, ECVarType var_type, uint32_t flags); // Called from G_InitNew() void UnlatchCVars (void); // Destroy CVars with the matching flags; called from CCMD(restart) -void DestroyCVarsFlagged (DWORD flags); +void DestroyCVarsFlagged (uint32_t flags); // archive cvars to FILE f void C_ArchiveCVars (FConfigFile *f, uint32 filter); @@ -431,8 +431,8 @@ extern int cvar_defflags; FBaseCVar *cvar_set (const char *var_name, const char *value); FBaseCVar *cvar_forceset (const char *var_name, const char *value); -inline FBaseCVar *cvar_set (const char *var_name, const BYTE *value) { return cvar_set (var_name, (const char *)value); } -inline FBaseCVar *cvar_forceset (const char *var_name, const BYTE *value) { return cvar_forceset (var_name, (const char *)value); } +inline FBaseCVar *cvar_set (const char *var_name, const uint8_t *value) { return cvar_set (var_name, (const char *)value); } +inline FBaseCVar *cvar_forceset (const char *var_name, const uint8_t *value) { return cvar_forceset (var_name, (const char *)value); } diff --git a/src/c_dispatch.cpp b/src/c_dispatch.cpp index 184f33adb..ad32fcca9 100644 --- a/src/c_dispatch.cpp +++ b/src/c_dispatch.cpp @@ -293,17 +293,17 @@ static int ListActionCommands (const char *pattern) #undef get16bits #if (defined(__GNUC__) && defined(__i386__)) || defined(__WATCOMC__) \ || defined(_MSC_VER) || defined (__BORLANDC__) || defined (__TURBOC__) -#define get16bits(d) (*((const WORD *) (d))) +#define get16bits(d) (*((const uint16_t *) (d))) #endif #if !defined (get16bits) -#define get16bits(d) ((((DWORD)(((const BYTE *)(d))[1])) << 8)\ - +(DWORD)(((const BYTE *)(d))[0]) ) +#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\ + +(uint32_t)(((const uint8_t *)(d))[0]) ) #endif -DWORD SuperFastHash (const char *data, size_t len) +uint32_t SuperFastHash (const char *data, size_t len) { - DWORD hash = 0, tmp; + uint32_t hash = 0, tmp; size_t rem; if (len == 0 || data == NULL) return 0; @@ -317,7 +317,7 @@ DWORD SuperFastHash (const char *data, size_t len) hash += get16bits (data); tmp = (get16bits (data+2) << 11) ^ hash; hash = (hash << 16) ^ tmp; - data += 2*sizeof (WORD); + data += 2*sizeof (uint16_t); hash += hash >> 11; } @@ -326,7 +326,7 @@ DWORD SuperFastHash (const char *data, size_t len) { case 3: hash += get16bits (data); hash ^= hash << 16; - hash ^= data[sizeof (WORD)] << 18; + hash ^= data[sizeof (uint16_t)] << 18; hash += hash >> 11; break; case 2: hash += get16bits (data); @@ -352,12 +352,12 @@ DWORD SuperFastHash (const char *data, size_t len) /* A modified version to do a case-insensitive hash */ #undef get16bits -#define get16bits(d) ((((DWORD)tolower(((const BYTE *)(d))[1])) << 8)\ - +(DWORD)tolower(((const BYTE *)(d))[0]) ) +#define get16bits(d) ((((uint32_t)tolower(((const uint8_t *)(d))[1])) << 8)\ + +(uint32_t)tolower(((const uint8_t *)(d))[0]) ) -DWORD SuperFastHashI (const char *data, size_t len) +uint32_t SuperFastHashI (const char *data, size_t len) { - DWORD hash = 0, tmp; + uint32_t hash = 0, tmp; size_t rem; if (len <= 0 || data == NULL) return 0; @@ -371,7 +371,7 @@ DWORD SuperFastHashI (const char *data, size_t len) hash += get16bits (data); tmp = (get16bits (data+2) << 11) ^ hash; hash = (hash << 16) ^ tmp; - data += 2*sizeof (WORD); + data += 2*sizeof (uint16_t); hash += hash >> 11; } @@ -380,7 +380,7 @@ DWORD SuperFastHashI (const char *data, size_t len) { case 3: hash += get16bits (data); hash ^= hash << 16; - hash ^= tolower(data[sizeof (WORD)]) << 18; + hash ^= tolower(data[sizeof (uint16_t)]) << 18; hash += hash >> 11; break; case 2: hash += get16bits (data); @@ -467,7 +467,7 @@ bool FButtonStatus::PressKey (int keynum) } Keys[open] = keynum; } - BYTE wasdown = bDown; + uint8_t wasdown = bDown; bDown = bWentDown = true; // Returns true if this key caused the button to go down. return !wasdown; @@ -476,7 +476,7 @@ bool FButtonStatus::PressKey (int keynum) bool FButtonStatus::ReleaseKey (int keynum) { int i, numdown, match; - BYTE wasdown = bDown; + uint8_t wasdown = bDown; keynum &= KEY_DBLCLICKED-1; diff --git a/src/c_dispatch.h b/src/c_dispatch.h index d85b2a116..68d623351 100644 --- a/src/c_dispatch.h +++ b/src/c_dispatch.h @@ -152,7 +152,7 @@ struct FButtonStatus { enum { MAX_KEYS = 6 }; // Maximum number of keys that can press this button - WORD Keys[MAX_KEYS]; + uint16_t Keys[MAX_KEYS]; BYTE bDown; // Button is down right now BYTE bWentDown; // Button went down this tic BYTE bWentUp; // Button went up this tic diff --git a/src/c_expr.cpp b/src/c_expr.cpp index 0fc20f68f..4d1668266 100644 --- a/src/c_expr.cpp +++ b/src/c_expr.cpp @@ -656,7 +656,7 @@ FProduction *ProdNeqStr (FStringProd *prod1, FStringProd *prod2) FProduction *ProdXorDbl (FDoubleProd *prod1, FDoubleProd *prod2) { - return NewDoubleProd ((double)((SQWORD)prod1->Value ^ (SQWORD)prod2->Value)); + return NewDoubleProd ((double)((int64_t)prod1->Value ^ (int64_t)prod2->Value)); } //========================================================================== @@ -667,7 +667,7 @@ FProduction *ProdXorDbl (FDoubleProd *prod1, FDoubleProd *prod2) FProduction *ProdAndDbl (FDoubleProd *prod1, FDoubleProd *prod2) { - return NewDoubleProd ((double)((SQWORD)prod1->Value & (SQWORD)prod2->Value)); + return NewDoubleProd ((double)((int64_t)prod1->Value & (int64_t)prod2->Value)); } //========================================================================== @@ -678,7 +678,7 @@ FProduction *ProdAndDbl (FDoubleProd *prod1, FDoubleProd *prod2) FProduction *ProdOrDbl (FDoubleProd *prod1, FDoubleProd *prod2) { - return NewDoubleProd ((double)((SQWORD)prod1->Value | (SQWORD)prod2->Value)); + return NewDoubleProd ((double)((int64_t)prod1->Value | (int64_t)prod2->Value)); } //========================================================================== @@ -689,7 +689,7 @@ FProduction *ProdOrDbl (FDoubleProd *prod1, FDoubleProd *prod2) FProduction *ProdLAndDbl (FDoubleProd *prod1, FDoubleProd *prod2) { - return NewDoubleProd ((double)((SQWORD)prod1->Value && (SQWORD)prod2->Value)); + return NewDoubleProd ((double)((int64_t)prod1->Value && (int64_t)prod2->Value)); } //========================================================================== @@ -700,7 +700,7 @@ FProduction *ProdLAndDbl (FDoubleProd *prod1, FDoubleProd *prod2) FProduction *ProdLOrDbl (FDoubleProd *prod1, FDoubleProd *prod2) { - return NewDoubleProd ((double)((SQWORD)prod1->Value || (SQWORD)prod2->Value)); + return NewDoubleProd ((double)((int64_t)prod1->Value || (int64_t)prod2->Value)); } diff --git a/src/colormatcher.cpp b/src/colormatcher.cpp index 895743943..bc0a92128 100644 --- a/src/colormatcher.cpp +++ b/src/colormatcher.cpp @@ -50,7 +50,7 @@ FColorMatcher::FColorMatcher () Pal = NULL; } -FColorMatcher::FColorMatcher (const DWORD *palette) +FColorMatcher::FColorMatcher (const uint32_t *palette) { SetPalette (palette); } @@ -66,7 +66,7 @@ FColorMatcher &FColorMatcher::operator= (const FColorMatcher &other) return *this; } -void FColorMatcher::SetPalette (const DWORD *palette) +void FColorMatcher::SetPalette (const uint32_t *palette) { Pal = (const PalEntry *)palette; } diff --git a/src/colormatcher.h b/src/colormatcher.h index 5fbe162de..e605fe055 100644 --- a/src/colormatcher.h +++ b/src/colormatcher.h @@ -38,12 +38,12 @@ class FColorMatcher { public: FColorMatcher (); - FColorMatcher (const DWORD *palette); + FColorMatcher (const uint32_t *palette); FColorMatcher (const FColorMatcher &other); - void SetPalette (const DWORD *palette); - BYTE Pick (int r, int g, int b); - BYTE Pick (PalEntry pe) + void SetPalette (const uint32_t *palette); + uint8_t Pick (int r, int g, int b); + uint8_t Pick (PalEntry pe) { return Pick(pe.r, pe.g, pe.b); } diff --git a/src/compatibility.cpp b/src/compatibility.cpp index 951f9e473..f47ea9a96 100644 --- a/src/compatibility.cpp +++ b/src/compatibility.cpp @@ -61,7 +61,7 @@ struct FCompatOption { const char *Name; - DWORD CompatFlags; + uint32_t CompatFlags; int WhichSlot; }; @@ -637,7 +637,7 @@ void SetCompatibilityParams() CCMD (mapchecksum) { MapData *map; - BYTE cksum[16]; + uint8_t cksum[16]; if (argv.argc() < 2) { diff --git a/src/compatibility.h b/src/compatibility.h index b2fbec681..2c33e962e 100644 --- a/src/compatibility.h +++ b/src/compatibility.h @@ -8,7 +8,7 @@ union FMD5Holder { BYTE Bytes[16]; - DWORD DWords[4]; + uint32_t DWords[4]; hash_t Hash; }; diff --git a/src/configfile.cpp b/src/configfile.cpp index 3adbd3761..146fefdfc 100644 --- a/src/configfile.cpp +++ b/src/configfile.cpp @@ -871,7 +871,7 @@ const char *FConfigFile::GenerateEndTag(const char *value) for (int i = 0; i < 5; ++i) { - //DWORD three_bytes = (rand_bytes[i*3] << 16) | (rand_bytes[i*3+1] << 8) | (rand_bytes[i*3+2]); // ??? + //uint32_t three_bytes = (rand_bytes[i*3] << 16) | (rand_bytes[i*3+1] << 8) | (rand_bytes[i*3+2]); // ??? EndTag[4+i*4 ] = Base64Table[rand_bytes[i*3] >> 2]; EndTag[4+i*4+1] = Base64Table[((rand_bytes[i*3] & 3) << 4) | (rand_bytes[i*3+1] >> 4)]; EndTag[4+i*4+2] = Base64Table[((rand_bytes[i*3+1] & 15) << 2) | (rand_bytes[i*3+2] >> 6)]; diff --git a/src/ct_chat.cpp b/src/ct_chat.cpp index 9d54a5991..98e95cdde 100644 --- a/src/ct_chat.cpp +++ b/src/ct_chat.cpp @@ -61,11 +61,11 @@ int chatmodeon; static void CT_ClearChatMessage (); static void CT_AddChar (char c); static void CT_BackSpace (); -static void ShoveChatStr (const char *str, BYTE who); +static void ShoveChatStr (const char *str, uint8_t who); static bool DoSubstitution (FString &out, const char *in); static int len; -static BYTE ChatQueue[QUEUESIZE]; +static uint8_t ChatQueue[QUEUESIZE]; CVAR (String, chatmacro1, "I'm ready to kick butt!", CVAR_ARCHIVE) CVAR (String, chatmacro2, "I'm OK.", CVAR_ARCHIVE) @@ -353,7 +353,7 @@ static void CT_ClearChatMessage () // //=========================================================================== -static void ShoveChatStr (const char *str, BYTE who) +static void ShoveChatStr (const char *str, uint8_t who) { // Don't send empty messages if (str == NULL || str[0] == '\0') diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 7e2b22e27..a4ff314a7 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -129,8 +129,8 @@ static TArray InfoNames; struct BitName { char Name[20]; - BYTE Bit; - BYTE WhichFlags; + uint8_t Bit; + uint8_t WhichFlags; }; static TArray BitNames; @@ -139,7 +139,7 @@ static TArray BitNames; struct StyleName { char Name[20]; - BYTE Num; + uint8_t Num; }; static TArray StyleNames; @@ -160,7 +160,7 @@ struct CodePointerAlias { FName name; char alias[20]; - BYTE params; + uint8_t params; }; static TArray MBFCodePointers; @@ -391,7 +391,7 @@ static bool HandleKey (const struct Key *keys, void *structure, const char *key, keys++; if (keys->name) { - *((int *)(((BYTE *)structure) + keys->offset)) = value; + *((int *)(((uint8_t *)structure) + keys->offset)) = value; return false; } @@ -401,11 +401,11 @@ static bool HandleKey (const struct Key *keys, void *structure, const char *key, static int FindSprite (const char *sprname) { int i; - DWORD nameint = *((DWORD *)sprname); + uint32_t nameint = *((uint32_t *)sprname); for (i = 0; i < NumUnchangedSprites; ++i) { - if (*((DWORD *)&UnchangedSpriteNames[i*4]) == nameint) + if (*((uint32_t *)&UnchangedSpriteNames[i*4]) == nameint) { return i; } @@ -842,7 +842,7 @@ static int PatchThing (int thingy) int result; AActor *info; - BYTE dummy[sizeof(AActor)]; + uint8_t dummy[sizeof(AActor)]; bool hadHeight = false; bool hadTranslucency = false; bool hadStyle = false; @@ -850,7 +850,7 @@ static int PatchThing (int thingy) bool patchedStates = false; ActorFlags oldflags; PClassActor *type; - SWORD *ednum, dummyed; + int16_t *ednum, dummyed; type = NULL; info = (AActor *)&dummy; @@ -898,7 +898,7 @@ static int PatchThing (int thingy) } else if (linelen == 11 && stricmp (Line1, "Pain chance") == 0) { - info->PainChance = (SWORD)val; + info->PainChance = (int16_t)val; } else if (linelen == 12 && stricmp (Line1, "Translucency") == 0) { @@ -1049,7 +1049,7 @@ static int PatchThing (int thingy) } else if (stricmp (Line1, "Bits") == 0) { - DWORD value[4] = { 0, 0, 0 }; + uint32_t value[4] = { 0, 0, 0 }; bool vchanged[4] = { false, false, false }; // ZDoom used to block the upper range of bits to force use of mnemonics for extra flags. // MBF also defined extra flags in the same range, but without forcing mnemonics. For MBF @@ -1244,7 +1244,7 @@ static int PatchThing (int thingy) } else if (stricmp (Line1, "ID #") == 0) { - *ednum = (SWORD)val; + *ednum = (int16_t)val; } } else Printf (unknown_str, Line1, "Thing", thingy); @@ -1605,7 +1605,7 @@ static int PatchWeapon (int weapNum) { int result; PClassActor *type = NULL; - BYTE dummy[sizeof(AWeapon)]; + uint8_t dummy[sizeof(AWeapon)]; AWeapon *info = (AWeapon *)&dummy; bool patchedStates = false; FStateDefinitions statedef; @@ -1917,7 +1917,7 @@ static int PatchMisc (int dummy) else if (a > 0) { GetDefaultByName (types[i])->ColorVar(NAME_BlendColor) = PalEntry( - BYTE(clamp(a,0.f,1.f)*255.f), + uint8_t(clamp(a,0.f,1.f)*255.f), clamp(r,0,255), clamp(g,0,255), clamp(b,0,255)); @@ -2111,7 +2111,7 @@ static int PatchCodePtrs (int dummy) } else { - TArray &args = sym->Variants[0].ArgFlags; + TArray &args = sym->Variants[0].ArgFlags; unsigned numargs = sym->GetImplicitArgs(); if ((sym->Variants[0].Flags & VARF_Virtual || (args.Size() > numargs && !(args[numargs] & VARF_Optional)))) { @@ -2592,9 +2592,9 @@ static bool DoDehPatch() return true; } -static inline bool CompareLabel (const char *want, const BYTE *have) +static inline bool CompareLabel (const char *want, const uint8_t *have) { - return *(DWORD *)want == *(DWORD *)have; + return *(uint32_t *)want == *(uint32_t *)have; } static int DehUseCount; @@ -2724,7 +2724,7 @@ static bool LoadDehSupp () } else { - TArray &args = sym->Variants[0].ArgFlags; + TArray &args = sym->Variants[0].ArgFlags; unsigned numargs = sym->GetImplicitArgs(); if ((sym->Variants[0].Flags & VARF_Virtual || (args.Size() > numargs && !(args[numargs] & VARF_Optional)))) { diff --git a/src/d_event.h b/src/d_event.h index 962286b8f..5b7d202a4 100644 --- a/src/d_event.h +++ b/src/d_event.h @@ -45,11 +45,11 @@ enum EGenericEvent // Event structure. struct event_t { - BYTE type; - BYTE subtype; - SWORD data1; // keys / mouse/joystick buttons - SWORD data2; - SWORD data3; + uint8_t type; + uint8_t subtype; + int16_t data1; // keys / mouse/joystick buttons + int16_t data2; + int16_t data3; int x; // mouse/joystick x move int y; // mouse/joystick y move }; diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index b80cbaf98..2a8504dc1 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -261,7 +261,7 @@ void FIWadManager::ParseIWadInfos(const char *fn) FResourceFile *resfile = FResourceFile::OpenResourceFile(fn, NULL, true); if (resfile != NULL) { - DWORD cnt = resfile->LumpCount(); + uint32_t cnt = resfile->LumpCount(); for(int i=cnt-1; i>=0; i--) { FResourceLump *lmp = resfile->GetLump(i); @@ -296,7 +296,7 @@ int FIWadManager::ScanIWAD (const char *iwad) if (iwadfile != NULL) { ClearChecks(); - for(DWORD ii = 0; ii < iwadfile->LumpCount(); ii++) + for(uint32_t ii = 0; ii < iwadfile->LumpCount(); ii++) { FResourceLump *lump = iwadfile->GetLump(ii); diff --git a/src/d_main.cpp b/src/d_main.cpp index 6edb61601..0da9cfdad 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -388,14 +388,14 @@ CUSTOM_CVAR (Int, dmflags, 0, CVAR_SERVERINFO) // If nofov is set, force everybody to the arbitrator's FOV. if ((self & DF_NO_FOV) && consoleplayer == Net_Arbitrator) { - BYTE fov; + uint8_t fov; Net_WriteByte (DEM_FOV); // If the game is started with DF_NO_FOV set, the arbitrator's // DesiredFOV will not be set when this callback is run, so // be sure not to transmit a 0 FOV. - fov = (BYTE)players[consoleplayer].DesiredFOV; + fov = (uint8_t)players[consoleplayer].DesiredFOV; if (fov == 0) { fov = 90; @@ -1936,7 +1936,7 @@ static FString CheckGameInfo(TArray & pwads) if (resfile != NULL) { - DWORD cnt = resfile->LumpCount(); + uint32_t cnt = resfile->LumpCount(); for(int i=cnt-1; i>=0; i--) { FResourceLump *lmp = resfile->GetLump(i); diff --git a/src/d_main.h b/src/d_main.h index 0bcf73a20..034c263c7 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -77,8 +77,8 @@ struct FIWADInfo FString Autoname; // Name of autoload ini section for this IWAD FString Configname; // Name of config section for this IWAD FString Required; // Requires another IWAD - DWORD FgColor; // Foreground color for title banner - DWORD BkColor; // Background color for title banner + uint32_t FgColor; // Foreground color for title banner + uint32_t BkColor; // Background color for title banner EGameType gametype; // which game are we playing? FString MapInfo; // Base mapinfo to load TArray Load; // Wads to be loaded with this one. @@ -92,8 +92,8 @@ struct FIWADInfo struct FStartupInfo { FString Name; - DWORD FgColor; // Foreground color for title banner - DWORD BkColor; // Background color for title banner + uint32_t FgColor; // Foreground color for title banner + uint32_t BkColor; // Background color for title banner FString Song; int Type; enum diff --git a/src/d_net.cpp b/src/d_net.cpp index 1dfa17116..f505285c2 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -72,7 +72,7 @@ EXTERN_CVAR (Int, autosavecount) //#define SIMULATEERRORS (RAND_MAX/3) #define SIMULATEERRORS 0 -extern BYTE *demo_p; // [RH] Special "ticcmds" get recorded in demos +extern uint8_t *demo_p; // [RH] Special "ticcmds" get recorded in demos extern FString savedescription; extern FString savegamefile; @@ -82,7 +82,7 @@ doomcom_t doomcom; #define netbuffer (doomcom.data) enum { NET_PeerToPeer, NET_PacketServer }; -BYTE NetMode = NET_PeerToPeer; +uint8_t NetMode = NET_PeerToPeer; @@ -127,11 +127,11 @@ void D_ProcessEvents (void); void G_BuildTiccmd (ticcmd_t *cmd); void D_DoAdvanceDemo (void); -static void SendSetup (DWORD playersdetected[MAXNETNODES], BYTE gotsetup[MAXNETNODES], int len); -static void RunScript(BYTE **stream, APlayerPawn *pawn, int snum, int argn, int always); +static void SendSetup (uint32_t playersdetected[MAXNETNODES], uint8_t gotsetup[MAXNETNODES], int len); +static void RunScript(uint8_t **stream, APlayerPawn *pawn, int snum, int argn, int always); int reboundpacket; -BYTE reboundstore[MAX_MSGLEN]; +uint8_t reboundstore[MAX_MSGLEN]; int frameon; int frameskip[4]; @@ -185,9 +185,9 @@ static TArray OutBuffer; // [RH] Special "ticcmds" get stored in here static struct TicSpecial { - BYTE *streams[BACKUPTICS]; + uint8_t *streams[BACKUPTICS]; size_t used[BACKUPTICS]; - BYTE *streamptr; + uint8_t *streamptr; size_t streamoffs; size_t specialsize; int lastmaketic; @@ -205,7 +205,7 @@ static struct TicSpecial for (i = 0; i < BACKUPTICS; i++) { - streams[i] = (BYTE *)M_Malloc (256); + streams[i] = (uint8_t *)M_Malloc (256); used[i] = 0; } okay = true; @@ -237,7 +237,7 @@ static struct TicSpecial DPrintf (DMSG_NOTIFY, "Expanding special size to %zu\n", specialsize); for (i = 0; i < BACKUPTICS; i++) - streams[i] = (BYTE *)M_Realloc (streams[i], specialsize); + streams[i] = (uint8_t *)M_Realloc (streams[i], specialsize); streamptr = streams[(maketic/ticdup)%BACKUPTICS] + streamoffs; } @@ -265,7 +265,7 @@ static struct TicSpecial streamoffs = 0; } - TicSpecial &operator << (BYTE it) + TicSpecial &operator << (uint8_t it) { if (streamptr) { @@ -399,7 +399,7 @@ int NetbufferSize () return k + 3 * count * numtics; } - BYTE *skipper = &netbuffer[k]; + uint8_t *skipper = &netbuffer[k]; if ((netbuffer[0] & NCMD_EXIT) == 0) { while (count-- > 0) @@ -446,13 +446,13 @@ void HSendPacket (int node, int len) { fprintf (debugfile,"%i/%i send %i = SETUP [%3i]", gametic, maketic, node, len); for (i = 0; i < len; i++) - fprintf (debugfile," %2x", ((BYTE *)netbuffer)[i]); + fprintf (debugfile," %2x", ((uint8_t *)netbuffer)[i]); } else if (netbuffer[0] & NCMD_EXIT) { fprintf (debugfile,"%i/%i send %i = EXIT [%3i]", gametic, maketic, node, len); for (i = 0; i < len; i++) - fprintf (debugfile," %2x", ((BYTE *)netbuffer)[i]); + fprintf (debugfile," %2x", ((uint8_t *)netbuffer)[i]); } else { @@ -480,7 +480,7 @@ void HSendPacket (int node, int len) numtics, realretrans, len); for (i = 0; i < len; i++) - fprintf (debugfile, "%c%2x", i==k?'|':' ', ((BYTE *)netbuffer)[i]); + fprintf (debugfile, "%c%2x", i==k?'|':' ', ((uint8_t *)netbuffer)[i]); } fprintf (debugfile, " [[ "); for (i = 0; i < doomcom.numnodes; ++i) @@ -613,14 +613,14 @@ bool HGetPacket (void) { fprintf (debugfile,"%i/%i get %i = SETUP [%3i]", gametic, maketic, doomcom.remotenode, doomcom.datalength); for (i = 0; i < doomcom.datalength; i++) - fprintf (debugfile, " %2x", ((BYTE *)netbuffer)[i]); + fprintf (debugfile, " %2x", ((uint8_t *)netbuffer)[i]); fprintf (debugfile, "\n"); } else if (netbuffer[0] & NCMD_EXIT) { fprintf (debugfile,"%i/%i get %i = EXIT [%3i]", gametic, maketic, doomcom.remotenode, doomcom.datalength); for (i = 0; i < doomcom.datalength; i++) - fprintf (debugfile, " %2x", ((BYTE *)netbuffer)[i]); + fprintf (debugfile, " %2x", ((uint8_t *)netbuffer)[i]); fprintf (debugfile, "\n"); } else { @@ -648,7 +648,7 @@ bool HGetPacket (void) numtics, realretrans, doomcom.datalength); for (i = 0; i < doomcom.datalength; i++) - fprintf (debugfile, "%c%2x", i==k?'|':' ', ((BYTE *)netbuffer)[i]); + fprintf (debugfile, "%c%2x", i==k?'|':' ', ((uint8_t *)netbuffer)[i]); if (numtics) fprintf (debugfile, " <<%4x>>\n", consistancy[playerfornode[doomcom.remotenode]][nettics[doomcom.remotenode]%BACKUPTICS] & 0xFFFF); @@ -740,7 +740,7 @@ void PlayerIsGone (int netnode, int netconsole) G_CheckDemoStatus (); //WriteByte (DEM_DROPPLAYER, &demo_p); - //WriteByte ((BYTE)netconsole, &demo_p); + //WriteByte ((uint8_t)netconsole, &demo_p); } } @@ -757,7 +757,7 @@ void GetPackets (void) int numtics; int retransmitfrom; int k; - BYTE playerbytes[MAXNETNODES]; + uint8_t playerbytes[MAXNETNODES]; int numplayers; while ( HGetPacket() ) @@ -792,7 +792,7 @@ void GetPackets (void) PlayerIsGone (netnode, netconsole); if (NetMode == NET_PacketServer) { - BYTE *foo = &netbuffer[2]; + uint8_t *foo = &netbuffer[2]; for (int i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i]) @@ -908,7 +908,7 @@ void GetPackets (void) // update command store from the packet { - BYTE *start; + uint8_t *start; int i, tics; remoteresend[netnode] = false; @@ -942,7 +942,7 @@ void NetUpdate (void) int newtics; int i,j; int realstart; - BYTE *cmddata; + uint8_t *cmddata; bool resendOnly; GC::CheckGC(); @@ -1120,7 +1120,7 @@ void NetUpdate (void) for (i = 0; i < doomcom.numnodes; i++) { - BYTE playerbytes[MAXPLAYERS]; + uint8_t playerbytes[MAXPLAYERS]; if (!nodeingame[i]) { @@ -1265,7 +1265,7 @@ void NetUpdate (void) else if (i != 0) { int len; - BYTE *spec; + uint8_t *spec; WriteWord (netcmds[playerbytes[l]][start].consistancy, &cmddata); spec = NetSpecs[playerbytes[l]][start].GetData (&len); @@ -1405,15 +1405,15 @@ void NetUpdate (void) struct ArbitrateData { - DWORD playersdetected[MAXNETNODES]; - BYTE gotsetup[MAXNETNODES]; + uint32_t playersdetected[MAXNETNODES]; + uint8_t gotsetup[MAXNETNODES]; }; bool DoArbitrate (void *userdata) { ArbitrateData *data = (ArbitrateData *)userdata; char *s; - BYTE *stream; + uint8_t *stream; int version; int node; int i, j; @@ -1490,7 +1490,7 @@ bool DoArbitrate (void *userdata) if (consoleplayer == Net_Arbitrator) { for (i = 0; i < doomcom.numnodes; ++i) - if (data->playersdetected[i] != DWORD(1 << doomcom.numnodes) - 1 || !data->gotsetup[i]) + if (data->playersdetected[i] != uint32_t(1 << doomcom.numnodes) - 1 || !data->gotsetup[i]) break; if (i == doomcom.numnodes) @@ -1537,7 +1537,7 @@ bool DoArbitrate (void *userdata) if (consoleplayer == Net_Arbitrator) { netbuffer[0] = NCMD_SETUP+2; - netbuffer[1] = (BYTE)doomcom.ticdup; + netbuffer[1] = (uint8_t)doomcom.ticdup; netbuffer[2] = NetMode; stream = &netbuffer[3]; WriteString (startmap, &stream); @@ -1631,7 +1631,7 @@ void D_ArbitrateNetStart (void) StartScreen->NetDone(); } -static void SendSetup (DWORD playersdetected[MAXNETNODES], BYTE gotsetup[MAXNETNODES], int len) +static void SendSetup (uint32_t playersdetected[MAXNETNODES], uint8_t gotsetup[MAXNETNODES], int len) { if (consoleplayer != Net_Arbitrator) { @@ -1769,7 +1769,7 @@ void D_QuitNetGame (void) k = 2; if (NetMode == NET_PacketServer && consoleplayer == Net_Arbitrator) { - BYTE *foo = &netbuffer[2]; + uint8_t *foo = &netbuffer[2]; // Let the new arbitrator know what resendto counts to use @@ -1998,7 +1998,7 @@ void Net_NewMakeTic (void) specials.NewMakeTic (); } -void Net_WriteByte (BYTE it) +void Net_WriteByte (uint8_t it) { specials << it; } @@ -2023,7 +2023,7 @@ void Net_WriteString (const char *it) specials << it; } -void Net_WriteBytes (const BYTE *block, int len) +void Net_WriteBytes (const uint8_t *block, int len) { while (len--) specials << *block++; @@ -2051,12 +2051,12 @@ FDynamicBuffer::~FDynamicBuffer () m_Len = m_BufferLen = 0; } -void FDynamicBuffer::SetData (const BYTE *data, int len) +void FDynamicBuffer::SetData (const uint8_t *data, int len) { if (len > m_BufferLen) { m_BufferLen = (len + 255) & ~255; - m_Data = (BYTE *)M_Realloc (m_Data, m_BufferLen); + m_Data = (uint8_t *)M_Realloc (m_Data, m_BufferLen); } if (data != NULL) { @@ -2069,7 +2069,7 @@ void FDynamicBuffer::SetData (const BYTE *data, int len) } } -BYTE *FDynamicBuffer::GetData (int *len) +uint8_t *FDynamicBuffer::GetData (int *len) { if (len) *len = m_Len; @@ -2128,9 +2128,9 @@ static int RemoveClass(const PClass *cls) // [RH] Execute a special "ticcmd". The type byte should // have already been read, and the stream is positioned // at the beginning of the command's actual data. -void Net_DoCommand (int type, BYTE **stream, int player) +void Net_DoCommand (int type, uint8_t **stream, int player) { - BYTE pos = 0; + uint8_t pos = 0; char *s = NULL; int i; @@ -2139,7 +2139,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) case DEM_SAY: { const char *name = players[player].userinfo.GetName(); - BYTE who = ReadByte (stream); + uint8_t who = ReadByte (stream); s = ReadString (stream); CleanseString (s); @@ -2270,7 +2270,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) case DEM_INVUSE: case DEM_INVDROP: { - DWORD which = ReadLong (stream); + uint32_t which = ReadLong (stream); int amt = -1; if (type == DEM_INVDROP) amt = ReadLong(stream); @@ -2308,8 +2308,8 @@ void Net_DoCommand (int type, BYTE **stream, int player) { PClassActor *typeinfo; int angle = 0; - SWORD tid = 0; - BYTE special = 0; + int16_t tid = 0; + uint8_t special = 0; int args[5]; s = ReadString (stream); @@ -2540,7 +2540,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) case DEM_ADDCONTROLLER: { - BYTE playernum = ReadByte (stream); + uint8_t playernum = ReadByte (stream); players[playernum].settings_controller = true; if (consoleplayer == playernum || consoleplayer == Net_Arbitrator) @@ -2550,7 +2550,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) case DEM_DELCONTROLLER: { - BYTE playernum = ReadByte (stream); + uint8_t playernum = ReadByte (stream); players[playernum].settings_controller = false; if (consoleplayer == playernum || consoleplayer == Net_Arbitrator) @@ -2691,7 +2691,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) } // Used by DEM_RUNSCRIPT, DEM_RUNSCRIPT2, and DEM_RUNNAMEDSCRIPT -static void RunScript(BYTE **stream, APlayerPawn *pawn, int snum, int argn, int always) +static void RunScript(uint8_t **stream, APlayerPawn *pawn, int snum, int argn, int always) { int arg[4] = { 0, 0, 0, 0 }; int i; @@ -2707,9 +2707,9 @@ static void RunScript(BYTE **stream, APlayerPawn *pawn, int snum, int argn, int P_StartScript(pawn, NULL, snum, level.MapName, arg, MIN(countof(arg), argn), ACS_NET | always); } -void Net_SkipCommand (int type, BYTE **stream) +void Net_SkipCommand (int type, uint8_t **stream) { - BYTE t; + uint8_t t; size_t skip; switch (type) diff --git a/src/d_net.h b/src/d_net.h index e1e4360a2..def8dee06 100644 --- a/src/d_net.h +++ b/src/d_net.h @@ -59,31 +59,31 @@ // struct doomcom_t { - DWORD id; // should be DOOMCOM_ID - SWORD intnum; // DOOM executes an int to execute commands + uint32_t id; // should be DOOMCOM_ID + int16_t intnum; // DOOM executes an int to execute commands // communication between DOOM and the driver - SWORD command; // CMD_SEND or CMD_GET - SWORD remotenode; // dest for send, set by get (-1 = no packet). - SWORD datalength; // bytes in doomdata to be sent + int16_t command; // CMD_SEND or CMD_GET + int16_t remotenode; // dest for send, set by get (-1 = no packet). + int16_t datalength; // bytes in doomdata to be sent // info common to all nodes - SWORD numnodes; // console is always node 0. - SWORD ticdup; // 1 = no duplication, 2-5 = dup for slow nets + int16_t numnodes; // console is always node 0. + int16_t ticdup; // 1 = no duplication, 2-5 = dup for slow nets #ifdef DJGPP - SWORD pad[5]; // keep things aligned for DOS drivers + int16_t pad[5]; // keep things aligned for DOS drivers #endif // info specific to this node - SWORD consoleplayer; - SWORD numplayers; + int16_t consoleplayer; + int16_t numplayers; #ifdef DJGPP - SWORD angleoffset; // does not work, but needed to preserve - SWORD drone; // alignment for DOS drivers + int16_t angleoffset; // does not work, but needed to preserve + int16_t drone; // alignment for DOS drivers #endif // packet data to be sent - BYTE data[MAX_MSGLEN]; + uint8_t data[MAX_MSGLEN]; }; @@ -94,11 +94,11 @@ public: FDynamicBuffer (); ~FDynamicBuffer (); - void SetData (const BYTE *data, int len); - BYTE *GetData (int *len = NULL); + void SetData (const uint8_t *data, int len); + uint8_t *GetData (int *len = NULL); private: - BYTE *m_Data; + uint8_t *m_Data; int m_Len, m_BufferLen; }; @@ -119,15 +119,15 @@ void Net_CheckLastReceived(int); // [RH] Functions for making and using special "ticcmds" void Net_NewMakeTic (); -void Net_WriteByte (BYTE); +void Net_WriteByte (uint8_t); void Net_WriteWord (short); void Net_WriteLong (int); void Net_WriteFloat (float); void Net_WriteString (const char *); -void Net_WriteBytes (const BYTE *, int len); +void Net_WriteBytes (const uint8_t *, int len); -void Net_DoCommand (int type, BYTE **stream, int player); -void Net_SkipCommand (int type, BYTE **stream); +void Net_DoCommand (int type, uint8_t **stream, int player); +void Net_SkipCommand (int type, uint8_t **stream); void Net_ClearBuffers (); diff --git a/src/d_netinfo.cpp b/src/d_netinfo.cpp index 8a856b44b..5c4b24978 100644 --- a/src/d_netinfo.cpp +++ b/src/d_netinfo.cpp @@ -228,7 +228,7 @@ void D_PickRandomTeam (int player) { static char teamline[8] = "\\team\\X"; - BYTE *foo = (BYTE *)teamline; + uint8_t *foo = (uint8_t *)teamline; teamline[6] = (char)D_PickRandomTeam() + '0'; D_ReadUserInfoStrings (player, &foo, teamplay); } @@ -538,7 +538,7 @@ void D_UserInfoChanged (FBaseCVar *cvar) Net_WriteString (foo); } -static const char *SetServerVar (char *name, ECVarType type, BYTE **stream, bool singlebit) +static const char *SetServerVar (char *name, ECVarType type, uint8_t **stream, bool singlebit) { FBaseCVar *var = FindCVar (name, NULL); UCVarValue value; @@ -619,8 +619,8 @@ void D_SendServerInfoChange (const FBaseCVar *cvar, UCVarValue value, ECVarType namelen = strlen (cvar->GetName ()); Net_WriteByte (DEM_SINFCHANGED); - Net_WriteByte ((BYTE)(namelen | (type << 6))); - Net_WriteBytes ((BYTE *)cvar->GetName (), (int)namelen); + Net_WriteByte ((uint8_t)(namelen | (type << 6))); + Net_WriteBytes ((uint8_t *)cvar->GetName (), (int)namelen); switch (type) { case CVAR_Bool: Net_WriteByte (value.Bool); break; @@ -638,12 +638,12 @@ void D_SendServerFlagChange (const FBaseCVar *cvar, int bitnum, bool set) namelen = (int)strlen (cvar->GetName ()); Net_WriteByte (DEM_SINFCHANGEDXOR); - Net_WriteByte ((BYTE)namelen); - Net_WriteBytes ((BYTE *)cvar->GetName (), namelen); - Net_WriteByte (BYTE(bitnum | (set << 5))); + Net_WriteByte ((uint8_t)namelen); + Net_WriteBytes ((uint8_t *)cvar->GetName (), namelen); + Net_WriteByte (uint8_t(bitnum | (set << 5))); } -void D_DoServerInfoChange (BYTE **stream, bool singlebit) +void D_DoServerInfoChange (uint8_t **stream, bool singlebit) { const char *value; char name[64]; @@ -679,7 +679,7 @@ static int namesortfunc(const void *a, const void *b) return stricmp(name1->GetChars(), name2->GetChars()); } -void D_WriteUserInfoStrings (int pnum, BYTE **stream, bool compact) +void D_WriteUserInfoStrings (int pnum, uint8_t **stream, bool compact) { if (pnum >= MAXPLAYERS) { @@ -741,7 +741,7 @@ void D_WriteUserInfoStrings (int pnum, BYTE **stream, bool compact) *(*stream)++ = '\0'; } -void D_ReadUserInfoStrings (int pnum, BYTE **stream, bool update) +void D_ReadUserInfoStrings (int pnum, uint8_t **stream, bool update) { userinfo_t *info = &players[pnum].userinfo; TArray compact_names(info->CountUsed()); diff --git a/src/d_player.h b/src/d_player.h index 379265cab..031083bbf 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -51,18 +51,18 @@ struct FPlayerColorSet { struct ExtraRange { - BYTE RangeStart, RangeEnd; // colors to remap - BYTE FirstColor, LastColor; // colors to map to + uint8_t RangeStart, RangeEnd; // colors to remap + uint8_t FirstColor, LastColor; // colors to map to }; FName Name; // Name of this color int Lump; // Lump to read the translation from, otherwise use next 2 fields - BYTE FirstColor, LastColor; // Describes the range of colors to use for the translation + uint8_t FirstColor, LastColor; // Describes the range of colors to use for the translation - BYTE RepresentativeColor; // A palette entry representative of this translation, + uint8_t RepresentativeColor; // A palette entry representative of this translation, // for map arrows and status bar backgrounds and such - BYTE NumExtraRanges; + uint8_t NumExtraRanges; ExtraRange Extra[6]; }; @@ -131,8 +131,8 @@ public: int RunHealth; int PlayerFlags; double FullHeight; - TObjPtr InvFirst; // first inventory item displayed on inventory bar - TObjPtr InvSel; // selected inventory item + TObjPtr InvFirst; // first inventory item displayed on inventory bar + TObjPtr InvSel; // selected inventory item // [GRB] Player class properties double JumpZ; @@ -162,8 +162,8 @@ public: FNameNoInit Portrait; FNameNoInit Slot[10]; double HexenArmor[5]; - BYTE ColorRangeStart; // Skin color range - BYTE ColorRangeEnd; + uint8_t ColorRangeStart; // Skin color range + uint8_t ColorRangeEnd; }; @@ -256,7 +256,7 @@ public: bool CheckSkin (int skin); PClassActor *Type; - DWORD Flags; + uint32_t Flags; TArray Skins; }; @@ -383,10 +383,10 @@ public: void SendPitchLimits() const; APlayerPawn *mo; - BYTE playerstate; + uint8_t playerstate; ticcmd_t cmd; usercmd_t original_cmd; - DWORD original_oldbuttons; + uint32_t original_oldbuttons; userinfo_t userinfo; // [RH] who is this? @@ -406,28 +406,28 @@ public: DVector2 Vel; bool centering; - BYTE turnticks; + uint8_t turnticks; bool attackdown; bool usedown; - DWORD oldbuttons; + uint32_t oldbuttons; int health; // only used between levels, mo->health // is used during levels int inventorytics; - BYTE CurrentPlayerClass; // class # for this player instance + uint8_t CurrentPlayerClass; // class # for this player instance int frags[MAXPLAYERS]; // kills of other players int fragcount; // [RH] Cumulative frags for this player int lastkilltime; // [RH] For multikills - BYTE multicount; - BYTE spreecount; // [RH] Keep track of killing sprees - WORD WeaponState; + uint8_t multicount; + uint8_t spreecount; // [RH] Keep track of killing sprees + uint16_t WeaponState; AWeapon *ReadyWeapon; AWeapon *PendingWeapon; // WP_NOCHANGE if not changing - TObjPtr psprites; // view sprites (gun, etc) + TObjPtr psprites; // view sprites (gun, etc) int cheats; // bit flags int timefreezer; // Player has an active time freezer @@ -442,8 +442,8 @@ public: int poisoncount; // screen flash for poison damage FName poisontype; // type of poison damage to apply FName poisonpaintype; // type of Pain state to enter for poison damage - TObjPtr poisoner; // NULL for non-player actors - TObjPtr attacker; // who did damage (NULL for floors) + TObjPtr poisoner; // NULL for non-player actors + TObjPtr attacker; // who did damage (NULL for floors) int extralight; // so gun flashes light up areas short fixedcolormap; // can be set to REDCOLORMAP, etc. short fixedlightlevel; @@ -451,27 +451,27 @@ public: PClassActor *MorphedPlayerClass; // [MH] (for SBARINFO) class # for this player instance when morphed int MorphStyle; // which effects to apply for this player instance when morphed PClassActor *MorphExitFlash; // flash to apply when demorphing (cache of value given to P_MorphPlayer) - TObjPtr PremorphWeapon; // ready weapon before morphing + TObjPtr PremorphWeapon; // ready weapon before morphing int chickenPeck; // chicken peck countdown int jumpTics; // delay the next jump for a moment bool onground; // Identifies if this player is on the ground or other object int respawn_time; // [RH] delay respawning until this tic - TObjPtr camera; // [RH] Whose eyes this player sees through + TObjPtr camera; // [RH] Whose eyes this player sees through int air_finished; // [RH] Time when you start drowning FName LastDamageType; // [RH] For damage-specific pain and death sounds - TObjPtr MUSINFOactor; // For MUSINFO purposes - SBYTE MUSINFOtics; + TObjPtr MUSINFOactor; // For MUSINFO purposes + int8_t MUSINFOtics; bool settings_controller; // Player can control game settings. - SBYTE crouching; - SBYTE crouchdir; + int8_t crouching; + int8_t crouchdir; //Added by MC: - TObjPtr Bot; + TObjPtr Bot; float BlendR; // [RH] Final blending values float BlendG; @@ -490,7 +490,7 @@ public: FWeaponSlots weapons; // [CW] I moved these here for multiplayer conversation support. - TObjPtr ConversationNPC, ConversationPC; + TObjPtr ConversationNPC, ConversationPC; DAngle ConversationNPCAngle; bool ConversationFaceTalker; diff --git a/src/d_protocol.cpp b/src/d_protocol.cpp index 6d7200f8c..36ec2cab2 100644 --- a/src/d_protocol.cpp +++ b/src/d_protocol.cpp @@ -41,7 +41,7 @@ #include "serializer.h" -char *ReadString (BYTE **stream) +char *ReadString (uint8_t **stream) { char *string = *((char **)stream); @@ -49,35 +49,35 @@ char *ReadString (BYTE **stream) return copystring (string); } -const char *ReadStringConst(BYTE **stream) +const char *ReadStringConst(uint8_t **stream) { const char *string = *((const char **)stream); *stream += strlen (string) + 1; return string; } -int ReadByte (BYTE **stream) +int ReadByte (uint8_t **stream) { - BYTE v = **stream; + uint8_t v = **stream; *stream += 1; return v; } -int ReadWord (BYTE **stream) +int ReadWord (uint8_t **stream) { short v = (((*stream)[0]) << 8) | (((*stream)[1])); *stream += 2; return v; } -int ReadLong (BYTE **stream) +int ReadLong (uint8_t **stream) { int v = (((*stream)[0]) << 24) | (((*stream)[1]) << 16) | (((*stream)[2]) << 8) | (((*stream)[3])); *stream += 4; return v; } -float ReadFloat (BYTE **stream) +float ReadFloat (uint8_t **stream) { union { @@ -88,7 +88,7 @@ float ReadFloat (BYTE **stream) return fakeint.f; } -void WriteString (const char *string, BYTE **stream) +void WriteString (const char *string, uint8_t **stream) { char *p = *((char **)stream); @@ -97,24 +97,24 @@ void WriteString (const char *string, BYTE **stream) } *p++ = 0; - *stream = (BYTE *)p; + *stream = (uint8_t *)p; } -void WriteByte (BYTE v, BYTE **stream) +void WriteByte (uint8_t v, uint8_t **stream) { **stream = v; *stream += 1; } -void WriteWord (short v, BYTE **stream) +void WriteWord (short v, uint8_t **stream) { (*stream)[0] = v >> 8; (*stream)[1] = v & 255; *stream += 2; } -void WriteLong (int v, BYTE **stream) +void WriteLong (int v, uint8_t **stream) { (*stream)[0] = v >> 24; (*stream)[1] = (v >> 16) & 255; @@ -123,7 +123,7 @@ void WriteLong (int v, BYTE **stream) *stream += 4; } -void WriteFloat (float v, BYTE **stream) +void WriteFloat (float v, uint8_t **stream) { union { @@ -135,10 +135,10 @@ void WriteFloat (float v, BYTE **stream) } // Returns the number of bytes read -int UnpackUserCmd (usercmd_t *ucmd, const usercmd_t *basis, BYTE **stream) +int UnpackUserCmd (usercmd_t *ucmd, const usercmd_t *basis, uint8_t **stream) { - BYTE *start = *stream; - BYTE flags; + uint8_t *start = *stream; + uint8_t flags; if (basis != NULL) { @@ -159,8 +159,8 @@ int UnpackUserCmd (usercmd_t *ucmd, const usercmd_t *basis, BYTE **stream) // We can support up to 29 buttons, using from 0 to 4 bytes to store them. if (flags & UCMDF_BUTTONS) { - DWORD buttons = ucmd->buttons; - BYTE in = ReadByte(stream); + uint32_t buttons = ucmd->buttons; + uint8_t in = ReadByte(stream); buttons = (buttons & ~0x7F) | (in & 0x7F); if (in & 0x80) @@ -198,13 +198,13 @@ int UnpackUserCmd (usercmd_t *ucmd, const usercmd_t *basis, BYTE **stream) } // Returns the number of bytes written -int PackUserCmd (const usercmd_t *ucmd, const usercmd_t *basis, BYTE **stream) +int PackUserCmd (const usercmd_t *ucmd, const usercmd_t *basis, uint8_t **stream) { - BYTE flags = 0; - BYTE *temp = *stream; - BYTE *start = *stream; + uint8_t flags = 0; + uint8_t *temp = *stream; + uint8_t *start = *stream; usercmd_t blank; - DWORD buttons_changed; + uint32_t buttons_changed; if (basis == NULL) { @@ -217,10 +217,10 @@ int PackUserCmd (const usercmd_t *ucmd, const usercmd_t *basis, BYTE **stream) buttons_changed = ucmd->buttons ^ basis->buttons; if (buttons_changed != 0) { - BYTE bytes[4] = { BYTE(ucmd->buttons & 0x7F), - BYTE((ucmd->buttons >> 7) & 0x7F), - BYTE((ucmd->buttons >> 14) & 0x7F), - BYTE((ucmd->buttons >> 21) & 0xFF) }; + uint8_t bytes[4] = { uint8_t(ucmd->buttons & 0x7F), + uint8_t((ucmd->buttons >> 7) & 0x7F), + uint8_t((ucmd->buttons >> 14) & 0x7F), + uint8_t((ucmd->buttons >> 21) & 0xFF) }; flags |= UCMDF_BUTTONS; @@ -318,7 +318,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, usercmd_t &cmd, usercm return arc; } -int WriteUserCmdMessage (usercmd_t *ucmd, const usercmd_t *basis, BYTE **stream) +int WriteUserCmdMessage (usercmd_t *ucmd, const usercmd_t *basis, uint8_t **stream) { if (basis == NULL) { @@ -352,10 +352,10 @@ int WriteUserCmdMessage (usercmd_t *ucmd, const usercmd_t *basis, BYTE **stream) } -int SkipTicCmd (BYTE **stream, int count) +int SkipTicCmd (uint8_t **stream, int count) { int i, skip; - BYTE *flow = *stream; + uint8_t *flow = *stream; for (i = count; i > 0; i--) { @@ -364,7 +364,7 @@ int SkipTicCmd (BYTE **stream, int count) flow += 2; // Skip consistancy marker while (moreticdata) { - BYTE type = *flow++; + uint8_t type = *flow++; if (type == DEM_USERCMD) { @@ -410,10 +410,10 @@ int SkipTicCmd (BYTE **stream, int count) #include extern short consistancy[MAXPLAYERS][BACKUPTICS]; -void ReadTicCmd (BYTE **stream, int player, int tic) +void ReadTicCmd (uint8_t **stream, int player, int tic) { int type; - BYTE *start; + uint8_t *start; ticcmd_t *tcmd; int ticmod = tic % BACKUPTICS; @@ -451,7 +451,7 @@ void ReadTicCmd (BYTE **stream, int player, int tic) void RunNetSpecs (int player, int buf) { - BYTE *stream; + uint8_t *stream; int len; if (gametic % ticdup == 0) @@ -459,7 +459,7 @@ void RunNetSpecs (int player, int buf) stream = NetSpecs[player][buf].GetData (&len); if (stream) { - BYTE *end = stream + len; + uint8_t *end = stream + len; while (stream < end) { int type = ReadByte (&stream); @@ -471,11 +471,11 @@ void RunNetSpecs (int player, int buf) } } -BYTE *lenspot; +uint8_t *lenspot; // Write the header of an IFF chunk and leave space // for the length field. -void StartChunk (int id, BYTE **stream) +void StartChunk (int id, uint8_t **stream) { WriteLong (id, stream); lenspot = *stream; @@ -484,7 +484,7 @@ void StartChunk (int id, BYTE **stream) // Write the length field for the chunk and insert // pad byte if the chunk is odd-sized. -void FinishChunk (BYTE **stream) +void FinishChunk (uint8_t **stream) { int len; @@ -501,7 +501,7 @@ void FinishChunk (BYTE **stream) // Skip past an unknown chunk. *stream should be // pointing to the chunk's length field. -void SkipChunk (BYTE **stream) +void SkipChunk (uint8_t **stream) { int len; diff --git a/src/d_protocol.h b/src/d_protocol.h index f95e3fc81..7de26a179 100644 --- a/src/d_protocol.h +++ b/src/d_protocol.h @@ -52,18 +52,18 @@ struct zdemoheader_s { - BYTE demovermajor; - BYTE demoverminor; - BYTE minvermajor; - BYTE minverminor; - BYTE map[8]; + uint8_t demovermajor; + uint8_t demoverminor; + uint8_t minvermajor; + uint8_t minverminor; + uint8_t map[8]; unsigned int rngseed; - BYTE consoleplayer; + uint8_t consoleplayer; }; struct usercmd_t { - DWORD buttons; + uint32_t buttons; short pitch; // up/down short yaw; // left/right short roll; // "tilt" @@ -141,7 +141,7 @@ enum EDemoCommand DEM_DELCONTROLLER, // 49 Player to remove from the controller list. DEM_KILLCLASSCHEAT, // 50 String: Class to kill. DEM_UNDONE11, // 51 - DEM_SUMMON2, // 52 String: Thing to fabricate, WORD: angle offset + DEM_SUMMON2, // 52 String: Thing to fabricate, uint16_t: angle offset DEM_SUMMONFRIEND2, // 53 DEM_SUMMONFOE2, // 54 DEM_ADDSLOTDEFAULT, // 55 @@ -221,30 +221,30 @@ enum ECheatCommand CHT_GOD2 }; -void StartChunk (int id, BYTE **stream); -void FinishChunk (BYTE **stream); -void SkipChunk (BYTE **stream); +void StartChunk (int id, uint8_t **stream); +void FinishChunk (uint8_t **stream); +void SkipChunk (uint8_t **stream); -int UnpackUserCmd (usercmd_t *ucmd, const usercmd_t *basis, BYTE **stream); -int PackUserCmd (const usercmd_t *ucmd, const usercmd_t *basis, BYTE **stream); -int WriteUserCmdMessage (usercmd_t *ucmd, const usercmd_t *basis, BYTE **stream); +int UnpackUserCmd (usercmd_t *ucmd, const usercmd_t *basis, uint8_t **stream); +int PackUserCmd (const usercmd_t *ucmd, const usercmd_t *basis, uint8_t **stream); +int WriteUserCmdMessage (usercmd_t *ucmd, const usercmd_t *basis, uint8_t **stream); struct ticcmd_t; -int SkipTicCmd (BYTE **stream, int count); -void ReadTicCmd (BYTE **stream, int player, int tic); +int SkipTicCmd (uint8_t **stream, int count); +void ReadTicCmd (uint8_t **stream, int player, int tic); void RunNetSpecs (int player, int buf); -int ReadByte (BYTE **stream); -int ReadWord (BYTE **stream); -int ReadLong (BYTE **stream); -float ReadFloat (BYTE **stream); -char *ReadString (BYTE **stream); -const char *ReadStringConst(BYTE **stream); -void WriteByte (BYTE val, BYTE **stream); -void WriteWord (short val, BYTE **stream); -void WriteLong (int val, BYTE **stream); -void WriteFloat (float val, BYTE **stream); -void WriteString (const char *string, BYTE **stream); +int ReadByte (uint8_t **stream); +int ReadWord (uint8_t **stream); +int ReadLong (uint8_t **stream); +float ReadFloat (uint8_t **stream); +char *ReadString (uint8_t **stream); +const char *ReadStringConst(uint8_t **stream); +void WriteByte (uint8_t val, uint8_t **stream); +void WriteWord (short val, uint8_t **stream); +void WriteLong (int val, uint8_t **stream); +void WriteFloat (float val, uint8_t **stream); +void WriteString (const char *string, uint8_t **stream); #endif //__D_PROTOCOL_H__ diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h index 7e819629c..66a629e08 100644 --- a/src/d_ticcmd.h +++ b/src/d_ticcmd.h @@ -32,7 +32,7 @@ struct ticcmd_t { usercmd_t ucmd; - SWORD consistancy; // checks for net game + int16_t consistancy; // checks for net game }; #endif // __D_TICCMD_H__ diff --git a/src/decallib.cpp b/src/decallib.cpp index 52a4eadf5..d4ca5984b 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -54,7 +54,7 @@ FDecalLib DecalLibrary; static double ReadScale (FScanner &sc); -static TArray DecalTranslations; +static TArray DecalTranslations; // A decal group holds multiple decals and returns one randomly // when GetDecal() is called. @@ -76,7 +76,7 @@ public: { Choices.ReplaceValues(from, to); } - void AddDecal (FDecalBase *decal, WORD weight) + void AddDecal (FDecalBase *decal, uint16_t weight) { Choices.AddEntry (decal, weight); } @@ -89,12 +89,12 @@ private: struct FDecalLib::FTranslation { - FTranslation (DWORD start, DWORD end); - FTranslation *LocateTranslation (DWORD start, DWORD end); + FTranslation (uint32_t start, uint32_t end); + FTranslation *LocateTranslation (uint32_t start, uint32_t end); - DWORD StartColor, EndColor; + uint32_t StartColor, EndColor; FTranslation *Next; - WORD Index; + uint16_t Index; }; struct FDecalAnimator @@ -115,7 +115,7 @@ struct DDecalThinker : public DThinker public: DDecalThinker (DBaseDecal *decal) : DThinker (STAT_DECALTHINKER), TheDecal (decal) {} void Serialize(FSerializer &arc); - TObjPtr TheDecal; + TObjPtr TheDecal; protected: DDecalThinker () : DThinker (STAT_DECALTHINKER) {} }; @@ -422,7 +422,7 @@ void FDecalLib::ReadDecals(FScanner &sc) } } -WORD FDecalLib::GetDecalID (FScanner &sc) +uint16_t FDecalLib::GetDecalID (FScanner &sc) { sc.MustGetString (); if (!IsNum (sc.String)) @@ -437,14 +437,14 @@ WORD FDecalLib::GetDecalID (FScanner &sc) { sc.ScriptError ("Decal ID must be between 1 and 65535"); } - return (WORD)num; + return (uint16_t)num; } } void FDecalLib::ParseDecal (FScanner &sc) { FString decalName; - WORD decalNum; + uint16_t decalNum; FDecalTemplate newdecal; FTextureID picnum; int lumpnum; @@ -546,7 +546,7 @@ void FDecalLib::ParseDecal (FScanner &sc) break; case DECAL_COLORS: - DWORD startcolor, endcolor; + uint32_t startcolor, endcolor; sc.MustGetString (); startcolor = V_GetColor (NULL, sc); sc.MustGetString (); endcolor = V_GetColor (NULL, sc); @@ -569,7 +569,7 @@ void FDecalLib::ParseDecal (FScanner &sc) void FDecalLib::ParseDecalGroup (FScanner &sc) { FString groupName; - WORD decalNum; + uint16_t decalNum; FDecalBase *targetDecal; FDecalGroup *group; @@ -871,7 +871,7 @@ void FDecalLib::ReplaceDecalRef (FDecalBase *from, FDecalBase *to, FDecalBase *r root->ReplaceDecalRef (from, to); } -void FDecalLib::AddDecal (const char *name, WORD num, const FDecalTemplate &decal) +void FDecalLib::AddDecal (const char *name, uint16_t num, const FDecalTemplate &decal) { FDecalTemplate *newDecal = new FDecalTemplate; @@ -944,7 +944,7 @@ void FDecalLib::AddDecal (FDecalBase *decal) } } -const FDecalTemplate *FDecalLib::GetDecalByNum (WORD num) const +const FDecalTemplate *FDecalLib::GetDecalByNum (uint16_t num) const { if (num == 0) { @@ -972,7 +972,7 @@ const FDecalTemplate *FDecalLib::GetDecalByName (const char *name) const return NULL; } -FDecalBase *FDecalLib::ScanTreeForNum (const WORD num, FDecalBase *root) +FDecalBase *FDecalLib::ScanTreeForNum (const uint16_t num, FDecalBase *root) { while (root != NULL) { @@ -1009,7 +1009,7 @@ FDecalBase *FDecalLib::ScanTreeForName (const char *name, FDecalBase *root) return root; } -FDecalLib::FTranslation *FDecalLib::GenerateTranslation (DWORD start, DWORD end) +FDecalLib::FTranslation *FDecalLib::GenerateTranslation (uint32_t start, uint32_t end) { FTranslation *trans; @@ -1069,11 +1069,11 @@ const FDecalTemplate *FDecalTemplate::GetDecal () const return this; } -FDecalLib::FTranslation::FTranslation (DWORD start, DWORD end) +FDecalLib::FTranslation::FTranslation (uint32_t start, uint32_t end) { - DWORD ri, gi, bi, rs, gs, bs; + uint32_t ri, gi, bi, rs, gs, bs; PalEntry *first, *last; - BYTE *table; + uint8_t *table; unsigned int i, tablei; StartColor = start; @@ -1109,10 +1109,10 @@ FDecalLib::FTranslation::FTranslation (DWORD start, DWORD end) table[i] = ColorMatcher.Pick (ri >> 24, gi >> 24, bi >> 24); } table[0] = table[1]; - Index = (WORD)TRANSLATION(TRANSLATION_Decals, tablei >> 8); + Index = (uint16_t)TRANSLATION(TRANSLATION_Decals, tablei >> 8); } -FDecalLib::FTranslation *FDecalLib::FTranslation::LocateTranslation (DWORD start, DWORD end) +FDecalLib::FTranslation *FDecalLib::FTranslation::LocateTranslation (uint32_t start, uint32_t end) { FTranslation *trans = this; diff --git a/src/decallib.h b/src/decallib.h index 5f08bdfd1..7c3369c4d 100644 --- a/src/decallib.h +++ b/src/decallib.h @@ -60,7 +60,7 @@ protected: FDecalBase *Left, *Right; FName Name; - WORD SpawnID; + uint16_t SpawnID; TArray Users; // Which actors generate this decal }; @@ -75,11 +75,11 @@ public: void ReplaceDecalRef (FDecalBase *from, FDecalBase *to); double ScaleX, ScaleY; - DWORD ShadeColor; - DWORD Translation; + uint32_t ShadeColor; + uint32_t Translation; FRenderStyle RenderStyle; FTextureID PicNum; - WORD RenderFlags; + uint16_t RenderFlags; double Alpha; // same as actor->alpha const FDecalAnimator *Animator; const FDecalBase *LowerDecal; @@ -97,22 +97,22 @@ public: void ReadDecals (FScanner &sc); void ReadAllDecals (); - const FDecalTemplate *GetDecalByNum (WORD num) const; + const FDecalTemplate *GetDecalByNum (uint16_t num) const; const FDecalTemplate *GetDecalByName (const char *name) const; private: struct FTranslation; static void DelTree (FDecalBase *root); - static FDecalBase *ScanTreeForNum (const WORD num, FDecalBase *root); + static FDecalBase *ScanTreeForNum (const uint16_t num, FDecalBase *root); static FDecalBase *ScanTreeForName (const char *name, FDecalBase *root); static void ReplaceDecalRef (FDecalBase *from, FDecalBase *to, FDecalBase *root); - FTranslation *GenerateTranslation (DWORD start, DWORD end); - void AddDecal (const char *name, WORD num, const FDecalTemplate &decal); + FTranslation *GenerateTranslation (uint32_t start, uint32_t end); + void AddDecal (const char *name, uint16_t num, const FDecalTemplate &decal); void AddDecal (FDecalBase *decal); FDecalAnimator *FindAnimator (const char *name); - WORD GetDecalID (FScanner &sc); + uint16_t GetDecalID (FScanner &sc); void ParseDecal (FScanner &sc); void ParseDecalGroup (FScanner &sc); void ParseGenerator (FScanner &sc); diff --git a/src/dobject.cpp b/src/dobject.cpp index b8097f549..456305f21 100644 --- a/src/dobject.cpp +++ b/src/dobject.cpp @@ -404,7 +404,7 @@ size_t DObject::PropagateMark() } while (*offsets != ~(size_t)0) { - GC::Mark((DObject **)((BYTE *)this + *offsets)); + GC::Mark((DObject **)((uint8_t *)this + *offsets)); offsets++; } @@ -416,7 +416,7 @@ size_t DObject::PropagateMark() } while (*offsets != ~(size_t)0) { - auto aray = (TArray*)((BYTE *)this + *offsets); + auto aray = (TArray*)((uint8_t *)this + *offsets); for (auto &p : *aray) { GC::Mark(&p); @@ -447,9 +447,9 @@ size_t DObject::PointerSubstitution (DObject *old, DObject *notOld) } while (*offsets != ~(size_t)0) { - if (*(DObject **)((BYTE *)this + *offsets) == old) + if (*(DObject **)((uint8_t *)this + *offsets) == old) { - *(DObject **)((BYTE *)this + *offsets) = notOld; + *(DObject **)((uint8_t *)this + *offsets) = notOld; changed++; } offsets++; @@ -463,7 +463,7 @@ size_t DObject::PointerSubstitution (DObject *old, DObject *notOld) } while (*offsets != ~(size_t)0) { - auto aray = (TArray*)((BYTE *)this + *offsets); + auto aray = (TArray*)((uint8_t *)this + *offsets); for (auto &p : *aray) { if (p == old) @@ -542,7 +542,7 @@ size_t DObject::StaticPointerSubstitution (DObject *old, DObject *notOld, bool s for (auto &sec : level.sectors) { #define SECTOR_CHECK(f,t) \ -if (sec.f.p == static_cast(old)) { sec.f = static_cast(notOld); changed++; } +if (sec.f.pp == static_cast(old)) { sec.f = static_cast(notOld); changed++; } SECTOR_CHECK( SoundTarget, AActor ); SECTOR_CHECK( SecActTarget, AActor ); SECTOR_CHECK( floordata, DSectorEffect ); @@ -552,9 +552,9 @@ if (sec.f.p == static_cast(old)) { sec.f = static_cast(notOld); change } // Go through bot stuff. - if (bglobal.firstthing.p == (AActor *)old) bglobal.firstthing = (AActor *)notOld, ++changed; - if (bglobal.body1.p == (AActor *)old) bglobal.body1 = (AActor *)notOld, ++changed; - if (bglobal.body2.p == (AActor *)old) bglobal.body2 = (AActor *)notOld, ++changed; + if (bglobal.firstthing.pp == (AActor *)old) bglobal.firstthing = (AActor *)notOld, ++changed; + if (bglobal.body1.pp == (AActor *)old) bglobal.body1 = (AActor *)notOld, ++changed; + if (bglobal.body2.pp == (AActor *)old) bglobal.body2 = (AActor *)notOld, ++changed; return changed; } diff --git a/src/dobject.h b/src/dobject.h index cc6672cdf..31215b981 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -348,70 +348,54 @@ class TObjPtr { union { - T *p; + T pp; DObject *o; }; public: TObjPtr() throw() { } - TObjPtr(T *q) throw() - : p(q) + TObjPtr(T q) throw() + : pp(q) { } TObjPtr(const TObjPtr &q) throw() - : p(q.p) + : pp(q.pp) { } - T *operator=(T *q) throw() + T operator=(T q) throw() { - return p = q; + return pp = q; // The caller must now perform a write barrier. } - operator T*() throw() + operator T() throw() { - return GC::ReadBarrier(p); + return GC::ReadBarrier(pp); } T &operator*() { - T *q = GC::ReadBarrier(p); + T q = GC::ReadBarrier(pp); assert(q != NULL); return *q; } - T **operator&() throw() + T *operator&() throw() { // Does not perform a read barrier. The only real use for this is with // the DECLARE_POINTER macro, where a read barrier would be a very bad // thing. - return &p; + return &pp; } - T *operator->() throw() + T operator->() throw() { - return GC::ReadBarrier(p); + return GC::ReadBarrier(pp); } - bool operator<(T *u) throw() + bool operator!=(T u) throw() { - return GC::ReadBarrier(p) < u; + return GC::ReadBarrier(o) != u; } - bool operator<=(T *u) throw() + bool operator==(T u) throw() { - return GC::ReadBarrier(p) <= u; - } - bool operator>(T *u) throw() - { - return GC::ReadBarrier(p) > u; - } - bool operator>=(T *u) throw() - { - return GC::ReadBarrier(p) >= u; - } - bool operator!=(T *u) throw() - { - return GC::ReadBarrier(p) != u; - } - bool operator==(T *u) throw() - { - return GC::ReadBarrier(p) == u; + return GC::ReadBarrier(o) == u; } template friend inline void GC::Mark(TObjPtr &obj); @@ -424,7 +408,7 @@ public: // the contents of a TObjPtr to a related type. template inline T barrier_cast(TObjPtr &o) { - return static_cast(static_cast(o)); + return static_cast(static_cast(o)); } template inline void GC::Mark(TObjPtr &obj) diff --git a/src/dobjgc.cpp b/src/dobjgc.cpp index 4f0aa20db..56e8c82d4 100644 --- a/src/dobjgc.cpp +++ b/src/dobjgc.cpp @@ -150,7 +150,7 @@ DObject *Gray; DObject *Root; DObject *SoftRoots; DObject **SweepPos; -DWORD CurrentWhite = OF_White0 | OF_Fixed; +uint32_t CurrentWhite = OF_White0 | OF_Fixed; EGCState State = GCS_Pause; int Pause = DEFAULT_GCPAUSE; int StepMul = DEFAULT_GCMUL; diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index a5dc66a5b..0812ac9d5 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -637,11 +637,11 @@ void PInt::SetValue(void *addr, int val) } else if (Size == 1) { - *(BYTE *)addr = val; + *(uint8_t *)addr = val; } else if (Size == 2) { - *(WORD *)addr = val; + *(uint16_t *)addr = val; } else if (Size == 8) { @@ -673,11 +673,11 @@ int PInt::GetValueInt(void *addr) const } else if (Size == 1) { - return Unsigned ? *(BYTE *)addr : *(SBYTE *)addr; + return Unsigned ? *(uint8_t *)addr : *(int8_t *)addr; } else if (Size == 2) { - return Unsigned ? *(WORD *)addr : *(SWORD *)addr; + return Unsigned ? *(uint16_t *)addr : *(int16_t *)addr; } else if (Size == 8) { // truncated output @@ -1035,7 +1035,7 @@ bool PString::ReadValue(FSerializer &ar, const char *key, void *addr) const void PString::SetDefaultValue(void *base, unsigned offset, TArray *special) const { - if (base != nullptr) new((BYTE *)base + offset) FString; + if (base != nullptr) new((uint8_t *)base + offset) FString; if (special != nullptr) { special->Push(std::make_pair(this, offset)); @@ -1715,7 +1715,7 @@ void PArray::WriteValue(FSerializer &ar, const char *key,const void *addr) const { if (ar.BeginArray(key)) { - const BYTE *addrb = (const BYTE *)addr; + const uint8_t *addrb = (const uint8_t *)addr; for (unsigned i = 0; i < ElementCount; ++i) { ElementType->WriteValue(ar, nullptr, addrb); @@ -1738,7 +1738,7 @@ bool PArray::ReadValue(FSerializer &ar, const char *key, void *addr) const bool readsomething = false; unsigned count = ar.ArraySize(); unsigned loop = MIN(count, ElementCount); - BYTE *addrb = (BYTE *)addr; + uint8_t *addrb = (uint8_t *)addr; for(unsigned i=0;iReadValue(ar, nullptr, addrb); @@ -2036,7 +2036,7 @@ void PDynArray::WriteValue(FSerializer &ar, const char *key, const void *addr) c { if (ar.BeginArray(key)) { - const BYTE *addrb = (const BYTE *)aray->Array; + const uint8_t *addrb = (const uint8_t *)aray->Array; for (unsigned i = 0; i < aray->Count; ++i) { ElementType->WriteValue(ar, nullptr, addrb); @@ -2068,7 +2068,7 @@ bool PDynArray::ReadValue(FSerializer &ar, const char *key, void *addr) const memset(aray->Array, 0, blocksize); aray->Most = aray->Count = count; - BYTE *addrb = (BYTE *)aray->Array; + uint8_t *addrb = (uint8_t *)aray->Array; for (unsigned i = 0; iFlags & (VARF_Transient|VARF_Meta))) { - field->Type->WriteValue(ar, field->SymbolName.GetChars(), (const BYTE *)addr + field->Offset); + field->Type->WriteValue(ar, field->SymbolName.GetChars(), (const uint8_t *)addr + field->Offset); } } } @@ -2357,7 +2357,7 @@ bool PStruct::ReadFields(FSerializer &ar, void *addr) const else { readsomething |= static_cast(sym)->Type->ReadValue(ar, nullptr, - (BYTE *)addr + static_cast(sym)->Offset); + (uint8_t *)addr + static_cast(sym)->Offset); } } return readsomething || !foundsomething; @@ -2372,7 +2372,7 @@ bool PStruct::ReadFields(FSerializer &ar, void *addr) const // //========================================================================== -PField *PStruct::AddField(FName name, PType *type, DWORD flags) +PField *PStruct::AddField(FName name, PType *type, uint32_t flags) { PField *field = new PField(name, type, flags); @@ -2405,7 +2405,7 @@ PField *PStruct::AddField(FName name, PType *type, DWORD flags) // //========================================================================== -PField *PStruct::AddNativeField(FName name, PType *type, size_t address, DWORD flags, int bitvalue) +PField *PStruct::AddNativeField(FName name, PType *type, size_t address, uint32_t flags, int bitvalue) { PField *field = new PField(name, type, flags|VARF_Native|VARF_Transient, address, bitvalue); @@ -2495,7 +2495,7 @@ PField::PField() } -PField::PField(FName name, PType *type, DWORD flags, size_t offset, int bitvalue) +PField::PField(FName name, PType *type, uint32_t flags, size_t offset, int bitvalue) : PSymbol(name), Offset(offset), Type(type), Flags(flags) { if (bitvalue != 0) @@ -3073,7 +3073,7 @@ PClass *PClass::FindClass (FName zaname) DObject *PClass::CreateNew() { - BYTE *mem = (BYTE *)M_Malloc (Size); + uint8_t *mem = (uint8_t *)M_Malloc (Size); assert (mem != nullptr); // Set this object's defaults before constructing it. @@ -3136,7 +3136,7 @@ void PClass::DestroySpecials(void *addr) ParentClass->DestroySpecials(addr); for (auto tao : SpecialInits) { - tao.first->DestroyValue((BYTE *)addr + tao.second); + tao.first->DestroyValue((uint8_t *)addr + tao.second); } } @@ -3172,7 +3172,7 @@ void PClass::InitializeDefaults() if (IsKindOf(RUNTIME_CLASS(PClassActor))) { assert(Defaults == nullptr); - Defaults = (BYTE *)M_Malloc(Size); + Defaults = (uint8_t *)M_Malloc(Size); // run the constructor on the defaults to set the vtbl pointer which is needed to run class-aware functions on them. // Temporarily setting bSerialOverride prevents linking into the thinker chains. @@ -3203,7 +3203,7 @@ void PClass::InitializeDefaults() assert(MetaSize >= ParentClass->MetaSize); if (MetaSize != 0) { - Meta = (BYTE*)M_Malloc(MetaSize); + Meta = (uint8_t*)M_Malloc(MetaSize); // Copy the defaults from the parent but leave the DObject part alone because it contains important data. if (ParentClass->Meta != nullptr) @@ -3330,7 +3330,7 @@ PClass *PClass::CreateDerivedClass(FName name, unsigned int size) // //========================================================================== -PField *PClass::AddMetaField(FName name, PType *type, DWORD flags) +PField *PClass::AddMetaField(FName name, PType *type, uint32_t flags) { PField *field = new PField(name, type, flags); @@ -3360,7 +3360,7 @@ PField *PClass::AddMetaField(FName name, PType *type, DWORD flags) // //========================================================================== -PField *PClass::AddField(FName name, PType *type, DWORD flags) +PField *PClass::AddField(FName name, PType *type, uint32_t flags) { if (!(flags & VARF_Meta)) { @@ -3372,7 +3372,7 @@ PField *PClass::AddField(FName name, PType *type, DWORD flags) // setting up any defaults for any class. if (field != nullptr && !(flags & VARF_Native) && Defaults != nullptr) { - Defaults = (BYTE *)M_Realloc(Defaults, Size); + Defaults = (uint8_t *)M_Realloc(Defaults, Size); memset(Defaults + oldsize, 0, Size - oldsize); } return field; @@ -3387,7 +3387,7 @@ PField *PClass::AddField(FName name, PType *type, DWORD flags) // setting up any defaults for any class. if (field != nullptr && !(flags & VARF_Native) && Meta != nullptr) { - Meta = (BYTE *)M_Realloc(Meta, MetaSize); + Meta = (uint8_t *)M_Realloc(Meta, MetaSize); memset(Meta + oldsize, 0, MetaSize - oldsize); } return field; diff --git a/src/dobjtype.h b/src/dobjtype.h index 0ec96b304..6b24610f8 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -92,7 +92,7 @@ public: bool MemberOnly = false; // type may only be used as a struct/class member but not as a local variable or function argument. FString mDescriptiveName; VersionInfo mVersion = { 0,0,0 }; - BYTE loadOp, storeOp, moveOp, RegType, RegCount; + uint8_t loadOp, storeOp, moveOp, RegType, RegCount; PType(unsigned int size = 1, unsigned int align = 1); virtual ~PType(); @@ -525,8 +525,8 @@ public: VMFunction *mConstructor = nullptr; VMFunction *mDestructor = nullptr; - virtual PField *AddField(FName name, PType *type, DWORD flags=0); - virtual PField *AddNativeField(FName name, PType *type, size_t address, DWORD flags = 0, int bitvalue = 0); + virtual PField *AddField(FName name, PType *type, uint32_t flags=0); + virtual PField *AddNativeField(FName name, PType *type, size_t address, uint32_t flags = 0, int bitvalue = 0); void WriteValue(FSerializer &ar, const char *key,const void *addr) const override; bool ReadValue(FSerializer &ar, const char *key,void *addr) const override; @@ -581,7 +581,7 @@ protected: void Derive(PClass *newclass, FName name); void InitializeSpecials(void *addr, void *defaults, TArray PClass::*Inits); void SetSuper(); - PField *AddMetaField(FName name, PType *type, DWORD flags); + PField *AddMetaField(FName name, PType *type, uint32_t flags); public: void WriteValue(FSerializer &ar, const char *key,const void *addr) const override; void WriteAllFields(FSerializer &ar, const void *addr) const; @@ -601,8 +601,8 @@ public: const size_t *Pointers; // object pointers defined by this class *only* const size_t *FlatPointers; // object pointers defined by this class and all its superclasses; not initialized by default const size_t *ArrayPointers; // dynamic arrays containing object pointers. - BYTE *Defaults; - BYTE *Meta; // Per-class static script data + uint8_t *Defaults; + uint8_t *Meta; // Per-class static script data unsigned MetaSize; bool bRuntimeClass; // class was defined at run-time, not compile-time bool bExported; // This type has been declared in a script @@ -617,7 +617,7 @@ public: void InsertIntoHash(); DObject *CreateNew(); PClass *CreateDerivedClass(FName name, unsigned int size); - PField *AddField(FName name, PType *type, DWORD flags=0) override; + PField *AddField(FName name, PType *type, uint32_t flags=0) override; void InitializeActorInfo(); void BuildFlatPointers(); void BuildArrayPointers(); diff --git a/src/doomdata.h b/src/doomdata.h index 0c1fb4a97..0ce01bf6a 100644 --- a/src/doomdata.h +++ b/src/doomdata.h @@ -71,19 +71,19 @@ enum // A single Vertex. struct mapvertex_t { - short x, y; + int16_t x, y; }; // A SideDef, defining the visual appearance of a wall, // by setting textures and offsets. struct mapsidedef_t { - short textureoffset; - short rowoffset; + int16_t textureoffset; + int16_t rowoffset; char toptexture[8]; char bottomtexture[8]; char midtexture[8]; - short sector; // Front sector, towards viewer. + int16_t sector; // Front sector, towards viewer. }; struct intmapsidedef_t @@ -97,24 +97,24 @@ struct intmapsidedef_t // A LineDef, as used for editing, and as input to the BSP builder. struct maplinedef_t { - WORD v1; - WORD v2; - WORD flags; - short special; - short tag; - WORD sidenum[2]; // sidenum[1] will be -1 if one sided + uint16_t v1; + uint16_t v2; + uint16_t flags; + int16_t special; + int16_t tag; + uint16_t sidenum[2]; // sidenum[1] will be -1 if one sided } ; // [RH] Hexen-compatible LineDef. struct maplinedef2_t { - WORD v1; - WORD v2; - WORD flags; - BYTE special; - BYTE args[5]; - WORD sidenum[2]; + uint16_t v1; + uint16_t v2; + uint16_t flags; + uint8_t special; + uint8_t args[5]; + uint16_t sidenum[2]; } ; @@ -221,27 +221,27 @@ static inline int GET_SPAC (int flags) // Sector definition, from editing struct mapsector_t { - short floorheight; - short ceilingheight; + int16_t floorheight; + int16_t ceilingheight; char floorpic[8]; char ceilingpic[8]; - short lightlevel; - short special; - short tag; + int16_t lightlevel; + int16_t special; + int16_t tag; }; // SubSector, as generated by BSP struct mapsubsector_t { - WORD numsegs; - WORD firstseg; // index of first one, segs are stored sequentially + uint16_t numsegs; + uint16_t firstseg; // index of first one, segs are stored sequentially }; #pragma pack(1) struct mapsubsector4_t { - WORD numsegs; - DWORD firstseg; // index of first one, segs are stored sequentially + uint16_t numsegs; + uint32_t firstseg; // index of first one, segs are stored sequentially }; #pragma pack() @@ -249,12 +249,12 @@ struct mapsubsector4_t // using partition lines selected by BSP builder. struct mapseg_t { - WORD v1; - WORD v2; - SWORD angle; - WORD linedef; - SWORD side; - SWORD offset; + uint16_t v1; + uint16_t v2; + int16_t angle; + uint16_t linedef; + int16_t side; + int16_t offset; int V1() { return LittleShort(v1); } int V2() { return LittleShort(v2); } @@ -264,10 +264,10 @@ struct mapseg4_t { int32_t v1; int32_t v2; - SWORD angle; - WORD linedef; - SWORD side; - SWORD offset; + int16_t angle; + uint16_t linedef; + int16_t side; + int16_t offset; int V1() { return LittleLong(v1); } int V2() { return LittleLong(v2); } @@ -286,13 +286,13 @@ struct mapnode_t NF_SUBSECTOR = 0x8000, NF_LUMPOFFSET = 0 }; - 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. - WORD children[2]; + uint16_t children[2]; - DWORD Child(int num) { return LittleShort(children[num]); } + uint32_t Child(int num) { return LittleShort(children[num]); } }; @@ -303,13 +303,13 @@ struct mapnode4_t NF_SUBSECTOR = 0x80000000, NF_LUMPOFFSET = 8 }; - 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]; - DWORD Child(int num) { return LittleLong(children[num]); } + uint32_t Child(int num) { return LittleLong(children[num]); } }; @@ -318,25 +318,25 @@ struct mapnode4_t // plus skill/visibility flags and attributes. struct mapthing_t { - SWORD x; - SWORD y; - SWORD angle; - SWORD type; - SWORD options; + int16_t x; + int16_t y; + int16_t angle; + int16_t type; + int16_t options; }; // [RH] Hexen-compatible MapThing. struct mapthinghexen_t { - SWORD thingid; - SWORD x; - SWORD y; - SWORD z; - SWORD angle; - SWORD type; - WORD flags; - BYTE special; - BYTE args[5]; + int16_t thingid; + int16_t x; + int16_t y; + int16_t z; + int16_t angle; + int16_t type; + uint16_t flags; + uint8_t special; + uint8_t args[5]; }; struct FDoomEdEntry; @@ -346,24 +346,24 @@ struct FMapThing { int thingid; DVector3 pos; - short angle; - WORD SkillFilter; - WORD ClassFilter; - short EdNum; + int16_t angle; + uint16_t SkillFilter; + uint16_t ClassFilter; + int16_t EdNum; FDoomEdEntry *info; - DWORD flags; + uint32_t flags; int special; int args[5]; int Conversation; double Gravity; double Alpha; - DWORD fillcolor; + uint32_t fillcolor; DVector2 Scale; double Health; int score; - short pitch; - short roll; - DWORD RenderStyle; + int16_t pitch; + int16_t roll; + uint32_t RenderStyle; int FloatbobPhase; }; @@ -426,7 +426,7 @@ enum EMapThingFlags struct FPlayerStart { DVector3 pos; - short angle, type; + int16_t angle, type; FPlayerStart() { } FPlayerStart(const FMapThing *mthing, int pnum) diff --git a/src/doomdef.h b/src/doomdef.h index 520f5b6ed..0b639db30 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -378,9 +378,9 @@ enum #define BLINKTHRESHOLD (4*32) #ifndef __BIG_ENDIAN__ -#define MAKE_ID(a,b,c,d) ((DWORD)((a)|((b)<<8)|((c)<<16)|((d)<<24))) +#define MAKE_ID(a,b,c,d) ((uint32_t)((a)|((b)<<8)|((c)<<16)|((d)<<24))) #else -#define MAKE_ID(a,b,c,d) ((DWORD)((d)|((c)<<8)|((b)<<16)|((a)<<24))) +#define MAKE_ID(a,b,c,d) ((uint32_t)((d)|((c)<<8)|((b)<<16)|((a)<<24))) #endif #endif // __DOOMDEF_H__ diff --git a/src/doomstat.h b/src/doomstat.h index ee7b7d210..a73f13447 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -234,7 +234,7 @@ struct DehInfo int KFAArmor; int KFAAC; char PlayerSprite[5]; - BYTE ExplosionStyle; + uint8_t ExplosionStyle; double ExplosionAlpha; int NoAutofreeze; int BFGCells; diff --git a/src/doomtype.h b/src/doomtype.h index fda7d00fa..0d0b79068 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -57,16 +57,6 @@ typedef TMap FClassMap; #define NOVTABLE #endif -#if defined(__clang__) -#if defined(__has_feature) && __has_feature(address_sanitizer) -#define NO_SANITIZE __attribute__((no_sanitize("address"))) -#else -#define NO_SANITIZE -#endif -#else -#define NO_SANITIZE -#endif - #if defined(__GNUC__) // With versions of GCC newer than 4.2, it appears it was determined that the // cost of an unaligned pointer on PPC was high enough to add padding to the @@ -133,24 +123,24 @@ struct PalEntry PalEntry &operator= (uint32 other) { d = other; return *this; } PalEntry InverseColor() const { PalEntry nc; nc.a = a; nc.r = 255 - r; nc.g = 255 - g; nc.b = 255 - b; return nc; } #ifdef __BIG_ENDIAN__ - PalEntry (BYTE ir, BYTE ig, BYTE ib) : a(0), r(ir), g(ig), b(ib) {} - PalEntry (BYTE ia, BYTE ir, BYTE ig, BYTE ib) : a(ia), r(ir), g(ig), b(ib) {} + PalEntry (uint8_t ir, uint8_t ig, uint8_t ib) : a(0), r(ir), g(ig), b(ib) {} + PalEntry (uint8_t ia, uint8_t ir, uint8_t ig, uint8_t ib) : a(ia), r(ir), g(ig), b(ib) {} union { struct { - BYTE a,r,g,b; + uint8_t a,r,g,b; }; uint32 d; }; #else - PalEntry (BYTE ir, BYTE ig, BYTE ib) : b(ib), g(ig), r(ir), a(0) {} - PalEntry (BYTE ia, BYTE ir, BYTE ig, BYTE ib) : b(ib), g(ig), r(ir), a(ia) {} + PalEntry (uint8_t ir, uint8_t ig, uint8_t ib) : b(ib), g(ig), r(ir), a(0) {} + PalEntry (uint8_t ia, uint8_t ir, uint8_t ig, uint8_t ib) : b(ib), g(ig), r(ir), a(ia) {} union { struct { - BYTE b,g,r,a; + uint8_t b,g,r,a; }; uint32 d; }; diff --git a/src/dsectoreffect.h b/src/dsectoreffect.h index 5139aaabd..e72e5bc56 100644 --- a/src/dsectoreffect.h +++ b/src/dsectoreffect.h @@ -29,7 +29,7 @@ public: DMover (sector_t *sector); void StopInterpolation(bool force = false); protected: - TObjPtr interpolation; + TObjPtr interpolation; private: protected: DMover (); diff --git a/src/dthinker.cpp b/src/dthinker.cpp index fddc28317..a5d78a504 100644 --- a/src/dthinker.cpp +++ b/src/dthinker.cpp @@ -156,7 +156,7 @@ void DThinker::SaveList(FSerializer &arc, DThinker *node) void DThinker::SerializeThinkers(FSerializer &arc, bool hubLoad) { //DThinker *thinker; - //BYTE stat; + //uint8_t stat; //int statcount; int i; diff --git a/src/dthinker.h b/src/dthinker.h index f86eff266..a8c374bb7 100644 --- a/src/dthinker.h +++ b/src/dthinker.h @@ -116,7 +116,7 @@ protected: const PClass *m_ParentType; private: DThinker *m_CurrThinker; - BYTE m_Stat; + uint8_t m_Stat; bool m_SearchStats; bool m_SearchingFresh; diff --git a/src/edata.cpp b/src/edata.cpp index 015be0bb1..ee5f1fe84 100644 --- a/src/edata.cpp +++ b/src/edata.cpp @@ -95,8 +95,8 @@ struct EDMapthing int type; double height; int args[5]; - WORD skillfilter; - DWORD flags; + uint16_t skillfilter; + uint32_t flags; }; struct EDLinedef @@ -107,8 +107,8 @@ struct EDLinedef int id; int args[5]; double alpha; - DWORD flags; - DWORD activation; + uint32_t flags; + uint32_t activation; }; @@ -117,24 +117,24 @@ struct EDSector { int recordnum; - DWORD flags; - DWORD flagsRemove; - DWORD flagsAdd; + uint32_t flags; + uint32_t flagsRemove; + uint32_t flagsAdd; int damageamount; int damageinterval; FNameNoInit damagetype; - BYTE leaky; - BYTE leakyadd; - BYTE leakyremove; + uint8_t leaky; + uint8_t leakyadd; + uint8_t leakyremove; int floorterrain; int ceilingterrain; - DWORD color; + uint32_t color; - DWORD damageflags; - DWORD damageflagsAdd; - DWORD damageflagsRemove; + uint32_t damageflags; + uint32_t damageflagsAdd; + uint32_t damageflagsRemove; bool flagsSet; bool damageflagsSet; @@ -143,7 +143,7 @@ struct EDSector // colormaptop//bottom cannot be used because ZDoom has no corresponding properties. double xoffs[2], yoffs[2]; DAngle angle[2]; - DWORD portalflags[2]; + uint32_t portalflags[2]; double Overlayalpha[2]; }; @@ -222,8 +222,8 @@ static void parseLinedef(FScanner &sc) else if (sc.Compare("extflags")) { // these are needed to build the proper activation mask out of the possible flags which do not match ZDoom 1:1. - DWORD actmethod = 0; - DWORD acttype = 0; + uint32_t actmethod = 0; + uint32_t acttype = 0; do { sc.CheckString("="); @@ -291,7 +291,7 @@ static void parseSector(FScanner &sc) } else if (sc.Compare("flags")) { - DWORD *flagvar = NULL; + uint32_t *flagvar = NULL; if (sc.CheckString(".")) { sc.MustGetString(); @@ -348,8 +348,8 @@ static void parseSector(FScanner &sc) } else if (sc.Compare("damageflags")) { - DWORD *flagvar = NULL; - BYTE *leakvar = NULL; + uint32_t *flagvar = NULL; + uint8_t *leakvar = NULL; if (sc.CheckString(".")) { sc.MustGetString(); @@ -449,7 +449,7 @@ static void parseSector(FScanner &sc) sc.MustGetString(); // Eternity is based on SMMU and uses colormaps differently than all other ports. // The only solution here is to convert the colormap to an RGB value and set it as the sector's color. - DWORD cmap = R_ColormapNumForName(sc.String); + uint32_t cmap = R_ColormapNumForName(sc.String); if (cmap != 0) { sec.color = R_BlendForColormap(cmap) & 0xff000000; @@ -700,7 +700,7 @@ void ProcessEDLinedef(line_t *ld, int recordnum) ld->special = 0; return; } - const DWORD fmask = ML_REPEAT_SPECIAL | ML_FIRSTSIDEONLY | ML_ADDTRANS | ML_BLOCKEVERYTHING | ML_ZONEBOUNDARY | ML_CLIP_MIDTEX; + const uint32_t fmask = ML_REPEAT_SPECIAL | ML_FIRSTSIDEONLY | ML_ADDTRANS | ML_BLOCKEVERYTHING | ML_ZONEBOUNDARY | ML_CLIP_MIDTEX; ld->special = eld->special; ld->activation = eld->activation; ld->flags = (ld->flags&~fmask) | eld->flags; @@ -719,11 +719,11 @@ void ProcessEDSector(sector_t *sec, int recordnum) } // In ZDoom the regular and the damage flags are part of the same flag word so we need to do some masking. - const DWORD flagmask = SECF_SECRET | SECF_WASSECRET | SECF_FRICTION | SECF_PUSH | SECF_SILENT | SECF_SILENTMOVE; + const uint32_t flagmask = SECF_SECRET | SECF_WASSECRET | SECF_FRICTION | SECF_PUSH | SECF_SILENT | SECF_SILENTMOVE; if (esec->flagsSet) sec->Flags = (sec->Flags & ~flagmask); sec->Flags = (sec->Flags | esec->flags | esec->flagsAdd) & ~esec->flagsRemove; - BYTE leak = 0; + uint8_t leak = 0; if (esec->damageflagsSet) sec->Flags = (sec->Flags & ~SECF_DAMAGEFLAGS); else leak = sec->leakydamage >= 256 ? 2 : sec->leakydamage >= 5 ? 1 : 0; sec->Flags = (sec->Flags | esec->damageflags | esec->damageflagsAdd) & ~esec->damageflagsRemove; @@ -740,7 +740,7 @@ void ProcessEDSector(sector_t *sec, int recordnum) if (esec->colorSet) sec->SetColor(RPART(esec->color), GPART(esec->color), BPART(esec->color), 0); - const DWORD pflagmask = PLANEF_DISABLED | PLANEF_NORENDER | PLANEF_NOPASS | PLANEF_BLOCKSOUND | PLANEF_ADDITIVE; + const uint32_t pflagmask = PLANEF_DISABLED | PLANEF_NORENDER | PLANEF_NOPASS | PLANEF_BLOCKSOUND | PLANEF_ADDITIVE; for (int i = 0; i < 2; i++) { sec->SetXOffset(i, esec->xoffs[i]); diff --git a/src/files.h b/src/files.h index b78282482..e8099ada8 100644 --- a/src/files.h +++ b/src/files.h @@ -13,33 +13,33 @@ public: virtual ~FileReaderBase() {} virtual long Read (void *buffer, long len) = 0; - FileReaderBase &operator>> (BYTE &v) + FileReaderBase &operator>> (uint8_t &v) { Read (&v, 1); return *this; } - FileReaderBase &operator>> (SBYTE &v) + FileReaderBase &operator>> (int8_t &v) { Read (&v, 1); return *this; } - FileReaderBase &operator>> (WORD &v) + FileReaderBase &operator>> (uint16_t &v) { Read (&v, 2); v = LittleShort(v); return *this; } - FileReaderBase &operator>> (SWORD &v) + FileReaderBase &operator>> (int16_t &v) { Read (&v, 2); v = LittleShort(v); return *this; } - FileReaderBase &operator>> (DWORD &v) + FileReaderBase &operator>> (uint32_t &v) { Read (&v, 4); v = LittleLong(v); @@ -79,33 +79,33 @@ public: FILE *GetFile () const { return File; } virtual const char *GetBuffer() const { return NULL; } - FileReader &operator>> (BYTE &v) + FileReader &operator>> (uint8_t &v) { Read (&v, 1); return *this; } - FileReader &operator>> (SBYTE &v) + FileReader &operator>> (int8_t &v) { Read (&v, 1); return *this; } - FileReader &operator>> (WORD &v) + FileReader &operator>> (uint16_t &v) { Read (&v, 2); v = LittleShort(v); return *this; } - FileReader &operator>> (SWORD &v) + FileReader &operator>> (int16_t &v) { Read (&v, 2); v = LittleShort(v); return *this; } - FileReader &operator>> (DWORD &v) + FileReader &operator>> (uint32_t &v) { Read (&v, 4); v = LittleLong(v); @@ -138,33 +138,33 @@ public: virtual long Read (void *buffer, long len); - FileReaderZ &operator>> (BYTE &v) + FileReaderZ &operator>> (uint8_t &v) { Read (&v, 1); return *this; } - FileReaderZ &operator>> (SBYTE &v) + FileReaderZ &operator>> (int8_t &v) { Read (&v, 1); return *this; } - FileReaderZ &operator>> (WORD &v) + FileReaderZ &operator>> (uint16_t &v) { Read (&v, 2); v = LittleShort(v); return *this; } - FileReaderZ &operator>> (SWORD &v) + FileReaderZ &operator>> (int16_t &v) { Read (&v, 2); v = LittleShort(v); return *this; } - FileReaderZ &operator>> (DWORD &v) + FileReaderZ &operator>> (uint32_t &v) { Read (&v, 4); v = LittleLong(v); @@ -184,7 +184,7 @@ private: FileReader &File; bool SawEOF; z_stream Stream; - BYTE InBuff[BUFF_SIZE]; + uint8_t InBuff[BUFF_SIZE]; void FillBuffer (); @@ -200,33 +200,33 @@ public: long Read (void *buffer, long len); - FileReaderBZ2 &operator>> (BYTE &v) + FileReaderBZ2 &operator>> (uint8_t &v) { Read (&v, 1); return *this; } - FileReaderBZ2 &operator>> (SBYTE &v) + FileReaderBZ2 &operator>> (int8_t &v) { Read (&v, 1); return *this; } - FileReaderBZ2 &operator>> (WORD &v) + FileReaderBZ2 &operator>> (uint16_t &v) { Read (&v, 2); v = LittleShort(v); return *this; } - FileReaderBZ2 &operator>> (SWORD &v) + FileReaderBZ2 &operator>> (int16_t &v) { Read (&v, 2); v = LittleShort(v); return *this; } - FileReaderBZ2 &operator>> (DWORD &v) + FileReaderBZ2 &operator>> (uint32_t &v) { Read (&v, 4); v = LittleLong(v); @@ -246,7 +246,7 @@ private: FileReader &File; bool SawEOF; bz_stream Stream; - BYTE InBuff[BUFF_SIZE]; + uint8_t InBuff[BUFF_SIZE]; void FillBuffer (); @@ -264,33 +264,33 @@ public: long Read (void *buffer, long len); - FileReaderLZMA &operator>> (BYTE &v) + FileReaderLZMA &operator>> (uint8_t &v) { Read (&v, 1); return *this; } - FileReaderLZMA &operator>> (SBYTE &v) + FileReaderLZMA &operator>> (int8_t &v) { Read (&v, 1); return *this; } - FileReaderLZMA &operator>> (WORD &v) + FileReaderLZMA &operator>> (uint16_t &v) { Read (&v, 2); v = LittleShort(v); return *this; } - FileReaderLZMA &operator>> (SWORD &v) + FileReaderLZMA &operator>> (int16_t &v) { Read (&v, 2); v = LittleShort(v); return *this; } - FileReaderLZMA &operator>> (DWORD &v) + FileReaderLZMA &operator>> (uint32_t &v) { Read (&v, 4); v = LittleLong(v); @@ -313,7 +313,7 @@ private: size_t Size; size_t InPos, InSize; size_t OutProcessed; - BYTE InBuff[BUFF_SIZE]; + uint8_t InBuff[BUFF_SIZE]; void FillBuffer (); @@ -347,12 +347,12 @@ public: virtual long Read (void *buffer, long len); virtual char *Gets(char *strbuf, int len); virtual const char *GetBuffer() const { return (char*)&buf[0]; } - TArray &GetArray() { return buf; } + TArray &GetArray() { return buf; } void UpdateLength() { Length = buf.Size(); } protected: - TArray buf; + TArray buf; }; diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 1a979824f..51c1dd05b 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -1218,7 +1218,7 @@ void FParser::SF_ObjFlag(void) if(mo && flagnum<26) // nullptr check { - DWORD tempflags = mo->flags; + uint32_t tempflags = mo->flags; // remove old bit tempflags &= ~(1 << flagnum); @@ -1953,7 +1953,7 @@ void FParser::SF_SectorColormap(void) if (t_argv[1].type==svt_string) { - DWORD cm = R_ColormapNumForName(t_argv[1].value.s); + uint32_t cm = R_ColormapNumForName(t_argv[1].value.s); FSSectorTagIterator itr(tagnum); while ((i = itr.Next()) >= 0) @@ -3257,7 +3257,7 @@ void FParser::SF_SpawnMissile() void FParser::SF_MapThingNumExist() { - TArray > &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings; + auto &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings; int intval; @@ -3295,7 +3295,7 @@ void FParser::SF_MapThingNumExist() void FParser::SF_MapThings() { - TArray > &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings; + auto &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings; t_return.type = svt_int; t_return.value.i = SpawnedThings.Size(); diff --git a/src/fragglescript/t_load.cpp b/src/fragglescript/t_load.cpp index eb7b602bf..16eab219e 100644 --- a/src/fragglescript/t_load.cpp +++ b/src/fragglescript/t_load.cpp @@ -375,7 +375,7 @@ void T_AddSpawnedThing(AActor * ac) { if (DFraggleThinker::ActiveThinker) { - TArray > &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings; + auto &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings; SpawnedThings.Push(GC::ReadBarrier(ac)); } } diff --git a/src/fragglescript/t_script.cpp b/src/fragglescript/t_script.cpp index 1ff4321fa..9dc153310 100644 --- a/src/fragglescript/t_script.cpp +++ b/src/fragglescript/t_script.cpp @@ -388,7 +388,7 @@ IMPLEMENT_POINTERS_START(DFraggleThinker) IMPLEMENT_POINTER(LevelScript) IMPLEMENT_POINTERS_END -TObjPtr DFraggleThinker::ActiveThinker; +TObjPtr DFraggleThinker::ActiveThinker; //========================================================================== // diff --git a/src/fragglescript/t_script.h b/src/fragglescript/t_script.h index eb0cc382b..bf990b679 100644 --- a/src/fragglescript/t_script.h +++ b/src/fragglescript/t_script.h @@ -174,11 +174,11 @@ struct DFsVariable : public DObject public: FString Name; - TObjPtr next; // for hashing + TObjPtr next; // for hashing int type; // svt_string or svt_int: same as in svalue_t FString string; - TObjPtr actor; + TObjPtr actor; union value_t { @@ -241,7 +241,7 @@ public: int start_index; int end_index; int loop_index; - TObjPtr next; // for hashing + TObjPtr next; // for hashing DFsSection() { @@ -320,27 +320,27 @@ public: // {} sections - TObjPtr sections[SECTIONSLOTS]; + TObjPtr sections[SECTIONSLOTS]; // variables: - TObjPtr variables[VARIABLESLOTS]; + TObjPtr variables[VARIABLESLOTS]; // ptr to the parent script // the parent script is the script above this level // eg. individual linetrigger scripts are children // of the levelscript, which is a child of the // global_script - TObjPtr parent; + TObjPtr parent; // haleyjd: 8-17 // child scripts. // levelscript holds ptrs to all of the level's scripts // here. - TObjPtr children[MAXSCRIPTS]; + TObjPtr children[MAXSCRIPTS]; - TObjPtr trigger; // object which triggered this script + TObjPtr trigger; // object which triggered this script bool lastiftrue; // haleyjd: whether last "if" statement was // true or false @@ -665,7 +665,7 @@ public: void OnDestroy() override; void Serialize(FSerializer &arc); - TObjPtr script; + TObjPtr script; // where we are int save_point; @@ -674,10 +674,10 @@ public: int wait_data; // data for wait: tagnum, counter, script number etc // saved variables - TObjPtr variables[VARIABLESLOTS]; + TObjPtr variables[VARIABLESLOTS]; - TObjPtr prev, next; // for chain - TObjPtr trigger; + TObjPtr prev, next; // for chain + TObjPtr trigger; }; //----------------------------------------------------------------------------- @@ -691,9 +691,9 @@ class DFraggleThinker : public DThinker HAS_OBJECT_POINTERS public: - TObjPtr LevelScript; - TObjPtr RunningScripts; - TArray > SpawnedThings; + TObjPtr LevelScript; + TObjPtr RunningScripts; + TArray > SpawnedThings; bool nocheckposition; bool setcolormaterial; @@ -708,7 +708,7 @@ public: bool wait_finished(DRunningScript *script); void AddRunningScript(DRunningScript *runscr); - static TObjPtr ActiveThinker; + static TObjPtr ActiveThinker; }; //----------------------------------------------------------------------------- diff --git a/src/fragglescript/t_variable.cpp b/src/fragglescript/t_variable.cpp index 9bdddda34..a87d2c1e6 100644 --- a/src/fragglescript/t_variable.cpp +++ b/src/fragglescript/t_variable.cpp @@ -153,7 +153,7 @@ AActor* actorvalue(const svalue_t &svalue) } else { - TArray > &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings; + auto &SpawnedThings = DFraggleThinker::ActiveThinker->SpawnedThings; // this requires some creativity. We use the intvalue // as the thing number of a thing in the level. intval = intvalue(svalue); diff --git a/src/g_game.cpp b/src/g_game.cpp index e0fbd9854..d1903a23a 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -180,13 +180,13 @@ bool demorecording; bool demoplayback; bool demonew; // [RH] Only used around G_InitNew for demos int demover; -BYTE* demobuffer; -BYTE* demo_p; -BYTE* democompspot; -BYTE* demobodyspot; +uint8_t* demobuffer; +uint8_t* demo_p; +uint8_t* democompspot; +uint8_t* demobodyspot; size_t maxdemosize; -BYTE* zdemformend; // end of FORM ZDEM chunk -BYTE* zdembodyend; // end of ZDEM BODY chunk +uint8_t* zdemformend; // end of FORM ZDEM chunk +uint8_t* zdembodyend; // end of ZDEM BODY chunk bool singledemo; // quit after playing a demo from cmdline bool precache = true; // if true, load all graphics at start @@ -1162,7 +1162,7 @@ void G_Ticker () // [RH] Include some random seeds and player stuff in the consistancy // check, not just the player's x position like BOOM. - DWORD rngsum = FRandom::StaticSumSeeds (); + uint32_t rngsum = FRandom::StaticSumSeeds (); //Added by MC: For some of that bot stuff. The main bot function. bglobal.Main (); @@ -1211,7 +1211,7 @@ void G_Ticker () } if (players[i].mo) { - DWORD sum = rngsum + int((players[i].mo->X() + players[i].mo->Y() + players[i].mo->Z())*257) + players[i].mo->Angles.Yaw.BAMs() + players[i].mo->Angles.Pitch.BAMs(); + uint32_t sum = rngsum + int((players[i].mo->X() + players[i].mo->Y() + players[i].mo->Z())*257) + players[i].mo->Angles.Yaw.BAMs() + players[i].mo->Angles.Pitch.BAMs(); sum ^= players[i].health; consistancy[i][buf] = sum; } @@ -1394,7 +1394,7 @@ void G_PlayerReborn (int player) int itemcount; int secretcount; int chasecam; - BYTE currclass; + uint8_t currclass; userinfo_t userinfo; // [RH] Save userinfo APlayerPawn *actor; PClassActor *cls; @@ -2034,11 +2034,11 @@ void G_DoLoadGame () arc("importantcvars", cvar); if (!cvar.IsEmpty()) { - BYTE *vars_p = (BYTE *)cvar.GetChars(); + uint8_t *vars_p = (uint8_t *)cvar.GetChars(); C_ReadCVars(&vars_p); } - DWORD time[2] = { 1,0 }; + uint32_t time[2] = { 1,0 }; arc("ticrate", time[0]) ("leveltime", time[1]); @@ -2206,7 +2206,7 @@ static void PutSaveComment (FSerializer &arc) { char comment[256]; const char *readableTime; - WORD len; + uint16_t len; int levelTime; // Get the current date and time @@ -2222,7 +2222,7 @@ static void PutSaveComment (FSerializer &arc) // Get level name //strcpy (comment, level.level_name); mysnprintf(comment, countof(comment), "%s - %s", level.MapName.GetChars(), level.LevelName.GetChars()); - len = (WORD)strlen (comment); + len = (uint16_t)strlen (comment); comment[len] = '\n'; // Append elapsed time @@ -2429,7 +2429,7 @@ void G_ReadDemoTiccmd (ticcmd_t *cmd, int player) case DEM_DROPPLAYER: { - BYTE i = ReadByte (&demo_p); + uint8_t i = ReadByte (&demo_p); if (i < MAXPLAYERS) { playeringame[i] = false; @@ -2451,11 +2451,11 @@ CCMD (stop) stoprecording = true; } -extern BYTE *lenspot; +extern uint8_t *lenspot; void G_WriteDemoTiccmd (ticcmd_t *cmd, int player, int buf) { - BYTE *specdata; + uint8_t *specdata; int speclen; if (stoprecording) @@ -2488,7 +2488,7 @@ void G_WriteDemoTiccmd (ticcmd_t *cmd, int player, int buf) ptrdiff_t body = demobodyspot - demobuffer; // [RH] Allocate more space for the demo maxdemosize += 0x20000; - demobuffer = (BYTE *)M_Realloc (demobuffer, maxdemosize); + demobuffer = (uint8_t *)M_Realloc (demobuffer, maxdemosize); demo_p = demobuffer + pos; lenspot = demobuffer + spot; democompspot = demobuffer + comp; @@ -2508,7 +2508,7 @@ void G_RecordDemo (const char* name) FixPathSeperator (demoname); DefaultExtension (demoname, ".lmp"); maxdemosize = 0x20000; - demobuffer = (BYTE *)M_Malloc (maxdemosize); + demobuffer = (uint8_t *)M_Malloc (maxdemosize); demorecording = true; } @@ -2549,7 +2549,7 @@ void G_BeginRecording (const char *startmap) if (playeringame[i]) { StartChunk (UINF_ID, &demo_p); - WriteByte ((BYTE)i, &demo_p); + WriteByte ((uint8_t)i, &demo_p); D_WriteUserInfoStrings (i, &demo_p); FinishChunk (&demo_p); } @@ -2635,7 +2635,7 @@ bool G_ProcessIFFDemo (FString &mapname) int numPlayers = 0; int id, len, i; uLong uncompSize = 0; - BYTE *nextchunk; + uint8_t *nextchunk; demoplayback = true; @@ -2763,7 +2763,7 @@ bool G_ProcessIFFDemo (FString &mapname) if (uncompSize > 0) { - BYTE *uncompressed = (BYTE*)M_Malloc(uncompSize); + uint8_t *uncompressed = (uint8_t*)M_Malloc(uncompSize); int r = uncompress (uncompressed, &uncompSize, demo_p, uLong(zdembodyend - demo_p)); if (r != Z_OK) { @@ -2791,7 +2791,7 @@ void G_DoPlayDemo (void) if (demolump >= 0) { int demolen = Wads.LumpLength (demolump); - demobuffer = (BYTE *)M_Malloc(demolen); + demobuffer = (uint8_t *)M_Malloc(demolen); Wads.ReadLump (demolump, demobuffer); } else @@ -2937,7 +2937,7 @@ bool G_CheckDemoStatus (void) if (demorecording) { - BYTE *formlen; + uint8_t *formlen; WriteByte (DEM_STOP, &demo_p); diff --git a/src/g_inventory/a_pickups.h b/src/g_inventory/a_pickups.h index 9b2fc1cc1..eb9731ddc 100644 --- a/src/g_inventory/a_pickups.h +++ b/src/g_inventory/a_pickups.h @@ -85,7 +85,7 @@ public: AInventory *PrevInv(); // Returns the previous item with IF_INVBAR set. AInventory *NextInv(); // Returns the next item with IF_INVBAR set. - TObjPtr Owner; // Who owns this item? NULL if it's still a pickup. + TObjPtr Owner; // Who owns this item? NULL if it's still a pickup. int Amount; // Amount of item this instance has int MaxAmount; // Max amount of item this instance can have int InterHubAmount; // Amount of item that can be kept between hubs or levels diff --git a/src/g_inventory/a_weapons.cpp b/src/g_inventory/a_weapons.cpp index fa9f63afa..2b1c78991 100644 --- a/src/g_inventory/a_weapons.cpp +++ b/src/g_inventory/a_weapons.cpp @@ -1487,7 +1487,7 @@ static int ntoh_cmp(const void *a, const void *b) // //=========================================================================== -void P_WriteDemoWeaponsChunk(BYTE **demo) +void P_WriteDemoWeaponsChunk(uint8_t **demo) { WriteWord(Weapons_ntoh.Size(), demo); for (unsigned int i = 1; i < Weapons_ntoh.Size(); ++i) @@ -1505,7 +1505,7 @@ void P_WriteDemoWeaponsChunk(BYTE **demo) // //=========================================================================== -void P_ReadDemoWeaponsChunk(BYTE **demo) +void P_ReadDemoWeaponsChunk(uint8_t **demo) { int count, i; PClassActor *type; @@ -1570,7 +1570,7 @@ void Net_WriteWeapon(PClassActor *type) // //=========================================================================== -PClassActor *Net_ReadWeapon(BYTE **stream) +PClassActor *Net_ReadWeapon(uint8_t **stream) { int index; diff --git a/src/g_inventory/a_weapons.h b/src/g_inventory/a_weapons.h index 606c96e98..9841d1a5a 100644 --- a/src/g_inventory/a_weapons.h +++ b/src/g_inventory/a_weapons.h @@ -79,11 +79,11 @@ struct FWeaponSlots void P_PlaybackKeyConfWeapons(FWeaponSlots *slots); void Net_WriteWeapon(PClassActor *type); -PClassActor *Net_ReadWeapon(BYTE **stream); +PClassActor *Net_ReadWeapon(uint8_t **stream); void P_SetupWeapons_ntohton(); -void P_WriteDemoWeaponsChunk(BYTE **demo); -void P_ReadDemoWeaponsChunk(BYTE **demo); +void P_WriteDemoWeaponsChunk(uint8_t **demo); +void P_ReadDemoWeaponsChunk(uint8_t **demo); class AWeapon : public AStateProvider @@ -91,7 +91,7 @@ class AWeapon : public AStateProvider DECLARE_CLASS(AWeapon, AStateProvider) HAS_OBJECT_POINTERS public: - DWORD WeaponFlags; + uint32_t WeaponFlags; PClassActor *AmmoType1, *AmmoType2; // Types of ammo used by this weapon int AmmoGive1, AmmoGive2; // Amount of each ammo to get when picking up weapon int MinAmmo1, MinAmmo2; // Minimum ammo needed to switch to this weapon @@ -113,8 +113,8 @@ public: int SlotPriority; // In-inventory instance variables - TObjPtr Ammo1, Ammo2; - TObjPtr SisterWeapon; + TObjPtr Ammo1, Ammo2; + TObjPtr SisterWeapon; float FOVScale; int Crosshair; // 0 to use player's crosshair bool GivenAsMorphWeapon; diff --git a/src/g_level.h b/src/g_level.h index 26da28b9a..0f8906b6a 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -230,7 +230,7 @@ enum ELevelFlags : unsigned int struct FSpecialAction { FName Type; // this is initialized before the actors... - BYTE Action; + uint8_t Action; int Args[5]; // must allow 16 bit tags for 666 & 667! }; @@ -288,35 +288,35 @@ struct level_info_t int cluster; int partime; int sucktime; - DWORD flags; - DWORD flags2; - DWORD flags3; + uint32_t flags; + uint32_t flags2; + uint32_t flags3; FString Music; FString LevelName; - SBYTE WallVertLight, WallHorizLight; + int8_t WallVertLight, WallHorizLight; int musicorder; FCompressedBuffer Snapshot; TArray deferred; float skyspeed1; float skyspeed2; - DWORD fadeto; - DWORD outsidefog; + uint32_t fadeto; + uint32_t outsidefog; int cdtrack; unsigned int cdid; double gravity; double aircontrol; int WarpTrans; int airsupply; - DWORD compatflags, compatflags2; - DWORD compatmask, compatmask2; + uint32_t compatflags, compatflags2; + uint32_t compatmask, compatmask2; FString Translator; // for converting Doom-format linedef and sector types. int DefaultEnvironment; // Default sound environment for the map. FName Intermission; FName deathsequence; FName slideshow; - DWORD hazardcolor; - DWORD hazardflash; + uint32_t hazardcolor; + uint32_t hazardflash; // Redirection: If any player is carrying the specified item, then // you go to the RedirectMap instead of this one. diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 9c77a64f9..401906436 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -8,7 +8,7 @@ struct FLevelLocals void Tick (); void AddScroller (int secnum); - BYTE md5[16]; // for savegame validation. If the MD5 does not match the savegame won't be loaded. + uint8_t md5[16]; // for savegame validation. If the MD5 does not match the savegame won't be loaded. int time; // time in the hub int maptime; // time in the map int totaltime; // time in the game @@ -36,15 +36,15 @@ struct FLevelLocals TArray sectorPortals; - DWORD flags; - DWORD flags2; - DWORD flags3; + uint32_t flags; + uint32_t flags2; + uint32_t flags3; - DWORD fadeto; // The color the palette fades to (usually black) - DWORD outsidefog; // The fog for sectors with sky ceilings + uint32_t fadeto; // The color the palette fades to (usually black) + uint32_t outsidefog; // The fog for sectors with sky ceilings - DWORD hazardcolor; // what color strife hazard blends the screen color as - DWORD hazardflash; // what color strife hazard flashes the screen color as + uint32_t hazardcolor; // what color strife hazard blends the screen color as + uint32_t hazardflash; // what color strife hazard flashes the screen color as FString Music; int musicorder; @@ -73,8 +73,8 @@ struct FLevelLocals TArray Scrolls; // NULL if no DScrollers in this level - SBYTE WallVertLight; // Light diffs for vert/horiz walls - SBYTE WallHorizLight; + int8_t WallVertLight; // Light diffs for vert/horiz walls + int8_t WallHorizLight; bool FromSnapshot; // The current map was restored from a snapshot diff --git a/src/g_mapinfo.cpp b/src/g_mapinfo.cpp index 69c90048f..231d376eb 100644 --- a/src/g_mapinfo.cpp +++ b/src/g_mapinfo.cpp @@ -965,14 +965,14 @@ DEFINE_MAP_OPTION(vertwallshade, true) { parse.ParseAssign(); parse.sc.MustGetNumber(); - info->WallVertLight = (SBYTE)clamp (parse.sc.Number / 2, -128, 127); + info->WallVertLight = (int8_t)clamp (parse.sc.Number / 2, -128, 127); } DEFINE_MAP_OPTION(horizwallshade, true) { parse.ParseAssign(); parse.sc.MustGetNumber(); - info->WallHorizLight = (SBYTE)clamp (parse.sc.Number / 2, -128, 127); + info->WallHorizLight = (int8_t)clamp (parse.sc.Number / 2, -128, 127); } DEFINE_MAP_OPTION(gravity, true) @@ -1243,7 +1243,7 @@ struct MapInfoFlagHandler { const char *name; EMIType type; - DWORD data1, data2; + uint32_t data1, data2; } MapFlagHandlers[] = { diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index 2d1a95cdd..575e7027c 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -86,8 +86,8 @@ public: DCorpsePointer (AActor *ptr); void OnDestroy() override; void Serialize(FSerializer &arc); - TObjPtr Corpse; - DWORD Count; // Only the first corpse pointer's count is valid. + TObjPtr Corpse; + uint32_t Count; // Only the first corpse pointer's count is valid. private: DCorpsePointer () {} }; @@ -104,7 +104,7 @@ CUSTOM_CVAR(Int, sv_corpsequeuesize, 64, CVAR_ARCHIVE|CVAR_SERVERINFO) { TThinkerIterator iterator (STAT_CORPSEPOINTER); DCorpsePointer *first = iterator.Next (); - while (first != NULL && first->Count > (DWORD)self) + while (first != NULL && first->Count > (uint32_t)self) { DCorpsePointer *next = iterator.Next (); first->Destroy (); @@ -126,7 +126,7 @@ DCorpsePointer::DCorpsePointer (AActor *ptr) if (first != this) { - if (first->Count >= (DWORD)sv_corpsequeuesize) + if (first->Count >= (uint32_t)sv_corpsequeuesize) { DCorpsePointer *next = iterator.Next (); first->Destroy (); diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index 21f116b07..9c31256ec 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -173,7 +173,7 @@ void DBaseDecal::GetXY (side_t *wall, double &ox, double &oy) const oy = v1->fY() + LeftDistance * dy; } -void DBaseDecal::SetShade (DWORD rgb) +void DBaseDecal::SetShade (uint32_t rgb) { PalEntry *entry = (PalEntry *)&rgb; AlphaColor = rgb | (ColorMatcher.Pick (entry->r, entry->g, entry->b) << 24); diff --git a/src/g_shared/a_lightning.cpp b/src/g_shared/a_lightning.cpp index a5401f59a..cec7c1800 100644 --- a/src/g_shared/a_lightning.cpp +++ b/src/g_shared/a_lightning.cpp @@ -58,7 +58,7 @@ void DLightningThinker::LightningFlash () { int i, j; sector_t *tempSec; - BYTE flashLight; + uint8_t flashLight; if (LightningFlashCount) { diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index ea367dd3a..f45cd9d0e 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -28,7 +28,7 @@ public: void OnDestroy() override; FTextureID StickToWall(side_t *wall, double x, double y, F3DFloor * ffloor); double GetRealZ (const side_t *wall) const; - void SetShade (DWORD rgb); + void SetShade (uint32_t rgb); void SetShade (int r, int g, int b); void Spread (const FDecalTemplate *tpl, side_t *wall, double x, double y, double z, F3DFloor * ffloor); void GetXY (side_t *side, double &x, double &y) const; @@ -39,10 +39,10 @@ public: double Z; double ScaleX, ScaleY; double Alpha; - DWORD AlphaColor; + uint32_t AlphaColor; int Translation; FTextureID PicNum; - DWORD RenderFlags; + uint32_t RenderFlags; FRenderStyle RenderStyle; side_t *Side; sector_t *Sector; @@ -95,7 +95,7 @@ protected: float Blends[2][4]; int TotalTics; int StartTic; - TObjPtr ForWho; + TObjPtr ForWho; void SetBlend (float time); DFlashFader (); @@ -131,7 +131,7 @@ public: void Serialize(FSerializer &arc); void Tick (); - TObjPtr m_Spot; + TObjPtr m_Spot; double m_TremorRadius, m_DamageRadius; int m_Countdown; int m_CountdownStart; @@ -164,7 +164,7 @@ public: void Die (AActor *source, AActor *inflictor, int dmgflags); void OnDestroy() override; - TObjPtr UnmorphedMe; + TObjPtr UnmorphedMe; int UnmorphTime, MorphStyle; PClassActor *MorphExitFlash; ActorFlags FlagsSave; diff --git a/src/g_shared/a_specialspot.cpp b/src/g_shared/a_specialspot.cpp index 46a9ccc41..2c41b2099 100644 --- a/src/g_shared/a_specialspot.cpp +++ b/src/g_shared/a_specialspot.cpp @@ -46,7 +46,7 @@ static FRandom pr_spawnmace ("SpawnMace"); IMPLEMENT_CLASS(DSpotState, false, false) IMPLEMENT_CLASS(ASpecialSpot, false, false) -TObjPtr DSpotState::SpotState; +TObjPtr DSpotState::SpotState; //---------------------------------------------------------------------------- // diff --git a/src/g_shared/a_specialspot.h b/src/g_shared/a_specialspot.h index 3b1e772d1..4bfef3b63 100644 --- a/src/g_shared/a_specialspot.h +++ b/src/g_shared/a_specialspot.h @@ -21,7 +21,7 @@ struct FSpotList; class DSpotState : public DThinker { DECLARE_CLASS(DSpotState, DThinker) - static TObjPtr SpotState; + static TObjPtr SpotState; TArray SpotLists; public: diff --git a/src/g_shared/hudmessages.cpp b/src/g_shared/hudmessages.cpp index 86ddc4bfd..eab0e8d29 100644 --- a/src/g_shared/hudmessages.cpp +++ b/src/g_shared/hudmessages.cpp @@ -281,7 +281,7 @@ void DHUDMessage::ResetText (const char *text) V_FreeBrokenLines (Lines); } - Lines = V_BreakLines (Font, NoWrap ? INT_MAX : width, (BYTE *)text); + Lines = V_BreakLines (Font, NoWrap ? INT_MAX : width, (uint8_t *)text); NumLines = 0; Width = 0; diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index 7fea7b014..97b1b54d6 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -670,7 +670,7 @@ static int DrawAmmo(player_t *CPlayer, int x, int y) // Weapons List // //--------------------------------------------------------------------------- -FTextureID GetInventoryIcon(AInventory *item, DWORD flags, bool *applyscale=NULL) // This function is also used by SBARINFO +FTextureID GetInventoryIcon(AInventory *item, uint32_t flags, bool *applyscale=NULL) // This function is also used by SBARINFO { FTextureID picnum, AltIcon = item->AltHUDIcon; FState * state=NULL, *ReadyState; diff --git a/src/g_skill.cpp b/src/g_skill.cpp index 25108c0df..a2c75376c 100644 --- a/src/g_skill.cpp +++ b/src/g_skill.cpp @@ -559,7 +559,7 @@ int FSkillInfo::GetTextColor() const { return CR_UNTRANSLATED; } - const BYTE *cp = (const BYTE *)TextColor.GetChars(); + const uint8_t *cp = (const uint8_t *)TextColor.GetChars(); int color = V_ParseFontColor(cp, 0, 0); if (color == CR_UNDEFINED) { diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index 1e8af1514..0e1eca144 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -133,8 +133,8 @@ protected: DHUDMessage () : SourceText(NULL) {} private: - TObjPtr Next; - DWORD SBarID; + TObjPtr Next; + uint32_t SBarID; char *SourceText; friend class DBaseStatusBar; @@ -225,11 +225,11 @@ struct FMugShotFrame struct FMugShotState { - BYTE bUsesLevels:1; - BYTE bHealth2:1; // Health level is the 2nd character from the end. - BYTE bHealthSpecial:1; // Like health2 only the 2nd frame gets the normal health type. - BYTE bDirectional:1; // Faces direction of damage. - BYTE bFinished:1; + uint8_t bUsesLevels:1; + uint8_t bHealth2:1; // Health level is the 2nd character from the end. + uint8_t bHealthSpecial:1; // Like health2 only the 2nd frame gets the normal health type. + uint8_t bDirectional:1; // Faces direction of damage. + uint8_t bFinished:1; unsigned int Position; int Time; @@ -415,7 +415,7 @@ private: void DrawConsistancy () const; void DrawWaiting () const; - TObjPtr Messages[NUM_HUDMSGLAYERS]; + TObjPtr Messages[NUM_HUDMSGLAYERS]; bool ShowLog; }; @@ -433,7 +433,7 @@ void ST_LoadCrosshair(bool alwaysload=false); void ST_Clear(); extern FTexture *CrosshairImage; -FTextureID GetInventoryIcon(AInventory *item, DWORD flags, bool *applyscale); +FTextureID GetInventoryIcon(AInventory *item, uint32_t flags, bool *applyscale); enum DI_Flags { diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index 5096ee813..b718e2703 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -189,9 +189,9 @@ class SBarInfoCommand if (!sc.CheckToken(TK_Null)) sc.MustGetToken(TK_Identifier); EColorRange returnVal = CR_UNTRANSLATED; FString namedTranslation; //we must send in "[translation]" - const BYTE *trans_ptr; + const uint8_t *trans_ptr; namedTranslation.Format("[%s]", sc.String); - trans_ptr = (const BYTE *)(&namedTranslation[0]); + trans_ptr = (const uint8_t *)(&namedTranslation[0]); if((returnVal = V_ParseFontColor(trans_ptr, CR_UNTRANSLATED, CR_UNTRANSLATED)) == CR_UNDEFINED) { sc.ScriptError("Missing definition for color %s.", sc.String); @@ -1379,7 +1379,7 @@ public: double xScale = 1.0; double yScale = 1.0; - const BYTE* str = (const BYTE*) cstring; + const uint8_t* str = (const uint8_t*) cstring; const EColorRange boldTranslation = EColorRange(translation ? translation - 1 : NumTextColors - 1); int fontcolor = translation; diff --git a/src/g_statusbar/sbarinfo_commands.cpp b/src/g_statusbar/sbarinfo_commands.cpp index ad2da961d..ccddc5939 100644 --- a/src/g_statusbar/sbarinfo_commands.cpp +++ b/src/g_statusbar/sbarinfo_commands.cpp @@ -344,7 +344,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl int maxheight; double spawnScaleX; double spawnScaleY; - DWORD flags; + uint32_t flags; bool applyscale; //Set remotely from from GetInventoryIcon when selected sprite comes from Spawn state // I'm using imgx/imgy here so that I can inherit drawimage with drawnumber for some commands. SBarInfoCoordinate imgx; @@ -2132,7 +2132,7 @@ class CommandDrawShader : public SBarInfoCommand DummySpan[1].TopOffset = 0; DummySpan[1].Length = 0; } - const BYTE *GetColumn(unsigned int column, const Span **spans_out) + const uint8_t *GetColumn(unsigned int column, const Span **spans_out) { if (spans_out != NULL) { @@ -2140,10 +2140,10 @@ class CommandDrawShader : public SBarInfoCommand } return Pixels + ((column & WidthMask) << HeightBits); } - const BYTE *GetPixels() { return Pixels; } + const uint8_t *GetPixels() { return Pixels; } void Unload() {} private: - BYTE Pixels[512]; + uint8_t Pixels[512]; Span DummySpan[2]; }; diff --git a/src/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index a0c825df5..db3b5deb5 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -403,7 +403,7 @@ void DBaseStatusBar::Tick () // //--------------------------------------------------------------------------- -void DBaseStatusBar::AttachMessage (DHUDMessage *msg, DWORD id, int layer) +void DBaseStatusBar::AttachMessage (DHUDMessage *msg, uint32_t id, int layer) { DHUDMessage *old = NULL; DHUDMessage **prev; @@ -471,7 +471,7 @@ DHUDMessage *DBaseStatusBar::DetachMessage (DHUDMessage *msg) return NULL; } -DHUDMessage *DBaseStatusBar::DetachMessage (DWORD id) +DHUDMessage *DBaseStatusBar::DetachMessage (uint32_t id) { for (size_t i = 0; i < countof(Messages); ++i) { @@ -597,10 +597,10 @@ void DBaseStatusBar::RefreshBackground () const void DBaseStatusBar::DrawCrosshair () { - static DWORD prevcolor = 0xffffffff; + static uint32_t prevcolor = 0xffffffff; static int palettecolor = 0; - DWORD color; + uint32_t color; double size; int w, h; diff --git a/src/gameconfigfile.cpp b/src/gameconfigfile.cpp index e6a0f9935..8b4e11ab5 100644 --- a/src/gameconfigfile.cpp +++ b/src/gameconfigfile.cpp @@ -488,7 +488,7 @@ void FGameConfigFile::ReadNetVars () // Read cvars from a cvar section of the ini. Flags are the flags to give // to newly-created cvars that were not already defined. -void FGameConfigFile::ReadCVars (DWORD flags) +void FGameConfigFile::ReadCVars (uint32_t flags) { const char *key, *value; FBaseCVar *cvar; diff --git a/src/gameconfigfile.h b/src/gameconfigfile.h index aa0d71e42..faeec2e51 100644 --- a/src/gameconfigfile.h +++ b/src/gameconfigfile.h @@ -63,7 +63,7 @@ protected: private: void SetRavenDefaults (bool isHexen); - void ReadCVars (DWORD flags); + void ReadCVars (uint32_t flags); bool bModSetup; diff --git a/src/gi.h b/src/gi.h index 2c614e3c7..f20ae0d99 100644 --- a/src/gi.h +++ b/src/gi.h @@ -55,8 +55,8 @@ extern const char *GameNames[17]; struct staticgameborder_t { - BYTE offset; - BYTE size; + uint8_t offset; + uint8_t size; char tl[8]; char t[8]; char tr[8]; @@ -69,8 +69,8 @@ struct staticgameborder_t struct gameborder_t { - BYTE offset; - BYTE size; + uint8_t offset; + uint8_t size; FString tl; FString t; FString tr; @@ -147,19 +147,19 @@ struct gameinfo_t double telefogheight; int defKickback; FString translator; - DWORD defaultbloodcolor; - DWORD defaultbloodparticlecolor; + uint32_t defaultbloodcolor; + uint32_t defaultbloodparticlecolor; FName backpacktype; FString statusbar; FString intermissionMusic; int intermissionOrder; FString CursorPic; - DWORD dimcolor; + uint32_t dimcolor; float dimamount; int definventorymaxamount; int defaultrespawntime; int defaultdropstyle; - DWORD pickupcolor; + uint32_t pickupcolor; TArray quitmessages; FName mTitleColor; FName mFontColor; diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 36ae3ad8f..a0bbd8002 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -319,7 +319,7 @@ DEFINE_MAP_OPTION(lightmode, false) FGLROptions *opt = info->GetOptData("gl_renderer"); parse.ParseAssign(); parse.sc.MustGetNumber(); - opt->lightmode = BYTE(parse.sc.Number); + opt->lightmode = uint8_t(parse.sc.Number); } DEFINE_MAP_OPTION(nocoloredspritelighting, false) diff --git a/src/gl/models/gl_models_md2.cpp b/src/gl/models/gl_models_md2.cpp index 0a4e85fed..bd0e9f0da 100644 --- a/src/gl/models/gl_models_md2.cpp +++ b/src/gl/models/gl_models_md2.cpp @@ -331,7 +331,7 @@ void FDMDModel::BuildVertexBuffer() // //=========================================================================== -void FDMDModel::AddSkins(BYTE *hitlist) +void FDMDModel::AddSkins(uint8_t *hitlist) { for (int i = 0; i < info.numSkins; i++) { diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index bc1fbce6d..0eb35e1c6 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -265,7 +265,7 @@ void OpenGLFrameBuffer::DoSetGamma() bool useHWGamma = m_supportsGamma && ((vid_hwgamma == 0) || (vid_hwgamma == 2 && IsFullscreen())); if (useHWGamma) { - WORD gammaTable[768]; + uint16_t gammaTable[768]; // This formula is taken from Doomsday float gamma = clamp(Gamma, 0.1f, 4.f); @@ -281,7 +281,7 @@ void OpenGLFrameBuffer::DoSetGamma() val += bright * 128; if(gamma != 1) val = pow(val, invgamma) / norm; - gammaTable[i] = gammaTable[i + 256] = gammaTable[i + 512] = (WORD)clamp(val*256, 0, 0xffff); + gammaTable[i] = gammaTable[i + 256] = gammaTable[i + 512] = (uint16_t)clamp(val*256, 0, 0xffff); } SetGammaTable(gammaTable); diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 9c3250d73..0f42d73d8 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -29,8 +29,8 @@ class player_t; // // Globally visible constants. // -#define HU_FONTSTART BYTE('!') // the first font characters -#define HU_FONTEND BYTE('\377') // the last font characters +#define HU_FONTSTART uint8_t('!') // the first font characters +#define HU_FONTEND uint8_t('\377') // the last font characters // Calculate # of glyphs in font. #define HU_FONTSIZE (HU_FONTEND - HU_FONTSTART + 1) diff --git a/src/i_net.cpp b/src/i_net.cpp index e03f50a6b..cc357e2c9 100644 --- a/src/i_net.cpp +++ b/src/i_net.cpp @@ -99,7 +99,7 @@ typedef int socklen_t; static u_short DOOMPORT = (IPPORT_USERRESERVED + 29); static SOCKET mysocket = INVALID_SOCKET; static sockaddr_in sendaddress[MAXNETNODES]; -static BYTE sendplayer[MAXNETNODES]; +static uint8_t sendplayer[MAXNETNODES]; #ifdef __WIN32__ const char *neterror (void); @@ -125,24 +125,24 @@ enum struct PreGamePacket { - BYTE Fake; - BYTE Message; - BYTE NumNodes; + uint8_t Fake; + uint8_t Message; + uint8_t NumNodes; union { - BYTE ConsoleNum; - BYTE NumPresent; + uint8_t ConsoleNum; + uint8_t NumPresent; }; struct { - DWORD address; - WORD port; - BYTE player; - BYTE pad; + uint32_t address; + uint16_t port; + uint8_t player; + uint8_t pad; } machines[MAXNETNODES]; }; -BYTE TransmitBuffer[TRANSMIT_SIZE]; +uint8_t TransmitBuffer[TRANSMIT_SIZE]; // // UDPsocket @@ -452,7 +452,7 @@ void StartNetwork (bool autoPort) void SendAbort (void) { - BYTE dis[2] = { PRE_FAKE, PRE_DISCONNECT }; + uint8_t dis[2] = { PRE_FAKE, PRE_DISCONNECT }; int i, j; if (doomcom.numnodes > 1) @@ -515,7 +515,7 @@ bool Host_CheckForConnects (void *userdata) { if (node == -1) { - const BYTE *s_addr_bytes = (const BYTE *)&from->sin_addr; + const uint8_t *s_addr_bytes = (const uint8_t *)&from->sin_addr; StartScreen->NetMessage ("Got extra connect from %d.%d.%d.%d:%d", s_addr_bytes[0], s_addr_bytes[1], s_addr_bytes[2], s_addr_bytes[3], from->sin_port); diff --git a/src/info.h b/src/info.h index 6caa27325..afa8baa13 100644 --- a/src/info.h +++ b/src/info.h @@ -119,8 +119,8 @@ struct FState uint8_t Frame; uint8_t UseFlags; uint8_t DefineFlags; // Unused byte so let's use it during state creation. - int32_t Misc1; // Was changed to SBYTE, reverted to long for MBF compat - int32_t Misc2; // Was changed to BYTE, reverted to long for MBF compat + int32_t Misc1; // Was changed to int8_t, reverted to long for MBF compat + int32_t Misc2; // Was changed to uint8_t, reverted to long for MBF compat public: inline int GetFrame() const { @@ -170,7 +170,7 @@ public: { return NextState; } - inline void SetFrame(BYTE frame) + inline void SetFrame(uint8_t frame) { Frame = frame - 'A'; } @@ -253,7 +253,7 @@ public: virtual size_t PointerSubstitution(DObject *oldclass, DObject *newclass); void BuildDefaults(); - void ApplyDefaults(BYTE *defaults); + void ApplyDefaults(uint8_t *defaults); void RegisterIDs(); void SetDamageFactor(FName type, double factor); void SetPainChance(FName type, int chance); @@ -279,11 +279,11 @@ public: PClassActor *Replacement; PClassActor *Replacee; int NumOwnedStates; - BYTE GameFilter; + uint8_t GameFilter; uint8_t DefaultStateUsage; // state flag defaults for blocks without a qualifier. - WORD SpawnID; - WORD ConversationID; - SWORD DoomEdNum; + uint16_t SpawnID; + uint16_t ConversationID; + int16_t DoomEdNum; FStateLabels *StateList; DmgFactors *DamageFactors; PainChanceList *PainChances; diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index 5dddef105..0143b3e40 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -124,12 +124,12 @@ void DIntermissionScreen::Init(FIntermissionAction *desc, bool first) if (desc->mPalette.IsNotEmpty() && (lumpnum = Wads.CheckNumForFullName(desc->mPalette, true)) > 0) { PalEntry *palette; - const BYTE *orgpal; + const uint8_t *orgpal; FMemLump lump; int i; lump = Wads.ReadLump (lumpnum); - orgpal = (BYTE *)lump.GetMem(); + orgpal = (uint8_t *)lump.GetMem(); palette = screen->GetPalette (); for (i = 256; i > 0; i--, orgpal += 3) { @@ -721,7 +721,7 @@ void DIntermissionScreenScroller::Drawer () DIntermissionController *DIntermissionController::CurrentIntermission; -DIntermissionController::DIntermissionController(FIntermissionDescriptor *Desc, bool DeleteDesc, BYTE state) +DIntermissionController::DIntermissionController(FIntermissionDescriptor *Desc, bool DeleteDesc, uint8_t state) { mDesc = Desc; mDeleteDesc = DeleteDesc; @@ -883,7 +883,7 @@ void DIntermissionController::OnDestroy () // //========================================================================== -void F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme, BYTE state) +void F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme, uint8_t state) { if (DIntermissionController::CurrentIntermission != NULL) { @@ -907,7 +907,7 @@ void F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme, BYTE stat // //========================================================================== -void F_StartIntermission(FName seq, BYTE state) +void F_StartIntermission(FName seq, uint8_t state) { FIntermissionDescriptor **pdesc = IntermissionDescriptors.CheckKey(seq); if (pdesc != NULL) diff --git a/src/intermission/intermission.h b/src/intermission/intermission.h index f0b423150..565e3a164 100644 --- a/src/intermission/intermission.h +++ b/src/intermission/intermission.h @@ -31,15 +31,15 @@ struct FIIntermissionPatch struct FCastSound { - BYTE mSequence; - BYTE mIndex; + uint8_t mSequence; + uint8_t mIndex; FString mSound; }; struct FICastSound { - BYTE mSequence; - BYTE mIndex; + uint8_t mSequence; + uint8_t mIndex; FSoundID mSound; }; @@ -285,11 +285,11 @@ class DIntermissionController : public DObject HAS_OBJECT_POINTERS FIntermissionDescriptor *mDesc; - TObjPtr mScreen; + TObjPtr mScreen; bool mDeleteDesc; bool mFirst; bool mAdvance, mSentAdvance; - BYTE mGameState; + uint8_t mGameState; int mIndex; bool NextPage(); @@ -297,7 +297,7 @@ class DIntermissionController : public DObject public: static DIntermissionController *CurrentIntermission; - DIntermissionController(FIntermissionDescriptor *mDesc = NULL, bool mDeleteDesc = false, BYTE state = FSTATE_ChangingLevel); + DIntermissionController(FIntermissionDescriptor *mDesc = NULL, bool mDeleteDesc = false, uint8_t state = FSTATE_ChangingLevel); bool Responder (event_t *ev); void Ticker (); void Drawer (); @@ -311,8 +311,8 @@ public: bool F_Responder (event_t* ev); void F_Ticker (); void F_Drawer (); -void F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme, BYTE state); -void F_StartIntermission(FName desc, BYTE state); +void F_StartIntermission(FIntermissionDescriptor *desc, bool deleteme, uint8_t state); +void F_StartIntermission(FName desc, uint8_t state); void F_EndFinale (); void F_AdvanceIntermission(); diff --git a/src/intermission/intermission_parse.cpp b/src/intermission/intermission_parse.cpp index b15b78e71..d8f46d2c3 100644 --- a/src/intermission/intermission_parse.cpp +++ b/src/intermission/intermission_parse.cpp @@ -382,10 +382,10 @@ bool FIntermissionActionCast::ParseKey(FScanner &sc) FCastSound *cs = &mCastSounds[mCastSounds.Reserve(1)]; sc.MustGetToken('='); sc.MustGetToken(TK_StringConst); - cs->mSequence = (BYTE)sc.MatchString(seqs); + cs->mSequence = (uint8_t)sc.MatchString(seqs); sc.MustGetToken(','); sc.MustGetToken(TK_IntConst); - cs->mIndex = (BYTE)sc.Number; + cs->mIndex = (uint8_t)sc.Number; sc.MustGetToken(','); sc.MustGetToken(TK_StringConst); cs->mSound = sc.String; @@ -573,7 +573,7 @@ void FMapInfoParser::ParseIntermission() struct EndSequence { - SBYTE EndType; + int8_t EndType; bool MusicLooping; bool PlayTheEnd; FString PicName; diff --git a/src/m_cheat.cpp b/src/m_cheat.cpp index 652385df2..ace2c0c61 100644 --- a/src/m_cheat.cpp +++ b/src/m_cheat.cpp @@ -352,7 +352,7 @@ void cht_DoCheat (player_t *player, int cheat) player->mo->SetState (player->mo->SpawnState); if (!(player->mo->flags2 & MF2_DONTTRANSLATE)) { - player->mo->Translation = TRANSLATION(TRANSLATION_Players, BYTE(player-players)); + player->mo->Translation = TRANSLATION(TRANSLATION_Players, uint8_t(player-players)); } if (player->ReadyWeapon != nullptr) { @@ -628,7 +628,7 @@ class DSuicider : public DThinker DECLARE_CLASS(DSuicider, DThinker) HAS_OBJECT_POINTERS; public: - TObjPtr Pawn; + TObjPtr Pawn; void Tick() { diff --git a/src/m_crc32.h b/src/m_crc32.h index f18b9448c..0d6a439db 100644 --- a/src/m_crc32.h +++ b/src/m_crc32.h @@ -37,16 +37,16 @@ // zlib includes some CRC32 stuff, so just use that -inline const DWORD *GetCRCTable () { return (const DWORD *)get_crc_table(); } -inline DWORD CalcCRC32 (const BYTE *buf, unsigned int len) +inline const uint32_t *GetCRCTable () { return (const uint32_t *)get_crc_table(); } +inline uint32_t CalcCRC32 (const uint8_t *buf, unsigned int len) { return crc32 (0, buf, len); } -inline DWORD AddCRC32 (DWORD crc, const BYTE *buf, unsigned int len) +inline uint32_t AddCRC32 (uint32_t crc, const uint8_t *buf, unsigned int len) { return crc32 (crc, buf, len); } -inline DWORD CRC1 (DWORD crc, const BYTE c, const DWORD *crcTable) +inline uint32_t CRC1 (uint32_t crc, const uint8_t c, const uint32_t *crcTable) { return crcTable[(crc & 0xff) ^ c] ^ (crc >> 8); } diff --git a/src/m_fixed.h b/src/m_fixed.h index dc7c3f4c9..b751d6b1f 100644 --- a/src/m_fixed.h +++ b/src/m_fixed.h @@ -70,9 +70,9 @@ __forceinline int32_t DivScale6(int32_t a, int32_t b) { return (int32_t)(((int64 __forceinline int32_t DivScale21(int32_t a, int32_t b) { return (int32_t)(((int64_t)a << 21) / b); } // only used by R_DrawVoxel __forceinline int32_t DivScale30(int32_t a, int32_t b) { return (int32_t)(((int64_t)a << 30) / b); } // only used once in the node builder -__forceinline void fillshort(void *buff, unsigned int count, WORD clear) +__forceinline void fillshort(void *buff, unsigned int count, uint16_t clear) { - SWORD *b2 = (SWORD *)buff; + int16_t *b2 = (int16_t *)buff; for (unsigned int i = 0; i != count; ++i) { b2[i] = clear; diff --git a/src/m_joy.cpp b/src/m_joy.cpp index 46c0b9006..dd5d8f58f 100644 --- a/src/m_joy.cpp +++ b/src/m_joy.cpp @@ -35,7 +35,7 @@ CUSTOM_CVAR(Bool, use_joystick, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINI // PRIVATE DATA DEFINITIONS ------------------------------------------------ // Bits 0 is X+, 1 is X-, 2 is Y+, and 3 is Y-. -static BYTE JoyAngleButtons[8] = { 1, 1+4, 4, 2+4, 2, 2+8, 8, 1+8 }; +static uint8_t JoyAngleButtons[8] = { 1, 1+4, 4, 2+4, 2, 2+8, 8, 1+8 }; // CODE -------------------------------------------------------------------- @@ -182,9 +182,9 @@ void M_SaveJoystickConfig(IJoystickConfig *joy) // //=========================================================================== -double Joy_RemoveDeadZone(double axisval, double deadzone, BYTE *buttons) +double Joy_RemoveDeadZone(double axisval, double deadzone, uint8_t *buttons) { - BYTE butt; + uint8_t butt; // Cancel out deadzone. if (fabs(axisval) < deadzone) diff --git a/src/m_joy.h b/src/m_joy.h index 9450e9c8e..042a59686 100644 --- a/src/m_joy.h +++ b/src/m_joy.h @@ -54,7 +54,7 @@ void M_SaveJoystickConfig(IJoystickConfig *joy); void Joy_GenerateButtonEvents(int oldbuttons, int newbuttons, int numbuttons, int base); void Joy_GenerateButtonEvents(int oldbuttons, int newbuttons, int numbuttons, const int *keys); int Joy_XYAxesToButtons(double x, double y); -double Joy_RemoveDeadZone(double axisval, double deadzone, BYTE *buttons); +double Joy_RemoveDeadZone(double axisval, double deadzone, uint8_t *buttons); // These ought to be provided by a system-specific i_input.cpp. void I_GetAxes(float axes[NUM_JOYAXIS]); diff --git a/src/m_misc.cpp b/src/m_misc.cpp index c49b342ce..40214f362 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -114,11 +114,11 @@ bool M_WriteFile (char const *name, void *source, int length) // // M_ReadFile // -int M_ReadFile (char const *name, BYTE **buffer) +int M_ReadFile (char const *name, uint8_t **buffer) { int handle, count, length; struct stat fileinfo; - BYTE *buf; + uint8_t *buf; handle = open (name, O_RDONLY | O_BINARY, 0666); if (handle == -1) @@ -127,7 +127,7 @@ int M_ReadFile (char const *name, BYTE **buffer) if (stat (name,&fileinfo) == -1) I_Error ("Couldn't read file %s", name); length = fileinfo.st_size; - buf = new BYTE[length]; + buf = new uint8_t[length]; count = read (handle, buf, length); close (handle); @@ -141,11 +141,11 @@ int M_ReadFile (char const *name, BYTE **buffer) // // M_ReadFile (same as above but use malloc instead of new to allocate the buffer.) // -int M_ReadFileMalloc (char const *name, BYTE **buffer) +int M_ReadFileMalloc (char const *name, uint8_t **buffer) { int handle, count, length; struct stat fileinfo; - BYTE *buf; + uint8_t *buf; handle = open (name, O_RDONLY | O_BINARY, 0666); if (handle == -1) @@ -154,7 +154,7 @@ int M_ReadFileMalloc (char const *name, BYTE **buffer) if (stat (name,&fileinfo) == -1) I_Error ("Couldn't read file %s", name); length = fileinfo.st_size; - buf = (BYTE*)M_Malloc(length); + buf = (uint8_t*)M_Malloc(length); count = read (handle, buf, length); close (handle); @@ -459,15 +459,15 @@ inline void putc(unsigned char chr, FileWriter *file) // // WritePCXfile // -void WritePCXfile (FileWriter *file, const BYTE *buffer, const PalEntry *palette, +void WritePCXfile (FileWriter *file, const uint8_t *buffer, const PalEntry *palette, ESSType color_type, int width, int height, int pitch) { - BYTE temprow[MAXWIDTH * 3]; - const BYTE *data; + uint8_t temprow[MAXWIDTH * 3]; + const uint8_t *data; int x, y; int runlen; int bytes_per_row_minus_one; - BYTE color; + uint8_t color; pcx_t pcx; pcx.manufacturer = 10; // PCX id @@ -600,7 +600,7 @@ void WritePCXfile (FileWriter *file, const BYTE *buffer, const PalEntry *palette // // WritePNGfile // -void WritePNGfile (FileWriter *file, const BYTE *buffer, const PalEntry *palette, +void WritePNGfile (FileWriter *file, const uint8_t *buffer, const PalEntry *palette, ESSType color_type, int width, int height, int pitch) { char software[100]; @@ -703,7 +703,7 @@ void M_ScreenShot (const char *filename) } // save the screenshot - const BYTE *buffer; + const uint8_t *buffer; int pitch; ESSType color_type; diff --git a/src/m_misc.h b/src/m_misc.h index d7365e1bb..cd2b09f2f 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -33,8 +33,8 @@ class FIWadManager; extern FGameConfigFile *GameConfig; bool M_WriteFile (char const *name, void *source, int length); -int M_ReadFile (char const *name, BYTE **buffer); -int M_ReadFileMalloc (char const *name, BYTE **buffer); +int M_ReadFile (char const *name, uint8_t **buffer); +int M_ReadFileMalloc (char const *name, uint8_t **buffer); void M_FindResponseFile (void); // [RH] M_ScreenShot now accepts a filename parameter. diff --git a/src/m_png.cpp b/src/m_png.cpp index b122212a5..50ecb29f4 100644 --- a/src/m_png.cpp +++ b/src/m_png.cpp @@ -66,13 +66,13 @@ struct IHDR { - DWORD Width; - DWORD Height; - BYTE BitDepth; - BYTE ColorType; - BYTE Compression; - BYTE Filter; - BYTE Interlace; + uint32_t Width; + uint32_t Height; + uint8_t BitDepth; + uint8_t ColorType; + uint8_t Compression; + uint8_t Filter; + uint8_t Interlace; }; PNGHandle::PNGHandle (FILE *file) : File(0), bDeleteFilePtr(true), ChunkPt(0) @@ -99,11 +99,11 @@ PNGHandle::~PNGHandle () // PRIVATE FUNCTION PROTOTYPES --------------------------------------------- -static inline void MakeChunk (void *where, DWORD type, size_t len); -static inline void StuffPalette (const PalEntry *from, BYTE *to); -static bool WriteIDAT (FileWriter *file, const BYTE *data, int len); -static void UnfilterRow (int width, BYTE *dest, BYTE *stream, BYTE *prev, int bpp); -static void UnpackPixels (int width, int bytesPerRow, int bitdepth, const BYTE *rowin, BYTE *rowout, bool grayscale); +static inline void MakeChunk (void *where, uint32_t type, size_t len); +static inline void StuffPalette (const PalEntry *from, uint8_t *to); +static bool WriteIDAT (FileWriter *file, const uint8_t *data, int len); +static void UnfilterRow (int width, uint8_t *dest, uint8_t *stream, uint8_t *prev, int bpp); +static void UnpackPixels (int width, int bytesPerRow, int bitdepth, const uint8_t *rowin, uint8_t *rowout, bool grayscale); // EXTERNAL DATA DECLARATIONS ---------------------------------------------- @@ -131,17 +131,17 @@ CVAR(Float, png_gamma, 0.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) // //========================================================================== -bool M_CreatePNG (FileWriter *file, const BYTE *buffer, const PalEntry *palette, +bool M_CreatePNG (FileWriter *file, const uint8_t *buffer, const PalEntry *palette, ESSType color_type, int width, int height, int pitch) { - BYTE work[8 + // signature + uint8_t work[8 + // signature 12+2*4+5 + // IHDR 12+4 + // gAMA 12+256*3]; // PLTE - DWORD *const sig = (DWORD *)&work[0]; + uint32_t *const sig = (uint32_t *)&work[0]; IHDR *const ihdr = (IHDR *)&work[8 + 8]; - DWORD *const gama = (DWORD *)((BYTE *)ihdr + 2*4+5 + 12); - BYTE *const plte = (BYTE *)gama + 4 + 12; + uint32_t *const gama = (uint32_t *)((uint8_t *)ihdr + 2*4+5 + 12); + uint8_t *const plte = (uint8_t *)gama + 4 + 12; size_t work_len; sig[0] = MAKE_ID(137,'P','N','G'); @@ -187,7 +187,7 @@ bool M_CreatePNG (FileWriter *file, const BYTE *buffer, const PalEntry *palette, bool M_CreateDummyPNG (FileWriter *file) { - static const BYTE dummyPNG[] = + static const uint8_t dummyPNG[] = { 137,'P','N','G',13,10,26,10, 0,0,0,13,'I','H','D','R', @@ -209,7 +209,7 @@ bool M_CreateDummyPNG (FileWriter *file) bool M_FinishPNG (FileWriter *file) { - static const BYTE iend[12] = { 0,0,0,0,73,69,78,68,174,66,96,130 }; + static const uint8_t iend[12] = { 0,0,0,0,73,69,78,68,174,66,96,130 }; return file->Write (iend, 12) == 12; } @@ -221,15 +221,15 @@ bool M_FinishPNG (FileWriter *file) // //========================================================================== -bool M_AppendPNGChunk (FileWriter *file, DWORD chunkID, const BYTE *chunkData, DWORD len) +bool M_AppendPNGChunk (FileWriter *file, uint32_t chunkID, const uint8_t *chunkData, uint32_t len) { - DWORD head[2] = { BigLong((unsigned int)len), chunkID }; - DWORD crc; + uint32_t head[2] = { BigLong((unsigned int)len), chunkID }; + uint32_t crc; if (file->Write (head, 8) == 8 && (len == 0 || file->Write (chunkData, len) == len)) { - crc = CalcCRC32 ((BYTE *)&head[1], 4); + crc = CalcCRC32 ((uint8_t *)&head[1], 4); if (len != 0) { crc = AddCRC32 (crc, chunkData, len); @@ -250,10 +250,10 @@ bool M_AppendPNGChunk (FileWriter *file, DWORD chunkID, const BYTE *chunkData, D bool M_AppendPNGText (FileWriter *file, const char *keyword, const char *text) { - struct { DWORD len, id; char key[80]; } head; + struct { uint32_t len, id; char key[80]; } head; int len = (int)strlen (text); int keylen = MIN ((int)strlen (keyword), 79); - DWORD crc; + uint32_t crc; head.len = BigLong(len + keylen + 1); head.id = MAKE_ID('t','E','X','t'); @@ -264,10 +264,10 @@ bool M_AppendPNGText (FileWriter *file, const char *keyword, const char *text) if ((int)file->Write (&head, keylen + 9) == keylen + 9 && (int)file->Write (text, len) == len) { - crc = CalcCRC32 ((BYTE *)&head+4, keylen + 5); + crc = CalcCRC32 ((uint8_t *)&head+4, keylen + 5); if (len != 0) { - crc = AddCRC32 (crc, (BYTE *)text, len); + crc = AddCRC32 (crc, (uint8_t *)text, len); } crc = BigLong((unsigned int)crc); return file->Write (&crc, 4) == 4; @@ -289,7 +289,7 @@ bool M_AppendPNGText (FileWriter *file, const char *keyword, const char *text) // //========================================================================== -unsigned int M_FindPNGChunk (PNGHandle *png, DWORD id) +unsigned int M_FindPNGChunk (PNGHandle *png, uint32_t id) { png->ChunkPt = 0; return M_NextPNGChunk (png, id); @@ -303,7 +303,7 @@ unsigned int M_FindPNGChunk (PNGHandle *png, DWORD id) // //========================================================================== -unsigned int M_NextPNGChunk (PNGHandle *png, DWORD id) +unsigned int M_NextPNGChunk (PNGHandle *png, uint32_t id) { for ( ; png->ChunkPt < png->Chunks.Size(); ++png->ChunkPt) { @@ -378,7 +378,7 @@ PNGHandle *M_VerifyPNG (FileReader *filer, bool takereader) { PNGHandle::Chunk chunk; PNGHandle *png; - DWORD data[2]; + uint32_t data[2]; bool sawIDAT = false; if (filer->Read(&data, 8) != 8) @@ -479,14 +479,14 @@ void M_FreePNG (PNGHandle *png) // //========================================================================== -bool M_ReadIDAT (FileReader *file, BYTE *buffer, int width, int height, int pitch, - BYTE bitdepth, BYTE colortype, BYTE interlace, unsigned int chunklen) +bool M_ReadIDAT (FileReader *file, uint8_t *buffer, int width, int height, int pitch, + uint8_t bitdepth, uint8_t colortype, uint8_t interlace, unsigned int chunklen) { // Uninterlaced images are treated as a conceptual eighth pass by these tables. - static const BYTE passwidthshift[8] = { 3, 3, 2, 2, 1, 1, 0, 0 }; - static const BYTE passheightshift[8] = { 3, 3, 3, 2, 2, 1, 1, 0 }; - static const BYTE passrowoffset[8] = { 0, 0, 4, 0, 2, 0, 1, 0 }; - static const BYTE passcoloffset[8] = { 0, 4, 0, 2, 0, 1, 0, 0 }; + static const uint8_t passwidthshift[8] = { 3, 3, 2, 2, 1, 1, 0, 0 }; + static const uint8_t passheightshift[8] = { 3, 3, 3, 2, 2, 1, 1, 0 }; + static const uint8_t passrowoffset[8] = { 0, 0, 4, 0, 2, 0, 1, 0 }; + static const uint8_t passcoloffset[8] = { 0, 4, 0, 2, 0, 1, 0, 0 }; Byte *inputLine, *prev, *curr, *adam7buff[3], *bufferend; Byte chunkbuffer[4096]; @@ -597,8 +597,8 @@ bool M_ReadIDAT (FileReader *file, BYTE *buffer, int width, int height, int pitc } else { - const BYTE *in; - BYTE *out; + const uint8_t *in; + uint8_t *out; int colstep, x; // Store pixels into a temporary buffer @@ -628,7 +628,7 @@ bool M_ReadIDAT (FileReader *file, BYTE *buffer, int width, int height, int pitc case 2: for (x = passwidth; x > 0; --x) { - *(WORD *)out = *(WORD *)in; + *(uint16_t *)out = *(uint16_t *)in; out += colstep; in += 2; } @@ -648,7 +648,7 @@ bool M_ReadIDAT (FileReader *file, BYTE *buffer, int width, int height, int pitc case 4: for (x = passwidth; x > 0; --x) { - *(DWORD *)out = *(DWORD *)in; + *(uint32_t *)out = *(uint32_t *)in; out += colstep; in += 4; } @@ -666,7 +666,7 @@ bool M_ReadIDAT (FileReader *file, BYTE *buffer, int width, int height, int pitc if (chunklen == 0 && !lastIDAT) { - DWORD x[3]; + uint32_t x[3]; if (file->Read (x, 12) != 12) { @@ -711,12 +711,12 @@ bool M_ReadIDAT (FileReader *file, BYTE *buffer, int width, int height, int pitc // //========================================================================== -static inline void MakeChunk (void *where, DWORD type, size_t len) +static inline void MakeChunk (void *where, uint32_t type, size_t len) { - BYTE *const data = (BYTE *)where; - *(DWORD *)(data - 8) = BigLong ((unsigned int)len); - *(DWORD *)(data - 4) = type; - *(DWORD *)(data + len) = BigLong ((unsigned int)CalcCRC32 (data-4, (unsigned int)(len+4))); + uint8_t *const data = (uint8_t *)where; + *(uint32_t *)(data - 8) = BigLong ((unsigned int)len); + *(uint32_t *)(data - 4) = type; + *(uint32_t *)(data + len) = BigLong ((unsigned int)CalcCRC32 (data-4, (unsigned int)(len+4))); } //========================================================================== @@ -727,7 +727,7 @@ static inline void MakeChunk (void *where, DWORD type, size_t len) // //========================================================================== -static void StuffPalette (const PalEntry *from, BYTE *to) +static void StuffPalette (const PalEntry *from, uint8_t *to) { for (int i = 256; i > 0; --i) { @@ -746,9 +746,9 @@ static void StuffPalette (const PalEntry *from, BYTE *to) // //========================================================================== -DWORD CalcSum(Byte *row, int len) +uint32_t CalcSum(Byte *row, int len) { - DWORD sum = 0; + uint32_t sum = 0; while (len-- != 0) { @@ -776,8 +776,8 @@ static int SelectFilter(Byte row[5][1 + MAXWIDTH*3], Byte prior[MAXWIDTH*3], int // As it turns out, it seems no filtering is the best for Doom screenshots, // no matter what the heuristic might determine. return 0; - DWORD sum; - DWORD bestsum; + uint32_t sum; + uint32_t bestsum; int bestfilter; int x; @@ -904,7 +904,7 @@ static int SelectFilter(Byte row[5][1 + MAXWIDTH*3], Byte prior[MAXWIDTH*3], int // //========================================================================== -bool M_SaveBitmap(const BYTE *from, ESSType color_type, int width, int height, int pitch, FileWriter *file) +bool M_SaveBitmap(const uint8_t *from, ESSType color_type, int width, int height, int pitch, FileWriter *file) { #if USE_FILTER_HEURISTIC Byte prior[MAXWIDTH*3]; @@ -1044,13 +1044,13 @@ bool M_SaveBitmap(const BYTE *from, ESSType color_type, int width, int height, i // //========================================================================== -static bool WriteIDAT (FileWriter *file, const BYTE *data, int len) +static bool WriteIDAT (FileWriter *file, const uint8_t *data, int len) { - DWORD foo[2], crc; + uint32_t foo[2], crc; foo[0] = BigLong (len); foo[1] = MAKE_ID('I','D','A','T'); - crc = CalcCRC32 ((BYTE *)&foo[1], 4); + crc = CalcCRC32 ((uint8_t *)&foo[1], 4); crc = BigLong ((unsigned int)AddCRC32 (crc, data, len)); if (file->Write (foo, 8) != 8 || @@ -1072,7 +1072,7 @@ static bool WriteIDAT (FileWriter *file, const BYTE *data, int len) // //========================================================================== -void UnfilterRow (int width, BYTE *dest, BYTE *row, BYTE *prev, int bpp) +void UnfilterRow (int width, uint8_t *dest, uint8_t *row, uint8_t *prev, int bpp) { int x; @@ -1110,7 +1110,7 @@ void UnfilterRow (int width, BYTE *dest, BYTE *row, BYTE *prev, int bpp) while (--x); for (x = width - bpp; x > 0; --x) { - *dest = *row++ + (BYTE)((unsigned(*(dest - bpp)) + unsigned(*prev++)) >> 1); + *dest = *row++ + (uint8_t)((unsigned(*(dest - bpp)) + unsigned(*prev++)) >> 1); dest++; } break; @@ -1134,7 +1134,7 @@ void UnfilterRow (int width, BYTE *dest, BYTE *row, BYTE *prev, int bpp) pc = abs (pa + pb); pa = abs (pa); pb = abs (pb); - *dest = *row + (BYTE)((pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c); + *dest = *row + (uint8_t)((pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c); dest++; row++; prev++; @@ -1158,11 +1158,11 @@ void UnfilterRow (int width, BYTE *dest, BYTE *row, BYTE *prev, int bpp) // //========================================================================== -static void UnpackPixels (int width, int bytesPerRow, int bitdepth, const BYTE *rowin, BYTE *rowout, bool grayscale) +static void UnpackPixels (int width, int bytesPerRow, int bitdepth, const uint8_t *rowin, uint8_t *rowout, bool grayscale) { - const BYTE *in; - BYTE *out; - BYTE pack; + const uint8_t *in; + uint8_t *out; + uint8_t pack; int lastbyte; assert(bitdepth == 1 || bitdepth == 2 || bitdepth == 4); @@ -1256,7 +1256,7 @@ static void UnpackPixels (int width, int bytesPerRow, int bitdepth, const BYTE * union { uint32 bits2l; - BYTE bits2[4]; + uint8_t bits2[4]; }; out = rowout + width; diff --git a/src/m_png.h b/src/m_png.h index 9fb9eeeff..2390059c1 100644 --- a/src/m_png.h +++ b/src/m_png.h @@ -44,14 +44,14 @@ // The passed file should be a newly created file. // This function writes the PNG signature and the IHDR, gAMA, PLTE, and IDAT // chunks. -bool M_CreatePNG (FileWriter *file, const BYTE *buffer, const PalEntry *pal, +bool M_CreatePNG (FileWriter *file, const uint8_t *buffer, const PalEntry *pal, ESSType color_type, int width, int height, int pitch); // Creates a grayscale 1x1 PNG file. Used for savegames without savepics. bool M_CreateDummyPNG (FileWriter *file); // Appends any chunk to a PNG file started with M_CreatePNG. -bool M_AppendPNGChunk (FileWriter *file, DWORD chunkID, const BYTE *chunkData, DWORD len); +bool M_AppendPNGChunk (FileWriter *file, uint32_t chunkID, const uint8_t *chunkData, uint32_t len); // Adds a tEXt chunk to a PNG file started with M_CreatePNG. bool M_AppendPNGText (FileWriter *file, const char *keyword, const char *text); @@ -59,7 +59,7 @@ bool M_AppendPNGText (FileWriter *file, const char *keyword, const char *text); // Appends the IEND chunk to a PNG file. bool M_FinishPNG (FileWriter *file); -bool M_SaveBitmap(const BYTE *from, ESSType color_type, int width, int height, int pitch, FileWriter *file); +bool M_SaveBitmap(const uint8_t *from, ESSType color_type, int width, int height, int pitch, FileWriter *file); // PNG Reading -------------------------------------------------------------- @@ -68,9 +68,9 @@ struct PNGHandle { struct Chunk { - DWORD ID; - DWORD Offset; - DWORD Size; + uint32_t ID; + uint32_t Offset; + uint32_t Size; }; FileReader *File; @@ -94,11 +94,11 @@ PNGHandle *M_VerifyPNG (FILE *file); // Finds a chunk in a PNG file. The file pointer will be positioned at the // beginning of the chunk data, and its length will be returned. A return // value of 0 indicates the chunk was either not present or had 0 length. -unsigned int M_FindPNGChunk (PNGHandle *png, DWORD chunkID); +unsigned int M_FindPNGChunk (PNGHandle *png, uint32_t chunkID); // Finds a chunk in the PNG file, starting its search at whatever chunk // the file pointer is currently positioned at. -unsigned int M_NextPNGChunk (PNGHandle *png, DWORD chunkID); +unsigned int M_NextPNGChunk (PNGHandle *png, uint32_t chunkID); // Finds a PNG text chunk with the given signature and returns a pointer // to a NULL-terminated string if present. Returns NULL on failure. @@ -108,8 +108,8 @@ bool M_GetPNGText (PNGHandle *png, const char *keyword, char *buffer, size_t buf // The file must be positioned at the start of the first IDAT. It reads // image data into the provided buffer. Returns true on success. -bool M_ReadIDAT (FileReader *file, BYTE *buffer, int width, int height, int pitch, - BYTE bitdepth, BYTE colortype, BYTE interlace, unsigned int idatlen); +bool M_ReadIDAT (FileReader *file, uint8_t *buffer, int width, int height, int pitch, + uint8_t bitdepth, uint8_t colortype, uint8_t interlace, unsigned int idatlen); class FTexture; diff --git a/src/m_random.cpp b/src/m_random.cpp index 697bb173f..ecb2bfe9e 100644 --- a/src/m_random.cpp +++ b/src/m_random.cpp @@ -94,10 +94,10 @@ extern FRandom pr_damagemobj; FRandom M_Random; // Global seed. This is modified predictably to initialize every RNG. -DWORD rngseed; +uint32_t rngseed; // Static RNG marker. This is only used when the RNG is set for each new game. -DWORD staticrngseed; +uint32_t staticrngseed; bool use_staticrng; // Allows checking or staticly setting the global seed. @@ -169,7 +169,7 @@ FRandom::FRandom () FRandom::FRandom (const char *name) { - NameCRC = CalcCRC32 ((const BYTE *)name, (unsigned int)strlen (name)); + NameCRC = CalcCRC32 ((const uint8_t *)name, (unsigned int)strlen (name)); #ifndef NDEBUG initialized = false; Name = name; @@ -257,12 +257,12 @@ void FRandom::StaticClearRandom () // //========================================================================== -void FRandom::Init(DWORD seed) +void FRandom::Init(uint32_t seed) { // [RH] Use the RNG's name's CRC to modify the original seed. // This way, new RNGs can be added later, and it doesn't matter // which order they get initialized in. - DWORD seeds[2] = { NameCRC, seed }; + uint32_t seeds[2] = { NameCRC, seed }; InitByArray(seeds, 2); } @@ -270,13 +270,13 @@ void FRandom::Init(DWORD seed) // // FRandom :: StaticSumSeeds // -// This function produces a DWORD that can be used to check the consistancy +// This function produces a uint32_t that can be used to check the consistancy // of network games between different machines. Only a select few RNGs are // used for the sum, because not all RNGs are important to network sync. // //========================================================================== -DWORD FRandom::StaticSumSeeds () +uint32_t FRandom::StaticSumSeeds () { return pr_spawnmobj.sfmt.u[0] + pr_spawnmobj.idx + @@ -377,7 +377,7 @@ void FRandom::StaticReadRNGState(FSerializer &arc) FRandom *FRandom::StaticFindRNG (const char *name) { - DWORD NameCRC = CalcCRC32 ((const BYTE *)name, (unsigned int)strlen (name)); + uint32_t NameCRC = CalcCRC32 ((const uint8_t *)name, (unsigned int)strlen (name)); // Use the default RNG if this one happens to have a CRC of 0. if (NameCRC == 0) return &pr_exrandom; diff --git a/src/m_random.h b/src/m_random.h index b3e0f3b28..c82c77a62 100644 --- a/src/m_random.h +++ b/src/m_random.h @@ -86,21 +86,21 @@ public: return operator()(); } - void Init(DWORD seed); + void Init(uint32_t seed); // SFMT interface unsigned int GenRand32(); QWORD GenRand64(); - void FillArray32(DWORD *array, int size); + void FillArray32(uint32_t *array, int size); void FillArray64(QWORD *array, int size); - void InitGenRand(DWORD seed); - void InitByArray(DWORD *init_key, int key_length); + void InitGenRand(uint32_t seed); + void InitByArray(uint32_t *init_key, int key_length); int GetMinArraySize32(); int GetMinArraySize64(); /* These real versions are due to Isaku Wada */ /** generates a random number on [0,1]-real-interval */ - static inline double ToReal1(DWORD v) + static inline double ToReal1(uint32_t v) { return v * (1.0/4294967295.0); /* divided by 2^32-1 */ @@ -113,7 +113,7 @@ public: } /** generates a random number on [0,1)-real-interval */ - static inline double ToReal2(DWORD v) + static inline double ToReal2(uint32_t v) { return v * (1.0/4294967296.0); /* divided by 2^32 */ @@ -126,7 +126,7 @@ public: } /** generates a random number on (0,1)-real-interval */ - static inline double ToReal3(DWORD v) + static inline double ToReal3(uint32_t v) { return (((double)v) + 0.5)*(1.0/4294967296.0); /* divided by 2^32 */ @@ -147,7 +147,7 @@ public: /** generates a random number on [0,1) with 53-bit resolution from two * 32 bit integers */ - static inline double ToRes53Mix(DWORD x, DWORD y) + static inline double ToRes53Mix(uint32_t x, uint32_t y) { return ToRes53(x | ((QWORD)y << 32)); } @@ -164,7 +164,7 @@ public: */ inline double GenRand_Res53_Mix() { - DWORD x, y; + uint32_t x, y; x = GenRand32(); y = GenRand32(); @@ -173,7 +173,7 @@ public: // Static interface static void StaticClearRandom (); - static DWORD StaticSumSeeds (); + static uint32_t StaticSumSeeds (); static void StaticReadRNGState (FSerializer &arc); static void StaticWriteRNGState (FSerializer &file); static FRandom *StaticFindRNG(const char *name); @@ -187,7 +187,7 @@ private: const char *Name; #endif FRandom *Next; - DWORD NameCRC; + uint32_t NameCRC; static FRandom *RNGList; @@ -215,9 +215,9 @@ private: #endif }; -extern DWORD rngseed; // The starting seed (not part of state) +extern uint32_t rngseed; // The starting seed (not part of state) -extern DWORD staticrngseed; // Static rngseed that can be set by the user +extern uint32_t staticrngseed; // Static rngseed that can be set by the user extern bool use_staticrng; diff --git a/src/md5.cpp b/src/md5.cpp index 772910843..ae3cb53c0 100644 --- a/src/md5.cpp +++ b/src/md5.cpp @@ -22,12 +22,12 @@ #include "templates.h" #ifdef __BIG_ENDIAN__ -void byteSwap(DWORD *buf, unsigned words) +void byteSwap(uint32_t *buf, unsigned words) { - BYTE *p = (BYTE *)buf; + uint8_t *p = (uint8_t *)buf; do { - *buf++ = (DWORD)((unsigned)p[3] << 8 | p[2]) << 16 | + *buf++ = (uint32_t)((unsigned)p[3] << 8 | p[2]) << 16 | ((unsigned)p[1] << 8 | p[0]); p += 4; } while (--words); @@ -55,9 +55,9 @@ void MD5Context::Init() * Update context to reflect the concatenation of another buffer full * of bytes. */ -void MD5Context::Update(const BYTE *buf, unsigned len) +void MD5Context::Update(const uint8_t *buf, unsigned len) { - DWORD t; + uint32_t t; /* Update byte count */ @@ -67,13 +67,13 @@ void MD5Context::Update(const BYTE *buf, unsigned len) t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */ if (t > len) { - memcpy((BYTE *)in + 64 - t, buf, len); + memcpy((uint8_t *)in + 64 - t, buf, len); return; } /* First chunk is an odd size */ if (t < 64) { - memcpy((BYTE *)in + 64 - t, buf, t); + memcpy((uint8_t *)in + 64 - t, buf, t); byteSwap(in, 16); MD5Transform(this->buf, in); buf += t; @@ -96,7 +96,7 @@ void MD5Context::Update(const BYTE *buf, unsigned len) void MD5Context::Update(FileReader *file, unsigned len) { - BYTE readbuf[8192]; + uint8_t readbuf[8192]; long t; while (len != 0) @@ -112,10 +112,10 @@ void MD5Context::Update(FileReader *file, unsigned len) * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ -void MD5Context::Final(BYTE digest[16]) +void MD5Context::Final(uint8_t digest[16]) { int count = bytes[0] & 0x3f; /* Number of bytes in ctx->in */ - BYTE *p = (BYTE *)in + count; + uint8_t *p = (uint8_t *)in + count; /* Set the first char of padding to 0x80. There is always room. */ *p++ = 0x80; @@ -128,7 +128,7 @@ void MD5Context::Final(BYTE digest[16]) memset(p, 0, count + 8); byteSwap(in, 16); MD5Transform(buf, in); - p = (BYTE *)in; + p = (uint8_t *)in; count = 56; } memset(p, 0, count); @@ -164,9 +164,9 @@ void MD5Context::Final(BYTE digest[16]) * the data and converts bytes into longwords for this routine. */ void -MD5Transform(DWORD buf[4], const DWORD in[16]) +MD5Transform(uint32_t buf[4], const uint32_t in[16]) { - DWORD a, b, c, d; + uint32_t a, b, c, d; a = buf[0]; b = buf[1]; @@ -276,7 +276,7 @@ CCMD (md5sum) else { MD5Context md5; - BYTE readbuf[8192]; + uint8_t readbuf[8192]; size_t len; while ((len = fread(readbuf, 1, sizeof(readbuf), file)) > 0) diff --git a/src/md5.h b/src/md5.h index 173fcbb75..1f2765378 100644 --- a/src/md5.h +++ b/src/md5.h @@ -25,17 +25,17 @@ struct MD5Context MD5Context() { Init(); } void Init(); - void Update(const BYTE *buf, unsigned len); + void Update(const uint8_t *buf, unsigned len); void Update(FileReader *file, unsigned len); - void Final(BYTE digest[16]); + void Final(uint8_t digest[16]); private: - DWORD buf[4]; - DWORD bytes[2]; - DWORD in[16]; + uint32_t buf[4]; + uint32_t bytes[2]; + uint32_t in[16]; }; -void MD5Transform(DWORD buf[4], DWORD const in[16]); +void MD5Transform(uint32_t buf[4], uint32_t const in[16]); #endif /* !MD5_H */ diff --git a/src/memarena.cpp b/src/memarena.cpp index af9f91547..88b2c8c4c 100644 --- a/src/memarena.cpp +++ b/src/memarena.cpp @@ -201,7 +201,7 @@ FMemArena::Block *FMemArena::AddBlock(size_t size) // Search for a free block to use for (last = &FreeBlocks, mem = FreeBlocks; mem != NULL; last = &mem->NextBlock, mem = mem->NextBlock) { - if ((BYTE *)mem->Limit - (BYTE *)mem >= (ptrdiff_t)size) + if ((uint8_t *)mem->Limit - (uint8_t *)mem >= (ptrdiff_t)size) { *last = mem->NextBlock; break; @@ -220,7 +220,7 @@ FMemArena::Block *FMemArena::AddBlock(size_t size) size += BlockSize/2; } mem = (Block *)M_Malloc(size); - mem->Limit = (BYTE *)mem + size; + mem->Limit = (uint8_t *)mem + size; } mem->Reset(); mem->NextBlock = TopBlock; diff --git a/src/menu/menu.cpp b/src/menu/menu.cpp index 15df785bf..435a867a2 100644 --- a/src/menu/menu.cpp +++ b/src/menu/menu.cpp @@ -771,7 +771,7 @@ void M_Drawer (void) { player = camera->player; } - fade = PalEntry (BYTE(player->BlendA*255), BYTE(player->BlendR*255), BYTE(player->BlendG*255), BYTE(player->BlendB*255)); + fade = PalEntry (uint8_t(player->BlendA*255), uint8_t(player->BlendR*255), uint8_t(player->BlendG*255), uint8_t(player->BlendB*255)); } diff --git a/src/menu/menu.h b/src/menu/menu.h index 0b6b55ea2..5c40b7f7b 100644 --- a/src/menu/menu.h +++ b/src/menu/menu.h @@ -262,7 +262,7 @@ public: MOUSE_Release }; - TObjPtr mParentMenu; + TObjPtr mParentMenu; bool mMouseCapture; bool mBackbuttonSelected; bool DontDim; diff --git a/src/menu/menudef.cpp b/src/menu/menudef.cpp index 239366dcf..a9fd42773 100644 --- a/src/menu/menudef.cpp +++ b/src/menu/menudef.cpp @@ -413,7 +413,7 @@ static void ParseListMenuBody(FScanner &sc, DListMenuDescriptor *desc) auto f = TexMan.CheckForTexture(sc.String, FTexture::TEX_MiscPatch); if (!f.Exists()) { - sc.ScriptError("Unknown texture %s", sc.String); + sc.ScriptMessage("Unknown texture %s", sc.String); } params.Push(f.GetIndex()); } diff --git a/src/menu/videomenu.cpp b/src/menu/videomenu.cpp index dfb08f13c..2c3abe52b 100644 --- a/src/menu/videomenu.cpp +++ b/src/menu/videomenu.cpp @@ -77,7 +77,7 @@ EXTERN_CVAR (Bool, vid_tft) // Defined below int testingmode; // Holds time to revert to old mode int OldWidth, OldHeight, OldBits; static FIntCVar DummyDepthCvar (NULL, 0, 0); -static BYTE BitTranslate[32]; +static uint8_t BitTranslate[32]; CUSTOM_CVAR (Int, menu_screenratios, -1, CVAR_ARCHIVE) { diff --git a/src/mus2midi.cpp b/src/mus2midi.cpp index 9d27d31ca..09abdeb19 100644 --- a/src/mus2midi.cpp +++ b/src/mus2midi.cpp @@ -43,7 +43,7 @@ #include "mus2midi.h" #include "doomdef.h" -static const BYTE StaticMIDIhead[] = +static const uint8_t StaticMIDIhead[] = { 'M','T','h','d', 0, 0, 0, 6, 0, 0, // format 0: only one track 0, 1, // yes, there is really only one track @@ -53,9 +53,9 @@ static const BYTE StaticMIDIhead[] = 0, 255, 81, 3, 0x07, 0xa1, 0x20 }; -extern int MUSHeaderSearch(const BYTE *head, int len); +extern int MUSHeaderSearch(const uint8_t *head, int len); -static const BYTE CtrlTranslate[15] = +static const uint8_t CtrlTranslate[15] = { 0, // program change 0, // bank select @@ -74,11 +74,11 @@ static const BYTE CtrlTranslate[15] = 121, // reset all controllers }; -static size_t ReadVarLen (const BYTE *buf, int *time_out) +static size_t ReadVarLen (const uint8_t *buf, int *time_out) { int time = 0; size_t ofs = 0; - BYTE t; + uint8_t t; do { @@ -89,7 +89,7 @@ static size_t ReadVarLen (const BYTE *buf, int *time_out) return ofs; } -static size_t WriteVarLen (TArray &file, int time) +static size_t WriteVarLen (TArray &file, int time) { long buffer; size_t ofs; @@ -101,7 +101,7 @@ static size_t WriteVarLen (TArray &file, int time) } for (ofs = 0;;) { - file.Push(BYTE(buffer & 0xff)); + file.Push(uint8_t(buffer & 0xff)); if (buffer & 0x80) buffer >>= 8; else @@ -110,16 +110,16 @@ static size_t WriteVarLen (TArray &file, int time) return ofs; } -bool ProduceMIDI (const BYTE *musBuf, int len, TArray &outFile) +bool ProduceMIDI (const uint8_t *musBuf, int len, TArray &outFile) { - BYTE midStatus, midArgs, mid1, mid2; + uint8_t midStatus, midArgs, mid1, mid2; size_t mus_p, maxmus_p; - BYTE event; + uint8_t event; int deltaTime; const MUSHeader *musHead; - BYTE status; - BYTE chanUsed[16]; - BYTE lastVel[16]; + uint8_t status; + uint8_t chanUsed[16]; + uint8_t lastVel[16]; long trackLen; bool no_op; @@ -159,7 +159,7 @@ bool ProduceMIDI (const BYTE *musBuf, int len, TArray &outFile) while (mus_p < maxmus_p && (event & 0x70) != MUS_SCOREEND) { int channel; - BYTE t = 0; + uint8_t t = 0; event = musBuf[mus_p++]; @@ -291,16 +291,16 @@ bool ProduceMIDI (const BYTE *musBuf, int len, TArray &outFile) // fill in track length trackLen = outFile.Size() - 22; - outFile[18] = BYTE((trackLen >> 24) & 255); - outFile[19] = BYTE((trackLen >> 16) & 255); - outFile[20] = BYTE((trackLen >> 8) & 255); - outFile[21] = BYTE(trackLen & 255); + outFile[18] = uint8_t((trackLen >> 24) & 255); + outFile[19] = uint8_t((trackLen >> 16) & 255); + outFile[20] = uint8_t((trackLen >> 8) & 255); + outFile[21] = uint8_t(trackLen & 255); return true; } -bool ProduceMIDI(const BYTE *musBuf, int len, FILE *outFile) +bool ProduceMIDI(const uint8_t *musBuf, int len, FILE *outFile) { - TArray work; + TArray work; if (ProduceMIDI(musBuf, len, work)) { return fwrite(&work[0], 1, work.Size(), outFile) == work.Size(); diff --git a/src/mus2midi.h b/src/mus2midi.h index 930f0a10b..7b61f9e85 100644 --- a/src/mus2midi.h +++ b/src/mus2midi.h @@ -41,38 +41,38 @@ #include #include "doomtype.h" -#define MIDI_SYSEX ((BYTE)0xF0) // SysEx begin -#define MIDI_SYSEXEND ((BYTE)0xF7) // SysEx end -#define MIDI_META ((BYTE)0xFF) // Meta event begin -#define MIDI_META_TEMPO ((BYTE)0x51) -#define MIDI_META_EOT ((BYTE)0x2F) // End-of-track -#define MIDI_META_SSPEC ((BYTE)0x7F) // System-specific event +#define MIDI_SYSEX ((uint8_t)0xF0) // SysEx begin +#define MIDI_SYSEXEND ((uint8_t)0xF7) // SysEx end +#define MIDI_META ((uint8_t)0xFF) // Meta event begin +#define MIDI_META_TEMPO ((uint8_t)0x51) +#define MIDI_META_EOT ((uint8_t)0x2F) // End-of-track +#define MIDI_META_SSPEC ((uint8_t)0x7F) // System-specific event -#define MIDI_NOTEOFF ((BYTE)0x80) // + note + velocity -#define MIDI_NOTEON ((BYTE)0x90) // + note + velocity -#define MIDI_POLYPRESS ((BYTE)0xA0) // + pressure (2 bytes) -#define MIDI_CTRLCHANGE ((BYTE)0xB0) // + ctrlr + value -#define MIDI_PRGMCHANGE ((BYTE)0xC0) // + new patch -#define MIDI_CHANPRESS ((BYTE)0xD0) // + pressure (1 byte) -#define MIDI_PITCHBEND ((BYTE)0xE0) // + pitch bend (2 bytes) +#define MIDI_NOTEOFF ((uint8_t)0x80) // + note + velocity +#define MIDI_NOTEON ((uint8_t)0x90) // + note + velocity +#define MIDI_POLYPRESS ((uint8_t)0xA0) // + pressure (2 bytes) +#define MIDI_CTRLCHANGE ((uint8_t)0xB0) // + ctrlr + value +#define MIDI_PRGMCHANGE ((uint8_t)0xC0) // + new patch +#define MIDI_CHANPRESS ((uint8_t)0xD0) // + pressure (1 byte) +#define MIDI_PITCHBEND ((uint8_t)0xE0) // + pitch bend (2 bytes) -#define MUS_NOTEOFF ((BYTE)0x00) -#define MUS_NOTEON ((BYTE)0x10) -#define MUS_PITCHBEND ((BYTE)0x20) -#define MUS_SYSEVENT ((BYTE)0x30) -#define MUS_CTRLCHANGE ((BYTE)0x40) -#define MUS_SCOREEND ((BYTE)0x60) +#define MUS_NOTEOFF ((uint8_t)0x00) +#define MUS_NOTEON ((uint8_t)0x10) +#define MUS_PITCHBEND ((uint8_t)0x20) +#define MUS_SYSEVENT ((uint8_t)0x30) +#define MUS_CTRLCHANGE ((uint8_t)0x40) +#define MUS_SCOREEND ((uint8_t)0x60) typedef struct { - DWORD Magic; - WORD SongLen; - WORD SongStart; - WORD NumChans; - WORD NumSecondaryChans; - WORD NumInstruments; - WORD Pad; - // WORD UsedInstruments[NumInstruments]; + uint32_t Magic; + uint16_t SongLen; + uint16_t SongStart; + uint16_t NumChans; + uint16_t NumSecondaryChans; + uint16_t NumInstruments; + uint16_t Pad; + // uint16_t UsedInstruments[NumInstruments]; } MUSHeader; #endif //__MUS2MIDI_H__ diff --git a/src/nodebuild.cpp b/src/nodebuild.cpp index 30c44b69c..d4794c639 100644 --- a/src/nodebuild.cpp +++ b/src/nodebuild.cpp @@ -131,11 +131,11 @@ void FNodeBuilder::BuildTree () CreateSubsectorsForReal (); } -int FNodeBuilder::CreateNode (DWORD set, unsigned int count, fixed_t bbox[4]) +int FNodeBuilder::CreateNode (uint32_t set, unsigned int count, fixed_t bbox[4]) { node_t node; int skip, selstat; - DWORD splitseg; + uint32_t splitseg; skip = int(count / MaxSegs); @@ -149,7 +149,7 @@ int FNodeBuilder::CreateNode (DWORD set, unsigned int count, fixed_t bbox[4]) CheckSubsector (set, node, splitseg)) { // Create a normal node - DWORD set1, set2; + uint32_t set1, set2; unsigned int count1, count2; SplitSegs (set, node, splitseg, set1, set2, count1, count2); @@ -170,7 +170,7 @@ int FNodeBuilder::CreateNode (DWORD set, unsigned int count, fixed_t bbox[4]) } } -int FNodeBuilder::CreateSubsector (DWORD set, fixed_t bbox[4]) +int FNodeBuilder::CreateSubsector (uint32_t set, fixed_t bbox[4]) { int ssnum, count; @@ -216,8 +216,8 @@ void FNodeBuilder::CreateSubsectorsForReal () for (i = 0; i < SubsectorSets.Size(); ++i) { - DWORD set = SubsectorSets[i]; - DWORD firstline = (DWORD)SegList.Size(); + uint32_t set = SubsectorSets[i]; + uint32_t firstline = (uint32_t)SegList.Size(); while (set != DWORD_MAX) { @@ -227,7 +227,7 @@ void FNodeBuilder::CreateSubsectorsForReal () SegList.Push (ptr); set = ptr.SegPtr->next; } - sub.numlines = (DWORD)(SegList.Size() - firstline); + sub.numlines = (uint32_t)(SegList.Size() - firstline); sub.firstline = (seg_t *)(size_t)firstline; // Sort segs by linedef for special effects @@ -247,7 +247,7 @@ void FNodeBuilder::CreateSubsectorsForReal () Vertices[SegList[i].SegPtr->v2].y>>16, Vertices[SegList[i].SegPtr->v1].x, Vertices[SegList[i].SegPtr->v1].y, Vertices[SegList[i].SegPtr->v2].x, Vertices[SegList[i].SegPtr->v2].y)); - SegList[i].SegNum = DWORD(SegList[i].SegPtr - &Segs[0]); + SegList[i].SegNum = uint32_t(SegList[i].SegPtr - &Segs[0]); } Subsectors.Push (sub); } @@ -318,10 +318,10 @@ int FNodeBuilder::SortSegs (const void *a, const void *b) // a splitter is synthesized, and true is returned to continue processing // down this branch of the tree. -bool FNodeBuilder::CheckSubsector (DWORD set, node_t &node, DWORD &splitseg) +bool FNodeBuilder::CheckSubsector (uint32_t set, node_t &node, uint32_t &splitseg) { sector_t *sec; - DWORD seg; + uint32_t seg; sec = NULL; seg = set; @@ -381,10 +381,10 @@ bool FNodeBuilder::CheckSubsector (DWORD set, node_t &node, DWORD &splitseg) // When creating GL nodes, we need to check for segs with the same start and // end vertices and split them into two subsectors. -bool FNodeBuilder::CheckSubsectorOverlappingSegs (DWORD set, node_t &node, DWORD &splitseg) +bool FNodeBuilder::CheckSubsectorOverlappingSegs (uint32_t set, node_t &node, uint32_t &splitseg) { int v1, v2; - DWORD seg1, seg2; + uint32_t seg1, seg2; for (seg1 = set; seg1 != DWORD_MAX; seg1 = Segs[seg1].next) { @@ -424,7 +424,7 @@ bool FNodeBuilder::CheckSubsectorOverlappingSegs (DWORD set, node_t &node, DWORD // seg in front of the splitter is partnered with a new miniseg on // the back so that the back will have two segs. -bool FNodeBuilder::ShoveSegBehind (DWORD set, node_t &node, DWORD seg, DWORD mate) +bool FNodeBuilder::ShoveSegBehind (uint32_t set, node_t &node, uint32_t seg, uint32_t mate) { SetNodeFromSeg (node, &Segs[seg]); HackSeg = seg; @@ -446,12 +446,12 @@ bool FNodeBuilder::ShoveSegBehind (DWORD set, node_t &node, DWORD seg, DWORD mat // each unique plane needs to be considered as a splitter. A result of 0 means // this set is a convex region. A result of -1 means that there were possible // splitters, but they all split segs we want to keep intact. -int FNodeBuilder::SelectSplitter (DWORD set, node_t &node, DWORD &splitseg, int step, bool nosplit) +int FNodeBuilder::SelectSplitter (uint32_t set, node_t &node, uint32_t &splitseg, int step, bool nosplit) { int stepleft; int bestvalue; - DWORD bestseg; - DWORD seg; + uint32_t bestseg; + uint32_t seg; bool nosplitters = false; bestvalue = 0; @@ -522,7 +522,7 @@ int FNodeBuilder::SelectSplitter (DWORD set, node_t &node, DWORD &splitseg, int // true. A score of 0 means that the splitter does not split any of the segs // in the set. -int FNodeBuilder::Heuristic (node_t &node, DWORD set, bool honorNoSplit) +int FNodeBuilder::Heuristic (node_t &node, uint32_t set, bool honorNoSplit) { // Set the initial score above 0 so that near vertex anti-weighting is less likely to produce a negative score. int score = 1000000; @@ -530,7 +530,7 @@ int FNodeBuilder::Heuristic (node_t &node, DWORD set, bool honorNoSplit) int counts[2] = { 0, 0 }; int realSegs[2] = { 0, 0 }; int specialSegs[2] = { 0, 0 }; - DWORD i = set; + uint32_t i = set; int sidev[2]; int side; bool splitter = false; @@ -760,7 +760,7 @@ int FNodeBuilder::Heuristic (node_t &node, DWORD set, bool honorNoSplit) return score; } -void FNodeBuilder::SplitSegs (DWORD set, node_t &node, DWORD splitseg, DWORD &outset0, DWORD &outset1, unsigned int &count0, unsigned int &count1) +void FNodeBuilder::SplitSegs (uint32_t set, node_t &node, uint32_t splitseg, uint32_t &outset0, uint32_t &outset1, unsigned int &count0, unsigned int &count1) { unsigned int _count0 = 0; unsigned int _count1 = 0; @@ -890,7 +890,7 @@ void FNodeBuilder::SplitSegs (DWORD set, node_t &node, DWORD splitseg, DWORD &ou } if (hack && GLNodes) { - DWORD newback, newfront; + uint32_t newback, newfront; newback = AddMiniseg (seg->v2, seg->v1, DWORD_MAX, set, splitseg); if (HackMate == DWORD_MAX) @@ -942,7 +942,7 @@ void FNodeBuilder::SetNodeFromSeg (node_t &node, const FPrivSeg *pseg) const } } -DWORD FNodeBuilder::SplitSeg (DWORD segnum, int splitvert, int v1InFront) +uint32_t FNodeBuilder::SplitSeg (uint32_t segnum, int splitvert, int v1InFront) { double dx, dy; FPrivSeg newseg; @@ -991,7 +991,7 @@ DWORD FNodeBuilder::SplitSeg (DWORD segnum, int splitvert, int v1InFront) return newnum; } -void FNodeBuilder::RemoveSegFromVert1 (DWORD segnum, int vertnum) +void FNodeBuilder::RemoveSegFromVert1 (uint32_t segnum, int vertnum) { FPrivVert *v = &Vertices[vertnum]; @@ -1001,7 +1001,7 @@ void FNodeBuilder::RemoveSegFromVert1 (DWORD segnum, int vertnum) } else { - DWORD prev, curr; + uint32_t prev, curr; prev = 0; curr = v->segs; while (curr != DWORD_MAX && curr != segnum) @@ -1016,7 +1016,7 @@ void FNodeBuilder::RemoveSegFromVert1 (DWORD segnum, int vertnum) } } -void FNodeBuilder::RemoveSegFromVert2 (DWORD segnum, int vertnum) +void FNodeBuilder::RemoveSegFromVert2 (uint32_t segnum, int vertnum) { FPrivVert *v = &Vertices[vertnum]; @@ -1026,7 +1026,7 @@ void FNodeBuilder::RemoveSegFromVert2 (DWORD segnum, int vertnum) } else { - DWORD prev, curr; + uint32_t prev, curr; prev = 0; curr = v->segs2; while (curr != DWORD_MAX && curr != segnum) @@ -1064,7 +1064,7 @@ double FNodeBuilder::InterceptVector (const node_t &splitter, const FPrivSeg &se return frac; } -void FNodeBuilder::PrintSet (int l, DWORD set) +void FNodeBuilder::PrintSet (int l, uint32_t set) { Printf (PRINT_LOG, "set %d:\n", l); for (; set != DWORD_MAX; set = Segs[set].next) diff --git a/src/nodebuild.h b/src/nodebuild.h index 6d730644e..c5297190d 100644 --- a/src/nodebuild.h +++ b/src/nodebuild.h @@ -9,7 +9,7 @@ struct FMiniBSP; struct FEventInfo { int Vertex; - DWORD FrontSeg; + uint32_t FrontSeg; }; struct FEvent @@ -62,12 +62,12 @@ class FNodeBuilder int linedef; sector_t *frontsector; sector_t *backsector; - DWORD next; - DWORD nextforvert; - DWORD nextforvert2; + uint32_t next; + uint32_t nextforvert; + uint32_t nextforvert2; int loopnum; // loop number for split avoidance (0 means splitting is okay) - DWORD partner; // seg on back side - DWORD storedseg; // seg # in the GL_SEGS lump + uint32_t partner; // seg on back side + uint32_t storedseg; // seg # in the GL_SEGS lump int planenum; bool planefront; @@ -75,8 +75,8 @@ class FNodeBuilder }; struct FPrivVert : FSimpleVert { - DWORD segs; // segs that use this vertex as v1 - DWORD segs2; // segs that use this vertex as v2 + uint32_t segs; // segs that use this vertex as v1 + uint32_t segs2; // segs that use this vertex as v2 bool operator== (const FPrivVert &other) { @@ -89,19 +89,19 @@ class FNodeBuilder }; union USegPtr { - DWORD SegNum; + uint32_t SegNum; FPrivSeg *SegPtr; }; struct FSplitSharer { double Distance; - DWORD Seg; + uint32_t Seg; bool Forward; }; struct glseg_t : public seg_t { - DWORD Partner; + uint32_t Partner; }; @@ -220,11 +220,11 @@ private: TArray Nodes; TArray Subsectors; - TArray SubsectorSets; + TArray SubsectorSets; TArray Segs; TArray Vertices; TArray SegList; - TArray PlaneChecked; + TArray PlaneChecked; TArray Planes; TArray Touched; // Loops a splitter touches on a vertex @@ -233,8 +233,8 @@ private: TArray SplitSharers; // Segs colinear with the current splitter - DWORD HackSeg; // Seg to force to back of splitter - DWORD HackMate; // Seg to use in front of hack seg + uint32_t HackSeg; // Seg to force to back of splitter + uint32_t HackMate; // Seg to use in front of hack seg FLevel &Level; bool GLNodes; // Add minisegs to make GL nodes? @@ -249,17 +249,17 @@ private: void GroupSegPlanesSimple (); void FindPolyContainers (TArray &spots, TArray &anchors); bool GetPolyExtents (int polynum, fixed_t bbox[4]); - int MarkLoop (DWORD firstseg, int loopnum); + int MarkLoop (uint32_t firstseg, int loopnum); void AddSegToBBox (fixed_t bbox[4], const FPrivSeg *seg); - int CreateNode (DWORD set, unsigned int count, fixed_t bbox[4]); - int CreateSubsector (DWORD set, fixed_t bbox[4]); + int CreateNode (uint32_t set, unsigned int count, fixed_t bbox[4]); + int CreateSubsector (uint32_t set, fixed_t bbox[4]); void CreateSubsectorsForReal (); - bool CheckSubsector (DWORD set, node_t &node, DWORD &splitseg); - bool CheckSubsectorOverlappingSegs (DWORD set, node_t &node, DWORD &splitseg); - bool ShoveSegBehind (DWORD set, node_t &node, DWORD seg, DWORD mate); int SelectSplitter (DWORD set, node_t &node, DWORD &splitseg, int step, bool nosplit); - void SplitSegs (DWORD set, node_t &node, DWORD splitseg, DWORD &outset0, DWORD &outset1, unsigned int &count0, unsigned int &count1); - DWORD SplitSeg (DWORD segnum, int splitvert, int v1InFront); - int Heuristic (node_t &node, DWORD set, bool honorNoSplit); + bool CheckSubsector (uint32_t set, node_t &node, uint32_t &splitseg); + bool CheckSubsectorOverlappingSegs (uint32_t set, node_t &node, uint32_t &splitseg); + bool ShoveSegBehind (uint32_t set, node_t &node, uint32_t seg, uint32_t mate); int SelectSplitter (uint32_t set, node_t &node, uint32_t &splitseg, int step, bool nosplit); + void SplitSegs (uint32_t set, node_t &node, uint32_t splitseg, uint32_t &outset0, uint32_t &outset1, unsigned int &count0, unsigned int &count1); + uint32_t SplitSeg (uint32_t segnum, int splitvert, int v1InFront); + int Heuristic (node_t &node, uint32_t set, bool honorNoSplit); // Returns: // 0 = seg is in front @@ -270,16 +270,16 @@ private: void FixSplitSharers (const node_t &node); double AddIntersection (const node_t &node, int vertex); - void AddMinisegs (const node_t &node, DWORD splitseg, DWORD &fset, DWORD &rset); - DWORD CheckLoopStart (fixed_t dx, fixed_t dy, int vertex1, int vertex2); - DWORD CheckLoopEnd (fixed_t dx, fixed_t dy, int vertex2); - void RemoveSegFromVert1 (DWORD segnum, int vertnum); - void RemoveSegFromVert2 (DWORD segnum, int vertnum); - DWORD AddMiniseg (int v1, int v2, DWORD partner, DWORD seg1, DWORD splitseg); + void AddMinisegs (const node_t &node, uint32_t splitseg, uint32_t &fset, uint32_t &rset); + uint32_t CheckLoopStart (fixed_t dx, fixed_t dy, int vertex1, int vertex2); + uint32_t CheckLoopEnd (fixed_t dx, fixed_t dy, int vertex2); + void RemoveSegFromVert1 (uint32_t segnum, int vertnum); + void RemoveSegFromVert2 (uint32_t segnum, int vertnum); + uint32_t AddMiniseg (int v1, int v2, uint32_t partner, uint32_t seg1, uint32_t splitseg); void SetNodeFromSeg (node_t &node, const FPrivSeg *pseg) const; int CloseSubsector (TArray &segs, int subsector, vertex_t *outVerts); - DWORD PushGLSeg (TArray &segs, const FPrivSeg *seg, vertex_t *outVerts); + uint32_t PushGLSeg (TArray &segs, const FPrivSeg *seg, vertex_t *outVerts); void PushConnectingGLSeg (int subsector, TArray &segs, vertex_t *v1, vertex_t *v2); int OutputDegenerateSubsector (TArray &segs, int subsector, bool bForward, double lastdot, FPrivSeg *&prev, vertex_t *outVerts); @@ -287,7 +287,7 @@ private: double InterceptVector (const node_t &splitter, const FPrivSeg &seg); - void PrintSet (int l, DWORD set); + void PrintSet (int l, uint32_t set); FNodeBuilder &operator= (const FNodeBuilder &) { return *this; } }; diff --git a/src/nodebuild_extract.cpp b/src/nodebuild_extract.cpp index bdb343449..98ade3f78 100644 --- a/src/nodebuild_extract.cpp +++ b/src/nodebuild_extract.cpp @@ -86,7 +86,7 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount, if (outNodes[i].intchildren[j] & 0x80000000) { D(Printf(PRINT_LOG, " subsector %d\n", outNodes[i].intchildren[j] & 0x7FFFFFFF)); - outNodes[i].children[j] = (BYTE *)(outSubs + (outNodes[i].intchildren[j] & 0x7fffffff)) + 1; + outNodes[i].children[j] = (uint8_t *)(outSubs + (outNodes[i].intchildren[j] & 0x7fffffff)) + 1; } else { @@ -109,7 +109,7 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount, for (i = 0; i < subCount; ++i) { - DWORD numsegs = CloseSubsector (segs, i, &outVerts[0]); + uint32_t numsegs = CloseSubsector (segs, i, &outVerts[0]); outSubs[i].numlines = numsegs; outSubs[i].firstline = (seg_t *)(size_t)(segs.Size() - numsegs); } @@ -123,7 +123,7 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount, if (segs[i].Partner != DWORD_MAX) { - const DWORD storedseg = Segs[segs[i].Partner].storedseg; + const uint32_t storedseg = Segs[segs[i].Partner].storedseg; outSegs[i].PartnerSeg = DWORD_MAX == storedseg ? nullptr : &outSegs[storedseg]; } else @@ -193,7 +193,7 @@ void FNodeBuilder::ExtractMini (FMiniBSP *bsp) if (bsp->Nodes[i].intchildren[j] & 0x80000000) { D(Printf(PRINT_LOG, " subsector %d\n", bsp->Nodes[i].intchildren[j] & 0x7FFFFFFF)); - bsp->Nodes[i].children[j] = (BYTE *)&bsp->Subsectors[bsp->Nodes[i].intchildren[j] & 0x7fffffff] + 1; + bsp->Nodes[i].children[j] = (uint8_t *)&bsp->Subsectors[bsp->Nodes[i].intchildren[j] & 0x7fffffff] + 1; } else { @@ -215,7 +215,7 @@ void FNodeBuilder::ExtractMini (FMiniBSP *bsp) TArray glsegs; for (i = 0; i < Subsectors.Size(); ++i) { - DWORD numsegs = CloseSubsector (glsegs, i, &bsp->Verts[0]); + uint32_t numsegs = CloseSubsector (glsegs, i, &bsp->Verts[0]); bsp->Subsectors[i].numlines = numsegs; bsp->Subsectors[i].firstline = &bsp->Segs[bsp->Segs.Size() - numsegs]; } @@ -265,11 +265,11 @@ int FNodeBuilder::CloseSubsector (TArray &segs, int subsector, vertex_t double accumx, accumy; fixed_t midx, midy; int firstVert; - DWORD first, max, count, i, j; + uint32_t first, max, count, i, j; bool diffplanes; int firstplane; - first = (DWORD)(size_t)Subsectors[subsector].firstline; + first = (uint32_t)(size_t)Subsectors[subsector].firstline; max = first + Subsectors[subsector].numlines; count = 0; @@ -329,7 +329,7 @@ int FNodeBuilder::CloseSubsector (TArray &segs, int subsector, vertex_t { angle_t bestdiff = ANGLE_MAX; FPrivSeg *bestseg = NULL; - DWORD bestj = DWORD_MAX; + uint32_t bestj = DWORD_MAX; j = first; do { @@ -434,7 +434,7 @@ int FNodeBuilder::OutputDegenerateSubsector (TArray &segs, int subsecto double dot, x1, y1, dx, dy, dx2, dy2; bool wantside; - first = (DWORD)(size_t)Subsectors[subsector].firstline; + first = (uint32_t)(size_t)Subsectors[subsector].firstline; max = first + Subsectors[subsector].numlines; count = 0; @@ -493,7 +493,7 @@ int FNodeBuilder::OutputDegenerateSubsector (TArray &segs, int subsecto return count; } -DWORD FNodeBuilder::PushGLSeg (TArray &segs, const FPrivSeg *seg, vertex_t *outVerts) +uint32_t FNodeBuilder::PushGLSeg (TArray &segs, const FPrivSeg *seg, vertex_t *outVerts) { glseg_t newseg; @@ -512,7 +512,7 @@ DWORD FNodeBuilder::PushGLSeg (TArray &segs, const FPrivSeg *seg, verte newseg.sidedef = NULL; } newseg.Partner = seg->partner; - return (DWORD)segs.Push (newseg); + return (uint32_t)segs.Push (newseg); } void FNodeBuilder::PushConnectingGLSeg (int subsector, TArray &segs, vertex_t *v1, vertex_t *v2) diff --git a/src/nodebuild_gl.cpp b/src/nodebuild_gl.cpp index 61bed0727..db9d716ac 100644 --- a/src/nodebuild_gl.cpp +++ b/src/nodebuild_gl.cpp @@ -87,7 +87,7 @@ void FNodeBuilder::FixSplitSharers (const node_t &node) D(Events.PrintTree()); for (unsigned int i = 0; i < SplitSharers.Size(); ++i) { - DWORD seg = SplitSharers[i].Seg; + uint32_t seg = SplitSharers[i].Seg; int v2 = Segs[seg].v2; FEvent *event = Events.FindEvent (SplitSharers[i].Distance); FEvent *next; @@ -136,12 +136,12 @@ void FNodeBuilder::FixSplitSharers (const node_t &node) Vertices[event->Info.Vertex].x>>16, Vertices[event->Info.Vertex].y>>16)); - DWORD newseg = SplitSeg (seg, event->Info.Vertex, 1); + uint32_t newseg = SplitSeg (seg, event->Info.Vertex, 1); Segs[newseg].next = Segs[seg].next; Segs[seg].next = newseg; - DWORD partner = Segs[seg].partner; + uint32_t partner = Segs[seg].partner; if (partner != DWORD_MAX) { int endpartner = SplitSeg (partner, event->Info.Vertex, 1); @@ -168,7 +168,7 @@ void FNodeBuilder::FixSplitSharers (const node_t &node) } } -void FNodeBuilder::AddMinisegs (const node_t &node, DWORD splitseg, DWORD &fset, DWORD &bset) +void FNodeBuilder::AddMinisegs (const node_t &node, uint32_t splitseg, uint32_t &fset, uint32_t &bset) { FEvent *event = Events.GetMinimum (), *prev = NULL; @@ -176,8 +176,8 @@ void FNodeBuilder::AddMinisegs (const node_t &node, DWORD splitseg, DWORD &fset, { if (prev != NULL) { - DWORD fseg1, bseg1, fseg2, bseg2; - DWORD fnseg, bnseg; + uint32_t fseg1, bseg1, fseg2, bseg2; + uint32_t fnseg, bnseg; // Minisegs should only be added when they can create valid loops on both the front and // back of the splitter. This means some subsectors could be unclosed if their sectors @@ -234,9 +234,9 @@ void FNodeBuilder::AddMinisegs (const node_t &node, DWORD splitseg, DWORD &fset, } } -DWORD FNodeBuilder::AddMiniseg (int v1, int v2, DWORD partner, DWORD seg1, DWORD splitseg) +uint32_t FNodeBuilder::AddMiniseg (int v1, int v2, uint32_t partner, uint32_t seg1, uint32_t splitseg) { - DWORD nseg; + uint32_t nseg; FPrivSeg *seg = &Segs[seg1]; FPrivSeg newseg; @@ -283,13 +283,13 @@ DWORD FNodeBuilder::AddMiniseg (int v1, int v2, DWORD partner, DWORD seg1, DWORD return nseg; } -DWORD FNodeBuilder::CheckLoopStart (fixed_t dx, fixed_t dy, int vertex, int vertex2) +uint32_t FNodeBuilder::CheckLoopStart (fixed_t dx, fixed_t dy, int vertex, int vertex2) { FPrivVert *v = &Vertices[vertex]; angle_t splitAngle = PointToAngle (dx, dy); - DWORD segnum; + uint32_t segnum; angle_t bestang; - DWORD bestseg; + uint32_t bestseg; // Find the seg ending at this vertex that forms the smallest angle // to the splitter. @@ -342,13 +342,13 @@ DWORD FNodeBuilder::CheckLoopStart (fixed_t dx, fixed_t dy, int vertex, int vert return bestseg; } -DWORD FNodeBuilder::CheckLoopEnd (fixed_t dx, fixed_t dy, int vertex) +uint32_t FNodeBuilder::CheckLoopEnd (fixed_t dx, fixed_t dy, int vertex) { FPrivVert *v = &Vertices[vertex]; angle_t splitAngle = PointToAngle (dx, dy) + ANGLE_180; - DWORD segnum; + uint32_t segnum; angle_t bestang; - DWORD bestseg; + uint32_t bestseg; // Find the seg starting at this vertex that forms the smallest angle // to the splitter. diff --git a/src/nodebuild_utility.cpp b/src/nodebuild_utility.cpp index b6115f4c8..f27b95485 100644 --- a/src/nodebuild_utility.cpp +++ b/src/nodebuild_utility.cpp @@ -486,9 +486,9 @@ void FNodeBuilder::FindPolyContainers (TArray &spots, TArrayv1].x>>16, Vertices[s1->v1].y>>16, Vertices[s1->v2].x>>16, Vertices[s1->v2].y>>16)); - DWORD bestseg = DWORD_MAX; - DWORD tryseg = Vertices[s1->v2].segs; + uint32_t bestseg = DWORD_MAX; + uint32_t tryseg = Vertices[s1->v2].segs; angle_t bestang = ANGLE_MAX; angle_t ang1 = PointToAngle (Vertices[s1->v2].x - Vertices[s1->v1].x, Vertices[s1->v2].y - Vertices[s1->v1].y); diff --git a/src/oplsynth/dosbox/opl.cpp b/src/oplsynth/dosbox/opl.cpp index 64b77ce8c..8f2fdd859 100644 --- a/src/oplsynth/dosbox/opl.cpp +++ b/src/oplsynth/dosbox/opl.cpp @@ -36,9 +36,9 @@ typedef uintptr_t Bitu; typedef intptr_t Bits; typedef DWORD Bit32u; typedef int32_t Bit32s; -typedef WORD Bit16u; -typedef SWORD Bit16s; -typedef BYTE Bit8u; +typedef uint16_t Bit16u; +typedef int16_t Bit16s; +typedef uint8_t Bit8u; typedef SBYTE Bit8s; #define OPLTYPE_IS_OPL3 diff --git a/src/oplsynth/mlopl.cpp b/src/oplsynth/mlopl.cpp index bbff8b5fd..87cd7f450 100644 --- a/src/oplsynth/mlopl.cpp +++ b/src/oplsynth/mlopl.cpp @@ -474,7 +474,7 @@ int musicBlock::OPLloadBank (FileReader &data) for (int i = 0; i < 175; ++i) { Printf ("%3d.%-33s%3d %3d %3d %d\n", i, - (BYTE *)data+6308+i*32, + (uint8_t *)data+6308+i*32, OPLinstruments[i].instr[0].basenote, OPLinstruments[i].instr[1].basenote, OPLinstruments[i].note, diff --git a/src/oplsynth/mlopl_io.cpp b/src/oplsynth/mlopl_io.cpp index 4e88ac108..ef89bfc27 100644 --- a/src/oplsynth/mlopl_io.cpp +++ b/src/oplsynth/mlopl_io.cpp @@ -102,7 +102,7 @@ void OPLio::OPLwriteValue(uint32_t regbase, uint32_t channel, uint8_t value) OPLwriteReg (which, reg, value); } -static WORD frequencies[] = +static uint16_t frequencies[] = { 0x133, 0x133, 0x134, 0x134, 0x135, 0x136, 0x136, 0x137, 0x137, 0x138, 0x138, 0x139, 0x139, 0x13a, 0x13b, 0x13b, 0x13c, 0x13c, 0x13d, 0x13d, 0x13e, 0x13f, 0x13f, 0x140, @@ -195,8 +195,8 @@ void OPLio::OPLwriteFreq(uint32_t channel, uint32_t note, uint32_t pitch, uint32 } int i = frequencies[j] | (octave << 10); - OPLwriteValue (0xA0, channel, (BYTE)i); - OPLwriteValue (0xB0, channel, (BYTE)(i>>8)|(keyon<<5)); + OPLwriteValue (0xA0, channel, (uint8_t)i); + OPLwriteValue (0xB0, channel, (uint8_t)(i>>8)|(keyon<<5)); } /* diff --git a/src/oplsynth/music_opl_mididevice.cpp b/src/oplsynth/music_opl_mididevice.cpp index 853a679c4..f6cfab30e 100644 --- a/src/oplsynth/music_opl_mididevice.cpp +++ b/src/oplsynth/music_opl_mididevice.cpp @@ -252,7 +252,7 @@ void OPLMIDIDevice::HandleEvent(int status, int parm1, int parm2) // //========================================================================== -void OPLMIDIDevice::HandleLongEvent(const BYTE *data, int len) +void OPLMIDIDevice::HandleLongEvent(const uint8_t *data, int len) { } diff --git a/src/oplsynth/music_opldumper_mididevice.cpp b/src/oplsynth/music_opldumper_mididevice.cpp index cf20a0e73..9e9110285 100644 --- a/src/oplsynth/music_opldumper_mididevice.cpp +++ b/src/oplsynth/music_opldumper_mididevice.cpp @@ -71,7 +71,7 @@ protected: double CurTime; int CurIntTime; int TickMul; - BYTE CurChip; + uint8_t CurChip; }; // EXTERNAL FUNCTION PROTOTYPES -------------------------------------------- @@ -101,7 +101,7 @@ public: { if (File != NULL) { - WORD endmark = 0xFFFF; + uint16_t endmark = 0xFFFF; fwrite(&endmark, 2, 1, File); fclose(File); } @@ -110,16 +110,16 @@ public: virtual void WriteReg(int reg, int v) { assert(File != NULL); - BYTE chipnum = reg >> 8; + uint8_t chipnum = reg >> 8; if (chipnum != CurChip) { - BYTE switcher[2] = { (BYTE)(chipnum + 1), 2 }; + uint8_t switcher[2] = { (uint8_t)(chipnum + 1), 2 }; fwrite(switcher, 1, 2, File); } reg &= 255; if (reg != 0 && reg != 2 && (reg != 255 || v != 255)) { - BYTE cmd[2] = { BYTE(v), BYTE(reg) }; + uint8_t cmd[2] = { uint8_t(v), uint8_t(reg) }; fwrite(cmd, 1, 2, File); } } @@ -130,7 +130,7 @@ public: double clock_rate; int clock_mul; - WORD clock_word; + uint16_t clock_word; clock_rate = samples_per_tick * ADLIB_CLOCK_MUL; clock_mul = 1; @@ -141,7 +141,7 @@ public: { clock_mul++; } - clock_word = WORD(clock_rate / clock_mul + 0.5); + clock_word = uint16_t(clock_rate / clock_mul + 0.5); if (NeedClockRate) { // Set the initial clock rate. @@ -153,7 +153,7 @@ public: } else { // Change the clock rate in the middle of the song. - BYTE clock_change[4] = { 0, 2, BYTE(clock_word & 255), BYTE(clock_word >> 8) }; + uint8_t clock_change[4] = { 0, 2, uint8_t(clock_word & 255), uint8_t(clock_word >> 8) }; fwrite(clock_change, 1, 4, File); } } @@ -162,7 +162,7 @@ public: if (ticks > 0) { // RDos raw has very precise delays but isn't very efficient at // storing long delays. - BYTE delay[2]; + uint8_t delay[2]; ticks *= TickMul; delay[1] = 0; @@ -172,7 +172,7 @@ public: delay[0] = 255; fwrite(delay, 1, 2, File); } - delay[0] = BYTE(ticks); + delay[0] = uint8_t(ticks); fwrite(delay, 1, 2, File); } } @@ -212,14 +212,14 @@ public: virtual void WriteReg(int reg, int v) { assert(File != NULL); - BYTE chipnum = reg >> 8; + uint8_t chipnum = reg >> 8; if (chipnum != CurChip) { CurChip = chipnum; fputc(chipnum + 2, File); } reg &= 255; - BYTE cmd[3] = { 4, BYTE(reg), BYTE(v) }; + uint8_t cmd[3] = { 4, uint8_t(reg), uint8_t(v) }; fwrite (cmd + (reg > 4), 1, 3 - (reg > 4), File); } virtual void WriteDelay(int ticks) @@ -233,20 +233,20 @@ public: CurIntTime += delay; while (delay > 65536) { - BYTE cmd[3] = { 1, 255, 255 }; + uint8_t cmd[3] = { 1, 255, 255 }; fwrite(cmd, 1, 2, File); delay -= 65536; } delay--; if (delay <= 255) { - BYTE cmd[2] = { 0, BYTE(delay) }; + uint8_t cmd[2] = { 0, uint8_t(delay) }; fwrite(cmd, 1, 2, File); } else { assert(delay <= 65535); - BYTE cmd[3] = { 1, BYTE(delay & 255), BYTE(delay >> 8) }; + uint8_t cmd[3] = { 1, uint8_t(delay & 255), uint8_t(delay >> 8) }; fwrite(cmd, 1, 3, File); } } diff --git a/src/oplsynth/muslib.h b/src/oplsynth/muslib.h index 9091c8536..9d5bdfcbd 100644 --- a/src/oplsynth/muslib.h +++ b/src/oplsynth/muslib.h @@ -88,28 +88,28 @@ class FileReader; /* OPL2 instrument */ struct OPL2instrument { -/*00*/ BYTE trem_vibr_1; /* OP 1: tremolo/vibrato/sustain/KSR/multi */ -/*01*/ BYTE att_dec_1; /* OP 1: attack rate/decay rate */ -/*02*/ BYTE sust_rel_1; /* OP 1: sustain level/release rate */ -/*03*/ BYTE wave_1; /* OP 1: waveform select */ -/*04*/ BYTE scale_1; /* OP 1: key scale level */ -/*05*/ BYTE level_1; /* OP 1: output level */ -/*06*/ BYTE feedback; /* feedback/AM-FM (both operators) */ -/*07*/ BYTE trem_vibr_2; /* OP 2: tremolo/vibrato/sustain/KSR/multi */ -/*08*/ BYTE att_dec_2; /* OP 2: attack rate/decay rate */ -/*09*/ BYTE sust_rel_2; /* OP 2: sustain level/release rate */ -/*0A*/ BYTE wave_2; /* OP 2: waveform select */ -/*0B*/ BYTE scale_2; /* OP 2: key scale level */ -/*0C*/ BYTE level_2; /* OP 2: output level */ -/*0D*/ BYTE unused; +/*00*/ uint8_t trem_vibr_1; /* OP 1: tremolo/vibrato/sustain/KSR/multi */ +/*01*/ uint8_t att_dec_1; /* OP 1: attack rate/decay rate */ +/*02*/ uint8_t sust_rel_1; /* OP 1: sustain level/release rate */ +/*03*/ uint8_t wave_1; /* OP 1: waveform select */ +/*04*/ uint8_t scale_1; /* OP 1: key scale level */ +/*05*/ uint8_t level_1; /* OP 1: output level */ +/*06*/ uint8_t feedback; /* feedback/AM-FM (both operators) */ +/*07*/ uint8_t trem_vibr_2; /* OP 2: tremolo/vibrato/sustain/KSR/multi */ +/*08*/ uint8_t att_dec_2; /* OP 2: attack rate/decay rate */ +/*09*/ uint8_t sust_rel_2; /* OP 2: sustain level/release rate */ +/*0A*/ uint8_t wave_2; /* OP 2: waveform select */ +/*0B*/ uint8_t scale_2; /* OP 2: key scale level */ +/*0C*/ uint8_t level_2; /* OP 2: output level */ +/*0D*/ uint8_t unused; /*0E*/ int16_t basenote; /* base note offset */ }; /* OP2 instrument file entry */ struct OP2instrEntry { -/*00*/ WORD flags; // see FL_xxx below -/*02*/ BYTE finetune; // finetune value for 2-voice sounds -/*03*/ BYTE note; // note # for fixed instruments +/*00*/ uint16_t flags; // see FL_xxx below +/*02*/ uint8_t finetune; // finetune value for 2-voice sounds +/*03*/ uint8_t note; // note # for fixed instruments /*04*/ struct OPL2instrument instr[2]; // instruments }; @@ -188,8 +188,8 @@ struct musicBlock { musicBlock(); ~musicBlock(); - BYTE *score; - BYTE *scoredata; + uint8_t *score; + uint8_t *scoredata; int playingcount; OPLdata driverdata; OPLio *io; diff --git a/src/oplsynth/nukedopl3.h b/src/oplsynth/nukedopl3.h index 5b1392542..b5abf3b38 100644 --- a/src/oplsynth/nukedopl3.h +++ b/src/oplsynth/nukedopl3.h @@ -36,9 +36,9 @@ typedef uintptr_t Bitu; typedef intptr_t Bits; typedef DWORD Bit32u; typedef int32_t Bit32s; -typedef WORD Bit16u; -typedef SWORD Bit16s; -typedef BYTE Bit8u; +typedef uint16_t Bit16u; +typedef int16_t Bit16s; +typedef uint8_t Bit8u; typedef SBYTE Bit8s; // Channel types diff --git a/src/oplsynth/opl_mus_player.cpp b/src/oplsynth/opl_mus_player.cpp index 465f89592..5c8d2d2a5 100644 --- a/src/oplsynth/opl_mus_player.cpp +++ b/src/oplsynth/opl_mus_player.cpp @@ -60,7 +60,7 @@ OPLmusicFile::OPLmusicFile (FileReader *reader) return; } - scoredata = new BYTE[ScoreLen]; + scoredata = new uint8_t[ScoreLen]; if (reader->Read(scoredata, ScoreLen) != ScoreLen) { @@ -79,17 +79,17 @@ fail: delete[] scoredata; ((DWORD *)scoredata)[1] == MAKE_ID('D','A','T','A')) { RawPlayer = RDosPlay; - if (*(WORD *)(scoredata + 8) == 0) + if (*(uint16_t *)(scoredata + 8) == 0) { // A clock speed of 0 is bad - *(WORD *)(scoredata + 8) = 0xFFFF; + *(uint16_t *)(scoredata + 8) = 0xFFFF; } - SamplesPerTick = LittleShort(*(WORD *)(scoredata + 8)) / ADLIB_CLOCK_MUL; + SamplesPerTick = LittleShort(*(uint16_t *)(scoredata + 8)) / ADLIB_CLOCK_MUL; } // Check for DosBox OPL dump else if (((DWORD *)scoredata)[0] == MAKE_ID('D','B','R','A') && ((DWORD *)scoredata)[1] == MAKE_ID('W','O','P','L')) { - if (LittleShort(((WORD *)scoredata)[5]) == 1) + if (LittleShort(((uint16_t *)scoredata)[5]) == 1) { RawPlayer = DosBox1; SamplesPerTick = OPL_SAMPLE_RATE / 1000; @@ -117,7 +117,7 @@ fail: delete[] scoredata; } else { - Printf("Unsupported DOSBox Raw OPL version %d.%d\n", LittleShort(((WORD *)scoredata)[4]), LittleShort(((WORD *)scoredata)[5])); + Printf("Unsupported DOSBox Raw OPL version %d.%d\n", LittleShort(((uint16_t *)scoredata)[4]), LittleShort(((uint16_t *)scoredata)[5])); goto fail; } } @@ -126,7 +126,7 @@ fail: delete[] scoredata; scoredata[4] == 'B' && scoredata[5] == 1) { int songlen; - BYTE *max = scoredata + ScoreLen; + uint8_t *max = scoredata + ScoreLen; RawPlayer = IMF; SamplesPerTick = OPL_SAMPLE_RATE / IMF_RATE; @@ -185,7 +185,7 @@ void OPLmusicFile::Restart () { case RDosPlay: score = scoredata + 10; - SamplesPerTick = LittleShort(*(WORD *)(scoredata + 8)) / ADLIB_CLOCK_MUL; + SamplesPerTick = LittleShort(*(uint16_t *)(scoredata + 8)) / ADLIB_CLOCK_MUL; break; case DosBox1: @@ -363,8 +363,8 @@ void OPLmusicBlock::OffsetSamples(float *buff, int count) int OPLmusicFile::PlayTick () { - BYTE reg, data; - WORD delay; + uint8_t reg, data; + uint16_t delay; switch (RawPlayer) { @@ -385,7 +385,7 @@ int OPLmusicFile::PlayTick () case 2: // Speed change or OPL3 switch if (data == 0) { - SamplesPerTick = LittleShort(*(WORD *)(score)) / ADLIB_CLOCK_MUL; + SamplesPerTick = LittleShort(*(uint16_t *)(score)) / ADLIB_CLOCK_MUL; io->SetClockRate(SamplesPerTick); score += 2; } @@ -453,14 +453,14 @@ int OPLmusicFile::PlayTick () case DosBox2: { - BYTE *to_reg = scoredata + 0x1A; - BYTE to_reg_size = scoredata[0x19]; - BYTE short_delay_code = scoredata[0x17]; - BYTE long_delay_code = scoredata[0x18]; + uint8_t *to_reg = scoredata + 0x1A; + uint8_t to_reg_size = scoredata[0x19]; + uint8_t short_delay_code = scoredata[0x17]; + uint8_t long_delay_code = scoredata[0x18]; while (score < scoredata + ScoreLen) { - BYTE code = *score++; + uint8_t code = *score++; data = *score++; // Which OPL chip to write to is encoded in the high bit of the code value. @@ -493,7 +493,7 @@ int OPLmusicFile::PlayTick () } reg = score[0]; data = score[1]; - delay = LittleShort(((WORD *)score)[1]); + delay = LittleShort(((uint16_t *)score)[1]); score += 4; io->OPLwriteReg (0, reg, data); } @@ -512,7 +512,7 @@ ADD_STAT (opl) OPLmusicFile::OPLmusicFile(const OPLmusicFile *source, const char *filename) { ScoreLen = source->ScoreLen; - scoredata = new BYTE[ScoreLen]; + scoredata = new uint8_t[ScoreLen]; memcpy(scoredata, source->scoredata, ScoreLen); SamplesPerTick = source->SamplesPerTick; RawPlayer = source->RawPlayer; diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 543ead302..35c6b4673 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -245,7 +245,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 e2070083d..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; }; @@ -1383,7 +1383,7 @@ private: double WatchD, LastD; int Special; int Args[5]; - TObjPtr Activator; + TObjPtr Activator; line_t *Line; bool LineSide; bool bCeiling; @@ -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; @@ -2879,7 +2879,7 @@ IMPLEMENT_POINTERS_START(DACSThinker) IMPLEMENT_POINTER(Scripts) IMPLEMENT_POINTERS_END -TObjPtr DACSThinker::ActiveThinker; +TObjPtr DACSThinker::ActiveThinker; DACSThinker::DACSThinker () : DThinker(STAT_SCRIPTS) @@ -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 dae4103ca..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); @@ -895,7 +895,7 @@ protected: int *pc; EScriptState state; int statedata; - TObjPtr activator; + TObjPtr activator; line_t *activationline; bool backSide; FFont *activefont; @@ -955,7 +955,7 @@ public: typedef TMap ScriptMap; ScriptMap RunningScripts; // Array of all synchronous scripts - static TObjPtr ActiveThinker; + static TObjPtr ActiveThinker; void DumpScriptStatus(); void StopScriptsFor (AActor *actor); 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 ebac76603..bb87a53d5 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -53,19 +53,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_pspr.h b/src/p_pspr.h index 5a8152591..311a241c4 100644 --- a/src/p_pspr.h +++ b/src/p_pspr.h @@ -95,8 +95,8 @@ private: void Tick(); public: // must be public to be able to generate the field export tables. Grrr... - TObjPtr Caller; - TObjPtr Next; + TObjPtr Caller; + TObjPtr Next; player_t *Owner; FState *State; int Sprite; diff --git a/src/p_pusher.cpp b/src/p_pusher.cpp index 5190b5ced..af6346710 100644 --- a/src/p_pusher.cpp +++ b/src/p_pusher.cpp @@ -66,7 +66,7 @@ public: protected: EPusher m_Type; - TObjPtr m_Source;// Point source if point pusher + TObjPtr m_Source;// Point source if point pusher DVector2 m_PushVec; double m_Magnitude; // Vector strength for point pusher double m_Radius; // Effective radius for point pusher 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_scroll.cpp b/src/p_scroll.cpp index 8dcf18a53..d74c6273f 100644 --- a/src/p_scroll.cpp +++ b/src/p_scroll.cpp @@ -66,7 +66,7 @@ protected: double m_vdx, m_vdy; // Accumulated velocity if accelerative int m_Accel; // Whether it's accelerative EScrollPos m_Parts; // Which parts of a sidedef are being scrolled? - TObjPtr m_Interpolations[3]; + TObjPtr m_Interpolations[3]; private: DScroller () 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 930ae5143..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); // @@ -254,8 +254,8 @@ protected: double m_CeilingTarget; int m_Crush; bool m_Hexencrush; - TObjPtr m_Interp_Ceiling; - TObjPtr m_Interp_Floor; + TObjPtr m_Interp_Ceiling; + TObjPtr m_Interp_Floor; private: DPillar (); @@ -595,8 +595,8 @@ protected: double m_FloorDestDist; double m_CeilingDestDist; double m_Speed; - TObjPtr m_Interp_Ceiling; - TObjPtr m_Interp_Floor; + TObjPtr m_Interp_Ceiling; + TObjPtr m_Interp_Floor; void StartFloorSound (); 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 6fba4a5a9..f93d2b742 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)); } } @@ -3049,7 +3049,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; @@ -3158,7 +3158,7 @@ void P_UnPredictPlayer () APlayerPawn *act = player->mo; AActor *savedcamera = player->camera; - TObjPtr InvSel = act->InvSel; + TObjPtr InvSel = act->InvSel; int inventorytics = player->inventorytics; *player = PredictionPlayerBackup; @@ -3175,7 +3175,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 34a735f05..d9e42c7fb 100644 --- a/src/po_man.h +++ b/src/po_man.h @@ -22,7 +22,7 @@ protected: int m_PolyObj; double m_Speed; double m_Dist; - TObjPtr m_Interpolation; + TObjPtr m_Interpolation; void SetInterpolation(); }; @@ -83,12 +83,12 @@ 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; - TObjPtr specialdata; // pointer to a thinker, if the poly is moving - TObjPtr interpolation; + TObjPtr specialdata; // pointer to a thinker, if the poly is moving + TObjPtr interpolation; FPolyObj(); DInterpolation *SetInterpolation(); 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 0f2e47068..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; @@ -227,7 +227,7 @@ struct FSectorPortal sector_t *mDestination; DVector2 mDisplacement; double mPlaneZ; - TObjPtr mSkybox; + TObjPtr mSkybox; bool MergeAllowed() const { diff --git a/src/posix/cocoa/i_input.mm b/src/posix/cocoa/i_input.mm index cb39c049a..53afa8536 100644 --- a/src/posix/cocoa/i_input.mm +++ b/src/posix/cocoa/i_input.mm @@ -317,7 +317,7 @@ uint8_t ModifierToDIK(const uint32_t modifier) return 0; } -SWORD ModifierFlagsToGUIKeyModifiers(NSEvent* theEvent) +int16_t ModifierFlagsToGUIKeyModifiers(NSEvent* theEvent) { const NSUInteger modifiers([theEvent modifierFlags] & NSDeviceIndependentModifierFlagsMask); return ((modifiers & NSShiftKeyMask ) ? GKM_SHIFT : 0) @@ -690,7 +690,7 @@ void ProcessMouseButtonEvent(NSEvent* theEvent) void ProcessMouseWheelEvent(NSEvent* theEvent) { - const SWORD modifiers = ModifierFlagsToGUIKeyModifiers(theEvent); + const int16_t modifiers = ModifierFlagsToGUIKeyModifiers(theEvent); const CGFloat delta = (modifiers & GKM_SHIFT) ? [theEvent deltaX] : [theEvent deltaY]; diff --git a/src/posix/cocoa/i_video.mm b/src/posix/cocoa/i_video.mm index d7791c43c..72f579a05 100644 --- a/src/posix/cocoa/i_video.mm +++ b/src/posix/cocoa/i_video.mm @@ -332,7 +332,7 @@ private: PalEntry m_palette[256]; bool m_needPaletteUpdate; - BYTE m_gammaTable[3][256]; + uint8_t m_gammaTable[3][256]; float m_gamma; bool m_needGammaUpdate; @@ -1160,7 +1160,7 @@ SDLGLFB::SDLGLFB(void*, const int width, const int height, int, int, const bool { for (uint32_t i = 0; i < GAMMA_TABLE_SIZE; ++i) { - m_originalGamma[i] = static_cast(gammaTable[i] * 65535.0f); + m_originalGamma[i] = static_cast(gammaTable[i] * 65535.0f); } } } @@ -1244,7 +1244,7 @@ void SDLGLFB::SwapBuffers() [[NSOpenGLContext currentContext] flushBuffer]; } -void SDLGLFB::SetGammaTable(WORD* table) +void SDLGLFB::SetGammaTable(uint16_t* table) { if (m_supportsGamma) { @@ -1520,7 +1520,7 @@ bool I_SetCursor(FTexture* cursorpic) // Load bitmap data to representation - BYTE* buffer = [bitmapImageRep bitmapData]; + uint8_t* buffer = [bitmapImageRep bitmapData]; memset(buffer, 0, imagePitch * imageHeight); FBitmap bitmap(buffer, imagePitch, imageWidth, imageHeight); @@ -1532,7 +1532,7 @@ bool I_SetCursor(FTexture* cursorpic) { const size_t offset = i * 4; - const BYTE temp = buffer[offset ]; + const uint8_t temp = buffer[offset ]; buffer[offset ] = buffer[offset + 2]; buffer[offset + 2] = temp; } diff --git a/src/posix/cocoa/sdlglvideo.h b/src/posix/cocoa/sdlglvideo.h index 43f2c9c43..b0076f11b 100644 --- a/src/posix/cocoa/sdlglvideo.h +++ b/src/posix/cocoa/sdlglvideo.h @@ -74,7 +74,7 @@ protected: static const uint32_t GAMMA_TABLE_SIZE = GAMMA_CHANNEL_SIZE * GAMMA_CHANNEL_COUNT; bool m_supportsGamma; - WORD m_originalGamma[GAMMA_TABLE_SIZE]; + uint16_t m_originalGamma[GAMMA_TABLE_SIZE]; SDLGLFB(); @@ -83,7 +83,7 @@ protected: bool CanUpdate(); void SwapBuffers(); - void SetGammaTable(WORD* table); + void SetGammaTable(uint16_t* table); void ResetGammaTable(); }; diff --git a/src/posix/sdl/i_input.cpp b/src/posix/sdl/i_input.cpp index 57ea03d92..fc705e855 100644 --- a/src/posix/sdl/i_input.cpp +++ b/src/posix/sdl/i_input.cpp @@ -110,9 +110,9 @@ static const SDL_Scancode DIKToKeyScan[256] = SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN }; -static TMap InitKeySymMap () +static TMap InitKeySymMap () { - TMap KeySymToDIK; + TMap KeySymToDIK; for (int i = 0; i < 256; ++i) { @@ -127,11 +127,11 @@ static TMap InitKeySymMap () return KeySymToDIK; } -static const TMap KeySymToDIK(InitKeySymMap()); +static const TMap KeySymToDIK(InitKeySymMap()); -static TMap InitKeyScanMap () +static TMap InitKeyScanMap () { - TMap KeyScanToDIK; + TMap KeyScanToDIK; for (int i = 0; i < 256; ++i) { @@ -140,7 +140,7 @@ static TMap InitKeyScanMap () return KeyScanToDIK; } -static const TMap KeyScanToDIK(InitKeyScanMap()); +static const TMap KeyScanToDIK(InitKeyScanMap()); static void I_CheckGUICapture () { @@ -377,9 +377,9 @@ void MessagePump (const SDL_Event &sev) // If that fails, then we'll do a lookup against the scan code, // which may not return the right key, but at least the key should // work in the game. - if (const BYTE *dik = KeySymToDIK.CheckKey (sev.key.keysym.sym)) + if (const uint8_t *dik = KeySymToDIK.CheckKey (sev.key.keysym.sym)) event.data1 = *dik; - else if (const BYTE *dik = KeyScanToDIK.CheckKey (sev.key.keysym.scancode)) + else if (const uint8_t *dik = KeyScanToDIK.CheckKey (sev.key.keysym.scancode)) event.data1 = *dik; if (event.data1) diff --git a/src/posix/sdl/sdlglvideo.cpp b/src/posix/sdl/sdlglvideo.cpp index 226600c64..12f33da40 100644 --- a/src/posix/sdl/sdlglvideo.cpp +++ b/src/posix/sdl/sdlglvideo.cpp @@ -35,7 +35,7 @@ IMPLEMENT_CLASS(SDLGLFB, true, false) struct MiniModeInfo { - WORD Width, Height; + uint16_t Width, Height; }; // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- @@ -420,7 +420,7 @@ bool SDLGLFB::CanUpdate () return true; } -void SDLGLFB::SetGammaTable(WORD *tbl) +void SDLGLFB::SetGammaTable(uint16_t *tbl) { if (m_supportsGamma) { diff --git a/src/posix/sdl/sdlglvideo.h b/src/posix/sdl/sdlglvideo.h index c3fde256c..6d60e1c0b 100644 --- a/src/posix/sdl/sdlglvideo.h +++ b/src/posix/sdl/sdlglvideo.h @@ -76,7 +76,7 @@ public: protected: bool CanUpdate(); - void SetGammaTable(WORD *tbl); + void SetGammaTable(uint16_t *tbl); void ResetGammaTable(); void InitializeState(); diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp index 8594eb648..030129fc0 100644 --- a/src/posix/sdl/sdlvideo.cpp +++ b/src/posix/sdl/sdlvideo.cpp @@ -28,7 +28,7 @@ IMPLEMENT_CLASS(SDLFB, false, false) struct MiniModeInfo { - WORD Width, Height; + uint16_t Width, Height; }; // PUBLIC FUNCTION PROTOTYPES ---------------------------------------------- @@ -273,7 +273,7 @@ void SDLFB::Update () { for (int y = 0; y < Height; ++y) { - memcpy ((BYTE *)pixels+y*pitch, MemBuffer+y*Pitch, Width); + memcpy ((uint8_t *)pixels+y*pitch, MemBuffer+y*Pitch, Width); } } } @@ -512,7 +512,7 @@ void SDLFB::SetVSync (bool vsync) #endif // __APPLE__ } -void SDLFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y) +void SDLFB::ScaleCoordsFromWindow(int16_t &x, int16_t &y) { int w, h; SDL_GetWindowSize (Screen, &w, &h); @@ -542,8 +542,8 @@ void SDLFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y) } else { - x = (SWORD)(x*Width/w); - y = (SWORD)(y*Height/h); + x = (int16_t)(x*Width/w); + y = (int16_t)(y*Height/h); } } diff --git a/src/r_data/r_interpolate.h b/src/r_data/r_interpolate.h index bcb584d02..cc0ed8bbc 100644 --- a/src/r_data/r_interpolate.h +++ b/src/r_data/r_interpolate.h @@ -15,8 +15,8 @@ class DInterpolation : public DObject DECLARE_ABSTRACT_CLASS(DInterpolation, DObject) HAS_OBJECT_POINTERS - TObjPtr Next; - TObjPtr Prev; + TObjPtr Next; + TObjPtr Prev; protected: int refcount; @@ -43,7 +43,7 @@ public: struct FInterpolator { - TObjPtr Head; + TObjPtr Head; bool didInterp; int count; diff --git a/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index e8ffda7ef..64f00b5bc 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -57,7 +57,7 @@ TAutoGrowArray translationtables[NUM_TRANSLATION_TABLES]; -const BYTE IcePalette[16][3] = +const uint8_t IcePalette[16][3] = { { 10, 8, 18 }, { 15, 15, 26 }, @@ -109,7 +109,7 @@ FRemapTable::~FRemapTable() void FRemapTable::Alloc(int count) { - Remap = (BYTE *)M_Malloc(count*sizeof(*Remap) + count*sizeof(*Palette)); + Remap = (uint8_t *)M_Malloc(count*sizeof(*Remap) + count*sizeof(*Palette)); assert (Remap != NULL); Palette = (PalEntry *)(Remap + count*(sizeof(*Remap))); Native = NULL; @@ -491,10 +491,10 @@ void FRemapTable::AddColourisation(int start, int end, int r, int g, int b) { for (int i = start; i < end; ++i) { - float br = GPalette.BaseColors[i].r; - float bg = GPalette.BaseColors[i].g; - float bb = GPalette.BaseColors[i].b; - float grey = (br * 0.299 + bg * 0.587 + bb * 0.114) / 255.0f; + double br = GPalette.BaseColors[i].r; + double bg = GPalette.BaseColors[i].g; + double bb = GPalette.BaseColors[i].b; + double grey = (br * 0.299 + bg * 0.587 + bb * 0.114) / 255.0f; if (grey > 1.0) grey = 1.0; br = r * grey; bg = g * grey; @@ -934,7 +934,7 @@ void R_InitTranslationTables () // Doom palette has no good substitutes for these bluish-tinted grays, so // they will just look gray unless you use a different PLAYPAL with Doom. - BYTE IcePaletteRemap[16]; + uint8_t IcePaletteRemap[16]; for (i = 0; i < 16; ++i) { IcePaletteRemap[i] = ColorMatcher.Pick (IcePalette[i][0], IcePalette[i][1], IcePalette[i][2]); @@ -1060,8 +1060,8 @@ static void R_CreatePlayerTranslation (float h, float s, float v, const FPlayerC FPlayerSkin *skin, FRemapTable *table, FRemapTable *alttable, FRemapTable *pillartable) { int i; - BYTE start = skin->range0start; - BYTE end = skin->range0end; + uint8_t start = skin->range0start; + uint8_t end = skin->range0end; float r, g, b; float bases, basev; float sdelta, vdelta; @@ -1125,7 +1125,7 @@ static void R_CreatePlayerTranslation (float h, float s, float v, const FPlayerC else { FMemLump translump = Wads.ReadLump(colorset->Lump); - const BYTE *trans = (const BYTE *)translump.GetMem(); + const uint8_t *trans = (const uint8_t *)translump.GetMem(); for (i = start; i <= end; ++i) { table->Remap[i] = GPalette.Remap[trans[i]]; diff --git a/src/r_data/r_translate.h b/src/r_data/r_translate.h index 6c0fe8c77..bd13550cc 100644 --- a/src/r_data/r_translate.h +++ b/src/r_data/r_translate.h @@ -47,7 +47,7 @@ struct FRemapTable void AddToTranslation(const char * range); int StoreTranslation(int slot); - BYTE *Remap; // For the software renderer + uint8_t *Remap; // For the software renderer PalEntry *Palette; // The ideal palette this maps to FNativePalette *Native; // The Palette stored in a HW texture int NumEntries; // # of elements in this table (usually 256) @@ -81,7 +81,7 @@ extern TAutoGrowArray translationtables[NUM_TRANS #define TRANSLATION_MASK ((1< BloodTranslationColors; diff --git a/src/r_data/renderstyle.cpp b/src/r_data/renderstyle.cpp index 5c9dcc429..c44b136a0 100644 --- a/src/r_data/renderstyle.cpp +++ b/src/r_data/renderstyle.cpp @@ -64,7 +64,7 @@ FRenderStyle LegacyRenderStyles[STYLE_Count] = #else FRenderStyle LegacyRenderStyles[STYLE_Count]; -static const BYTE Styles[STYLE_Count * 4] = +static const uint8_t Styles[STYLE_Count * 4] = { STYLEOP_None, STYLEALPHA_Zero, STYLEALPHA_Zero, 0, STYLEOP_Add, STYLEALPHA_Src, STYLEALPHA_InvSrc, STYLEF_Alpha1, diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index d6d6aa4e1..d4c046512 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -31,7 +31,7 @@ struct spriteframewithrotate : public spriteframe_t // [RH] skin globals TArray Skins; -BYTE OtherGameSkinRemap[256]; +uint8_t OtherGameSkinRemap[256]; PalEntry OtherGameSkinPalette[256]; @@ -211,7 +211,7 @@ static void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxfr // allocate space for the frames present and copy sprtemp to it sprites[num].numframes = maxframe; - sprites[num].spriteframes = WORD(framestart = SpriteFrames.Reserve (maxframe)); + sprites[num].spriteframes = uint16_t(framestart = SpriteFrames.Reserve (maxframe)); for (frame = 0; frame < maxframe; ++frame) { memcpy (SpriteFrames[framestart+frame].Texture, sprtemp[frame].Texture, sizeof(sprtemp[frame].Texture)); @@ -428,7 +428,7 @@ static void R_ExtendSpriteFrames(spritedef_t &spr, int frame) newstart = SpriteFrames.Reserve(frame - spr.numframes); if (spr.numframes == 0) { - spr.spriteframes = WORD(newstart); + spr.spriteframes = uint16_t(newstart); } } else @@ -440,7 +440,7 @@ static void R_ExtendSpriteFrames(spritedef_t &spr, int frame) { SpriteFrames[newstart + i] = SpriteFrames[spr.spriteframes + i]; } - spr.spriteframes = WORD(newstart); + spr.spriteframes = uint16_t(newstart); newstart += i; } // Initialize all new frames to 0. @@ -893,7 +893,7 @@ CCMD (skins) static void R_CreateSkinTranslation (const char *palname) { FMemLump lump = Wads.ReadLump (palname); - const BYTE *otherPal = (BYTE *)lump.GetMem(); + const uint8_t *otherPal = (uint8_t *)lump.GetMem(); for (int i = 0; i < 256; ++i) { diff --git a/src/r_data/sprites.h b/src/r_data/sprites.h index 9e7d9392e..d40be370f 100644 --- a/src/r_data/sprites.h +++ b/src/r_data/sprites.h @@ -19,7 +19,7 @@ struct spriteframe_t { struct FVoxelDef *Voxel;// voxel to use for this frame FTextureID Texture[16]; // texture to use for view angles 0-15 - WORD Flip; // flip (1 = flip) to use for view angles 0-15. + uint16_t Flip; // flip (1 = flip) to use for view angles 0-15. }; // @@ -32,10 +32,10 @@ struct spritedef_t union { char name[5]; - DWORD dwName; + uint32_t dwName; }; - BYTE numframes; - WORD spriteframes; + uint8_t numframes; + uint16_t spriteframes; }; extern TArray SpriteFrames; @@ -49,9 +49,9 @@ class FPlayerSkin public: FString Name; FString Face; - BYTE gender = 0; // This skin's gender (not really used) - BYTE range0start = 0; - BYTE range0end = 0; + uint8_t gender = 0; // This skin's gender (not really used) + uint8_t range0start = 0; + uint8_t range0end = 0; bool othergame = 0; // [GRB] DVector2 Scale = { 1, 1 }; int sprite = 0; @@ -61,7 +61,7 @@ public: extern TArray Skins; -extern BYTE OtherGameSkinRemap[256]; +extern uint8_t OtherGameSkinRemap[256]; extern PalEntry OtherGameSkinPalette[256]; void R_InitSprites (); diff --git a/src/r_defs.h b/src/r_defs.h index ea0e11480..0dca1f222 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. @@ -79,7 +79,7 @@ enum struct vertexdata_t { double zCeiling, zFloor; - DWORD flags; + uint32_t flags; }; #ifdef USE_FLOAT @@ -974,7 +974,7 @@ public: PalEntry SpecialColors[5]; - TObjPtr SoundTarget; + TObjPtr SoundTarget; short special; short lightlevel; @@ -995,9 +995,9 @@ public: int terrainnum[2]; // thinker_t for reversable actions - TObjPtr floordata; // jff 2/22/98 make thinkers on - TObjPtr ceilingdata; // floors, ceilings, lighting, - TObjPtr lightingdata; // independent of one another + TObjPtr floordata; // jff 2/22/98 make thinkers on + TObjPtr ceilingdata; // floors, ceilings, lighting, + TObjPtr lightingdata; // independent of one another enum { @@ -1006,20 +1006,20 @@ public: CeilingScroll, FloorScroll }; - TObjPtr interpolations[4]; + TObjPtr interpolations[4]; 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 @@ -1035,15 +1035,15 @@ 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 // joined by their tracer fields. When a potential sector action // occurs, SecActTarget's TriggerAction method is called. - TObjPtr SecActTarget; + TObjPtr SecActTarget; // [RH] The portal or skybox to render for this sector. unsigned Portals[2]; @@ -1125,7 +1125,7 @@ struct side_t double xScale; double yScale; FTextureID texture; - TObjPtr interpolation; + TObjPtr interpolation; //int Light; }; @@ -1133,16 +1133,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; } @@ -1412,7 +1412,7 @@ enum struct FPortalCoverage { - DWORD * subsectors; + uint32_t * subsectors; int sscount; }; @@ -1423,7 +1423,7 @@ struct subsector_t FMiniBSP *BSP; seg_t *firstline; sector_t *render_sector; - DWORD numlines; + uint32_t numlines; int flags; void BuildPolyBSP(); @@ -1481,7 +1481,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 diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 046cd9ab5..54016ac39 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -130,7 +130,7 @@ double ViewSin, ViewTanSin; AActor *camera; // [RH] camera to draw from. doesn't have to be a player double r_TicFracF; // same as floating point -DWORD r_FrameTime; // [RH] Time this frame started drawing (in ms) +uint32_t r_FrameTime; // [RH] Time this frame started drawing (in ms) bool r_NoInterpolate; bool r_showviewer; @@ -318,7 +318,7 @@ subsector_t *R_PointInSubsector (fixed_t x, fixed_t y) } while (!((size_t)node & 1)); - return (subsector_t *)((BYTE *)node - 1); + return (subsector_t *)((uint8_t *)node - 1); } //========================================================================== diff --git a/src/r_utility.h b/src/r_utility.h index ac31a6f5b..f1c1fc60d 100644 --- a/src/r_utility.h +++ b/src/r_utility.h @@ -42,7 +42,7 @@ extern bool LocalKeyboardTurner; // [RH] The local player used the keyboard t extern float WidescreenRatio; extern double r_TicFracF; -extern DWORD r_FrameTime; +extern uint32_t r_FrameTime; extern int extralight; extern unsigned int R_OldBlend; @@ -113,7 +113,7 @@ extern void R_ClearPastViewer (AActor *actor); struct FCanvasTextureInfo { FCanvasTextureInfo *Next; - TObjPtr Viewpoint; + TObjPtr Viewpoint; FCanvasTexture *Texture; FTextureID PicNum; int FOV; diff --git a/src/resourcefiles/file_7z.cpp b/src/resourcefiles/file_7z.cpp index f65951bfc..9cc52f6c9 100644 --- a/src/resourcefiles/file_7z.cpp +++ b/src/resourcefiles/file_7z.cpp @@ -262,7 +262,7 @@ bool F7ZFile::Open(bool quiet) TArray nameUTF16; TArray nameASCII; - for (DWORD i = 0; i < NumLumps; ++i) + for (uint32_t i = 0; i < NumLumps; ++i) { // skip Directories if (SzArEx_IsDir(archPtr, i)) diff --git a/src/resourcefiles/file_grp.cpp b/src/resourcefiles/file_grp.cpp index 464e790bd..663aeb16e 100644 --- a/src/resourcefiles/file_grp.cpp +++ b/src/resourcefiles/file_grp.cpp @@ -46,8 +46,8 @@ struct GrpInfo { - DWORD Magic[3]; - DWORD NumLumps; + uint32_t Magic[3]; + uint32_t NumLumps; }; struct GrpLump @@ -57,7 +57,7 @@ struct GrpLump struct { char Name[12]; - DWORD Size; + uint32_t Size; }; char NameWithZero[13]; }; @@ -110,7 +110,7 @@ bool FGrpFile::Open(bool quiet) int Position = sizeof(GrpInfo) + NumLumps * sizeof(GrpLump); - for(DWORD i = 0; i < NumLumps; i++) + for(uint32_t i = 0; i < NumLumps; i++) { Lumps[i].Owner = this; Lumps[i].Position = Position; diff --git a/src/resourcefiles/file_pak.cpp b/src/resourcefiles/file_pak.cpp index 16f7e8ea5..b76a937c8 100644 --- a/src/resourcefiles/file_pak.cpp +++ b/src/resourcefiles/file_pak.cpp @@ -106,7 +106,7 @@ bool FPakFile::Open(bool quiet) if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps); - for(DWORD i = 0; i < NumLumps; i++) + for(uint32_t i = 0; i < NumLumps; i++) { Lumps[i].LumpNameSetup(fileinfo[i].name); Lumps[i].Owner = this; diff --git a/src/resourcefiles/file_rff.cpp b/src/resourcefiles/file_rff.cpp index 25b5ccdab..ba73dfc8b 100644 --- a/src/resourcefiles/file_rff.cpp +++ b/src/resourcefiles/file_rff.cpp @@ -48,23 +48,23 @@ struct RFFInfo { // Should be "RFF\x18" - DWORD Magic; - DWORD Version; - DWORD DirOfs; - DWORD NumLumps; + uint32_t Magic; + uint32_t Version; + uint32_t DirOfs; + uint32_t NumLumps; }; struct RFFLump { - DWORD DontKnow1[4]; - DWORD FilePos; - DWORD Size; - DWORD DontKnow2; - DWORD Time; - BYTE Flags; + uint32_t DontKnow1[4]; + uint32_t FilePos; + uint32_t Size; + uint32_t DontKnow2; + uint32_t Time; + uint8_t Flags; char Extension[3]; char Name[8]; - DWORD IndexNum; // Used by .sfx, possibly others + uint32_t IndexNum; // Used by .sfx, possibly others }; //========================================================================== @@ -78,7 +78,7 @@ struct FRFFLump : public FUncompressedLump virtual FileReader *GetReader(); virtual int FillCache(); - DWORD IndexNum; + uint32_t IndexNum; int GetIndexNum() const { return IndexNum; } }; @@ -91,11 +91,11 @@ struct FRFFLump : public FUncompressedLump void BloodCrypt (void *data, int key, int len) { - int p = (BYTE)key, i; + int p = (uint8_t)key, i; for (i = 0; i < len; ++i) { - ((BYTE *)data)[i] ^= (unsigned char)(p+(i>>1)); + ((uint8_t *)data)[i] ^= (unsigned char)(p+(i>>1)); } } @@ -153,7 +153,7 @@ bool FRFFFile::Open(bool quiet) Lumps = new FRFFLump[NumLumps]; if (!quiet && !batchrun) Printf(", %d lumps\n", NumLumps); - for (DWORD i = 0; i < NumLumps; ++i) + for (uint32_t i = 0; i < NumLumps; ++i) { Lumps[i].Position = LittleLong(lumps[i].FilePos); Lumps[i].LumpSize = LittleLong(lumps[i].Size); @@ -230,7 +230,7 @@ int FRFFLump::FillCache() if (Flags & LUMPF_BLOODCRYPT) { int cryptlen = MIN (LumpSize, 256); - BYTE *data = (BYTE *)Cache; + uint8_t *data = (uint8_t *)Cache; for (int i = 0; i < cryptlen; ++i) { diff --git a/src/resourcefiles/file_wad.cpp b/src/resourcefiles/file_wad.cpp index 5965a5c8a..477bda8e1 100644 --- a/src/resourcefiles/file_wad.cpp +++ b/src/resourcefiles/file_wad.cpp @@ -49,7 +49,7 @@ private: FileReader &File; bool SawEOF; - BYTE InBuff[BUFF_SIZE]; + uint8_t InBuff[BUFF_SIZE]; enum StreamState { @@ -62,15 +62,15 @@ private: { StreamState State; - BYTE *In; + uint8_t *In; unsigned int AvailIn; unsigned int InternalOut; - BYTE CFlags, Bits; + uint8_t CFlags, Bits; - BYTE Window[WINDOW_SIZE+INTERNAL_BUFFER_SIZE]; - const BYTE *WindowData; - BYTE *InternalBuffer; + uint8_t Window[WINDOW_SIZE+INTERNAL_BUFFER_SIZE]; + const uint8_t *WindowData; + uint8_t *InternalBuffer; } Stream; void FillBuffer() @@ -109,8 +109,8 @@ private: return false; Stream.AvailIn -= 2; - WORD pos = BigShort(*(WORD*)Stream.In); - BYTE len = (pos & 0xF)+1; + uint16_t pos = BigShort(*(uint16_t*)Stream.In); + uint8_t len = (pos & 0xF)+1; pos >>= 4; Stream.In += 2; if(len == 1) @@ -120,7 +120,7 @@ private: return true; } - const BYTE* copyStart = Stream.InternalBuffer-pos-1; + const uint8_t* copyStart = Stream.InternalBuffer-pos-1; // Complete overlap: Single byte repeated if(pos == 0) @@ -182,7 +182,7 @@ public: long Read(void *buffer, long len) { - BYTE *Out = (BYTE*)buffer; + uint8_t *Out = (uint8_t*)buffer; long AvailOut = len; do @@ -222,7 +222,7 @@ public: while(AvailOut && Stream.State != STREAM_FINAL); assert(AvailOut == 0); - return (long)(Out - (BYTE*)buffer); + return (long)(Out - (uint8_t*)buffer); } }; @@ -329,7 +329,7 @@ FWadFile::~FWadFile() bool FWadFile::Open(bool quiet) { wadinfo_t header; - DWORD InfoTableOfs; + uint32_t InfoTableOfs; bool isBigEndian = false; // Little endian is assumed until proven otherwise const long wadSize = Reader->GetLength(); @@ -358,7 +358,7 @@ bool FWadFile::Open(bool quiet) Lumps = new FWadFileLump[NumLumps]; - for(DWORD i = 0; i < NumLumps; i++) + for(uint32_t i = 0; i < NumLumps; i++) { uppercopy (Lumps[i].Name, fileinfo[i].Name); Lumps[i].Name[8] = 0; @@ -563,7 +563,7 @@ void FWadFile::SkinHack () static int namespc = ns_firstskin; bool skinned = false; bool hasmap = false; - DWORD i; + uint32_t i; for (i = 0; i < NumLumps; i++) { @@ -580,7 +580,7 @@ void FWadFile::SkinHack () if (!skinned) { skinned = true; - DWORD j; + uint32_t j; for (j = 0; j < NumLumps; j++) { @@ -627,7 +627,7 @@ void FWadFile::SkinHack () void FWadFile::FindStrifeTeaserVoices () { - for (DWORD i = 0; i <= NumLumps; ++i) + for (uint32_t i = 0; i <= NumLumps; ++i) { if (Lumps[i].Name[0] == 'V' && Lumps[i].Name[1] == 'O' && diff --git a/src/resourcefiles/file_zip.cpp b/src/resourcefiles/file_zip.cpp index a48a17ca2..1245cfabe 100644 --- a/src/resourcefiles/file_zip.cpp +++ b/src/resourcefiles/file_zip.cpp @@ -123,23 +123,23 @@ bool FCompressedBuffer::Decompress(char *destbuffer) // //----------------------------------------------------------------------- -static DWORD Zip_FindCentralDir(FileReader * fin) +static uint32_t Zip_FindCentralDir(FileReader * fin) { unsigned char buf[BUFREADCOMMENT + 4]; - DWORD FileSize; - DWORD uBackRead; - DWORD uMaxBack; // maximum size of global comment - DWORD uPosFound=0; + uint32_t FileSize; + uint32_t uBackRead; + uint32_t uMaxBack; // maximum size of global comment + uint32_t uPosFound=0; fin->Seek(0, SEEK_END); FileSize = fin->Tell(); - uMaxBack = MIN(0xffff, FileSize); + uMaxBack = MIN(0xffff, FileSize); uBackRead = 4; while (uBackRead < uMaxBack) { - DWORD uReadSize, uReadPos; + uint32_t uReadSize, uReadPos; int i; if (uBackRead + BUFREADCOMMENT > uMaxBack) uBackRead = uMaxBack; @@ -147,7 +147,7 @@ static DWORD Zip_FindCentralDir(FileReader * fin) uBackRead += BUFREADCOMMENT; uReadPos = FileSize - uBackRead; - uReadSize = MIN((BUFREADCOMMENT + 4), (FileSize - uReadPos)); + uReadSize = MIN((BUFREADCOMMENT + 4), (FileSize - uReadPos)); if (fin->Seek(uReadPos, SEEK_SET) != 0) break; @@ -182,7 +182,7 @@ FZipFile::FZipFile(const char * filename, FileReader *file) bool FZipFile::Open(bool quiet) { - DWORD centraldir = Zip_FindCentralDir(Reader); + uint32_t centraldir = Zip_FindCentralDir(Reader); FZipEndOfCentralDirectory info; int skipped = 0; @@ -223,7 +223,7 @@ bool FZipFile::Open(bool quiet) // Check if all files have the same prefix so that this can be stripped out. // This will only be done if there is either a MAPINFO, ZMAPINFO or GAMEINFO lump in the subdirectory, denoting a ZDoom mod. - if (NumLumps > 1) for (DWORD i = 0; i < NumLumps; i++) + if (NumLumps > 1) for (uint32_t i = 0; i < NumLumps; i++) { FZipCentralDirectoryInfo *zip_fh = (FZipCentralDirectoryInfo *)dirptr; @@ -292,7 +292,7 @@ bool FZipFile::Open(bool quiet) dirptr = (char*)directory; lump_p = Lumps; - for (DWORD i = 0; i < NumLumps; i++) + for (uint32_t i = 0; i < NumLumps; i++) { FZipCentralDirectoryInfo *zip_fh = (FZipCentralDirectoryInfo *)dirptr; @@ -348,7 +348,7 @@ bool FZipFile::Open(bool quiet) lump_p->Owner = this; // The start of the Reader will be determined the first time it is accessed. lump_p->Flags = LUMPF_ZIPFILE | LUMPFZIP_NEEDFILESTART; - lump_p->Method = BYTE(zip_fh->Method); + lump_p->Method = uint8_t(zip_fh->Method); lump_p->GPFlags = zip_fh->Flags; lump_p->CRC32 = zip_fh->CRC32; lump_p->CompressedSize = LittleLong(zip_fh->CompressedSize); diff --git a/src/resourcefiles/file_zip.h b/src/resourcefiles/file_zip.h index 427d9cbf3..1078a0714 100644 --- a/src/resourcefiles/file_zip.h +++ b/src/resourcefiles/file_zip.h @@ -16,8 +16,8 @@ enum struct FZipLump : public FResourceLump { - WORD GPFlags; - BYTE Method; + uint16_t GPFlags; + uint8_t Method; int CompressedSize; int Position; unsigned CRC32; diff --git a/src/resourcefiles/resourcefile.cpp b/src/resourcefiles/resourcefile.cpp index c9f2f7446..7c9c957e3 100644 --- a/src/resourcefiles/resourcefile.cpp +++ b/src/resourcefiles/resourcefile.cpp @@ -204,7 +204,7 @@ FCompressedBuffer FResourceLump::GetRawData() { FCompressedBuffer cbuf = { (unsigned)LumpSize, (unsigned)LumpSize, METHOD_STORED, 0, 0, new char[LumpSize] }; memcpy(cbuf.mBuffer, CacheLump(), LumpSize); - cbuf.mCRC32 = crc32(0, (BYTE*)cbuf.mBuffer, LumpSize); + cbuf.mCRC32 = crc32(0, (uint8_t*)cbuf.mBuffer, LumpSize); ReleaseCache(); return cbuf; } @@ -365,7 +365,7 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize) // Filter out lumps using the same names as the Autoload.* sections // in the ini file use. We reduce the maximum lump concidered after // each one so that we don't risk refiltering already filtered lumps. - DWORD max = NumLumps; + uint32_t max = NumLumps; max -= FilterLumpsByGameType(gameinfo.gametype, lumps, lumpsize, max); long len; @@ -390,10 +390,10 @@ void FResourceFile::PostProcessArchive(void *lumps, size_t lumpsize) // //========================================================================== -int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize, DWORD max) +int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize, uint32_t max) { FString filter; - DWORD start, end; + uint32_t start, end; if (filtername.IsEmpty()) { @@ -402,11 +402,11 @@ int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize, filter << "filter/" << filtername << '/'; if (FindPrefixRange(filter, lumps, lumpsize, max, start, end)) { - void *from = (BYTE *)lumps + start * lumpsize; + void *from = (uint8_t *)lumps + start * lumpsize; // Remove filter prefix from every name void *lump_p = from; - for (DWORD i = start; i < end; ++i, lump_p = (BYTE *)lump_p + lumpsize) + for (uint32_t i = start; i < end; ++i, lump_p = (uint8_t *)lump_p + lumpsize) { FResourceLump *lump = (FResourceLump *)lump_p; assert(lump->FullName.CompareNoCase(filter, (int)filter.Len()) == 0); @@ -415,17 +415,17 @@ int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize, // Move filtered lumps to the end of the lump list. size_t count = (end - start) * lumpsize; - void *to = (BYTE *)lumps + NumLumps * lumpsize - count; + void *to = (uint8_t *)lumps + NumLumps * lumpsize - count; assert (to >= from); if (from != to) { // Copy filtered lumps to a temporary buffer. - BYTE *filteredlumps = new BYTE[count]; + uint8_t *filteredlumps = new uint8_t[count]; memcpy(filteredlumps, from, count); // Shift lumps left to make room for the filtered ones at the end. - memmove(from, (BYTE *)from + count, (NumLumps - end) * lumpsize); + memmove(from, (uint8_t *)from + count, (NumLumps - end) * lumpsize); // Copy temporary buffer to newly freed space. memcpy(to, filteredlumps, count); @@ -445,7 +445,7 @@ int FResourceFile::FilterLumps(FString filtername, void *lumps, size_t lumpsize, // //========================================================================== -int FResourceFile::FilterLumpsByGameType(int type, void *lumps, size_t lumpsize, DWORD max) +int FResourceFile::FilterLumpsByGameType(int type, void *lumps, size_t lumpsize, uint32_t max) { static const struct { int match; const char *name; } blanket[] = { @@ -479,16 +479,16 @@ int FResourceFile::FilterLumpsByGameType(int type, void *lumps, size_t lumpsize, // //========================================================================== -void FResourceFile::JunkLeftoverFilters(void *lumps, size_t lumpsize, DWORD max) +void FResourceFile::JunkLeftoverFilters(void *lumps, size_t lumpsize, uint32_t max) { - DWORD start, end; + uint32_t start, end; if (FindPrefixRange("filter/", lumps, lumpsize, max, start, end)) { // Since the resource lumps may contain non-POD data besides the // full name, we "delete" them by erasing their names so they // can't be found. - void *stop = (BYTE *)lumps + end * lumpsize; - for (void *p = (BYTE *)lumps + start * lumpsize; p < stop; p = (BYTE *)p + lumpsize) + void *stop = (uint8_t *)lumps + end * lumpsize; + for (void *p = (uint8_t *)lumps + start * lumpsize; p < stop; p = (uint8_t *)p + lumpsize) { FResourceLump *lump = (FResourceLump *)p; lump->FullName = 0; @@ -508,9 +508,9 @@ void FResourceFile::JunkLeftoverFilters(void *lumps, size_t lumpsize, DWORD max) // //========================================================================== -bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize, DWORD maxlump, DWORD &start, DWORD &end) +bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize, uint32_t maxlump, uint32_t &start, uint32_t &end) { - DWORD min, max, mid, inside; + uint32_t min, max, mid, inside; FResourceLump *lump; int cmp; @@ -518,14 +518,14 @@ bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize // Pretend that our range starts at 1 instead of 0 so that we can avoid // unsigned overflow if the range starts at the first lump. - lumps = (BYTE *)lumps - lumpsize; + lumps = (uint8_t *)lumps - lumpsize; // Binary search to find any match at all. min = 1, max = maxlump; while (min <= max) { mid = min + (max - min) / 2; - lump = (FResourceLump *)((BYTE *)lumps + mid * lumpsize); + lump = (FResourceLump *)((uint8_t *)lumps + mid * lumpsize); cmp = lump->FullName.CompareNoCase(filter, (int)filter.Len()); if (cmp == 0) break; @@ -545,7 +545,7 @@ bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize while (min <= max) { mid = min + (max - min) / 2; - lump = (FResourceLump *)((BYTE *)lumps + mid * lumpsize); + lump = (FResourceLump *)((uint8_t *)lumps + mid * lumpsize); cmp = lump->FullName.CompareNoCase(filter, (int)filter.Len()); // Go left on matches and right on misses. if (cmp == 0) @@ -560,7 +560,7 @@ bool FResourceFile::FindPrefixRange(FString filter, void *lumps, size_t lumpsize while (min <= max) { mid = min + (max - min) / 2; - lump = (FResourceLump *)((BYTE *)lumps + mid * lumpsize); + lump = (FResourceLump *)((uint8_t *)lumps + mid * lumpsize); cmp = lump->FullName.CompareNoCase(filter, (int)filter.Len()); // Go right on matches and left on misses. if (cmp == 0) diff --git a/src/resourcefiles/resourcefile.h b/src/resourcefiles/resourcefile.h index bedcad3bb..a36d6ad49 100644 --- a/src/resourcefiles/resourcefile.h +++ b/src/resourcefiles/resourcefile.h @@ -40,11 +40,11 @@ struct FResourceLump { char Name[9]; - DWORD dwName; // These are for accessing the first 4 or 8 chars of + uint32_t dwName; // These are for accessing the first 4 or 8 chars of QWORD qwName; // Name as a unit without breaking strict aliasing rules }; - BYTE Flags; - SBYTE RefCount; + uint8_t Flags; + int8_t RefCount; char * Cache; FResourceFile * Owner; FTexture * LinkedTexture; @@ -84,7 +84,7 @@ public: FileReader *Reader; const char *Filename; protected: - DWORD NumLumps; + uint32_t NumLumps; FResourceFile(const char *filename, FileReader *r); @@ -92,21 +92,21 @@ protected: void PostProcessArchive(void *lumps, size_t lumpsize); private: - DWORD FirstLump; + uint32_t FirstLump; - int FilterLumps(FString filtername, void *lumps, size_t lumpsize, DWORD max); - int FilterLumpsByGameType(int gametype, void *lumps, size_t lumpsize, DWORD max); - bool FindPrefixRange(FString filter, void *lumps, size_t lumpsize, DWORD max, DWORD &start, DWORD &end); - void JunkLeftoverFilters(void *lumps, size_t lumpsize, DWORD max); + int FilterLumps(FString filtername, void *lumps, size_t lumpsize, uint32_t max); + int FilterLumpsByGameType(int gametype, void *lumps, size_t lumpsize, uint32_t max); + bool FindPrefixRange(FString filter, void *lumps, size_t lumpsize, uint32_t max, uint32_t &start, uint32_t &end); + void JunkLeftoverFilters(void *lumps, size_t lumpsize, uint32_t max); public: static FResourceFile *OpenResourceFile(const char *filename, FileReader *file, bool quiet = false, bool containeronly = false); static FResourceFile *OpenDirectory(const char *filename, bool quiet = false); virtual ~FResourceFile(); FileReader *GetReader() const { return Reader; } - DWORD LumpCount() const { return NumLumps; } - DWORD GetFirstLump() const { return FirstLump; } - void SetFirstLump(DWORD f) { FirstLump = f; } + uint32_t LumpCount() const { return NumLumps; } + uint32_t GetFirstLump() const { return FirstLump; } + void SetFirstLump(uint32_t f) { FirstLump = f; } virtual void FindStrifeTeaserVoices (); virtual bool Open(bool quiet) = 0; diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 687a27a43..5aa52981d 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -79,15 +79,15 @@ struct FRandomSoundList } } - WORD *Sounds; // A list of sounds that can result for the following id - WORD SfxHead; // The sound id used to reference this list - WORD NumSounds; + uint16_t *Sounds; // A list of sounds that can result for the following id + uint16_t SfxHead; // The sound id used to reference this list + uint16_t NumSounds; }; struct FPlayerClassLookup { FString Name; - WORD ListIndex[3]; // indices into PlayerSounds (0xffff means empty) + uint16_t ListIndex[3]; // indices into PlayerSounds (0xffff means empty) }; // Used to lookup a sound like "*grunt". This contains all player sounds for @@ -163,10 +163,10 @@ enum SICommands struct FBloodSFX { - DWORD RelVol; // volume, 0-255 + uint32_t RelVol; // volume, 0-255 int Pitch; // pitch change int PitchRange; // range of random pitch - DWORD Format; // format of audio 1=11025 5=22050 + uint32_t Format; // format of audio 1=11025 5=22050 int32_t LoopStart; // loop position (-1 means no looping) char RawName[9]; // name of RAW resource }; @@ -270,7 +270,7 @@ static TArray PlayerSounds; static FString DefPlayerClassName; static int DefPlayerClass; -static BYTE CurrentPitchMask; +static uint8_t CurrentPitchMask; static FRandom pr_randsound ("RandSound"); @@ -1070,7 +1070,7 @@ void S_AddLocalSndInfo(int lump) static void S_AddSNDINFO (int lump) { bool skipToEndIf; - TArray list; + TArray list; FScanner sc(lump); skipToEndIf = false; @@ -1395,7 +1395,7 @@ static void S_AddSNDINFO (int lump) sc.MustGetStringName ("{"); while (sc.GetString () && !sc.Compare ("}")) { - WORD sfxto = S_FindSoundTentative (sc.String); + uint16_t sfxto = S_FindSoundTentative (sc.String); if (sfxto == random.SfxHead) { Printf("Definition of random sound '%s' refers to itself recursively.", sc.String); @@ -1410,11 +1410,11 @@ static void S_AddSNDINFO (int lump) } else if (list.Size() > 1) { // Only add non-empty random lists - random.NumSounds = (WORD)list.Size(); - S_sfx[random.SfxHead].link = (WORD)S_rnd.Push (random); + random.NumSounds = (uint16_t)list.Size(); + S_sfx[random.SfxHead].link = (uint16_t)S_rnd.Push (random); S_sfx[random.SfxHead].bRandomHeader = true; - S_rnd[S_sfx[random.SfxHead].link].Sounds = new WORD[random.NumSounds]; - memcpy (S_rnd[S_sfx[random.SfxHead].link].Sounds, &list[0], sizeof(WORD)*random.NumSounds); + S_rnd[S_sfx[random.SfxHead].link].Sounds = new uint16_t[random.NumSounds]; + memcpy (S_rnd[S_sfx[random.SfxHead].link].Sounds, &list[0], sizeof(uint16_t)*random.NumSounds); S_sfx[random.SfxHead].NearLimit = -1; } } @@ -1700,7 +1700,7 @@ static int S_AddPlayerGender (int classnum, int gender) if (index == 0xffff) { index = PlayerSounds.Reserve (1); - PlayerClassLookups[classnum].ListIndex[gender] = (WORD)index; + PlayerClassLookups[classnum].ListIndex[gender] = (uint16_t)index; } return index; } diff --git a/src/s_environment.cpp b/src/s_environment.cpp index 377537a6c..4dafa706e 100644 --- a/src/s_environment.cpp +++ b/src/s_environment.cpp @@ -489,7 +489,7 @@ static void ReadReverbDef (int lump) char *name; int id1, id2, i, j; bool inited[NUM_REVERB_FIELDS]; - BYTE bools[32]; + uint8_t bools[32]; sc.OpenLumpNum(lump); while (sc.GetString ()) diff --git a/src/s_sndseq.cpp b/src/s_sndseq.cpp index af3f3617b..71cb943f8 100644 --- a/src/s_sndseq.cpp +++ b/src/s_sndseq.cpp @@ -97,7 +97,7 @@ typedef enum struct hexenseq_t { ENamedName Name; - BYTE Seqs[4]; + uint8_t Seqs[4]; }; class DSeqActorNode : public DSeqNode @@ -126,7 +126,7 @@ public: } private: DSeqActorNode() {} - TObjPtr m_Actor; + TObjPtr m_Actor; }; class DSeqPolyNode : public DSeqNode @@ -203,7 +203,7 @@ struct FSoundSequencePtrArray : public TArray static void AssignTranslations (FScanner &sc, int seq, seqtype_t type); static void AssignHexenTranslations (void); -static void AddSequence (int curseq, FName seqname, FName slot, int stopsound, const TArray &ScriptTemp); +static void AddSequence (int curseq, FName seqname, FName slot, int stopsound, const TArray &ScriptTemp); static int FindSequence (const char *searchname); static int FindSequence (FName seqname); static bool TwiddleSeqNum (int &sequence, seqtype_t type); @@ -559,7 +559,7 @@ void S_ClearSndSeq() void S_ParseSndSeq (int levellump) { - TArray ScriptTemp; + TArray ScriptTemp; int lastlump, lump; char seqtype = ':'; FName seqname; @@ -785,13 +785,13 @@ void S_ParseSndSeq (int levellump) AssignHexenTranslations (); } -static void AddSequence (int curseq, FName seqname, FName slot, int stopsound, const TArray &ScriptTemp) +static void AddSequence (int curseq, FName seqname, FName slot, int stopsound, const TArray &ScriptTemp) { - Sequences[curseq] = (FSoundSequence *)M_Malloc (sizeof(FSoundSequence) + sizeof(DWORD)*ScriptTemp.Size()); + Sequences[curseq] = (FSoundSequence *)M_Malloc (sizeof(FSoundSequence) + sizeof(uint32_t)*ScriptTemp.Size()); Sequences[curseq]->SeqName = seqname; Sequences[curseq]->Slot = slot; Sequences[curseq]->StopSound = FSoundID(stopsound); - memcpy (Sequences[curseq]->Script, &ScriptTemp[0], sizeof(DWORD)*ScriptTemp.Size()); + memcpy (Sequences[curseq]->Script, &ScriptTemp[0], sizeof(uint32_t)*ScriptTemp.Size()); Sequences[curseq]->Script[ScriptTemp.Size()] = MakeCommand(SS_CMD_END, 0); } diff --git a/src/s_sndseq.h b/src/s_sndseq.h index e77df2271..c392f1178 100644 --- a/src/s_sndseq.h +++ b/src/s_sndseq.h @@ -55,8 +55,8 @@ protected: int m_ModeNum; TArray m_SequenceChoices; - TObjPtr m_ChildSeqNode; - TObjPtr m_ParentSeqNode; + TObjPtr m_ChildSeqNode; + TObjPtr m_ParentSeqNode; private: static DSeqNode *SequenceListHead; diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 89fc13365..544149ca3 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -131,7 +131,7 @@ FSoundChan *Channels; FSoundChan *FreeChannels; FRolloffInfo S_Rolloff; -BYTE *S_SoundCurve; +uint8_t *S_SoundCurve; int S_SoundCurveSize; FBoolCVar noisedebug ("noise", false, 0); // [RH] Print sound debugging info? @@ -301,7 +301,7 @@ void S_Init () if (curvelump >= 0) { S_SoundCurveSize = Wads.LumpLength (curvelump); - S_SoundCurve = new BYTE[S_SoundCurveSize]; + S_SoundCurve = new uint8_t[S_SoundCurveSize]; Wads.ReadLump(curvelump, S_SoundCurve); } @@ -1398,7 +1398,7 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx) if (size > 0) { FWadLump wlump = Wads.OpenLumpNum(sfx->lumpnum); - BYTE *sfxdata = new BYTE[size]; + uint8_t *sfxdata = new uint8_t[size]; wlump.Read(sfxdata, size); int32_t dmxlen = LittleLong(((int32_t *)sfxdata)[1]); std::pair snd; @@ -1414,9 +1414,9 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx) snd = GSnd->LoadSoundRaw(sfxdata, size, sfx->RawRate, 1, 8, sfx->LoopStart); } // Otherwise, try the sound as DMX format. - else if (((BYTE *)sfxdata)[0] == 3 && ((BYTE *)sfxdata)[1] == 0 && dmxlen <= size - 8) + else if (((uint8_t *)sfxdata)[0] == 3 && ((uint8_t *)sfxdata)[1] == 0 && dmxlen <= size - 8) { - int frequency = LittleShort(((WORD *)sfxdata)[1]); + int frequency = LittleShort(((uint16_t *)sfxdata)[1]); if (frequency == 0) frequency = 11025; snd = GSnd->LoadSoundRaw(sfxdata+8, dmxlen, frequency, 1, 8, sfx->LoopStart); } @@ -1458,7 +1458,7 @@ static void S_LoadSound3D(sfxinfo_t *sfx) if(size <= 0) return; FWadLump wlump = Wads.OpenLumpNum(sfx->lumpnum); - BYTE *sfxdata = new BYTE[size]; + uint8_t *sfxdata = new uint8_t[size]; wlump.Read(sfxdata, size); int32_t dmxlen = LittleLong(((int32_t *)sfxdata)[1]); std::pair snd; @@ -1474,9 +1474,9 @@ static void S_LoadSound3D(sfxinfo_t *sfx) snd = GSnd->LoadSoundRaw(sfxdata, size, sfx->RawRate, 1, 8, sfx->LoopStart, true); } // Otherwise, try the sound as DMX format. - else if (((BYTE *)sfxdata)[0] == 3 && ((BYTE *)sfxdata)[1] == 0 && dmxlen <= size - 8) + else if (((uint8_t *)sfxdata)[0] == 3 && ((uint8_t *)sfxdata)[1] == 0 && dmxlen <= size - 8) { - int frequency = LittleShort(((WORD *)sfxdata)[1]); + int frequency = LittleShort(((uint16_t *)sfxdata)[1]); if (frequency == 0) frequency = 11025; snd = GSnd->LoadSoundRaw(sfxdata+8, dmxlen, frequency, 1, 8, sfx->LoopStart, -1, true); } diff --git a/src/s_sound.h b/src/s_sound.h index 00c7d0587..541a50701 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -46,21 +46,21 @@ struct sfxinfo_t unsigned int next, index; // [RH] For hashing float Volume; - BYTE PitchMask; - SWORD NearLimit; // 0 means unlimited + uint8_t PitchMask; + int16_t NearLimit; // 0 means unlimited float LimitRange; // Range for sound limiting (squared for faster computations) - WORD bRandomHeader:1; - WORD bPlayerReserve:1; - WORD bLoadRAW:1; - WORD bPlayerCompat:1; - WORD b16bit:1; - WORD bUsed:1; - WORD bSingular:1; - WORD bTentative:1; - WORD bPlayerSilent:1; // This player sound is intentionally silent. + unsigned bRandomHeader:1; + unsigned bPlayerReserve:1; + unsigned bLoadRAW:1; + unsigned bPlayerCompat:1; + unsigned b16bit:1; + unsigned bUsed:1; + unsigned bSingular:1; + unsigned bTentative:1; + unsigned bPlayerSilent:1; // This player sound is intentionally silent. - WORD RawRate; // Sample rate to use when bLoadRAW is true + int RawRate; // Sample rate to use when bLoadRAW is true int LoopStart; // -1 means no specific loop defined @@ -177,7 +177,7 @@ public: }; extern FRolloffInfo S_Rolloff; -extern BYTE *S_SoundCurve; +extern uint8_t *S_SoundCurve; extern int S_SoundCurveSize; // Information about one playing sound. @@ -191,11 +191,11 @@ struct FSoundChan : public FISoundChannel FSoundID OrgID; // Sound ID of sound used to start this channel. float Volume; int ChanFlags; - SWORD Pitch; // Pitch variation. - BYTE EntChannel; // Actor's sound channel. - SBYTE Priority; - SWORD NearLimit; - BYTE SourceType; + int16_t Pitch; // Pitch variation. + uint8_t EntChannel; // Actor's sound channel. + int8_t Priority; + int16_t NearLimit; + uint8_t SourceType; float LimitRange; union { diff --git a/src/sc_man.cpp b/src/sc_man.cpp index 577f7690e..ee31e0f6d 100644 --- a/src/sc_man.cpp +++ b/src/sc_man.cpp @@ -200,7 +200,7 @@ void FScanner::Open (const char *name) void FScanner::OpenFile (const char *name) { - BYTE *filebuf; + uint8_t *filebuf; int filesize; Close (); diff --git a/src/sc_man.h b/src/sc_man.h index 25565ad9a..860935b8d 100644 --- a/src/sc_man.h +++ b/src/sc_man.h @@ -103,7 +103,7 @@ protected: const char *LastGotPtr; int LastGotLine; bool CMode; - BYTE StateMode; + uint8_t StateMode; bool StateOptions; bool Escape; VersionInfo ParseVersion = { 0, 0, 0 }; // no ZScript extensions by default diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index c0a69eb6e..56bf71080 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -2466,7 +2466,7 @@ FxExpression *FxAssign::Resolve(FCompileContext &ctx) ExpEmit FxAssign::Emit(VMFunctionBuilder *build) { - static const BYTE loadops[] = { OP_LK, OP_LKF, OP_LKS, OP_LKP }; + static const uint8_t loadops[] = { OP_LK, OP_LKF, OP_LKS, OP_LKP }; assert(Base->ValueType->GetRegType() == Right->ValueType->GetRegType()); ExpEmit pointer = Base->Emit(build); diff --git a/src/scripting/backend/vmbuilder.cpp b/src/scripting/backend/vmbuilder.cpp index 31290cc48..308410922 100644 --- a/src/scripting/backend/vmbuilder.cpp +++ b/src/scripting/backend/vmbuilder.cpp @@ -40,7 +40,7 @@ struct VMRemap { - BYTE altOp, kReg, kType; + uint8_t altOp, kReg, kType; }; @@ -563,7 +563,7 @@ size_t VMFunctionBuilder::GetAddress() size_t VMFunctionBuilder::Emit(int opcode, int opa, int opb, int opc) { - static BYTE opcodes[] = { OP_LK, OP_LKF, OP_LKS, OP_LKP }; + static uint8_t opcodes[] = { OP_LK, OP_LKF, OP_LKS, OP_LKP }; assert(opcode >= 0 && opcode < NUM_OPS); assert(opa >= 0); diff --git a/src/scripting/decorate/olddecorations.cpp b/src/scripting/decorate/olddecorations.cpp index e926fdbbd..9ecf8c2a0 100644 --- a/src/scripting/decorate/olddecorations.cpp +++ b/src/scripting/decorate/olddecorations.cpp @@ -331,7 +331,7 @@ static void ParseInsideDecoration (Baggage &bag, AActor *defaults, { sc.ScriptError ("DoomEdNum must be in the range [-1,32767]"); } - bag.Info->DoomEdNum = (SWORD)sc.Number; + bag.Info->DoomEdNum = (int16_t)sc.Number; } else if (sc.Compare ("SpawnNum")) { @@ -340,7 +340,7 @@ static void ParseInsideDecoration (Baggage &bag, AActor *defaults, { sc.ScriptError ("SpawnNum must be in the range [0,255]"); } - bag.Info->SpawnID = (BYTE)sc.Number; + bag.Info->SpawnID = (uint8_t)sc.Number; } else if (sc.Compare ("Sprite") || ( (def == DEF_BreakableDecoration || def == DEF_Projectile) && diff --git a/src/scripting/decorate/thingdef_states.cpp b/src/scripting/decorate/thingdef_states.cpp index 7bfd5c685..4355941be 100644 --- a/src/scripting/decorate/thingdef_states.cpp +++ b/src/scripting/decorate/thingdef_states.cpp @@ -610,7 +610,7 @@ void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray ¶ms = afd->Variants[0].Proto->ArgumentTypes; - const TArray ¶mflags = afd->Variants[0].ArgFlags; + const TArray ¶mflags = afd->Variants[0].ArgFlags; int numparams = (int)params.Size(); int pnum = 0; bool zeroparm; diff --git a/src/scripting/symbols.cpp b/src/scripting/symbols.cpp index b6adb33e7..41ca4a1a8 100644 --- a/src/scripting/symbols.cpp +++ b/src/scripting/symbols.cpp @@ -79,7 +79,7 @@ PSymbolConstString::PSymbolConstString(FName name, const FString &str) // //========================================================================== -unsigned PFunction::AddVariant(PPrototype *proto, TArray &argflags, TArray &argnames, VMFunction *impl, int flags, int useflags) +unsigned PFunction::AddVariant(PPrototype *proto, TArray &argflags, TArray &argnames, VMFunction *impl, int flags, int useflags) { Variant variant; diff --git a/src/scripting/thingdef.cpp b/src/scripting/thingdef.cpp index e63f9aa71..82e358638 100644 --- a/src/scripting/thingdef.cpp +++ b/src/scripting/thingdef.cpp @@ -101,7 +101,7 @@ FScriptPosition & GetStateSource(FState *state) // //========================================================================== -void SetImplicitArgs(TArray *args, TArray *argflags, TArray *argnames, PStruct *cls, DWORD funcflags, int useflags) +void SetImplicitArgs(TArray *args, TArray *argflags, TArray *argnames, PStruct *cls, uint32_t funcflags, int useflags) { // Must be called before adding any other arguments. assert(args == nullptr || args->Size() == 0); diff --git a/src/scripting/thingdef.h b/src/scripting/thingdef.h index 3f42e8c7a..7517283cf 100644 --- a/src/scripting/thingdef.h +++ b/src/scripting/thingdef.h @@ -52,7 +52,7 @@ struct FStateDefine FName Label; TArray Children; FState *State; - BYTE DefineFlags; + uint8_t DefineFlags; }; class FStateDefinitions @@ -83,7 +83,7 @@ public: lastlabel = -1; } - void SetStateLabel(const char *statename, FState *state, BYTE defflags = SDF_STATE); + void SetStateLabel(const char *statename, FState *state, uint8_t defflags = SDF_STATE); void AddStateLabel(const char *statename); int GetStateLabelIndex (FName statename); void InstallStates(PClassActor *info, AActor *defaults); @@ -159,7 +159,7 @@ void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray *args, TArray *argflags, TArray *argnames, PStruct *cls, DWORD funcflags, int useflags); +void SetImplicitArgs(TArray *args, TArray *argflags, TArray *argnames, PStruct *cls, uint32_t funcflags, int useflags); PFunction *CreateAnonymousFunction(PClass *containingclass, PType *returntype, int flags); PFunction *FindClassMemberFunction(PStruct *cls, PStruct *funccls, FName name, FScriptPosition &sc, bool *error); void CreateDamageFunction(PNamespace *ns, const VersionInfo &ver, PClassActor *info, AActor *defaults, FxExpression *id, bool fromDecorate, int lumpnum); diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index 7d70cfd0f..ad6e7e8d8 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -123,7 +123,7 @@ void ModActorFlag(AActor *actor, FFlagDef *fd, bool set) if (fd->fieldsize == 4) #endif { - DWORD *flagvar = (DWORD *)((char *)actor + fd->structoffset); + uint32_t *flagvar = (uint32_t *)((char *)actor + fd->structoffset); if (set) { *flagvar |= fd->flagbit; @@ -136,7 +136,7 @@ void ModActorFlag(AActor *actor, FFlagDef *fd, bool set) #ifdef __BIG_ENDIAN__ else if (fd->fieldsize == 2) { - WORD *flagvar = (WORD *)((char *)actor + fd->structoffset); + uint16_t *flagvar = (uint16_t *)((char *)actor + fd->structoffset); if (set) { *flagvar |= fd->flagbit; @@ -149,7 +149,7 @@ void ModActorFlag(AActor *actor, FFlagDef *fd, bool set) else { assert(fd->fieldsize == 1); - BYTE *flagvar = (BYTE *)((char *)actor + fd->structoffset); + uint8_t *flagvar = (uint8_t *)((char *)actor + fd->structoffset); if (set) { *flagvar |= fd->flagbit; @@ -245,17 +245,17 @@ INTBOOL CheckActorFlag(const AActor *owner, FFlagDef *fd) if (fd->fieldsize == 4) #endif { - return fd->flagbit & *(DWORD *)(((char*)owner) + fd->structoffset); + return fd->flagbit & *(uint32_t *)(((char*)owner) + fd->structoffset); } #ifdef __BIG_ENDIAN__ else if (fd->fieldsize == 2) { - return fd->flagbit & *(WORD *)(((char*)owner) + fd->structoffset); + return fd->flagbit & *(uint16_t *)(((char*)owner) + fd->structoffset); } else { assert(fd->fieldsize == 1); - return fd->flagbit & *(BYTE *)(((char*)owner) + fd->structoffset); + return fd->flagbit & *(uint8_t *)(((char*)owner) + fd->structoffset); } #endif } @@ -520,7 +520,7 @@ DEFINE_INFO_PROPERTY(spawnid, I, Actor) { I_Error ("SpawnID must be in the range [0,65535]"); } - else info->SpawnID=(WORD)id; + else info->SpawnID=(uint16_t)id; } //========================================================================== @@ -533,7 +533,7 @@ DEFINE_INFO_PROPERTY(conversationid, IiI, Actor) PROP_INT_PARM(id2, 2); if (convid <= 0 || convid > 65535) return; // 0 is not usable because the dialogue scripts use it as 'no object'. - else info->ConversationID=(WORD)convid; + else info->ConversationID=(uint16_t)convid; } //========================================================================== @@ -2507,7 +2507,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, damagescreencolor, Cfs, PlayerPawn) { PROP_DOUBLE_PARM(a, 2); - color.a = BYTE(255 * clamp(a, 0.f, 1.f)); + color.a = uint8_t(255 * clamp(a, 0.f, 1.f)); defaults->DamageFade = color; } else @@ -2515,7 +2515,7 @@ DEFINE_CLASS_PROPERTY_PREFIX(player, damagescreencolor, Cfs, PlayerPawn) PROP_DOUBLE_PARM(a, 2); PROP_STRING_PARM(type, 3); - color.a = BYTE(255 * clamp(a, 0.f, 1.f)); + color.a = uint8_t(255 * clamp(a, 0.f, 1.f)); PainFlashes.Push(std::make_tuple(info, type, color)); } } diff --git a/src/scripting/vm/vm.h b/src/scripting/vm/vm.h index 02f048a1c..3a4ffb02c 100644 --- a/src/scripting/vm/vm.h +++ b/src/scripting/vm/vm.h @@ -704,7 +704,7 @@ class VMFunction public: bool Unsafe = false; int VarFlags = 0; // [ZZ] this replaces 5+ bool fields - BYTE ImplicitArgs = 0; // either 0 for static, 1 for method or 3 for action + uint8_t ImplicitArgs = 0; // either 0 for static, 1 for method or 3 for action unsigned VirtualIndex = ~0u; FName Name; TArray DefaultArgs; diff --git a/src/scripting/vm/vmexec.h b/src/scripting/vm/vmexec.h index 594942351..ce3e3be22 100644 --- a/src/scripting/vm/vmexec.h +++ b/src/scripting/vm/vmexec.h @@ -649,9 +649,9 @@ begin: } NEXTOP; OP(SCOPE) : - { - ASSERTA(a); ASSERTA(C); - FScopeBarrier::ValidateCall(((DObject*)a)->GetClass(), (VMFunction*)C, B - 1); + { + ASSERTA(a); ASSERTA(C); + FScopeBarrier::ValidateCall(((DObject*)konsta[a].v)->GetClass(), (VMFunction*)konsta[C].v, B - 1); } NEXTOP; diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index fc8794aac..6be8a0038 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -2292,7 +2292,7 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool } else { - (*afd->VMPointer)->ImplicitArgs = BYTE(implicitargs); + (*afd->VMPointer)->ImplicitArgs = uint8_t(implicitargs); } } SetImplicitArgs(&args, &argflags, &argnames, c->Type(), varflags, useflags); diff --git a/src/scripting/zscript/zcc_parser.cpp b/src/scripting/zscript/zcc_parser.cpp index 6df435f6c..c4f86eff1 100644 --- a/src/scripting/zscript/zcc_parser.cpp +++ b/src/scripting/zscript/zcc_parser.cpp @@ -64,14 +64,14 @@ void AddInclude(ZCC_ExprConstant *node) struct TokenMapEntry { - SWORD TokenType; - WORD TokenName; - TokenMapEntry(SWORD a, WORD b) + int16_t TokenType; + uint16_t TokenName; + TokenMapEntry(int16_t a, uint16_t b) : TokenType(a), TokenName(b) { } }; -static TMap TokenMap; -static SWORD BackTokenMap[YYERRORSYMBOL]; // YYERRORSYMBOL immediately follows the terminals described by the grammar +static TMap TokenMap; +static int16_t BackTokenMap[YYERRORSYMBOL]; // YYERRORSYMBOL immediately follows the terminals described by the grammar #define TOKENDEF2(sc, zcc, name) { TokenMapEntry tme(zcc, name); TokenMap.Insert(sc, tme); } BackTokenMap[zcc] = sc #define TOKENDEF(sc, zcc) TOKENDEF2(sc, zcc, NAME_None) diff --git a/src/sfmt/SFMT.cpp b/src/sfmt/SFMT.cpp index b739e4c72..aaece8575 100644 --- a/src/sfmt/SFMT.cpp +++ b/src/sfmt/SFMT.cpp @@ -29,7 +29,7 @@ #endif /** a parity check vector which certificate the period of 2^{MEXP} */ -static const DWORD parity[4] = { PARITY1, PARITY2, PARITY3, PARITY4 }; +static const uint32_t parity[4] = { PARITY1, PARITY2, PARITY3, PARITY4 }; /*---------------- STATIC FUNCTIONS @@ -37,8 +37,8 @@ STATIC FUNCTIONS inline static int idxof(int i); inline static void rshift128(w128_t *out, w128_t const *in, int shift); inline static void lshift128(w128_t *out, w128_t const *in, int shift); -inline static DWORD func1(DWORD x); -inline static DWORD func2(DWORD x); +inline static uint32_t func1(uint32_t x); +inline static uint32_t func2(uint32_t x); #if defined(BIG_ENDIAN64) && !defined(ONLY64) inline static void swap(w128_t *array, int size); #endif @@ -89,10 +89,10 @@ inline static void rshift128(w128_t *out, w128_t const *in, int shift) { oh = th >> (shift * 8); ol = tl >> (shift * 8); ol |= th << (64 - shift * 8); - out->u[0] = (DWORD)(ol >> 32); - out->u[1] = (DWORD)ol; - out->u[2] = (DWORD)(oh >> 32); - out->u[3] = (DWORD)oh; + out->u[0] = (uint32_t)(ol >> 32); + out->u[1] = (uint32_t)ol; + out->u[2] = (uint32_t)(oh >> 32); + out->u[3] = (uint32_t)oh; } #else inline static void rshift128(w128_t *out, w128_t const *in, int shift) { @@ -104,10 +104,10 @@ inline static void rshift128(w128_t *out, w128_t const *in, int shift) { oh = th >> (shift * 8); ol = tl >> (shift * 8); ol |= th << (64 - shift * 8); - out->u[1] = (DWORD)(ol >> 32); - out->u[0] = (DWORD)ol; - out->u[3] = (DWORD)(oh >> 32); - out->u[2] = (DWORD)oh; + out->u[1] = (uint32_t)(ol >> 32); + out->u[0] = (uint32_t)ol; + out->u[3] = (uint32_t)(oh >> 32); + out->u[2] = (uint32_t)oh; } #endif /** @@ -128,10 +128,10 @@ inline static void lshift128(w128_t *out, w128_t const *in, int shift) { oh = th << (shift * 8); ol = tl << (shift * 8); oh |= tl >> (64 - shift * 8); - out->u[0] = (DWORD)(ol >> 32); - out->u[1] = (DWORD)ol; - out->u[2] = (DWORD)(oh >> 32); - out->u[3] = (DWORD)oh; + out->u[0] = (uint32_t)(ol >> 32); + out->u[1] = (uint32_t)ol; + out->u[2] = (uint32_t)(oh >> 32); + out->u[3] = (uint32_t)oh; } #else inline static void lshift128(w128_t *out, w128_t const *in, int shift) { @@ -143,10 +143,10 @@ inline static void lshift128(w128_t *out, w128_t const *in, int shift) { oh = th << (shift * 8); ol = tl << (shift * 8); oh |= tl >> (64 - shift * 8); - out->u[1] = (DWORD)(ol >> 32); - out->u[0] = (DWORD)ol; - out->u[3] = (DWORD)(oh >> 32); - out->u[2] = (DWORD)oh; + out->u[1] = (uint32_t)(ol >> 32); + out->u[0] = (uint32_t)ol; + out->u[3] = (uint32_t)(oh >> 32); + out->u[2] = (uint32_t)oh; } #endif @@ -264,7 +264,7 @@ void FRandom::GenRandArray(w128_t *array, int size) #if defined(BIG_ENDIAN64) && !defined(ONLY64) && !defined(HAVE_ALTIVEC) inline static void swap(w128_t *array, int size) { int i; - DWORD x, y; + uint32_t x, y; for (i = 0; i < size; i++) { x = array[i].u[0]; @@ -282,9 +282,9 @@ inline static void swap(w128_t *array, int size) { * @param x 32-bit integer * @return 32-bit integer */ -static DWORD func1(DWORD x) +static uint32_t func1(uint32_t x) { - return (x ^ (x >> 27)) * (DWORD)1664525UL; + return (x ^ (x >> 27)) * (uint32_t)1664525UL; } /** @@ -293,9 +293,9 @@ static DWORD func1(DWORD x) * @param x 32-bit integer * @return 32-bit integer */ -static DWORD func2(DWORD x) +static uint32_t func2(uint32_t x) { - return (x ^ (x >> 27)) * (DWORD)1566083941UL; + return (x ^ (x >> 27)) * (uint32_t)1566083941UL; } /** @@ -305,7 +305,7 @@ void FRandom::PeriodCertification() { int inner = 0; int i, j; - DWORD work; + uint32_t work; for (i = 0; i < 4; i++) inner ^= sfmt.u[idxof(i)] & parity[i]; @@ -360,7 +360,7 @@ int FRandom::GetMinArraySize64() */ unsigned int FRandom::GenRand32() { - DWORD r; + uint32_t r; assert(initialized); if (idx >= SFMT::N32) @@ -382,7 +382,7 @@ unsigned int FRandom::GenRand32() QWORD FRandom::GenRand64() { #if defined(BIG_ENDIAN64) && !defined(ONLY64) - DWORD r1, r2; + uint32_t r1, r2; #else QWORD r; #endif @@ -433,7 +433,7 @@ QWORD FRandom::GenRand64() * memory. Mac OSX doesn't have these functions, but \b malloc of OSX * returns the pointer to the aligned memory block. */ -void FRandom::FillArray32(DWORD *array, int size) +void FRandom::FillArray32(uint32_t *array, int size) { assert(initialized); assert(idx == SFMT::N32); @@ -491,7 +491,7 @@ void FRandom::FillArray64(QWORD *array, int size) * * @param seed a 32-bit integer used as the seed. */ -void FRandom::InitGenRand(DWORD seed) +void FRandom::InitGenRand(uint32_t seed) { int i; @@ -515,10 +515,10 @@ void FRandom::InitGenRand(DWORD seed) * @param init_key the array of 32-bit integers, used as a seed. * @param key_length the length of init_key. */ -void FRandom::InitByArray(DWORD *init_key, int key_length) +void FRandom::InitByArray(uint32_t *init_key, int key_length) { int i, j, count; - DWORD r; + uint32_t r; int lag; int mid; int size = SFMT::N * 4; diff --git a/src/sfmt/SFMT.h b/src/sfmt/SFMT.h index 8fde00741..72c990186 100644 --- a/src/sfmt/SFMT.h +++ b/src/sfmt/SFMT.h @@ -67,7 +67,7 @@ /** 128-bit data structure */ union w128_t { vector unsigned int s; - DWORD u[4]; + uint32_t u[4]; QWORD u64[2]; }; @@ -77,7 +77,7 @@ union w128_t { /** 128-bit data structure */ union w128_t { __m128i si; - DWORD u[4]; + uint32_t u[4]; QWORD u64[2]; }; @@ -85,7 +85,7 @@ union w128_t { /** 128-bit data structure */ union w128_t { - DWORD u[4]; + uint32_t u[4]; QWORD u64[2]; }; diff --git a/src/sound/fmodsound.cpp b/src/sound/fmodsound.cpp index cb4fac2cc..db9f88887 100644 --- a/src/sound/fmodsound.cpp +++ b/src/sound/fmodsound.cpp @@ -64,6 +64,7 @@ extern HWND Window; #include "cmdlib.h" #include "s_sound.h" #include "files.h" +#include "i_musicinterns.h" #if FMOD_VERSION > 0x42899 && FMOD_VERSION < 0x43400 #error You are trying to compile with an unsupported version of FMOD. @@ -3478,6 +3479,11 @@ FMOD_RESULT FMODSoundRenderer::SetSystemReverbProperties(const REVERB_PROPERTIES #endif } +MIDIDevice* FMODSoundRenderer::CreateMIDIDevice() const +{ + return new SndSysMIDIDevice; +} + #endif // NO_FMOD diff --git a/src/sound/fmodsound.h b/src/sound/fmodsound.h index e85a993c5..34fdeb7ad 100644 --- a/src/sound/fmodsound.h +++ b/src/sound/fmodsound.h @@ -68,6 +68,8 @@ public: void DrawWaveDebug(int mode); + virtual MIDIDevice* CreateMIDIDevice() const override; + private: DWORD ActiveFMODVersion; int SFXPaused; diff --git a/src/sound/i_music.cpp b/src/sound/i_music.cpp index a896aeee7..69a27a55c 100644 --- a/src/sound/i_music.cpp +++ b/src/sound/i_music.cpp @@ -602,7 +602,7 @@ static bool ungzip(BYTE *data, int complen, TArray &newdata) // Find start of compressed data stream if (flags & GZIP_FEXTRA) { - compstart += 2 + LittleShort(*(WORD *)(data + 10)); + compstart += 2 + LittleShort(*(uint16_t *)(data + 10)); } if (flags & GZIP_FNAME) { diff --git a/src/sound/i_musicinterns.h b/src/sound/i_musicinterns.h index a86429e97..c6bf2c98c 100644 --- a/src/sound/i_musicinterns.h +++ b/src/sound/i_musicinterns.h @@ -16,6 +16,9 @@ #define FALSE 0 #define TRUE 1 #endif +#ifdef __APPLE__ +#include +#endif // __APPLE__ #include "tempfiles.h" #include "oplsynth/opl_mus_player.h" #include "c_cvars.h" @@ -97,7 +100,7 @@ public: virtual bool FakeVolume(); virtual bool Pause(bool paused) = 0; virtual bool NeedThreadedCallback(); - virtual void PrecacheInstruments(const WORD *instruments, int count); + virtual void PrecacheInstruments(const uint16_t *instruments, int count); virtual void TimidityVolumeChanged(); virtual void FluidSettingInt(const char *setting, int value); virtual void FluidSettingNum(const char *setting, double value); @@ -130,7 +133,7 @@ public: bool FakeVolume(); bool NeedThreadedCallback(); bool Pause(bool paused); - void PrecacheInstruments(const WORD *instruments, int count); + void PrecacheInstruments(const uint16_t *instruments, int count); protected: static void CALLBACK CallbackFunc(HMIDIOUT, UINT, DWORD_PTR, DWORD, DWORD); @@ -145,6 +148,44 @@ protected: }; #endif +// AudioToolbox implementation of a MIDI output device ---------------------- + +#ifdef __APPLE__ + +class AudioToolboxMIDIDevice : public MIDIDevice +{ +public: + virtual int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userData) override; + virtual void Close() override; + virtual bool IsOpen() const override; + virtual int GetTechnology() const override; + virtual int SetTempo(int tempo) override; + virtual int SetTimeDiv(int timediv) override; + virtual int StreamOut(MIDIHDR *data) override; + virtual int StreamOutSync(MIDIHDR *data) override; + virtual int Resume() override; + virtual void Stop() override; + virtual int PrepareHeader(MIDIHDR* data) override; + virtual bool FakeVolume() override { return true; } + virtual bool Pause(bool paused) override; + virtual bool Preprocess(MIDIStreamer *song, bool looping) override; + +private: + MusicPlayer m_player = nullptr; + MusicSequence m_sequence = nullptr; + AudioUnit m_audioUnit = nullptr; + CFRunLoopTimerRef m_timer = nullptr; + MusicTimeStamp m_length = 0; + + typedef void (*Callback)(unsigned int, void *, DWORD, DWORD); + Callback m_callback = nullptr; + void* m_userData = nullptr; + + static void TimerCallback(CFRunLoopTimerRef timer, void* info); +}; + +#endif // __APPLE__ + // Base class for pseudo-MIDI devices --------------------------------------- class PseudoMIDIDevice : public MIDIDevice @@ -307,7 +348,7 @@ public: ~TimidityMIDIDevice(); int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata); - void PrecacheInstruments(const WORD *instruments, int count); + void PrecacheInstruments(const uint16_t *instruments, int count); FString GetStats(); protected: @@ -341,7 +382,7 @@ public: ~WildMIDIDevice(); int Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userdata); - void PrecacheInstruments(const WORD *instruments, int count); + void PrecacheInstruments(const uint16_t *instruments, int count); FString GetStats(); protected: @@ -577,7 +618,7 @@ protected: TrackInfo *TrackDue; int NumTracks; int Format; - WORD DesignationMask; + uint16_t DesignationMask; }; // HMI file played with a MIDI stream --------------------------------------- diff --git a/src/sound/i_sound.cpp b/src/sound/i_sound.cpp index d7788ae7a..ecca194e6 100644 --- a/src/sound/i_sound.cpp +++ b/src/sound/i_sound.cpp @@ -250,6 +250,11 @@ public: { return "Null sound module has no stats."; } + + virtual MIDIDevice* CreateMIDIDevice() const override + { + return nullptr; + } }; void I_InitSound () diff --git a/src/sound/i_sound.h b/src/sound/i_sound.h index 4e565e885..db97c3555 100644 --- a/src/sound/i_sound.h +++ b/src/sound/i_sound.h @@ -85,6 +85,7 @@ public: typedef bool (*SoundStreamCallback)(SoundStream *stream, void *buff, int len, void *userdata); struct SoundDecoder; +class MIDIDevice; class SoundRenderer { @@ -157,6 +158,8 @@ public: virtual void DrawWaveDebug(int mode); + virtual MIDIDevice* CreateMIDIDevice() const = 0; + protected: virtual SoundDecoder *CreateDecoder(FileReader *reader); }; diff --git a/src/sound/i_soundinternal.h b/src/sound/i_soundinternal.h index c86c6cdaa..786ff5dca 100644 --- a/src/sound/i_soundinternal.h +++ b/src/sound/i_soundinternal.h @@ -60,7 +60,7 @@ struct ReverbContainer { ReverbContainer *Next; const char *Name; - WORD ID; + uint16_t ID; bool Builtin; bool Modified; REVERB_PROPERTIES Properties; diff --git a/src/sound/music_audiotoolbox_mididevice.cpp b/src/sound/music_audiotoolbox_mididevice.cpp new file mode 100644 index 000000000..3dc57fdb0 --- /dev/null +++ b/src/sound/music_audiotoolbox_mididevice.cpp @@ -0,0 +1,292 @@ +// +//--------------------------------------------------------------------------- +// +// MIDI device for Apple's macOS using AudioToolbox framework +// Copyright(C) 2017 Alexey Lysiuk +// All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see http://www.gnu.org/licenses/ +// +//-------------------------------------------------------------------------- +// + +// Implementation is loosely based on macOS native MIDI support from SDL_mixer + +#ifdef __APPLE__ + +#include "i_musicinterns.h" +#include "templates.h" + +#define AT_MIDI_CHECK_ERROR(CALL,...) \ +{ \ + const OSStatus result = CALL; \ + if (noErr != result) \ + { \ + DPrintf(DMSG_ERROR, \ + "Failed with error 0x%08X at " __FILE__ ":%d:\n> %s", \ + result, __LINE__, #CALL); \ + return __VA_ARGS__; \ + } \ +} + +int AudioToolboxMIDIDevice::Open(void (*callback)(unsigned int, void *, DWORD, DWORD), void *userData) +{ + AT_MIDI_CHECK_ERROR(NewMusicPlayer(&m_player), false); + AT_MIDI_CHECK_ERROR(NewMusicSequence(&m_sequence), false); + AT_MIDI_CHECK_ERROR(MusicPlayerSetSequence(m_player, m_sequence), false); + + CFRunLoopTimerContext context = { 0, this, nullptr, nullptr, nullptr }; + m_timer = CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent(), 0.1, 0, 0, TimerCallback, &context); + + if (nullptr == m_timer) + { + DPrintf(DMSG_ERROR, "Failed with create timer for MIDI playback"); + return 1; + } + + CFRunLoopAddTimer(CFRunLoopGetMain(), m_timer, kCFRunLoopDefaultMode); + + m_callback = callback; + m_userData = userData; + + return 0; +} + +void AudioToolboxMIDIDevice::Close() +{ + m_length = 0; + m_audioUnit = nullptr; + + m_callback = nullptr; + m_userData = nullptr; + + if (nullptr != m_timer) + { + CFRunLoopRemoveTimer(CFRunLoopGetMain(), m_timer, kCFRunLoopDefaultMode); + + CFRelease(m_timer); + m_timer = nullptr; + } + + if (nullptr != m_sequence) + { + DisposeMusicSequence(m_sequence); + m_sequence = nullptr; + } + + if (nullptr != m_player) + { + DisposeMusicPlayer(m_player); + m_player = nullptr; + } +} + +bool AudioToolboxMIDIDevice::IsOpen() const +{ + return nullptr != m_player + && nullptr != m_sequence + && nullptr != m_timer; +} + +int AudioToolboxMIDIDevice::GetTechnology() const +{ + return MOD_SWSYNTH; +} + +int AudioToolboxMIDIDevice::SetTempo(int tempo) +{ + return 0; +} + +int AudioToolboxMIDIDevice::SetTimeDiv(int timediv) +{ + return 0; +} + +int AudioToolboxMIDIDevice::StreamOut(MIDIHDR* data) +{ + return 0; +} + +int AudioToolboxMIDIDevice::StreamOutSync(MIDIHDR* data) +{ + return 0; +} + +int AudioToolboxMIDIDevice::Resume() +{ + AT_MIDI_CHECK_ERROR(MusicPlayerSetTime(m_player, 0), false); + AT_MIDI_CHECK_ERROR(MusicPlayerPreroll(m_player), false); + + if (nullptr == m_audioUnit) + { + AUGraph graph; + AT_MIDI_CHECK_ERROR(MusicSequenceGetAUGraph(m_sequence, &graph), false); + + UInt32 nodecount; + AT_MIDI_CHECK_ERROR(AUGraphGetNodeCount(graph, &nodecount), false); + + for (UInt32 i = 0; i < nodecount; ++i) + { + AUNode node; + AT_MIDI_CHECK_ERROR(AUGraphGetIndNode(graph, i, &node), false); + + AudioComponentDescription desc = {}; + AudioUnit audioUnit = nullptr; + AT_MIDI_CHECK_ERROR(AUGraphNodeInfo(graph, node, &desc, &audioUnit), false); + + if ( kAudioUnitType_Output != desc.componentType + || kAudioUnitSubType_DefaultOutput != desc.componentSubType) + { + continue; + } + + const float volume = clamp(snd_musicvolume * relative_volume, 0.f, 1.f); + AT_MIDI_CHECK_ERROR(AudioUnitSetParameter(audioUnit, kHALOutputParam_Volume, kAudioUnitScope_Global, 0, volume, 0), false); + + m_audioUnit = audioUnit; + break; + } + } + + AT_MIDI_CHECK_ERROR(MusicPlayerStart(m_player), false); + + return 0; +} + +void AudioToolboxMIDIDevice::Stop() +{ + AT_MIDI_CHECK_ERROR(MusicPlayerStop(m_player)); +} + +int AudioToolboxMIDIDevice::PrepareHeader(MIDIHDR* data) +{ + MIDIHDR* events = data; + DWORD position = 0; + + while (nullptr != events) + { + DWORD* const event = reinterpret_cast(events->lpData + position); + const DWORD message = event[2]; + + if (0 == MEVT_EVENTTYPE(message)) + { + static const DWORD VOLUME_CHANGE_EVENT = 7; + + const DWORD status = message & 0xFF; + const DWORD param1 = (message >> 8) & 0x7F; + const DWORD param2 = (message >> 16) & 0x7F; + + if (nullptr != m_audioUnit && MIDI_CTRLCHANGE == status && VOLUME_CHANGE_EVENT == param1) + { + AT_MIDI_CHECK_ERROR(AudioUnitSetParameter(m_audioUnit, kHALOutputParam_Volume, kAudioUnitScope_Global, 0, param2 / 100.f, 0), false); + } + } + + // Advance to next event + position += 12 + ( (message < 0x80000000) + ? 0 + : ((MEVT_EVENTPARM(message) + 3) & ~3) ); + + // Did we use up this buffer? + if (position >= events->dwBytesRecorded) + { + events = events->lpNext; + position = 0; + } + + if (nullptr == events) + { + break; + } + } + + return 0; +} + +bool AudioToolboxMIDIDevice::Pause(bool paused) +{ + return false; +} + +static MusicTimeStamp GetSequenceLength(MusicSequence sequence) +{ + UInt32 trackCount; + AT_MIDI_CHECK_ERROR(MusicSequenceGetTrackCount(sequence, &trackCount), 0); + + MusicTimeStamp result = 0; + + for (UInt32 i = 0; i < trackCount; ++i) + { + MusicTrack track; + AT_MIDI_CHECK_ERROR(MusicSequenceGetIndTrack(sequence, i, &track), 0); + + MusicTimeStamp trackLength = 0; + UInt32 trackLengthSize = sizeof trackLength; + + AT_MIDI_CHECK_ERROR(MusicTrackGetProperty(track, kSequenceTrackProperty_TrackLength, &trackLength, &trackLengthSize), 0); + + if (result < trackLength) + { + result = trackLength; + } + } + + return result; +} + +bool AudioToolboxMIDIDevice::Preprocess(MIDIStreamer* song, bool looping) +{ + assert(nullptr != song); + + TArray midi; + song->CreateSMF(midi, looping ? 0 : 1); + + CFDataRef data = CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, &midi[0], midi.Size(), kCFAllocatorNull); + if (nullptr == data) + { + DPrintf(DMSG_ERROR, "Failed with create CFDataRef for MIDI song"); + return false; + } + + AT_MIDI_CHECK_ERROR(MusicSequenceFileLoadData(m_sequence, data, kMusicSequenceFile_MIDIType, 0), CFRelease(data), false); + + CFRelease(data); + + m_length = GetSequenceLength(m_sequence); + + return true; +} + +void AudioToolboxMIDIDevice::TimerCallback(CFRunLoopTimerRef timer, void* info) +{ + AudioToolboxMIDIDevice* const self = static_cast(info); + + if (nullptr != self->m_callback) + { + self->m_callback(MOM_DONE, self->m_userData, 0, 0); + } + + MusicTimeStamp currentTime = 0; + AT_MIDI_CHECK_ERROR(MusicPlayerGetTime(self->m_player, ¤tTime)); + + if (currentTime > self->m_length) + { + MusicPlayerSetTime(self->m_player, 0); + } +} + +#undef AT_MIDI_CHECK_ERROR + +#endif // __APPLE__ diff --git a/src/sound/music_cd.cpp b/src/sound/music_cd.cpp index 4aaf46e52..17b050f8b 100644 --- a/src/sound/music_cd.cpp +++ b/src/sound/music_cd.cpp @@ -82,9 +82,9 @@ bool CDSong::IsPlaying () CDDAFile::CDDAFile (FileReader &reader) : CDSong () { - DWORD chunk; - WORD track; - DWORD discid; + uint32_t chunk; + uint16_t track; + uint32_t discid; long endpos = reader.Tell() + reader.GetLength() - 8; // I_RegisterSong already identified this as a CDDA file, so we diff --git a/src/sound/music_dumb.cpp b/src/sound/music_dumb.cpp index fe1fbbb76..3c48dac7b 100644 --- a/src/sound/music_dumb.cpp +++ b/src/sound/music_dumb.cpp @@ -80,26 +80,26 @@ typedef struct tagITFILEHEADER { DWORD id; // 0x4D504D49 char songname[26]; - WORD reserved1; // 0x1004 - WORD ordnum; - WORD insnum; - WORD smpnum; - WORD patnum; - WORD cwtv; - WORD cmwt; - WORD flags; - WORD special; - BYTE globalvol; - BYTE mv; - BYTE speed; - BYTE tempo; - BYTE sep; - BYTE zero; - WORD msglength; + uint16_t reserved1; // 0x1004 + uint16_t ordnum; + uint16_t insnum; + uint16_t smpnum; + uint16_t patnum; + uint16_t cwtv; + uint16_t cmwt; + uint16_t flags; + uint16_t special; + uint8_t globalvol; + uint8_t mv; + uint8_t speed; + uint8_t tempo; + uint8_t sep; + uint8_t zero; + uint16_t msglength; DWORD msgoffset; DWORD reserved2; - BYTE chnpan[64]; - BYTE chnvol[64]; + uint8_t chnpan[64]; + uint8_t chnvol[64]; } FORCE_PACKED ITFILEHEADER, *PITFILEHEADER; typedef struct MODMIDICFG @@ -242,7 +242,7 @@ static void ReadDUH(DUH * duh, input_mod *info, bool meta, bool dos) // //========================================================================== -static bool ReadIT(const BYTE * ptr, unsigned size, input_mod *info, bool meta) +static bool ReadIT(const uint8_t * ptr, unsigned size, input_mod *info, bool meta) { PITFILEHEADER pifh = (PITFILEHEADER) ptr; if ((!ptr) || (size < 0x100)) return false; @@ -327,7 +327,7 @@ static bool ReadIT(const BYTE * ptr, unsigned size, input_mod *info, bool meta) if (pos < size) { - WORD val16 = LittleShort( *(WORD *)(ptr + pos) ); + uint16_t val16 = LittleShort( *(uint16_t *)(ptr + pos) ); pos += 2; if (pos + val16 * 8 < size) pos += val16 * 8; } @@ -395,24 +395,24 @@ static bool ReadIT(const BYTE * ptr, unsigned size, input_mod *info, bool meta) offset = (DWORD *)(ptr + 0xC0 + LittleShort(pifh->ordnum) + LittleShort(pifh->insnum) * 4 + LittleShort(pifh->smpnum) * 4); - BYTE chnmask[64]; + uint8_t chnmask[64]; for (n = 0, l = LittleShort(pifh->patnum); n < l; n++) { memset(chnmask, 0, sizeof(chnmask)); DWORD offset_n = LittleLong( offset[n] ); if ((!offset_n) || (offset_n + 4 >= size)) continue; - unsigned len = LittleShort(*(WORD *)(ptr + offset_n)); - unsigned rows = LittleShort(*(WORD *)(ptr + offset_n + 2)); + unsigned len = LittleShort(*(uint16_t *)(ptr + offset_n)); + unsigned rows = LittleShort(*(uint16_t *)(ptr + offset_n + 2)); if ((rows < 4) || (rows > 256)) continue; if (offset_n + 8 + len > size) continue; unsigned i = 0; - const BYTE * p = ptr + offset_n + 8; + const uint8_t * p = ptr + offset_n + 8; unsigned nrow = 0; while (nrow < rows) { if (i >= len) break; - BYTE b = p[i++]; + uint8_t b = p[i++]; if (!b) { nrow++; @@ -464,7 +464,7 @@ static bool ReadIT(const BYTE * ptr, unsigned size, input_mod *info, bool meta) typedef struct tdumbfile_mem_status { - const BYTE *ptr; + const uint8_t *ptr; unsigned int offset, size; } dumbfile_mem_status; @@ -537,15 +537,15 @@ static DUMBFILE_SYSTEM mem_dfs = { // //========================================================================== -DUMBFILE *dumb_read_allfile(dumbfile_mem_status *filestate, BYTE *start, FileReader &reader, int lenhave, int lenfull) +DUMBFILE *dumb_read_allfile(dumbfile_mem_status *filestate, uint8_t *start, FileReader &reader, int lenhave, int lenfull) { filestate->size = lenfull; filestate->offset = 0; if (lenhave >= lenfull) - filestate->ptr = (BYTE *)start; + filestate->ptr = (uint8_t *)start; else { - BYTE *mem = new BYTE[lenfull]; + uint8_t *mem = new uint8_t[lenfull]; memcpy(mem, start, lenhave); if (reader.Read(mem + lenhave, lenfull - lenhave) != (lenfull - lenhave)) { @@ -758,7 +758,7 @@ MusInfo *MOD_OpenSong(FileReader &reader) int headsize; union { - BYTE start[64]; + uint8_t start[64]; DWORD dstart[64/4]; }; dumbfile_mem_status filestate; @@ -891,7 +891,7 @@ MusInfo *MOD_OpenSong(FileReader &reader) if ( ! duh ) { is_dos = false; - if (filestate.ptr == (BYTE *)start) + if (filestate.ptr == (uint8_t *)start) { if (!(f = dumb_read_allfile(&filestate, start, reader, headsize, size))) { @@ -938,9 +938,9 @@ MusInfo *MOD_OpenSong(FileReader &reader) // Reposition file pointer for other codecs to do their checks. reader.Seek(fpos, SEEK_SET); } - if (filestate.ptr != (BYTE *)start) + if (filestate.ptr != (uint8_t *)start) { - delete[] const_cast(filestate.ptr); + delete[] const_cast(filestate.ptr); } return state; } @@ -982,7 +982,7 @@ bool input_mod::read(SoundStream *stream, void *buffer, int sizebytes, void *use ((float *)buffer)[i] = (((int *)buffer)[i] / (float)(1 << 24)) * mod_dumb_mastervolume; } } - buffer = (BYTE *)buffer + written * 8; + buffer = (uint8_t *)buffer + written * 8; sizebytes -= written * 8; } state->crit_sec.Leave(); diff --git a/src/sound/music_hmi_midiout.cpp b/src/sound/music_hmi_midiout.cpp index 691970765..5197cd308 100644 --- a/src/sound/music_hmi_midiout.cpp +++ b/src/sound/music_hmi_midiout.cpp @@ -94,7 +94,7 @@ struct HMISong::TrackInfo size_t MaxTrackP; DWORD Delay; DWORD PlayedTime; - WORD Designation[NUM_HMI_DESIGNATIONS]; + uint16_t Designation[NUM_HMI_DESIGNATIONS]; bool Enabled; bool Finished; BYTE RunningStatus; diff --git a/src/sound/music_midi_base.cpp b/src/sound/music_midi_base.cpp index 8c44a2ac4..3ad8fafc2 100644 --- a/src/sound/music_midi_base.cpp +++ b/src/sound/music_midi_base.cpp @@ -130,7 +130,7 @@ void I_BuildMIDIMenuList (FOptionValues *opt) } } -static void PrintMidiDevice (int id, const char *name, WORD tech, DWORD support) +static void PrintMidiDevice (int id, const char *name, uint16_t tech, DWORD support) { if (id == snd_mididevice) { diff --git a/src/sound/music_midistream.cpp b/src/sound/music_midistream.cpp index 7cbffc7ad..0f7501f79 100644 --- a/src/sound/music_midistream.cpp +++ b/src/sound/music_midistream.cpp @@ -273,7 +273,7 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype) const #endif case MDEV_SNDSYS: - return new SndSysMIDIDevice; + return GSnd->CreateMIDIDevice(); case MDEV_GUS: return new TimidityMIDIDevice(Args); @@ -1131,13 +1131,13 @@ void MIDIStreamer::Precache() DoRestart(); // Now pack everything into a contiguous region for the PrecacheInstruments call(). - TArray packed; + TArray packed; for (int i = 0; i < 256; ++i) { if (found_instruments[i]) { - WORD packnum = (i & 127) | ((i & 128) << 7); + uint16_t packnum = (i & 127) | ((i & 128) << 7); if (!multiple_banks) { packed.Push(packnum); @@ -1429,7 +1429,7 @@ MIDIDevice::~MIDIDevice() // //========================================================================== -void MIDIDevice::PrecacheInstruments(const WORD *instruments, int count) +void MIDIDevice::PrecacheInstruments(const uint16_t *instruments, int count) { } diff --git a/src/sound/music_mus_midiout.cpp b/src/sound/music_mus_midiout.cpp index 58b86201a..420c1dfcd 100644 --- a/src/sound/music_mus_midiout.cpp +++ b/src/sound/music_mus_midiout.cpp @@ -211,14 +211,14 @@ bool MUSSong2::CheckDone() void MUSSong2::Precache() { - TArray work(LittleShort(MusHeader->NumInstruments)); + TArray work(LittleShort(MusHeader->NumInstruments)); const BYTE *used = (BYTE *)MusHeader + sizeof(MUSHeader) / sizeof(BYTE); int i, k; for (i = k = 0; i < LittleShort(MusHeader->NumInstruments); ++i) { BYTE instr = used[k++]; - WORD val; + uint16_t val; if (instr < 128) { val = instr; diff --git a/src/sound/music_smf_midiout.cpp b/src/sound/music_smf_midiout.cpp index ae0c47e80..623cef53e 100644 --- a/src/sound/music_smf_midiout.cpp +++ b/src/sound/music_smf_midiout.cpp @@ -67,7 +67,7 @@ struct MIDISong2::TrackInfo bool Designated; bool EProgramChange; bool EVolume; - WORD Designation; + uint16_t Designation; size_t LoopBegin; DWORD LoopDelay; diff --git a/src/sound/music_timidity_mididevice.cpp b/src/sound/music_timidity_mididevice.cpp index df87a9298..401c34af7 100644 --- a/src/sound/music_timidity_mididevice.cpp +++ b/src/sound/music_timidity_mididevice.cpp @@ -51,18 +51,18 @@ struct FmtChunk { DWORD ChunkID; DWORD ChunkLen; - WORD FormatTag; - WORD Channels; + uint16_t FormatTag; + uint16_t Channels; DWORD SamplesPerSec; DWORD AvgBytesPerSec; - WORD BlockAlign; - WORD BitsPerSample; - WORD ExtensionSize; - WORD ValidBitsPerSample; + uint16_t BlockAlign; + uint16_t BitsPerSample; + uint16_t ExtensionSize; + uint16_t ValidBitsPerSample; DWORD ChannelMask; DWORD SubFormatA; - WORD SubFormatB; - WORD SubFormatC; + uint16_t SubFormatB; + uint16_t SubFormatC; BYTE SubFormatD[8]; }; @@ -136,7 +136,7 @@ int TimidityMIDIDevice::Open(void (*callback)(unsigned int, void *, DWORD, DWORD // //========================================================================== -void TimidityMIDIDevice::PrecacheInstruments(const WORD *instruments, int count) +void TimidityMIDIDevice::PrecacheInstruments(const uint16_t *instruments, int count) { for (int i = 0; i < count; ++i) { diff --git a/src/sound/music_wildmidi_mididevice.cpp b/src/sound/music_wildmidi_mididevice.cpp index 03ededb46..c664dc623 100644 --- a/src/sound/music_wildmidi_mididevice.cpp +++ b/src/sound/music_wildmidi_mididevice.cpp @@ -167,7 +167,7 @@ int WildMIDIDevice::Open(void (*callback)(unsigned int, void *, DWORD, DWORD), v // //========================================================================== -void WildMIDIDevice::PrecacheInstruments(const WORD *instruments, int count) +void WildMIDIDevice::PrecacheInstruments(const uint16_t *instruments, int count) { for (int i = 0; i < count; ++i) { diff --git a/src/sound/music_win_mididevice.cpp b/src/sound/music_win_mididevice.cpp index ed00b0c87..b025d70f0 100644 --- a/src/sound/music_win_mididevice.cpp +++ b/src/sound/music_win_mididevice.cpp @@ -239,7 +239,7 @@ void WinMIDIDevice::Stop() // //========================================================================== -void WinMIDIDevice::PrecacheInstruments(const WORD *instruments, int count) +void WinMIDIDevice::PrecacheInstruments(const uint16_t *instruments, int count) { // Setting snd_midiprecache to false disables this precaching, since it // does involve sleeping for more than a miniscule amount of time. diff --git a/src/sound/oalsound.cpp b/src/sound/oalsound.cpp index 601ec7200..6bd2dc091 100644 --- a/src/sound/oalsound.cpp +++ b/src/sound/oalsound.cpp @@ -2052,6 +2052,18 @@ void OpenALSoundRenderer::PrintDriversList() } } +MIDIDevice* OpenALSoundRenderer::CreateMIDIDevice() const +{ +#ifdef _WIN32 + extern UINT mididevice; + return new WinMIDIDevice(mididevice); +#elif defined __APPLE__ + return new AudioToolboxMIDIDevice; +#else + return new OPLMIDIDevice(nullptr); +#endif +} + void OpenALSoundRenderer::PurgeStoppedSources() { // Release channels that are stopped diff --git a/src/sound/oalsound.h b/src/sound/oalsound.h index d69e2e367..3e110bde0 100644 --- a/src/sound/oalsound.h +++ b/src/sound/oalsound.h @@ -131,6 +131,8 @@ public: virtual void PrintDriversList(); virtual FString GatherStats(); + virtual MIDIDevice* CreateMIDIDevice() const override; + private: struct { bool EXT_EFX; @@ -219,8 +221,8 @@ private: const ReverbContainer *PrevEnvironment; - typedef TMap EffectMap; - typedef TMapIterator EffectMapIter; + typedef TMap EffectMap; + typedef TMapIterator EffectMapIter; ALuint EnvSlot; ALuint EnvFilters[2]; EffectMap EnvEffects; diff --git a/src/st_stuff.cpp b/src/st_stuff.cpp index 632eaadf8..ea3de557b 100644 --- a/src/st_stuff.cpp +++ b/src/st_stuff.cpp @@ -38,16 +38,16 @@ EXTERN_CVAR (Int, am_cheat); struct cheatseq_t { - BYTE *Sequence; - BYTE *Pos; - BYTE DontCheck; - BYTE CurrentArg; - BYTE Args[2]; + uint8_t *Sequence; + uint8_t *Pos; + uint8_t DontCheck; + uint8_t CurrentArg; + uint8_t Args[2]; bool (*Handler)(cheatseq_t *); }; static bool CheatCheckList (event_t *ev, cheatseq_t *cheats, int numcheats); -static bool CheatAddKey (cheatseq_t *cheat, BYTE key, bool *eat); +static bool CheatAddKey (cheatseq_t *cheat, uint8_t key, bool *eat); static bool Cht_Generic (cheatseq_t *); static bool Cht_Music (cheatseq_t *); static bool Cht_BeholdMenu (cheatseq_t *); @@ -60,7 +60,7 @@ static bool Cht_MyPos (cheatseq_t *); static bool Cht_Sound (cheatseq_t *); static bool Cht_Ticker (cheatseq_t *); -BYTE CheatPowerup[7][10] = +uint8_t CheatPowerup[7][10] = { { 'i','d','b','e','h','o','l','d','v', 255 }, { 'i','d','b','e','h','o','l','d','s', 255 }, @@ -70,7 +70,7 @@ BYTE CheatPowerup[7][10] = { 'i','d','b','e','h','o','l','d','l', 255 }, { 'i','d','b','e','h','o','l','d', 255 }, }; -BYTE CheatPowerup1[11][7] = +uint8_t CheatPowerup1[11][7] = { { 'g','i','m','m','e','a',255 }, { 'g','i','m','m','e','b',255 }, @@ -84,7 +84,7 @@ BYTE CheatPowerup1[11][7] = { 'g','i','m','m','e','j',255 }, { 'g','i','m','m','e','z',255 }, }; -BYTE CheatPowerup2[8][10] = +uint8_t CheatPowerup2[8][10] = { { 'p','u','m','p','u','p','b',255 }, { 'p','u','m','p','u','p','i',255 }, @@ -97,84 +97,84 @@ BYTE CheatPowerup2[8][10] = }; // Smashing Pumpkins Into Small Piles Of Putrid Debris. -static BYTE CheatNoclip[] = { 'i','d','s','p','i','s','p','o','p','d',255 }; -static BYTE CheatNoclip2[] = { 'i','d','c','l','i','p',255 }; -static BYTE CheatMus[] = { 'i','d','m','u','s',0,0,255 }; -static BYTE CheatChoppers[] = { 'i','d','c','h','o','p','p','e','r','s',255 }; -static BYTE CheatGod[] = { 'i','d','d','q','d',255 }; -static BYTE CheatAmmo[] = { 'i','d','k','f','a',255 }; -static BYTE CheatAmmoNoKey[] = { 'i','d','f','a',255 }; -static BYTE CheatClev[] = { 'i','d','c','l','e','v',0,0,255 }; -static BYTE CheatMypos[] = { 'i','d','m','y','p','o','s',255 }; -static BYTE CheatAmap[] = { 'i','d','d','t',255 }; +static uint8_t CheatNoclip[] = { 'i','d','s','p','i','s','p','o','p','d',255 }; +static uint8_t CheatNoclip2[] = { 'i','d','c','l','i','p',255 }; +static uint8_t CheatMus[] = { 'i','d','m','u','s',0,0,255 }; +static uint8_t CheatChoppers[] = { 'i','d','c','h','o','p','p','e','r','s',255 }; +static uint8_t CheatGod[] = { 'i','d','d','q','d',255 }; +static uint8_t CheatAmmo[] = { 'i','d','k','f','a',255 }; +static uint8_t CheatAmmoNoKey[] = { 'i','d','f','a',255 }; +static uint8_t CheatClev[] = { 'i','d','c','l','e','v',0,0,255 }; +static uint8_t CheatMypos[] = { 'i','d','m','y','p','o','s',255 }; +static uint8_t CheatAmap[] = { 'i','d','d','t',255 }; -static BYTE CheatQuicken[] = { 'q','u','i','c','k','e','n',255 }; -static BYTE CheatKitty[] = { 'k','i','t','t','y',255 }; -static BYTE CheatRambo[] = { 'r','a','m','b','o',255 }; -static BYTE CheatShazam[] = { 's','h','a','z','a','m',255 }; -static BYTE CheatPonce[] = { 'p','o','n','c','e',255 }; -static BYTE CheatSkel[] = { 's','k','e','l',255 }; -static BYTE CheatNoise[] = { 'n','o','i','s','e',255 }; -static BYTE CheatTicker[] = { 't','i','c','k','e','r',255 }; -static BYTE CheatEngage[] = { 'e','n','g','a','g','e',0,0,255 }; -static BYTE CheatChicken[] = { 'c','o','c','k','a','d','o','o','d','l','e','d','o','o',255 }; -static BYTE CheatMassacre[] = { 'm','a','s','s','a','c','r','e',255 }; -static BYTE CheatRavMap[] = { 'r','a','v','m','a','p',255 }; +static uint8_t CheatQuicken[] = { 'q','u','i','c','k','e','n',255 }; +static uint8_t CheatKitty[] = { 'k','i','t','t','y',255 }; +static uint8_t CheatRambo[] = { 'r','a','m','b','o',255 }; +static uint8_t CheatShazam[] = { 's','h','a','z','a','m',255 }; +static uint8_t CheatPonce[] = { 'p','o','n','c','e',255 }; +static uint8_t CheatSkel[] = { 's','k','e','l',255 }; +static uint8_t CheatNoise[] = { 'n','o','i','s','e',255 }; +static uint8_t CheatTicker[] = { 't','i','c','k','e','r',255 }; +static uint8_t CheatEngage[] = { 'e','n','g','a','g','e',0,0,255 }; +static uint8_t CheatChicken[] = { 'c','o','c','k','a','d','o','o','d','l','e','d','o','o',255 }; +static uint8_t CheatMassacre[] = { 'm','a','s','s','a','c','r','e',255 }; +static uint8_t CheatRavMap[] = { 'r','a','v','m','a','p',255 }; -static BYTE CheatSatan[] = { 's','a','t','a','n',255 }; -static BYTE CheatCasper[] = { 'c','a','s','p','e','r',255 }; -static BYTE CheatNRA[] = { 'n','r','a',255 }; -static BYTE CheatClubMed[] = { 'c','l','u','b','m','e','d',255 }; -static BYTE CheatLocksmith[] = { 'l','o','c','k','s','m','i','t','h',255 }; -static BYTE CheatIndiana[] = { 'i','n','d','i','a','n','a',255 }; -static BYTE CheatSherlock[] = { 's','h','e','r','l','o','c','k',255 }; -static BYTE CheatVisit[] = { 'v','i','s','i','t',0,0,255 }; -static BYTE CheatPig[] = { 'd','e','l','i','v','e','r','a','n','c','e',255 }; -static BYTE CheatButcher[] = { 'b','u','t','c','h','e','r',255 }; -static BYTE CheatConan[] = { 'c','o','n','a','n',255 }; -static BYTE CheatMapsco[] = { 'm','a','p','s','c','o',255 }; -static BYTE CheatWhere[] = { 'w','h','e','r','e',255 }; +static uint8_t CheatSatan[] = { 's','a','t','a','n',255 }; +static uint8_t CheatCasper[] = { 'c','a','s','p','e','r',255 }; +static uint8_t CheatNRA[] = { 'n','r','a',255 }; +static uint8_t CheatClubMed[] = { 'c','l','u','b','m','e','d',255 }; +static uint8_t CheatLocksmith[] = { 'l','o','c','k','s','m','i','t','h',255 }; +static uint8_t CheatIndiana[] = { 'i','n','d','i','a','n','a',255 }; +static uint8_t CheatSherlock[] = { 's','h','e','r','l','o','c','k',255 }; +static uint8_t CheatVisit[] = { 'v','i','s','i','t',0,0,255 }; +static uint8_t CheatPig[] = { 'd','e','l','i','v','e','r','a','n','c','e',255 }; +static uint8_t CheatButcher[] = { 'b','u','t','c','h','e','r',255 }; +static uint8_t CheatConan[] = { 'c','o','n','a','n',255 }; +static uint8_t CheatMapsco[] = { 'm','a','p','s','c','o',255 }; +static uint8_t CheatWhere[] = { 'w','h','e','r','e',255 }; #if 0 -static BYTE CheatClass1[] = { 's','h','a','d','o','w','c','a','s','t','e','r',255 }; -static BYTE CheatClass2[] = { 's','h','a','d','o','w','c','a','s','t','e','r',0,255 }; -static BYTE CheatInit[] = { 'i','n','i','t',255 }; -static BYTE CheatScript1[] = { 'p','u','k','e',255 }; -static BYTE CheatScript2[] = { 'p','u','k','e',0,255 }; -static BYTE CheatScript3[] = { 'p','u','k','e',0,0,255 }; +static uint8_t CheatClass1[] = { 's','h','a','d','o','w','c','a','s','t','e','r',255 }; +static uint8_t CheatClass2[] = { 's','h','a','d','o','w','c','a','s','t','e','r',0,255 }; +static uint8_t CheatInit[] = { 'i','n','i','t',255 }; +static uint8_t CheatScript1[] = { 'p','u','k','e',255 }; +static uint8_t CheatScript2[] = { 'p','u','k','e',0,255 }; +static uint8_t CheatScript3[] = { 'p','u','k','e',0,0,255 }; #endif -static BYTE CheatSpin[] = { 's','p','i','n',0,0,255 }; -static BYTE CheatRift[] = { 'r','i','f','t',0,0,255 }; -static BYTE CheatGPS[] = { 'g','p','s',255 }; -static BYTE CheatGripper[] = { 'g','r','i','p','p','e','r',255 }; -static BYTE CheatLego[] = { 'l','e','g','o',255 }; -static BYTE CheatDots[] = { 'd','o','t','s',255 }; -static BYTE CheatScoot[] = { 's','c','o','o','t',0,255 }; -static BYTE CheatDonnyTrump[] = { 'd','o','n','n','y','t','r','u','m','p',255 }; -static BYTE CheatOmnipotent[] = { 'o','m','n','i','p','o','t','e','n','t',255 }; -static BYTE CheatJimmy[] = { 'j','i','m','m','y',255 }; -static BYTE CheatBoomstix[] = { 'b','o','o','m','s','t','i','x',255 }; -static BYTE CheatStoneCold[] = { 's','t','o','n','e','c','o','l','d',255 }; -static BYTE CheatElvis[] = { 'e','l','v','i','s',255 }; -static BYTE CheatTopo[] = { 't','o','p','o',255 }; +static uint8_t CheatSpin[] = { 's','p','i','n',0,0,255 }; +static uint8_t CheatRift[] = { 'r','i','f','t',0,0,255 }; +static uint8_t CheatGPS[] = { 'g','p','s',255 }; +static uint8_t CheatGripper[] = { 'g','r','i','p','p','e','r',255 }; +static uint8_t CheatLego[] = { 'l','e','g','o',255 }; +static uint8_t CheatDots[] = { 'd','o','t','s',255 }; +static uint8_t CheatScoot[] = { 's','c','o','o','t',0,255 }; +static uint8_t CheatDonnyTrump[] = { 'd','o','n','n','y','t','r','u','m','p',255 }; +static uint8_t CheatOmnipotent[] = { 'o','m','n','i','p','o','t','e','n','t',255 }; +static uint8_t CheatJimmy[] = { 'j','i','m','m','y',255 }; +static uint8_t CheatBoomstix[] = { 'b','o','o','m','s','t','i','x',255 }; +static uint8_t CheatStoneCold[] = { 's','t','o','n','e','c','o','l','d',255 }; +static uint8_t CheatElvis[] = { 'e','l','v','i','s',255 }; +static uint8_t CheatTopo[] = { 't','o','p','o',255 }; //[BL] Graf will probably get rid of this -static BYTE CheatJoelKoenigs[] = { 'j','o','e','l','k','o','e','n','i','g','s',255 }; -static BYTE CheatDavidBrus[] = { 'd','a','v','i','d','b','r','u','s',255 }; -static BYTE CheatScottHolman[] = { 's','c','o','t','t','h','o','l','m','a','n',255 }; -static BYTE CheatMikeKoenigs[] = { 'm','i','k','e','k','o','e','n','i','g','s',255 }; -static BYTE CheatCharlesJacobi[] = { 'c','h','a','r','l','e','s','j','a','c','o','b','i',255 }; -static BYTE CheatAndrewBenson[] = { 'a','n','d','r','e','w','b','e','n','s','o','n',255 }; -static BYTE CheatDeanHyers[] = { 'd','e','a','n','h','y','e','r','s',255 }; -static BYTE CheatMaryBregi[] = { 'm','a','r','y','b','r','e','g','i',255 }; -static BYTE CheatAllen[] = { 'a','l','l','e','n',255 }; -static BYTE CheatDigitalCafe[] = { 'd','i','g','i','t','a','l','c','a','f','e',255 }; -static BYTE CheatJoshuaStorms[] = { 'j','o','s','h','u','a','s','t','o','r','m','s',255 }; -static BYTE CheatLeeSnyder[] = { 'l','e','e','s','n','y','d','e','r',0,0,255 }; -static BYTE CheatKimHyers[] = { 'k','i','m','h','y','e','r','s',255 }; -static BYTE CheatShrrill[] = { 's','h','e','r','r','i','l','l',255 }; +static uint8_t CheatJoelKoenigs[] = { 'j','o','e','l','k','o','e','n','i','g','s',255 }; +static uint8_t CheatDavidBrus[] = { 'd','a','v','i','d','b','r','u','s',255 }; +static uint8_t CheatScottHolman[] = { 's','c','o','t','t','h','o','l','m','a','n',255 }; +static uint8_t CheatMikeKoenigs[] = { 'm','i','k','e','k','o','e','n','i','g','s',255 }; +static uint8_t CheatCharlesJacobi[] = { 'c','h','a','r','l','e','s','j','a','c','o','b','i',255 }; +static uint8_t CheatAndrewBenson[] = { 'a','n','d','r','e','w','b','e','n','s','o','n',255 }; +static uint8_t CheatDeanHyers[] = { 'd','e','a','n','h','y','e','r','s',255 }; +static uint8_t CheatMaryBregi[] = { 'm','a','r','y','b','r','e','g','i',255 }; +static uint8_t CheatAllen[] = { 'a','l','l','e','n',255 }; +static uint8_t CheatDigitalCafe[] = { 'd','i','g','i','t','a','l','c','a','f','e',255 }; +static uint8_t CheatJoshuaStorms[] = { 'j','o','s','h','u','a','s','t','o','r','m','s',255 }; +static uint8_t CheatLeeSnyder[] = { 'l','e','e','s','n','y','d','e','r',0,0,255 }; +static uint8_t CheatKimHyers[] = { 'k','i','m','h','y','e','r','s',255 }; +static uint8_t CheatShrrill[] = { 's','h','e','r','r','i','l','l',255 }; -static BYTE CheatTNTem[] = { 't','n','t','e','m',255 }; +static uint8_t CheatTNTem[] = { 't','n','t','e','m',255 }; static cheatseq_t DoomCheats[] = { @@ -364,7 +364,7 @@ static bool CheatCheckList (event_t *ev, cheatseq_t *cheats, int numcheats) for (i = 0; i < numcheats; i++, cheats++) { - if (CheatAddKey (cheats, (BYTE)ev->data2, &eat)) + if (CheatAddKey (cheats, (uint8_t)ev->data2, &eat)) { if (cheats->DontCheck || !CheckCheatmode ()) { @@ -390,7 +390,7 @@ static bool CheatCheckList (event_t *ev, cheatseq_t *cheats, int numcheats) // //-------------------------------------------------------------------------- -static bool CheatAddKey (cheatseq_t *cheat, BYTE key, bool *eat) +static bool CheatAddKey (cheatseq_t *cheat, uint8_t key, bool *eat) { if (cheat->Pos == NULL) { diff --git a/src/stringtable.cpp b/src/stringtable.cpp index cdcb3071a..549af499f 100644 --- a/src/stringtable.cpp +++ b/src/stringtable.cpp @@ -54,7 +54,7 @@ struct FStringTable::StringEntry { StringEntry *Next; char *Name; - BYTE PassNum; + uint8_t PassNum; char String[]; }; @@ -138,13 +138,13 @@ void FStringTable::LoadStrings (bool enuOnly) } } -void FStringTable::LoadLanguage (int lumpnum, DWORD code, bool exactMatch, int passnum) +void FStringTable::LoadLanguage (int lumpnum, uint32_t code, bool exactMatch, int passnum) { static bool errordone = false; - const DWORD orMask = exactMatch ? 0 : MAKE_ID(0,0,0xff,0); - DWORD inCode = 0; + const uint32_t orMask = exactMatch ? 0 : MAKE_ID(0,0,0xff,0); + uint32_t inCode = 0; StringEntry *entry, **pentry; - DWORD bucket; + uint32_t bucket; int cmpval; bool skip = true; @@ -328,7 +328,7 @@ const char *FStringTable::operator[] (const char *name) const { return NULL; } - DWORD bucket = MakeKey (name) & (HASH_SIZE - 1); + uint32_t bucket = MakeKey (name) & (HASH_SIZE - 1); StringEntry *entry = Buckets[bucket]; while (entry != NULL) @@ -359,7 +359,7 @@ const char *FStringTable::operator() (const char *name) const // pointer to it. Return NULL for entry1 if it wasn't found. void FStringTable::FindString (const char *name, StringEntry **&pentry1, StringEntry *&entry1) { - DWORD bucket = MakeKey (name) & (HASH_SIZE - 1); + uint32_t bucket = MakeKey (name) & (HASH_SIZE - 1); StringEntry **pentry = &Buckets[bucket], *entry = *pentry; while (entry != NULL) diff --git a/src/stringtable.h b/src/stringtable.h index 523647a85..792ef06b3 100644 --- a/src/stringtable.h +++ b/src/stringtable.h @@ -69,7 +69,7 @@ private: void FreeData (); void FreeNonDehackedStrings (); - void LoadLanguage (int lumpnum, DWORD code, bool exactMatch, int passnum); + void LoadLanguage (int lumpnum, uint32_t code, bool exactMatch, int passnum); static size_t ProcessEscapes (char *str); void FindString (const char *stringName, StringEntry **&pentry, StringEntry *&entry); }; diff --git a/src/teaminfo.cpp b/src/teaminfo.cpp index 18a2580e2..b9d5d24aa 100644 --- a/src/teaminfo.cpp +++ b/src/teaminfo.cpp @@ -284,7 +284,7 @@ int FTeam::GetTextColor () const if (m_TextColor.IsEmpty ()) return CR_UNTRANSLATED; - const BYTE *pColor = (const BYTE *)m_TextColor.GetChars (); + const uint8_t *pColor = (const uint8_t *)m_TextColor.GetChars (); int iColor = V_ParseFontColor (pColor, 0, 0); if (iColor == CR_UNDEFINED) diff --git a/src/textures/animations.cpp b/src/textures/animations.cpp index 06c496d9a..7b2aab98b 100644 --- a/src/textures/animations.cpp +++ b/src/textures/animations.cpp @@ -95,7 +95,7 @@ FAnimDef *FTextureManager::AddAnim (FAnimDef *anim) // //========================================================================== -FAnimDef *FTextureManager::AddSimpleAnim (FTextureID picnum, int animcount, DWORD speedmin, DWORD speedrange) +FAnimDef *FTextureManager::AddSimpleAnim (FTextureID picnum, int animcount, uint32_t speedmin, uint32_t speedrange) { if (AreTexturesCompatible(picnum, picnum + (animcount - 1))) { @@ -187,11 +187,11 @@ void FTextureManager::InitAnimated (void) { FMemLump animatedlump = Wads.ReadLump (lumpnum); int animatedlen = Wads.LumpLength(lumpnum); - const BYTE *animdefs = (const BYTE *)animatedlump.GetMem(); - const BYTE *anim_p; + const uint8_t *animdefs = (const uint8_t *)animatedlump.GetMem(); + const uint8_t *anim_p; FTextureID pic1, pic2; int animtype; - DWORD animspeed; + uint32_t animspeed; // Init animation animtype = FAnimDef::ANIM_Forward; @@ -349,7 +349,7 @@ void FTextureManager::ParseAnim (FScanner &sc, int usetype) int defined = 0; bool optional = false, missing = false; FAnimDef *ani = NULL; - BYTE type = FAnimDef::ANIM_Forward; + uint8_t type = FAnimDef::ANIM_Forward; sc.MustGetString (); if (sc.Compare ("optional")) @@ -467,7 +467,7 @@ FAnimDef *FTextureManager::ParseRangeAnim (FScanner &sc, FTextureID picnum, int { int type; FTextureID framenum; - DWORD min, max; + uint32_t min, max; type = FAnimDef::ANIM_Forward; framenum = ParseFramenum (sc, picnum, usetype, missing); @@ -507,7 +507,7 @@ FAnimDef *FTextureManager::ParseRangeAnim (FScanner &sc, FTextureID picnum, int void FTextureManager::ParsePicAnim (FScanner &sc, FTextureID picnum, int usetype, bool missing, TArray &frames) { FTextureID framenum; - DWORD min = 1, max = 1; + uint32_t min = 1, max = 1; framenum = ParseFramenum (sc, picnum, usetype, missing); ParseTime (sc, min, max); @@ -561,20 +561,20 @@ FTextureID FTextureManager::ParseFramenum (FScanner &sc, FTextureID basepicnum, // //========================================================================== -void FTextureManager::ParseTime (FScanner &sc, DWORD &min, DWORD &max) +void FTextureManager::ParseTime (FScanner &sc, uint32_t &min, uint32_t &max) { sc.MustGetString (); if (sc.Compare ("tics")) { sc.MustGetFloat (); - min = max = DWORD(sc.Float * 1000 / 35); + min = max = uint32_t(sc.Float * 1000 / 35); } else if (sc.Compare ("rand")) { sc.MustGetFloat (); - min = DWORD(sc.Float * 1000 / 35); + min = uint32_t(sc.Float * 1000 / 35); sc.MustGetFloat (); - max = DWORD(sc.Float * 1000 / 35); + max = uint32_t(sc.Float * 1000 / 35); } else { @@ -876,7 +876,7 @@ FDoorAnimation *FTextureManager::FindAnimatedDoor (FTextureID picnum) // //========================================================================== -void FAnimDef::SetSwitchTime (DWORD mstime) +void FAnimDef::SetSwitchTime (uint32_t mstime) { int speedframe = bDiscrete ? CurFrame : 0; @@ -917,7 +917,7 @@ void FTextureManager::SetTranslation (FTextureID fromtexnum, FTextureID totexnum // //========================================================================== -void FTextureManager::UpdateAnimations (DWORD mstime) +void FTextureManager::UpdateAnimations (uint32_t mstime) { for (unsigned int j = 0; j < mAnimations.Size(); ++j) { @@ -955,7 +955,7 @@ void FTextureManager::UpdateAnimations (DWORD mstime) // select a random frame other than the current one if (anim->NumFrames > 1) { - WORD rndFrame = (WORD)pr_animatepictures(anim->NumFrames - 1); + uint16_t rndFrame = (uint16_t)pr_animatepictures(anim->NumFrames - 1); if (rndFrame >= anim->CurFrame) rndFrame++; anim->CurFrame = rndFrame; } diff --git a/src/textures/automaptexture.cpp b/src/textures/automaptexture.cpp index 9aac379ef..3bd16f5bc 100644 --- a/src/textures/automaptexture.cpp +++ b/src/textures/automaptexture.cpp @@ -51,15 +51,15 @@ class FAutomapTexture : public FTexture public: ~FAutomapTexture (); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); void Unload (); void MakeTexture (); FAutomapTexture (int lumpnum); private: - BYTE *Pixels; + uint8_t *Pixels; Span DummySpan[2]; }; @@ -89,7 +89,7 @@ FAutomapTexture::FAutomapTexture (int lumpnum) : FTexture(NULL, lumpnum), Pixels(NULL) { Width = 320; - Height = WORD(Wads.LumpLength(lumpnum) / 320); + Height = uint16_t(Wads.LumpLength(lumpnum) / 320); CalcBitSize (); DummySpan[0].TopOffset = 0; @@ -135,9 +135,9 @@ void FAutomapTexture::MakeTexture () { int x, y; FMemLump data = Wads.ReadLump (SourceLump); - const BYTE *indata = (const BYTE *)data.GetMem(); + const uint8_t *indata = (const uint8_t *)data.GetMem(); - Pixels = new BYTE[Width * Height]; + Pixels = new uint8_t[Width * Height]; for (x = 0; x < Width; ++x) { @@ -154,7 +154,7 @@ void FAutomapTexture::MakeTexture () // //========================================================================== -const BYTE *FAutomapTexture::GetPixels () +const uint8_t *FAutomapTexture::GetPixels () { if (Pixels == NULL) { @@ -169,7 +169,7 @@ const BYTE *FAutomapTexture::GetPixels () // //========================================================================== -const BYTE *FAutomapTexture::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FAutomapTexture::GetColumn (unsigned int column, const Span **spans_out) { if (Pixels == NULL) { diff --git a/src/textures/backdroptexture.cpp b/src/textures/backdroptexture.cpp index 0f18fe6d6..aec95cc2e 100644 --- a/src/textures/backdroptexture.cpp +++ b/src/textures/backdroptexture.cpp @@ -273,26 +273,26 @@ void FBackdropTexture::Render() int x, y; - const DWORD a1add = DEGREES(0.5); - const DWORD a2add = DEGREES(359); - const DWORD a3add = DEGREES(5 / 7.f); - const DWORD a4add = DEGREES(358.66666); + const uint32_t a1add = DEGREES(0.5); + const uint32_t a2add = DEGREES(359); + const uint32_t a3add = DEGREES(5 / 7.f); + const uint32_t a4add = DEGREES(358.66666); - const DWORD t1add = DEGREES(358); - const DWORD t2add = DEGREES(357.16666); - const DWORD t3add = DEGREES(2.285); - const DWORD t4add = DEGREES(359.33333); - const DWORD x1add = 5 * 524288; - const DWORD x2add = 0u - 13 * 524288; - const DWORD z1add = 3 * 524288; - const DWORD z2add = 4 * 524288; + const uint32_t t1add = DEGREES(358); + const uint32_t t2add = DEGREES(357.16666); + const uint32_t t3add = DEGREES(2.285); + const uint32_t t4add = DEGREES(359.33333); + const uint32_t x1add = 5 * 524288; + const uint32_t x2add = 0u - 13 * 524288; + const uint32_t z1add = 3 * 524288; + const uint32_t z2add = 4 * 524288; - DWORD a1, a2, a3, a4; + uint32_t a1, a2, a3, a4; int32_t c1, c2, c3, c4; - DWORD tx, ty, tc, ts; - DWORD ux, uy, uc, us; - DWORD ltx, lty, lux, luy; + uint32_t tx, ty, tc, ts; + uint32_t ux, uy, uc, us; + uint32_t ltx, lty, lux, luy; from = Pixels; diff --git a/src/textures/bitmap.cpp b/src/textures/bitmap.cpp index 7873e35cb..18fb5446b 100644 --- a/src/textures/bitmap.cpp +++ b/src/textures/bitmap.cpp @@ -46,12 +46,12 @@ // //=========================================================================== template -void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *inf, - BYTE tr, BYTE tg, BYTE tb) +void iCopyColors(uint8_t *pout, const uint8_t *pin, int count, int step, FCopyInfo *inf, + uint8_t tr, uint8_t tg, uint8_t tb) { int i; int fac; - BYTE r,g,b; + uint8_t r,g,b; int gray; int a; @@ -184,7 +184,7 @@ void iCopyColors(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *in } } -typedef void (*CopyFunc)(BYTE *pout, const BYTE *pin, int count, int step, FCopyInfo *inf, BYTE r, BYTE g, BYTE b); +typedef void (*CopyFunc)(uint8_t *pout, const uint8_t *pin, int count, int step, FCopyInfo *inf, uint8_t r, uint8_t g, uint8_t b); #define COPY_FUNCS(op) \ { \ @@ -219,7 +219,7 @@ static const CopyFunc copyfuncs[][10]={ // //=========================================================================== bool ClipCopyPixelRect(const FClipRect *cr, int &originx, int &originy, - const BYTE *&patch, int &srcwidth, int &srcheight, + const uint8_t *&patch, int &srcwidth, int &srcheight, int &pstep_x, int &pstep_y, int rotate) { int pixxoffset; @@ -371,13 +371,13 @@ bool FClipRect::Intersect(int ix, int iy, int iw, int ih) // True Color texture copy function // //=========================================================================== -void FBitmap::CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int srcwidth, +void FBitmap::CopyPixelDataRGB(int originx, int originy, const uint8_t *patch, int srcwidth, int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf, int r, int g, int b) { if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate)) { - BYTE *buffer = data + 4 * originx + Pitch * originy; + uint8_t *buffer = data + 4 * originx + Pitch * originy; int op = inf==NULL? OP_COPY : inf->op; for (int y=0;y -void iCopyPaletted(BYTE *buffer, const BYTE * patch, int srcwidth, int srcheight, int Pitch, +void iCopyPaletted(uint8_t *buffer, const uint8_t * patch, int srcwidth, int srcheight, int Pitch, int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf) { int x,y,pos; @@ -412,7 +412,7 @@ void iCopyPaletted(BYTE *buffer, const BYTE * patch, int srcwidth, int srcheight } } -typedef void (*CopyPalettedFunc)(BYTE *buffer, const BYTE * patch, int srcwidth, int srcheight, int Pitch, +typedef void (*CopyPalettedFunc)(uint8_t *buffer, const uint8_t * patch, int srcwidth, int srcheight, int Pitch, int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf); @@ -435,18 +435,18 @@ static const CopyPalettedFunc copypalettedfuncs[]= // Paletted to True Color texture copy function // //=========================================================================== -void FBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int srcwidth, int srcheight, +void FBitmap::CopyPixelData(int originx, int originy, const uint8_t * patch, int srcwidth, int srcheight, int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf) { if (ClipCopyPixelRect(&ClipRect, originx, originy, patch, srcwidth, srcheight, step_x, step_y, rotate)) { - BYTE *buffer = data + 4*originx + Pitch*originy; + uint8_t *buffer = data + 4*originx + Pitch*originy; PalEntry penew[256]; memset(penew, 0, sizeof(penew)); if (inf && inf->blend) { - iCopyColors((BYTE*)penew, (const BYTE*)palette, 256, 4, inf, 0, 0, 0); + iCopyColors((uint8_t*)penew, (const uint8_t*)palette, 256, 4, inf, 0, 0, 0); palette = penew; } @@ -462,7 +462,7 @@ void FBitmap::CopyPixelData(int originx, int originy, const BYTE * patch, int sr //=========================================================================== void FBitmap::Zero() { - BYTE *buffer = data; + uint8_t *buffer = data; for (int y = ClipRect.y; y < ClipRect.height; ++y) { memset(buffer + ClipRect.x, 0, ClipRect.width*4); diff --git a/src/textures/bitmap.h b/src/textures/bitmap.h index a27d1ff98..9a6dcd853 100644 --- a/src/textures/bitmap.h +++ b/src/textures/bitmap.h @@ -59,7 +59,7 @@ enum class FBitmap { protected: - BYTE *data; + uint8_t *data; int Width; int Height; int Pitch; @@ -77,7 +77,7 @@ public: ClipRect.x = ClipRect.y = ClipRect.width = ClipRect.height = 0; } - FBitmap(BYTE *buffer, int pitch, int width, int height) + FBitmap(uint8_t *buffer, int pitch, int width, int height) { data = buffer; @@ -107,7 +107,7 @@ public: Pitch = w*4; Width = w; Height = h; - data = new BYTE[4*w*h]; + data = new uint8_t[4*w*h]; memset(data, 0, 4*w*h); FreeBuffer = true; ClipRect.x = ClipRect.y = 0; @@ -131,12 +131,12 @@ public: return Pitch; } - const BYTE *GetPixels() const + const uint8_t *GetPixels() const { return data; } - BYTE *GetPixels() + uint8_t *GetPixels() { return data; } @@ -164,17 +164,17 @@ public: void Zero(); - virtual void CopyPixelDataRGB(int originx, int originy, const BYTE *patch, int srcwidth, + virtual void CopyPixelDataRGB(int originx, int originy, const uint8_t *patch, int srcwidth, int srcheight, int step_x, int step_y, int rotate, int ct, FCopyInfo *inf = NULL, /* for PNG tRNS */ int r=0, int g=0, int b=0); - virtual void CopyPixelData(int originx, int originy, const BYTE * patch, int srcwidth, int srcheight, + virtual void CopyPixelData(int originx, int originy, const uint8_t * patch, int srcwidth, int srcheight, int step_x, int step_y, int rotate, PalEntry * palette, FCopyInfo *inf = NULL); }; bool ClipCopyPixelRect(const FClipRect *cr, int &originx, int &originy, - const BYTE *&patch, int &srcwidth, int &srcheight, + const uint8_t *&patch, int &srcwidth, int &srcheight, int &step_x, int &step_y, int rotate); //=========================================================================== @@ -188,7 +188,7 @@ struct cRGB static __forceinline unsigned char R(const unsigned char * p) { return p[0]; } static __forceinline unsigned char G(const unsigned char * p) { return p[1]; } static __forceinline unsigned char B(const unsigned char * p) { return p[2]; } - static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; } + static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return 255; } static __forceinline int Gray(const unsigned char * p) { return (p[0]*77 + p[1]*143 + p[2]*36)>>8; } }; @@ -197,7 +197,7 @@ struct cRGBT static __forceinline unsigned char R(const unsigned char * p) { return p[0]; } static __forceinline unsigned char G(const unsigned char * p) { return p[1]; } static __forceinline unsigned char B(const unsigned char * p) { return p[2]; } - static __forceinline unsigned char A(const unsigned char * p, BYTE r, BYTE g, BYTE b) { return (p[0] != r || p[1] != g || p[2] != b) ? 255 : 0; } + static __forceinline unsigned char A(const unsigned char * p, uint8_t r, uint8_t g, uint8_t b) { return (p[0] != r || p[1] != g || p[2] != b) ? 255 : 0; } static __forceinline int Gray(const unsigned char * p) { return (p[0]*77 + p[1]*143 + p[2]*36)>>8; } }; @@ -213,7 +213,7 @@ struct cRGBA static __forceinline unsigned char R(const unsigned char * p) { return p[0]; } static __forceinline unsigned char G(const unsigned char * p) { return p[1]; } static __forceinline unsigned char B(const unsigned char * p) { return p[2]; } - static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return p[3]; } + static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return p[3]; } static __forceinline int Gray(const unsigned char * p) { return (p[0]*77 + p[1]*143 + p[2]*36)>>8; } }; @@ -222,7 +222,7 @@ struct cIA static __forceinline unsigned char R(const unsigned char * p) { return p[0]; } static __forceinline unsigned char G(const unsigned char * p) { return p[0]; } static __forceinline unsigned char B(const unsigned char * p) { return p[0]; } - static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return p[1]; } + static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return p[1]; } static __forceinline int Gray(const unsigned char * p) { return p[0]; } }; @@ -231,7 +231,7 @@ struct cCMYK static __forceinline unsigned char R(const unsigned char * p) { return p[3] - (((256-p[0])*p[3]) >> 8); } static __forceinline unsigned char G(const unsigned char * p) { return p[3] - (((256-p[1])*p[3]) >> 8); } static __forceinline unsigned char B(const unsigned char * p) { return p[3] - (((256-p[2])*p[3]) >> 8); } - static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; } + static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return 255; } static __forceinline int Gray(const unsigned char * p) { return (R(p)*77 + G(p)*143 + B(p)*36)>>8; } }; @@ -240,7 +240,7 @@ struct cBGR static __forceinline unsigned char R(const unsigned char * p) { return p[2]; } static __forceinline unsigned char G(const unsigned char * p) { return p[1]; } static __forceinline unsigned char B(const unsigned char * p) { return p[0]; } - static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; } + static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return 255; } static __forceinline int Gray(const unsigned char * p) { return (p[2]*77 + p[1]*143 + p[0]*36)>>8; } }; @@ -256,7 +256,7 @@ struct cBGRA static __forceinline unsigned char R(const unsigned char * p) { return p[2]; } static __forceinline unsigned char G(const unsigned char * p) { return p[1]; } static __forceinline unsigned char B(const unsigned char * p) { return p[0]; } - static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return p[3]; } + static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return p[3]; } static __forceinline int Gray(const unsigned char * p) { return (p[2]*77 + p[1]*143 + p[0]*36)>>8; } }; @@ -272,7 +272,7 @@ struct cARGB static __forceinline unsigned char R(const unsigned char * p) { return p[1]; } static __forceinline unsigned char G(const unsigned char * p) { return p[2]; } static __forceinline unsigned char B(const unsigned char * p) { return p[3]; } - static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return p[0]; } + static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return p[0]; } static __forceinline int Gray(const unsigned char * p) { return (p[1]*77 + p[2]*143 + p[3]*36)>>8; } }; @@ -281,16 +281,16 @@ struct cI16 static __forceinline unsigned char R(const unsigned char * p) { return p[1]; } static __forceinline unsigned char G(const unsigned char * p) { return p[1]; } static __forceinline unsigned char B(const unsigned char * p) { return p[1]; } - static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; } + static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return 255; } static __forceinline int Gray(const unsigned char * p) { return p[1]; } }; struct cRGB555 { - static __forceinline unsigned char R(const unsigned char * p) { return (((*(WORD*)p)&0x1f)<<3); } - static __forceinline unsigned char G(const unsigned char * p) { return (((*(WORD*)p)&0x3e0)>>2); } - static __forceinline unsigned char B(const unsigned char * p) { return (((*(WORD*)p)&0x7c00)>>7); } - static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return 255; } + static __forceinline unsigned char R(const unsigned char * p) { return (((*(uint16_t*)p)&0x1f)<<3); } + static __forceinline unsigned char G(const unsigned char * p) { return (((*(uint16_t*)p)&0x3e0)>>2); } + static __forceinline unsigned char B(const unsigned char * p) { return (((*(uint16_t*)p)&0x7c00)>>7); } + static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return 255; } static __forceinline int Gray(const unsigned char * p) { return (R(p)*77 + G(p)*143 + B(p)*36)>>8; } }; @@ -299,7 +299,7 @@ struct cPalEntry static __forceinline unsigned char R(const unsigned char * p) { return ((PalEntry*)p)->r; } static __forceinline unsigned char G(const unsigned char * p) { return ((PalEntry*)p)->g; } static __forceinline unsigned char B(const unsigned char * p) { return ((PalEntry*)p)->b; } - static __forceinline unsigned char A(const unsigned char * p, BYTE x, BYTE y, BYTE z) { return ((PalEntry*)p)->a; } + static __forceinline unsigned char A(const unsigned char * p, uint8_t x, uint8_t y, uint8_t z) { return ((PalEntry*)p)->a; } static __forceinline int Gray(const unsigned char * p) { return (R(p)*77 + G(p)*143 + B(p)*36)>>8; } }; @@ -353,71 +353,71 @@ struct FCopyInfo struct bOverwrite { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; } - static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = s; } + static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return true; } }; struct bCopy { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; } - static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = s; } + static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; struct bCopyNewAlpha { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = s; } - static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = (s*i->alpha) >> BLENDBITS; } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = s; } + static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = (s*i->alpha) >> BLENDBITS; } static __forceinline bool ProcessAlpha0() { return false; } }; struct bCopyAlpha { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; } - static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; } + static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; struct bOverlay { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; } - static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = MAX(s,d); } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; } + static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = MAX(s,d); } static __forceinline bool ProcessAlpha0() { return false; } }; struct bBlend { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (d*i->invalpha + s*i->alpha) >> BLENDBITS; } - static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = (d*i->invalpha + s*i->alpha) >> BLENDBITS; } + static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; struct bAdd { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MIN((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); } - static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = MIN((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); } + static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; struct bSubtract { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MAX((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); } - static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = MAX((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); } + static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; struct bReverseSubtract { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = MAX((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); } - static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = MAX((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); } + static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; struct bModulate { - static __forceinline void OpC(BYTE &d, BYTE s, BYTE a, FCopyInfo *i) { d = (s*d)/255; } - static __forceinline void OpA(BYTE &d, BYTE s, FCopyInfo *i) { d = s; } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = (s*d)/255; } + static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; diff --git a/src/textures/ddstexture.cpp b/src/textures/ddstexture.cpp index 90a8e38da..1eaf68159 100644 --- a/src/textures/ddstexture.cpp +++ b/src/textures/ddstexture.cpp @@ -104,42 +104,42 @@ struct DDPIXELFORMAT { - DWORD Size; // Must be 32 - DWORD Flags; - DWORD FourCC; - DWORD RGBBitCount; - DWORD RBitMask, GBitMask, BBitMask; - DWORD RGBAlphaBitMask; + uint32_t Size; // Must be 32 + uint32_t Flags; + uint32_t FourCC; + uint32_t RGBBitCount; + uint32_t RBitMask, GBitMask, BBitMask; + uint32_t RGBAlphaBitMask; }; struct DDCAPS2 { - DWORD Caps1, Caps2; - DWORD Reserved[2]; + uint32_t Caps1, Caps2; + uint32_t Reserved[2]; }; struct DDSURFACEDESC2 { - DWORD Size; // Must be 124. DevIL claims some writers set it to 'DDS ' instead. - DWORD Flags; - DWORD Height; - DWORD Width; + uint32_t Size; // Must be 124. DevIL claims some writers set it to 'DDS ' instead. + uint32_t Flags; + uint32_t Height; + uint32_t Width; union { int32_t Pitch; - DWORD LinearSize; + uint32_t LinearSize; }; - DWORD Depth; - DWORD MipMapCount; - DWORD Reserved1[11]; + uint32_t Depth; + uint32_t MipMapCount; + uint32_t Reserved1[11]; DDPIXELFORMAT PixelFormat; DDCAPS2 Caps; - DWORD Reserved2; + uint32_t Reserved2; }; struct DDSFileHeader { - DWORD Magic; + uint32_t Magic; DDSURFACEDESC2 Desc; }; @@ -156,32 +156,32 @@ public: FDDSTexture (FileReader &lump, int lumpnum, void *surfdesc); ~FDDSTexture (); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); void Unload (); FTextureFormat GetFormat (); protected: - BYTE *Pixels; + uint8_t *Pixels; Span **Spans; - DWORD Format; + uint32_t Format; - DWORD RMask, GMask, BMask, AMask; - BYTE RShiftL, GShiftL, BShiftL, AShiftL; - BYTE RShiftR, GShiftR, BShiftR, AShiftR; + uint32_t RMask, GMask, BMask, AMask; + uint8_t RShiftL, GShiftL, BShiftL, AShiftL; + uint8_t RShiftR, GShiftR, BShiftR, AShiftR; int32_t Pitch; - DWORD LinearSize; + uint32_t LinearSize; - static void CalcBitShift (DWORD mask, BYTE *lshift, BYTE *rshift); + static void CalcBitShift (uint32_t mask, uint8_t *lshift, uint8_t *rshift); void MakeTexture (); - void ReadRGB (FWadLump &lump, BYTE *tcbuf = NULL); - void DecompressDXT1 (FWadLump &lump, BYTE *tcbuf = NULL); - void DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbuf = NULL); - void DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbuf = NULL); + void ReadRGB (FWadLump &lump, uint8_t *tcbuf = NULL); + void DecompressDXT1 (FWadLump &lump, uint8_t *tcbuf = NULL); + void DecompressDXT3 (FWadLump &lump, bool premultiplied, uint8_t *tcbuf = NULL); + void DecompressDXT5 (FWadLump &lump, bool premultiplied, uint8_t *tcbuf = NULL); int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); bool UseBasePalette(); @@ -224,7 +224,7 @@ FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum) union { DDSURFACEDESC2 surfdesc; - DWORD byteswapping[sizeof(DDSURFACEDESC2) / 4]; + uint32_t byteswapping[sizeof(DDSURFACEDESC2) / 4]; }; if (!CheckDDS(data)) return NULL; @@ -233,7 +233,7 @@ FTexture *DDSTexture_TryCreate (FileReader &data, int lumpnum) data.Read (&surfdesc, sizeof(surfdesc)); #ifdef __BIG_ENDIAN__ - // Every single element of the header is a DWORD + // Every single element of the header is a uint32_t for (unsigned int i = 0; i < sizeof(DDSURFACEDESC2) / 4; ++i) { byteswapping[i] = LittleLong(byteswapping[i]); @@ -293,8 +293,8 @@ FDDSTexture::FDDSTexture (FileReader &lump, int lumpnum, void *vsurfdesc) TopOffset = 0; bMasked = false; - Width = WORD(surf->Width); - Height = WORD(surf->Height); + Width = uint16_t(surf->Width); + Height = uint16_t(surf->Height); CalcBitSize (); if (surf->PixelFormat.Flags & DDPF_FOURCC) @@ -345,9 +345,9 @@ FDDSTexture::FDDSTexture (FileReader &lump, int lumpnum, void *vsurfdesc) // //========================================================================== -void FDDSTexture::CalcBitShift (DWORD mask, BYTE *lshiftp, BYTE *rshiftp) +void FDDSTexture::CalcBitShift (uint32_t mask, uint8_t *lshiftp, uint8_t *rshiftp) { - BYTE shift; + uint8_t shift; if (mask == 0) { @@ -434,7 +434,7 @@ FTextureFormat FDDSTexture::GetFormat() // //========================================================================== -const BYTE *FDDSTexture::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FDDSTexture::GetColumn (unsigned int column, const Span **spans_out) { if (Pixels == NULL) { @@ -468,7 +468,7 @@ const BYTE *FDDSTexture::GetColumn (unsigned int column, const Span **spans_out) // //========================================================================== -const BYTE *FDDSTexture::GetPixels () +const uint8_t *FDDSTexture::GetPixels () { if (Pixels == NULL) { @@ -487,7 +487,7 @@ void FDDSTexture::MakeTexture () { FWadLump lump = Wads.OpenLumpNum (SourceLump); - Pixels = new BYTE[Width*Height]; + Pixels = new uint8_t[Width*Height]; lump.Seek (sizeof(DDSURFACEDESC2) + 4, SEEK_SET); @@ -515,27 +515,27 @@ void FDDSTexture::MakeTexture () // //========================================================================== -void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf) +void FDDSTexture::ReadRGB (FWadLump &lump, uint8_t *tcbuf) { - DWORD x, y; - DWORD amask = AMask == 0 ? 0 : 0x80000000 >> AShiftL; - BYTE *linebuff = new BYTE[Pitch]; + uint32_t x, y; + uint32_t amask = AMask == 0 ? 0 : 0x80000000 >> AShiftL; + uint8_t *linebuff = new uint8_t[Pitch]; for (y = Height; y > 0; --y) { - BYTE *buffp = linebuff; - BYTE *pixelp = tcbuf? tcbuf + 4*y*Height : Pixels + y; + uint8_t *buffp = linebuff; + uint8_t *pixelp = tcbuf? tcbuf + 4*y*Height : Pixels + y; lump.Read (linebuff, Pitch); for (x = Width; x > 0; --x) { - DWORD c; + uint32_t c; if (Format == 4) { - c = LittleLong(*(DWORD *)buffp); buffp += 4; + c = LittleLong(*(uint32_t *)buffp); buffp += 4; } else if (Format == 2) { - c = LittleShort(*(WORD *)buffp); buffp += 2; + c = LittleShort(*(uint16_t *)buffp); buffp += 2; } else if (Format == 3) { @@ -549,9 +549,9 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf) { if (amask == 0 || (c & amask)) { - DWORD r = (c & RMask) << RShiftL; r |= r >> RShiftR; - DWORD g = (c & GMask) << GShiftL; g |= g >> GShiftR; - DWORD b = (c & BMask) << BShiftL; b |= b >> BShiftR; + uint32_t r = (c & RMask) << RShiftL; r |= r >> RShiftR; + uint32_t g = (c & GMask) << GShiftL; g |= g >> GShiftR; + uint32_t b = (c & BMask) << BShiftL; b |= b >> BShiftR; *pixelp = RGB256k.RGB[r >> 26][g >> 26][b >> 26]; } else @@ -563,14 +563,14 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf) } else { - DWORD r = (c & RMask) << RShiftL; r |= r >> RShiftR; - DWORD g = (c & GMask) << GShiftL; g |= g >> GShiftR; - DWORD b = (c & BMask) << BShiftL; b |= b >> BShiftR; - DWORD a = (c & AMask) << AShiftL; a |= a >> AShiftR; - pixelp[0] = (BYTE)(r>>24); - pixelp[1] = (BYTE)(g>>24); - pixelp[2] = (BYTE)(b>>24); - pixelp[3] = (BYTE)(a>>24); + uint32_t r = (c & RMask) << RShiftL; r |= r >> RShiftR; + uint32_t g = (c & GMask) << GShiftL; g |= g >> GShiftR; + uint32_t b = (c & BMask) << BShiftL; b |= b >> BShiftR; + uint32_t a = (c & AMask) << AShiftL; a |= a >> AShiftR; + pixelp[0] = (uint8_t)(r>>24); + pixelp[1] = (uint8_t)(g>>24); + pixelp[2] = (uint8_t)(b>>24); + pixelp[3] = (uint8_t)(a>>24); pixelp+=4; } } @@ -584,13 +584,13 @@ void FDDSTexture::ReadRGB (FWadLump &lump, BYTE *tcbuf) // //========================================================================== -void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf) +void FDDSTexture::DecompressDXT1 (FWadLump &lump, uint8_t *tcbuf) { const long blocklinelen = ((Width + 3) >> 2) << 3; - BYTE *blockbuff = new BYTE[blocklinelen]; - BYTE *block; + uint8_t *blockbuff = new uint8_t[blocklinelen]; + uint8_t *block; PalEntry color[4]; - BYTE palcol[4]; + uint8_t palcol[4]; int ox, oy, x, y, i; color[0].a = 255; @@ -603,7 +603,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf) block = blockbuff; for (ox = 0; ox < Width; ox += 4) { - WORD color16[2] = { LittleShort(((WORD *)block)[0]), LittleShort(((WORD *)block)[1]) }; + uint16_t color16[2] = { LittleShort(((uint16_t *)block)[0]), LittleShort(((uint16_t *)block)[1]) }; // Convert color from R5G6B5 to R8G8B8. for (i = 1; i >= 0; --i) @@ -647,7 +647,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf) { break; } - BYTE yslice = block[4 + y]; + uint8_t yslice = block[4 + y]; for (x = 0; x < 4; ++x) { if (ox + x >= Width) @@ -661,7 +661,7 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf) } else { - BYTE * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4]; + uint8_t * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4]; tcp[0] = color[ci].r; tcp[1] = color[ci].g; tcp[2] = color[ci].b; @@ -682,13 +682,13 @@ void FDDSTexture::DecompressDXT1 (FWadLump &lump, BYTE *tcbuf) // //========================================================================== -void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbuf) +void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, uint8_t *tcbuf) { const long blocklinelen = ((Width + 3) >> 2) << 4; - BYTE *blockbuff = new BYTE[blocklinelen]; - BYTE *block; + uint8_t *blockbuff = new uint8_t[blocklinelen]; + uint8_t *block; PalEntry color[4]; - BYTE palcol[4]; + uint8_t palcol[4]; int ox, oy, x, y, i; for (oy = 0; oy < Height; oy += 4) @@ -697,7 +697,7 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu block = blockbuff; for (ox = 0; ox < Width; ox += 4) { - WORD color16[2] = { LittleShort(((WORD *)block)[4]), LittleShort(((WORD *)block)[5]) }; + uint16_t color16[2] = { LittleShort(((uint16_t *)block)[4]), LittleShort(((uint16_t *)block)[5]) }; // Convert color from R5G6B5 to R8G8B8. for (i = 1; i >= 0; --i) @@ -727,8 +727,8 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu { break; } - BYTE yslice = block[12 + y]; - WORD yalphaslice = LittleShort(((WORD *)block)[y]); + uint8_t yslice = block[12 + y]; + uint16_t yalphaslice = LittleShort(((uint16_t *)block)[y]); for (x = 0; x < 4; ++x) { if (ox + x >= Width) @@ -742,7 +742,7 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu } else { - BYTE * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4]; + uint8_t * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4]; int c = (yslice >> (x + x)) & 3; tcp[0] = color[c].r; tcp[1] = color[c].g; @@ -764,14 +764,14 @@ void FDDSTexture::DecompressDXT3 (FWadLump &lump, bool premultiplied, BYTE *tcbu // //========================================================================== -void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbuf) +void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, uint8_t *tcbuf) { const long blocklinelen = ((Width + 3) >> 2) << 4; - BYTE *blockbuff = new BYTE[blocklinelen]; - BYTE *block; + uint8_t *blockbuff = new uint8_t[blocklinelen]; + uint8_t *block; PalEntry color[4]; - BYTE palcol[4]; - DWORD yalphaslice = 0; + uint8_t palcol[4]; + uint32_t yalphaslice = 0; int ox, oy, x, y, i; for (oy = 0; oy < Height; oy += 4) @@ -780,8 +780,8 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu block = blockbuff; for (ox = 0; ox < Width; ox += 4) { - WORD color16[2] = { LittleShort(((WORD *)block)[4]), LittleShort(((WORD *)block)[5]) }; - BYTE alpha[8]; + uint16_t color16[2] = { LittleShort(((uint16_t *)block)[4]), LittleShort(((uint16_t *)block)[5]) }; + uint8_t alpha[8]; // Calculate the eight alpha values. alpha[0] = block[0]; @@ -841,7 +841,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu { yalphaslice >>= 12; } - BYTE yslice = block[12 + y]; + uint8_t yslice = block[12 + y]; for (x = 0; x < 4; ++x) { if (ox + x >= Width) @@ -855,7 +855,7 @@ void FDDSTexture::DecompressDXT5 (FWadLump &lump, bool premultiplied, BYTE *tcbu } else { - BYTE * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4]; + uint8_t * tcp = &tcbuf[(ox + x)*4 + (oy + y) * Width*4]; int c = (yslice >> (x + x)) & 3; tcp[0] = color[c].r; tcp[1] = color[c].g; @@ -880,7 +880,7 @@ int FDDSTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo { FWadLump lump = Wads.OpenLumpNum (SourceLump); - BYTE *TexBuffer = new BYTE[4*Width*Height]; + uint8_t *TexBuffer = new uint8_t[4*Width*Height]; lump.Seek (sizeof(DDSURFACEDESC2) + 4, SEEK_SET); diff --git a/src/textures/emptytexture.cpp b/src/textures/emptytexture.cpp index 55093a3cf..701380993 100644 --- a/src/textures/emptytexture.cpp +++ b/src/textures/emptytexture.cpp @@ -50,12 +50,12 @@ class FEmptyTexture : public FTexture public: FEmptyTexture (int lumpnum); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); void Unload() {} protected: - BYTE Pixels[1]; + uint8_t Pixels[1]; Span DummySpans[1]; }; @@ -103,7 +103,7 @@ FEmptyTexture::FEmptyTexture (int lumpnum) // //========================================================================== -const BYTE *FEmptyTexture::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FEmptyTexture::GetColumn (unsigned int column, const Span **spans_out) { if (spans_out != NULL) { @@ -118,7 +118,7 @@ const BYTE *FEmptyTexture::GetColumn (unsigned int column, const Span **spans_ou // //========================================================================== -const BYTE *FEmptyTexture::GetPixels () +const uint8_t *FEmptyTexture::GetPixels () { return Pixels; } diff --git a/src/textures/flattexture.cpp b/src/textures/flattexture.cpp index 08e0d1221..6e584f694 100644 --- a/src/textures/flattexture.cpp +++ b/src/textures/flattexture.cpp @@ -51,12 +51,12 @@ public: FFlatTexture (int lumpnum); ~FFlatTexture (); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); void Unload (); protected: - BYTE *Pixels; + uint8_t *Pixels; Span DummySpans[2]; @@ -147,7 +147,7 @@ void FFlatTexture::Unload () // //========================================================================== -const BYTE *FFlatTexture::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FFlatTexture::GetColumn (unsigned int column, const Span **spans_out) { if (Pixels == NULL) { @@ -177,7 +177,7 @@ const BYTE *FFlatTexture::GetColumn (unsigned int column, const Span **spans_out // //========================================================================== -const BYTE *FFlatTexture::GetPixels () +const uint8_t *FFlatTexture::GetPixels () { if (Pixels == NULL) { @@ -195,7 +195,7 @@ const BYTE *FFlatTexture::GetPixels () void FFlatTexture::MakeTexture () { FWadLump lump = Wads.OpenLumpNum (SourceLump); - Pixels = new BYTE[Width*Height]; + Pixels = new uint8_t[Width*Height]; long numread = lump.Read (Pixels, Width*Height); if (numread < Width*Height) { diff --git a/src/textures/imgztexture.cpp b/src/textures/imgztexture.cpp index 04932d4bf..1689289d0 100644 --- a/src/textures/imgztexture.cpp +++ b/src/textures/imgztexture.cpp @@ -51,26 +51,26 @@ class FIMGZTexture : public FTexture { struct ImageHeader { - BYTE Magic[4]; - WORD Width; - WORD Height; - SWORD LeftOffset; - SWORD TopOffset; - BYTE Compression; - BYTE Reserved[11]; + uint8_t Magic[4]; + uint16_t Width; + uint16_t Height; + int16_t LeftOffset; + int16_t TopOffset; + uint8_t Compression; + uint8_t Reserved[11]; }; public: - FIMGZTexture (int lumpnum, WORD w, WORD h, SWORD l, SWORD t); + FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int16_t t); ~FIMGZTexture (); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); void Unload (); protected: - BYTE *Pixels; + uint8_t *Pixels; Span **Spans; void MakeTexture (); @@ -85,9 +85,9 @@ protected: FTexture *IMGZTexture_TryCreate(FileReader & file, int lumpnum) { - DWORD magic = 0; - WORD w, h; - SWORD l, t; + uint32_t magic = 0; + uint16_t w, h; + int16_t l, t; file.Seek(0, SEEK_SET); if (file.Read(&magic, 4) != 4) return NULL; @@ -102,7 +102,7 @@ FTexture *IMGZTexture_TryCreate(FileReader & file, int lumpnum) // //========================================================================== -FIMGZTexture::FIMGZTexture (int lumpnum, WORD w, WORD h, SWORD l, SWORD t) +FIMGZTexture::FIMGZTexture (int lumpnum, uint16_t w, uint16_t h, int16_t l, int16_t t) : FTexture(NULL, lumpnum), Pixels(0), Spans(0) { Wads.GetLumpName (Name, lumpnum); @@ -151,7 +151,7 @@ void FIMGZTexture::Unload () // //========================================================================== -const BYTE *FIMGZTexture::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FIMGZTexture::GetColumn (unsigned int column, const Span **spans_out) { if (Pixels == NULL) { @@ -185,7 +185,7 @@ const BYTE *FIMGZTexture::GetColumn (unsigned int column, const Span **spans_out // //========================================================================== -const BYTE *FIMGZTexture::GetPixels () +const uint8_t *FIMGZTexture::GetPixels () { if (Pixels == NULL) { @@ -204,7 +204,7 @@ void FIMGZTexture::MakeTexture () { FMemLump lump = Wads.ReadLump (SourceLump); const ImageHeader *imgz = (const ImageHeader *)lump.GetMem(); - const BYTE *data = (const BYTE *)&imgz[1]; + const uint8_t *data = (const uint8_t *)&imgz[1]; if (Width != 0xFFFF) { @@ -214,12 +214,12 @@ void FIMGZTexture::MakeTexture () TopOffset = LittleShort(imgz->TopOffset); } - BYTE *dest_p; + uint8_t *dest_p; int dest_adv = Height; int dest_rew = Width * Height - 1; CalcBitSize (); - Pixels = new BYTE[Width*Height]; + Pixels = new uint8_t[Width*Height]; dest_p = Pixels; // Convert the source image from row-major to column-major format @@ -240,7 +240,7 @@ void FIMGZTexture::MakeTexture () { // IMGZ compression is the same RLE used by IFF ILBM files int runlen = 0, setlen = 0; - BYTE setval = 0; // Shut up, GCC + uint8_t setval = 0; // Shut up, GCC for (int y = Height; y != 0; --y) { @@ -248,7 +248,7 @@ void FIMGZTexture::MakeTexture () { if (runlen != 0) { - BYTE color = *data; + uint8_t color = *data; *dest_p = color; dest_p += dest_adv; data++; @@ -264,7 +264,7 @@ void FIMGZTexture::MakeTexture () } else { - SBYTE code = *data++; + int8_t code = *data++; if (code >= 0) { runlen = code + 1; diff --git a/src/textures/jpegtexture.cpp b/src/textures/jpegtexture.cpp index 684e06fa6..02bb82829 100644 --- a/src/textures/jpegtexture.cpp +++ b/src/textures/jpegtexture.cpp @@ -185,8 +185,8 @@ public: FJPEGTexture (int lumpnum, int width, int height); ~FJPEGTexture (); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); void Unload (); FTextureFormat GetFormat (); int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); @@ -194,7 +194,7 @@ public: protected: - BYTE *Pixels; + uint8_t *Pixels; Span DummySpans[2]; void MakeTexture (); @@ -212,9 +212,9 @@ FTexture *JPEGTexture_TryCreate(FileReader & data, int lumpnum) { union { - DWORD dw; - WORD w[2]; - BYTE b[4]; + uint32_t dw; + uint16_t w[2]; + uint8_t b[4]; } first4bytes; data.Seek(0, SEEK_SET); @@ -317,7 +317,7 @@ FTextureFormat FJPEGTexture::GetFormat() // //========================================================================== -const BYTE *FJPEGTexture::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FJPEGTexture::GetColumn (unsigned int column, const Span **spans_out) { if (Pixels == NULL) { @@ -347,7 +347,7 @@ const BYTE *FJPEGTexture::GetColumn (unsigned int column, const Span **spans_out // //========================================================================== -const BYTE *FJPEGTexture::GetPixels () +const uint8_t *FJPEGTexture::GetPixels () { if (Pixels == NULL) { @@ -370,7 +370,7 @@ void FJPEGTexture::MakeTexture () jpeg_decompress_struct cinfo; jpeg_error_mgr jerr; - Pixels = new BYTE[Width * Height]; + Pixels = new uint8_t[Width * Height]; memset (Pixels, 0xBA, Width * Height); cinfo.err = jpeg_std_error(&jerr); @@ -392,13 +392,13 @@ void FJPEGTexture::MakeTexture () jpeg_start_decompress(&cinfo); int y = 0; - buff = new BYTE[cinfo.output_width * cinfo.output_components]; + buff = new uint8_t[cinfo.output_width * cinfo.output_components]; while (cinfo.output_scanline < cinfo.output_height) { int num_scanlines = jpeg_read_scanlines(&cinfo, &buff, 1); - BYTE *in = buff; - BYTE *out = Pixels + y; + uint8_t *in = buff; + uint8_t *out = Pixels + y; switch (cinfo.out_color_space) { case JCS_RGB: @@ -494,12 +494,12 @@ int FJPEGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FC jpeg_start_decompress(&cinfo); int yc = 0; - buff = new BYTE[cinfo.output_height * cinfo.output_width * cinfo.output_components]; + buff = new uint8_t[cinfo.output_height * cinfo.output_width * cinfo.output_components]; while (cinfo.output_scanline < cinfo.output_height) { - BYTE * ptr = buff + cinfo.output_width * cinfo.output_components * yc; + uint8_t * ptr = buff + cinfo.output_width * cinfo.output_components * yc; jpeg_read_scanlines(&cinfo, &ptr, 1); yc++; } diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 1a704edf2..63b86d7a9 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -58,7 +58,7 @@ // all and only while initing the textures is beyond me. #ifdef ALPHA -#define SAFESHORT(s) ((short)(((BYTE *)&(s))[0] + ((BYTE *)&(s))[1] * 256)) +#define SAFESHORT(s) ((short)(((uint8_t *)&(s))[0] + ((uint8_t *)&(s))[1] * 256)) #else #define SAFESHORT(s) LittleShort(s) #endif @@ -78,11 +78,11 @@ // struct mappatch_t { - SWORD originx; - SWORD originy; - SWORD patch; - SWORD stepdir; - SWORD colormap; + int16_t originx; + int16_t originy; + int16_t patch; + int16_t stepdir; + int16_t colormap; }; // @@ -91,14 +91,14 @@ struct mappatch_t // struct maptexture_t { - BYTE name[8]; - WORD Flags; // [RH] Was unused - BYTE ScaleX; // [RH] Scaling (8 is normal) - BYTE ScaleY; // [RH] Same as above - SWORD width; - SWORD height; - BYTE columndirectory[4]; // OBSOLETE - SWORD patchcount; + uint8_t name[8]; + uint16_t Flags; // [RH] Was unused + uint8_t ScaleX; // [RH] Scaling (8 is normal) + uint8_t ScaleY; // [RH] Same as above + int16_t width; + int16_t height; + uint8_t columndirectory[4]; // OBSOLETE + int16_t patchcount; mappatch_t patches[1]; }; @@ -108,9 +108,9 @@ struct maptexture_t struct strifemappatch_t { - SWORD originx; - SWORD originy; - SWORD patch; + int16_t originx; + int16_t originy; + int16_t patch; }; // @@ -119,13 +119,13 @@ struct strifemappatch_t // struct strifemaptexture_t { - BYTE name[8]; - WORD Flags; // [RH] Was unused - BYTE ScaleX; // [RH] Scaling (8 is normal) - BYTE ScaleY; // [RH] Same as above - SWORD width; - SWORD height; - SWORD patchcount; + uint8_t name[8]; + uint16_t Flags; // [RH] Was unused + uint8_t ScaleX; // [RH] Scaling (8 is normal) + uint8_t ScaleY; // [RH] Same as above + int16_t width; + int16_t height; + int16_t patchcount; strifemappatch_t patches[1]; }; @@ -155,8 +155,8 @@ public: FMultiPatchTexture (FScanner &sc, int usetype); ~FMultiPatchTexture (); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); FTextureFormat GetFormat(); bool UseBasePalette() ; void Unload (); @@ -169,15 +169,15 @@ public: void ResolvePatches(); protected: - BYTE *Pixels; + uint8_t *Pixels; Span **Spans; int DefinitionLump; struct TexPart { - SWORD OriginX, OriginY; - BYTE Rotate; - BYTE op; + int16_t OriginX, OriginY; + uint8_t Rotate; + uint8_t op; FRemapTable *Translation; PalEntry Blend; FTexture *Texture; @@ -368,7 +368,7 @@ void FMultiPatchTexture::Unload () // //========================================================================== -const BYTE *FMultiPatchTexture::GetPixels () +const uint8_t *FMultiPatchTexture::GetPixels () { if (bRedirect) { @@ -387,7 +387,7 @@ const BYTE *FMultiPatchTexture::GetPixels () // //========================================================================== -const BYTE *FMultiPatchTexture::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FMultiPatchTexture::GetColumn (unsigned int column, const Span **spans_out) { if (bRedirect) { @@ -426,7 +426,7 @@ const BYTE *FMultiPatchTexture::GetColumn (unsigned int column, const Span **spa // //========================================================================== -BYTE *GetBlendMap(PalEntry blend, BYTE *blendwork) +uint8_t *GetBlendMap(PalEntry blend, uint8_t *blendwork) { switch (blend.a==0 ? int(blend) : -1) @@ -486,10 +486,10 @@ void FMultiPatchTexture::MakeTexture () // Add a little extra space at the end if the texture's height is not // a power of 2, in case somebody accidentally makes it repeat vertically. int numpix = Width * Height + (1 << HeightBits) - Height; - BYTE blendwork[256]; + uint8_t blendwork[256]; bool hasTranslucent = false; - Pixels = new BYTE[numpix]; + Pixels = new uint8_t[numpix]; memset (Pixels, 0, numpix); for (int i = 0; i < NumParts; ++i) @@ -506,7 +506,7 @@ void FMultiPatchTexture::MakeTexture () { if (Parts[i].Texture->bHasCanvas) continue; // cannot use camera textures as patch. - BYTE *trans = Parts[i].Translation ? Parts[i].Translation->Remap : NULL; + uint8_t *trans = Parts[i].Translation ? Parts[i].Translation->Remap : NULL; { if (Parts[i].Blend != 0) { @@ -521,13 +521,13 @@ void FMultiPatchTexture::MakeTexture () { // In case there are translucent patches let's do the composition in // True color to keep as much precision as possible before downconverting to the palette. - BYTE *buffer = new BYTE[Width * Height * 4]; + uint8_t *buffer = new uint8_t[Width * Height * 4]; memset(buffer, 0, Width * Height * 4); FillBuffer(buffer, Width * 4, Height, TEX_RGB); for(int y = 0; y < Height; y++) { - BYTE *in = buffer + Width * y * 4; - BYTE *out = Pixels + y; + uint8_t *in = buffer + Width * y * 4; + uint8_t *out = Pixels + y; for (int x = 0; x < Width; x++) { if (*out == 0 && in[3] != 0) @@ -824,7 +824,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d { FPatchLookup *patchlookup = NULL; int i; - DWORD numpatches; + uint32_t numpatches; if (firstdup == 0) { @@ -845,7 +845,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d // Check whether the amount of names reported is correct. int lumplength = Wads.LumpLength(patcheslump); - if (numpatches > DWORD((lumplength-4)/8)) + if (numpatches > uint32_t((lumplength-4)/8)) { Printf("PNAMES lump is shorter than required (%u entries reported but only %d bytes (%d entries) long\n", numpatches, lumplength, (lumplength-4)/8); @@ -856,7 +856,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d // Catalog the patches these textures use so we know which // textures they represent. patchlookup = new FPatchLookup[numpatches]; - for (DWORD i = 0; i < numpatches; ++i) + for (uint32_t i = 0; i < numpatches; ++i) { char pname[9]; pnames.Read(pname, 8); @@ -866,16 +866,16 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d } bool isStrife = false; - const DWORD *maptex, *directory; - DWORD maxoff; + const uint32_t *maptex, *directory; + uint32_t maxoff; int numtextures; - DWORD offset = 0; // Shut up, GCC! + uint32_t offset = 0; // Shut up, GCC! - maptex = (const DWORD *)lumpdata; + maptex = (const uint32_t *)lumpdata; numtextures = LittleLong(*maptex); maxoff = lumpsize; - if (maxoff < DWORD(numtextures+1)*4) + if (maxoff < uint32_t(numtextures+1)*4) { Printf ("Texture directory is too short"); delete[] patchlookup; @@ -893,7 +893,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d return; } - maptexture_t *tex = (maptexture_t *)((BYTE *)maptex + offset); + maptexture_t *tex = (maptexture_t *)((uint8_t *)maptex + offset); // There is bizzarely a Doom editing tool that writes to the // first two elements of columndirectory, so I can't check those. @@ -916,7 +916,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d // The very first texture is just a dummy. Copy its dimensions to texture 0. // It still needs to be created in case someone uses it by name. offset = LittleLong(directory[1]); - const maptexture_t *tex = (const maptexture_t *)((const BYTE *)maptex + offset); + const maptexture_t *tex = (const maptexture_t *)((const uint8_t *)maptex + offset); FDummyTexture *tex0 = static_cast(Textures[0].Texture); tex0->SetSize (SAFESHORT(tex->width), SAFESHORT(tex->height)); } @@ -940,7 +940,7 @@ void FTextureManager::AddTexturesLump (const void *lumpdata, int lumpsize, int d } if (j + 1 == firstdup) { - FMultiPatchTexture *tex = new FMultiPatchTexture ((const BYTE *)maptex + offset, patchlookup, numpatches, isStrife, deflumpnum); + FMultiPatchTexture *tex = new FMultiPatchTexture ((const uint8_t *)maptex + offset, patchlookup, numpatches, isStrife, deflumpnum); if (i == 1 && texture1) { tex->UseType = FTexture::TEX_FirstDefined; diff --git a/src/textures/patchtexture.cpp b/src/textures/patchtexture.cpp index 8388515c0..2393357bd 100644 --- a/src/textures/patchtexture.cpp +++ b/src/textures/patchtexture.cpp @@ -44,8 +44,8 @@ // posts are runs of non masked source pixels struct column_t { - BYTE topdelta; // -1 is the last post in a column - BYTE length; // length data bytes follows + uint8_t topdelta; // -1 is the last post in a column + uint8_t length; // length data bytes follows }; @@ -61,12 +61,12 @@ public: FPatchTexture (int lumpnum, patch_t *header); ~FPatchTexture (); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); void Unload (); protected: - BYTE *Pixels; + uint8_t *Pixels; Span **Spans; bool hackflag; @@ -85,7 +85,7 @@ static bool CheckIfPatch(FileReader & file) { if (file.GetLength() < 13) return false; // minimum length of a valid Doom patch - BYTE *data = new BYTE[file.GetLength()]; + uint8_t *data = new uint8_t[file.GetLength()]; file.Seek(0, SEEK_SET); file.Read(data, file.GetLength()); @@ -105,12 +105,12 @@ static bool CheckIfPatch(FileReader & file) for (x = 0; x < width; ++x) { - DWORD ofs = LittleLong(foo->columnofs[x]); - if (ofs == (DWORD)width * 4 + 8) + uint32_t ofs = LittleLong(foo->columnofs[x]); + if (ofs == (uint32_t)width * 4 + 8) { gapAtStart = false; } - else if (ofs >= (DWORD)(file.GetLength())) // Need one byte for an empty column (but there's patches that don't know that!) + else if (ofs >= (uint32_t)(file.GetLength())) // Need one byte for an empty column (but there's patches that don't know that!) { delete [] data; return false; @@ -193,7 +193,7 @@ void FPatchTexture::Unload () // //========================================================================== -const BYTE *FPatchTexture::GetPixels () +const uint8_t *FPatchTexture::GetPixels () { if (Pixels == NULL) { @@ -208,7 +208,7 @@ const BYTE *FPatchTexture::GetPixels () // //========================================================================== -const BYTE *FPatchTexture::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FPatchTexture::GetColumn (unsigned int column, const Span **spans_out) { if (Pixels == NULL) { @@ -245,7 +245,7 @@ const BYTE *FPatchTexture::GetColumn (unsigned int column, const Span **spans_ou void FPatchTexture::MakeTexture () { - BYTE *remap, remaptable[256]; + uint8_t *remap, remaptable[256]; int numspans; const column_t *maxcol; int x; @@ -253,7 +253,7 @@ void FPatchTexture::MakeTexture () FMemLump lump = Wads.ReadLump (SourceLump); const patch_t *patch = (const patch_t *)lump.GetMem(); - maxcol = (const column_t *)((const BYTE *)patch + Wads.LumpLength (SourceLump) - 3); + maxcol = (const column_t *)((const uint8_t *)patch + Wads.LumpLength (SourceLump) - 3); // Check for badly-sized patches #if 0 // Such textures won't be created so there's no need to check here @@ -285,13 +285,13 @@ void FPatchTexture::MakeTexture () if (hackflag) { - Pixels = new BYTE[Width * Height]; - BYTE *out; + Pixels = new uint8_t[Width * Height]; + uint8_t *out; // Draw the image to the buffer for (x = 0, out = Pixels; x < Width; ++x) { - const BYTE *in = (const BYTE *)patch + LittleLong(patch->columnofs[x]) + 3; + const uint8_t *in = (const uint8_t *)patch + LittleLong(patch->columnofs[x]) + 3; for (int y = Height; y > 0; --y) { @@ -308,14 +308,14 @@ void FPatchTexture::MakeTexture () numspans = Width; - Pixels = new BYTE[numpix]; + Pixels = new uint8_t[numpix]; memset (Pixels, 0, numpix); // Draw the image to the buffer for (x = 0; x < Width; ++x) { - BYTE *outtop = Pixels + x*Height; - const column_t *column = (const column_t *)((const BYTE *)patch + LittleLong(patch->columnofs[x])); + uint8_t *outtop = Pixels + x*Height; + const column_t *column = (const column_t *)((const uint8_t *)patch + LittleLong(patch->columnofs[x])); int top = -1; while (column < maxcol && column->topdelta != 0xFF) @@ -330,7 +330,7 @@ void FPatchTexture::MakeTexture () } int len = column->length; - BYTE *out = outtop + top; + uint8_t *out = outtop + top; if (len != 0) { @@ -342,14 +342,14 @@ void FPatchTexture::MakeTexture () { numspans++; - const BYTE *in = (const BYTE *)column + 3; + const uint8_t *in = (const uint8_t *)column + 3; for (int i = 0; i < len; ++i) { out[i] = remap[in[i]]; } } } - column = (const column_t *)((const BYTE *)column + column->length + 4); + column = (const column_t *)((const uint8_t *)column + column->length + 4); } } } @@ -368,19 +368,19 @@ void FPatchTexture::HackHack (int newheight) // one post, where each post has a supposed length of 0. FMemLump lump = Wads.ReadLump (SourceLump); const patch_t *realpatch = (patch_t *)lump.GetMem(); - const DWORD *cofs = realpatch->columnofs; + const uint32_t *cofs = realpatch->columnofs; int x, x2 = LittleShort(realpatch->width); if (LittleShort(realpatch->height) == 256) { for (x = 0; x < x2; ++x) { - const column_t *col = (column_t*)((BYTE*)realpatch+LittleLong(cofs[x])); + const column_t *col = (column_t*)((uint8_t*)realpatch+LittleLong(cofs[x])); if (col->topdelta != 0 || col->length != 0) { break; // It's not bad! } - col = (column_t *)((BYTE *)col + 256 + 4); + col = (column_t *)((uint8_t *)col + 256 + 4); if (col->topdelta != 0xFF) { break; // More than one post in a column! diff --git a/src/textures/pcxtexture.cpp b/src/textures/pcxtexture.cpp index 6f7c277e3..757877b03 100644 --- a/src/textures/pcxtexture.cpp +++ b/src/textures/pcxtexture.cpp @@ -53,24 +53,24 @@ struct PCXHeader { - BYTE manufacturer; - BYTE version; - BYTE encoding; - BYTE bitsPerPixel; + uint8_t manufacturer; + uint8_t version; + uint8_t encoding; + uint8_t bitsPerPixel; - WORD xmin, ymin; - WORD xmax, ymax; - WORD horzRes, vertRes; + uint16_t xmin, ymin; + uint16_t xmax, ymax; + uint16_t horzRes, vertRes; - BYTE palette[48]; - BYTE reserved; - BYTE numColorPlanes; + uint8_t palette[48]; + uint8_t reserved; + uint8_t numColorPlanes; - WORD bytesPerScanLine; - WORD paletteType; - WORD horzSize, vertSize; + uint16_t bytesPerScanLine; + uint16_t paletteType; + uint16_t horzSize, vertSize; - BYTE padding[54]; + uint8_t padding[54]; } FORCE_PACKED; #pragma pack() @@ -87,8 +87,8 @@ public: FPCXTexture (int lumpnum, PCXHeader &); ~FPCXTexture (); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); void Unload (); FTextureFormat GetFormat (); @@ -96,13 +96,13 @@ public: bool UseBasePalette(); protected: - BYTE *Pixels; + uint8_t *Pixels; Span DummySpans[2]; - void ReadPCX1bit (BYTE *dst, FileReader & lump, PCXHeader *hdr); - void ReadPCX4bits (BYTE *dst, FileReader & lump, PCXHeader *hdr); - void ReadPCX8bits (BYTE *dst, FileReader & lump, PCXHeader *hdr); - void ReadPCX24bits (BYTE *dst, FileReader & lump, PCXHeader *hdr, int planes); + void ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr); + void ReadPCX4bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr); + void ReadPCX8bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr); + void ReadPCX24bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr, int planes); virtual void MakeTexture (); @@ -211,7 +211,7 @@ FTextureFormat FPCXTexture::GetFormat() // //========================================================================== -const BYTE *FPCXTexture::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FPCXTexture::GetColumn (unsigned int column, const Span **spans_out) { if (Pixels == NULL) { @@ -241,7 +241,7 @@ const BYTE *FPCXTexture::GetColumn (unsigned int column, const Span **spans_out) // //========================================================================== -const BYTE *FPCXTexture::GetPixels () +const uint8_t *FPCXTexture::GetPixels () { if (Pixels == NULL) { @@ -256,19 +256,19 @@ const BYTE *FPCXTexture::GetPixels () // //========================================================================== -void FPCXTexture::ReadPCX1bit (BYTE *dst, FileReader & lump, PCXHeader *hdr) +void FPCXTexture::ReadPCX1bit (uint8_t *dst, FileReader & lump, PCXHeader *hdr) { int y, i, bytes; int rle_count = 0; - BYTE rle_value = 0; + uint8_t rle_value = 0; - BYTE * srcp = new BYTE[lump.GetLength() - sizeof(PCXHeader)]; + uint8_t * srcp = new uint8_t[lump.GetLength() - sizeof(PCXHeader)]; lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader)); - BYTE * src = srcp; + uint8_t * src = srcp; for (y = 0; y < Height; ++y) { - BYTE * ptr = &dst[y * Width]; + uint8_t * ptr = &dst[y * Width]; bytes = hdr->bytesPerScanLine; @@ -304,26 +304,26 @@ void FPCXTexture::ReadPCX1bit (BYTE *dst, FileReader & lump, PCXHeader *hdr) // //========================================================================== -void FPCXTexture::ReadPCX4bits (BYTE *dst, FileReader & lump, PCXHeader *hdr) +void FPCXTexture::ReadPCX4bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr) { int rle_count = 0, rle_value = 0; int x, y, c; int bytes; - BYTE * line = new BYTE[hdr->bytesPerScanLine]; - BYTE * colorIndex = new BYTE[Width]; + uint8_t * line = new uint8_t[hdr->bytesPerScanLine]; + uint8_t * colorIndex = new uint8_t[Width]; - BYTE * srcp = new BYTE[lump.GetLength() - sizeof(PCXHeader)]; + uint8_t * srcp = new uint8_t[lump.GetLength() - sizeof(PCXHeader)]; lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader)); - BYTE * src = srcp; + uint8_t * src = srcp; for (y = 0; y < Height; ++y) { - BYTE * ptr = &dst[y * Width]; - memset (ptr, 0, Width * sizeof (BYTE)); + uint8_t * ptr = &dst[y * Width]; + memset (ptr, 0, Width * sizeof (uint8_t)); for (c = 0; c < 4; ++c) { - BYTE * pLine = line; + uint8_t * pLine = line; bytes = hdr->bytesPerScanLine; @@ -367,18 +367,18 @@ void FPCXTexture::ReadPCX4bits (BYTE *dst, FileReader & lump, PCXHeader *hdr) // //========================================================================== -void FPCXTexture::ReadPCX8bits (BYTE *dst, FileReader & lump, PCXHeader *hdr) +void FPCXTexture::ReadPCX8bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr) { int rle_count = 0, rle_value = 0; int y, bytes; - BYTE * srcp = new BYTE[lump.GetLength() - sizeof(PCXHeader)]; + uint8_t * srcp = new uint8_t[lump.GetLength() - sizeof(PCXHeader)]; lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader)); - BYTE * src = srcp; + uint8_t * src = srcp; for (y = 0; y < Height; ++y) { - BYTE * ptr = &dst[y * Width]; + uint8_t * ptr = &dst[y * Width]; bytes = hdr->bytesPerScanLine; while (bytes--) @@ -409,22 +409,22 @@ void FPCXTexture::ReadPCX8bits (BYTE *dst, FileReader & lump, PCXHeader *hdr) // //========================================================================== -void FPCXTexture::ReadPCX24bits (BYTE *dst, FileReader & lump, PCXHeader *hdr, int planes) +void FPCXTexture::ReadPCX24bits (uint8_t *dst, FileReader & lump, PCXHeader *hdr, int planes) { int rle_count = 0, rle_value = 0; int y, c; int bytes; - BYTE * srcp = new BYTE[lump.GetLength() - sizeof(PCXHeader)]; + uint8_t * srcp = new uint8_t[lump.GetLength() - sizeof(PCXHeader)]; lump.Read(srcp, lump.GetLength() - sizeof(PCXHeader)); - BYTE * src = srcp; + uint8_t * src = srcp; for (y = 0; y < Height; ++y) { /* for each color plane */ for (c = 0; c < planes; ++c) { - BYTE * ptr = &dst[y * Width * planes]; + uint8_t * ptr = &dst[y * Width * planes]; bytes = hdr->bytesPerScanLine; while (bytes--) @@ -443,7 +443,7 @@ void FPCXTexture::ReadPCX24bits (BYTE *dst, FileReader & lump, PCXHeader *hdr, i } rle_count--; - ptr[c] = (BYTE)rle_value; + ptr[c] = (uint8_t)rle_value; ptr += planes; } } @@ -459,7 +459,7 @@ void FPCXTexture::ReadPCX24bits (BYTE *dst, FileReader & lump, PCXHeader *hdr, i void FPCXTexture::MakeTexture() { - BYTE PaletteMap[256]; + uint8_t PaletteMap[256]; PCXHeader header; int bitcount; @@ -468,7 +468,7 @@ void FPCXTexture::MakeTexture() lump.Read(&header, sizeof(header)); bitcount = header.bitsPerPixel * header.numColorPlanes; - Pixels = new BYTE[Width*Height]; + Pixels = new uint8_t[Width*Height]; if (bitcount < 24) { @@ -493,14 +493,14 @@ void FPCXTexture::MakeTexture() } else if (bitcount == 8) { - BYTE c; + uint8_t c; lump.Seek(-769, SEEK_END); lump >> c; //if (c !=0x0c) memcpy(PaletteMap, GrayMap, 256); // Fallback for files without palette //else for(int i=0;i<256;i++) { - BYTE r,g,b; + uint8_t r,g,b; lump >> r >> g >> b; PaletteMap[i] = ColorMatcher.Pick(r,g,b); } @@ -513,17 +513,17 @@ void FPCXTexture::MakeTexture() } else { - BYTE *newpix = new BYTE[Width*Height]; + uint8_t *newpix = new uint8_t[Width*Height]; FlipNonSquareBlockRemap (newpix, Pixels, Width, Height, Width, PaletteMap); - BYTE *oldpix = Pixels; + uint8_t *oldpix = Pixels; Pixels = newpix; delete[] oldpix; } } else { - BYTE * buffer = new BYTE[Width*Height * 3]; - BYTE * row = buffer; + uint8_t * buffer = new uint8_t[Width*Height * 3]; + uint8_t * row = buffer; ReadPCX24bits (buffer, lump, &header, 3); for(int y=0; y> c; c=0x0c; // Apparently there's many non-compliant PCXs out there... @@ -592,7 +592,7 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo } else for(int i=0;i<256;i++) { - BYTE r,g,b; + uint8_t r,g,b; lump >> r >> g >> b; pe[i] = PalEntry(255, r,g,b); } @@ -603,7 +603,7 @@ int FPCXTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo } else { - Pixels = new BYTE[Width*Height * 3]; + Pixels = new uint8_t[Width*Height * 3]; ReadPCX24bits (Pixels, lump, &header, 3); bmp->CopyPixelDataRGB(x, y, Pixels, Width, Height, 3, Width*3, rotate, CF_RGB, inf); } diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index 30b7c6445..63948bcea 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -51,11 +51,11 @@ class FPNGTexture : public FTexture { public: - FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height, BYTE bitdepth, BYTE colortype, BYTE interlace); + FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height, uint8_t bitdepth, uint8_t colortype, uint8_t interlace); ~FPNGTexture (); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); void Unload (); FTextureFormat GetFormat (); int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf = NULL); @@ -64,19 +64,19 @@ public: protected: FString SourceFile; - BYTE *Pixels; + uint8_t *Pixels; Span **Spans; FileReader *fr; - BYTE BitDepth; - BYTE ColorType; - BYTE Interlace; + uint8_t BitDepth; + uint8_t ColorType; + uint8_t Interlace; bool HaveTrans; - WORD NonPaletteTrans[3]; + uint16_t NonPaletteTrans[3]; - BYTE *PaletteMap; + uint8_t *PaletteMap; int PaletteSize; - DWORD StartOfIDAT; + uint32_t StartOfIDAT; void MakeTexture (); @@ -94,13 +94,13 @@ FTexture *PNGTexture_TryCreate(FileReader & data, int lumpnum) { union { - DWORD dw; - WORD w[2]; - BYTE b[4]; + uint32_t dw; + uint16_t w[2]; + uint8_t b[4]; } first4bytes; - DWORD width, height; - BYTE bitdepth, colortype, compression, filter, interlace; + uint32_t width, height; + uint8_t bitdepth, colortype, compression, filter, interlace; // This is most likely a PNG, but make sure. (Note that if the // first 4 bytes match, but later bytes don't, we assume it's @@ -159,8 +159,8 @@ FTexture *PNGTexture_TryCreate(FileReader & data, int lumpnum) FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename) { - DWORD width, height; - BYTE bitdepth, colortype, compression, filter, interlace; + uint32_t width, height; + uint8_t bitdepth, colortype, compression, filter, interlace; if (M_FindPNGChunk(png, MAKE_ID('I','H','D','R')) == 0) { @@ -196,18 +196,18 @@ FTexture *PNGTexture_CreateFromFile(PNGHandle *png, const FString &filename) //========================================================================== FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename, int width, int height, - BYTE depth, BYTE colortype, BYTE interlace) + uint8_t depth, uint8_t colortype, uint8_t interlace) : FTexture(NULL, lumpnum), SourceFile(filename), Pixels(0), Spans(0), BitDepth(depth), ColorType(colortype), Interlace(interlace), HaveTrans(false), PaletteMap(0), PaletteSize(0), StartOfIDAT(0) { union { - DWORD palette[256]; - BYTE pngpal[256][3]; + uint32_t palette[256]; + uint8_t pngpal[256][3]; } p; - BYTE trans[256]; - DWORD len, id; + uint8_t trans[256]; + uint32_t len, id; int i; if (lumpnum == -1) fr = &lump; @@ -241,7 +241,7 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename case MAKE_ID('g','r','A','b'): // This is like GRAB found in an ILBM, except coordinates use 4 bytes { - DWORD hotx, hoty; + uint32_t hotx, hoty; int ihotx, ihoty; lump.Read(&hotx, 4); @@ -280,9 +280,9 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename lump.Read (trans, len); HaveTrans = true; // Save for colortype 2 - NonPaletteTrans[0] = WORD(trans[0] * 256 + trans[1]); - NonPaletteTrans[1] = WORD(trans[2] * 256 + trans[3]); - NonPaletteTrans[2] = WORD(trans[4] * 256 + trans[5]); + NonPaletteTrans[0] = uint16_t(trans[0] * 256 + trans[1]); + NonPaletteTrans[1] = uint16_t(trans[2] * 256 + trans[3]); + NonPaletteTrans[2] = uint16_t(trans[4] * 256 + trans[5]); break; case MAKE_ID('a','l','P','h'): @@ -310,7 +310,7 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename { bMasked = true; PaletteSize = 256; - PaletteMap = new BYTE[256]; + PaletteMap = new uint8_t[256]; memcpy (PaletteMap, GrayMap, 256); PaletteMap[NonPaletteTrans[0]] = 0; } @@ -322,7 +322,7 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, const FString &filename break; case 3: // Paletted - PaletteMap = new BYTE[PaletteSize]; + PaletteMap = new uint8_t[PaletteSize]; GPalette.MakeRemap (p.palette, PaletteMap, trans, PaletteSize); for (i = 0; i < PaletteSize; ++i) { @@ -405,7 +405,7 @@ FTextureFormat FPNGTexture::GetFormat() // //========================================================================== -const BYTE *FPNGTexture::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FPNGTexture::GetColumn (unsigned int column, const Span **spans_out) { if (Pixels == NULL) { @@ -439,7 +439,7 @@ const BYTE *FPNGTexture::GetColumn (unsigned int column, const Span **spans_out) // //========================================================================== -const BYTE *FPNGTexture::GetPixels () +const uint8_t *FPNGTexture::GetPixels () { if (Pixels == NULL) { @@ -468,14 +468,14 @@ void FPNGTexture::MakeTexture () lump = fr;// new FileReader(SourceFile.GetChars()); } - Pixels = new BYTE[Width*Height]; + Pixels = new uint8_t[Width*Height]; if (StartOfIDAT == 0) { memset (Pixels, 0x99, Width*Height); } else { - DWORD len, id; + uint32_t len, id; lump->Seek (StartOfIDAT, SEEK_SET); lump->Read(&len, 4); lump->Read(&id, 4); @@ -497,7 +497,7 @@ void FPNGTexture::MakeTexture () } else { - BYTE *newpix = new BYTE[Width*Height]; + uint8_t *newpix = new uint8_t[Width*Height]; if (PaletteMap != NULL) { FlipNonSquareBlockRemap (newpix, Pixels, Width, Height, Width, PaletteMap); @@ -506,7 +506,7 @@ void FPNGTexture::MakeTexture () { FlipNonSquareBlock (newpix, Pixels, Width, Height, Width); } - BYTE *oldpix = Pixels; + uint8_t *oldpix = Pixels; Pixels = newpix; delete[] oldpix; } @@ -514,8 +514,8 @@ void FPNGTexture::MakeTexture () else /* RGB and/or Alpha present */ { int bytesPerPixel = ColorType == 2 ? 3 : ColorType == 4 ? 2 : 4; - BYTE *tempix = new BYTE[Width * Height * bytesPerPixel]; - BYTE *in, *out; + uint8_t *tempix = new uint8_t[Width * Height * bytesPerPixel]; + uint8_t *in, *out; int x, y, pitch, backstep; M_ReadIDAT (lump, tempix, Width, Height, Width*bytesPerPixel, BitDepth, ColorType, Interlace, BigLong((unsigned int)len)); @@ -615,7 +615,7 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo { // Parse pre-IDAT chunks. I skip the CRCs. Is that bad? PalEntry pe[256]; - DWORD len, id; + uint32_t len, id; FileReader *lump; static char bpp[] = {1, 0, 3, 1, 2, 0, 4}; int pixwidth = Width * bpp[ColorType]; @@ -655,7 +655,7 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo case MAKE_ID('t','R','N','S'): if (ColorType == 3) { - for(DWORD i = 0; i < len; i++) + for(uint32_t i = 0; i < len; i++) { (*lump) >> pe[i].a; if (pe[i].a != 0 && pe[i].a != 255) @@ -680,7 +680,7 @@ int FPNGTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo transpal = true; } - BYTE * Pixels = new BYTE[pixwidth * Height]; + uint8_t * Pixels = new uint8_t[pixwidth * Height]; lump->Seek (StartOfIDAT, SEEK_SET); lump->Read(&len, 4); diff --git a/src/textures/rawpagetexture.cpp b/src/textures/rawpagetexture.cpp index 69313fd1c..bdcebbbaf 100644 --- a/src/textures/rawpagetexture.cpp +++ b/src/textures/rawpagetexture.cpp @@ -52,12 +52,12 @@ public: FRawPageTexture (int lumpnum); ~FRawPageTexture (); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); void Unload (); protected: - BYTE *Pixels; + uint8_t *Pixels; static const Span DummySpans[2]; void MakeTexture (); @@ -97,8 +97,8 @@ static bool CheckIfRaw(FileReader & data) for (x = 0; x < width; ++x) { - DWORD ofs = LittleLong(foo->columnofs[x]); - if (ofs == (DWORD)width * 4 + 8) + uint32_t ofs = LittleLong(foo->columnofs[x]); + if (ofs == (uint32_t)width * 4 + 8) { gapAtStart = false; } @@ -110,7 +110,7 @@ static bool CheckIfRaw(FileReader & data) else { // Ensure this column does not extend beyond the end of the patch - const BYTE *foo2 = (const BYTE *)foo; + const uint8_t *foo2 = (const uint8_t *)foo; while (ofs < 64000) { if (foo2[ofs] == 255) @@ -215,7 +215,7 @@ void FRawPageTexture::Unload () // //========================================================================== -const BYTE *FRawPageTexture::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FRawPageTexture::GetColumn (unsigned int column, const Span **spans_out) { if (Pixels == NULL) { @@ -238,7 +238,7 @@ const BYTE *FRawPageTexture::GetColumn (unsigned int column, const Span **spans_ // //========================================================================== -const BYTE *FRawPageTexture::GetPixels () +const uint8_t *FRawPageTexture::GetPixels () { if (Pixels == NULL) { @@ -256,11 +256,11 @@ const BYTE *FRawPageTexture::GetPixels () void FRawPageTexture::MakeTexture () { FMemLump lump = Wads.ReadLump (SourceLump); - const BYTE *source = (const BYTE *)lump.GetMem(); - const BYTE *source_p = source; - BYTE *dest_p; + const uint8_t *source = (const uint8_t *)lump.GetMem(); + const uint8_t *source_p = source; + uint8_t *dest_p; - Pixels = new BYTE[Width*Height]; + Pixels = new uint8_t[Width*Height]; dest_p = Pixels; // Convert the source image from row-major to column-major format diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index 39948f732..4714a7eea 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -764,7 +764,7 @@ void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname) void FTextureManager::AddPatches (int lumpnum) { FWadLump *file = Wads.ReopenLumpNum (lumpnum); - DWORD numpatches, i; + uint32_t numpatches, i; char name[9]; *file >> numpatches; @@ -1181,7 +1181,7 @@ int FTextureManager::CountLumpTextures (int lumpnum) if (lumpnum >= 0) { FWadLump file = Wads.OpenLumpNum (lumpnum); - DWORD numtex; + uint32_t numtex; file >> numtex; return int(numtex) >= 0 ? numtex : 0; diff --git a/src/textures/tgatexture.cpp b/src/textures/tgatexture.cpp index 878b41084..702da82b1 100644 --- a/src/textures/tgatexture.cpp +++ b/src/textures/tgatexture.cpp @@ -53,19 +53,19 @@ struct TGAHeader { - BYTE id_len; - BYTE has_cm; - BYTE img_type; - SWORD cm_first; - SWORD cm_length; - BYTE cm_size; + uint8_t id_len; + uint8_t has_cm; + uint8_t img_type; + int16_t cm_first; + int16_t cm_length; + uint8_t cm_size; - SWORD x_origin; - SWORD y_origin; - SWORD width; - SWORD height; - BYTE bpp; - BYTE img_desc; + int16_t x_origin; + int16_t y_origin; + int16_t width; + int16_t height; + uint8_t bpp; + uint8_t img_desc; }; #pragma pack() @@ -82,8 +82,8 @@ public: FTGATexture (int lumpnum, TGAHeader *); ~FTGATexture (); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); void Unload (); FTextureFormat GetFormat (); @@ -91,10 +91,10 @@ public: bool UseBasePalette(); protected: - BYTE *Pixels; + uint8_t *Pixels; Span **Spans; - void ReadCompressed(FileReader &lump, BYTE * buffer, int bytesperpixel); + void ReadCompressed(FileReader &lump, uint8_t * buffer, int bytesperpixel); virtual void MakeTexture (); @@ -201,7 +201,7 @@ FTextureFormat FTGATexture::GetFormat() // //========================================================================== -const BYTE *FTGATexture::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FTGATexture::GetColumn (unsigned int column, const Span **spans_out) { if (Pixels == NULL) { @@ -235,7 +235,7 @@ const BYTE *FTGATexture::GetColumn (unsigned int column, const Span **spans_out) // //========================================================================== -const BYTE *FTGATexture::GetPixels () +const uint8_t *FTGATexture::GetPixels () { if (Pixels == NULL) { @@ -250,10 +250,10 @@ const BYTE *FTGATexture::GetPixels () // //========================================================================== -void FTGATexture::ReadCompressed(FileReader &lump, BYTE * buffer, int bytesperpixel) +void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytesperpixel) { - BYTE b; - BYTE data[4]; + uint8_t b; + uint8_t data[4]; int Size = Width * Height; while (Size > 0) @@ -289,14 +289,14 @@ void FTGATexture::ReadCompressed(FileReader &lump, BYTE * buffer, int bytesperpi void FTGATexture::MakeTexture () { - BYTE PaletteMap[256]; + uint8_t PaletteMap[256]; FWadLump lump = Wads.OpenLumpNum (SourceLump); TGAHeader hdr; - WORD w; - BYTE r,g,b,a; - BYTE * buffer; + uint16_t w; + uint8_t r,g,b,a; + uint8_t * buffer; - Pixels = new BYTE[Width*Height]; + Pixels = new uint8_t[Width*Height]; lump.Read(&hdr, sizeof(hdr)); lump.Seek(hdr.id_len, SEEK_CUR); @@ -340,7 +340,7 @@ void FTGATexture::MakeTexture () } int Size = Width * Height * (hdr.bpp>>3); - buffer = new BYTE[Size]; + buffer = new uint8_t[Size]; if (hdr.img_type < 4) // uncompressed { @@ -351,7 +351,7 @@ void FTGATexture::MakeTexture () ReadCompressed(lump, buffer, hdr.bpp>>3); } - BYTE * ptr = buffer; + uint8_t * ptr = buffer; int step_x = (hdr.bpp>>3); int Pitch = Width * step_x; @@ -373,7 +373,7 @@ void FTGATexture::MakeTexture () case 1: // paletted for(int y=0;y>=1; for(int y=0;y>2][p[1]>>2][p[0]>>2]; @@ -417,7 +417,7 @@ void FTGATexture::MakeTexture () { for(int y=0;y>2][p[1]>>2][p[0]>>2]; @@ -429,7 +429,7 @@ void FTGATexture::MakeTexture () { for(int y=0;y= 128? RGB256k.RGB[p[2]>>2][p[1]>>2][p[0]>>2] : 0; @@ -450,7 +450,7 @@ void FTGATexture::MakeTexture () case 8: for(int y=0;y>3); - sbuffer = new BYTE[Size]; + sbuffer = new uint8_t[Size]; if (hdr.img_type < 4) // uncompressed { @@ -553,7 +553,7 @@ int FTGATexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCo ReadCompressed(lump, sbuffer, hdr.bpp>>3); } - BYTE * ptr = sbuffer; + uint8_t * ptr = sbuffer; int step_x = (hdr.bpp>>3); int Pitch = Width * step_x; diff --git a/src/tflags.h b/src/tflags.h index a7536ab01..203fa70e6 100644 --- a/src/tflags.h +++ b/src/tflags.h @@ -40,7 +40,7 @@ * A Qt-inspired type-safe flagset type. * * T is the enum type of individual flags, - * TT is the underlying integer type used (defaults to DWORD) + * TT is the underlying integer type used (defaults to uint32_t) */ template class TFlags diff --git a/src/timidity/gf1patch.h b/src/timidity/gf1patch.h index f652e1304..b030bb6e0 100644 --- a/src/timidity/gf1patch.h +++ b/src/timidity/gf1patch.h @@ -29,15 +29,15 @@ struct GF1PatchHeader BYTE Instruments; BYTE Voices; BYTE Channels; - WORD WaveForms; - WORD MasterVolume; + uint16_t WaveForms; + uint16_t MasterVolume; DWORD DataSize; BYTE Reserved[PATCH_HEADER_RESERVED_SIZE]; } GCC_PACKED; struct GF1InstrumentData { - WORD Instrument; + uint16_t Instrument; char InstrumentName[INST_NAME_SIZE]; int InstrumentSize; BYTE Layers; @@ -60,11 +60,11 @@ struct GF1PatchData int WaveSize; int StartLoop; int EndLoop; - WORD SampleRate; + uint16_t SampleRate; int LowFrequency; int HighFrequency; int RootFrequency; - SWORD Tune; + int16_t Tune; BYTE Balance; BYTE EnvelopeRate[ENVELOPES]; BYTE EnvelopeOffset[ENVELOPES]; @@ -75,8 +75,8 @@ struct GF1PatchData BYTE VibratoRate; BYTE VibratoDepth; BYTE Modes; - SWORD ScaleFrequency; - WORD ScaleFactor; /* From 0 to 2048 or 0 to 2 */ + int16_t ScaleFrequency; + uint16_t ScaleFactor; /* From 0 to 2048 or 0 to 2 */ BYTE Reserved[PATCH_DATA_RESERVED_SIZE]; } GCC_PACKED; #ifdef _MSC_VER diff --git a/src/timidity/instrum.cpp b/src/timidity/instrum.cpp index 6cce239a8..e4d591879 100644 --- a/src/timidity/instrum.cpp +++ b/src/timidity/instrum.cpp @@ -511,7 +511,7 @@ void convert_sample_data(Sample *sp, const void *data) case PATCH_16: { /* 16-bit, signed */ - SWORD *cp = (SWORD *)data; + int16_t *cp = (int16_t *)data; /* Convert these to samples */ sp->data_length >>= 1; sp->loop_start >>= 1; @@ -534,7 +534,7 @@ void convert_sample_data(Sample *sp, const void *data) case PATCH_16 | PATCH_UNSIGNED: { /* 16-bit, unsigned */ - WORD *cp = (WORD *)data; + auto *cp = (uint16_t *)data; /* Convert these to samples */ sp->data_length >>= 1; sp->loop_start >>= 1; diff --git a/src/timidity/instrum_dls.cpp b/src/timidity/instrum_dls.cpp index c882cd84e..06ce83df2 100644 --- a/src/timidity/instrum_dls.cpp +++ b/src/timidity/instrum_dls.cpp @@ -56,9 +56,9 @@ struct RIFF_Chunk } } - DWORD magic; - DWORD length; - DWORD subtype; + uint32_t magic; + uint32_t length; + uint32_t subtype; BYTE *data; RIFF_Chunk *child; RIFF_Chunk *next; @@ -75,20 +75,20 @@ void PrintRIFF(RIFF_Chunk *chunk, int level); #define RIFF MAKE_ID('R','I','F','F') #define LIST MAKE_ID('L','I','S','T') -static bool ChunkHasSubType(DWORD magic) +static bool ChunkHasSubType(uint32_t magic) { return (magic == RIFF || magic == LIST); } -static int ChunkHasSubChunks(DWORD magic) +static int ChunkHasSubChunks(uint32_t magic) { return (magic == RIFF || magic == LIST); } -static void LoadSubChunks(RIFF_Chunk *chunk, BYTE *data, DWORD left) +static void LoadSubChunks(RIFF_Chunk *chunk, BYTE *data, uint32_t left) { BYTE *subchunkData; - DWORD subchunkDataLen; + uint32_t subchunkDataLen; while ( left > 8 ) { RIFF_Chunk *child = new RIFF_Chunk; @@ -102,10 +102,10 @@ static void LoadSubChunks(RIFF_Chunk *chunk, BYTE *data, DWORD left) chunk->child = child; } - child->magic = *(DWORD *)data; + child->magic = *(uint32_t *)data; data += 4; left -= 4; - child->length = LittleLong(*(DWORD *)data); + child->length = LittleLong(*(uint32_t *)data); data += 4; left -= 4; child->data = data; @@ -117,7 +117,7 @@ static void LoadSubChunks(RIFF_Chunk *chunk, BYTE *data, DWORD left) subchunkData = child->data; subchunkDataLen = child->length; if ( ChunkHasSubType(child->magic) && subchunkDataLen >= 4 ) { - child->subtype = *(DWORD *)subchunkData; + child->subtype = *(uint32_t *)subchunkData; subchunkData += 4; subchunkDataLen -= 4; } @@ -134,7 +134,7 @@ RIFF_Chunk *LoadRIFF(FILE *src) { RIFF_Chunk *chunk; BYTE *subchunkData; - DWORD subchunkDataLen; + uint32_t subchunkDataLen; /* Allocate the chunk structure */ chunk = new RIFF_Chunk; @@ -162,7 +162,7 @@ RIFF_Chunk *LoadRIFF(FILE *src) subchunkData = chunk->data; subchunkDataLen = chunk->length; if ( ChunkHasSubType(chunk->magic) && subchunkDataLen >= 4 ) { - chunk->subtype = *(DWORD *)subchunkData; + chunk->subtype = *(uint32_t *)subchunkData; subchunkData += 4; subchunkDataLen -= 4; } @@ -251,10 +251,10 @@ http://www.midi.org/about-midi/dls/dlsspec.shtml /* Some typedefs so the public dls headers don't need to be modified */ #define FAR -typedef SWORD SHORT; -typedef WORD USHORT; +typedef int16_t SHORT; +typedef uint16_t USHORT; typedef int32_t LONG; -typedef DWORD ULONG; +typedef uint32_t ULONG; #define mmioFOURCC MAKE_ID #define DEFINE_GUID(A, B, C, E, F, G, H, I, J, K, L, M) @@ -263,19 +263,19 @@ typedef DWORD ULONG; struct WaveFMT { - WORD wFormatTag; - WORD wChannels; - DWORD dwSamplesPerSec; - DWORD dwAvgBytesPerSec; - WORD wBlockAlign; - WORD wBitsPerSample; + uint16_t wFormatTag; + uint16_t wChannels; + uint32_t dwSamplesPerSec; + uint32_t dwAvgBytesPerSec; + uint16_t wBlockAlign; + uint16_t wBitsPerSample; }; struct DLS_Wave { WaveFMT *format; BYTE *data; - DWORD length; + uint32_t length; WSMPL *wsmp; WLOOP *wsmp_loop; }; @@ -303,7 +303,7 @@ struct DLS_Data { RIFF_Chunk *chunk; - DWORD cInstruments; + uint32_t cInstruments; DLS_Instrument *instruments; POOLTABLE *ptbl; @@ -367,7 +367,7 @@ static void AllocRegions(DLS_Instrument *instrument) static void FreeInstruments(DLS_Data *data) { if ( data->instruments ) { - DWORD i; + uint32_t i; for ( i = 0; i < data->cInstruments; ++i ) { FreeRegions(&data->instruments[i]); } @@ -404,7 +404,7 @@ static void AllocWaveList(DLS_Data *data) static void Parse_colh(DLS_Data *data, RIFF_Chunk *chunk) { - data->cInstruments = LittleLong(*(DWORD *)chunk->data); + data->cInstruments = LittleLong(*(uint32_t *)chunk->data); AllocInstruments(data); } @@ -442,7 +442,7 @@ static void Parse_wlnk(DLS_Data *data, RIFF_Chunk *chunk, DLS_Region *region) static void Parse_wsmp(DLS_Data *data, RIFF_Chunk *chunk, WSMPL **wsmp_ptr, WLOOP **wsmp_loop_ptr) { - DWORD i; + uint32_t i; WSMPL *wsmp = (WSMPL *)chunk->data; WLOOP *loop; wsmp->cbSize = LittleLong(wsmp->cbSize); @@ -465,7 +465,7 @@ static void Parse_wsmp(DLS_Data *data, RIFF_Chunk *chunk, WSMPL **wsmp_ptr, WLOO static void Parse_art(DLS_Data *data, RIFF_Chunk *chunk, CONNECTIONLIST **art_ptr, CONNECTION **artList_ptr) { - DWORD i; + uint32_t i; CONNECTIONLIST *art = (CONNECTIONLIST *)chunk->data; CONNECTION *artList; art->cbSize = LittleLong(art->cbSize); @@ -487,7 +487,7 @@ static void Parse_lart(DLS_Data *data, RIFF_Chunk *chunk, CONNECTIONLIST **conn_ { /* FIXME: This only supports one set of connections */ for ( chunk = chunk->child; chunk; chunk = chunk->next ) { - DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; + uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; switch(magic) { case FOURCC_ART1: case FOURCC_ART2: @@ -500,7 +500,7 @@ static void Parse_lart(DLS_Data *data, RIFF_Chunk *chunk, CONNECTIONLIST **conn_ static void Parse_rgn(DLS_Data *data, RIFF_Chunk *chunk, DLS_Region *region) { for ( chunk = chunk->child; chunk; chunk = chunk->next ) { - DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; + uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; switch(magic) { case FOURCC_RGNH: Parse_rgnh(data, chunk, region); @@ -521,9 +521,9 @@ static void Parse_rgn(DLS_Data *data, RIFF_Chunk *chunk, DLS_Region *region) static void Parse_lrgn(DLS_Data *data, RIFF_Chunk *chunk, DLS_Instrument *instrument) { - DWORD region = 0; + uint32_t region = 0; for ( chunk = chunk->child; chunk; chunk = chunk->next ) { - DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; + uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; switch(magic) { case FOURCC_RGN: case FOURCC_RGN2: @@ -538,7 +538,7 @@ static void Parse_lrgn(DLS_Data *data, RIFF_Chunk *chunk, DLS_Instrument *instru static void Parse_INFO_INS(DLS_Data *data, RIFF_Chunk *chunk, DLS_Instrument *instrument) { for ( chunk = chunk->child; chunk; chunk = chunk->next ) { - DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; + uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; switch(magic) { case FOURCC_INAM: /* Name */ instrument->name = (const char *)chunk->data; @@ -550,7 +550,7 @@ static void Parse_INFO_INS(DLS_Data *data, RIFF_Chunk *chunk, DLS_Instrument *in static void Parse_ins(DLS_Data *data, RIFF_Chunk *chunk, DLS_Instrument *instrument) { for ( chunk = chunk->child; chunk; chunk = chunk->next ) { - DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; + uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; switch(magic) { case FOURCC_INSH: Parse_insh(data, chunk, instrument); @@ -571,9 +571,9 @@ static void Parse_ins(DLS_Data *data, RIFF_Chunk *chunk, DLS_Instrument *instrum static void Parse_lins(DLS_Data *data, RIFF_Chunk *chunk) { - DWORD instrument = 0; + uint32_t instrument = 0; for ( chunk = chunk->child; chunk; chunk = chunk->next ) { - DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; + uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; switch(magic) { case FOURCC_INS: if ( instrument < data->cInstruments ) { @@ -586,7 +586,7 @@ static void Parse_lins(DLS_Data *data, RIFF_Chunk *chunk) static void Parse_ptbl(DLS_Data *data, RIFF_Chunk *chunk) { - DWORD i; + uint32_t i; POOLTABLE *ptbl = (POOLTABLE *)chunk->data; ptbl->cbSize = LittleLong(ptbl->cbSize); ptbl->cCues = LittleLong(ptbl->cCues); @@ -619,7 +619,7 @@ static void Parse_data(DLS_Data *data, RIFF_Chunk *chunk, DLS_Wave *wave) static void Parse_wave(DLS_Data *data, RIFF_Chunk *chunk, DLS_Wave *wave) { for ( chunk = chunk->child; chunk; chunk = chunk->next ) { - DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; + uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; switch(magic) { case FOURCC_FMT: Parse_fmt(data, chunk, wave); @@ -636,9 +636,9 @@ static void Parse_wave(DLS_Data *data, RIFF_Chunk *chunk, DLS_Wave *wave) static void Parse_wvpl(DLS_Data *data, RIFF_Chunk *chunk) { - DWORD wave = 0; + uint32_t wave = 0; for ( chunk = chunk->child; chunk; chunk = chunk->next ) { - DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; + uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; switch(magic) { case FOURCC_wave: if ( wave < data->ptbl->cCues ) { @@ -652,7 +652,7 @@ static void Parse_wvpl(DLS_Data *data, RIFF_Chunk *chunk) static void Parse_INFO_DLS(DLS_Data *data, RIFF_Chunk *chunk) { for ( chunk = chunk->child; chunk; chunk = chunk->next ) { - DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; + uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; switch(magic) { case FOURCC_IARL: /* Archival Location */ break; @@ -713,7 +713,7 @@ DLS_Data *LoadDLS(FILE *src) } for ( chunk = data->chunk->child; chunk; chunk = chunk->next ) { - DWORD magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; + uint32_t magic = (chunk->magic == FOURCC_LIST) ? chunk->subtype : chunk->magic; switch(magic) { case FOURCC_COLH: Parse_colh(data, chunk); @@ -883,7 +883,7 @@ static const char *DestinationToString(USHORT usDestination) static void PrintArt(const char *type, CONNECTIONLIST *art, CONNECTION *artList) { - DWORD i; + uint32_t i; printf("%s Connections:\n", type); for ( i = 0; i < art->cConnections; ++i ) { printf(" Source: %s, Control: %s, Destination: %s, Transform: %s, Scale: %d\n", @@ -895,14 +895,14 @@ static void PrintArt(const char *type, CONNECTIONLIST *art, CONNECTION *artList) } } -static void PrintWave(DLS_Wave *wave, DWORD index) +static void PrintWave(DLS_Wave *wave, uint32_t index) { WaveFMT *format = wave->format; if ( format ) { printf(" Wave %u: Format: %hu, %hu channels, %u Hz, %hu bits (length = %u)\n", index, format->wFormatTag, format->wChannels, format->dwSamplesPerSec, format->wBitsPerSample, wave->length); } if ( wave->wsmp ) { - DWORD i; + uint32_t i; printf(" wsmp->usUnityNote = %hu\n", wave->wsmp->usUnityNote); printf(" wsmp->sFineTune = %hd\n", wave->wsmp->sFineTune); printf(" wsmp->lAttenuation = %d\n", wave->wsmp->lAttenuation); @@ -917,7 +917,7 @@ static void PrintWave(DLS_Wave *wave, DWORD index) } } -static void PrintRegion(DLS_Region *region, DWORD index) +static void PrintRegion(DLS_Region *region, uint32_t index) { printf(" Region %u:\n", index); if ( region->header ) { @@ -933,7 +933,7 @@ static void PrintRegion(DLS_Region *region, DWORD index) printf(" wlnk->ulTableIndex = %u\n", region->wlnk->ulTableIndex); } if ( region->wsmp ) { - DWORD i; + uint32_t i; printf(" wsmp->usUnityNote = %hu\n", region->wsmp->usUnityNote); printf(" wsmp->sFineTune = %hd\n", region->wsmp->sFineTune); printf(" wsmp->lAttenuation = %d\n", region->wsmp->lAttenuation); @@ -951,14 +951,14 @@ static void PrintRegion(DLS_Region *region, DWORD index) } } -static void PrintInstrument(DLS_Instrument *instrument, DWORD index) +static void PrintInstrument(DLS_Instrument *instrument, uint32_t index) { printf("Instrument %u:\n", index); if ( instrument->name ) { printf(" Name: %s\n", instrument->name); } if ( instrument->header ) { - DWORD i; + uint32_t i; printf(" ulBank = 0x%8.8x\n", instrument->header->Locale.ulBank); printf(" ulInstrument = %u\n", instrument->header->Locale.ulInstrument); printf(" Regions: %u\n", instrument->header->cRegions); @@ -976,13 +976,13 @@ void PrintDLS(DLS_Data *data) printf("DLS Data:\n"); printf("cInstruments = %u\n", data->cInstruments); if ( data->instruments ) { - DWORD i; + uint32_t i; for ( i = 0; i < data->cInstruments; ++i ) { PrintInstrument(&data->instruments[i], i); } } if ( data->ptbl && data->ptbl->cCues > 0 ) { - DWORD i; + uint32_t i; printf("Cues: "); for ( i = 0; i < data->ptbl->cCues; ++i ) { if ( i > 0 ) { @@ -993,7 +993,7 @@ void PrintDLS(DLS_Data *data) printf("\n"); } if ( data->waveList && data->ptbl ) { - DWORD i; + uint32_t i; printf("Waves:\n"); for ( i = 0; i < data->ptbl->cCues; ++i ) { PrintWave(&data->waveList[i], i); @@ -1116,7 +1116,7 @@ static int load_connection(ULONG cConnections, CONNECTION *artList, USHORT desti return value; } -static void load_region_dls(Renderer *song, Sample *sample, DLS_Instrument *ins, DWORD index) +static void load_region_dls(Renderer *song, Sample *sample, DLS_Instrument *ins, uint32_t index) { DLS_Region *rgn = &ins->regions[index]; DLS_Wave *wave = &song->patches->waveList[rgn->wlnk->ulTableIndex]; @@ -1187,7 +1187,7 @@ static void load_region_dls(Renderer *song, Sample *sample, DLS_Instrument *ins, Instrument *load_instrument_dls(Renderer *song, int drum, int bank, int instrument) { Instrument *inst; - DWORD i; + uint32_t i; DLS_Instrument *dls_ins = NULL; if (song->patches == NULL) diff --git a/src/timidity/instrum_sf2.cpp b/src/timidity/instrum_sf2.cpp index 2e9d7d0c0..fe839ce45 100644 --- a/src/timidity/instrum_sf2.cpp +++ b/src/timidity/instrum_sf2.cpp @@ -192,7 +192,7 @@ ListHandler PdtaHandlers[] = { 0, 0 } }; -static double timecent_to_sec(SWORD timecent) +static double timecent_to_sec(int16_t timecent) { if (timecent == -32768) return 0; @@ -250,7 +250,7 @@ static inline int read_char(FileReader *f) static inline int read_uword(FileReader *f) { - WORD x; + uint16_t x; if (f->Read(&x, 2) != 2) { throw CIOErr(); @@ -260,7 +260,7 @@ static inline int read_uword(FileReader *f) static inline int read_sword(FileReader *f) { - SWORD x; + int16_t x; if (f->Read(&x, 2) != 2) { throw CIOErr(); @@ -317,7 +317,7 @@ static void check_list(FileReader *f, DWORD id, DWORD filelen, DWORD &chunklen) static void ParseIfil(SFFile *sf2, FileReader *f, DWORD chunkid, DWORD chunklen) { - WORD major, minor; + uint16_t major, minor; if (chunklen != 4) { @@ -473,7 +473,7 @@ static void ParsePhdr(SFFile *sf2, FileReader *f, DWORD chunkid, DWORD chunklen) static void ParseBag(SFFile *sf2, FileReader *f, DWORD chunkid, DWORD chunklen) { SFBag *bags, *bag; - WORD prev_mod = 0; + uint16_t prev_mod = 0; int numbags; int i; @@ -513,7 +513,7 @@ static void ParseBag(SFFile *sf2, FileReader *f, DWORD chunkid, DWORD chunklen) for (bag = bags, i = numbags; i != 0; --i, ++bag) { bag->GenIndex = read_uword(f); - WORD mod = read_uword(f); + uint16_t mod = read_uword(f); // Section 7.3, page 22: // If the generator or modulator indices are non-monotonic or do not // match the size of the respective PGEN or PMOD sub-chunks, the file @@ -1165,7 +1165,7 @@ void SFFile::SetInstrumentGenerators(SFGenComposite *composite, int start, int s continue; } // Set the generator - ((WORD *)composite)[GenDefs[gen->Oper].StructIndex] = gen->uAmount; + ((uint16_t *)composite)[GenDefs[gen->Oper].StructIndex] = gen->uAmount; if (gen->Oper == GEN_sampleID) { // Anything past sampleID is ignored. break; @@ -1209,7 +1209,7 @@ void SFFile::AddPresetGenerators(SFGenComposite *composite, int start, int stop, continue; } // Add to instrument/default generator. - int added = ((SWORD *)composite)[def->StructIndex] + gen->Amount; + int added = ((int16_t *)composite)[def->StructIndex] + gen->Amount; // Clamp to proper range. if (added <= -32768 && def->Flags & GENF_32768_Ok) { @@ -1219,7 +1219,7 @@ void SFFile::AddPresetGenerators(SFGenComposite *composite, int start, int stop, { added = clamp(added, def->Min, def->Max); } - ((SWORD *)composite)[def->StructIndex] = added; + ((int16_t *)composite)[def->StructIndex] = added; gen_set[gen->Oper] = true; if (gen->Oper == GEN_instrument) { // Anything past the instrument generator is ignored. @@ -1513,7 +1513,7 @@ void SFFile::LoadSample(SFSample *sample) // Load 16-bit sample data. for (i = 0; i < sample->End - sample->Start; ++i) { - SWORD samp; + int16_t samp; *fp >> samp; sample->InMemoryData[i] = samp / 32768.f; } diff --git a/src/timidity/resample.cpp b/src/timidity/resample.cpp index 649262a14..bd45271e1 100644 --- a/src/timidity/resample.cpp +++ b/src/timidity/resample.cpp @@ -485,7 +485,7 @@ static sample_t *rs_vib_bidir(sample_t *resample_buffer, float rate, Voice *vp, sample_t *resample_voice(Renderer *song, Voice *vp, int *countptr) { int ofs; - WORD modes; + uint16_t modes; if (vp->sample->sample_rate == 0) { diff --git a/src/timidity/sf2.h b/src/timidity/sf2.h index 122aff99e..45dec4ae0 100644 --- a/src/timidity/sf2.h +++ b/src/timidity/sf2.h @@ -1,4 +1,4 @@ -typedef WORD SFGenerator; +typedef uint16_t SFGenerator; struct SFRange { @@ -11,16 +11,16 @@ struct SFPreset char Name[21]; BYTE LoadOrder:7; BYTE bHasGlobalZone:1; - WORD Program; - WORD Bank; - WORD BagIndex; + uint16_t Program; + uint16_t Bank; + uint16_t BagIndex; /* Don't care about library, genre, and morphology */ }; struct SFBag { - WORD GenIndex; -// WORD ModIndex; // If I am feeling ambitious, I might add support for modulators some day. + uint16_t GenIndex; +// uint16_t ModIndex; // If I am feeling ambitious, I might add support for modulators some day. SFRange KeyRange; SFRange VelRange; int Target; // Either an instrument or sample index @@ -31,7 +31,7 @@ struct SFInst char Name[21]; BYTE Pad:7; BYTE bHasGlobalZone:1; - WORD BagIndex; + uint16_t BagIndex; }; struct SFSample @@ -44,8 +44,8 @@ struct SFSample DWORD SampleRate; BYTE OriginalPitch; SBYTE PitchCorrection; - WORD SampleLink; - WORD SampleType; + uint16_t SampleLink; + uint16_t SampleType; char Name[21]; }; @@ -68,8 +68,8 @@ struct SFGenList union { SFRange Range; - SWORD Amount; - WORD uAmount; + int16_t Amount; + uint16_t uAmount; }; }; @@ -142,20 +142,20 @@ enum struct SFModulator { - WORD Index:7; - WORD CC:1; - WORD Dir:1; /* 0 = min->max, 1 = max->min */ - WORD Polarity:1; /* 0 = unipolar, 1 = bipolar */ - WORD Type:6; + uint16_t Index:7; + uint16_t CC:1; + uint16_t Dir:1; /* 0 = min->max, 1 = max->min */ + uint16_t Polarity:1; /* 0 = unipolar, 1 = bipolar */ + uint16_t Type:6; }; struct SFModList { SFModulator SrcOper; SFGenerator DestOper; - SWORD Amount; + int16_t Amount; SFModulator AmtSrcOper; - WORD Transform; + uint16_t Transform; }; // Modulator sources when CC is 0 @@ -206,55 +206,55 @@ struct SFGenComposite SFRange velRange; union { - WORD instrument; // At preset level - WORD sampleID; // At instrument level + uint16_t instrument; // At preset level + uint16_t sampleID; // At instrument level }; - SWORD modLfoToPitch; - SWORD vibLfoToPitch; - SWORD modEnvToPitch; - SWORD initialFilterFc; - SWORD initialFilterQ; - SWORD modLfoToFilterFc; - SWORD modEnvToFilterFc; - SWORD modLfoToVolume; - SWORD chorusEffectsSend; - SWORD reverbEffectsSend; - SWORD pan; - SWORD delayModLFO; - SWORD freqModLFO; - SWORD delayVibLFO; - SWORD freqVibLFO; - SWORD delayModEnv; - SWORD attackModEnv; - SWORD holdModEnv; - SWORD decayModEnv; - SWORD sustainModEnv; - SWORD releaseModEnv; - SWORD keynumToModEnvHold; - SWORD keynumToModEnvDecay; - SWORD delayVolEnv; - SWORD attackVolEnv; - SWORD holdVolEnv; - SWORD decayVolEnv; - SWORD sustainVolEnv; - SWORD releaseVolEnv; - SWORD keynumToVolEnvHold; - SWORD keynumToVolEnvDecay; - SWORD initialAttenuation; - SWORD coarseTune; - SWORD fineTune; - SWORD scaleTuning; + int16_t modLfoToPitch; + int16_t vibLfoToPitch; + int16_t modEnvToPitch; + int16_t initialFilterFc; + int16_t initialFilterQ; + int16_t modLfoToFilterFc; + int16_t modEnvToFilterFc; + int16_t modLfoToVolume; + int16_t chorusEffectsSend; + int16_t reverbEffectsSend; + int16_t pan; + int16_t delayModLFO; + int16_t freqModLFO; + int16_t delayVibLFO; + int16_t freqVibLFO; + int16_t delayModEnv; + int16_t attackModEnv; + int16_t holdModEnv; + int16_t decayModEnv; + int16_t sustainModEnv; + int16_t releaseModEnv; + int16_t keynumToModEnvHold; + int16_t keynumToModEnvDecay; + int16_t delayVolEnv; + int16_t attackVolEnv; + int16_t holdVolEnv; + int16_t decayVolEnv; + int16_t sustainVolEnv; + int16_t releaseVolEnv; + int16_t keynumToVolEnvHold; + int16_t keynumToVolEnvDecay; + int16_t initialAttenuation; + int16_t coarseTune; + int16_t fineTune; + int16_t scaleTuning; // The following are only for instruments: - SWORD startAddrsOffset, startAddrsCoarseOffset; - SWORD endAddrsOffset, endAddrsCoarseOffset; - SWORD startLoopAddrsOffset, startLoopAddrsCoarseOffset; - SWORD endLoopAddrsOffset, endLoopAddrsCoarseOffset; - SWORD keynum; - SWORD velocity; - WORD sampleModes; - SWORD exclusiveClass; - SWORD overridingRootKey; + int16_t startAddrsOffset, startAddrsCoarseOffset; + int16_t endAddrsOffset, endAddrsCoarseOffset; + int16_t startLoopAddrsOffset, startLoopAddrsCoarseOffset; + int16_t endLoopAddrsOffset, endLoopAddrsCoarseOffset; + int16_t keynum; + int16_t velocity; + uint16_t sampleModes; + int16_t exclusiveClass; + int16_t overridingRootKey; }; // Intermediate percussion representation diff --git a/src/timidity/timidity.h b/src/timidity/timidity.h index b3a1e2c80..28f4908af 100644 --- a/src/timidity/timidity.h +++ b/src/timidity/timidity.h @@ -240,13 +240,13 @@ struct Sample tremolo_depth, vibrato_depth, low_vel, high_vel, type; - WORD + uint16_t modes; - SWORD + int16_t panning; - WORD + uint16_t scale_factor, key_group; - SWORD + int16_t scale_note; bool self_nonexclusive; @@ -254,7 +254,7 @@ struct Sample left_offset, right_offset; // SF2 stuff - SWORD tune; + int16_t tune; SBYTE velocity; float initial_attenuation; @@ -432,7 +432,7 @@ struct Channel volume, expression; SBYTE panning; - WORD + uint16_t rpn, nrpn; bool nrpn_mode; diff --git a/src/v_blend.cpp b/src/v_blend.cpp index 874e81ca1..7ea4a4fdf 100644 --- a/src/v_blend.cpp +++ b/src/v_blend.cpp @@ -58,7 +58,7 @@ CVAR( Float, pickup_fade_scalar, 1.0f, CVAR_ARCHIVE ) // [SP] Uses same logic as // [RH] Amount of red flash for up to 114 damage points. Calculated by hand // using a logarithmic scale and my trusty HP48G. -static BYTE DamageToAlpha[114] = +static uint8_t DamageToAlpha[114] = { 0, 8, 16, 23, 30, 36, 42, 47, 53, 58, 62, 67, 71, 75, 79, 83, 87, 90, 94, 97, 100, 103, 107, 109, 112, 115, 118, 120, 123, 125, diff --git a/src/v_font.cpp b/src/v_font.cpp index 7bd855cb5..0bdbf0749 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -101,15 +101,15 @@ The FON2 header is followed by variable length data: #define DEFAULT_LOG_COLOR PalEntry(223,223,223) // TYPES ------------------------------------------------------------------- -void RecordTextureColors (FTexture *pic, BYTE *colorsused); +void RecordTextureColors (FTexture *pic, uint8_t *colorsused); // This structure is used by BuildTranslations() to hold color information. struct TranslationParm { short RangeStart; // First level for this range short RangeEnd; // Last level for this range - BYTE Start[3]; // Start color for this range - BYTE End[3]; // End color for this range + uint8_t Start[3]; // Start color for this range + uint8_t End[3]; // End color for this range }; struct TranslationMap @@ -126,12 +126,12 @@ public: protected: void CheckFON1Chars (double *luminosity); void BuildTranslations2 (); - void FixupPalette (BYTE *identity, double *luminosity, const BYTE *palette, + void FixupPalette (uint8_t *identity, double *luminosity, const uint8_t *palette, bool rescale, PalEntry *out_palette); void LoadTranslations (); - void LoadFON1 (int lump, const BYTE *data); - void LoadFON2 (int lump, const BYTE *data); - void LoadBMF (int lump, const BYTE *data); + void LoadFON1 (int lump, const uint8_t *data); + void LoadFON2 (int lump, const uint8_t *data); + void LoadBMF (int lump, const uint8_t *data); void CreateFontFromPic (FTextureID picnum); static int BMFCompare(const void *a, const void *b); @@ -142,7 +142,7 @@ protected: FONT2, BMFFONT } FontType; - BYTE PaletteData[768]; + uint8_t PaletteData[768]; bool RescalePalette; }; @@ -176,9 +176,9 @@ class FFontChar1 : public FTexture { public: FFontChar1 (FTexture *sourcelump); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); - void SetSourceRemap(const BYTE *sourceremap); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); + void SetSourceRemap(const uint8_t *sourceremap); void Unload (); ~FFontChar1 (); @@ -186,8 +186,8 @@ protected: void MakeTexture (); FTexture *BaseTexture; - BYTE *Pixels; - const BYTE *SourceRemap; + uint8_t *Pixels; + const uint8_t *SourceRemap; }; // This is a font character that reads RLE compressed data. @@ -197,17 +197,17 @@ public: FFontChar2 (int sourcelump, int sourcepos, int width, int height, int leftofs=0, int topofs=0); ~FFontChar2 (); - const BYTE *GetColumn (unsigned int column, const Span **spans_out); - const BYTE *GetPixels (); - void SetSourceRemap(const BYTE *sourceremap); + const uint8_t *GetColumn (unsigned int column, const Span **spans_out); + const uint8_t *GetPixels (); + void SetSourceRemap(const uint8_t *sourceremap); void Unload (); protected: int SourceLump; int SourcePos; - BYTE *Pixels; + uint8_t *Pixels; Span **Spans; - const BYTE *SourceRemap; + const uint8_t *SourceRemap; void MakeTexture (); }; @@ -371,7 +371,7 @@ FFont::FFont (const char *name, const char *nametemplate, int first, int count, Lump = fdlump; Chars = new CharData[count]; charlumps = new FTexture *[count]; - PatchRemap = new BYTE[256]; + PatchRemap = new uint8_t[256]; FirstChar = first; LastChar = first + count - 1; FontHeight = 0; @@ -550,18 +550,18 @@ DEFINE_ACTION_FUNCTION(FFont, FindFont) // //========================================================================== -void RecordTextureColors (FTexture *pic, BYTE *usedcolors) +void RecordTextureColors (FTexture *pic, uint8_t *usedcolors) { int x; for (x = pic->GetWidth() - 1; x >= 0; x--) { const FTexture::Span *spans; - const BYTE *column = pic->GetColumn (x, &spans); + const uint8_t *column = pic->GetColumn (x, &spans); while (spans->Length != 0) { - const BYTE *source = column + spans->TopOffset; + const uint8_t *source = column + spans->TopOffset; int count = spans->Length; do @@ -584,12 +584,12 @@ void RecordTextureColors (FTexture *pic, BYTE *usedcolors) static int compare (const void *arg1, const void *arg2) { - if (RPART(GPalette.BaseColors[*((BYTE *)arg1)]) * 299 + - GPART(GPalette.BaseColors[*((BYTE *)arg1)]) * 587 + - BPART(GPalette.BaseColors[*((BYTE *)arg1)]) * 114 < - RPART(GPalette.BaseColors[*((BYTE *)arg2)]) * 299 + - GPART(GPalette.BaseColors[*((BYTE *)arg2)]) * 587 + - BPART(GPalette.BaseColors[*((BYTE *)arg2)]) * 114) + if (RPART(GPalette.BaseColors[*((uint8_t *)arg1)]) * 299 + + GPART(GPalette.BaseColors[*((uint8_t *)arg1)]) * 587 + + BPART(GPalette.BaseColors[*((uint8_t *)arg1)]) * 114 < + RPART(GPalette.BaseColors[*((uint8_t *)arg2)]) * 299 + + GPART(GPalette.BaseColors[*((uint8_t *)arg2)]) * 587 + + BPART(GPalette.BaseColors[*((uint8_t *)arg2)]) * 114) return -1; else return 1; @@ -614,7 +614,7 @@ static int compare (const void *arg1, const void *arg2) // //========================================================================== -int FFont::SimpleTranslation (BYTE *colorsused, BYTE *translation, BYTE *reverse, double **luminosity) +int FFont::SimpleTranslation (uint8_t *colorsused, uint8_t *translation, uint8_t *reverse, double **luminosity) { double min, max, diver; int i, j; @@ -671,7 +671,7 @@ int FFont::SimpleTranslation (BYTE *colorsused, BYTE *translation, BYTE *reverse // //========================================================================== -void FFont::BuildTranslations (const double *luminosity, const BYTE *identity, +void FFont::BuildTranslations (const double *luminosity, const uint8_t *identity, const void *ranges, int total_colors, const PalEntry *palette) { int i, j; @@ -871,7 +871,7 @@ DEFINE_ACTION_FUNCTION(FFont, GetHeight) // //========================================================================== -int FFont::StringWidth(const BYTE *string) const +int FFont::StringWidth(const uint8_t *string) const { int w = 0; int maxw = 0; @@ -926,7 +926,7 @@ DEFINE_ACTION_FUNCTION(FFont, StringWidth) void FFont::LoadTranslations() { unsigned int count = LastChar - FirstChar + 1; - BYTE usedcolors[256], identity[256]; + uint8_t usedcolors[256], identity[256]; double *luminosity; memset (usedcolors, 0, 256); @@ -1029,7 +1029,7 @@ FSingleLumpFont::FSingleLumpFont (const char *name, int lump) : FFont(lump) FontName = name; FMemLump data1 = Wads.ReadLump (lump); - const BYTE *data = (const BYTE *)data1.GetMem(); + const uint8_t *data = (const uint8_t *)data1.GetMem(); if (data[0] == 0xE1 && data[1] == 0xE6 && data[2] == 0xD5 && data[3] == 0x1A) { @@ -1089,7 +1089,7 @@ void FSingleLumpFont::CreateFontFromPic (FTextureID picnum) void FSingleLumpFont::LoadTranslations() { double luminosity[256]; - BYTE identity[256]; + uint8_t identity[256]; PalEntry local_palette[256]; bool useidentity = true; bool usepalette = false; @@ -1135,7 +1135,7 @@ void FSingleLumpFont::LoadTranslations() // //========================================================================== -void FSingleLumpFont::LoadFON1 (int lump, const BYTE *data) +void FSingleLumpFont::LoadFON1 (int lump, const uint8_t *data) { int w, h; @@ -1150,7 +1150,7 @@ void FSingleLumpFont::LoadFON1 (int lump, const BYTE *data) FirstChar = 0; LastChar = 255; GlobalKerning = 0; - PatchRemap = new BYTE[256]; + PatchRemap = new uint8_t[256]; for(unsigned int i = 0;i < 256;++i) Chars[i].Pic = NULL; @@ -1167,13 +1167,13 @@ void FSingleLumpFont::LoadFON1 (int lump, const BYTE *data) // //========================================================================== -void FSingleLumpFont::LoadFON2 (int lump, const BYTE *data) +void FSingleLumpFont::LoadFON2 (int lump, const uint8_t *data) { int count, i, totalwidth; int *widths2; - WORD *widths; - const BYTE *palette; - const BYTE *data_p; + uint16_t *widths; + const uint8_t *palette; + const uint8_t *data_p; FontType = FONT2; FontHeight = data[4] + data[5]*256; @@ -1188,13 +1188,13 @@ void FSingleLumpFont::LoadFON2 (int lump, const BYTE *data) widths2 = new int[count]; if (data[11] & 1) { // Font specifies a kerning value. - GlobalKerning = LittleShort(*(SWORD *)&data[12]); - widths = (WORD *)(data + 14); + GlobalKerning = LittleShort(*(int16_t *)&data[12]); + widths = (uint16_t *)(data + 14); } else { // Font does not specify a kerning value. GlobalKerning = 0; - widths = (WORD *)(data + 12); + widths = (uint16_t *)(data + 12); } totalwidth = 0; @@ -1206,7 +1206,7 @@ void FSingleLumpFont::LoadFON2 (int lump, const BYTE *data) widths2[i] = totalwidth; } totalwidth *= count; - palette = (BYTE *)&widths[1]; + palette = (uint8_t *)&widths[1]; } else { // Font has varying character widths. @@ -1215,7 +1215,7 @@ void FSingleLumpFont::LoadFON2 (int lump, const BYTE *data) widths2[i] = LittleShort(widths[i]); totalwidth += widths2[i]; } - palette = (BYTE *)(widths + i); + palette = (uint8_t *)(widths + i); } if (FirstChar <= ' ' && LastChar >= ' ') @@ -1248,7 +1248,7 @@ void FSingleLumpFont::LoadFON2 (int lump, const BYTE *data) Chars[i].Pic = new FFontChar2 (lump, int(data_p - data), widths2[i], FontHeight); do { - SBYTE code = *data_p++; + int8_t code = *data_p++; if (code >= 0) { data_p += code+1; @@ -1281,18 +1281,18 @@ void FSingleLumpFont::LoadFON2 (int lump, const BYTE *data) // //========================================================================== -void FSingleLumpFont::LoadBMF(int lump, const BYTE *data) +void FSingleLumpFont::LoadBMF(int lump, const uint8_t *data) { - const BYTE *chardata; + const uint8_t *chardata; int numchars, count, totalwidth, nwidth; int infolen; int i, chari; - BYTE raw_palette[256*3]; + uint8_t raw_palette[256*3]; PalEntry sort_palette[256]; FontType = BMFFONT; FontHeight = data[5]; - GlobalKerning = (SBYTE)data[8]; + GlobalKerning = (int8_t)data[8]; ActiveColors = data[16]; SpaceWidth = -1; nwidth = -1; @@ -1354,7 +1354,7 @@ void FSingleLumpFont::LoadBMF(int lump, const BYTE *data) qsort(sort_palette + 1, ActiveColors - 1, sizeof(PalEntry), BMFCompare); // Create the PatchRemap table from the sorted "alpha" values. - PatchRemap = new BYTE[ActiveColors]; + PatchRemap = new uint8_t[ActiveColors]; PatchRemap[0] = 0; for (i = 1; i < ActiveColors; ++i) { @@ -1384,8 +1384,8 @@ void FSingleLumpFont::LoadBMF(int lump, const BYTE *data) Chars[chardata[chari] - FirstChar].Pic = new FFontChar2(lump, int(chardata + chari + 6 - data), chardata[chari+1], // width chardata[chari+2], // height - -(SBYTE)chardata[chari+3], // x offset - -(SBYTE)chardata[chari+4] // y offset + -(int8_t)chardata[chari+3], // x offset + -(int8_t)chardata[chari+4] // y offset ); } @@ -1436,10 +1436,10 @@ int FSingleLumpFont::BMFCompare(const void *a, const void *b) void FSingleLumpFont::CheckFON1Chars (double *luminosity) { FMemLump memLump = Wads.ReadLump(Lump); - const BYTE* data = (const BYTE*) memLump.GetMem(); + const uint8_t* data = (const uint8_t*) memLump.GetMem(); - BYTE used[256], reverse[256]; - const BYTE *data_p; + uint8_t used[256], reverse[256]; + const uint8_t *data_p; int i, j; memset (used, 0, 256); @@ -1458,7 +1458,7 @@ void FSingleLumpFont::CheckFON1Chars (double *luminosity) // Advance to next char's data and count the used colors. do { - SBYTE code = *data_p++; + int8_t code = *data_p++; if (code >= 0) { destSize -= code+1; @@ -1501,7 +1501,7 @@ void FSingleLumpFont::CheckFON1Chars (double *luminosity) // //========================================================================== -void FSingleLumpFont::FixupPalette (BYTE *identity, double *luminosity, const BYTE *palette, bool rescale, PalEntry *out_palette) +void FSingleLumpFont::FixupPalette (uint8_t *identity, double *luminosity, const uint8_t *palette, bool rescale, PalEntry *out_palette) { int i; double maxlum = 0.0; @@ -1639,7 +1639,7 @@ FFontChar1::FFontChar1 (FTexture *sourcelump) // //========================================================================== -const BYTE *FFontChar1::GetPixels () +const uint8_t *FFontChar1::GetPixels () { if (Pixels == NULL) { @@ -1658,8 +1658,8 @@ void FFontChar1::MakeTexture () { // Make the texture as normal, then remap it so that all the colors // are at the low end of the palette - Pixels = new BYTE[Width*Height]; - const BYTE *pix = BaseTexture->GetPixels(); + Pixels = new uint8_t[Width*Height]; + const uint8_t *pix = BaseTexture->GetPixels(); if (!SourceRemap) { @@ -1680,7 +1680,7 @@ void FFontChar1::MakeTexture () // //========================================================================== -const BYTE *FFontChar1::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FFontChar1::GetColumn (unsigned int column, const Span **spans_out) { if (Pixels == NULL) { @@ -1697,7 +1697,7 @@ const BYTE *FFontChar1::GetColumn (unsigned int column, const Span **spans_out) // //========================================================================== -void FFontChar1::SetSourceRemap(const BYTE *sourceremap) +void FFontChar1::SetSourceRemap(const uint8_t *sourceremap) { Unload(); SourceRemap = sourceremap; @@ -1787,7 +1787,7 @@ void FFontChar2::Unload () // //========================================================================== -const BYTE *FFontChar2::GetPixels () +const uint8_t *FFontChar2::GetPixels () { if (Pixels == NULL) { @@ -1802,7 +1802,7 @@ const BYTE *FFontChar2::GetPixels () // //========================================================================== -const BYTE *FFontChar2::GetColumn (unsigned int column, const Span **spans_out) +const uint8_t *FFontChar2::GetColumn (unsigned int column, const Span **spans_out) { if (Pixels == NULL) { @@ -1829,7 +1829,7 @@ const BYTE *FFontChar2::GetColumn (unsigned int column, const Span **spans_out) // //========================================================================== -void FFontChar2::SetSourceRemap(const BYTE *sourceremap) +void FFontChar2::SetSourceRemap(const uint8_t *sourceremap) { Unload(); SourceRemap = sourceremap; @@ -1845,12 +1845,12 @@ void FFontChar2::MakeTexture () { FWadLump lump = Wads.OpenLumpNum (SourceLump); int destSize = Width * Height; - BYTE max = 255; + uint8_t max = 255; bool rle = true; // This is to "fix" bad fonts { - BYTE buff[16]; + uint8_t buff[16]; lump.Read (buff, 4); if (buff[3] == '2') { @@ -1871,11 +1871,11 @@ void FFontChar2::MakeTexture () } } - Pixels = new BYTE[destSize]; + Pixels = new uint8_t[destSize]; int runlen = 0, setlen = 0; - BYTE setval = 0; // Shut up, GCC! - BYTE *dest_p = Pixels; + uint8_t setval = 0; // Shut up, GCC! + uint8_t *dest_p = Pixels; int dest_adv = Height; int dest_rew = destSize - 1; @@ -1887,7 +1887,7 @@ void FFontChar2::MakeTexture () { if (runlen != 0) { - BYTE color; + uint8_t color; lump >> color; color = MIN (color, max); @@ -1909,7 +1909,7 @@ void FFontChar2::MakeTexture () } else { - SBYTE code; + int8_t code; lump >> code; if (code >= 0) @@ -1918,7 +1918,7 @@ void FFontChar2::MakeTexture () } else if (code != -128) { - BYTE color; + uint8_t color; lump >> color; setlen = (-code) + 1; @@ -1939,7 +1939,7 @@ void FFontChar2::MakeTexture () { for (int x = Width; x != 0; --x) { - BYTE color; + uint8_t color; lump >> color; if (color > max) { @@ -1984,7 +1984,7 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l FontName = name; Chars = new CharData[count]; charlumps = new FTexture*[count]; - PatchRemap = new BYTE[256]; + PatchRemap = new uint8_t[256]; FirstChar = first; LastChar = first + count - 1; FontHeight = 0; @@ -2052,7 +2052,7 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l void FSpecialFont::LoadTranslations() { int count = LastChar - FirstChar + 1; - BYTE usedcolors[256], identity[256]; + uint8_t usedcolors[256], identity[256]; double *luminosity; int TotalColors; int i, j; @@ -2609,9 +2609,9 @@ PalEntry V_LogColorFromColorRange (EColorRange range) // //========================================================================== -EColorRange V_ParseFontColor (const BYTE *&color_value, int normalcolor, int boldcolor) +EColorRange V_ParseFontColor (const uint8_t *&color_value, int normalcolor, int boldcolor) { - const BYTE *ch = color_value; + const uint8_t *ch = color_value; int newcolor = *ch++; if (newcolor == '-') // Normal @@ -2632,7 +2632,7 @@ EColorRange V_ParseFontColor (const BYTE *&color_value, int normalcolor, int bol } else if (newcolor == '[') // Named { - const BYTE *namestart = ch; + const uint8_t *namestart = ch; while (*ch != ']' && *ch != '\0') { ch++; diff --git a/src/v_font.h b/src/v_font.h index ec85f7622..6553f5855 100644 --- a/src/v_font.h +++ b/src/v_font.h @@ -93,9 +93,9 @@ public: static void StaticPreloadFonts(); // Return width of string in pixels (unscaled) - int StringWidth (const BYTE *str) const; - inline int StringWidth (const char *str) const { return StringWidth ((const BYTE *)str); } - inline int StringWidth (const FString &str) const { return StringWidth ((const BYTE *)str.GetChars()); } + int StringWidth (const uint8_t *str) const; + inline int StringWidth (const char *str) const { return StringWidth ((const uint8_t *)str); } + inline int StringWidth (const FString &str) const { return StringWidth ((const uint8_t *)str.GetChars()); } int GetCharCode(int code, bool needpic) const; char GetCursor() const { return Cursor; } @@ -105,12 +105,12 @@ public: protected: FFont (int lump); - void BuildTranslations (const double *luminosity, const BYTE *identity, + void BuildTranslations (const double *luminosity, const uint8_t *identity, const void *ranges, int total_colors, const PalEntry *palette); void FixXMoves(); - static int SimpleTranslation (BYTE *colorsused, BYTE *translation, - BYTE *identity, double **luminosity); + static int SimpleTranslation (uint8_t *colorsused, uint8_t *translation, + uint8_t *identity, double **luminosity); int FirstChar, LastChar; int SpaceWidth; @@ -125,7 +125,7 @@ protected: } *Chars; int ActiveColors; TArray Ranges; - BYTE *PatchRemap; + uint8_t *PatchRemap; int Lump; FName FontName; @@ -144,7 +144,7 @@ void V_InitFonts(); void V_ClearFonts(); EColorRange V_FindFontColor (FName name); PalEntry V_LogColorFromColorRange (EColorRange range); -EColorRange V_ParseFontColor (const BYTE *&color_value, int normalcolor, int boldcolor); +EColorRange V_ParseFontColor (const uint8_t *&color_value, int normalcolor, int boldcolor); FFont *V_GetFont(const char *); void V_InitFontColors(); diff --git a/src/v_palette.cpp b/src/v_palette.cpp index 4f4c9cb18..5873de10b 100644 --- a/src/v_palette.cpp +++ b/src/v_palette.cpp @@ -72,7 +72,7 @@ static int sortforremap2 (const void *a, const void *b); /* Gamma correction stuff */ /**************************/ -BYTE newgamma[256]; +uint8_t newgamma[256]; CUSTOM_CVAR (Float, Gamma, 1.f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) { if (self == 0.f) @@ -135,12 +135,12 @@ FPalette::FPalette () { } -FPalette::FPalette (const BYTE *colors) +FPalette::FPalette (const uint8_t *colors) { SetPalette (colors); } -void FPalette::SetPalette (const BYTE *colors) +void FPalette::SetPalette (const uint8_t *colors) { for (int i = 0; i < 256; i++, colors += 3) { @@ -151,8 +151,8 @@ void FPalette::SetPalette (const BYTE *colors) // Find white and black from the original palette so that they can be // used to make an educated guess of the translucency % for a BOOM // translucency map. - WhiteIndex = BestColor ((DWORD *)BaseColors, 255, 255, 255, 0, 255); - BlackIndex = BestColor ((DWORD *)BaseColors, 0, 0, 0, 0, 255); + WhiteIndex = BestColor ((uint32_t *)BaseColors, 255, 255, 255, 0, 255); + BlackIndex = BestColor ((uint32_t *)BaseColors, 0, 0, 0, 0, 255); } // In ZDoom's new texture system, color 0 is used as the transparent color. @@ -216,18 +216,18 @@ void FPalette::MakeGoodRemap () static int sortforremap (const void *a, const void *b) { - return (*(const DWORD *)a & 0xFFFFFF) - (*(const DWORD *)b & 0xFFFFFF); + return (*(const uint32_t *)a & 0xFFFFFF) - (*(const uint32_t *)b & 0xFFFFFF); } struct RemappingWork { - DWORD Color; - BYTE Foreign; // 0 = local palette, 1 = foreign palette - BYTE PalEntry; // Entry # in the palette - BYTE Pad[2]; + uint32_t Color; + uint8_t Foreign; // 0 = local palette, 1 = foreign palette + uint8_t PalEntry; // Entry # in the palette + uint8_t Pad[2]; }; -void FPalette::MakeRemap (const DWORD *colors, BYTE *remap, const BYTE *useful, int numcolors) const +void FPalette::MakeRemap (const uint32_t *colors, uint8_t *remap, const uint8_t *useful, int numcolors) const { RemappingWork workspace[255+256]; int i, j, k; @@ -238,7 +238,7 @@ void FPalette::MakeRemap (const DWORD *colors, BYTE *remap, const BYTE *useful, for (i = 1; i < 256; ++i) { - workspace[i-1].Color = DWORD(BaseColors[i]) & 0xFFFFFF; + workspace[i-1].Color = uint32_t(BaseColors[i]) & 0xFFFFFF; workspace[i-1].Foreign = 0; workspace[i-1].PalEntry = i; } @@ -282,7 +282,7 @@ void FPalette::MakeRemap (const DWORD *colors, BYTE *remap, const BYTE *useful, { if (workspace[i].Foreign == 1) { - remap[workspace[i].PalEntry] = BestColor ((DWORD *)BaseColors, + remap[workspace[i].PalEntry] = BestColor ((uint32_t *)BaseColors, RPART(workspace[i].Color), GPART(workspace[i].Color), BPART(workspace[i].Color), 1, 255); } @@ -305,7 +305,7 @@ static int sortforremap2 (const void *a, const void *b) } } -static bool FixBuildPalette (BYTE *opal, int lump, bool blood) +static bool FixBuildPalette (uint8_t *opal, int lump, bool blood) { if (Wads.LumpLength (lump) < 768) { @@ -313,7 +313,7 @@ static bool FixBuildPalette (BYTE *opal, int lump, bool blood) } FMemLump data = Wads.ReadLump (lump); - const BYTE *ipal = (const BYTE *)data.GetMem(); + const uint8_t *ipal = (const uint8_t *)data.GetMem(); // Reverse the palette because BUILD used entry 255 as // transparent, but we use 0 as transparent. @@ -338,7 +338,7 @@ static bool FixBuildPalette (BYTE *opal, int lump, bool blood) void InitPalette () { - BYTE pal[768]; + uint8_t pal[768]; bool usingBuild = false; int lump; @@ -359,14 +359,14 @@ void InitPalette () GPalette.SetPalette (pal); GPalette.MakeGoodRemap (); - ColorMatcher.SetPalette ((DWORD *)GPalette.BaseColors); + ColorMatcher.SetPalette ((uint32_t *)GPalette.BaseColors); // The BUILD engine already has a transparent color, so it doesn't need any remapping. if (!usingBuild) { if (GPalette.Remap[0] == 0) { // No duplicates, so settle for something close to color 0 - GPalette.Remap[0] = BestColor ((DWORD *)GPalette.BaseColors, + GPalette.Remap[0] = BestColor ((uint32_t *)GPalette.BaseColors, GPalette.BaseColors[0].r, GPalette.BaseColors[0].g, GPalette.BaseColors[0].b, 1, 255); } } @@ -385,13 +385,13 @@ void DoBlending (const PalEntry *from, PalEntry *to, int count, int r, int g, in { if (from != to) { - memcpy (to, from, count * sizeof(DWORD)); + memcpy (to, from, count * sizeof(uint32_t)); } return; } else if (a == 256) { - DWORD t = MAKERGB(r,g,b); + uint32_t t = MAKERGB(r,g,b); int i; for (i = 0; i < count; i++) @@ -507,7 +507,7 @@ CCMD (testblend) CCMD (testfade) { FString colorstring; - DWORD color; + uint32_t color; if (argv.argc() < 2) { @@ -606,7 +606,7 @@ void HSVtoRGB (float *r, float *g, float *b, float h, float s, float v) CCMD (testcolor) { FString colorstring; - DWORD color; + uint32_t color; int desaturate; if (argv.argc() < 2) diff --git a/src/v_palette.h b/src/v_palette.h index 784c01c98..62628eb5c 100644 --- a/src/v_palette.h +++ b/src/v_palette.h @@ -37,8 +37,8 @@ #include "doomtype.h" #include "c_cvars.h" -#define MAKERGB(r,g,b) DWORD(((r)<<16)|((g)<<8)|(b)) -#define MAKEARGB(a,r,g,b) DWORD(((a)<<24)|((r)<<16)|((g)<<8)|(b)) +#define MAKERGB(r,g,b) uint32_t(((r)<<16)|((g)<<8)|(b)) +#define MAKEARGB(a,r,g,b) uint32_t(((a)<<24)|((r)<<16)|((g)<<8)|(b)) #define APART(c) (((c)>>24)&0xff) #define RPART(c) (((c)>>16)&0xff) @@ -48,21 +48,21 @@ struct FPalette { FPalette (); - FPalette (const BYTE *colors); + FPalette (const uint8_t *colors); - void SetPalette (const BYTE *colors); + void SetPalette (const uint8_t *colors); void MakeGoodRemap (); PalEntry BaseColors[256]; // non-gamma corrected palette - BYTE Remap[256]; // remap original palette indices to in-game indices + uint8_t Remap[256]; // remap original palette indices to in-game indices - BYTE WhiteIndex; // white in original palette index - BYTE BlackIndex; // black in original palette index + uint8_t WhiteIndex; // white in original palette index + uint8_t BlackIndex; // black in original palette index // Given an array of colors, fills in remap with values to remap the // passed array of colors to this palette. - void MakeRemap (const DWORD *colors, BYTE *remap, const BYTE *useful, int numcolors) const; + void MakeRemap (const uint32_t *colors, uint8_t *remap, const uint8_t *useful, int numcolors) const; }; extern FPalette GPalette; diff --git a/src/v_pfx.cpp b/src/v_pfx.cpp index 8f4ea6949..260e87944 100644 --- a/src/v_pfx.cpp +++ b/src/v_pfx.cpp @@ -43,7 +43,7 @@ extern "C" PfxState GPfx; } -static bool AnalyzeMask (DWORD mask, BYTE *shift); +static bool AnalyzeMask (uint32_t mask, uint8_t *shift); static void Palette16Generic (const PalEntry *pal); static void Palette16R5G5B5 (const PalEntry *pal); @@ -52,19 +52,19 @@ static void Palette32Generic (const PalEntry *pal); static void Palette32RGB (const PalEntry *pal); static void Palette32BGR (const PalEntry *pal); -static void Scale8 (BYTE *src, int srcpitch, +static void Scale8 (uint8_t *src, int srcpitch, void *destin, int destpitch, int destwidth, int destheight, fixed_t xstep, fixed_t ystep, fixed_t xfrac, fixed_t yfrac); -static void Convert8 (BYTE *src, int srcpitch, +static void Convert8 (uint8_t *src, int srcpitch, void *destin, int destpitch, int destwidth, int destheight, fixed_t xstep, fixed_t ystep, fixed_t xfrac, fixed_t yfrac); -static void Convert16 (BYTE *src, int srcpitch, +static void Convert16 (uint8_t *src, int srcpitch, void *destin, int destpitch, int destwidth, int destheight, fixed_t xstep, fixed_t ystep, fixed_t xfrac, fixed_t yfrac); -static void Convert24 (BYTE *src, int srcpitch, +static void Convert24 (uint8_t *src, int srcpitch, void *destin, int destpitch, int destwidth, int destheight, fixed_t xstep, fixed_t ystep, fixed_t xfrac, fixed_t yfrac); -static void Convert32 (BYTE *src, int srcpitch, +static void Convert32 (uint8_t *src, int srcpitch, void *destin, int destpitch, int destwidth, int destheight, fixed_t xstep, fixed_t ystep, fixed_t xfrac, fixed_t yfrac); @@ -96,9 +96,9 @@ void PfxState::SetFormat (int bits, uint32 redMask, uint32 greenMask, uint32 blu SetPalette = Palette16Generic; } Convert = Convert16; - Masks.Bits16.Red = (WORD)redMask; - Masks.Bits16.Green = (WORD)greenMask; - Masks.Bits16.Blue = (WORD)blueMask; + Masks.Bits16.Red = (uint16_t)redMask; + Masks.Bits16.Green = (uint16_t)greenMask; + Masks.Bits16.Blue = (uint16_t)blueMask; break; case 24: @@ -148,9 +148,9 @@ void PfxState::SetFormat (int bits, uint32 redMask, uint32 greenMask, uint32 blu } } -static bool AnalyzeMask (DWORD mask, BYTE *shiftout) +static bool AnalyzeMask (uint32_t mask, uint8_t *shiftout) { - BYTE shift = 0; + uint8_t shift = 0; if (mask >= 0xff) { @@ -178,12 +178,12 @@ static bool AnalyzeMask (DWORD mask, BYTE *shiftout) static void Palette16Generic (const PalEntry *pal) { - WORD *p16; + uint16_t *p16; int i; for (p16 = GPfxPal.Pal16, i = 256; i != 0; i--, pal++, p16++) { - WORD rpart, gpart, bpart; + uint16_t rpart, gpart, bpart; if (GPfx.RedLeft) rpart = pal->r << GPfx.RedShift; else rpart = pal->r >> GPfx.RedShift; @@ -202,7 +202,7 @@ static void Palette16Generic (const PalEntry *pal) static void Palette16R5G5B5 (const PalEntry *pal) { - WORD *p16; + uint16_t *p16; int i; for (p16 = GPfxPal.Pal16, i = 256; i != 0; i--, pal++, p16++) @@ -215,7 +215,7 @@ static void Palette16R5G5B5 (const PalEntry *pal) static void Palette16R5G6B5 (const PalEntry *pal) { - WORD *p16; + uint16_t *p16; int i; for (p16 = GPfxPal.Pal16, i = 256; i != 0; i--, pal++, p16++) @@ -228,12 +228,12 @@ static void Palette16R5G6B5 (const PalEntry *pal) static void Palette32Generic (const PalEntry *pal) { - DWORD *p32; + uint32_t *p32; int i; for (p32 = GPfxPal.Pal32, i = 256; i != 0; i--, pal++, p32++) { - DWORD rpart, gpart, bpart; + uint32_t rpart, gpart, bpart; if (GPfx.RedLeft) rpart = pal->r << GPfx.RedShift; else rpart = pal->r >> GPfx.RedShift; @@ -257,7 +257,7 @@ static void Palette32RGB (const PalEntry *pal) static void Palette32BGR (const PalEntry *pal) { - DWORD *p32; + uint32_t *p32; int i; for (p32 = GPfxPal.Pal32, i = 256; i != 0; i--, pal++, p32++) @@ -268,7 +268,7 @@ static void Palette32BGR (const PalEntry *pal) // Bitmap converters ------------------------------------------------------- -static void Scale8 (BYTE *src, int srcpitch, +static void Scale8 (uint8_t *src, int srcpitch, void *destin, int destpitch, int destwidth, int destheight, fixed_t xstep, fixed_t ystep, fixed_t xfrac, fixed_t yfrac) { @@ -278,7 +278,7 @@ static void Scale8 (BYTE *src, int srcpitch, } int x, y, savedx; - BYTE *dest = (BYTE *)destin; + uint8_t *dest = (uint8_t *)destin; if (xstep == FRACUNIT && ystep == FRACUNIT) { @@ -291,14 +291,14 @@ static void Scale8 (BYTE *src, int srcpitch, } else if (xstep == FRACUNIT/2 && ystep == FRACUNIT/2) { - BYTE *dest2 = dest + destpitch; + uint8_t *dest2 = dest + destpitch; destpitch = destpitch * 2 - destwidth; srcpitch -= destwidth / 2; for (y = destheight / 2; y != 0; --y) { for (x = destwidth / 2; x != 0; --x) { - BYTE foo = src[0]; + uint8_t foo = src[0]; dest[0] = foo; dest[1] = foo; dest2[0] = foo; @@ -318,9 +318,9 @@ static void Scale8 (BYTE *src, int srcpitch, srcpitch -= destwidth / 4; for (y = destheight / 4; y != 0; --y) { - for (BYTE *end = dest + destpitch; dest != end; dest += 4) + for (uint8_t *end = dest + destpitch; dest != end; dest += 4) { - BYTE foo = src[0]; + uint8_t foo = src[0]; dest[0] = foo; dest[1] = foo; dest[2] = foo; @@ -358,7 +358,7 @@ static void Scale8 (BYTE *src, int srcpitch, } for (savedx = x, x >>= 2; x != 0; x--) { - DWORD work; + uint32_t work; #ifdef __BIG_ENDIAN__ work = src[xf >> FRACBITS] << 24; xf += xstep; @@ -371,7 +371,7 @@ static void Scale8 (BYTE *src, int srcpitch, work |= src[xf >> FRACBITS] << 16; xf += xstep; work |= src[xf >> FRACBITS] << 24; xf += xstep; #endif - *(DWORD *)dest = work; + *(uint32_t *)dest = work; dest += 4; } for (savedx &= 3; savedx != 0; savedx--, xf += xstep) @@ -389,7 +389,7 @@ static void Scale8 (BYTE *src, int srcpitch, } } -static void Convert8 (BYTE *src, int srcpitch, +static void Convert8 (uint8_t *src, int srcpitch, void *destin, int destpitch, int destwidth, int destheight, fixed_t xstep, fixed_t ystep, fixed_t xfrac, fixed_t yfrac) { @@ -399,7 +399,7 @@ static void Convert8 (BYTE *src, int srcpitch, } int x, y, savedx; - BYTE *dest = (BYTE *)destin; + uint8_t *dest = (uint8_t *)destin; destpitch -= destwidth; if (xstep == FRACUNIT && ystep == FRACUNIT) @@ -415,7 +415,7 @@ static void Convert8 (BYTE *src, int srcpitch, } for (savedx = x, x >>= 2; x != 0; x--) { - *(DWORD *)dest = + *(uint32_t *)dest = #ifdef __BIG_ENDIAN__ (GPfxPal.Pal8[src[0]] << 24) | (GPfxPal.Pal8[src[1]] << 16) | @@ -452,7 +452,7 @@ static void Convert8 (BYTE *src, int srcpitch, } for (savedx = x, x >>= 2; x != 0; x--) { - DWORD work; + uint32_t work; #ifdef __BIG_ENDIAN__ work = GPfxPal.Pal8[src[xf >> FRACBITS]] << 24; xf += xstep; @@ -465,7 +465,7 @@ static void Convert8 (BYTE *src, int srcpitch, work |= GPfxPal.Pal8[src[xf >> FRACBITS]] << 16; xf += xstep; work |= GPfxPal.Pal8[src[xf >> FRACBITS]] << 24; xf += xstep; #endif - *(DWORD *)dest = work; + *(uint32_t *)dest = work; dest += 4; } for (savedx &= 3; savedx != 0; savedx--, xf += xstep) @@ -483,7 +483,7 @@ static void Convert8 (BYTE *src, int srcpitch, } } -static void Convert16 (BYTE *src, int srcpitch, +static void Convert16 (uint8_t *src, int srcpitch, void *destin, int destpitch, int destwidth, int destheight, fixed_t xstep, fixed_t ystep, fixed_t xfrac, fixed_t yfrac) { @@ -493,7 +493,7 @@ static void Convert16 (BYTE *src, int srcpitch, } int x, y, savedx; - WORD *dest = (WORD *)destin; + uint16_t *dest = (uint16_t *)destin; destpitch = (destpitch >> 1) - destwidth; if (xstep == FRACUNIT && ystep == FRACUNIT) @@ -509,7 +509,7 @@ static void Convert16 (BYTE *src, int srcpitch, } for (savedx = x, x >>= 1; x != 0; x--) { - *(DWORD *)dest = + *(uint32_t *)dest = #ifdef __BIG_ENDIAN__ (GPfxPal.Pal16[src[0]] << 16) | (GPfxPal.Pal16[src[1]]); @@ -542,7 +542,7 @@ static void Convert16 (BYTE *src, int srcpitch, } for (savedx = x, x >>= 1; x != 0; x--) { - DWORD work; + uint32_t work; #ifdef __BIG_ENDIAN__ work = GPfxPal.Pal16[src[xf >> FRACBITS]] << 16; xf += xstep; @@ -551,7 +551,7 @@ static void Convert16 (BYTE *src, int srcpitch, work = GPfxPal.Pal16[src[xf >> FRACBITS]]; xf += xstep; work |= GPfxPal.Pal16[src[xf >> FRACBITS]] << 16; xf += xstep; #endif - *(DWORD *)dest = work; + *(uint32_t *)dest = work; dest += 2; } if (savedx & 1) @@ -569,7 +569,7 @@ static void Convert16 (BYTE *src, int srcpitch, } } -static void Convert24 (BYTE *src, int srcpitch, +static void Convert24 (uint8_t *src, int srcpitch, void *destin, int destpitch, int destwidth, int destheight, fixed_t xstep, fixed_t ystep, fixed_t xfrac, fixed_t yfrac) { @@ -579,7 +579,7 @@ static void Convert24 (BYTE *src, int srcpitch, } int x, y; - BYTE *dest = (BYTE *)destin; + uint8_t *dest = (uint8_t *)destin; destpitch = destpitch - destwidth*3; if (xstep == FRACUNIT && ystep == FRACUNIT) @@ -589,7 +589,7 @@ static void Convert24 (BYTE *src, int srcpitch, { for (x = destwidth; x != 0; x--) { - BYTE *pe = GPfxPal.Pal24[src[0]]; + uint8_t *pe = GPfxPal.Pal24[src[0]]; dest[0] = pe[0]; dest[1] = pe[1]; dest[2] = pe[2]; @@ -607,7 +607,7 @@ static void Convert24 (BYTE *src, int srcpitch, fixed_t xf = xfrac; for (x = destwidth; x != 0; x--) { - BYTE *pe = GPfxPal.Pal24[src[xf >> FRACBITS]]; + uint8_t *pe = GPfxPal.Pal24[src[xf >> FRACBITS]]; dest[0] = pe[0]; dest[1] = pe[1]; dest[2] = pe[2]; @@ -625,7 +625,7 @@ static void Convert24 (BYTE *src, int srcpitch, } } -static void Convert32 (BYTE *src, int srcpitch, +static void Convert32 (uint8_t *src, int srcpitch, void *destin, int destpitch, int destwidth, int destheight, fixed_t xstep, fixed_t ystep, fixed_t xfrac, fixed_t yfrac) { @@ -635,7 +635,7 @@ static void Convert32 (BYTE *src, int srcpitch, } int x, y, savedx; - DWORD *dest = (DWORD *)destin; + uint32_t *dest = (uint32_t *)destin; destpitch = (destpitch >> 2) - destwidth; if (xstep == FRACUNIT && ystep == FRACUNIT) diff --git a/src/v_pfx.h b/src/v_pfx.h index d2b29a482..230b30c8d 100644 --- a/src/v_pfx.h +++ b/src/v_pfx.h @@ -40,10 +40,10 @@ union PfxUnion { - BYTE Pal8[256]; - WORD Pal16[256]; - DWORD Pal32[256]; - BYTE Pal24[256][4]; + uint8_t Pal8[256]; + uint16_t Pal16[256]; + uint32_t Pal32[256]; + uint8_t Pal24[256][4]; }; struct PfxState @@ -52,27 +52,27 @@ struct PfxState { struct { - WORD Red; - WORD Green; - WORD Blue; + uint16_t Red; + uint16_t Green; + uint16_t Blue; } Bits16; struct { - uint32 Red; - uint32 Green; - uint32 Blue; + uint32_t Red; + uint32_t Green; + uint32_t Blue; } Bits32; } Masks; - BYTE RedShift; - BYTE BlueShift; - BYTE GreenShift; + uint8_t RedShift; + uint8_t BlueShift; + uint8_t GreenShift; BITFIELD RedLeft:1; BITFIELD BlueLeft:1; BITFIELD GreenLeft:1; - void SetFormat (int bits, uint32 redMask, uint32 greenMask, uint32 blueMask); + void SetFormat (int bits, uint32_t redMask, uint32_t greenMask, uint32_t blueMask); void (*SetPalette) (const PalEntry *pal); - void (*Convert) (BYTE *src, int srcpitch, + void (*Convert) (uint8_t *src, int srcpitch, void *dest, int destpitch, int destwidth, int destheight, fixed_t xstep, fixed_t ystep, fixed_t xfrac, fixed_t yfrac); }; diff --git a/src/v_text.cpp b/src/v_text.cpp index a80a566ab..ca445913f 100644 --- a/src/v_text.cpp +++ b/src/v_text.cpp @@ -132,7 +132,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawChar) void DCanvas::DrawTextCommon(FFont *font, int normalcolor, double x, double y, const char *string, DrawParms &parms) { int w; - const BYTE *ch; + const uint8_t *ch; int c; double cx; double cy; @@ -154,7 +154,7 @@ void DCanvas::DrawTextCommon(FFont *font, int normalcolor, double x, double y, c kerning = font->GetDefaultKerning(); - ch = (const BYTE *)string; + ch = (const uint8_t *)string; cx = x; cy = y; @@ -254,7 +254,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawText) // //========================================================================== -static void breakit (FBrokenLines *line, FFont *font, const BYTE *start, const BYTE *stop, FString &linecolor) +static void breakit (FBrokenLines *line, FFont *font, const uint8_t *start, const uint8_t *stop, FString &linecolor) { if (!linecolor.IsEmpty()) { @@ -265,11 +265,11 @@ static void breakit (FBrokenLines *line, FFont *font, const BYTE *start, const B line->Width = font->StringWidth (line->Text); } -FBrokenLines *V_BreakLines (FFont *font, int maxwidth, const BYTE *string, bool preservecolor, unsigned int *count) +FBrokenLines *V_BreakLines (FFont *font, int maxwidth, const uint8_t *string, bool preservecolor, unsigned int *count) { TArray Lines(128); - const BYTE *space = NULL, *start = string; + const uint8_t *space = NULL, *start = string; int c, w, nw; FString lastcolor, linecolor; bool lastWasSpace = false; @@ -285,7 +285,7 @@ FBrokenLines *V_BreakLines (FFont *font, int maxwidth, const BYTE *string, bool { if (*string == '[') { - const BYTE *start = string; + const uint8_t *start = string; while (*string != ']' && *string != '\0') { string++; @@ -355,7 +355,7 @@ FBrokenLines *V_BreakLines (FFont *font, int maxwidth, const BYTE *string, bool // String here is pointing one character after the '\0' if (--string - start >= 1) { - const BYTE *s = start; + const uint8_t *s = start; while (s < string) { diff --git a/src/v_text.h b/src/v_text.h index bd24be405..4c54b941b 100644 --- a/src/v_text.h +++ b/src/v_text.h @@ -75,11 +75,11 @@ struct FBrokenLines #define TEXTCOLOR_CHAT "\034*" #define TEXTCOLOR_TEAMCHAT "\034!" -FBrokenLines *V_BreakLines (FFont *font, int maxwidth, const BYTE *str, bool preservecolor = false, unsigned int *count = nullptr); +FBrokenLines *V_BreakLines (FFont *font, int maxwidth, const uint8_t *str, bool preservecolor = false, unsigned int *count = nullptr); void V_FreeBrokenLines (FBrokenLines *lines); inline FBrokenLines *V_BreakLines (FFont *font, int maxwidth, const char *str, bool preservecolor = false, unsigned int *count = nullptr) - { return V_BreakLines (font, maxwidth, (const BYTE *)str, preservecolor, count); } + { return V_BreakLines (font, maxwidth, (const uint8_t *)str, preservecolor, count); } inline FBrokenLines *V_BreakLines (FFont *font, int maxwidth, const FString &str, bool preservecolor = false, unsigned int *count = nullptr) - { return V_BreakLines (font, maxwidth, (const BYTE *)str.GetChars(), preservecolor, count); } + { return V_BreakLines (font, maxwidth, (const uint8_t *)str.GetChars(), preservecolor, count); } #endif //__V_TEXT_H__ diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 41833fc24..c9230f584 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -187,10 +187,10 @@ void FWadCollection::InitMultipleFiles (TArray &filenames) FixMacHexen(); // [RH] Set up hash table - FirstLumpIndex = new DWORD[NumLumps]; - NextLumpIndex = new DWORD[NumLumps]; - FirstLumpIndex_FullName = new DWORD[NumLumps]; - NextLumpIndex_FullName = new DWORD[NumLumps]; + FirstLumpIndex = new uint32_t[NumLumps]; + NextLumpIndex = new uint32_t[NumLumps]; + FirstLumpIndex_FullName = new uint32_t[NumLumps]; + NextLumpIndex_FullName = new uint32_t[NumLumps]; InitHashChains (); LumpInfo.ShrinkToFit(); Files.ShrinkToFit(); @@ -268,10 +268,10 @@ void FWadCollection::AddFile (const char *filename, FileReader *wadinfo) if (resfile != NULL) { - DWORD lumpstart = LumpInfo.Size(); + uint32_t lumpstart = LumpInfo.Size(); resfile->SetFirstLump(lumpstart); - for (DWORD i=0; i < resfile->LumpCount(); i++) + for (uint32_t i=0; i < resfile->LumpCount(); i++) { FResourceLump *lump = resfile->GetLump(i); FWadCollection::LumpRecord *lump_p = &LumpInfo[LumpInfo.Reserve(1)]; @@ -286,7 +286,7 @@ void FWadCollection::AddFile (const char *filename, FileReader *wadinfo) } Files.Push(resfile); - for (DWORD i=0; i < resfile->LumpCount(); i++) + for (uint32_t i=0; i < resfile->LumpCount(); i++) { FResourceLump *lump = resfile->GetLump(i); if (lump->Flags & LUMPF_EMBEDDED) @@ -300,7 +300,7 @@ void FWadCollection::AddFile (const char *filename, FileReader *wadinfo) if (hashfile) { - BYTE cksum[16]; + uint8_t cksum[16]; char cksumout[33]; memset(cksumout, 0, sizeof(cksumout)); @@ -324,7 +324,7 @@ void FWadCollection::AddFile (const char *filename, FileReader *wadinfo) else fprintf(hashfile, "file: %s, Directory structure\n", filename); - for (DWORD i = 0; i < resfile->LumpCount(); i++) + for (uint32_t i = 0; i < resfile->LumpCount(); i++) { FResourceLump *lump = resfile->GetLump(i); @@ -431,7 +431,7 @@ int FWadCollection::CheckNumForName (const char *name, int space) char uname[8]; QWORD qname; }; - DWORD i; + uint32_t i; if (name == NULL) { @@ -477,7 +477,7 @@ int FWadCollection::CheckNumForName (const char *name, int space, int wadnum, bo char uname[8]; QWORD qname; }; - DWORD i; + uint32_t i; if (wadnum < 0) { @@ -543,7 +543,7 @@ int FWadCollection::GetNumForName (const char *name, int space) int FWadCollection::CheckNumForFullName (const char *name, bool trynormal, int namespc) { - DWORD i; + uint32_t i; if (name == NULL) { @@ -568,7 +568,7 @@ int FWadCollection::CheckNumForFullName (const char *name, bool trynormal, int n int FWadCollection::CheckNumForFullName (const char *name, int wadnum) { - DWORD i; + uint32_t i; if (wadnum < 0) { @@ -702,10 +702,10 @@ int FWadCollection::GetLumpFlags (int lump) // //========================================================================== -DWORD FWadCollection::LumpNameHash (const char *s) +uint32_t FWadCollection::LumpNameHash (const char *s) { - const DWORD *table = GetCRCTable ();; - DWORD hash = 0xffffffff; + const uint32_t *table = GetCRCTable ();; + uint32_t hash = 0xffffffff; int i; for (i = 8; i > 0 && *s; --i, ++s) @@ -769,11 +769,11 @@ void FWadCollection::RenameSprites () bool renameAll; bool MNTRZfound = false; - static const DWORD HereticRenames[] = + static const uint32_t HereticRenames[] = { MAKE_ID('H','E','A','D'), MAKE_ID('L','I','C','H'), // Ironlich }; - static const DWORD HexenRenames[] = + static const uint32_t HexenRenames[] = { MAKE_ID('B','A','R','L'), MAKE_ID('Z','B','A','R'), // ZBarrel MAKE_ID('A','R','M','1'), MAKE_ID('A','R','_','1'), // MeshArmor MAKE_ID('A','R','M','2'), MAKE_ID('A','R','_','2'), // FalconShield @@ -790,7 +790,7 @@ void FWadCollection::RenameSprites () MAKE_ID('I','N','V','U'), MAKE_ID('D','E','F','N'), // Icon of the Defender }; - static const DWORD StrifeRenames[] = + static const uint32_t StrifeRenames[] = { MAKE_ID('M','I','S','L'), MAKE_ID('S','M','I','S'), // lots of places MAKE_ID('A','R','M','1'), MAKE_ID('A','R','M','3'), // MetalArmor MAKE_ID('A','R','M','2'), MAKE_ID('A','R','M','4'), // LeatherArmor @@ -810,7 +810,7 @@ void FWadCollection::RenameSprites () MAKE_ID('S','P','I','D'), MAKE_ID('S','T','L','K'), // Stalker }; - const DWORD *renames; + const uint32_t *renames; int numrenames; switch (gameinfo.gametype) @@ -837,7 +837,7 @@ void FWadCollection::RenameSprites () } - for (DWORD i=0; i< LumpInfo.Size(); i++) + for (uint32_t i=0; i< LumpInfo.Size(); i++) { // check for full Minotaur animations. If this is not found // some frames need to be renamed. @@ -853,7 +853,7 @@ void FWadCollection::RenameSprites () renameAll = !!Args->CheckParm ("-oldsprites") || nospriterename; - for (DWORD i = 0; i < LumpInfo.Size(); i++) + for (uint32_t i = 0; i < LumpInfo.Size(); i++) { if (LumpInfo[i].lump->Namespace == ns_sprites) { @@ -916,8 +916,8 @@ void FWadCollection::RenameNerve () return; bool found = false; - BYTE cksum[16]; - static const BYTE nerve[16] = { 0x96, 0x7d, 0x5a, 0xe2, 0x3d, 0xaf, 0x45, 0x19, + uint8_t cksum[16]; + static const uint8_t nerve[16] = { 0x96, 0x7d, 0x5a, 0xe2, 0x3d, 0xaf, 0x45, 0x19, 0x62, 0x12, 0xae, 0x1b, 0x60, 0x5d, 0xa3, 0xb0 }; size_t nervesize = 3819855; // NERVE.WAD's file size int w = IWAD_FILENUM; @@ -1000,24 +1000,24 @@ void FWadCollection::FixMacHexen() reader->Seek(0, SEEK_SET); - BYTE checksum[16]; + uint8_t checksum[16]; MD5Context md5; md5.Update(reader, iwadSize); md5.Final(checksum); - static const BYTE HEXEN_DEMO_MD5[16] = + static const uint8_t HEXEN_DEMO_MD5[16] = { 0x92, 0x5f, 0x9f, 0x50, 0x00, 0xe1, 0x7d, 0xc8, 0x4b, 0x0a, 0x6a, 0x3b, 0xed, 0x3a, 0x6f, 0x31 }; - static const BYTE HEXEN_BETA_MD5[16] = + static const uint8_t HEXEN_BETA_MD5[16] = { 0x2a, 0xf1, 0xb2, 0x7c, 0xd1, 0x1f, 0xb1, 0x59, 0xe6, 0x08, 0x47, 0x2a, 0x1b, 0x53, 0xe4, 0x0e }; - static const BYTE HEXEN_FULL_MD5[16] = + static const uint8_t HEXEN_FULL_MD5[16] = { 0xb6, 0x81, 0x40, 0xa7, 0x96, 0xf6, 0xfd, 0x7f, 0x3a, 0x5d, 0x32, 0x26, 0xa3, 0x2b, 0x93, 0xbe @@ -1340,7 +1340,7 @@ FWadLump *FWadCollection::ReopenLumpNumNewFile (int lump) FileReader *FWadCollection::GetFileReader(int wadnum) { - if ((DWORD)wadnum >= Files.Size()) + if ((uint32_t)wadnum >= Files.Size()) { return NULL; } @@ -1359,7 +1359,7 @@ const char *FWadCollection::GetWadName (int wadnum) const { const char *name, *slash; - if ((DWORD)wadnum >= Files.Size()) + if ((uint32_t)wadnum >= Files.Size()) { return NULL; } @@ -1376,7 +1376,7 @@ const char *FWadCollection::GetWadName (int wadnum) const int FWadCollection::GetFirstLump (int wadnum) const { - if ((DWORD)wadnum >= Files.Size()) + if ((uint32_t)wadnum >= Files.Size()) { return 0; } @@ -1391,7 +1391,7 @@ int FWadCollection::GetFirstLump (int wadnum) const int FWadCollection::GetLastLump (int wadnum) const { - if ((DWORD)wadnum >= Files.Size()) + if ((uint32_t)wadnum >= Files.Size()) { return 0; } diff --git a/src/w_wad.h b/src/w_wad.h index a10d6d3ea..5eaea8fab 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -34,15 +34,15 @@ class FTexture; struct wadinfo_t { // Should be "IWAD" or "PWAD". - DWORD Magic; - DWORD NumLumps; - DWORD InfoTableOfs; + uint32_t Magic; + uint32_t NumLumps; + uint32_t InfoTableOfs; }; struct wadlump_t { - DWORD FilePos; - DWORD Size; + uint32_t FilePos; + uint32_t Size; char Name[8]; }; @@ -164,14 +164,14 @@ public: int CheckNumForName (const char *name, int namespc, int wadfile, bool exact = true); int GetNumForName (const char *name, int namespc); - inline int CheckNumForName (const BYTE *name) { return CheckNumForName ((const char *)name, ns_global); } + inline int CheckNumForName (const uint8_t *name) { return CheckNumForName ((const char *)name, ns_global); } inline int CheckNumForName (const char *name) { return CheckNumForName (name, ns_global); } inline int CheckNumForName (const FString &name) { return CheckNumForName (name.GetChars()); } - inline int CheckNumForName (const BYTE *name, int ns) { return CheckNumForName ((const char *)name, ns); } + inline int CheckNumForName (const uint8_t *name, int ns) { return CheckNumForName ((const char *)name, ns); } inline int GetNumForName (const char *name) { return GetNumForName (name, ns_global); } inline int GetNumForName (const FString &name) { return GetNumForName (name.GetChars(), ns_global); } - inline int GetNumForName (const BYTE *name) { return GetNumForName ((const char *)name); } - inline int GetNumForName (const BYTE *name, int ns) { return GetNumForName ((const char *)name, ns); } + inline int GetNumForName (const uint8_t *name) { return GetNumForName ((const char *)name); } + inline int GetNumForName (const uint8_t *name, int ns) { return GetNumForName ((const char *)name, ns); } int CheckNumForFullName (const char *name, bool trynormal = false, int namespc = ns_global); int CheckNumForFullName (const char *name, int wadfile); @@ -200,7 +200,7 @@ public: int FindLumpMulti (const char **names, int *lastlump, bool anyns = false, int *nameindex = NULL); // same with multiple possible names bool CheckLumpName (int lump, const char *name); // [RH] True if lump's name == name - static DWORD LumpNameHash (const char *name); // [RH] Create hash key from an 8-char name + static uint32_t LumpNameHash (const char *name); // [RH] Create hash key from an 8-char name int LumpLength (int lump) const; int GetLumpOffset (int lump); // [RH] Returns offset of lump in the wadfile @@ -229,14 +229,14 @@ protected: TArray Files; TArray LumpInfo; - DWORD *FirstLumpIndex; // [RH] Hashing stuff moved out of lumpinfo structure - DWORD *NextLumpIndex; + uint32_t *FirstLumpIndex; // [RH] Hashing stuff moved out of lumpinfo structure + uint32_t *NextLumpIndex; - DWORD *FirstLumpIndex_FullName; // The same information for fully qualified paths from .zips - DWORD *NextLumpIndex_FullName; + uint32_t *FirstLumpIndex_FullName; // The same information for fully qualified paths from .zips + uint32_t *NextLumpIndex_FullName; - DWORD NumLumps; // Not necessarily the same as LumpInfo.Size() - DWORD NumWads; + uint32_t NumLumps; // Not necessarily the same as LumpInfo.Size() + uint32_t NumWads; void SkinHack (int baselump); void InitHashChains (); // [RH] Set up the lumpinfo hashing diff --git a/src/w_zip.h b/src/w_zip.h index 4f51a13cc..6120e629b 100644 --- a/src/w_zip.h +++ b/src/w_zip.h @@ -5,53 +5,53 @@ // FZipCentralInfo struct FZipEndOfCentralDirectory { - DWORD Magic; - WORD DiskNumber; - WORD FirstDisk; - WORD NumEntries; - WORD NumEntriesOnAllDisks; - DWORD DirectorySize; - DWORD DirectoryOffset; - WORD ZipCommentLength; + uint32_t Magic; + uint16_t DiskNumber; + uint16_t FirstDisk; + uint16_t NumEntries; + uint16_t NumEntriesOnAllDisks; + uint32_t DirectorySize; + uint32_t DirectoryOffset; + uint16_t ZipCommentLength; } FORCE_PACKED; // FZipFileInfo struct FZipCentralDirectoryInfo { - DWORD Magic; - BYTE VersionMadeBy[2]; - BYTE VersionToExtract[2]; - WORD Flags; - WORD Method; - WORD ModTime; - WORD ModDate; - DWORD CRC32; - DWORD CompressedSize; - DWORD UncompressedSize; - WORD NameLength; - WORD ExtraLength; - WORD CommentLength; - WORD StartingDiskNumber; - WORD InternalAttributes; - DWORD ExternalAttributes; - DWORD LocalHeaderOffset; + uint32_t Magic; + uint8_t VersionMadeBy[2]; + uint8_t VersionToExtract[2]; + uint16_t Flags; + uint16_t Method; + uint16_t ModTime; + uint16_t ModDate; + uint32_t CRC32; + uint32_t CompressedSize; + uint32_t UncompressedSize; + uint16_t NameLength; + uint16_t ExtraLength; + uint16_t CommentLength; + uint16_t StartingDiskNumber; + uint16_t InternalAttributes; + uint32_t ExternalAttributes; + uint32_t LocalHeaderOffset; // file name and other variable length info follows } FORCE_PACKED; // FZipLocalHeader struct FZipLocalFileHeader { - DWORD Magic; - BYTE VersionToExtract[2]; - WORD Flags; - WORD Method; - WORD ModTime; - WORD ModDate; - DWORD CRC32; - DWORD CompressedSize; - DWORD UncompressedSize; - WORD NameLength; - WORD ExtraLength; + uint32_t Magic; + uint8_t VersionToExtract[2]; + uint16_t Flags; + uint16_t Method; + uint16_t ModTime; + uint16_t ModDate; + uint32_t CRC32; + uint32_t CompressedSize; + uint32_t UncompressedSize; + uint16_t NameLength; + uint16_t ExtraLength; // file name and other variable length info follows } FORCE_PACKED; diff --git a/src/weightedlist.h b/src/weightedlist.h index e171f6e35..55bcc95a8 100644 --- a/src/weightedlist.h +++ b/src/weightedlist.h @@ -44,10 +44,10 @@ class TWeightedList template struct Choice { - Choice(WORD w, U v) : Next(NULL), Weight(w), RandomVal(0), Value(v) {} + Choice(uint16_t w, U v) : Next(NULL), Weight(w), RandomVal(0), Value(v) {} Choice *Next; - WORD Weight; + uint16_t Weight; BYTE RandomVal; // 0 (never) - 255 (always) T Value; }; @@ -65,7 +65,7 @@ class TWeightedList } } - void AddEntry (T value, WORD weight); + void AddEntry (T value, uint16_t weight); T PickEntry () const; void ReplaceValues (T oldval, T newval); @@ -79,7 +79,7 @@ class TWeightedList }; template -void TWeightedList::AddEntry (T value, WORD weight) +void TWeightedList::AddEntry (T value, uint16_t weight) { if (weight == 0) { // If the weight is 0, don't bother adding it, diff --git a/src/win32/eaxedit.cpp b/src/win32/eaxedit.cpp index ec3a2ac29..c28603aa6 100644 --- a/src/win32/eaxedit.cpp +++ b/src/win32/eaxedit.cpp @@ -56,8 +56,8 @@ typedef struct w32apiFixedOFNA { LPCSTR lpstrInitialDir; LPCSTR lpstrTitle; DWORD Flags; - WORD nFileOffset; - WORD nFileExtension; + uint16_t nFileOffset; + uint16_t nFileExtension; LPCSTR lpstrDefExt; LPARAM lCustData; LPOFNHOOKPROC lpfnHook; @@ -255,7 +255,7 @@ void PopulateEnvDropDown (HWND hCtl, bool showIDs, const ReverbContainer *defEnv } } -void SetIDEdits (HWND hDlg, WORD id) +void SetIDEdits (HWND hDlg, uint16_t id) { char text[4]; @@ -292,7 +292,7 @@ void PopulateEnvList (HWND hCtl, bool show, const ReverbContainer *defEnv) SendMessage (hCtl, WM_SETREDRAW, TRUE, 0); } -WORD FirstFreeID (WORD base, bool builtin) +uint16_t FirstFreeID (uint16_t base, bool builtin) { int tryCount = 0; int priID = HIBYTE(base); @@ -316,7 +316,7 @@ WORD FirstFreeID (WORD base, bool builtin) for (;;) { - WORD lastID = Environments->ID; + uint16_t lastID = Environments->ID; const ReverbContainer *env = Environments->Next; // Find the lowest-numbered free ID with the same primary ID as base diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 2689e549a..84e98bb0e 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -879,7 +879,7 @@ bool D3DFB::CreateVertexes () { return false; } - if (FAILED(D3DDevice->CreateIndexBuffer(sizeof(WORD)*NUM_INDEXES, + if (FAILED(D3DDevice->CreateIndexBuffer(sizeof(uint16_t)*NUM_INDEXES, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFMT_INDEX16, D3DPOOL_DEFAULT, &IndexBuffer, NULL))) { return false; diff --git a/src/win32/fb_d3d9_wipe.cpp b/src/win32/fb_d3d9_wipe.cpp index fb46cc215..34cd30e74 100644 --- a/src/win32/fb_d3d9_wipe.cpp +++ b/src/win32/fb_d3d9_wipe.cpp @@ -468,7 +468,7 @@ bool D3DFB::Wiper_Melt::Run(int ticks, D3DFB *fb) BufferedTris *quad = &fb->QuadExtra[fb->QuadBatchPos]; FBVERTEX *vert = &fb->VertexData[fb->VertexPos]; - WORD *index = &fb->IndexData[fb->IndexPos]; + uint16_t *index = &fb->IndexData[fb->IndexPos]; quad->Group1 = 0; quad->Flags = BQF_DisableAlphaTest; diff --git a/src/win32/i_crash.cpp b/src/win32/i_crash.cpp index b45cda168..e338eded5 100644 --- a/src/win32/i_crash.cpp +++ b/src/win32/i_crash.cpp @@ -169,15 +169,15 @@ namespace zip { DWORD Magic; // 0 BYTE VersionToExtract[2]; // 4 - WORD Flags; // 6 - WORD Method; // 8 - WORD ModTime; // 10 - WORD ModDate; // 12 + uint16_t Flags; // 6 + uint16_t Method; // 8 + uint16_t ModTime; // 10 + uint16_t ModDate; // 12 DWORD CRC32; // 14 DWORD CompressedSize; // 18 DWORD UncompressedSize; // 22 - WORD NameLength; // 26 - WORD ExtraLength; // 28 + uint16_t NameLength; // 26 + uint16_t ExtraLength; // 28 }; struct CentralDirectoryEntry @@ -185,18 +185,18 @@ namespace zip DWORD Magic; BYTE VersionMadeBy[2]; BYTE VersionToExtract[2]; - WORD Flags; - WORD Method; - WORD ModTime; - WORD ModDate; + uint16_t Flags; + uint16_t Method; + uint16_t ModTime; + uint16_t ModDate; DWORD CRC32; DWORD CompressedSize; DWORD UncompressedSize; - WORD NameLength; - WORD ExtraLength; - WORD CommentLength; - WORD StartingDiskNumber; - WORD InternalAttributes; + uint16_t NameLength; + uint16_t ExtraLength; + uint16_t CommentLength; + uint16_t StartingDiskNumber; + uint16_t InternalAttributes; DWORD ExternalAttributes; DWORD LocalHeaderOffset; }; @@ -204,13 +204,13 @@ namespace zip struct EndOfCentralDirectory { DWORD Magic; - WORD DiskNumber; - WORD FirstDisk; - WORD NumEntries; - WORD NumEntriesOnAllDisks; + uint16_t DiskNumber; + uint16_t FirstDisk; + uint16_t NumEntries; + uint16_t NumEntriesOnAllDisks; DWORD DirectorySize; DWORD DirectoryOffset; - WORD ZipCommentLength; + uint16_t ZipCommentLength; }; #pragma pack(pop) } @@ -803,7 +803,7 @@ HANDLE WriteTextReport () //" Cr0NpxState=%08x\r\n" "\r\n" , - (WORD)ctxt->FloatSave.ControlWord, (WORD)ctxt->FloatSave.StatusWord, (WORD)ctxt->FloatSave.TagWord, + (uint16_t)ctxt->FloatSave.ControlWord, (uint16_t)ctxt->FloatSave.StatusWord, (uint16_t)ctxt->FloatSave.TagWord, ctxt->FloatSave.ErrorOffset, ctxt->FloatSave.ErrorSelector, ctxt->FloatSave.DataOffset, ctxt->FloatSave.DataSelector //, ctxt->FloatSave.Cr0NpxState @@ -1583,7 +1583,7 @@ static HANDLE MakeZip () central.CRC32 = LittleLong(TarFiles[i].CRC32); central.CompressedSize = LittleLong(TarFiles[i].CompressedSize); central.UncompressedSize = LittleLong(TarFiles[i].UncompressedSize); - central.NameLength = LittleShort((WORD)namelen); + central.NameLength = LittleShort((uint16_t)namelen); central.LocalHeaderOffset = LittleLong(TarFiles[i].ZipOffset); WriteFile (file, ¢ral, sizeof(central), &len, NULL); WriteFile (file, TarFiles[i].Filename, (DWORD)namelen, &len, NULL); @@ -1648,7 +1648,7 @@ static void AddZipFile (HANDLE ziphandle, TarFile *whichfile, short dosdate, sho local.ModTime = dostime; local.ModDate = dosdate; local.UncompressedSize = LittleLong(whichfile->UncompressedSize); - local.NameLength = LittleShort((WORD)strlen(whichfile->Filename)); + local.NameLength = LittleShort((uint16_t)strlen(whichfile->Filename)); whichfile->ZipOffset = SetFilePointer (ziphandle, 0, NULL, FILE_CURRENT); WriteFile (ziphandle, &local, sizeof(local), &wrote, NULL); diff --git a/src/win32/i_input.h b/src/win32/i_input.h index a9d165fca..f941d9e8e 100644 --- a/src/win32/i_input.h +++ b/src/win32/i_input.h @@ -89,7 +89,7 @@ protected: int WheelMove[2]; int LastX, LastY; // for m_filter - WORD ButtonState; // bit mask of current button states (1=down, 0=up) + int ButtonState; // bit mask of current button states (1=down, 0=up) }; class FKeyboard : public FInputDevice diff --git a/src/win32/i_mouse.cpp b/src/win32/i_mouse.cpp index d13ef2445..0af52cb1a 100644 --- a/src/win32/i_mouse.cpp +++ b/src/win32/i_mouse.cpp @@ -1059,7 +1059,7 @@ bool FWin32Mouse::WndProcHook(HWND hWnd, UINT message, WPARAM wParam, LPARAM lPa // a single message. Winuser.h describes the button field as being filled with // flags, which suggests that it could merge them. My testing // indicates it does not, but I will assume it might in the future. - WORD xbuttons = GET_XBUTTON_WPARAM(wParam); + auto xbuttons = GET_XBUTTON_WPARAM(wParam); event_t ev = { 0 }; ev.type = (message == WM_XBUTTONDOWN) ? EV_KeyDown : EV_KeyUp; diff --git a/src/win32/i_rawps2.cpp b/src/win32/i_rawps2.cpp index 940ef4bb1..29f477a14 100644 --- a/src/win32/i_rawps2.cpp +++ b/src/win32/i_rawps2.cpp @@ -126,7 +126,7 @@ protected: float Multiplier; AxisInfo Axes[NUM_AXES]; static DefaultAxisConfig DefaultAxes[NUM_AXES]; - WORD LastButtons; + int LastButtons; bool Connected; bool Marked; bool Active; @@ -481,7 +481,7 @@ bool FRawPS2Controller::ProcessInput(RAWHID *raw, int code) } // Generate events for buttons that have changed. - WORD buttons = 0; + int buttons = 0; // If we know we are digital, ignore the D-Pad. if (!digital) diff --git a/src/win32/i_xinput.cpp b/src/win32/i_xinput.cpp index 22c2dd714..7286a9d8f 100644 --- a/src/win32/i_xinput.cpp +++ b/src/win32/i_xinput.cpp @@ -115,7 +115,7 @@ protected: AxisInfo Axes[NUM_AXES]; static DefaultAxisConfig DefaultAxes[NUM_AXES]; DWORD LastPacketNumber; - WORD LastButtons; + int LastButtons; bool Connected; void Attached(); diff --git a/src/win32/st_start.cpp b/src/win32/st_start.cpp index 1fc47754a..4c322b90e 100644 --- a/src/win32/st_start.cpp +++ b/src/win32/st_start.cpp @@ -1342,7 +1342,7 @@ void ST_Util_DrawBlock (BITMAPINFO *bitmap_info, const BYTE *src, int x, int y, { // net progress notches for (; height > 0; --height) { - *((WORD *)dest) = *((const WORD *)src); + *((uint16_t *)dest) = *((const uint16_t *)src); dest += destpitch; src += 2; } diff --git a/src/win32/win32gliface.cpp b/src/win32/win32gliface.cpp index 1323787a9..01635d5c7 100644 --- a/src/win32/win32gliface.cpp +++ b/src/win32/win32gliface.cpp @@ -1038,7 +1038,7 @@ void Win32GLFrameBuffer::ResetGammaTable() } } -void Win32GLFrameBuffer::SetGammaTable(WORD *tbl) +void Win32GLFrameBuffer::SetGammaTable(uint16_t *tbl) { if (m_supportsGamma) { diff --git a/src/win32/win32gliface.h b/src/win32/win32gliface.h index fbaf34bd5..49431b114 100644 --- a/src/win32/win32gliface.h +++ b/src/win32/win32gliface.h @@ -138,7 +138,7 @@ protected: bool CanUpdate(); void ResetGammaTable(); - void SetGammaTable(WORD * tbl); + void SetGammaTable(uint16_t * tbl); float m_Gamma, m_Brightness, m_Contrast; WORD m_origGamma[768]; diff --git a/src/win32/win32iface.h b/src/win32/win32iface.h index 0dafab6fb..0a81f5781 100644 --- a/src/win32/win32iface.h +++ b/src/win32/win32iface.h @@ -127,7 +127,7 @@ public: virtual void Blank () = 0; virtual bool PaintToWindow () = 0; virtual HRESULT GetHR () = 0; - virtual void ScaleCoordsFromWindow(SWORD &x, SWORD &y); + virtual void ScaleCoordsFromWindow(int16_t &x, int16_t &y); protected: virtual bool CreateResources () = 0; @@ -304,8 +304,8 @@ private: BYTE Desat; D3DPal *Palette; IDirect3DTexture9 *Texture; - WORD NumVerts; // Number of _unique_ vertices used by this set. - WORD NumTris; // Number of triangles used by this set. + int NumVerts; // Number of _unique_ vertices used by this set. + int NumTris; // Number of triangles used by this set. }; enum @@ -448,7 +448,7 @@ private: IDirect3DVertexBuffer9 *VertexBuffer; FBVERTEX *VertexData; IDirect3DIndexBuffer9 *IndexBuffer; - WORD *IndexData; + uint16_t *IndexData; BufferedTris *QuadExtra; int VertexPos; int IndexPos; diff --git a/src/win32/win32video.cpp b/src/win32/win32video.cpp index 5a09a7af7..319305a2f 100644 --- a/src/win32/win32video.cpp +++ b/src/win32/win32video.cpp @@ -758,15 +758,15 @@ void Win32Video::SetWindowedScale (float scale) // //========================================================================== -void BaseWinFB::ScaleCoordsFromWindow(SWORD &x, SWORD &y) +void BaseWinFB::ScaleCoordsFromWindow(int16_t &x, int16_t &y) { RECT rect; int TrueHeight = GetTrueHeight(); if (GetClientRect(Window, &rect)) { - x = SWORD(x * Width / (rect.right - rect.left)); - y = SWORD(y * TrueHeight / (rect.bottom - rect.top)); + x = int16_t(x * Width / (rect.right - rect.left)); + y = int16_t(y * TrueHeight / (rect.bottom - rect.top)); } // Subtract letterboxing borders y -= (TrueHeight - Height) / 2; diff --git a/src/xlat/parse_xlat.cpp b/src/xlat/parse_xlat.cpp index 6e5266cbf..87e68954d 100644 --- a/src/xlat/parse_xlat.cpp +++ b/src/xlat/parse_xlat.cpp @@ -80,8 +80,8 @@ struct SpecialArg struct ListFilter { - WORD filter; - BYTE value; + uint16_t filter; + uint8_t value; }; struct MoreFilters @@ -98,8 +98,8 @@ struct MoreLines struct ParseBoomArg { - BYTE constant; - WORD mask; + uint8_t constant; + uint16_t mask; MoreFilters *filters; }; diff --git a/src/xlat/xlat.h b/src/xlat/xlat.h index 494ac7992..770f69bca 100644 --- a/src/xlat/xlat.h +++ b/src/xlat/xlat.h @@ -69,15 +69,15 @@ struct FBoomArg BYTE ListSize; BYTE ArgNum; BYTE ConstantValue; - WORD AndValue; - WORD ResultFilter[15]; + uint16_t AndValue; + uint16_t ResultFilter[15]; BYTE ResultValue[15]; }; struct FBoomTranslator { - WORD FirstLinetype; - WORD LastLinetype; + uint16_t FirstLinetype; + uint16_t LastLinetype; BYTE NewSpecial; TArray Args; } ;