diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml index e080bf629..03e2cdf9f 100644 --- a/.github/workflows/continuous_integration.yml +++ b/.github/workflows/continuous_integration.yml @@ -43,10 +43,10 @@ jobs: build_type: "RelWithDebInfo" } - { - name: "Linux GCC 10", + name: "Linux GCC 11", os: ubuntu-20.04, - extra_options: "-DCMAKE_C_COMPILER=gcc-10 -DCMAKE_CXX_COMPILER=g++-10", - deps_cmdline: "sudo apt update && sudo apt install g++-10 libsdl2-dev libvpx-dev libgtk-3-dev", + extra_options: "-DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11", + deps_cmdline: "sudo apt update && sudo apt install g++-11 libsdl2-dev libvpx-dev libgtk-3-dev", build_type: "MinSizeRel" } - { @@ -54,7 +54,7 @@ jobs: os: ubuntu-20.04, extra_options: "-DCMAKE_C_COMPILER=clang-6.0 -DCMAKE_CXX_COMPILER=clang++-6.0 \ -DDYN_FLUIDSYNTH=OFF -DDYN_OPENAL=OFF -DDYN_SNDFILE=OFF -DDYN_MPG123=OFF", - deps_cmdline: "sudo apt update && sudo apt install clang-6.0 libsdl2-dev libvpx-dev libopenal-dev libfluidsynth-dev libmpg123-dev libsndfile1-dev", + deps_cmdline: "sudo apt update && sudo apt remove gcc-11 libgcc-11-dev g++-11 libstdc++-11-dev && sudo apt install clang-6.0 libstdc++-9-dev libsdl2-dev libvpx-dev libopenal-dev libfluidsynth-dev libmpg123-dev libsndfile1-dev", build_type: "Debug" } - { diff --git a/CMakeLists.txt b/CMakeLists.txt index fa7d66978..a5696bb77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,7 +234,7 @@ if( MSVC ) set( ALL_C_FLAGS "${ALL_C_FLAGS} /wd4996 /DUNICODE /D_UNICODE /D_WIN32_WINNT=0x0600" ) # These must be silenced because the code is full of them. Expect some of undefined behavior hidden in this mess. :( - set( ALL_C_FLAGS "${ALL_C_FLAGS} /wd4244 /wd4018 /wd4267" ) + #set( ALL_C_FLAGS "${ALL_C_FLAGS} /wd4244 /wd4018 /wd4267" ) # Most of these need to be cleaned out. The source is currently infested with far too much conditional compilation which is a constant source of problems. diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 5f98674b7..55528c95d 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -828,8 +828,6 @@ set( NOT_COMPILED_SOURCE_FILES games/duke/src/render.cpp games/duke/src/savegame.cpp games/duke/src/sbar.cpp - games/duke/src/sbar_d.cpp - games/duke/src/sbar_r.cpp games/duke/src/sectors.cpp games/duke/src/sectors_d.cpp games/duke/src/sectors_r.cpp diff --git a/source/build/include/build.h b/source/build/include/build.h index 6f09a4d15..0b7163ec3 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -392,7 +392,7 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange int32_t (*blacklist_sprite_func)(int32_t) = nullptr) ATTRIBUTE((nonnull(6,7,8))); int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, int32_t y2, int32_t z2, int16_t sect2); -int32_t inside(int32_t x, int32_t y, int16_t sectnum); +int32_t inside(int32_t x, int32_t y, int sectnum); void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags = 0); int32_t try_facespr_intersect(uspriteptr_t const spr, vec3_t const in, int32_t vx, int32_t vy, int32_t vz, @@ -420,9 +420,9 @@ inline int32_t krand(void) int32_t krand(void); #endif -inline int32_t ksqrt(uint32_t num) +inline int32_t ksqrt(uint64_t num) { - return int(sqrt((float)num)); + return int(sqrt(double(num))); } int32_t getangle(int32_t xvect, int32_t yvect); @@ -461,36 +461,36 @@ void yax_getzsofslope(int sectNum, int playerX, int playerY, int32_t* pCeilZ, in int32_t yax_getceilzofslope(int const sectnum, vec2_t const vect); int32_t yax_getflorzofslope(int const sectnum, vec2_t const vect); -inline int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day) +inline int32_t getceilzofslope(int sectnum, int32_t dax, int32_t day) { return getceilzofslopeptr((usectorptr_t)§or[sectnum], dax, day); } -inline int32_t getflorzofslope(int16_t sectnum, int32_t dax, int32_t day) +inline int32_t getflorzofslope(int sectnum, int32_t dax, int32_t day) { return getflorzofslopeptr((usectorptr_t)§or[sectnum], dax, day); } -inline void getzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) +inline void getzsofslope(int sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) { getzsofslopeptr((usectorptr_t)§or[sectnum], dax, day, ceilz, florz); } -inline void getcorrectzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) +inline void getcorrectzsofslope(int sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) { vec2_t closest = { dax, day }; getsectordist(closest, sectnum, &closest); getzsofslopeptr((usectorptr_t)§or[sectnum], closest.x, closest.y, ceilz, florz); } -inline int32_t getcorrectceilzofslope(int16_t sectnum, int32_t dax, int32_t day) +inline int32_t getcorrectceilzofslope(int sectnum, int32_t dax, int32_t day) { vec2_t closest = { dax, day }; getsectordist(closest, sectnum, &closest); return getceilzofslopeptr((usectorptr_t)§or[sectnum], closest.x, closest.y); } -inline int32_t getcorrectflorzofslope(int16_t sectnum, int32_t dax, int32_t day) +inline int32_t getcorrectflorzofslope(int sectnum, int32_t dax, int32_t day) { vec2_t closest = { dax, day }; getsectordist(closest, sectnum, &closest); @@ -706,8 +706,8 @@ extern int32_t(*changespritestat_replace)(int16_t spritenum, int16_t newstatnum) enum EHitBits { kHitNone = 0, - kHitTypeMask = 0xE000, - kHitIndexMask = 0x1FFF, + kHitTypeMask = 0xC000, + kHitIndexMask = 0x3FFF, kHitSector = 0x4000, kHitWall = 0x8000, kHitSprite = 0xC000, diff --git a/source/build/include/buildtypes.h b/source/build/include/buildtypes.h index 5bf3e7989..98b6bb7f4 100644 --- a/source/build/include/buildtypes.h +++ b/source/build/include/buildtypes.h @@ -79,14 +79,14 @@ struct sectortype int ceilingypan() const { return int(ceilingypan_); } int floorxpan() const { return int(floorxpan_); } int floorypan() const { return int(floorypan_); } - void setfloorxpan(float val) { floorxpan_ = fmod(val + 512, 256); } // +512 is for handling negative offsets - void setfloorypan(float val) { floorypan_ = fmod(val + 512, 256); } // +512 is for handling negative offsets - void setceilingxpan(float val) { ceilingxpan_ = fmod(val + 512, 256); } // +512 is for handling negative offsets - void setceilingypan(float val) { ceilingypan_ = fmod(val + 512, 256); } // +512 is for handling negative offsets - void addfloorxpan(float add) { floorxpan_ = fmod(floorxpan_ + add + 512, 256); } // +512 is for handling negative offsets - void addfloorypan(float add) { floorypan_ = fmod(floorypan_ + add + 512, 256); } // +512 is for handling negative offsets - void addceilingxpan(float add) { ceilingxpan_ = fmod(ceilingxpan_ + add + 512, 256); } // +512 is for handling negative offsets - void addceilingypan(float add) { ceilingypan_ = fmod(ceilingypan_ + add + 512, 256); } // +512 is for handling negative offsets + void setfloorxpan(float val) { floorxpan_ = fmodf(val + 512, 256); } // +512 is for handling negative offsets + void setfloorypan(float val) { floorypan_ = fmodf(val + 512, 256); } // +512 is for handling negative offsets + void setceilingxpan(float val) { ceilingxpan_ = fmodf(val + 512, 256); } // +512 is for handling negative offsets + void setceilingypan(float val) { ceilingypan_ = fmodf(val + 512, 256); } // +512 is for handling negative offsets + void addfloorxpan(float add) { floorxpan_ = fmodf(floorxpan_ + add + 512, 256); } // +512 is for handling negative offsets + void addfloorypan(float add) { floorypan_ = fmodf(floorypan_ + add + 512, 256); } // +512 is for handling negative offsets + void addceilingxpan(float add) { ceilingxpan_ = fmodf(ceilingxpan_ + add + 512, 256); } // +512 is for handling negative offsets + void addceilingypan(float add) { ceilingypan_ = fmodf(ceilingypan_ + add + 512, 256); } // +512 is for handling negative offsets }; //cstat: @@ -130,10 +130,10 @@ struct walltype int xpan() const { return int(xpan_); } int ypan() const { return int(ypan_); } - void setxpan(float val) { xpan_ = fmod(val + 512, 256); } // +512 is for handling negative offsets - void setypan(float val) { ypan_ = fmod(val + 512, 256); } // +512 is for handling negative offsets - void addxpan(float add) { xpan_ = fmod(xpan_ + add + 512, 256); } // +512 is for handling negative offsets - void addypan(float add) { ypan_ = fmod(ypan_ + add + 512, 256); } // +512 is for handling negative offsets + void setxpan(float add) { xpan_ = fmodf(add + 512, 256); } // +512 is for handling negative offsets + void setypan(float add) { ypan_ = fmodf(add + 512, 256); } // +512 is for handling negative offsets + void addxpan(float add) { xpan_ = fmodf(xpan_ + add + 512, 256); } // +512 is for handling negative offsets + void addypan(float add) { ypan_ = fmodf(ypan_ + add + 512, 256); } // +512 is for handling negative offsets #if 0 // make sure we do not accidentally copy this diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index 109d34380..2a3ba6352 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -295,7 +295,7 @@ static inline int32_t cliptrace(vec2_t const pos, vec2_t * const goal) { int32_t hitwall = -1; - for (native_t z=clipnum-1; z>=0; z--) + for (int z=clipnum-1; z>=0; z--) { vec2_t const p1 = { clipit[z].x1, clipit[z].y1 }; vec2_t const p2 = { clipit[z].x2, clipit[z].y2 }; @@ -716,13 +716,13 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int int32_t hitwalls[4], hitwall; int32_t clipReturn = 0; - native_t cnt = clipmoveboxtracenum; + int cnt = clipmoveboxtracenum; do { if (enginecompatibility_mode == ENGINECOMPATIBILITY_NONE && (xvect|yvect)) { - for (native_t i=clipnum-1;i>=0;--i) + for (int i=clipnum-1;i>=0;--i) { if (!bitmap_test(clipignore, i) && clipinsideboxline(pos->x, pos->y, clipit[i].x1, clipit[i].y1, clipit[i].x2, clipit[i].y2, walldist)) { @@ -750,7 +750,7 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int int32_t const templl2 = (int32_t)clamp(compat_maybe_truncate_to_int32((int64_t)(goal.x - vec.x) * clipr.x + (int64_t)(goal.y - vec.y) * clipr.y), INT32_MIN, INT32_MAX); int32_t const i = (enginecompatibility_mode == ENGINECOMPATIBILITY_19950829 || (abs(templl2)>>11) < templl) ? - DivScaleL(templl2, templl, 20) : 0; + (int)DivScaleL(templl2, templl, 20) : 0; goal = { MulScale(clipr.x, i, 20)+vec.x, MulScale(clipr.y, i, 20)+vec.y }; } @@ -807,7 +807,7 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int int32_t tempint2, tempint1 = INT32_MAX; *sectnum = -1; - for (native_t j=numsectors-1; j>=0; j--) + for (int j=numsectors-1; j>=0; j--) if (inside(pos->x, pos->y, j) == 1) { if (enginecompatibility_mode != ENGINECOMPATIBILITY_19950829 && (sector[j].ceilingstat&2)) @@ -819,7 +819,8 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int { if (tempint2 < tempint1) { - *sectnum = j; tempint1 = tempint2; + *sectnum = (int16_t)j; + tempint1 = tempint2; } } else @@ -831,12 +832,13 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int if (tempint2 <= 0) { - *sectnum = j; + *sectnum = (int16_t)j; return clipReturn; } if (tempint2 < tempint1) { - *sectnum = j; tempint1 = tempint2; + *sectnum = (int16_t)j; + tempint1 = tempint2; } } } @@ -1257,9 +1259,9 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t * { if (tmp==NULL) { - if (inside(x1,y1,sec-sector) == 1) + if (inside(x1,y1,int(sec-sector)) == 1) { - hit_set(hit, sec-sector, -1, -1, x1, y1, z1); + hit_set(hit, int(sec-sector), -1, -1, x1, y1, z1); hitscan_hitsectcf = (how+1)>>1; } } @@ -1267,12 +1269,12 @@ static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t * { const int32_t curidx=(int32_t)tmp[0]; auto const curspr=(spritetype *)tmp[1]; - const int32_t thislastsec = tmp[2]; + const int32_t thislastsec = (int32_t)tmp[2]; if (!thislastsec) { - if (inside(x1,y1,sec-sector) == 1) - hit_set(hit, curspr->sectnum, -1, curspr-sprite, x1, y1, z1); + if (inside(x1,y1,int(sec-sector)) == 1) + hit_set(hit, int(curspr->sectnum), -1, int(curspr-sprite), x1, y1, z1); } } } diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 75da21c2d..dbef8264d 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -778,7 +778,7 @@ int32_t inside_old(int32_t x, int32_t y, int16_t sectnum) return -1; } -int32_t inside(int32_t x, int32_t y, int16_t sectnum) +int32_t inside(int32_t x, int32_t y, int sectnum) { switch (enginecompatibility_mode) { diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index bac6b65cf..157dc1f23 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -19,6 +19,12 @@ #include "hw_voxels.h" #include "../../glbackend/glbackend.h" +#ifdef _MSC_VER +// just make it shut up. Most of this file will go down the drain anyway soon. +#pragma warning(disable:4244) +#pragma warning(disable:4267) +#endif + static int32_t curextra=MAXTILES; #define MIN_CACHETIME_PRINT 10 diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index a8a7572bc..95d4bef9d 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -28,6 +28,10 @@ Ken Silverman's official web site: http://www.advsys.net/ken #include "gamestruct.h" #include "hw_voxels.h" +#ifdef _MSC_VER +// just make it shut up. Most of this file will go down the drain anyway soon. +#pragma warning(disable:4244) +#endif typedef struct { union { double x; double d; }; @@ -309,7 +313,7 @@ static void polymost_updaterotmat(void) renderSetVisibility(g_visibility * fxdimen * (1.f / (65536.f)) / r_ambientlight); } -const vec2_16_t tileSize(size_t index) +const vec2_16_t tileSize(int index) { vec2_16_t v = { (int16_t)tileWidth(index), (int16_t)tileHeight(index) }; return v; diff --git a/source/common/audio/sound/s_sound.cpp b/source/common/audio/sound/s_sound.cpp index 7112308dd..98ef9a4e0 100644 --- a/source/common/audio/sound/s_sound.cpp +++ b/source/common/audio/sound/s_sound.cpp @@ -929,12 +929,7 @@ void SoundEngine::StopSound(int sourcetype, const void* actor, int channel, int void SoundEngine::StopActorSounds(int sourcetype, const void* actor, int chanmin, int chanmax) { const bool all = (chanmin == 0 && chanmax == 0); - if (!all && chanmax > chanmin) - { - const int temp = chanmax; - chanmax = chanmin; - chanmin = temp; - } + if (chanmax < chanmin) std::swap(chanmin, chanmax); FSoundChan* chan = Channels; while (chan != nullptr) diff --git a/source/common/console/c_enginecmds.cpp b/source/common/console/c_enginecmds.cpp index 542abe91d..0af6f3b56 100644 --- a/source/common/console/c_enginecmds.cpp +++ b/source/common/console/c_enginecmds.cpp @@ -293,8 +293,8 @@ CCMD (md5sum) } for (int i = 1; i < argv.argc(); ++i) { - FileReader fr = fileSystem.OpenFileReader(argv[i]); - if (!fr.isOpen()) + FileReader fr; + if (!fr.OpenFile(argv[i])) { Printf("%s: %s\n", argv[i], strerror(errno)); } diff --git a/source/common/engine/namedef.h b/source/common/engine/namedef.h index 8ec5d4081..af285ce7e 100644 --- a/source/common/engine/namedef.h +++ b/source/common/engine/namedef.h @@ -1108,3 +1108,4 @@ xy(menu_advance, "menu/advance") xx(zoomsize) xx(ScreenJobRunner) +xx(RazeStatusBar) diff --git a/source/common/engine/sc_man.h b/source/common/engine/sc_man.h index 56a4a8d82..1caa177a2 100644 --- a/source/common/engine/sc_man.h +++ b/source/common/engine/sc_man.h @@ -145,6 +145,12 @@ public: return true; } + bool GetFloat(float& var, bool evaluate = false) + { + if (!GetFloat(evaluate)) return false; + var = float(Float); + return true; + } void MustGetFloat(bool evaluate = false); bool CheckFloat(bool evaluate = false); diff --git a/source/common/menu/savegamemanager.cpp b/source/common/menu/savegamemanager.cpp index 22dd8c6a3..935b6dedd 100644 --- a/source/common/menu/savegamemanager.cpp +++ b/source/common/menu/savegamemanager.cpp @@ -232,7 +232,6 @@ DEFINE_ACTION_FUNCTION(FSavegameManager, LoadSavegame) void FSavegameManagerBase::DoSave(int Selected, const char *savegamestring) { - RemoveNewSaveNode(); if (Selected != 0) { auto node = SaveGames[Selected]; diff --git a/source/common/objects/dobject.cpp b/source/common/objects/dobject.cpp index 3676e7eaf..9f4a164e4 100644 --- a/source/common/objects/dobject.cpp +++ b/source/common/objects/dobject.cpp @@ -314,7 +314,7 @@ void DObject::Release() // //========================================================================== -void DObject:: Destroy () +void DObject::Destroy () { // We cannot call the VM during shutdown because all the needed data has been or is in the process of being deleted. if (PClass::bVMOperational) diff --git a/source/common/platform/posix/sdl/sdlglvideo.cpp b/source/common/platform/posix/sdl/sdlglvideo.cpp index 9487854f9..43bd99a64 100644 --- a/source/common/platform/posix/sdl/sdlglvideo.cpp +++ b/source/common/platform/posix/sdl/sdlglvideo.cpp @@ -449,13 +449,14 @@ DFrameBuffer *SDLVideo::CreateFrameBuffer () device = new VulkanDevice(); fb = new VulkanFrameBuffer(nullptr, vid_fullscreen, device); } - catch (CVulkanError const&) + catch (CVulkanError const &error) { if (Priv::window != nullptr) { Priv::DestroyWindow(); } + Printf(TEXTCOLOR_RED "Initialization of Vulkan failed: %s\n", error.what()); Priv::vulkanEnabled = false; } } diff --git a/source/common/scripting/core/dynarrays.cpp b/source/common/scripting/core/dynarrays.cpp index 6be216c12..21a362248 100644 --- a/source/common/scripting/core/dynarrays.cpp +++ b/source/common/scripting/core/dynarrays.cpp @@ -1006,6 +1006,22 @@ DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Push, ArrayPushPush(val)); } +DEFINE_ACTION_FUNCTION(FDynArray_String, PushV) +{ + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); + PARAM_VA_POINTER(va_reginfo); // Get the hidden type information array + VMVa_List args = { param + 1, 0, numparam - 2, va_reginfo + 1 }; + while (args.curindex < args.numargs) + { + if (args.reginfo[args.curindex] == REGT_STRING) + { + self->Push(args.args[args.curindex++].s()); + } + else ThrowAbortException(X_OTHER, "Invalid parameter in pushv, string expected"); + } + ACTION_RETURN_INT(self->Size() - 1); +} + DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Pop, ArrayPop) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); diff --git a/source/common/scripting/interface/vmnatives.cpp b/source/common/scripting/interface/vmnatives.cpp index 23705b93a..6276ac906 100644 --- a/source/common/scripting/interface/vmnatives.cpp +++ b/source/common/scripting/interface/vmnatives.cpp @@ -81,10 +81,10 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, StatusbarToRealCoords, StatusbarTo return MIN(4, numret); } -void SBar_DrawTexture(DStatusBarCore* self, int texid, double x, double y, int flags, double alpha, double w, double h, double scaleX, double scaleY, int style) +void SBar_DrawTexture(DStatusBarCore* self, int texid, double x, double y, int flags, double alpha, double w, double h, double scaleX, double scaleY, int style, int color, int translation, double clipwidth) { if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); - self->DrawGraphic(FSetTextureID(texid), x, y, flags, alpha, w, h, scaleX, scaleY, ERenderStyle(style)); + self->DrawGraphic(FSetTextureID(texid), x, y, flags, alpha, w, h, scaleX, scaleY, ERenderStyle(style), color, translation, clipwidth); } DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawTexture, SBar_DrawTexture) @@ -100,14 +100,17 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawTexture, SBar_DrawTexture) PARAM_FLOAT(scaleX); PARAM_FLOAT(scaleY); PARAM_INT(style); - SBar_DrawTexture(self, texid, x, y, flags, alpha, w, h, scaleX, scaleY, style); + PARAM_INT(col); + PARAM_INT(trans); + PARAM_FLOAT(clipwidth); + SBar_DrawTexture(self, texid, x, y, flags, alpha, w, h, scaleX, scaleY, style, col, trans, clipwidth); return 0; } -void SBar_DrawImage(DStatusBarCore* self, const FString& texid, double x, double y, int flags, double alpha, double w, double h, double scaleX, double scaleY, int style) +void SBar_DrawImage(DStatusBarCore* self, const FString& texid, double x, double y, int flags, double alpha, double w, double h, double scaleX, double scaleY, int style, int color, int translation, double clipwidth) { if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); - self->DrawGraphic(TexMan.CheckForTexture(texid, ETextureType::Any), x, y, flags, alpha, w, h, scaleX, scaleY, ERenderStyle(style)); + self->DrawGraphic(TexMan.CheckForTexture(texid, ETextureType::Any), x, y, flags, alpha, w, h, scaleX, scaleY, ERenderStyle(style), color, translation, clipwidth); } DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawImage, SBar_DrawImage) @@ -123,10 +126,62 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawImage, SBar_DrawImage) PARAM_FLOAT(scaleX); PARAM_FLOAT(scaleY); PARAM_INT(style); - SBar_DrawImage(self, texid, x, y, flags, alpha, w, h, scaleX, scaleY, style); + PARAM_INT(col); + PARAM_INT(trans); + PARAM_FLOAT(clipwidth); + SBar_DrawImage(self, texid, x, y, flags, alpha, w, h, scaleX, scaleY, style, col, trans, clipwidth); return 0; } +void SBar_DrawImageRotated(DStatusBarCore* self, const FString& texid, double x, double y, int flags, double angle, double alpha, double scaleX, double scaleY, int style, int color, int translation) +{ + if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); + self->DrawRotated(TexMan.CheckForTexture(texid, ETextureType::Any), x, y, flags, angle, alpha, scaleX, scaleY, color, translation, (ERenderStyle)style); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawImageRotated, SBar_DrawImageRotated) +{ + PARAM_SELF_PROLOGUE(DStatusBarCore); + PARAM_STRING(texid); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_INT(flags); + PARAM_FLOAT(angle); + PARAM_FLOAT(alpha); + PARAM_FLOAT(scaleX); + PARAM_FLOAT(scaleY); + PARAM_INT(style); + PARAM_INT(col); + PARAM_INT(trans); + SBar_DrawImageRotated(self, texid, x, y, flags, angle, alpha, scaleX, scaleY, style, col, trans); + return 0; +} + +void SBar_DrawTextureRotated(DStatusBarCore* self, int texid, double x, double y, int flags, double angle, double alpha, double scaleX, double scaleY, int style, int color, int translation) +{ + if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); + self->DrawRotated(FSetTextureID(texid), x, y, flags, alpha, scaleX, scaleY, color, translation, style); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawTextureRotated, SBar_DrawTextureRotated) +{ + PARAM_SELF_PROLOGUE(DStatusBarCore); + PARAM_INT(texid); + PARAM_FLOAT(x); + PARAM_FLOAT(y); + PARAM_INT(flags); + PARAM_FLOAT(angle); + PARAM_FLOAT(alpha); + PARAM_FLOAT(scaleX); + PARAM_FLOAT(scaleY); + PARAM_INT(style); + PARAM_INT(col); + PARAM_INT(trans); + SBar_DrawTextureRotated(self, texid, x, y, flags, angle, alpha, scaleX, scaleY, style, col, trans); + return 0; +} + + void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY, int translation, int style); DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, DrawString, SBar_DrawString) diff --git a/source/common/statusbar/base_sbar.cpp b/source/common/statusbar/base_sbar.cpp index 948b2504b..5e29ae0db 100644 --- a/source/common/statusbar/base_sbar.cpp +++ b/source/common/statusbar/base_sbar.cpp @@ -51,7 +51,7 @@ FGameTexture* CrosshairImage; static int CrosshairNum; -IMPLEMENT_CLASS(DStatusBarCore, true, false) +IMPLEMENT_CLASS(DStatusBarCore, false, false) IMPLEMENT_CLASS(DHUDFont, false, false); @@ -458,7 +458,7 @@ void DStatusBarCore::DrawGraphic(FTextureID texture, double x, double y, int fla return; FGameTexture* tex = TexMan.GetGameTexture(texture, !(flags & DI_DONTANIMATE)); - DrawGraphic(tex, x, y, flags, Alpha, boxwidth, boxheight, scaleX, scaleY, style, color, translation); + DrawGraphic(tex, x, y, flags, Alpha, boxwidth, boxheight, scaleX, scaleY, style, color, translation, clipwidth); } void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flags, double Alpha, double boxwidth, double boxheight, double scaleX, double scaleY, ERenderStyle style, PalEntry color, int translation, double clipwidth) @@ -577,6 +577,10 @@ void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flag x += orgx; y += orgy; } + if (clipwidth != -1) + { + int a = 0; + } DrawTexture(twod, tex, x, y, DTA_TopOffset, 0, DTA_LeftOffset, 0, @@ -594,7 +598,7 @@ void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flag DTA_FillColor, (flags & DI_ALPHAMAPPED) ? 0 : -1, DTA_FlipX, !!(flags & DI_MIRROR), DTA_FlipY, !!(flags& DI_MIRRORY), - DTA_LegacyRenderStyle, style, + DTA_LegacyRenderStyle, (flags & DI_ALPHAMAPPED) ? STYLE_Shaded : style, TAG_DONE); } diff --git a/source/common/thirdparty/base64.cpp b/source/common/thirdparty/base64.cpp index e7099711a..fcd0ae414 100644 --- a/source/common/thirdparty/base64.cpp +++ b/source/common/thirdparty/base64.cpp @@ -89,8 +89,8 @@ TArray base64_encode(unsigned char const* bytes_to_encode, size_t in_le while((i++ < 3)) reta.Push('='); - reta.Push(0); } + reta.Push(0); return reta; diff --git a/source/core/automap.cpp b/source/core/automap.cpp index 1b7ba5519..f9ef9e153 100644 --- a/source/core/automap.cpp +++ b/source/core/automap.cpp @@ -185,7 +185,7 @@ static void CalcMapBounds() void AutomapControl() { static int nonsharedtimer; - int ms = screen->FrameTime; + int ms = (int)screen->FrameTime; int interval; int panvert = 0, panhorz = 0; @@ -197,7 +197,7 @@ void AutomapControl() { interval = 0; } - nonsharedtimer = screen->FrameTime; + nonsharedtimer = ms; if (System_WantGuiCapture()) return; diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index b843b1688..4b033c31a 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -362,22 +362,37 @@ inline binangle bvectangbam(int32_t x, int32_t y) // //--------------------------------------------------------------------------- -inline int32_t interpolatedvalue(int32_t oval, int32_t val, double const smoothratio, int const scale = 16) +inline constexpr int32_t interpolatedvalue(int32_t oval, int32_t val, double const smoothratio, int const scale = 16) +{ + return oval + MulScale(val - oval, int(smoothratio), scale); +} + +inline constexpr int32_t interpolatedvalue(int32_t oval, int32_t val, int const smoothratio, int const scale = 16) { return oval + MulScale(val - oval, smoothratio, scale); } -inline double interpolatedvaluef(double oval, double val, double const smoothratio, int const scale = 16) +inline constexpr double interpolatedvaluef(double oval, double val, double const smoothratio, int const scale = 16) { return oval + MulScaleF(val - oval, smoothratio, scale); } -inline int32_t interpolatedangle(int32_t oang, int32_t ang, double const smoothratio, int const scale = 16) +inline constexpr int32_t interpolatedangle(int32_t oang, int32_t ang, double const smoothratio, int const scale = 16) +{ + return oang + MulScale(((ang + 1024 - oang) & 2047) - 1024, int(smoothratio), scale); +} + +inline constexpr int32_t interpolatedangle(int32_t oang, int32_t ang, int const smoothratio, int const scale = 16) { return oang + MulScale(((ang + 1024 - oang) & 2047) - 1024, smoothratio, scale); } -inline binangle interpolatedangle(binangle oang, binangle ang, double const smoothratio, int const scale = 16) +inline constexpr binangle interpolatedangle(binangle oang, binangle ang, double const smoothratio, int const scale = 16) +{ + return bamang(oang.asbam() + MulScale(((ang.asbam() + 0x80000000 - oang.asbam()) & 0xFFFFFFFF) - 0x80000000, int(smoothratio), scale)); +} + +inline constexpr binangle interpolatedangle(binangle oang, binangle ang, int const smoothratio, int const scale = 16) { return bamang(oang.asbam() + MulScale(((ang.asbam() + 0x80000000 - oang.asbam()) & 0xFFFFFFFF) - 0x80000000, smoothratio, scale)); } diff --git a/source/core/cheats.cpp b/source/core/cheats.cpp index 9b670931c..013a145fc 100644 --- a/source/core/cheats.cpp +++ b/source/core/cheats.cpp @@ -196,7 +196,7 @@ CCMD(give) if (!CheckCheatmode(true, true)) { Net_WriteByte(DEM_GIVE); - Net_WriteByte(found); + Net_WriteByte((uint8_t)found); } } diff --git a/source/core/cheats.h b/source/core/cheats.h index 7398073ae..d014dd03a 100644 --- a/source/core/cheats.h +++ b/source/core/cheats.h @@ -9,3 +9,4 @@ EXTERN_CVAR(Bool, sv_cheats) void genericCheat(int player, uint8_t** stream, bool skip); void changeMap(int player, uint8_t** stream, bool skip); void endScreenJob(int player, uint8_t** stream, bool skip); +void startSaveGame(int player, uint8_t** stream, bool skip); diff --git a/source/core/console/c_notifybuffer.cpp b/source/core/console/c_notifybuffer.cpp index d4375c20b..575e0b35b 100644 --- a/source/core/console/c_notifybuffer.cpp +++ b/source/core/console/c_notifybuffer.cpp @@ -116,10 +116,10 @@ void FNotifyBuffer::DrawNative() FFont* font = isBlood() ? SmallFont2 : SmallFont; - int line = isBlood() ? Top : (g_gameType & GAMEFLAG_SW) ? 40 : (g_gameType & GAMEFLAG_WHALL)? 18 : font->GetDisplacement(); + double line = isBlood() ? Top : (g_gameType & GAMEFLAG_SW) ? 40 : (g_gameType & GAMEFLAG_WHALL)? 18 : font->GetDisplacement(); bool canskip = isBlood(); double scale = 1 / (NotifyFontScale * con_notifyscale); - int lineadv = font->GetHeight() / NotifyFontScale; + double lineadv = font->GetHeight() / NotifyFontScale; int textleft = (g_gameType & GAMEFLAG_WHALL) ? 18 : 0; for (unsigned i = topline; i < Text.Size(); ++i) @@ -193,8 +193,8 @@ void FNotifyBuffer::Draw() double nfscale = (generic_ui? 0.7 : NotifyFontScale); double scale = 1 / ( * con_notifyscale); - int line = Top + font->GetDisplacement() / nfscale; - int lineadv = font->GetHeight () / nfscale; + double line = Top + font->GetDisplacement() / nfscale; + double lineadv = font->GetHeight () / nfscale; for (unsigned i = 0; i < Text.Size(); ++ i) { diff --git a/source/core/d_net.cpp b/source/core/d_net.cpp index 30c7891d1..041eada4f 100644 --- a/source/core/d_net.cpp +++ b/source/core/d_net.cpp @@ -1674,6 +1674,7 @@ bool D_CheckNetGame (void) Net_SetCommandHandler(DEM_GENERICCHEAT, genericCheat); Net_SetCommandHandler(DEM_CHANGEMAP, changeMap); Net_SetCommandHandler(DEM_ENDSCREENJOB, endScreenJob); + Net_SetCommandHandler(DEM_SAVEGAME, startSaveGame); for (i = 0; i < MAXNETNODES; i++) { diff --git a/source/core/d_protocol.h b/source/core/d_protocol.h index 98c4e4ba3..5d74905c1 100644 --- a/source/core/d_protocol.h +++ b/source/core/d_protocol.h @@ -90,6 +90,7 @@ enum EDemoCommand DEM_GIVE, DEM_CHANGEMAP, DEM_ENDSCREENJOB, + DEM_SAVEGAME, DEM_SPELL, //Witchaven DEM_MAX diff --git a/source/core/defparser.cpp b/source/core/defparser.cpp index 65c00ab68..baa8480ab 100644 --- a/source/core/defparser.cpp +++ b/source/core/defparser.cpp @@ -135,7 +135,7 @@ static void parseTexturePaletteBlock(FScanner& sc, int tile) int pal = -1, xsiz = 0, ysiz = 0; FString fn; - double alphacut = -1.0, xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0; + float alphacut = -1.0, xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0; if (!sc.GetNumber(pal, true)) return; @@ -178,7 +178,7 @@ static void parseTextureSpecialBlock(FScanner& sc, int tile, int pal) FScriptPosition pos = sc; FString fn; - double xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0; + float xscale = 1.0, yscale = 1.0, specpower = 1.0, specfactor = 1.0; if (sc.StartBraces(&blockend)) return; while (!sc.FoundEndBrace(blockend)) @@ -653,6 +653,7 @@ void parseVoxel(FScanner& sc, FScriptPosition& pos) FScanner::SavedPos blockend; int tile0 = MAXTILES, tile1 = -1; FString fn; + bool error = false; if (!sc.GetString(fn)) return; @@ -661,17 +662,16 @@ void parseVoxel(FScanner& sc, FScriptPosition& pos) if (nextvoxid == MAXVOXELS) { pos.Message(MSG_ERROR, "Maximum number of voxels (%d) already defined.", MAXVOXELS); - return; + error = true; } - - if (voxDefine(nextvoxid, fn)) + else if (voxDefine(nextvoxid, fn)) { pos.Message(MSG_ERROR, "Unable to load voxel file \"%s\"", fn.GetChars()); - return; + error = true; } int lastvoxid = nextvoxid++; - + if (sc.StartBraces(&blockend)) return; while (!sc.FoundEndBrace(blockend)) { @@ -679,13 +679,16 @@ void parseVoxel(FScanner& sc, FScriptPosition& pos) if (sc.Compare("tile")) { sc.GetNumber(true); - if (ValidateTilenum("voxel", sc.Number, pos)) tiletovox[sc.Number] = lastvoxid; + if (ValidateTilenum("voxel", sc.Number, pos)) + { + if (!error) tiletovox[sc.Number] = lastvoxid; + } } if (sc.Compare("tile0")) sc.GetNumber(tile0, true); if (sc.Compare("tile1")) { sc.GetNumber(tile1, true); - if (ValidateTileRange("voxel", tile0, tile1, pos)) + if (ValidateTileRange("voxel", tile0, tile1, pos) && !error) { for (int i = tile0; i <= tile1; i++) tiletovox[i] = lastvoxid; } @@ -693,9 +696,9 @@ void parseVoxel(FScanner& sc, FScriptPosition& pos) if (sc.Compare("scale")) { sc.GetFloat(true); - voxscale[lastvoxid] = (float)sc.Float; + if (!error) voxscale[lastvoxid] = (float)sc.Float; } - if (sc.Compare("rotate")) voxrotate.Set(lastvoxid); + if (sc.Compare("rotate") && !error) voxrotate.Set(lastvoxid); } } @@ -834,7 +837,7 @@ void parseMapinfo(FScanner& sc, FScriptPosition& pos) for (int i = 0; i < 16; i++) { char smallbuf[3] = { sc.String[2 * i], sc.String[2 * i + 1], 0 }; - mhk.md4[i] = strtol(smallbuf, nullptr, 16); + mhk.md4[i] = (uint8_t)strtol(smallbuf, nullptr, 16); } } } @@ -1772,7 +1775,7 @@ static bool parseModelFrameBlock(FScanner& sc, FixedBitArray<1024>& usedframes) bool ok = true; int pal = -1; int starttile = -1, endtile = -1; - double smoothduration = 0.1f; + float smoothduration = 0.1f; if (sc.StartBraces(&blockend)) return false; while (!sc.FoundEndBrace(blockend)) @@ -1855,7 +1858,7 @@ static bool parseModelSkinBlock(FScanner& sc, int pal) FString filename; int surface = 0; - double param = 1.0, specpower = 1.0, specfactor = 1.0; + float param = 1.0, specpower = 1.0, specfactor = 1.0; int flags = 0; if (sc.StartBraces(&blockend)) return false; @@ -1887,7 +1890,7 @@ static bool parseModelSkinBlock(FScanner& sc, int pal) return false; } - if (pal == DETAILPAL) param = 1. / param; + if (pal == DETAILPAL) param = 1.f / param; int res = md_defineskin(mdglobal.lastmodelid, filename, pal, max(0, mdglobal.modelskin), surface, param, specpower, specfactor, flags); if (res < 0) { diff --git a/source/core/g_mapinfo.cpp b/source/core/g_mapinfo.cpp index 60afb7d1b..1f1712454 100644 --- a/source/core/g_mapinfo.cpp +++ b/source/core/g_mapinfo.cpp @@ -586,14 +586,14 @@ DEFINE_MAP_OPTION(ex_ramses_pup, false) { parse.ParseAssign(); parse.sc.MustGetString(); - info->ex_ramses_pup = parse.sc.Number; + info->ex_ramses_pup = parse.sc.String; } DEFINE_MAP_OPTION(ex_ramses_text, false) { parse.ParseAssign(); parse.sc.MustGetString(); - info->ex_ramses_text = parse.sc.Number; + info->ex_ramses_text = parse.sc.String; } int ex_ramses_horiz = 11; @@ -925,7 +925,7 @@ MapRecord *FMapInfoParser::ParseMapHeader(MapRecord &defaultinfo) if (map != &sink && map->name.IsEmpty()) sc.ScriptError("Missing level name"); sc.UnGet(); } - if (!map->levelNumber) map->levelNumber = GetDefaultLevelNum(map->labelName); + if (map->levelNumber <= 0) map->levelNumber = GetDefaultLevelNum(map->labelName); return map; } @@ -1128,6 +1128,14 @@ void FMapInfoParser::ParseGameInfo() sc.SetCMode(false); globalCutscenes.MPSummaryScreen = sc.String; } + else if (sc.Compare("statusbarclass")) + { + ParseAssign(); + sc.SetCMode(false); + sc.MustGetString(); + sc.SetCMode(false); + globalCutscenes.StatusBarClass = sc.String; + } else if (!ParseCloseBrace()) { // Unknown diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index c63ad1a1e..c20aeae22 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -140,7 +140,7 @@ void PostLoadSetup(); void FontCharCreated(FGameTexture* base, FGameTexture* untranslated, FGameTexture* translated); void LoadVoxelModels(); -DBaseStatusBar* StatusBar; +DStatusBarCore* StatusBar; bool AppActive = true; @@ -477,9 +477,6 @@ void CheckUserMap() namespace Duke3d { ::GameInterface* CreateInterface(); - DBaseStatusBar* CreateDukeStatusBar(); - DBaseStatusBar* CreateRedneckStatusBar(); - } namespace Blood { @@ -810,32 +807,15 @@ void InitLanguages() void CreateStatusBar() { - int flags = g_gameType; - PClass* stbarclass = nullptr; - - GC::AddMarkerFunc([]() { GC::Mark(StatusBar); }); - if (flags & GAMEFLAG_BLOOD) - { - stbarclass = PClass::FindClass("BloodStatusBar"); - } - else if (flags & GAMEFLAG_SW) - { - stbarclass = PClass::FindClass("SWStatusBar"); - } - else if (flags & GAMEFLAG_PSEXHUMED) - { - stbarclass = PClass::FindClass("ExhumedStatusBar"); - } - else - { - StatusBar = isRR() ? Duke3d::CreateRedneckStatusBar() : Duke3d::CreateDukeStatusBar(); - return; - } + auto stbarclass = PClass::FindClass(globalCutscenes.StatusBarClass); if (!stbarclass) { I_FatalError("No status bar defined"); } - StatusBar = static_cast(stbarclass->CreateNew()); + StatusBar = static_cast(stbarclass->CreateNew()); + StatusBar->SetSize(0, 320, 200); + InitStatusBar(); + GC::AddMarkerFunc([]() { GC::Mark(StatusBar); }); } @@ -1075,7 +1055,7 @@ int RunGame() void updatePauseStatus() { // This must go through the network in multiplayer games. - if (M_Active() || System_WantGuiCapture()) + if (M_Active() || System_WantGuiCapture() || !AppActive) { paused = 1; } @@ -1224,10 +1204,10 @@ void S_SetSoundPaused(int state) if (paused == 0) { S_ResumeSound(true); - if (GSnd != nullptr) - { - GSnd->SetInactive(SoundRenderer::INACTIVE_Active); - } + } + if (GSnd != nullptr) + { + GSnd->SetInactive(SoundRenderer::INACTIVE_Active); } } else @@ -1537,7 +1517,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Raze, MusicEnabled, MusicEnabled) DEFINE_ACTION_FUNCTION_NATIVE(_Raze, GetTimeFrac, I_GetTimeFrac) { - ACTION_RETURN_INT(I_GetTimeFrac()); + ACTION_RETURN_FLOAT(I_GetTimeFrac()); } DEFINE_ACTION_FUNCTION(_Raze, PlayerName) @@ -1563,6 +1543,25 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Raze, bcos, bcos) ACTION_RETURN_INT(bcos(v, shift)); } +DEFINE_ACTION_FUNCTION_NATIVE(_Raze, GetBuildTime, I_GetBuildTime) +{ + ACTION_RETURN_INT(I_GetBuildTime()); +} + +bool PickTexture(FRenderState* state, FGameTexture* tex, int paletteid, TexturePick& pick); + +DEFINE_ACTION_FUNCTION(_Raze, PickTexture) +{ + PARAM_PROLOGUE; + PARAM_INT(texid); + TexturePick pick; + if (PickTexture(nullptr, TexMan.GetGameTexture(FSetTextureID(texid)), TRANSLATION(Translation_Remap, 0), pick)) + { + ACTION_RETURN_INT(pick.texture->GetID().GetIndex()); + } + ACTION_RETURN_INT(texid); +} + DEFINE_ACTION_FUNCTION(_MapRecord, GetCluster) { PARAM_SELF_STRUCT_PROLOGUE(MapRecord); @@ -1578,6 +1577,8 @@ DEFINE_GLOBAL(demoplayback) DEFINE_GLOBAL(consoleplayer) DEFINE_GLOBAL(currentLevel) DEFINE_GLOBAL(paused) +DEFINE_GLOBAL(automapMode) +DEFINE_GLOBAL(PlayClock) DEFINE_FIELD_X(ClusterDef, ClusterDef, name) DEFINE_FIELD_X(ClusterDef, ClusterDef, InterBackground) diff --git a/source/core/gamecontrol.h b/source/core/gamecontrol.h index ef201a17c..5dc09559c 100644 --- a/source/core/gamecontrol.h +++ b/source/core/gamecontrol.h @@ -12,6 +12,10 @@ #include "i_time.h" #include "palentry.h" +extern bool sendsave; +extern FString savedescription; +extern FString savegamefile; + extern FString currentGame; extern FString LumpFilter; extern int PlayClock; diff --git a/source/core/gamecvars.cpp b/source/core/gamecvars.cpp index f4b0c3de0..6eaec0d76 100644 --- a/source/core/gamecvars.cpp +++ b/source/core/gamecvars.cpp @@ -146,7 +146,7 @@ CCMD(sizeup) } else { - hud_scalefactor = hud_scalefactor + 0.04; + hud_scalefactor = hud_scalefactor + 0.04f; } } @@ -162,7 +162,7 @@ CCMD(sizedown) } else { - hud_scalefactor = hud_scalefactor - 0.04; + hud_scalefactor = hud_scalefactor - 0.04f; } } diff --git a/source/core/gamefuncs.cpp b/source/core/gamefuncs.cpp index f34cd1249..7015acacb 100644 --- a/source/core/gamefuncs.cpp +++ b/source/core/gamefuncs.cpp @@ -131,7 +131,7 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, short *psectnu *pz += MulScale(nz, cameradist, 16); // Caculate clock using GameTicRate so it increases the same rate on all speed computers. - int myclock = PlayClock + MulScale(120 / GameTicRate, smoothratio, 16); + int myclock = PlayClock + MulScale(120 / GameTicRate, int(smoothratio), 16); if (cameraclock == INT_MIN) { // Third person view was just started. @@ -154,7 +154,7 @@ bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, short *psectnu // //========================================================================== -void PlanesAtPoint(const sectortype* sec, float dax, float day, float* pceilz, float* pflorz) +void PlanesAtPoint(const sectortype* sec, int dax, int day, float* pceilz, float* pflorz) { float ceilz = float(sec->ceilingz); float florz = float(sec->floorz); @@ -164,13 +164,13 @@ void PlanesAtPoint(const sectortype* sec, float dax, float day, float* pceilz, f auto wal = &wall[sec->wallptr]; auto wal2 = &wall[wal->point2]; - float dx = wal2->x - wal->x; - float dy = wal2->y - wal->y; + float dx = float(wal2->x - wal->x); + float dy = float(wal2->y - wal->y); int i = (int)sqrt(dx * dx + dy * dy) << 5; // length of sector's first wall. if (i != 0) { - float const j = (dx * (day - wal->y) - dy * (dax - wal->x)) * (1.f / 8.f); + float const j = (dx * (float(day - wal->y)) - dy * (float(dax - wal->x))) * (1.f / 8.f); if (sec->ceilingstat & CSTAT_SECTOR_SLOPE) ceilz += (sec->ceilingheinum * j) / i; if (sec->floorstat & CSTAT_SECTOR_SLOPE) florz += (sec->floorheinum * j) / i; } diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 20a5d7ad7..0f5d0a8a8 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -9,7 +9,11 @@ extern int cameradist, cameraclock; void loaddefinitionsfile(const char* fn, bool cumulative = false); bool calcChaseCamPos(int* px, int* py, int* pz, spritetype* pspr, short *psectnum, binangle ang, fixedhoriz horiz, double const smoothratio); -void PlanesAtPoint(const sectortype* sec, float dax, float day, float* ceilz, float* florz); +void PlanesAtPoint(const sectortype* sec, int dax, int day, float* ceilz, float* florz); +inline void PlanesAtPoint(const sectortype* sec, float dax, float day, float* ceilz, float* florz) // this is just for warning evasion. +{ + PlanesAtPoint(sec, int(dax), int(day), ceilz, florz); +} void setWallSectors(); void GetWallSpritePosition(const spritetype* spr, vec2_t pos, vec2_t* out, bool render = false); void GetFlatSpritePosition(const spritetype* spr, vec2_t pos, vec2_t* out, bool render = false); diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 8560220a2..236e50082 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -61,7 +61,7 @@ binangle getincanglebam(binangle a, binangle na) if(cura > INT32_MAX) cura -= UINT32_MAX; } - return bamang(newa-cura); + return bamang(uint32_t(newa-cura)); } //--------------------------------------------------------------------------- @@ -133,7 +133,7 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn if (buttonMap.ButtonDown(gamefunc_Strafe) && allowstrafe) currInput->svel -= xs_CRoundToInt((hidInput->mousemovex * mousevelscale) + (scaleAdjust * hidInput->dyaw * keymove * cntrlvelscale)); else - currInput->avel += hidInput->mouseturnx + (scaleAdjust * hidInput->dyaw * hidspeed * turnscale); + currInput->avel += float(hidInput->mouseturnx + (scaleAdjust * hidInput->dyaw * hidspeed * turnscale)); if (!(inputBuffer->actions & SB_AIMMODE)) currInput->horz -= hidInput->mouseturny; @@ -147,7 +147,7 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn currInput->avel = -currInput->avel; // process remaining controller input. - currInput->horz -= scaleAdjust * hidInput->dpitch * hidspeed; + currInput->horz -= float(scaleAdjust * hidInput->dpitch * hidspeed); currInput->svel += xs_CRoundToInt(scaleAdjust * hidInput->dx * keymove * cntrlvelscale); currInput->fvel += xs_CRoundToInt(scaleAdjust * hidInput->dz * keymove * cntrlvelscale); @@ -177,12 +177,12 @@ void processMovement(InputPacket* currInput, InputPacket* inputBuffer, ControlIn if (buttonMap.ButtonDown(gamefunc_Turn_Left) || (buttonMap.ButtonDown(gamefunc_Strafe_Left) && !allowstrafe)) { updateTurnHeldAmt(scaleAdjust); - currInput->avel -= scaleAdjust * (isTurboTurnTime() ? turnamount : preambleturn); + currInput->avel -= float(scaleAdjust * (isTurboTurnTime() ? turnamount : preambleturn)); } else if (buttonMap.ButtonDown(gamefunc_Turn_Right) || (buttonMap.ButtonDown(gamefunc_Strafe_Right) && !allowstrafe)) { updateTurnHeldAmt(scaleAdjust); - currInput->avel += scaleAdjust * (isTurboTurnTime() ? turnamount : preambleturn); + currInput->avel += float(scaleAdjust * (isTurboTurnTime() ? turnamount : preambleturn)); } else { diff --git a/source/core/initfs.cpp b/source/core/initfs.cpp index 837f4b0ea..80bc3d3eb 100644 --- a/source/core/initfs.cpp +++ b/source/core/initfs.cpp @@ -263,7 +263,7 @@ static void DeleteStuff(FileSystem &fileSystem, const TArray& deletelum str.Truncate(ndx); } - for (uint32_t i = 0; i < fileSystem.GetNumEntries(); i++) + for (int i = 0; i < fileSystem.GetNumEntries(); i++) { int cf = fileSystem.GetFileContainer(i); auto fname = fileSystem.GetFileFullName(i, false); @@ -343,8 +343,8 @@ void InitFileSystem(TArray& groups) D_AddConfigFiles(Files, "Global.Autoload", "*.grp", GameConfig); - long len; - int lastpos = 0; + size_t len; + size_t lastpos = 0; while (lastpos < LumpFilter.Len() && (len = strcspn(LumpFilter.GetChars() + lastpos, ".")) > 0) { diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index 03a20a7c9..b9f360802 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -106,10 +106,14 @@ int oldentertics; int gametic; int intermissiondelay; +FString savename; FString BackupSaveGame; void DoLoadGame(const char* name); +bool sendsave; +FString savedescription; +FString savegamefile; //========================================================================== // @@ -119,6 +123,14 @@ void DoLoadGame(const char* name); void G_BuildTiccmd(ticcmd_t* cmd) { + if (sendsave) + { + sendsave = false; + Net_WriteByte(DEM_SAVEGAME); + Net_WriteString(savegamefile); + Net_WriteString(savedescription); + savegamefile = ""; + } cmd->ucmd = {}; I_GetEvent(); auto input = CONTROL_GetInput(); @@ -138,6 +150,7 @@ void NewGame(MapRecord* map, int skill, bool ns = false) newGameStarted = true; ShowIntermission(nullptr, map, nullptr, [=](bool) { gi->NewGame(map, skill, ns); + ResetStatusBar(); }); } @@ -187,6 +200,7 @@ static void GameTicker() gi->FreeLevelData(); gameaction = ga_level; gi->NextLevel(g_nextmap, g_nextskill); + ResetStatusBar(); } else { @@ -199,6 +213,7 @@ static void GameTicker() gi->FreeLevelData(); gameaction = ga_level; gi->NextLevel(g_nextmap, g_nextskill); + ResetStatusBar(); break; case ga_newgame: @@ -240,8 +255,16 @@ static void GameTicker() break; case ga_savegame: - // We only need this for multiplayer saves that need to go through the network. - // gi->SaveGame(); + G_DoSaveGame(true, false, savegamefile, savedescription); + gameaction = ga_nothing; + savegamefile = ""; + savedescription = ""; + break; + + case ga_loadgame: + case ga_loadgamehidecon: + //case ga_autoloadgame: + G_DoLoadGame(); break; case ga_autosave: @@ -340,6 +363,7 @@ static void GameTicker() gameupdatetime.Reset(); gameupdatetime.Clock(); gi->Ticker(); + TickStatusBar(); levelTextTime--; gameupdatetime.Unclock(); break; diff --git a/source/core/mapinfo.cpp b/source/core/mapinfo.cpp index 3231c990a..d327d5587 100644 --- a/source/core/mapinfo.cpp +++ b/source/core/mapinfo.cpp @@ -168,7 +168,7 @@ MapRecord* FindNextSecretMap(MapRecord* thismap) bool SetMusicForMap(const char* mapname, const char* music, bool namehack) { static const char* specials[] = { "intro", "briefing", "loading" }; - for (int i = 0; i < 3; i++) + for (unsigned i = 0; i < 3; i++) { if (!stricmp(mapname, specials[i])) { diff --git a/source/core/mapinfo.h b/source/core/mapinfo.h index 56addf366..32662cb4c 100644 --- a/source/core/mapinfo.h +++ b/source/core/mapinfo.h @@ -104,6 +104,7 @@ struct GlobalCutscenes CutsceneDef LoadingScreen; FString MPSummaryScreen; FString SummaryScreen; + FString StatusBarClass; }; struct ClusterDef diff --git a/source/core/maploader.cpp b/source/core/maploader.cpp index ee6bf0d99..88449a459 100644 --- a/source/core/maploader.cpp +++ b/source/core/maploader.cpp @@ -208,7 +208,7 @@ static void SetWallPalV5() static void ValidateSprite(spritetype& spr) { - int index = &spr - sprite; + int index = int(&spr - sprite); bool bugged = false; if ((unsigned)spr.statnum >= MAXSTATUS) { diff --git a/source/core/menu/loadsavemenu.cpp b/source/core/menu/loadsavemenu.cpp index ef9ba4e88..487114bb8 100644 --- a/source/core/menu/loadsavemenu.cpp +++ b/source/core/menu/loadsavemenu.cpp @@ -114,12 +114,12 @@ void FSavegameManager::ReadSaveStrings() void FSavegameManager::PerformLoadGame(const char *f, bool s) { - G_LoadGame(f); + G_LoadGame(f, s); } void FSavegameManager::PerformSaveGame(const char *f, const char *s) { - G_SaveGame(f, s, true, false); + G_SaveGame(f, s); } FString FSavegameManager::BuildSaveName(const char* fn, int slot) diff --git a/source/core/menu/razemenu.cpp b/source/core/menu/razemenu.cpp index 7eeac3809..cc62f8fd7 100644 --- a/source/core/menu/razemenu.cpp +++ b/source/core/menu/razemenu.cpp @@ -192,16 +192,10 @@ bool M_SetSpecialMenu(FName& menu, int param) void M_StartControlPanel(bool makeSound, bool) { - static bool created = false; // intro might call this repeatedly if (CurrentMenu != NULL) return; - if (!created) // Cannot do this earlier. - { - created = true; - M_CreateMenus(); - } GSnd->SetSfxPaused(true, PAUSESFX_MENU); gi->MenuOpened(); if (makeSound && menu_sounds) gi->MenuSound(ActivateSound); @@ -309,7 +303,7 @@ CCMD(quicksave) // [mxd]. Just save the game, no questions asked. if (!saveloadconfirmation) { - G_SaveGame(savegameManager.quickSaveSlot->Filename, savegameManager.quickSaveSlot->SaveTitle, true, true); + G_SaveGame(savegameManager.quickSaveSlot->Filename, savegameManager.quickSaveSlot->SaveTitle); return; } @@ -320,7 +314,7 @@ CCMD(quicksave) DMenu* newmenu = CreateMessageBoxMenu(CurrentMenu, tempstring, 0, false, NAME_None, []() { M_ClearMenus(); - G_SaveGame(savegameManager.quickSaveSlot->Filename, savegameManager.quickSaveSlot->SaveTitle, true, true); + G_SaveGame(savegameManager.quickSaveSlot->Filename, savegameManager.quickSaveSlot->SaveTitle); }); M_ActivateMenu(newmenu); @@ -416,7 +410,7 @@ static void BuildEpisodeMenu() } ld->mSelectedItem = gDefaultVolume + ld->mItems.Size(); // account for pre-added items - int y = ld->mYpos; + double y = ld->mYpos; // Volume definitions should be sorted by intended menu order. for (auto &vol : volumes) @@ -473,7 +467,7 @@ static void BuildEpisodeMenu() } if (isBlood()) gDefaultSkill = 2; ld->mSelectedItem = gDefaultSkill + ld->mItems.Size(); // account for pre-added items - int y = ld->mYpos; + double y = ld->mYpos; for (int i = 0; i < MAXSKILLS; i++) { diff --git a/source/core/movie/movieplayer.cpp b/source/core/movie/movieplayer.cpp index f5dfbe0b0..579c2d84c 100644 --- a/source/core/movie/movieplayer.cpp +++ b/source/core/movie/movieplayer.cpp @@ -419,7 +419,7 @@ public: { if (soundtrack > 0) { - Mus_Play(nullptr, fileSystem.GetFileFullName(soundtrack, false), false); + Mus_Play(fileSystem.GetFileFullName(soundtrack, false), false); } animtex.SetSize(AnimTexture::YUV, width, height); } @@ -519,7 +519,6 @@ class SmkPlayer : public MoviePlayer AnimTextures animtex; TArray pFrame; TArray audioBuffer; - int nFrameRate; int nFrames; bool fullscreenScale; uint64_t nFrameNs; @@ -571,8 +570,8 @@ public: flags = flags_; Smacker_GetFrameSize(hSMK, nWidth, nHeight); pFrame.Resize(nWidth * nHeight + std::max(nWidth, nHeight)); - nFrameRate = Smacker_GetFrameRate(hSMK); - nFrameNs = 1'000'000'000 / nFrameRate; + float frameRate = Smacker_GetFrameRate(hSMK); + nFrameNs = uint64_t(1'000'000'000 / frameRate); nFrames = Smacker_GetNumFrames(hSMK); Smacker_GetPalette(hSMK, palette); @@ -617,7 +616,7 @@ public: bool Frame(uint64_t clock) override { - int frame = clock / nFrameNs; + int frame = int(clock / nFrameNs); twod->ClearScreen(); if (frame > nFrame) @@ -698,7 +697,7 @@ MoviePlayer* OpenMovie(const char* filename, TArray& ans, const int* framet if (!fr.isOpen()) fr = fileSystem.OpenFileReader(filename); if (!fr.isOpen()) { - int nLen = strlen(filename); + size_t nLen = strlen(filename); // Strip the drive letter and retry. if (nLen >= 3 && isalpha(filename[0]) && filename[1] == ':' && filename[2] == '/') { diff --git a/source/core/movie/playmve.cpp b/source/core/movie/playmve.cpp index 03f77f378..4967d2ccc 100644 --- a/source/core/movie/playmve.cpp +++ b/source/core/movie/playmve.cpp @@ -252,7 +252,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock) { nTimerRate = fr.ReadUInt32(); nTimerDiv = fr.ReadUInt16(); - nFrameDuration = ((double)nTimerRate * nTimerDiv) * 1000; + nFrameDuration = ((uint64_t)nTimerRate * nTimerDiv) * 1000; break; } @@ -346,7 +346,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock) case OPCODE_AUDIO_FRAME: { - int nStart = fr.Tell(); + int nStart = (int)fr.Tell(); uint16_t seqIndex = fr.ReadUInt16(); uint16_t streamMask = fr.ReadUInt16(); uint16_t nSamples = fr.ReadUInt16(); // number of samples this chunk @@ -380,7 +380,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock) ch ^= audio.nChannels - 1; } - int nEnd = fr.Tell(); + int nEnd = (int)fr.Tell(); int nRead = nEnd - nStart; assert(opcodeSize == nRead); break; @@ -449,14 +449,14 @@ bool InterplayDecoder::RunFrame(uint64_t clock) } } - int nRead = fr.Read(decodeMap.pData, opcodeSize); + int nRead = (int)fr.Read(decodeMap.pData, opcodeSize); assert(nRead == opcodeSize); break; } case OPCODE_VIDEO_DATA: { - int nStart = fr.Tell(); + int nStart = (int)fr.Tell(); // need to skip 14 bytes fr.Seek(14, FileReader::SeekCur); @@ -536,7 +536,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock) } } - int nEnd = fr.Tell(); + int nEnd = (int)fr.Tell(); int nSkipBytes = opcodeSize - (nEnd - nStart); // we can end up with 1 byte left we need to skip assert(nSkipBytes <= 1); diff --git a/source/core/music/s_advsound.cpp b/source/core/music/s_advsound.cpp index 8270d5386..e6adecb1c 100644 --- a/source/core/music/s_advsound.cpp +++ b/source/core/music/s_advsound.cpp @@ -52,13 +52,11 @@ enum SICommands SI_MusicVolume, SI_MidiDevice, SI_MusicAlias, - SI_LevelMusic, }; // This specifies whether Timidity or Windows playback is preferred for a certain song (only useful for Windows.) extern MusicAliasMap MusicAliases; -extern MusicAliasMap LevelMusicAliases; extern MidiDeviceMap MidiDevices; extern MusicVolumeMap MusicVolumes; @@ -80,7 +78,6 @@ static const char *SICommandStrings[] = "$musicvolume", "$mididevice", "$musicalias", - "$levelmusic", NULL }; @@ -140,7 +137,7 @@ static void S_AddSNDINFO (int lump) sc.MustGetString(); FName musname (sc.String); sc.MustGetFloat(); - MusicVolumes[musname] = sc.Float; + MusicVolumes[musname] = (float)sc.Float; } break; @@ -172,20 +169,6 @@ static void S_AddSNDINFO (int lump) } break; - case SI_LevelMusic: { - sc.MustGetString(); - FName alias = sc.String; - sc.MustGetString(); - FName mapped = sc.String; - - // only set the alias if the lump it maps to exists. - if (mapped == NAME_None || fileSystem.FindFile(sc.String) >= 0) - { - LevelMusicAliases[alias] = mapped; - } - } - break; - case SI_MidiDevice: { sc.MustGetString(); FName nm = sc.String; diff --git a/source/core/raze_music.cpp b/source/core/raze_music.cpp index c23f0b0ff..2453e8e40 100644 --- a/source/core/raze_music.cpp +++ b/source/core/raze_music.cpp @@ -49,7 +49,6 @@ static FString lastStartedMusic; TArray specialmusic; MusicAliasMap MusicAliases; -MusicAliasMap LevelMusicAliases; CVAR(Bool, printmusicinfo, false, 0) CVAR(Bool, mus_extendedlookup, false, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) @@ -191,31 +190,18 @@ static FString LookupMusicCB(const char* musicname, int& order) } -static FString lastMusicLevel, lastMusic; -int Mus_Play(const char *mapname, const char *fn, bool loop) +static FString lastMusic; +int Mus_Play(const char *fn, bool loop) { if (mus_blocked) return 1; // Caller should believe it succeeded. if (*fn == '/') fn++; // Store the requested names for resuming. - lastMusicLevel = mapname; lastMusic = fn; if (!MusicEnabled()) { return 1; } - - // Allow per level music substitution. - // For most cases using $musicalias would be sufficient, but that method only works if a level actually has some music defined at all. - // This way it can be done with an add-on definition lump even in cases like Redneck Rampage where no music definitions exist - // or where music gets reused for multiple levels but replacement is wanted individually. - if (mapname && *mapname) - { - if (*mapname == '/') mapname++; - FName *check = LevelMusicAliases.CheckKey(FName(mapname, true)); - if (check) fn = check->GetChars(); - } - return S_ChangeMusic(fn, 0, loop, true); } diff --git a/source/core/raze_music.h b/source/core/raze_music.h index a87644406..be614353f 100644 --- a/source/core/raze_music.h +++ b/source/core/raze_music.h @@ -11,7 +11,7 @@ extern TArray specialmusic; // Totally minimalistic interface - should be all the game modules need. void Mus_InitMusic(); void Mus_UpdateMusic(); -int Mus_Play(const char *mapname, const char *fn, bool loop); +int Mus_Play(const char *fn, bool loop); void Mus_Stop(); bool Mus_IsPlaying(); void Mus_SetPaused(bool on); diff --git a/source/core/rendering/scene/hw_bunchdrawer.cpp b/source/core/rendering/scene/hw_bunchdrawer.cpp index b81b9c0ef..13db57d40 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.cpp +++ b/source/core/rendering/scene/hw_bunchdrawer.cpp @@ -57,6 +57,7 @@ void BunchDrawer::Init(HWDrawInfo *_di, Clipper* c, vec2_t& view, binangle a1, b { ang1 = a1; ang2 = a2; + angrange = ang2 - ang1; di = _di; clipper = c; viewx = view.x * (1/ 16.f); @@ -108,10 +109,11 @@ bool BunchDrawer::StartBunch(int sectnum, int linenum, binangle startan, binangl bunch->sectnum = sectnum; bunch->startline = bunch->endline = linenum; - bunch->startangle = (startan.asbam() - ang1.asbam()) > ANGLE_180? ang1 :startan; - bunch->endangle = (endan.asbam() - ang2.asbam()) < ANGLE_180 ? ang2 : endan; + bunch->startangle = startan; + bunch->endangle = endan; bunch->portal = portal; - return bunch->endangle != ang2; + assert(bunch->endangle.asbam() > bunch->startangle.asbam()); + return bunch->endangle != angrange; } //========================================================================== @@ -123,8 +125,10 @@ bool BunchDrawer::StartBunch(int sectnum, int linenum, binangle startan, binangl bool BunchDrawer::AddLineToBunch(int line, binangle newan) { Bunches[LastBunch].endline++; - Bunches[LastBunch].endangle = (newan.asbam() - ang2.asbam()) < ANGLE_180 ? ang2 : newan; - return Bunches[LastBunch].endangle != ang2; + assert(newan.asbam() > Bunches[LastBunch].endangle.asbam()); + Bunches[LastBunch].endangle = newan; + assert(Bunches[LastBunch].endangle.asbam() > Bunches[LastBunch].startangle.asbam()); + return Bunches[LastBunch].endangle != angrange; } //========================================================================== @@ -202,8 +206,8 @@ int BunchDrawer::ClipLine(int aline, bool portal) int section = cline->section; int line = cline->wall; - auto startAngleBam = wall[cline->startpoint].clipangle; - auto endAngleBam = wall[cline->endpoint].clipangle; + auto startAngleBam = ClipAngle(cline->startpoint); + auto endAngleBam = ClipAngle(cline->endpoint); // Back side, i.e. backface culling - read: endAngle <= startAngle! if (startAngleBam.asbam() - endAngleBam.asbam() < ANGLE_180) @@ -213,10 +217,10 @@ int BunchDrawer::ClipLine(int aline, bool portal) if (line >= 0 && blockwall[line]) return CL_Draw; // convert to clipper coordinates and clamp to valid range. - int startAngle = startAngleBam.asbam() - ang1.asbam(); - int endAngle = endAngleBam.asbam() - ang1.asbam(); + int startAngle = startAngleBam.asbam(); + int endAngle = endAngleBam.asbam(); if (startAngle < 0) startAngle = 0; - if (endAngle < 0) endAngle = INT_MAX; + if (endAngle < 0 || endAngle > (int)angrange.asbam()) endAngle = angrange.asbam(); // since these values are derived from previous calls of this function they cannot be out of range. int sectStartAngle = sectionstartang[section]; @@ -380,9 +384,6 @@ int BunchDrawer::WallInFront(int line1, int line2) //========================================================================== // -// This is a bit more complicated than it looks because angles can wrap -// around so we can only compare angle differences. -// // Rules: // 1. Any bunch can span at most 180°. // 2. 2 bunches can never overlap at both ends @@ -395,15 +396,15 @@ int BunchDrawer::BunchInFront(FBunch* b1, FBunch* b2) { binangle anglecheck, endang; - if (b2->startangle.asbam() - b1->startangle.asbam() < b1->endangle.asbam() - b1->startangle.asbam()) + if (b2->startangle.asbam() >= b1->startangle.asbam() && b2->startangle.asbam() < b1->endangle.asbam()) { // we have an overlap at b2->startangle - anglecheck = b2->startangle - b1->startangle; + anglecheck = b2->startangle; // Find the wall in b1 that overlaps b2->startangle for (int i = b1->startline; i <= b1->endline; i++) { - endang = wall[wall[i].point2].clipangle - b1->startangle; + endang = ClipAngle(wall[i].point2); if (endang.asbam() > anglecheck.asbam()) { // found a line @@ -412,15 +413,15 @@ int BunchDrawer::BunchInFront(FBunch* b1, FBunch* b2) } } } - else if (b1->startangle.asbam() - b2->startangle.asbam() < b2->endangle.asbam() - b2->startangle.asbam()) + else if (b1->startangle.asbam() >= b2->startangle.asbam() && b1->startangle.asbam() < b2->endangle.asbam()) { // we have an overlap at b1->startangle - anglecheck = b1->startangle - b2->startangle; + anglecheck = b1->startangle; // Find the wall in b2 that overlaps b1->startangle for (int i = b2->startline; i <= b2->endline; i++) { - endang = wall[wall[i].point2].clipangle - b2->startangle; + endang = ClipAngle(wall[i].point2); if (endang.asbam() > anglecheck.asbam()) { // found a line @@ -500,7 +501,6 @@ void BunchDrawer::ProcessSection(int sectionnum, bool portal) gotsection2.Set(sectionnum); bool inbunch; - binangle startangle; SetupSprite.Clock(); @@ -548,31 +548,29 @@ void BunchDrawer::ProcessSection(int sectionnum, bool portal) { auto thisline = §ionLines[section->lines[i]]; -#ifdef _DEBUG - // For displaying positions in debugger - //DVector2 start = { WallStartX(thiswall), WallStartY(thiswall) }; - //DVector2 end = { WallStartX(thiswall->point2), WallStartY(thiswall->point2) }; -#endif - binangle walang1 = wall[thisline->startpoint].clipangle; - binangle walang2 = wall[thisline->endpoint].clipangle; + binangle walang1 = ClipAngle(thisline->startpoint); + binangle walang2 = ClipAngle(thisline->endpoint); // outside the visible area or seen from the backside. - if ((walang1.asbam() - ang1.asbam() > ANGLE_180 && walang2.asbam() - ang1.asbam() > ANGLE_180) || - (walang1.asbam() - ang2.asbam() < ANGLE_180 && walang2.asbam() - ang2.asbam() < ANGLE_180) || + if ((walang1.asbam() > angrange.asbam() && walang2.asbam() > angrange.asbam() && walang1.asbam() < walang2.asbam()) || (walang1.asbam() - walang2.asbam() < ANGLE_180)) { inbunch = false; } - else if (!inbunch) - { - startangle = walang1; - //Printf("Starting bunch:\n\tWall %d\n", sect->wallptr + i); - inbunch = StartBunch(sectnum, section->lines[i], walang1, walang2, portal); - } else { - //Printf("\tWall %d\n", sect->wallptr + i); - inbunch = AddLineToBunch(section->lines[i], walang2); + if (walang1.asbam() >= angrange.asbam()) { walang1 = bamang(0); inbunch = false; } + if (walang2.asbam() >= angrange.asbam()) walang2 = angrange; + if (!inbunch) + { + //Printf("Starting bunch:\n\tWall %d\n", section->lines[i]); + inbunch = StartBunch(sectnum, section->lines[i], walang1, walang2, portal); + } + else + { + //Printf("\tWall %d\n", section->lines[i]); + inbunch = AddLineToBunch(section->lines[i], walang2); + } } if (thisline->endpoint != section->lines[i] + 1) inbunch = false; } @@ -596,7 +594,7 @@ void BunchDrawer::RenderScene(const int* viewsectors, unsigned sectcount, bool p for (auto j : sectionspersector[viewsectors[i]]) { sectionstartang[j] = 0; - sectionendang[j] = int(ang2.asbam() - ang1.asbam()); + sectionendang[j] = int(angrange.asbam()); } } for (unsigned i = 0; i < sectcount; i++) @@ -626,10 +624,12 @@ void BunchDrawer::RenderScene(const int* viewsectors, unsigned sectcount, bool p auto rotang = di->Viewpoint.RotAngle; ang1 = bamang(rotang - ANGLE_90); ang2 = bamang(rotang + ANGLE_90 - 1); + angrange = ang2 - ang1; process(); gotsection2.Zero(); ang1 = bamang(rotang + ANGLE_90); ang2 = bamang(rotang - ANGLE_90 - 1); + angrange = ang2 - ang1; process(); } Bsp.Unclock(); diff --git a/source/core/rendering/scene/hw_bunchdrawer.h b/source/core/rendering/scene/hw_bunchdrawer.h index 685ca25bc..a8b12fa6c 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.h +++ b/source/core/rendering/scene/hw_bunchdrawer.h @@ -31,7 +31,7 @@ class BunchDrawer FixedBitArray gotsection2; FixedBitArray gotwall; FixedBitArray blockwall; - binangle ang1, ang2; + binangle ang1, ang2, angrange; int sectionstartang[MAXSECTORS*5/4], sectionendang[MAXSECTORS*5/4]; @@ -44,6 +44,7 @@ private: CL_Pass = 2, }; + binangle ClipAngle(int wal) { return wall[wal].clipangle - ang1; } void StartScene(); bool StartBunch(int sectnum, int linenum, binangle startan, binangle endan, bool portal); bool AddLineToBunch(int line, binangle newan); diff --git a/source/core/rendering/scene/hw_drawstructs.h b/source/core/rendering/scene/hw_drawstructs.h index f5658b8f3..3c2609e7a 100644 --- a/source/core/rendering/scene/hw_drawstructs.h +++ b/source/core/rendering/scene/hw_drawstructs.h @@ -15,9 +15,7 @@ #include "hw_renderstate.h" #include "hw_cvars.h" -#ifdef _MSC_VER -#pragma warning(disable:4244) -#endif +#pragma warning(disable:4244) // this gets a bit annoying in the renderer... struct HWHorizonInfo; struct HWSkyInfo; @@ -403,15 +401,12 @@ inline void SetSpriteTranslucency(const spritetype* sprite, float& alpha, FRende extern PalEntry GlobalMapFog; extern float GlobalFogDensity; -__forceinline void SetLightAndFog(FRenderState& state, PalEntry fade, int palette, int shade, float visibility, float alpha, bool setcolor = true) +__forceinline void SetLightAndFog(FRenderState& state, PalEntry fade, int palette, int shade, float visibility, float alpha) { // Fog must be done before the texture so that the texture selector can override it. bool foggy = (GlobalMapFog || (fade & 0xffffff)); auto ShadeDiv = lookups.tables[palette].ShadeFactor; - bool shadow = shade >= numshades; - - if (shadow) state.SetObjectColor(0xff000000); // make sure that nothing lights this up again. - else state.SetObjectColor(0xffffffff); + if (shade == 127) state.SetObjectColor(0xff000000); // 127 is generally used for shadow objects that must be black, even in foggy areas. // Disable brightmaps if non-black fog is used. if (ShadeDiv >= 1 / 1000.f && foggy) diff --git a/source/core/rendering/scene/hw_flats.cpp b/source/core/rendering/scene/hw_flats.cpp index cd8cdeeb7..7b2025381 100644 --- a/source/core/rendering/scene/hw_flats.cpp +++ b/source/core/rendering/scene/hw_flats.cpp @@ -191,7 +191,7 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent) if (translucent) state.SetRenderStyle(LegacyRenderStyles[STYLE_Translucent]); state.EnableBrightmap(true); - //state.SetObjectColor(0xffffffff); + state.SetObjectColor(0xffffffff); //state.SetAddColor(0); //state.ApplyTextureManipulation(nullptr); } @@ -244,7 +244,7 @@ void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, int section const auto &vp = di->Viewpoint; float florz, ceilz; - PlanesAtPoint(frontsector, vp.Pos.X * 16.f, vp.Pos.Y * -16.f, &ceilz, &florz); + PlanesAtPoint(frontsector, float(vp.Pos.X) * 16.f, float(vp.Pos.Y) * -16.f, &ceilz, &florz); fade = lookups.getFade(frontsector->floorpal); // fog is per sector. visibility = sectorVisibility(frontsector); diff --git a/source/core/rendering/scene/hw_portal.cpp b/source/core/rendering/scene/hw_portal.cpp index 1ce9e32df..30f522958 100644 --- a/source/core/rendering/scene/hw_portal.cpp +++ b/source/core/rendering/scene/hw_portal.cpp @@ -481,7 +481,7 @@ int HWLinePortal::ClipSeg(walltype *seg, const DVector3 &viewpos) int HWLinePortal::ClipSector(sectortype *sub) { // this seg is completely behind the mirror - for (unsigned int i = 0; iwallnum; i++) + for (int i = 0; iwallnum; i++) { if (PointOnLineSide(WallStart(&wall[sub->wallptr]), line) == 0) return PClip_Inside; } diff --git a/source/core/rendering/scene/hw_sprites.cpp b/source/core/rendering/scene/hw_sprites.cpp index e55eda495..a29c9f16f 100644 --- a/source/core/rendering/scene/hw_sprites.cpp +++ b/source/core/rendering/scene/hw_sprites.cpp @@ -109,7 +109,10 @@ void HWSprite::DrawSprite(HWDrawInfo* di, FRenderState& state, bool translucent) else RenderStyle.BlendOp = STYLEOP_Fuzz; // subtractive with models is not going to work. } - SetLightAndFog(state, fade, palette, shade, visibility, alpha, this->shade <= numshades); + SetLightAndFog(state, fade, palette, shade, visibility, alpha); + + if (shade >= numshades) state.SetObjectColor(0xff000000); // make sure that nothing lights this up again. + if (modelframe == 0) { @@ -161,6 +164,7 @@ void HWSprite::DrawSprite(HWDrawInfo* di, FRenderState& state, bool translucent) { //RenderModel(&renderer, x, y, z, modelframe, actor, di->Viewpoint.TicFrac); } + state.SetObjectColor(0xffffffff); state.SetVertexBuffer(screen->mVertexData); state.EnableModelMatrix(false); } diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index 4c528a7a3..499459c2a 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -128,7 +128,7 @@ void HWWall::RenderMirrorSurface(HWDrawInfo *di, FRenderState &state) // Use sphere mapping for this state.SetEffect(EFF_SPHEREMAP); - SetLightAndFog(state, fade, palette, shade, visibility, alpha, false); + SetLightAndFog(state, fade, palette, min(shade, numshades), visibility, alpha); state.SetColor(PalEntry(25, globalr >> 1, globalg >> 1, globalb >> 1)); state.SetRenderStyle(STYLE_Add); @@ -173,8 +173,8 @@ void HWWall::RenderTexturedWall(HWDrawInfo *di, FRenderState &state, int rflags) RenderWall(di, state, rflags); state.SetNpotEmulation(0.f, 0.f); - /* none of these functions is in use. state.SetObjectColor(0xffffffff); + /* none of these functions is in use. state.SetObjectColor2(0); state.SetAddColor(0); state.SetTextureMode(tmode); @@ -1088,10 +1088,17 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sect zbottom[0] = zbottom[1] = (sprz) * (1 / -256.); ztop[0] = ztop[1] = (sprz - ((height * spr->yrepeat) << 2)) * (1 / -256.); + if (zbottom[0] > ztop[0]) + { + // reorder coordinates to make the clipping code below behave. + auto zz = zbottom[0]; + zbottom[0] = zbottom[1] = ztop[0]; + ztop[0] = ztop[1] = zz; + } // Clip sprites to ceilings/floors - float origz = ztop[0]; - float polyh = (zbottom[0] - origz); + float origz = zbottom[0]; + float polyh = (ztop[0] - origz); if (!(sector->ceilingstat & CSTAT_SECTOR_SKY)) { float ceilingz = sector->ceilingz * (1 / -256.f); diff --git a/source/core/rts.cpp b/source/core/rts.cpp index ac892f2e0..1754d990f 100644 --- a/source/core/rts.cpp +++ b/source/core/rts.cpp @@ -95,7 +95,7 @@ bool RTS_IsInitialized() { FileLump *li = (FileLump*)(RTSFile.Data() + LittleLong(wi->infotableofs)); LumpInfo.Resize(numlumps); - for(unsigned i = 0; i < numlumps; i++, li++) + for(int i = 0; i < numlumps; i++, li++) { LumpInfo[i] = { LittleLong(li->position), LittleLong(li->size), -1 }; if (unsigned(LumpInfo[i].position + LumpInfo[i].size) >= RTSFile.Size()) diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index 1df080525..a2a2022f5 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -68,7 +68,10 @@ walltype wallbackup[MAXWALLS]; void WriteSavePic(FileWriter* file, int width, int height); bool WriteZip(const char* filename, TArray& filenames, TArray& content); +extern FString savename; extern FString BackupSaveGame; +int SaveVersion; + void SerializeMap(FSerializer &arc); FixedBitArray activeSprites; @@ -344,6 +347,7 @@ int G_ValidateSavegame(FileReader &fr, FString *savetitle, bool formenu) // not our business. Leave it alone. return 0; } + SaveVersion = savesig.currentsavever; MapRecord *curLevel = FindMapByName(label); @@ -686,26 +690,103 @@ static int nextquicksave = -1; } - void G_LoadGame(const char *filename) + void G_LoadGame(const char* name, bool hidecon) { - inputState.ClearAllInput(); - gi->FreeLevelData(); - DoLoadGame(filename); - BackupSaveGame = filename; + if (name != NULL) + { + savename = name; + gameaction = !hidecon ? ga_loadgame : ga_loadgamehidecon; + } } - void G_SaveGame(const char *fn, const char *desc, bool ok4q, bool forceq) + void G_DoLoadGame() + { + if (gameaction == ga_loadgamehidecon && gamestate == GS_FULLCONSOLE) + { + // does this even do anything anymore? + gamestate = GS_HIDECONSOLE; + } + + inputState.ClearAllInput(); + gi->FreeLevelData(); + DoLoadGame(savename); + BackupSaveGame = savename; + } + + extern bool sendsave; + extern FString savedescription; + extern FString savegamefile; + + void G_SaveGame(const char* filename, const char* description) + { + if (sendsave || gameaction == ga_savegame) + { + Printf("%s\n", GStrings("TXT_SAVEPENDING")); + } + else if (gamestate != GS_LEVEL) + { + Printf("%s\n", GStrings("TXT_NOTINLEVEL")); + } + else if (!gi->CanSave()) + { + Printf("%s\n", GStrings("TXT_SPPLAYERDEAD")); + } + else + { + savegamefile = filename; + savedescription = description; + sendsave = true; + } + } + + //--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + + void startSaveGame(int player, uint8_t** stream, bool skip) + { + auto s = ReadString(stream); + savegamefile = s; + delete[] s; + s = ReadString(stream); + savedescription = s; + if (!skip && gi->CanSave()) + { + if (player != consoleplayer) + { + // Paths sent over the network will be valid for the system that sent + // the save command. For other systems, the path needs to be changed. + savegamefile = G_BuildSaveName(ExtractFileBase(savegamefile, true)); + } + gameaction = ga_savegame; + } + } + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + + void G_DoSaveGame(bool ok4q, bool forceq, const char* fn, const char* desc) { if (WriteSavegame(fn, desc)) { - savegameManager.NotifyNewSave(fn, desc, ok4q, forceq); - Printf(PRINT_NOTIFY, "%s\n", GStrings("GAME SAVED")); - BackupSaveGame = fn; - } + savegameManager.NotifyNewSave(fn, desc, ok4q, forceq); + Printf(PRINT_NOTIFY, "%s\n", GStrings("GGSAVED")); + BackupSaveGame = fn; } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- - -void M_Autosave() + void M_Autosave() { if (disableautosave) return; if (!gi->CanSave()) return; @@ -728,7 +809,7 @@ void M_Autosave() readableTime = myasctime(); FStringf SaveTitle("Autosave %s", readableTime); nextautosave = (nextautosave + 1) % count; - G_SaveGame(Filename, SaveTitle, false, false); + G_DoSaveGame(false, false, Filename, SaveTitle); } CCMD(autosave) @@ -759,7 +840,51 @@ CCMD(rotatingquicksave) readableTime = myasctime(); FStringf SaveTitle("Quicksave %s", readableTime); nextquicksave = (nextquicksave + 1) % count; - G_SaveGame(Filename, SaveTitle, false, false); + G_SaveGame(Filename, SaveTitle); +} + + +//========================================================================== +// +// CCMD load +// +// Load a saved game. +// +//========================================================================== + +UNSAFE_CCMD(load) +{ + if (argv.argc() != 2) + { + Printf("usage: load \n"); + return; + } + if (netgame) + { + Printf("cannot load during a network game\n"); + return; + } + FString fname = G_BuildSaveName(argv[1]); + G_LoadGame(fname); +} + +//========================================================================== +// +// CCMD save +// +// Save the current game. +// +//========================================================================== + +UNSAFE_CCMD(save) +{ + if (argv.argc() < 2 || argv.argc() > 3) + { + Printf("usage: save [description]\n"); + return; + } + FString fname = G_BuildSaveName(argv[1]); + G_SaveGame(fname, argv.argc() > 2 ? argv[2] : argv[1]); } diff --git a/source/core/savegamehelp.h b/source/core/savegamehelp.h index 84502debb..98db88944 100644 --- a/source/core/savegamehelp.h +++ b/source/core/savegamehelp.h @@ -7,12 +7,15 @@ extern FixedBitArray activeSprites; // Savegame utilities class FileReader; +extern int SaveVersion; FString G_BuildSaveName (const char *prefix); int G_ValidateSavegame(FileReader &fr, FString *savetitle, bool formenu); -void G_LoadGame(const char* filename); -void G_SaveGame(const char* fn, const char* desc, bool ok4q, bool forceq); +void G_LoadGame(const char* filename, bool hidecon = false); +void G_SaveGame(const char* fn, const char* desc); +void G_DoSaveGame(bool okForQuicksave, bool forceQuicksave, const char* filename, const char* description); +void G_DoLoadGame(); void M_Autosave(); diff --git a/source/core/screenjob.cpp b/source/core/screenjob.cpp index 02a1569e4..4d1486587 100644 --- a/source/core/screenjob.cpp +++ b/source/core/screenjob.cpp @@ -94,7 +94,7 @@ void Job_Init() static VMFunction* LookupFunction(const char* qname, bool validate = true) { - int p = strcspn(qname, "."); + size_t p = strcspn(qname, "."); if (p == 0) I_Error("Call to undefined function %s", qname); FString clsname(qname, p); FString funcname = qname + p + 1; @@ -488,7 +488,11 @@ void ShowIntermission(MapRecord* fromMap, MapRecord* toMap, SummaryInfo* info, C if (tocluster == nullptr || !tocluster->intro.Create(runner, toMap, !!fromMap)) globalCutscenes.DefaultMapIntro.Create(runner, toMap, !!fromMap); } - globalCutscenes.LoadingScreen.Create(runner, toMap, true); + // Skip the load screen if the level is started from the console. + // In this case the load screen is not helpful as it blocks the actual level start, + // requiring closing and reopening the console first before entering any commands that need the level. + if (ConsoleState == c_up || ConsoleState == c_rising) + globalCutscenes.LoadingScreen.Create(runner, toMap, true); } else if (isShareware()) { diff --git a/source/core/searchpaths.cpp b/source/core/searchpaths.cpp index 60e083482..38e7a7ccd 100644 --- a/source/core/searchpaths.cpp +++ b/source/core/searchpaths.cpp @@ -668,7 +668,7 @@ void GetCRC(FileEntry *entry, TArray &CRCCache) do { b = f.Read(buffer.Data(), buffer.Size()); - if (b > 0) crcval = AddCRC32(crcval, buffer.Data(), b); + if (b > 0) crcval = AddCRC32(crcval, buffer.Data(), unsigned(b)); } while (b == buffer.Size()); entry->CRCValue = crcval; diff --git a/source/core/sectorgeometry.cpp b/source/core/sectorgeometry.cpp index 4db5b3617..29e622f10 100644 --- a/source/core/sectorgeometry.cpp +++ b/source/core/sectorgeometry.cpp @@ -139,8 +139,8 @@ public: DVector2 dv = { double(ix2 - ix1), -double(iy2 - iy1) }; auto vang = dv.Angle() - 90.; - cosalign = vang.Cos(); - sinalign = vang.Sin(); + cosalign = float(vang.Cos()); + sinalign = float(vang.Sin()); int pow2width = 1 << sizeToBits((int)tx->GetDisplayWidth()); if (pow2width < (int)tx->GetDisplayWidth()) pow2width *= 2; @@ -247,9 +247,9 @@ bool SectorGeometry::MakeVertices(unsigned int secnum, int plane, const FVector2 { auto sline = §ionLines[sec->lines[start]]; auto wallp = &wall[sline->startpoint]; - float X = WallStartX(wallp); - float Y = WallStartY(wallp); - if (fabs(X) > 32768. || fabs(Y) > 32768.) + float X = float(WallStartX(wallp)); + float Y = float(WallStartY(wallp)); + if (fabs(X) > 32768.f || fabs(Y) > 32768.f) { // If we get here there's some fuckery going around with the coordinates. Let's better abort and wait for things to realign. // Do not try alternative methods if this happens. @@ -277,7 +277,7 @@ bool SectorGeometry::MakeVertices(unsigned int secnum, int plane, const FVector2 { minx = pt.first; miny = pt.second; - outer = a; + outer = int(a); } } } @@ -303,8 +303,8 @@ bool SectorGeometry::MakeVertices(unsigned int secnum, int plane, const FVector2 } auto& entry = data[secnum].planes[plane]; - entry.vertices.Resize(indices.size()); - entry.texcoords.Resize(indices.size()); + entry.vertices.Resize((unsigned)indices.size()); + entry.texcoords.Resize((unsigned)indices.size()); entry.normal = CalcNormal(sectorp, plane); auto texture = tileGetTexture(plane ? sectorp->ceilingpicnum : sectorp->floorpicnum); diff --git a/source/core/statusbar.h b/source/core/statusbar.h index 086b4c383..4404a4dca 100644 --- a/source/core/statusbar.h +++ b/source/core/statusbar.h @@ -70,63 +70,7 @@ enum HUDMSGLayer_Default = HUDMSGLayer_OverHUD, }; -struct FLevelStats -{ - int screenbottomspace; - int time; // in milliseconds - int frags; - int kills, maxkills; // set maxkills to -1 to ignore, or to -2 to only print kills - int secrets, maxsecrets, supersecrets; // set maxsecrets to -1 to ignore - int spacing; // uses fontheight if 0 or less. - EColorRange letterColor, standardColor, completeColor; - double fontscale; - FFont* font; -}; - -//============================================================================ -// -// encapsulates all settings a HUD font may need -// -//============================================================================ - -class DBaseStatusBar : public DStatusBarCore -{ - DECLARE_ABSTRACT_CLASS (DBaseStatusBar, DStatusBarCore) - -public: - DBaseStatusBar (); - virtual ~DBaseStatusBar() = default; - - // do not make this a DObject Serialize function because it's not used like one! - //void SerializeMessages(FSerializer &arc); - - virtual void Tick (); - - void PrintLevelStats(FLevelStats& stats); - void PrintAutomapInfo(FLevelStats& stats, bool forcetextfont = false); - int GetTopOfStatusbar() const - { - return SBarTop; - } - short CalcMagazineAmount(short ammo_remaining, short clip_capacity, bool reloading); - void Set43ClipRect(); - virtual void UpdateStatusBar() = 0; - - -private: - DObject *AltHud = nullptr; - -public: - - - bool Centering; - bool FixedOrigin; - -private: - -}; - -extern DBaseStatusBar *StatusBar; +extern DStatusBarCore *StatusBar; // Status bar factories ----------------------------------------------------- @@ -136,7 +80,6 @@ void ST_Clear(); extern FGameTexture *CrosshairImage; -void SBar_DrawString(DStatusBarCore* self, DHUDFont* font, const FString& string, double x, double y, int flags, int trans, double alpha, int wrapwidth, int linespacing, double scaleX, double scaleY, int pt = 0, int style = STYLE_Translucent); void setViewport(int viewSize); struct MapRecord; void setLevelStarted(MapRecord *); @@ -144,5 +87,10 @@ void drawMapTitle(); class FSerializer; void SerializeHud(FSerializer &arc); extern int levelTextTime; +struct SummaryInfo; +void UpdateStatusBar(SummaryInfo* info); +void TickStatusBar(); +void ResetStatusBar(); +void InitStatusBar(); #endif /* __SBAR_H__ */ diff --git a/source/core/statusbar2.cpp b/source/core/statusbar2.cpp index cce7f8f90..8b9018663 100644 --- a/source/core/statusbar2.cpp +++ b/source/core/statusbar2.cpp @@ -64,12 +64,6 @@ #include "../version.h" -#define XHAIRSHRINKSIZE (1./18) -#define XHAIRPICKUPSIZE (2+XHAIRSHRINKSIZE) -#define POWERUPICONSIZE 32 - -//IMPLEMENT_CLASS(DHUDFont, true, false); - EXTERN_CVAR (Bool, am_showmonsters) EXTERN_CVAR (Bool, am_showsecrets) EXTERN_CVAR (Bool, am_showtime) @@ -78,12 +72,10 @@ EXTERN_CVAR (Bool, noisedebug) EXTERN_CVAR(Bool, vid_fps) EXTERN_CVAR(Bool, inter_subtitles) -//extern DBaseStatusBar *StatusBar; - extern int setblocks; -IMPLEMENT_CLASS(DBaseStatusBar, true, false) //--------------------------------------------------------------------------- +// // ST_Clear // //--------------------------------------------------------------------------- @@ -99,198 +91,6 @@ void ST_Clear() */ } -//--------------------------------------------------------------------------- -// -// Constructor -// -//--------------------------------------------------------------------------- -DBaseStatusBar::DBaseStatusBar () -{ - CompleteBorder = false; - Centering = false; - FixedOrigin = false; - SetSize(0); -} - -//--------------------------------------------------------------------------- -// -// PROC Tick -// -//--------------------------------------------------------------------------- - -void DBaseStatusBar::Tick () -{ -} - - -static DObject *InitObject(PClass *type, int paramnum, VM_ARGS) -{ - auto obj = type->CreateNew(); - // Todo: init - return obj; -} - -//============================================================================ -// -// -// -//============================================================================ - -void DBaseStatusBar::PrintLevelStats(FLevelStats &stats) -{ - double y; - double scale = stats.fontscale * hud_statscale; - if (stats.spacing <= 0) stats.spacing = stats.font->GetHeight() * stats.fontscale; - double spacing = stats.spacing * hud_statscale; - if (stats.screenbottomspace < 0) - { - y = 200 - (RelTop - stats.screenbottomspace) * hud_scalefactor - spacing; - } - else - { - y = 200 - stats.screenbottomspace * hud_scalefactor - spacing; - } - - double y1, y2, y3; - - if (stats.maxsecrets > 0) // don't bother if there are no secrets. - { - y1 = y; - y -= spacing; - } - if (stats.frags >= 0 || stats.maxkills != -1) - { - y2 = y; - y -= spacing; - } - y3 = y; - - - FString text; - int black = 0x80000000; - - text.Format(TEXTCOLOR_ESCAPESTR "%cT: " TEXTCOLOR_ESCAPESTR "%c%d:%02d", stats.letterColor + 'A', stats.standardColor + 'A', stats.time / 60000, (stats.time % 60000) / 1000); - DrawText(twod, stats.font, CR_UNTRANSLATED, 2 * hud_statscale + scale, y3 + scale, text, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_LegacyRenderStyle, STYLE_TranslucentStencil, DTA_Color, black, TAG_DONE); - DrawText(twod, stats.font, CR_UNTRANSLATED, 2 * hud_statscale, y3, text, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); - - text = ""; - if (stats.frags > -1) text.Format(TEXTCOLOR_ESCAPESTR "%cF: " TEXTCOLOR_ESCAPESTR "%c%d", stats.letterColor + 'A', stats.standardColor + 'A', stats.frags); - else if (stats.maxkills == -2) text.Format(TEXTCOLOR_ESCAPESTR "%cK: " TEXTCOLOR_ESCAPESTR "%c%d", stats.letterColor + 'A', stats.standardColor + 'A', stats.kills); - else if (stats.maxkills != -1) text.Format(TEXTCOLOR_ESCAPESTR "%cK: " TEXTCOLOR_ESCAPESTR "%c%d/%d", - stats.letterColor + 'A', stats.kills == stats.maxkills ? stats.completeColor + 'A' : stats.standardColor + 'A', stats.kills, stats.maxkills); - - if (text.IsNotEmpty()) - { - DrawText(twod, stats.font, CR_UNTRANSLATED, 2 * hud_statscale+scale, y2+scale, text, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_LegacyRenderStyle, STYLE_TranslucentStencil, DTA_Color, black, TAG_DONE); - - DrawText(twod, stats.font, CR_UNTRANSLATED, 2 * hud_statscale, y2, text, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); - } - - if (stats.maxsecrets > 0) // don't bother if there are no secrets. - { - if (stats.supersecrets <= 0) - text.Format(TEXTCOLOR_ESCAPESTR "%cS: " TEXTCOLOR_ESCAPESTR "%c%d/%d", - stats.letterColor + 'A', stats.secrets >= stats.maxsecrets ? stats.completeColor + 'A' : stats.standardColor + 'A', stats.secrets, stats.maxsecrets); - else - text.Format(TEXTCOLOR_ESCAPESTR "%cS: " TEXTCOLOR_ESCAPESTR "%c%d/%d+%d", - stats.letterColor + 'A', stats.secrets >= stats.maxsecrets ? stats.completeColor + 'A' : stats.standardColor + 'A', stats.secrets, stats.maxsecrets, stats.supersecrets); - - - DrawText(twod, stats.font, CR_UNTRANSLATED, 2 * hud_statscale + scale, y1 + scale, text, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_LegacyRenderStyle, STYLE_TranslucentStencil, DTA_Color, black, TAG_DONE); - - DrawText(twod, stats.font, CR_UNTRANSLATED, 2 * hud_statscale, y1, text, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, TAG_DONE); - } -} - -//============================================================================ -// -// -// -//============================================================================ - -void DBaseStatusBar::PrintAutomapInfo(FLevelStats& stats, bool forcetextfont) -{ - auto lev = currentLevel; - FString mapname; - if (am_showlabel) - mapname.Format(TEXTCOLOR_ESCAPESTR "%c%s: " TEXTCOLOR_ESCAPESTR "%c%s", stats.letterColor+'A', lev->LabelName(), stats.standardColor+'A', lev->DisplayName()); - else - mapname = lev->DisplayName(); - - forcetextfont |= am_textfont; - double y; - double scale = stats.fontscale * (forcetextfont ? *hud_statscale : 1); // the tiny default font used by all games here cannot be scaled for readability purposes. - if (stats.spacing <= 0) stats.spacing = stats.font->GetHeight() * stats.fontscale; - double spacing = stats.spacing * (forcetextfont ? *hud_statscale : 1); - if (am_nameontop) - { - y = spacing + 1; - } - else if (stats.screenbottomspace < 0) - { - y = 200 - RelTop - spacing; - } - else - { - y = 200 - stats.screenbottomspace - spacing; - } - auto cluster = FindCluster(lev->cluster); - FString volname; - if (cluster) volname = cluster->name; - if (volname.IsEmpty() && am_nameontop) y = 1; - - DrawText(twod, stats.font, stats.standardColor, 2 * hud_statscale, y, mapname, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE); - y -= spacing; - if (!(lev->flags & MI_USERMAP) && !(g_gameType & GAMEFLAG_PSEXHUMED) && volname.IsNotEmpty()) - DrawText(twod, stats.font, stats.standardColor, 2 * hud_statscale, y, GStrings.localize(volname), - DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, - DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true, TAG_DONE); -} - -//============================================================================ -// -// -// -//============================================================================ - -short DBaseStatusBar::CalcMagazineAmount(short ammo_remaining, short clip_capacity, bool reloading) -{ - // Determine amount in clip. - short clip_amount = ammo_remaining % clip_capacity; - - // Set current clip value to clip capacity if wrapped around to zero, otherwise use determined value. - short clip_current = ammo_remaining != 0 && clip_amount == 0 ? clip_capacity : clip_amount; - - // Return current clip value if weapon has rounds or is not on a reload cycle. - return ammo_remaining == 0 || (reloading && clip_amount == 0) ? 0 : clip_current; -} - -//============================================================================ -// -// -// -//============================================================================ - -void DBaseStatusBar::Set43ClipRect() -{ - auto GetWidth = [=]() { return twod->GetWidth(); }; - auto GetHeight = [=]() {return twod->GetHeight(); }; - - auto screenratio = ActiveRatio(GetWidth(), GetHeight()); - if (screenratio < 1.34) return; - - int width = xs_CRoundToInt(GetWidth() * 1.333 / screenratio); - int left = (GetWidth() - width) / 2; - twod->SetClipRect(left, 0, width, GetHeight()); -} - //============================================================================ // // @@ -379,5 +179,39 @@ void drawMapTitle() } } +void UpdateStatusBar(SummaryInfo* info) +{ + IFVIRTUALPTRNAME(StatusBar, NAME_RazeStatusBar, UpdateStatusBar) + { + VMValue params[] = { StatusBar, info }; + VMCall(func, params, 2, nullptr, 0); + } +} +void TickStatusBar() +{ + IFVIRTUALPTRNAME(StatusBar, NAME_RazeStatusBar, Tick) + { + VMValue params[] = { StatusBar }; + VMCall(func, params, 1, nullptr, 0); + } +} + +void ResetStatusBar() +{ + IFVIRTUALPTRNAME(StatusBar, NAME_RazeStatusBar, Reset) + { + VMValue params[] = { StatusBar }; + VMCall(func, params, 1, nullptr, 0); + } +} + +void InitStatusBar() +{ + IFVIRTUALPTRNAME(StatusBar, NAME_RazeStatusBar, Init) + { + VMValue params[] = { StatusBar }; + VMCall(func, params, 1, nullptr, 0); + } +} diff --git a/source/core/textures/buildtiles.cpp b/source/core/textures/buildtiles.cpp index 5cd2b27c0..de2d75278 100644 --- a/source/core/textures/buildtiles.cpp +++ b/source/core/textures/buildtiles.cpp @@ -274,7 +274,7 @@ void BuildTiles::MakeCanvas(int tilenum, int width, int height) { auto canvas = ValidateCustomTile(tilenum, ReplacementType::Canvas); canvas->SetSize(width*4, height*4); - canvas->SetDisplaySize(width, height); + canvas->SetDisplaySize((float)width, (float)height); canvas->GetTexture()->SetSize(width * 4, height * 4); static_cast(canvas->GetTexture())->aspectRatio = (float)width / height; } @@ -291,7 +291,7 @@ void BuildTiles::MakeCanvas(int tilenum, int width, int height) int BuildTiles::LoadArtFile(const char *fn, const char *mapname, int firsttile) { - auto old = FindFile(fn); + unsigned old = FindFile(fn); if (old >= ArtFiles.Size()) // Do not process if already loaded. { FileReader fr = fileSystem.OpenFileReader(fn); diff --git a/source/core/textures/hightile.cpp b/source/core/textures/hightile.cpp index 36f8e6315..87d8eaf7c 100644 --- a/source/core/textures/hightile.cpp +++ b/source/core/textures/hightile.cpp @@ -440,7 +440,7 @@ bool PreBindTexture(FRenderState* state, FGameTexture*& tex, EUpscaleFlags& flag flags |= (((pick.tintFlags & TINTF_BLENDMASK) >> 6) + 1) & TextureManipulation::BlendMask; } } - addcol.W = flags; + addcol.W = (float)flags; if ((pick.translation & 0x80000000) && hw_shadeinterpolate) addcol.W += 16384; // hijack a free bit in here. state->SetTextureColors(&modcol.X, &addcol.X, &blendcol.X); } diff --git a/source/core/version.h b/source/core/version.h index c8420f004..d2bd47a97 100644 --- a/source/core/version.h +++ b/source/core/version.h @@ -70,16 +70,16 @@ const char *GetVersionString(); #define SAVESIG_PS GAMENAME ".Exhumed" #define SAVESIG_WH GAMENAME ".Witchaven" -#define MINSAVEVER_DN3D 10 -#define MINSAVEVER_BLD 11 -#define MINSAVEVER_SW 12 -#define MINSAVEVER_PS 12 +#define MINSAVEVER_DN3D 11 +#define MINSAVEVER_BLD 12 +#define MINSAVEVER_SW 13 +#define MINSAVEVER_PS 13 #define MINSAVEVER_WH 10 -#define SAVEVER_DN3D 10 -#define SAVEVER_BLD 11 -#define SAVEVER_SW 12 -#define SAVEVER_PS 12 +#define SAVEVER_DN3D 11 +#define SAVEVER_BLD 12 +#define SAVEVER_SW 13 +#define SAVEVER_PS 13 #define SAVEVER_WH 10 #define NETGAMEVERSION 1 diff --git a/source/games/blood/src/_polymost.cpp b/source/games/blood/src/_polymost.cpp index 64b755d73..05f8967b2 100644 --- a/source/games/blood/src/_polymost.cpp +++ b/source/games/blood/src/_polymost.cpp @@ -148,7 +148,7 @@ RORHACK: for (int i = 0; i < 16; i++) ror_status[i] = testgotpic(4080 + i); fixed_t deliriumPitchI = interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate); - DrawMirrors(cX, cY, cZ, cA.asq16(), cH.asq16() + deliriumPitchI, gInterpolate, gViewIndex); + DrawMirrors(cX, cY, cZ, cA.asq16(), cH.asq16() + deliriumPitchI, int(gInterpolate), gViewIndex); int bakCstat = gView->pSprite->cstat; if (gViewPos == 0) { @@ -160,7 +160,7 @@ RORHACK: } renderDrawRoomsQ16(cX, cY, cZ, cA.asq16(), cH.asq16() + deliriumPitchI, nSectnum); - viewProcessSprites(pm_tsprite, pm_spritesortcnt, cX, cY, cZ, cA.asbuild(), gInterpolate); + viewProcessSprites(pm_tsprite, pm_spritesortcnt, cX, cY, cZ, cA.asbuild(), int(gInterpolate)); bool do_ror_hack = false; for (int i = 0; i < 16; i++) if (ror_status[i] != testgotpic(4080 + i)) @@ -176,7 +176,7 @@ RORHACK: renderDrawMasks(); pm_spritesortcnt = nSpriteSortCnt; setPortalFlags(0); - processSpritesOnOtherSideOfPortal(cX, cY, gInterpolate); + processSpritesOnOtherSideOfPortal(cX, cY, int(gInterpolate)); renderDrawMasks(); gView->pSprite->cstat = bakCstat; diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 60bbf823b..63f2db9db 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2926,7 +2926,7 @@ bool actHealDude(DBloodActor* actor, int add, int threshold) auto pXDude = &actor->x(); add <<= 4; threshold <<= 4; - if (pXDude->health < threshold) + if (pXDude->health < (unsigned)threshold) { spritetype* pSprite = &actor->s(); if (actor->IsPlayerActor()) sfxPlay3DSound(pSprite->x, pSprite->y, pSprite->z, 780, pSprite->sectnum); diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index beac0ff94..b204e7959 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -1003,7 +1003,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType GENDUDEEXTRA* pExtra = genDudeExtra(pSprite); if (nDmgType == DAMAGE_TYPE_1) { - if (pXSprite->health > pDudeInfo->fleeHealth) break; + if (pXSprite->health > (unsigned)pDudeInfo->fleeHealth) break; else if (pXSprite->txID <= 0 || getNextIncarnation(pXSprite) == NULL) { removeDudeStuff(pSprite); diff --git a/source/games/blood/src/aibeast.cpp b/source/games/blood/src/aibeast.cpp index 857d01cfe..c9aae1c1f 100644 --- a/source/games/blood/src/aibeast.cpp +++ b/source/games/blood/src/aibeast.cpp @@ -292,7 +292,7 @@ static void beastThinkChase(DBloodActor* actor) else pXSector = NULL; int hit = HitScan(pSprite, pSprite->z, dx, dy, 0, CLIPMASK1, 0); - if (pXTarget->health > gPlayerTemplate[0].startHealth/2) + if (pXTarget->health > (unsigned)gPlayerTemplate[0].startHealth/2) { switch (hit) { diff --git a/source/games/blood/src/barf.cpp b/source/games/blood/src/barf.cpp index 47233eede..043cac154 100644 --- a/source/games/blood/src/barf.cpp +++ b/source/games/blood/src/barf.cpp @@ -138,7 +138,7 @@ void AddCmdDefine(char *text, int value) static void SplitPath(const char *pzPath, char *pzDirectory, char *pzFile, char *pzType) { - int const nLength = strlen(pzPath); + int const nLength = (int)strlen(pzPath); const char *pDirectory = pzPath+nLength; const char *pDot = NULL; for (int i = nLength-1; i >= 0; i--) @@ -217,7 +217,7 @@ int RFS::Open(int lumpnum) return 1; } - int fileSize = hFile.GetLength(); + int fileSize = (int)hFile.GetLength(); buffer.Resize(fileSize); _ptr = buffer.Data(); if (_ptr == NULL) { @@ -890,7 +890,7 @@ void ParseScript(int lumpnum) case kTagString: { memcpy(&buffer[nBytes], scriptBuffer, strlen(scriptBuffer) + 1); - nBytes += strlen(scriptBuffer) + 1; + nBytes += (int)strlen(scriptBuffer) + 1; break; } case kTagConstant: diff --git a/source/games/blood/src/blood.cpp b/source/games/blood/src/blood.cpp index f37c40693..f65a2acc8 100644 --- a/source/games/blood/src/blood.cpp +++ b/source/games/blood/src/blood.cpp @@ -487,7 +487,7 @@ void GameInterface::Render() void sndPlaySpecialMusicOrNothing(int nMusic) { - if (!Mus_Play(nullptr, quoteMgr.GetQuote(nMusic), true)) + if (!Mus_Play(quoteMgr.GetQuote(nMusic), true)) { Mus_Stop(); } @@ -539,7 +539,7 @@ DEFINE_ACTION_FUNCTION(_Blood, OriginalLoadScreen) DEFINE_ACTION_FUNCTION(_Blood, PlayIntroMusic) { - Mus_Play(nullptr, "PESTIS.MID", false); + Mus_Play("PESTIS.MID", false); return 0; } @@ -565,4 +565,37 @@ DEFINE_ACTION_FUNCTION(_Blood, sndStartSampleNamed) return 0; } +DEFINE_ACTION_FUNCTION(_Blood, PowerupIcon) +{ + PARAM_PROLOGUE; + PARAM_INT(pwup); + int tile = -1; + if (pwup >= 0 && pwup < (int)countof(gPowerUpInfo)) + { + tile = gPowerUpInfo[pwup].picnum; + } + FGameTexture* tex = tileGetTexture(tile); + ACTION_RETURN_INT(tex ? tex->GetID().GetIndex() : -1); +} + +DEFINE_ACTION_FUNCTION(_Blood, GetViewPlayer) +{ + PARAM_PROLOGUE; + ACTION_RETURN_POINTER(gView); +} + +DEFINE_ACTION_FUNCTION(_BloodPlayer, GetHealth) +{ + PARAM_SELF_STRUCT_PROLOGUE(PLAYER); + XSPRITE* pXSprite = self->pXSprite; + ACTION_RETURN_INT(pXSprite->health); +} + +DEFINE_ACTION_FUNCTION_NATIVE(_BloodPlayer, powerupCheck, powerupCheck) +{ + PARAM_SELF_STRUCT_PROLOGUE(PLAYER); + PARAM_INT(pwup); + ACTION_RETURN_INT(powerupCheck(self, pwup)); +} + END_BLD_NS diff --git a/source/games/blood/src/bloodactor.h b/source/games/blood/src/bloodactor.h index 4947650ea..d98d4951e 100644 --- a/source/games/blood/src/bloodactor.h +++ b/source/games/blood/src/bloodactor.h @@ -142,7 +142,7 @@ inline void actBurnSprite(DBloodActor* pSource, DBloodActor* pTarget, int nTime) { auto pXSprite = &pTarget->x(); pXSprite->burnTime = ClipHigh(pXSprite->burnTime + nTime, sprite[pXSprite->reference].statnum == kStatDude ? 2400 : 1200); - pXSprite->burnSource = pSource->s().index; + pXSprite->burnSource = pSource? pSource->s().index : -1; } inline void GetActorExtents(DBloodActor* actor, int* top, int* bottom) diff --git a/source/games/blood/src/callback.cpp b/source/games/blood/src/callback.cpp index b61cc55d7..c1621d09f 100644 --- a/source/games/blood/src/callback.cpp +++ b/source/games/blood/src/callback.cpp @@ -712,7 +712,7 @@ void callbackCondition(int nSprite) { if (pXSprite->isTriggered) return; TRCONDITION* pCond = &gCondition[pXSprite->sysData1]; - for (int i = 0; i < pCond->length; i++) { + for (unsigned i = 0; i < pCond->length; i++) { EVENT evn; evn.index = pCond->obj[i].index; evn.type = pCond->obj[i].type; evn.cmd = pCond->obj[i].cmd; evn.funcID = kCallbackCondition; useCondition(&sprite[pXSprite->reference], pXSprite, evn); diff --git a/source/games/blood/src/eventq.cpp b/source/games/blood/src/eventq.cpp index 78cd6fc33..77fbf3a0a 100644 --- a/source/games/blood/src/eventq.cpp +++ b/source/games/blood/src/eventq.cpp @@ -200,18 +200,18 @@ static void SortRXBucket(int nCount) vbx++; } RXBUCKET* v2c = pArray + nCount; - int vt = ClipHigh(vbx - first, first - pArray); + int vt = int(min(vbx - first, first - pArray)); for (int i = 0; i < vt; i++) { SortSwap(&vbx[i - vt], &pArray[i]); } - vt = ClipHigh(last - v4, v2c - last - 1); + vt = int(min(last - v4, v2c - last - 1)); for (int i = 0; i < vt; i++) { SortSwap(&v2c[i - vt], &vbx[i]); } - int vvsi = last - v4; - int vvdi = vbx - first; + int vvsi = int(last - v4); + int vvdi = int(vbx - first); if (vvsi >= vvdi) { vc4[v14] = vvsi; diff --git a/source/games/blood/src/hudsprites.cpp b/source/games/blood/src/hudsprites.cpp index bb0f4a311..b35fb8969 100644 --- a/source/games/blood/src/hudsprites.cpp +++ b/source/games/blood/src/hudsprites.cpp @@ -127,14 +127,14 @@ void hudDraw(PLAYER *gView, int nSectnum, double bobx, double boby, double zDelt } #ifdef NOONE_EXTENSIONS - if (gView->sceneQav < 0) WeaponDraw(gView, nShade, cX, cY, nPalette, smoothratio); - else if (gView->pXSprite->health > 0) playerQavSceneDraw(gView, nShade, cX, cY, nPalette, smoothratio); + if (gView->sceneQav < 0) WeaponDraw(gView, nShade, cX, cY, nPalette, int(smoothratio)); + else if (gView->pXSprite->health > 0) playerQavSceneDraw(gView, nShade, cX, cY, nPalette, int(smoothratio)); else { gView->sceneQav = gView->weaponQav = -1; gView->weaponTimer = gView->curWeapon = 0; } #else - WeaponDraw(gView, nShade, cX, cY, nPalette, smoothratio); + WeaponDraw(gView, nShade, cX, cY, nPalette, int(smoothratio)); #endif } if (gViewPos == 0 && gView->pXSprite->burnTime > 60) diff --git a/source/games/blood/src/inifile.cpp b/source/games/blood/src/inifile.cpp index 6f3c37dd6..b90af0da1 100644 --- a/source/games/blood/src/inifile.cpp +++ b/source/games/blood/src/inifile.cpp @@ -171,7 +171,6 @@ void IniFile::Load() auto fp = fileSystem.OpenFileReader(fileName); if (fp.isOpen()) { - int nSize = fp.GetLength(); auto pBuffer = fp.Read(); LoadRes(pBuffer.Data()); } diff --git a/source/games/blood/src/levels.cpp b/source/games/blood/src/levels.cpp index 449f617ce..4d25e7394 100644 --- a/source/games/blood/src/levels.cpp +++ b/source/games/blood/src/levels.cpp @@ -246,12 +246,12 @@ void levelTryPlayMusic() else { buffer = currentLevel->music; - if (Mus_Play(currentLevel->labelName, buffer, true)) return; + if (Mus_Play(buffer, true)) return; if (buffer.IsNotEmpty()) DefaultExtension(buffer, ".mid"); } - if (!Mus_Play(currentLevel->labelName, buffer, true)) + if (!Mus_Play(buffer, true)) { - Mus_Play("", "", true); + Mus_Play("", true); } } diff --git a/source/games/blood/src/namelist.h b/source/games/blood/src/namelist.h index 89ed1a7b4..306c39e75 100644 --- a/source/games/blood/src/namelist.h +++ b/source/games/blood/src/namelist.h @@ -18,3 +18,177 @@ x(SBarNumberInv, 9240) x(SBarNumberArmor1, 9250) x(SBarNumberArmor2, 9260) x(SBarNumberArmor3, 9270) +x(SBarSlash, 9280) + +x(PackBG, 2568) +x(PackSelect, 2559) + +x(PackIcon1, 2569) +x(PackIcon2, 2564) +x(PackIcon3, 2566) +x(PackIcon4, 2568) +x(PackIcon5, 2560) + +x(Pack2Icon1, 519) +x(Pack2Icon2, 830) +x(Pack2Icon3, 760) +x(Pack2Icon4, 839) +x(Pack2Icon5, 827) + +x(AmmoIcon1, 816) +x(AmmoIcon2, 619) +x(AmmoIcon3, 817) +x(AmmoIcon4, 801) +x(AmmoIcon5, 589) +x(AmmoIcon6, 618) +x(AmmoIcon7, 548) +x(AmmoIcon8, 820) +x(AmmoIcon9, 525) +x(AmmoIcon10, 811) +x(AmmoIcon11, 810) + +x(SBPlayerSlot, 2229) + +x(FlagHave, 3558) +x(FlagHaveNot, 3559) +x(FlagDropped, 2332) +x(FlagTaken, 4097) +x(Statusbar, 2200) +x(FullHUD, 2201) +x(Armor1Gauge, 2207) +x(Armor2Gauge, 2208) +x(Armor3Gauge, 2209) + +x(KeyIcon1, 2220) +x(KeyIcon2, 2221) +x(KeyIcon3, 2222) +x(KeyIcon4, 2223) +x(KeyIcon5, 2224) +x(KeyIcon6, 2225) + +x(HudKeyIcon1, 2552) +x(HudKeyIcon2, 2553) +x(HudKeyIcon3, 2554) +x(HudKeyIcon4, 2555) +x(HudKeyIcon5, 2556) +x(HudKeyIcon6, 2557) +x(HudKeyIcon7, 2558) + +x(BlinkIcon, 2202) +x(ThrowGauge, 2260) +x(Armorbox, 2173) + +x(Healthicon, 2169) +x(Armor1Icon, 2578) +x(Armor2Icon, 2602) +x(Armor3Icon, 2586) + +x(SBarNumberHealth0, 9220) +x(SBarNumberHealth1, 9221) +x(SBarNumberHealth2, 9222) +x(SBarNumberHealth3, 9223) +x(SBarNumberHealth4, 9224) +x(SBarNumberHealth5, 9225) +x(SBarNumberHealth6, 9226) +x(SBarNumberHealth7, 9227) +x(SBarNumberHealth8, 9228) +x(SBarNumberHealth9, 9229) + +x(SBarNumberAmmo0, 9230) +x(SBarNumberAmmo1, 9231) +x(SBarNumberAmmo2, 9232) +x(SBarNumberAmmo3, 9233) +x(SBarNumberAmmo4, 9234) +x(SBarNumberAmmo5, 9235) +x(SBarNumberAmmo6, 9236) +x(SBarNumberAmmo7, 9237) +x(SBarNumberAmmo8, 9238) +x(SBarNumberAmmo9, 9239) + +x(SBarNumberInv0, 9240) +x(SBarNumberInv1, 9241) +x(SBarNumberInv2, 9242) +x(SBarNumberInv3, 9243) +x(SBarNumberInv4, 9244) +x(SBarNumberInv5, 9245) +x(SBarNumberInv6, 9246) +x(SBarNumberInv7, 9247) +x(SBarNumberInv8, 9248) +x(SBarNumberInv9, 9249) + +x(SBarNumberArmor1_0, 9250) +x(SBarNumberArmor1_1, 9251) +x(SBarNumberArmor1_2, 9252) +x(SBarNumberArmor1_3, 9253) +x(SBarNumberArmor1_4, 9254) +x(SBarNumberArmor1_5, 9255) +x(SBarNumberArmor1_6, 9256) +x(SBarNumberArmor1_7, 9257) +x(SBarNumberArmor1_8, 9258) +x(SBarNumberArmor1_9, 9259) + +x(SBarNumberArmor2_0, 9260) +x(SBarNumberArmor2_1, 9261) +x(SBarNumberArmor2_2, 9262) +x(SBarNumberArmor2_3, 9263) +x(SBarNumberArmor2_4, 9264) +x(SBarNumberArmor2_5, 9265) +x(SBarNumberArmor2_6, 9266) +x(SBarNumberArmor2_7, 9267) +x(SBarNumberArmor2_8, 9268) +x(SBarNumberArmor2_9, 9269) + +x(SBarNumberArmor3_0, 9270) +x(SBarNumberArmor3_1, 9271) +x(SBarNumberArmor3_2, 9272) +x(SBarNumberArmor3_3, 9273) +x(SBarNumberArmor3_4, 9274) +x(SBarNumberArmor3_5, 9275) +x(SBarNumberArmor3_6, 9276) +x(SBarNumberArmor3_7, 9277) +x(SBarNumberArmor3_8, 9278) +x(SBarNumberArmor3_9, 9279) + +x(SBarPackAmount0, 2250) +x(SBarPackAmount1, 2251) +x(SBarPackAmount2, 2252) +x(SBarPackAmount3, 2253) +x(SBarPackAmount4, 2254) +x(SBarPackAmount5, 2255) +x(SBarPackAmount6, 2256) +x(SBarPackAmount7, 2257) +x(SBarPackAmount8, 2258) +x(SBarPackAmount9, 2259) + +x(SBarHealthAmount0, 2190) +x(SBarHealthAmount1, 2191) +x(SBarHealthAmount2, 2192) +x(SBarHealthAmount3, 2193) +x(SBarHealthAmount4, 2194) +x(SBarHealthAmount5, 2195) +x(SBarHealthAmount6, 2196) +x(SBarHealthAmount7, 2197) +x(SBarHealthAmount8, 2198) +x(SBarHealthAmount9, 2199) + +x(SBarAmmoAmount0, 2230) +x(SBarAmmoAmount1, 2231) +x(SBarAmmoAmount2, 2232) +x(SBarAmmoAmount3, 2233) +x(SBarAmmoAmount4, 2234) +x(SBarAmmoAmount5, 2235) +x(SBarAmmoAmount6, 2236) +x(SBarAmmoAmount7, 2237) +x(SBarAmmoAmount8, 2238) +x(SBarAmmoAmount9, 2239) + +x(SBarWaponNum0, 2240) +x(SBarWaponNum0, 2241) +x(SBarWaponNum0, 2242) +x(SBarWaponNum0, 2243) +x(SBarWaponNum0, 2244) +x(SBarWaponNum0, 2245) +x(SBarWaponNum0, 2246) +x(SBarWaponNum0, 2247) +x(SBarWaponNum0, 2248) +x(SBarWaponNum0, 2249) diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index c49388ef7..d6f9528b4 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -229,7 +229,7 @@ void nnExtResetGlobals() { if (gTrackingCondsCount > 0) { for (int i = 0; i < gTrackingCondsCount; i++) { TRCONDITION* pCond = &gCondition[i]; - for (int k = 0; k < pCond->length; k++) { + for (unsigned k = 0; k < pCond->length; k++) { pCond->obj[k].index = pCond->obj[k].cmd = 0; pCond->obj[k].type = -1; } @@ -716,7 +716,7 @@ spritetype* randomDropPickupObject(spritetype* pSource, short prevItem) { pSprite2 = actDropObject(pSource, selected); if (pSprite2 != NULL) { - pXSource->dropMsg = pSprite2->type; // store dropped item type in dropMsg + pXSource->dropMsg = uint8_t(pSprite2->type); // store dropped item type in dropMsg pSprite2->x = pSource->x; pSprite2->y = pSource->y; pSprite2->z = pSource->z; @@ -763,7 +763,7 @@ void nnExtProcessSuperSprites() { if (pCond->length > 0 && !pXCond->locked && !pXCond->isTriggered && ++pXCond->busy >= pXCond->busyTime) { pXCond->busy = 0; - for (int k = 0; k < pCond->length; k++) { + for (unsigned k = 0; k < pCond->length; k++) { EVENT evn; evn.index = pCond->obj[k].index; evn.cmd = pCond->obj[k].cmd; @@ -1400,7 +1400,7 @@ void trPlayerCtrlLink(XSPRITE* pXSource, PLAYER* pPlayer, bool checkCondition) { continue; // search for player control sprite and replace it with actual player sprite - for (int k = 0; k < pCond->length; k++) { + for (unsigned k = 0; k < pCond->length; k++) { if (pCond->obj[k].type != OBJ_SPRITE || pCond->obj[k].index != pXSource->reference) continue; pCond->obj[k].index = pPlayer->nSprite; pCond->obj[k].cmd = pPlayer->pXSprite->command; @@ -1638,16 +1638,16 @@ void useObjResizer(XSPRITE* pXSource, short objType, int objIndex) { // for sectors case 6: if (valueIsBetween(pXSource->data1, -1, 32767)) - sector[objIndex].floorxpan_ = ClipRange(pXSource->data1, 0, 255); + sector[objIndex].floorxpan_ = (float)ClipRange(pXSource->data1, 0, 255); if (valueIsBetween(pXSource->data2, -1, 32767)) - sector[objIndex].floorypan_ = ClipRange(pXSource->data2, 0, 255); + sector[objIndex].floorypan_ = (float)ClipRange(pXSource->data2, 0, 255); if (valueIsBetween(pXSource->data3, -1, 32767)) - sector[objIndex].ceilingxpan_ = ClipRange(pXSource->data3, 0, 255); + sector[objIndex].ceilingxpan_ = (float)ClipRange(pXSource->data3, 0, 255); if (valueIsBetween(pXSource->data4, -1, 65535)) - sector[objIndex].ceilingypan_ = ClipRange(pXSource->data4, 0, 255); + sector[objIndex].ceilingypan_ = (float)ClipRange(pXSource->data4, 0, 255); break; // for sprites case 3: @@ -1698,10 +1698,10 @@ void useObjResizer(XSPRITE* pXSource, short objType, int objIndex) { wall[objIndex].yrepeat = ClipRange(pXSource->data2, 0, 255); if (valueIsBetween(pXSource->data3, -1, 32767)) - wall[objIndex].xpan_ = ClipRange(pXSource->data3, 0, 255); + wall[objIndex].xpan_ = (float)ClipRange(pXSource->data3, 0, 255); if (valueIsBetween(pXSource->data4, -1, 65535)) - wall[objIndex].ypan_ = ClipRange(pXSource->data4, 0, 255); + wall[objIndex].ypan_ = (float)ClipRange(pXSource->data4, 0, 255); break; } @@ -2314,7 +2314,7 @@ void useSpriteDamager(XSPRITE* pXSource, spritetype* pSprite) { } if (dmgType >= kDmgFall) { - if (dmg < pXSprite->health << 4) { + if (dmg < (int)pXSprite->health << 4) { if (nnExtIsImmune(pSprite, dmgType, 0)) { Printf(PRINT_HIGH, "Dude type %d is immune to damage type %d!", pSprite->type, dmgType); return; @@ -3201,7 +3201,7 @@ void condUpdateObjectIndex(int objType, int oldIndex, int newIndex) { for (int i = 0; i < gTrackingCondsCount; i++) { TRCONDITION* pCond = &gCondition[i]; - for (int k = 0; k < pCond->length; k++) { + for (unsigned k = 0; k < pCond->length; k++) { if (pCond->obj[k].type != objType || pCond->obj[k].index != oldIndex) continue; pCond->obj[k].index = newIndex; break; @@ -3851,7 +3851,7 @@ bool modernTypeOperateSprite(int nSprite, spritetype* pSprite, XSPRITE* pXSprite else evPost(nSprite, 3, 0, kCmdOff); break; } - pXSprite->dropMsg = pXSprite->data4; + pXSprite->dropMsg = uint8_t(pXSprite->data4); return true; case kModernObjDataAccumulator: switch (event.cmd) { @@ -4352,7 +4352,7 @@ void useSoundGen(spritetype* pSource, XSPRITE* pXSource) { void useIncDecGen(XSPRITE* pXSource, short objType, int objIndex) { char buffer[5]; int data = -65535; short tmp = 0; int dataIndex = 0; - sprintf(buffer, "%d", abs(pXSource->data1)); int len = strlen(buffer); + sprintf(buffer, "%d", abs(pXSource->data1)); int len = int(strlen(buffer)); for (int i = 0; i < len; i++) { dataIndex = (buffer[i] - 52) + 4; @@ -4449,7 +4449,7 @@ void useSectorLigthChanger(XSPRITE* pXSource, XSECTOR* pXSector) { int oldAmplitude = pXSector->amplitude; if (valueIsBetween(pXSource->data2, -128, 128)) - pXSector->amplitude = pXSource->data2; + pXSector->amplitude = uint8_t(pXSource->data2); if (valueIsBetween(pXSource->data3, -1, 32767)) pXSector->freq = ClipHigh(pXSource->data3, 255); @@ -4521,7 +4521,7 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) { // heal dude a bit in case of friendly fire int startHp = (pXSprite->sysData2 > 0) ? ClipRange(pXSprite->sysData2 << 4, 1, 65535) : pDudeInfo->startHealth << 4; - if (pXSprite->health < startHp) actHealDude(pXSprite, receiveHp, startHp); + if (pXSprite->health < (unsigned)startHp) actHealDude(pXSprite, receiveHp, startHp); } else if (xsprite[pBurnSource->extra].health <= 0) { pXSprite->burnTime = 0; } @@ -4581,11 +4581,11 @@ void useTargetChanger(XSPRITE* pXSource, spritetype* pSprite) { // heal dude int startHp = (pXSprite->sysData2 > 0) ? ClipRange(pXSprite->sysData2 << 4, 1, 65535) : pDudeInfo->startHealth << 4; - if (pXSprite->health < startHp) actHealDude(pXSprite, receiveHp, startHp); + if (pXSprite->health < (unsigned)startHp) actHealDude(pXSprite, receiveHp, startHp); // heal mate startHp = (pXMate->sysData2 > 0) ? ClipRange(pXMate->sysData2 << 4, 1, 65535) : getDudeInfo(pMate->type)->startHealth << 4; - if (pXMate->health < startHp) actHealDude(pXMate, receiveHp, startHp); + if (pXMate->health < (unsigned)startHp) actHealDude(pXMate, receiveHp, startHp); if (pXMate->target > -1 && sprite[pXMate->target].extra >= 0) { pTarget = &sprite[pXMate->target]; @@ -4742,10 +4742,10 @@ void usePictureChanger(XSPRITE* pXSource, int objType, int objIndex) { sector[objIndex].ceilingpicnum = pXSource->data2; if (valueIsBetween(pXSource->data3, -1, 32767)) - sector[objIndex].floorpal = pXSource->data3; + sector[objIndex].floorpal = uint8_t(pXSource->data3); if (valueIsBetween(pXSource->data4, -1, 65535)) - sector[objIndex].ceilingpal = pXSource->data4; + sector[objIndex].ceilingpal = uint8_t(pXSource->data4); break; case OBJ_SPRITE: if (valueIsBetween(pXSource->data1, -1, 32767)) @@ -4755,7 +4755,7 @@ void usePictureChanger(XSPRITE* pXSource, int objType, int objIndex) { else if (pXSource->data2 < -1) sprite[objIndex].shade = (pXSource->data2 < -127) ? -127 : pXSource->data2; if (valueIsBetween(pXSource->data3, -1, 32767)) - sprite[objIndex].pal = pXSource->data3; + sprite[objIndex].pal = uint8_t(pXSource->data3); break; case OBJ_WALL: if (valueIsBetween(pXSource->data1, -1, 32767)) @@ -4765,7 +4765,7 @@ void usePictureChanger(XSPRITE* pXSource, int objType, int objIndex) { wall[objIndex].overpicnum = pXSource->data2; if (valueIsBetween(pXSource->data3, -1, 32767)) - wall[objIndex].pal = pXSource->data3; + wall[objIndex].pal = uint8_t(pXSource->data3); break; } } @@ -5163,7 +5163,7 @@ XSPRITE* evrListRedirectors(int objType, int objXIndex, XSPRITE* pXRedir, int* t bool incDecGoalValueIsReached(XSPRITE* pXSprite) { if (pXSprite->data3 != pXSprite->sysData1) return false; - char buffer[5]; sprintf(buffer, "%d", abs(pXSprite->data1)); int len = strlen(buffer); int rx = -1; + char buffer[5]; sprintf(buffer, "%d", abs(pXSprite->data1)); int len = int(strlen(buffer)); int rx = -1; for (int i = bucketHead[pXSprite->txID]; i < bucketHead[pXSprite->txID + 1]; i++) { if (rxBucket[i].type == OBJ_SPRITE && evrIsRedirector(rxBucket[i].index)) continue; for (int a = 0; a < len; a++) { diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index b32c5e76d..5e560d796 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -2328,4 +2328,79 @@ void SerializePlayers(FSerializer& arc) +DEFINE_FIELD_X(BloodPlayer, PLAYER, newWeapon) +DEFINE_FIELD_X(BloodPlayer, PLAYER, weaponQav) +DEFINE_FIELD_X(BloodPlayer, PLAYER, qavCallback) +DEFINE_FIELD_X(BloodPlayer, PLAYER, isRunning) +DEFINE_FIELD_X(BloodPlayer, PLAYER, posture) // stand, crouch, swim +DEFINE_FIELD_X(BloodPlayer, PLAYER, sceneQav) // by NoOne: used to keep qav id +DEFINE_FIELD_X(BloodPlayer, PLAYER, bobPhase) +DEFINE_FIELD_X(BloodPlayer, PLAYER, bobAmp) +DEFINE_FIELD_X(BloodPlayer, PLAYER, bobHeight) +DEFINE_FIELD_X(BloodPlayer, PLAYER, bobWidth) +DEFINE_FIELD_X(BloodPlayer, PLAYER, swayPhase) +DEFINE_FIELD_X(BloodPlayer, PLAYER, swayAmp) +DEFINE_FIELD_X(BloodPlayer, PLAYER, swayHeight) +DEFINE_FIELD_X(BloodPlayer, PLAYER, swayWidth) +DEFINE_FIELD_X(BloodPlayer, PLAYER, nPlayer) // Connect id +DEFINE_FIELD_X(BloodPlayer, PLAYER, nSprite) +DEFINE_FIELD_X(BloodPlayer, PLAYER, lifeMode) +DEFINE_FIELD_X(BloodPlayer, PLAYER, zView) +DEFINE_FIELD_X(BloodPlayer, PLAYER, zViewVel) +DEFINE_FIELD_X(BloodPlayer, PLAYER, zWeapon) +DEFINE_FIELD_X(BloodPlayer, PLAYER, zWeaponVel) +DEFINE_FIELD_X(BloodPlayer, PLAYER, slope) +DEFINE_FIELD_X(BloodPlayer, PLAYER, isUnderwater) +DEFINE_FIELD_X(BloodPlayer, PLAYER, hasKey) +DEFINE_FIELD_X(BloodPlayer, PLAYER, hasFlag) +DEFINE_FIELD_X(BloodPlayer, PLAYER, damageControl) +DEFINE_FIELD_X(BloodPlayer, PLAYER, curWeapon) +DEFINE_FIELD_X(BloodPlayer, PLAYER, nextWeapon) +DEFINE_FIELD_X(BloodPlayer, PLAYER, weaponTimer) +DEFINE_FIELD_X(BloodPlayer, PLAYER, weaponState) +DEFINE_FIELD_X(BloodPlayer, PLAYER, weaponAmmo) //rename +DEFINE_FIELD_X(BloodPlayer, PLAYER, hasWeapon) +DEFINE_FIELD_X(BloodPlayer, PLAYER, weaponMode) +DEFINE_FIELD_X(BloodPlayer, PLAYER, weaponOrder) +DEFINE_FIELD_X(BloodPlayer, PLAYER, ammoCount) +DEFINE_FIELD_X(BloodPlayer, PLAYER, qavLoop) +DEFINE_FIELD_X(BloodPlayer, PLAYER, fuseTime) +DEFINE_FIELD_X(BloodPlayer, PLAYER, throwTime) +DEFINE_FIELD_X(BloodPlayer, PLAYER, throwPower) +DEFINE_FIELD_X(BloodPlayer, PLAYER, aim) // world +DEFINE_FIELD_X(BloodPlayer, PLAYER, aimTarget) // aim target sprite +DEFINE_FIELD_X(BloodPlayer, PLAYER, aimTargetsCount) +DEFINE_FIELD_X(BloodPlayer, PLAYER, aimTargets) +DEFINE_FIELD_X(BloodPlayer, PLAYER, deathTime) +DEFINE_FIELD_X(BloodPlayer, PLAYER, pwUpTime) +DEFINE_FIELD_X(BloodPlayer, PLAYER, teamId) +DEFINE_FIELD_X(BloodPlayer, PLAYER, fragCount) +DEFINE_FIELD_X(BloodPlayer, PLAYER, fragInfo) +DEFINE_FIELD_X(BloodPlayer, PLAYER, underwaterTime) +DEFINE_FIELD_X(BloodPlayer, PLAYER, bubbleTime) +DEFINE_FIELD_X(BloodPlayer, PLAYER, restTime) +DEFINE_FIELD_X(BloodPlayer, PLAYER, kickPower) +DEFINE_FIELD_X(BloodPlayer, PLAYER, laughCount) +DEFINE_FIELD_X(BloodPlayer, PLAYER, godMode) +DEFINE_FIELD_X(BloodPlayer, PLAYER, fallScream) +DEFINE_FIELD_X(BloodPlayer, PLAYER, cantJump) +DEFINE_FIELD_X(BloodPlayer, PLAYER, packItemTime) // pack timer +DEFINE_FIELD_X(BloodPlayer, PLAYER, packItemId) // pack id 1: diving suit, 2: crystal ball, 3: +DEFINE_FIELD_X(BloodPlayer, PLAYER, packSlots) // at325 1]: diving suit, [2]: crystal ball, +DEFINE_FIELD_X(BloodPlayer, PLAYER, armor) // armor +DEFINE_FIELD_X(BloodPlayer, PLAYER, voodooTarget) +DEFINE_FIELD_X(BloodPlayer, PLAYER, flickerEffect) +DEFINE_FIELD_X(BloodPlayer, PLAYER, tiltEffect) +DEFINE_FIELD_X(BloodPlayer, PLAYER, visibility) +DEFINE_FIELD_X(BloodPlayer, PLAYER, painEffect) +DEFINE_FIELD_X(BloodPlayer, PLAYER, blindEffect) +DEFINE_FIELD_X(BloodPlayer, PLAYER, chokeEffect) +DEFINE_FIELD_X(BloodPlayer, PLAYER, handTime) +DEFINE_FIELD_X(BloodPlayer, PLAYER, hand) // if true, there is hand start choking the player +DEFINE_FIELD_X(BloodPlayer, PLAYER, pickupEffect) +DEFINE_FIELD_X(BloodPlayer, PLAYER, flashEffect) // if true, reduce pPlayer->visibility counter +DEFINE_FIELD_X(BloodPlayer, PLAYER, quakeEffect) +DEFINE_FIELD_X(BloodPlayer, PLAYER, player_par) +DEFINE_FIELD_X(BloodPlayer, PLAYER, nWaterPal) + END_BLD_NS diff --git a/source/games/blood/src/sbar.cpp b/source/games/blood/src/sbar.cpp index 4f9621f87..bcf0d8429 100644 --- a/source/games/blood/src/sbar.cpp +++ b/source/games/blood/src/sbar.cpp @@ -1,13 +1,13 @@ //------------------------------------------------------------------------- /* -Copyright (C) 2010-2019 EDuke32 developers and contributors -Copyright (C) 2019 Nuke.YKT +Copyright (C) 2020-2021 Christoph Oelckers -This file is part of NBlood. +This file is part of Raze. -NBlood is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. +This is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +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 @@ -31,8 +31,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "blood.h" #include "zstring.h" -#include "razemenu.h" -#include "gstrings.h" #include "v_2ddrawer.h" #include "v_video.h" #include "v_font.h" @@ -42,802 +40,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gamecvars.h" CVARD(Bool, hud_powerupduration, true, CVAR_ARCHIVE/*|CVAR_FRONTEND_BLOOD*/, "enable/disable displaying the remaining seconds for power-ups") +CVAR(Bool, hud_ctf_vanilla, false, CVAR_ARCHIVE) BEGIN_BLD_NS -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static int gPackIcons[5] = { - 2569, 2564, 2566, 2568, 2560 -}; - -struct PACKICON2 { - short nTile; - int nScale; - int nYOffs; -}; - -PACKICON2 gPackIcons2[] = { - { 519, (int)(65536 * 0.5), 0 }, - { 830, (int)(65536 * 0.3), 0 }, - { 760, (int)(65536 * 0.6), 0 }, - { 839, (int)(65536 * 0.5), -4 }, - { 827, (int)(65536 * 0.4), 0 }, -}; - -struct AMMOICON { - short nTile; - int nScale; - int nYOffs; -}; - -static AMMOICON gAmmoIcons[] = { - { -1, 0, 0 }, - { 816, (int)(65536 * 0.5), 0 }, - { 619, (int)(65536 * 0.8), 0 }, - { 817, (int)(65536 * 0.7), 3 }, - { 801, (int)(65536 * 0.5), -6 }, - { 589, (int)(65536 * 0.7), 2 }, - { 618, (int)(65536 * 0.5), 4 }, - { 548, (int)(65536 * 0.3), -6 }, - { 820, (int)(65536 * 0.3), -6 }, - { 525, (int)(65536 * 0.6), -6 }, - { 811, (int)(65536 * 0.5), 2 }, - { 810, (int)(65536 * 0.45), 2 }, -}; - -struct POWERUPDISPLAY -{ - int nTile; - float nScaleRatio; - int yOffset; - int remainingDuration; -}; - - - -class DBloodStatusBar : public DBaseStatusBar -{ - DECLARE_CLASS(DBloodStatusBar, DBaseStatusBar) - enum NewRSFlags - { - RS_CENTERBOTTOM = 16384, - }; - - TObjPtr smallf, tinyf; - -public: - DBloodStatusBar() - { - smallf = Create(SmallFont, 0, Off, 0, 0 ); - tinyf = Create(gFont[4], 4, CellRight, 0, 0 ); - } - -private: - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DrawStatSprite(int nTile, double x, double y, int nShade = 0, int nPalette = 0, unsigned int nStat = 0, int nScale = 65536, ERenderStyle style = STYLE_Normal, int align = DI_SCREEN_AUTO) - { - int flags = align | ((nStat & RS_CENTERBOTTOM)? DI_ITEM_CENTER_BOTTOM : (nStat & RS_TOPLEFT)? DI_ITEM_LEFT_TOP : DI_ITEM_RELCENTER); - double alpha = 1.; - double scale = nScale / 65536.; - DrawGraphic(tileGetTexture(nTile, true), x, y, flags, alpha, -1, -1, scale, scale, STYLE_Translucent, shadeToLight(nShade), TRANSLATION(Translation_Remap, nPalette), style); - } - void DrawStatMaskedSprite(int nTile, double x, double y, int nShade = 0, int nPalette = 0, unsigned int nStat = 0, int nScale = 65536, int align = DI_SCREEN_AUTO) - { - DrawStatSprite(nTile, x, y, nShade, nPalette, nStat, nScale, STYLE_Translucent, align); - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DrawStatNumber(const char* pFormat, int nNumber, int nTile, double x, double y, int nShade, int nPalette, unsigned int nStat = 0, int nScale = 65536, int align = 0) - { - double width = (tileWidth(nTile) + 1) * (nScale / 65536.); - - char tempbuf[80]; - mysnprintf(tempbuf, 80, pFormat, nNumber); - x += 0.5; - y += 0.5; // This is needed because due to using floating point math, this code rounds slightly differently which for the numbers can be a problem. - for (unsigned int i = 0; tempbuf[i]; i++, x += width) - { - if (tempbuf[i] == ' ') continue; - DrawStatSprite(nTile + tempbuf[i] - '0', x, y, nShade, nPalette, nStat, nScale, STYLE_Translucent, align); - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DrawCharArray(const char* string, int nTile, double x, double y, int nShade, int nPalette, unsigned int nStat = 0, int nScale = 65536, int align = 0) - { - double width = (tileWidth(nTile) + 1) * (nScale / 65536.); - - x += 0.5; - y += 0.5; // This is needed because due to using floating point math, this code rounds slightly differently which for the numbers can be a problem. - - for (unsigned int i = 0; string[i]; i++, x += width) - { - // Hackasaurus rex to give me a slash when drawing the weapon count of a reloadable gun. - if (string[i] == 47 && nTile == kSBarNumberAmmo) - { - DrawStatSprite(9280, x, y, nShade, nPalette, nStat, nScale, STYLE_Translucent, align); - } - else - { - DrawStatSprite(nTile + string[i] - '0', x, y, nShade, nPalette, nStat, nScale, STYLE_Translucent, align); - } - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void TileHGauge(int nTile, double x, double y, int nMult, int nDiv, int nStat = 0, int nScale = 65536) - { - int w = tileWidth(nTile); - int bx = scale(MulScale(w, nScale, 16), nMult, nDiv) + x; - double scale = double(bx - x) / w; - double sc = nScale / 65536.; - DrawGraphic(tileGetTexture(nTile, true), x, y, DI_ITEM_LEFT_TOP, 1., -1, -1, sc, sc, STYLE_Translucent, 0xffffffff, 0, scale); - } - - - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void PrintLevelStats(PLAYER* pPlayer, int bottomy) - { - FLevelStats stats{}; - - stats.fontscale = 1.; - stats.spacing = SmallFont->GetHeight() + 1; - stats.screenbottomspace = bottomy; - stats.font = SmallFont; - stats.letterColor = CR_DARKRED; - stats.standardColor = CR_DARKGRAY; - stats.time = gFrameCount / GameTicRate; - - if (automapMode == am_full) - { - bool textfont = am_textfont; - if (!am_textfont) - { - // For non-English languages force use of the text font. The tiny one is simply too small to ever add localized characters to it. - auto p = GStrings["REQUIRED_CHARACTERS"]; - if (p && *p) textfont = true; - } - - if (!textfont) - { - stats.font = SmallFont2; - stats.spacing = 6; - } - if (hud_size <= Hud_StbarOverlay) stats.screenbottomspace = 56; - DBaseStatusBar::PrintAutomapInfo(stats, textfont); - } - if (automapMode == am_off && hud_stats) - { - stats.completeColor = CR_DARKGREEN; - - stats.kills = gKillMgr.Kills; - stats.maxkills = gKillMgr.TotalKills; - stats.frags = gGameOptions.nGameType == 3? pPlayer->fragCount : -1; - stats.secrets = gSecretMgr.Founds; - stats.supersecrets = gSecretMgr.Super; - stats.maxsecrets = max(gSecretMgr.Founds, gSecretMgr.Total); // If we found more than there are, increase the total. Some levels have a bugged counter. - stats.time = Scale(PlayClock, 1000, 120); - - DBaseStatusBar::PrintLevelStats(stats); - } - } - - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - enum { nPowerUps = 11 }; - - void sortPowerUps(POWERUPDISPLAY* powerups) { - for (int i = 1; i < nPowerUps; i++) - { - for (int j = 0; j < nPowerUps - i; j++) - { - if (powerups[j].remainingDuration > powerups[j + 1].remainingDuration) - { - POWERUPDISPLAY temp = powerups[j]; - powerups[j] = powerups[j + 1]; - powerups[j + 1] = temp; - } - } - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void viewDrawPowerUps(PLAYER* pPlayer) - { - if (!hud_powerupduration) - return; - - POWERUPDISPLAY powerups[nPowerUps]; - powerups[0] = { gPowerUpInfo[kPwUpShadowCloak].picnum, 0.4f, 0, pPlayer->pwUpTime[kPwUpShadowCloak] }; // Invisibility - powerups[1] = { gPowerUpInfo[kPwUpReflectShots].picnum, 0.4f, 5, pPlayer->pwUpTime[kPwUpReflectShots] }; // Reflects enemy shots - powerups[2] = { gPowerUpInfo[kPwUpDeathMask].picnum, 0.3f, 9, pPlayer->pwUpTime[kPwUpDeathMask] }; // Invulnerability - powerups[3] = { gPowerUpInfo[kPwUpTwoGuns].picnum, 0.3f, 5, pPlayer->pwUpTime[kPwUpTwoGuns] }; // Guns Akimbo - powerups[4] = { gPowerUpInfo[kPwUpShadowCloakUseless].picnum, 0.4f, 9, pPlayer->pwUpTime[kPwUpShadowCloakUseless] }; // Does nothing, only appears at near the end of Cryptic Passage's Lost Monastery (CP04) - - // Not in official maps, but custom maps can use them - powerups[5] = { gPowerUpInfo[kPwUpFeatherFall].picnum, 0.3f, 7, pPlayer->pwUpTime[kPwUpFeatherFall] }; // Makes player immune to fall damage - powerups[6] = { gPowerUpInfo[kPwUpGasMask].picnum, 0.4f, 4, pPlayer->pwUpTime[kPwUpGasMask] }; // Makes player immune to choke damage - powerups[7] = { gPowerUpInfo[kPwUpDoppleganger].picnum, 0.5f, 5, pPlayer->pwUpTime[kPwUpDoppleganger] }; // Works in multiplayer, it swaps player's team colors, so enemy team player thinks it's a team mate - powerups[8] = { gPowerUpInfo[kPwUpAsbestArmor].picnum, 0.3f, 9, pPlayer->pwUpTime[kPwUpAsbestArmor] }; // Makes player immune to fire damage and draws HUD - powerups[9] = { gPowerUpInfo[kPwUpGrowShroom].picnum, 0.4f, 4, pPlayer->pwUpTime[kPwUpGrowShroom] }; // Grows player size, works only if gModernMap == true - powerups[10] = { gPowerUpInfo[kPwUpShrinkShroom].picnum, 0.4f, 4, pPlayer->pwUpTime[kPwUpShrinkShroom] }; // Shrinks player size, works only if gModernMap == true - - sortPowerUps(powerups); - - const int warningTime = 5; - const int x = 15; - int y = -50; - for (int i = 0; i < nPowerUps; i++) - { - if (powerups[i].remainingDuration) - { - int remainingSeconds = powerups[i].remainingDuration / 100; - if (remainingSeconds > warningTime || (PlayClock & 32)) - { - DrawStatMaskedSprite(powerups[i].nTile, x, y + powerups[i].yOffset, 0, 0, 256, (int)(65536 * powerups[i].nScaleRatio), DI_SCREEN_LEFT_CENTER); - } - - DrawStatNumber("%d", remainingSeconds, kSBarNumberInv, x + 15, y, 0, remainingSeconds > warningTime ? 0 : 2, 256, 65536 * 0.5, DI_SCREEN_LEFT_CENTER); - y += 20; - } - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void drawInventory(PLAYER* pPlayer, int x, int y) - { - int packs[5]; - if (pPlayer->packItemTime) - { - int nPacks = 0; - int width = 0; - for (int i = 0; i < 5; i++) - { - if (pPlayer->packSlots[i].curAmount) - { - packs[nPacks++] = i; - width += tileWidth(gPackIcons[i]) + 1; - } - } - width /= 2; - x -= width; - for (int i = 0; i < nPacks; i++) - { - int nPack = packs[i]; - DrawStatSprite(2568, x + 1, y - 8); - DrawStatSprite(2568, x + 1, y - 6); - DrawStatSprite(gPackIcons[nPack], x + 1, y + 1); - if (nPack == pPlayer->packItemId) - DrawStatMaskedSprite(2559, x + 1, y + 1); - int nShade; - if (pPlayer->packSlots[nPack].isActive) - nShade = 4; - else - nShade = 24; - DrawStatNumber("%3d", pPlayer->packSlots[nPack].curAmount, 2250, x - 4, y - 13, nShade, 0); - x += tileWidth(gPackIcons[nPack]) + 1; - } - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DrawPackItemInStatusBar(PLAYER* pPlayer, int x, int y, int x2, int y2) - { - auto id = pPlayer->packItemId; - //id = 0; - if (id < 0) return; - - DrawStatSprite(gPackIcons[id], x, y, 0, 0); - DrawStatNumber("%3d", pPlayer->packSlots[id].curAmount, 2250, x2, y2, 0, 0); - } - - void DrawPackItemInStatusBar2(PLAYER* pPlayer, int x, int y, int x2, int y2, int nStat, int nScale) - { - if (pPlayer->packItemId < 0) return; - - DrawStatMaskedSprite(gPackIcons2[pPlayer->packItemId].nTile, x, y + gPackIcons2[pPlayer->packItemId].nYOffs, 0, 0, nStat, gPackIcons2[pPlayer->packItemId].nScale); - DrawStatNumber("%3d", pPlayer->packSlots[pPlayer->packItemId].curAmount, kSBarNumberInv, x2, y2, 0, 0, nStat, nScale); - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void viewDrawPlayerSlots(void) - { - for (int nRows = (gNetPlayers - 1) / 4; nRows >= 0; nRows--) - { - for (int nCol = 0; nCol < 4; nCol++) - { - DrawStatSprite(2229, -120 + nCol * 80, 4 + nRows * 9, 16, 0, 0, 65536, STYLE_Normal, DI_SCREEN_CENTER_TOP); - } - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void viewDrawPlayerFrags(void) - { - FString gTempStr; - viewDrawPlayerSlots(); - for (int i = 0, p = connecthead; p >= 0; i++, p = connectpoint2[p]) - { - int x = -160 + 80 * (i & 3); - int y = 9 * (i / 4); - int col = gPlayer[p].teamId & 3; - const char* name = PlayerName(p); - gTempStr.Format("%s", name); - int color = CR_UNDEFINED;// todo: remap the colors. (11+col) - SBar_DrawString(this, tinyf, gTempStr, x + 4, y, DI_SCREEN_CENTER_TOP, color, 1., -1, -1, 1, 1); - gTempStr.Format("%2d", gPlayer[p].fragCount); - SBar_DrawString(this, tinyf, gTempStr, x + 76, y, DI_SCREEN_CENTER_TOP, color, 1., -1, -1, 1, 1); - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void viewDrawPlayerFlags(void) - { - FString gTempStr; - viewDrawPlayerSlots(); - for (int i = 0, p = connecthead; p >= 0; i++, p = connectpoint2[p]) - { - int x = -160 + 80 * (i & 3); - int y = 9 * (i / 4); - int col = gPlayer[p].teamId & 3; - const char* name = PlayerName(p); - gTempStr.Format("%s", name); - gTempStr.ToUpper(); - int color = CR_UNDEFINED;// todo: remap the colors. - SBar_DrawString(this, tinyf, gTempStr, x + 4, y, DI_SCREEN_CENTER_TOP, color, 1., -1, -1, 1, 1); - - gTempStr = "F"; - x += 76; - if (gPlayer[p].hasFlag & 2) - { - SBar_DrawString(this, tinyf, gTempStr, x, y, DI_SCREEN_CENTER_TOP, CR_GREEN/*12*/, 1., -1, -1, 1, 1); - x -= 6; - } - - if (gPlayer[p].hasFlag & 1) - SBar_DrawString(this, tinyf, gTempStr, x, y, DI_SCREEN_CENTER_TOP, CR_RED/*11*/, 1., -1, -1, 1, 1); - } - } - - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void viewDrawCtfHudVanilla() - { - FString gTempStr; - int x = 1, y = 1; - if (team_ticker[0] == 0 || (PlayClock & 8)) - { - SBar_DrawString(this, smallf, GStrings("TXT_COLOR_BLUE"), x, y, 0, CR_LIGHTBLUE, 1., -1, -1, 1, 1); - gTempStr.Format("%-3d", team_score[0]); - SBar_DrawString(this, smallf, gTempStr, x, y + 10, 0, CR_LIGHTBLUE, 1., -1, -1, 1, 1); - } - x = -2; - if (team_ticker[1] == 0 || (PlayClock & 8)) - { - SBar_DrawString(this, smallf, GStrings("TXT_COLOR_RED"), x, y, DI_TEXT_ALIGN_RIGHT, CR_BRICK, 1., -1, -1, 1, 1); - gTempStr.Format("%3d", team_score[1]); - SBar_DrawString(this, smallf, gTempStr, x, y + 10, DI_TEXT_ALIGN_RIGHT, CR_BRICK, 1., -1, -1, 1, 1); - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void flashTeamScore(int team, bool show) - { - assert(0 == team || 1 == team); // 0: blue, 1: red - - if (team_ticker[team] == 0 || (PlayClock & 8)) - { - if (show) - DrawStatNumber("%d", team_score[team], kSBarNumberInv, -30, team ? 25 : -10, 0, team ? 2 : 10, 512, 65536 * 0.75, DI_SCREEN_RIGHT_CENTER); - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void viewDrawCtfHud() - { - if (hud_size == Hud_Nothing) - { - flashTeamScore(0, false); - flashTeamScore(1, false); - return; - } - - bool blueFlagTaken = false; - bool redFlagTaken = false; - int blueFlagCarrierColor = 0; - int redFlagCarrierColor = 0; - for (int i = 0, p = connecthead; p >= 0; i++, p = connectpoint2[p]) - { - if ((gPlayer[p].hasFlag & 1) != 0) - { - blueFlagTaken = true; - blueFlagCarrierColor = gPlayer[p].teamId & 3; - } - if ((gPlayer[p].hasFlag & 2) != 0) - { - redFlagTaken = true; - redFlagCarrierColor = gPlayer[p].teamId & 3; - } - } - - bool meHaveBlueFlag = gMe->hasFlag & 1; - DrawStatMaskedSprite(meHaveBlueFlag ? 3558 : 3559, 0, 75-100, 0, 10, 512, 65536 * 0.35, DI_SCREEN_RIGHT_CENTER); - if (gBlueFlagDropped) - DrawStatMaskedSprite(2332, 305-320, 83 - 100, 0, 10, 512, 65536, DI_SCREEN_RIGHT_CENTER); - else if (blueFlagTaken) - DrawStatMaskedSprite(4097, 307-320, 77 - 100, 0, blueFlagCarrierColor ? 2 : 10, 512, 65536, DI_SCREEN_RIGHT_CENTER); - flashTeamScore(0, true); - - bool meHaveRedFlag = gMe->hasFlag & 2; - DrawStatMaskedSprite(meHaveRedFlag ? 3558 : 3559, 0, 10, 0, 2, 512, 65536 * 0.35, DI_SCREEN_RIGHT_CENTER); - if (gRedFlagDropped) - DrawStatMaskedSprite(2332, 305-320, 17, 0, 2, 512, 65536, DI_SCREEN_RIGHT_CENTER); - else if (redFlagTaken) - DrawStatMaskedSprite(4097, 307-320, 11, 0, redFlagCarrierColor ? 2 : 10, 512, 65536, DI_SCREEN_RIGHT_CENTER); - flashTeamScore(1, true); - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DrawStatusBar(int nPalette) - { - BeginStatusBar(320, 200, tileHeight(2200)); - - PLAYER* pPlayer = gView; - XSPRITE* pXSprite = pPlayer->pXSprite; - - DrawStatMaskedSprite(2200, 160, 200, 0, nPalette, RS_CENTERBOTTOM); - DrawPackItemInStatusBar(pPlayer, 265, 186, 260, 172); - - if (pXSprite->health >= 16 || (PlayClock & 16) || pXSprite->health == 0) - { - DrawStatNumber("%3d", pXSprite->health >> 4, 2190, 86, 183, 0, 0); - } - if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1) - { - int num = pPlayer->ammoCount[pPlayer->weaponAmmo]; - if (pPlayer->weaponAmmo == 6) - num /= 10; - DrawStatNumber("%3d", num, 2240, 216, 183, 0, 0); - } - for (int i = 9; i >= 1; i--) - { - int x = 135 + ((i - 1) / 3) * 23; - int y = 182 + ((i - 1) % 3) * 6; - int num = pPlayer->ammoCount[i]; - if (i == 6) - num /= 10; - DrawStatNumber("%3d", num, 2230, x, y, i == pPlayer->weaponAmmo? -128 : 32, 10); - } - DrawStatNumber("%2d", pPlayer->ammoCount[10], 2230, 291, 194, pPlayer->weaponAmmo == 10? -128 : 32, 10); - DrawStatNumber("%2d", pPlayer->ammoCount[11], 2230, 309, 194, pPlayer->weaponAmmo == 11? -128 : 32, 10); - - if (pPlayer->armor[1]) - { - TileHGauge(2207, 44, 174, pPlayer->armor[1], 3200); - DrawStatNumber("%3d", pPlayer->armor[1] >> 4, 2230, 50, 177, 0, 0); - } - if (pPlayer->armor[0]) - { - TileHGauge(2209, 44, 182, pPlayer->armor[0], 3200); - DrawStatNumber("%3d", pPlayer->armor[0] >> 4, 2230, 50, 185, 0, 0); - } - if (pPlayer->armor[2]) - { - TileHGauge(2208, 44, 190, pPlayer->armor[2], 3200); - DrawStatNumber("%3d", pPlayer->armor[2] >> 4, 2230, 50, 193, 0, 0); - } - - for (int i = 0; i < 6; i++) - { - int nTile = 2220 + i; - double x = 73.5 + (i & 1) * 173; - double y = 171.5 + (i >> 1) * 11; - if (pPlayer->hasKey[i + 1]) - DrawStatSprite(nTile, x, y); - else - DrawStatSprite(nTile, x, y, 40, 5); - } - DrawStatMaskedSprite(2202, 118.5, 185.5, /*pPlayer->isRunning ? 16 :*/ 40); - DrawStatMaskedSprite(2202, 201.5, 185.5, /*pPlayer->isRunning ? 16 :*/ 40); - if (pPlayer->throwPower) - { - TileHGauge(2260, 124, 175.5, pPlayer->throwPower, 65536); - } - drawInventory(pPlayer, 166, 200 - tileHeight(2200)); - // Depending on the scale we can lower the stats display. This needs some tweaking but this catches the important default case already. - PrintLevelStats(pPlayer, (hud_statscale <= 0.501f || hud_scalefactor < 0.7) && double(twod->GetWidth())/twod->GetHeight() > 1.6? 28 : 56); - - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DrawHUD1(int nPalette) - { - PLAYER* pPlayer = gView; - XSPRITE* pXSprite = pPlayer->pXSprite; - - BeginHUD(320, 200, 1); - DrawStatSprite(2201, 34, 187 - 200, 16, nPalette); - if (pXSprite->health >= 16 || (PlayClock & 16) || pXSprite->health == 0) - { - DrawStatNumber("%3d", pXSprite->health >> 4, 2190, 8, 183 - 200, 0, 0); - } - if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1) - { - int num = pPlayer->ammoCount[pPlayer->weaponAmmo]; - if (pPlayer->weaponAmmo == 6) - num /= 10; - DrawStatNumber("%3d", num, 2240, 42, 183 - 200, 0, 0); - } - DrawStatSprite(2173, 284-320, 187 - 200, 16, nPalette); - if (pPlayer->armor[1]) - { - TileHGauge(2207, 250-320, 175 - 200, pPlayer->armor[1], 3200); - DrawStatNumber("%3d", pPlayer->armor[1] >> 4, 2230, 255-320, 178 - 200, 0, 0); - } - if (pPlayer->armor[0]) - { - TileHGauge(2209, 250-320, 183 - 200, pPlayer->armor[0], 3200); - DrawStatNumber("%3d", pPlayer->armor[0] >> 4, 2230, 255-320, 186 - 200, 0, 0); - } - if (pPlayer->armor[2]) - { - TileHGauge(2208, 250-320, 191 - 200, pPlayer->armor[2], 3200); - DrawStatNumber("%3d", pPlayer->armor[2] >> 4, 2230, 255-320, 194 - 200, 0, 0); - } - - DrawPackItemInStatusBar(pPlayer, 286-320, 186 - 200, 302-320, 183 - 200); - - for (int i = 0; i < 6; i++) - { - int nTile = 2220 + i; - int x; - int y = - 6; - if (i & 1) - { - x = - (78 + (i >> 1) * 10); - } - else - { - x = 73 + (i >> 1) * 10; - } - if (pPlayer->hasKey[i + 1]) - DrawStatSprite(nTile, x, y, 0, 0); - } - PrintLevelStats(pPlayer, 28); - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DrawHUD2() - { - PLAYER* pPlayer = gView; - XSPRITE* pXSprite = pPlayer->pXSprite; - - BeginHUD(320, 200, 1); - DrawStatMaskedSprite(2169, 12, 195 - 200, 0, 0, 256, (int)(65536 * 0.56)); - DrawStatNumber("%d", pXSprite->health >> 4, kSBarNumberHealth, 28, 187 - 200, 0, 0, 256); - if (pPlayer->armor[1]) - { - DrawStatMaskedSprite(2578, 70, 186 - 200, 0, 0, 256, (int)(65536 * 0.5)); - DrawStatNumber("%3d", pPlayer->armor[1] >> 4, kSBarNumberArmor2, 83, 187 - 200, 0, 0, 256, (int)(65536 * 0.65)); - } - if (pPlayer->armor[0]) - { - DrawStatMaskedSprite(2586, 112, 195 - 200, 0, 0, 256, (int)(65536 * 0.5)); - DrawStatNumber("%3d", pPlayer->armor[0] >> 4, kSBarNumberArmor1, 125, 187 - 200, 0, 0, 256, (int)(65536 * 0.65)); - } - if (pPlayer->armor[2]) - { - DrawStatMaskedSprite(2602, 155, 196 - 200, 0, 0, 256, (int)(65536 * 0.5)); - DrawStatNumber("%3d", pPlayer->armor[2] >> 4, kSBarNumberArmor3, 170, 187 - 200, 0, 0, 256, (int)(65536 * 0.65)); - } - - DrawPackItemInStatusBar2(pPlayer, 216 - 320, 194 - 200, 231 - 320, 187 - 200, 512, (int)(65536 * 0.7)); - - if (pPlayer->curWeapon && pPlayer->weaponAmmo != -1) - { - int num = pPlayer->ammoCount[pPlayer->weaponAmmo]; - if (pPlayer->weaponAmmo == 6) - num /= 10; - if ((unsigned int)gAmmoIcons[pPlayer->weaponAmmo].nTile < kMaxTiles) - DrawStatMaskedSprite(gAmmoIcons[pPlayer->weaponAmmo].nTile, 304-320, -8 + gAmmoIcons[pPlayer->weaponAmmo].nYOffs, - 0, 0, 512, gAmmoIcons[pPlayer->weaponAmmo].nScale); - - bool reloadableWeapon = pPlayer->curWeapon == 3 && !powerupCheck(pPlayer, kPwUpTwoGuns); - if (!reloadableWeapon || (reloadableWeapon && !cl_showmagamt)) - { - DrawStatNumber("%3d", num, kSBarNumberAmmo, 267-320, 187 - 200, 0, 0, 512); - } - else - { - FString format; - short clip = CalcMagazineAmount(num, 2, pPlayer->weaponState == 1); - short total = num - clip; - format.Format("%d/%d", clip, num - clip); - - DrawCharArray(format.GetChars(), kSBarNumberAmmo, (total < 10 ? 267 : 258) - 320, 187 - 200, 0, 0, 512); - } - } - - for (int i = 0; i < 6; i++) - { - if (pPlayer->hasKey[i + 1]) - DrawStatMaskedSprite(2552 + i, -60 + 10 * i, 170 - 200, 0, 0, 0, (int)(65536 * 0.25)); - } - - BeginStatusBar(320, 200, 28); - if (pPlayer->throwPower) - TileHGauge(2260, 124, 175, pPlayer->throwPower, 65536); - else - drawInventory(pPlayer, 166, 200-tileHeight(2201) / 2 - 30); - PrintLevelStats(pPlayer, 28); - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - public: - void UpdateStatusBar() - { - PLAYER* pPlayer = gView; - XSPRITE* pXSprite = pPlayer->pXSprite; - - int nPalette = 0; - - if (gGameOptions.nGameType == 3) - { - if (pPlayer->teamId & 1) - nPalette = 7; - else - nPalette = 10; - } - - if (hud_size == Hud_full) - { - DrawHUD2(); - } - else if (hud_size > Hud_Stbar) - { - BeginStatusBar(320, 200, 28); - if (pPlayer->throwPower) - TileHGauge(2260, 124, 175, pPlayer->throwPower, 65536); - else if (hud_size > Hud_StbarOverlay) - drawInventory(pPlayer, 166, 200 - tileHeight(2201) / 2); - } - if (hud_size == Hud_Mini) - { - DrawHUD1(nPalette); - } - else if (hud_size <= Hud_StbarOverlay) - { - DrawStatusBar(nPalette); - } - - // All remaining parts must be done with HUD alignment rules, even when showing a status bar. - BeginHUD(320, 200, 1); - viewDrawPowerUps(pPlayer); - - if (gGameOptions.nGameType >= 1) - { - if (gGameOptions.nGameType == 3) - { - if (VanillaMode()) - { - viewDrawCtfHudVanilla(); - } - else - { - viewDrawCtfHud(); - viewDrawPlayerFlags(); - } - } - else - { - viewDrawPlayerFrags(); - } - } - } -}; - -IMPLEMENT_CLASS(DBloodStatusBar, false, false) - - static void UpdateFrame(void) { auto tex = tileGetTexture(kBackTile); @@ -861,8 +67,22 @@ void UpdateStatusBar() { UpdateFrame(); } - - StatusBar->UpdateStatusBar(); + SummaryInfo sum; + if (gGameOptions.nGameType == 3) + { + sum.kills = gView ? gView->fragCount : 0; + sum.maxkills = -3; + } + else + { + sum.kills = gKillMgr.Kills; + sum.maxkills = gKillMgr.TotalKills; + } + sum.secrets = gSecretMgr.Founds; + sum.supersecrets = gSecretMgr.Super; + sum.maxsecrets = max(gSecretMgr.Founds, gSecretMgr.Total); // If we found more than there are, increase the total. Some levels have a bugged counter. + sum.time = Scale(PlayClock, 1000, 120); + UpdateStatusBar(&sum); } diff --git a/source/games/blood/src/sectorfx.cpp b/source/games/blood/src/sectorfx.cpp index 84eea1e80..4d91c4529 100644 --- a/source/games/blood/src/sectorfx.cpp +++ b/source/games/blood/src/sectorfx.cpp @@ -281,8 +281,8 @@ void DoSectorPanning(void) int px = MulScale(speed << 2, Cos(angle), 30) / xBits; int yBits = tileHeight(nTile) >> int((pSector->floorstat & 8) != 0); int py = MulScale(speed << 2, Sin(angle), 30) / yBits; - pSector->addfloorxpan(px * (1. / 256)); - pSector->addfloorypan(-py * (1. / 256)); + pSector->addfloorxpan(px * (1.f / 256)); + pSector->addfloorypan(-py * (1.f / 256)); } if (pXSector->panCeiling) // Ceiling { @@ -293,8 +293,8 @@ void DoSectorPanning(void) int px = MulScale(speed << 2, Cos(angle), 30) / xBits; int yBits = tileHeight(nTile) >> int((pSector->ceilingstat & 8) != 0); int py = MulScale(speed << 2, Sin(angle), 30) / yBits; - pSector->addceilingxpan(px * (1. / 256)); - pSector->addceilingypan(-py * (1. / 256)); + pSector->addceilingxpan(px * (1.f / 256)); + pSector->addceilingypan(-py * (1.f / 256)); } } } @@ -317,8 +317,8 @@ void DoSectorPanning(void) int px = (psx << 2) / tileWidth(nTile); int py = (psy << 2) / tileHeight(nTile); - wall[nWall].addxpan(px * (1. / 256)); - wall[nWall].addypan(py * (1. / 256)); + wall[nWall].addxpan(px * (1.f / 256)); + wall[nWall].addypan(py * (1.f / 256)); } } } diff --git a/source/games/blood/src/sfx.cpp b/source/games/blood/src/sfx.cpp index f1ac8e609..8acaef21f 100644 --- a/source/games/blood/src/sfx.cpp +++ b/source/games/blood/src/sfx.cpp @@ -114,7 +114,7 @@ void GameInterface::UpdateSounds() if (gMe->pSprite) { - listener.angle = -gMe->pSprite->ang * BAngRadian; // Build uses a period of 2048. + listener.angle = -gMe->pSprite->ang * float(BAngRadian); // Build uses a period of 2048. listener.velocity.Zero(); listener.position = GetSoundPos(&gMe->pSprite->pos); listener.valid = true; diff --git a/source/games/blood/src/sound.cpp b/source/games/blood/src/sound.cpp index 28dae78bb..d3a626cb5 100644 --- a/source/games/blood/src/sound.cpp +++ b/source/games/blood/src/sound.cpp @@ -181,6 +181,7 @@ void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop, else nVolume = 255; } if (bLoop) chanflags |= CHANF_LOOP; + soundEngine->StopActorSounds(SOURCE_None, nullptr, nChannel + 1, nChannel + 1); soundEngine->StartSound(SOURCE_None, nullptr, nullptr, (nChannel + 1), chanflags, snd, nVolume / 255.f, ATTN_NONE); } } diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index 5bc3c10b0..06ac6fc6a 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -270,9 +270,9 @@ void LifeLeechOperate(spritetype *pSprite, XSPRITE *pXSprite, EVENT event) int nMissileType = kMissileLifeLeechAltNormal + (pXSprite->data3 ? 1 : 0); int t2; if (!pXSprite->data3) - t2 = 120 / 10.0; + t2 = 120 / 10; else - t2 = (3*120) / 10.0; + t2 = (3*120) / 10; spritetype *pMissile = actFireMissile(pSprite, 0, z1, dx, dy, dz, nMissileType); if (pMissile) { diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index fa3498741..68383054c 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -742,7 +742,7 @@ void viewDrawScreen(bool sceneonly) } else { - renderSetRollAngle(rotscrnang.asbuildf()); + renderSetRollAngle((float)rotscrnang.asbuildf()); render3DViewPolymost(nSectnum, cX, cY, cZ, cA, cH); } bDeliriumOld = bDelirium && gDeliriumBlur; @@ -785,12 +785,6 @@ void viewDrawScreen(bool sceneonly) { gChoke.animateChoke(160, zn, (int)gInterpolate); } -#if 0 - if (drawtile_2048) - { - DrawStatSprite(2048, xdim-15, 20); - } -#endif viewDrawAimedPlayerName(); if (paused) diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index f180a3092..8c94b6dd6 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -194,7 +194,7 @@ static bool CheckAmmo(PLAYER *pPlayer, int ammotype, int count) return 1; if (pPlayer->curWeapon == 12 && pPlayer->weaponAmmo == 11 && pPlayer->weaponState == 11) return 1; - if (pPlayer->curWeapon == 9 && pPlayer->pXSprite->health >= (count<<4)) + if (pPlayer->curWeapon == 9 && pPlayer->pXSprite->health >= unsigned(count<<4)) return 1; return pPlayer->ammoCount[ammotype] >= count; } @@ -1703,7 +1703,7 @@ void AltFireLifeLeech(int , PLAYER *pPlayer) if (gGameOptions.nGameType <= 1) { int nAmmo = pPlayer->ammoCount[8]; - if (nAmmo < 25 && pPlayer->pXSprite->health > ((25-nAmmo)<<4)) + if (nAmmo < 25 && pPlayer->pXSprite->health > unsigned((25-nAmmo)<<4)) { actDamageSprite(pPlayer->nSprite, pPlayer->pSprite, DAMAGE_TYPE_5, ((25-nAmmo)<<4)); nAmmo = 25; diff --git a/source/games/duke/all_d.cpp b/source/games/duke/all_d.cpp index 65c9bf7c0..a528bf07d 100644 --- a/source/games/duke/all_d.cpp +++ b/source/games/duke/all_d.cpp @@ -6,7 +6,6 @@ #include "src/player_d.cpp" #include "src/player_w.cpp" #include "src/premap_d.cpp" -#include "src/sbar_d.cpp" #include "src/sectors_d.cpp" #include "src/spawn_d.cpp" diff --git a/source/games/duke/all_r.cpp b/source/games/duke/all_r.cpp index 88e850128..7a0263cc5 100644 --- a/source/games/duke/all_r.cpp +++ b/source/games/duke/all_r.cpp @@ -7,6 +7,5 @@ #include "src/hudweapon_r.cpp" #include "src/player_r.cpp" #include "src/premap_r.cpp" -#include "src/sbar_r.cpp" #include "src/sectors_r.cpp" #include "src/spawn_r.cpp" diff --git a/source/games/duke/src/2d_d.cpp b/source/games/duke/src/2d_d.cpp index e8f3561f6..c84e4ce46 100644 --- a/source/games/duke/src/2d_d.cpp +++ b/source/games/duke/src/2d_d.cpp @@ -112,9 +112,9 @@ void InitFonts_d() fontdata.Clear(); // SBAR index font - for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(THREEBYFIVE + i)); - fontdata.Insert(':', tileGetTexture(THREEBYFIVE + 10)); - fontdata.Insert('/', tileGetTexture(THREEBYFIVE + 11)); + for (int i = 0; i < 10; i++) fontdata.Insert('0' + i, tileGetTexture(THREEBYFIVE0 + i)); + fontdata.Insert(':', tileGetTexture(THREEBYFIVE0 + 10)); + fontdata.Insert('/', tileGetTexture(THREEBYFIVE0 + 11)); fontdata.Insert('%', tileGetTexture(MINIFONT + '%' - '!')); fontdata.Insert(1, TexMan.FindGameTexture("TINYBLAK")); // this is only here to widen the color range of the font to produce a better translation. GlyphSet::Iterator iti(fontdata); diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 89ba3c3fa..dc498fbfd 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -316,19 +316,14 @@ void ms(DDukeActor* const actor) void movecyclers(void) { - short q, j, x, t, s, * c; - walltype* wal; - char cshade; - - for (q = numcyclers - 1; q >= 0; q--) + for (int q = numcyclers - 1; q >= 0; q--) { + short* c = &cyclers[q][0]; + int s = c[0]; - c = &cyclers[q][0]; - s = c[0]; - - t = c[3]; - j = t + bsin(c[1], -10); - cshade = c[2]; + int t = c[3]; + int j = t + bsin(c[1], -10); + int cshade = c[2]; if (j < cshade) j = cshade; else if (j > t) j = t; @@ -336,8 +331,8 @@ void movecyclers(void) c[1] += sector[s].extra; if (c[5]) { - wal = &wall[sector[s].wallptr]; - for (x = sector[s].wallnum; x > 0; x--, wal++) + auto wal = &wall[sector[s].wallptr]; + for (int x = sector[s].wallnum; x > 0; x--, wal++) if (wal->hitag != 1) { wal->shade = j; @@ -4466,7 +4461,7 @@ void handle_se27(DDukeActor* actor) { if (cansee(s->x, s->y, s->z, s->sectnum, ps[p].posx, ps[p].posy, ps[p].posz, ps[p].cursectnum)) { - if (x < (unsigned)sh) + if (x < sh) { ud.cameraactor = actor; t[0] = 999; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 0962311d8..912d73225 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -220,9 +220,9 @@ void addweapon_d(struct player_struct *p, int weapon) { if ( p->gotweapon[weapon] == 0 ) { - p->gotweapon.Set(weapon); - if(weapon == SHRINKER_WEAPON) - p->gotweapon.Set(GROW_WEAPON); + p->gotweapon[weapon] = true; + if (weapon == SHRINKER_WEAPON) + p->gotweapon[GROW_WEAPON] = true; } p->random_club_frame = 0; @@ -1578,7 +1578,7 @@ static bool movefireball(DDukeActor* actor) spr->zvel = proj->zv; } } - spr->yrepeat = spr->xrepeat = (short)(s->xrepeat * siz); + spr->yrepeat = spr->xrepeat = (uint8_t)(s->xrepeat * siz); spr->cstat = s->cstat; spr->extra = 0; diff --git a/source/games/duke/src/actors_lava.cpp b/source/games/duke/src/actors_lava.cpp index 290b1932f..396269616 100644 --- a/source/games/duke/src/actors_lava.cpp +++ b/source/games/duke/src/actors_lava.cpp @@ -557,7 +557,7 @@ void thunder(void) struct player_struct* p; int r1, r2; short startwall, endwall, i, j; - unsigned char shade; + uint8_t shade; p = &ps[screenpeek]; @@ -612,10 +612,10 @@ void thunder(void) { startwall = sector[lightninsector[i]].wallptr; endwall = startwall + sector[lightninsector[i]].wallnum; - sector[lightninsector[i]].floorshade = lightninsectorshade[i]; - sector[lightninsector[i]].ceilingshade = lightninsectorshade[i]; + sector[lightninsector[i]].floorshade = (int8_t)lightninsectorshade[i]; + sector[lightninsector[i]].ceilingshade = (int8_t)lightninsectorshade[i]; for (j = startwall; j < endwall; j++) - wall[j].shade = lightninsectorshade[i]; + wall[j].shade = (int8_t)lightninsectorshade[i]; } } } diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 76fcc7170..73d1a2e2a 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -118,16 +118,16 @@ void addweapon_r(struct player_struct* p, int weapon) short cw = p->curr_weapon; if (p->OnMotorcycle || p->OnBoat) { - p->gotweapon.Set(weapon); + p->gotweapon[weapon] = true;; if (weapon == THROWSAW_WEAPON) { - p->gotweapon.Set(BUZZSAW_WEAPON); + p->gotweapon[BUZZSAW_WEAPON] = true; p->ammo_amount[BUZZSAW_WEAPON] = 1; } else if (weapon == CROSSBOW_WEAPON) { - p->gotweapon.Set(CHICKEN_WEAPON); - p->gotweapon.Set(DYNAMITE_WEAPON); + p->gotweapon[CHICKEN_WEAPON] = true; + p->gotweapon[DYNAMITE_WEAPON] = true; } else if (weapon == SLINGBLADE_WEAPON) { @@ -138,17 +138,17 @@ void addweapon_r(struct player_struct* p, int weapon) if (p->gotweapon[weapon] == 0) { - p->gotweapon.Set(weapon); + p->gotweapon[weapon] = true;; if (weapon == THROWSAW_WEAPON) { - p->gotweapon.Set(BUZZSAW_WEAPON); + p->gotweapon[BUZZSAW_WEAPON] = true; p->ammo_amount[BUZZSAW_WEAPON] = 1; } if (isRRRA()) { if (weapon == CROSSBOW_WEAPON) { - p->gotweapon.Set(CHICKEN_WEAPON); + p->gotweapon[CHICKEN_WEAPON] = true; } if (weapon == SLINGBLADE_WEAPON) { @@ -157,7 +157,7 @@ void addweapon_r(struct player_struct* p, int weapon) } if (weapon == CROSSBOW_WEAPON) { - p->gotweapon.Set(DYNAMITE_WEAPON); + p->gotweapon[DYNAMITE_WEAPON] = true; } if (weapon != DYNAMITE_WEAPON) diff --git a/source/games/duke/src/ccmds.cpp b/source/games/duke/src/ccmds.cpp index a2b5c339b..f7d04da40 100644 --- a/source/games/duke/src/ccmds.cpp +++ b/source/games/duke/src/ccmds.cpp @@ -29,7 +29,6 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "ns.h" #include "duke3d.h" -#include "sbar.h" #include "mapinfo.h" #include "cheathandler.h" #include "c_dispatch.h" diff --git a/source/games/duke/src/cheats.cpp b/source/games/duke/src/cheats.cpp index c76f8c96e..e87bce1fc 100644 --- a/source/games/duke/src/cheats.cpp +++ b/source/games/duke/src/cheats.cpp @@ -194,7 +194,7 @@ const char* GameInterface::GenericCheat(int player, int cheat) case CHT_RHETT: ud.god = 0; - ps[player].gotweapon.Zero(); + memset(ps[player].gotweapon, 0, MAX_WEAPONS); ps[player].curr_weapon = KNEE_WEAPON; ps[player].nocheat = 1; ps[player].GetActor()->s->extra = 1; @@ -231,7 +231,7 @@ static bool cheatWeapons(int player) for (int weapon = PISTOL_WEAPON; weapon < weaponLimit; weapon++ ) { addammo( weapon, &ps[player], gs.max_ammo_amount[weapon] ); - ps[player].gotweapon.Set(weapon); + ps[player].gotweapon[weapon] = true;; } if (isRRRA()) ps[player].ammo_amount[SLINGBLADE_WEAPON] = 1; diff --git a/source/games/duke/src/flags_r.cpp b/source/games/duke/src/flags_r.cpp index 04ef28b6e..3fcb1ae8a 100644 --- a/source/games/duke/src/flags_r.cpp +++ b/source/games/duke/src/flags_r.cpp @@ -173,7 +173,7 @@ void initactorflags_r() STEROIDS, HEATSENSOR, BOOTS, - JETPACK, + COWPIE, HOLODUKE, AIRTANK }); @@ -205,7 +205,7 @@ void initactorflags_r() gs.weaponsandammosprites[2] = DEVISTATORAMMO; gs.weaponsandammosprites[3] = RPGAMMO; gs.weaponsandammosprites[4] = RPGAMMO; - gs.weaponsandammosprites[5] = JETPACK; + gs.weaponsandammosprites[5] = COWPIE; gs.weaponsandammosprites[6] = SHIELD; gs.weaponsandammosprites[7] = FIRSTAID; gs.weaponsandammosprites[8] = STEROIDS; diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 64b9199f6..bc3f2a56e 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -227,6 +227,7 @@ void PlayerColorChanged(void); bool movementBlocked(player_struct *p); void loadcons(); void recordoldspritepos(); +void DrawStatusBar(); int* animateptr(int i); diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 89e32c0af..8f4165183 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -40,7 +40,6 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "st_start.h" #include "i_interface.h" #include "prediction.h" -#include "sbar.h" #include "gamestate.h" #include "dukeactor.h" #include "interpolate.h" @@ -232,7 +231,7 @@ void drawoverlays(double smoothratio) // loogies courtesy of being snotted on if (pp->loogcnt > 0 && !isRR()) { - V_AddBlend(0, 63, 0, (pp->loogcnt >> 1), blend); + V_AddBlend(0, 63, 0, float(pp->loogcnt >> 1), blend); } if (blend[3]) { @@ -291,9 +290,7 @@ void drawoverlays(double smoothratio) } } - DrawBorder(); - - StatusBar->UpdateStatusBar(); + DrawStatusBar(); if (ps[myconnectindex].newOwner == nullptr && ud.cameraactor == nullptr) { diff --git a/source/games/duke/src/gamedef.cpp b/source/games/duke/src/gamedef.cpp index 9b86ae0db..89ccc2dda 100644 --- a/source/games/duke/src/gamedef.cpp +++ b/source/games/duke/src/gamedef.cpp @@ -300,7 +300,7 @@ int ConCompiler::getkeyword(const char* text) while (min <= max) { - int mid = (min + max) >> 1; + auto mid = (min + max) >> 1; const int comp = strcmp(text, cmdList[mid].cmd); if (comp == 0) diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 1a9b7d754..e2d0b2751 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -633,7 +633,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, case PLAYER_ONE_EIGHTY_COUNT: if (bSet) ps[iPlayer].angle.spin = lValue; - else SetGameVarID(lVar2, ps[iPlayer].angle.spin, sActor, sPlayer); + else SetGameVarID(lVar2, int(ps[iPlayer].angle.spin), sActor, sPlayer); break; case PLAYER_CHEAT_PHASE: @@ -851,7 +851,7 @@ void DoPlayer(bool bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, break; case PLAYER_GOTWEAPON: - if (bSet) ps[iPlayer].gotweapon.Set(lParm2, lValue); + if (bSet) ps[iPlayer].gotweapon[lParm2, lValue] = true; else SetGameVarID(lVar2, ps[iPlayer].gotweapon[lParm2], sActor, sPlayer); break; @@ -987,11 +987,11 @@ void DoWall(char bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, s else SetGameVarID(lVar2, wall[iWall].yrepeat, sActor, sPlayer); break; case WALL_XPANNING: - if (bSet) wall[iWall].xpan_ = lValue; + if (bSet) wall[iWall].xpan_ = (float)(lValue & 255); else SetGameVarID(lVar2, wall[iWall].xpan(), sActor, sPlayer); break; case WALL_YPANNING: - if (bSet) wall[iWall].ypan_ = lValue; + if (bSet) wall[iWall].ypan_ = (float)(lValue & 255); else SetGameVarID(lVar2, wall[iWall].ypan(), sActor, sPlayer); break; case WALL_LOTAG: @@ -1077,11 +1077,11 @@ void DoSector(char bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, else SetGameVarID(lVar2, sector[iSector].ceilingpal, sActor, sPlayer); break; case SECTOR_CEILINGXPANNING: - if (bSet) sector[iSector].ceilingxpan_ = lValue; + if (bSet) sector[iSector].ceilingxpan_ = (float)(lValue & 255); else SetGameVarID(lVar2, sector[iSector].ceilingxpan(), sActor, sPlayer); break; case SECTOR_CEILINGYPANNING: - if (bSet) sector[iSector].ceilingypan_ = lValue; + if (bSet) sector[iSector].ceilingypan_ = (float)(lValue & 255); else SetGameVarID(lVar2, sector[iSector].ceilingypan(), sActor, sPlayer); break; case SECTOR_FLOORPICNUM: @@ -1101,11 +1101,11 @@ void DoSector(char bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor, else SetGameVarID(lVar2, sector[iSector].floorpal, sActor, sPlayer); break; case SECTOR_FLOORXPANNING: - if (bSet) sector[iSector].floorxpan_ = lValue; + if (bSet) sector[iSector].floorxpan_ = (float)(lValue & 255); else SetGameVarID(lVar2, sector[iSector].floorxpan(), sActor, sPlayer); break; case SECTOR_FLOORYPANNING: - if (bSet) sector[iSector].floorypan_ = lValue; + if (bSet) sector[iSector].floorypan_ = (float)(lValue & 255); else SetGameVarID(lVar2, sector[iSector].floorypan(), sActor, sPlayer); break; case SECTOR_VISIBILITY: @@ -1698,7 +1698,7 @@ int ParseState::parse(void) ps[connecthead].max_actors_killed++; //revive the egg g_ac->temp_data[5] = 0; } - g_sp->pal = g_ac->tempang; + g_sp->pal = (uint8_t)g_ac->tempang; } g_ac->tempang = 0; break; @@ -2194,7 +2194,7 @@ int ParseState::parse(void) break; case concmd_clipdist: insptr++; - g_sp->clipdist = (short) *insptr; + g_sp->clipdist = (uint8_t) *insptr; insptr++; break; case concmd_cstat: @@ -2809,7 +2809,7 @@ int ParseState::parse(void) parseifelse( fi.floorspace(g_sp->sectnum)); break; case concmd_ifnotmoving: - parseifelse( (g_ac->movflag&kHitTypeMask) > kHitSprite ); + parseifelse( (g_ac->movflag&kHitTypeMask) > kHitSector ); break; case concmd_respawnhitag: insptr++; diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index 492dddf95..ee05dcc9a 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -30,7 +30,6 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "gamestate.h" #include "duke3d.h" -#include "sbar.h" #include "m_argv.h" #include "mapinfo.h" #include "texturemanager.h" diff --git a/source/games/duke/src/gamevar.cpp b/source/games/duke/src/gamevar.cpp index 56a5dfa99..68b73a236 100644 --- a/source/games/duke/src/gamevar.cpp +++ b/source/games/duke/src/gamevar.cpp @@ -122,10 +122,10 @@ int AddGameVar(const char* pszLabel, intptr_t lValue, unsigned dwFlags) if (aGameVars[i].dwFlags & GAMEVAR_FLAG_SYSTEM && !(dwFlags & (GAMEVAR_FLAG_PLONG | GAMEVAR_FLAG_PFUNC))) { // if existing is system, they only get to change default value.... - aGameVars[i].lValue = lValue; + aGameVars[i].lValue = (int)lValue; if (!(dwFlags & GAMEVAR_FLAG_NODEFAULT)) { - aGameVars[i].defaultValue = lValue; + aGameVars[i].defaultValue = (int)lValue; } } else @@ -138,11 +138,11 @@ int AddGameVar(const char* pszLabel, intptr_t lValue, unsigned dwFlags) } else { - aGameVars[i].lValue = lValue; + aGameVars[i].lValue = (int)lValue; } if (!(dwFlags & GAMEVAR_FLAG_NODEFAULT)) { - aGameVars[i].defaultValue = lValue; + aGameVars[i].defaultValue = (int)lValue; } } @@ -161,7 +161,7 @@ int AddGameVar(const char* pszLabel, intptr_t lValue, unsigned dwFlags) aGameVars[i].plArray.Resize(MAXPLAYERS); for (j = 0; j < MAXPLAYERS; j++) { - aGameVars[i].plArray[j] = lValue; + aGameVars[i].plArray[j] = (int)lValue; } } else if (aGameVars[i].dwFlags & GAMEVAR_FLAG_PERACTOR) @@ -169,7 +169,7 @@ int AddGameVar(const char* pszLabel, intptr_t lValue, unsigned dwFlags) aGameVars[i].plArray.Resize(MAXSPRITES); for (j = 0; j < MAXSPRITES; j++) { - aGameVars[i].plArray[j] = lValue; + aGameVars[i].plArray[j] = (int)lValue; } } return 1; diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index 8f7058736..b1b8ef20f 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -63,21 +63,20 @@ inline static void hud_drawpal(double x, double y, int tilenum, int shade, int o void displayloogie(player_struct* p) { - int i, a, y, z; + double a, y; + int z; double x; if (p->loogcnt == 0) return; y = (p->loogcnt << 2); - for (i = 0; i < p->numloogs; i++) + for (int i = 0; i < p->numloogs; i++) { - a = abs(bsinf((p->loogcnt + i) << 5, -5)); + a = fabs(bsinf((p->loogcnt + i) << 5, -5)); z = 4096 + ((p->loogcnt + i) << 9); x = -getavel(p->i) + bsinf((p->loogcnt + i) << 6, -10); - hud_drawsprite( - (p->loogiex[i] + x), (200 + p->loogiey[i] - y), z - (i << 8), 256 - a, - LOOGIE, 0, 0, 2); + hud_drawsprite((p->loogiex[i] + x), (200 + p->loogiey[i] - y), z - (i << 8), 256 - a, LOOGIE, 0, 0, 2); } } @@ -90,16 +89,16 @@ void displayloogie(player_struct* p) int animatefist(int gs, player_struct* p, double look_anghalf, double looking_arc, double plravel, int fistpal) { short fisti; - int fistzoom; + double fistzoom; double fistz; fisti = p->fist_incs; if (fisti > 32) fisti = 32; if (fisti <= 0) return 0; - fistzoom = 65536L - bcosf(fisti << 6, 2); - if (fistzoom > 90612L) - fistzoom = 90612L; + fistzoom = 65536 - bcosf(fisti << 6, 2); + if (fistzoom > 90612) + fistzoom = 90612; if (fistzoom < 40920) fistzoom = 40290; fistz = 194 + bsinf((6 + fisti) << 7, -9); @@ -107,7 +106,7 @@ int animatefist(int gs, player_struct* p, double look_anghalf, double looking_ar hud_drawsprite( (-fisti + 222 + plravel), (looking_arc + fistz), - fistzoom, 0, FIST, gs, fistpal, 2); + int(fistzoom), 0, FIST, gs, fistpal, 2); return 1; } @@ -323,12 +322,12 @@ void displayweapon_d(int snum, double smoothratio) looking_arc += 32 - (i >> 1); fistsign += i >> 1; } - cw = weapon_xoffset; + double owo = weapon_xoffset; weapon_xoffset += bsinf(fistsign, -10); hud_draw(weapon_xoffset + 250 - look_anghalf, looking_arc + 258 - fabs(bsinf(fistsign, -8)), FIST, shade, o); - weapon_xoffset = cw; + weapon_xoffset = owo; weapon_xoffset -= bsinf(fistsign, -10); hud_draw(weapon_xoffset + 40 - look_anghalf, looking_arc + 200 + fabs(bsinf(fistsign, -8)), diff --git a/source/games/duke/src/hudweapon_r.cpp b/source/games/duke/src/hudweapon_r.cpp index d04c09b18..6fd360121 100644 --- a/source/games/duke/src/hudweapon_r.cpp +++ b/source/games/duke/src/hudweapon_r.cpp @@ -298,10 +298,10 @@ void displayweapon_r(int snum, double smoothratio) looking_arc += 32 - (i >> 1); fistsign += i >> 1; } - cw = weapon_xoffset; + double owo = weapon_xoffset; weapon_xoffset += bsinf(fistsign, -10); hud_draw(weapon_xoffset + 250 - look_anghalf, looking_arc + 258 - abs(bsinf(fistsign, -8)), FIST, shade, o); - weapon_xoffset = cw; + weapon_xoffset = owo; weapon_xoffset -= bsinf(fistsign, -10); hud_draw(weapon_xoffset + 40 - look_anghalf, looking_arc + 200 + abs(bsinf(fistsign, -8)), FIST, shade, o | 4); } diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 3441e3bd2..3b048d17d 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -369,7 +369,7 @@ void hud_input(int plnum) { int j = gs.max_player_health - p->GetActor()->s->extra; - if ((unsigned int)p->firstaid_amount > j) + if (p->firstaid_amount > j) { p->firstaid_amount -= j; p->GetActor()->s->extra = gs.max_player_health; @@ -565,13 +565,13 @@ static double motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool if (kbdLeft || hidInput->mouseturnx < 0 || hidInput->dyaw < 0) { - p->TiltStatus -= factor; + p->TiltStatus -= (float)factor; if (p->TiltStatus < -10) p->TiltStatus = -10; } else if (kbdRight || hidInput->mouseturnx > 0 || hidInput->dyaw > 0) { - p->TiltStatus += factor; + p->TiltStatus += (float)factor; if (p->TiltStatus > 10) p->TiltStatus = 10; } @@ -586,7 +586,7 @@ static double motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool if (kbdLeft || p->moto_drink < 0 || hidInput->mouseturnx < 0 || hidInput->dyaw < 0) { updateTurnHeldAmt(factor); - p->TiltStatus -= factor; + p->TiltStatus -= (float)factor; if (p->TiltStatus < -10) p->TiltStatus = -10; @@ -604,7 +604,7 @@ static double motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool if (kbdRight || p->moto_drink > 0 || hidInput->mouseturnx > 0 || hidInput->dyaw > 0) { updateTurnHeldAmt(factor); - p->TiltStatus += factor; + p->TiltStatus += (float)factor; if (p->TiltStatus > 10) p->TiltStatus = 10; @@ -624,9 +624,9 @@ static double motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool resetTurnHeldAmt(); if (p->TiltStatus > 0) - p->TiltStatus -= factor; + p->TiltStatus -= (float)factor; else if (p->TiltStatus < 0) - p->TiltStatus += factor; + p->TiltStatus += (float)factor; } } @@ -660,7 +660,7 @@ static double boatApplyTurn(player_struct *p, ControlInfo* const hidInput, bool if (!p->NotOnWater) { - p->TiltStatus -= factor; + p->TiltStatus -= (float)factor; if (p->TiltStatus < -10) p->TiltStatus = -10; } @@ -681,7 +681,7 @@ static double boatApplyTurn(player_struct *p, ControlInfo* const hidInput, bool if (!p->NotOnWater) { - p->TiltStatus += factor; + p->TiltStatus += (float)factor; if (p->TiltStatus > 10) p->TiltStatus = 10; } @@ -701,9 +701,9 @@ static double boatApplyTurn(player_struct *p, ControlInfo* const hidInput, bool resetTurnHeldAmt(); if (p->TiltStatus > 0) - p->TiltStatus -= factor; + p->TiltStatus -= (float)factor; else if (p->TiltStatus < 0) - p->TiltStatus += factor; + p->TiltStatus += (float)factor; } } else if (!p->NotOnWater) @@ -711,9 +711,9 @@ static double boatApplyTurn(player_struct *p, ControlInfo* const hidInput, bool resetTurnHeldAmt(); if (p->TiltStatus > 0) - p->TiltStatus -= factor; + p->TiltStatus -= (float)factor; else if (p->TiltStatus < 0) - p->TiltStatus += factor; + p->TiltStatus += (float)factor; } if (fabs(p->TiltStatus) < factor) @@ -744,12 +744,12 @@ static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, I if (p->OnMotorcycle) { - input.avel = motoApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust); + input.avel = (float)motoApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust); if (p->moto_underwater) p->MotoSpeed = 0; } else { - input.avel = boatApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust); + input.avel = (float)boatApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust); } loc.fvel = clamp(xs_CRoundToInt(p->MotoSpeed), -(MAXVELMOTO >> 3), MAXVELMOTO); diff --git a/source/games/duke/src/namelist_d.h b/source/games/duke/src/namelist_d.h index d05332000..d62867483 100644 --- a/source/games/duke/src/namelist_d.h +++ b/source/games/duke/src/namelist_d.h @@ -13,6 +13,7 @@ x(AMMOBOX, 31) x(GROWSPRITEICON, 32) x(INVENTORYBOX, 33) x(FREEZEAMMO, 37) +x(FREEZEAMMO1, 38) x(AMMO, 40) x(BATTERYAMMO, 41) x(DEVISTATORAMMO, 42) @@ -571,6 +572,16 @@ x(BIGFNTCURSOR, 2820) x(SMALLFNTCURSOR, 2821) x(STARTALPHANUM, 2822) x(ENDALPHANUM, 2915) +x(BIGALPHANUM0, 2930) +x(BIGALPHANUM1, 2931) +x(BIGALPHANUM2, 2932) +x(BIGALPHANUM3, 2933) +x(BIGALPHANUM4, 2934) +x(BIGALPHANUM5, 2935) +x(BIGALPHANUM6, 2936) +x(BIGALPHANUM7, 2937) +x(BIGALPHANUM8, 2938) +x(BIGALPHANUM9, 2939) x(BIGALPHANUM, 2940) x(BIGPERIOD, 3002) x(BIGCOMMA, 3003) @@ -578,7 +589,18 @@ x(BIGX, 3004) x(BIGQ, 3005) x(BIGSEMI, 3006) x(BIGCOLIN, 3007) -x(THREEBYFIVE, 3010) +x(THREEBYFIVE0, 3010) +x(THREEBYFIVE1, 3011) +x(THREEBYFIVE2, 3012) +x(THREEBYFIVE3, 3013) +x(THREEBYFIVE4, 3014) +x(THREEBYFIVE5, 3015) +x(THREEBYFIVE6, 3016) +x(THREEBYFIVE7, 3017) +x(THREEBYFIVE8, 3018) +x(THREEBYFIVE9, 3019) +x(THREEBYFIVE10, 3020) +x(THREEBYFIVE11, 3021) x(BIGAPPOS, 3022) x(BLANK, 3026) x(MINIFONT, 3072) @@ -766,6 +788,7 @@ x(WTGLASS1, 5736) x(WTGLASS2, 5737) x(FLAMETHROWERSPRITE, 5134) x(FLAMETHROWERAMMO, 5135) +x(FLAMETHROWERAMMO1, 5136) x(FLAMETHROWER, 5138) x(ONFIRE, 5152) x(LAVAPOOL, 5304) diff --git a/source/games/duke/src/namelist_r.h b/source/games/duke/src/namelist_r.h index 46696dd5e..ecc5e6a5d 100644 --- a/source/games/duke/src/namelist_r.h +++ b/source/games/duke/src/namelist_r.h @@ -35,13 +35,13 @@ x(CRYSTALAMMO, 46) x(HBOMBAMMO, 47) x(AMMOLOTS, 48) x(SHOTGUNAMMO, 49) -x(COLA, 51) +x(BEER, 51) x(SIXPAK, 52) x(FIRSTAID, 53) x(SHIELD, 54) x(STEROIDS, 55) x(AIRTANK, 56) -x(JETPACK, 57) +x(COWPIE, 57) x(HEATSENSOR, 59) x(ACCESSCARD, 60) x(BOOTS, 61) @@ -229,7 +229,17 @@ x(GUTMETER_LIGHT1, 920) x(GUTMETER_LIGHT2, 921) x(GUTMETER_LIGHT3, 922) x(GUTMETER_LIGHT4, 923) -x(AMMO_ICON, 930) +x(AMMO_ICON0, 930) +x(AMMO_ICON1, 931) +x(AMMO_ICON2, 932) +x(AMMO_ICON3, 933) +x(AMMO_ICON4, 934) +x(AMMO_ICON5, 935) +x(AMMO_ICON6, 936) +x(AMMO_ICON7, 937) +x(AMMO_ICON8, 938) +x(AMMO_ICON9, 939) +x(AMMO_ICON10, 940) x(CLOUDYSKIES, 1021) x(MOONSKY1, 1022) x(MOONSKY2, 1023) diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index bcbc0b057..f8a149aeb 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -37,6 +37,7 @@ source as it is released. #include "global.h" #include "mapinfo.h" #include "dukeactor.h" +#include "vm.h" BEGIN_DUKE_NS @@ -521,7 +522,7 @@ void footprints(int snum) default: fprint = spawn(actor, TILE_FOOTPRINTS4); break; } fprint->s->pal = p->footprintpal; - fprint->s->shade = p->footprintshade; + fprint->s->shade = (int8_t)p->footprintshade; } } } @@ -1064,4 +1065,203 @@ void shootbloodsplat(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, i } } + +DEFINE_FIELD_X(DukePlayer, player_struct, gotweapon) +DEFINE_FIELD_X(DukePlayer, player_struct, pals) +DEFINE_FIELD_X(DukePlayer, player_struct, weapon_sway) +DEFINE_FIELD_X(DukePlayer, player_struct, oweapon_sway) +DEFINE_FIELD_X(DukePlayer, player_struct, weapon_pos) +DEFINE_FIELD_X(DukePlayer, player_struct, kickback_pic) +DEFINE_FIELD_X(DukePlayer, player_struct, random_club_frame) +DEFINE_FIELD_X(DukePlayer, player_struct, oweapon_pos) +DEFINE_FIELD_X(DukePlayer, player_struct, okickback_pic) +DEFINE_FIELD_X(DukePlayer, player_struct, orandom_club_frame) +DEFINE_FIELD_X(DukePlayer, player_struct, hard_landing) +DEFINE_FIELD_X(DukePlayer, player_struct, ohard_landing) +DEFINE_FIELD_X(DukePlayer, player_struct, psectlotag) +DEFINE_FIELD_X(DukePlayer, player_struct, exitx) +DEFINE_FIELD_X(DukePlayer, player_struct, exity) +DEFINE_FIELD_X(DukePlayer, player_struct, loogiex) +DEFINE_FIELD_X(DukePlayer, player_struct, loogiey) +DEFINE_FIELD_X(DukePlayer, player_struct, numloogs) +DEFINE_FIELD_X(DukePlayer, player_struct, loogcnt) +DEFINE_FIELD_X(DukePlayer, player_struct, invdisptime) +DEFINE_FIELD_X(DukePlayer, player_struct, bobposx) +DEFINE_FIELD_X(DukePlayer, player_struct, bobposy) +DEFINE_FIELD_X(DukePlayer, player_struct, oposx) +DEFINE_FIELD_X(DukePlayer, player_struct, oposy) +DEFINE_FIELD_X(DukePlayer, player_struct, oposz) +DEFINE_FIELD_X(DukePlayer, player_struct, pyoff) +DEFINE_FIELD_X(DukePlayer, player_struct, opyoff) +DEFINE_FIELD_X(DukePlayer, player_struct, posxv) +DEFINE_FIELD_X(DukePlayer, player_struct, posyv) +DEFINE_FIELD_X(DukePlayer, player_struct, poszv) +DEFINE_FIELD_X(DukePlayer, player_struct, last_pissed_time) +DEFINE_FIELD_X(DukePlayer, player_struct, truefz) +DEFINE_FIELD_X(DukePlayer, player_struct, truecz) +DEFINE_FIELD_X(DukePlayer, player_struct, player_par) +DEFINE_FIELD_X(DukePlayer, player_struct, visibility) +DEFINE_FIELD_X(DukePlayer, player_struct, bobcounter) +DEFINE_FIELD_X(DukePlayer, player_struct, randomflamex) +DEFINE_FIELD_X(DukePlayer, player_struct, crack_time) +DEFINE_FIELD_X(DukePlayer, player_struct, aim_mode) +DEFINE_FIELD_X(DukePlayer, player_struct, ftt) +DEFINE_FIELD_X(DukePlayer, player_struct, cursectnum) +DEFINE_FIELD_X(DukePlayer, player_struct, last_extra) +DEFINE_FIELD_X(DukePlayer, player_struct, subweapon) +DEFINE_FIELD_X(DukePlayer, player_struct, ammo_amount) +DEFINE_FIELD_X(DukePlayer, player_struct, frag) +DEFINE_FIELD_X(DukePlayer, player_struct, fraggedself) +DEFINE_FIELD_X(DukePlayer, player_struct, curr_weapon) +DEFINE_FIELD_X(DukePlayer, player_struct, last_weapon) +DEFINE_FIELD_X(DukePlayer, player_struct, tipincs) +DEFINE_FIELD_X(DukePlayer, player_struct, wantweaponfire) +DEFINE_FIELD_X(DukePlayer, player_struct, holoduke_amount) +DEFINE_FIELD_X(DukePlayer, player_struct, hurt_delay) +DEFINE_FIELD_X(DukePlayer, player_struct, hbomb_hold_delay) +DEFINE_FIELD_X(DukePlayer, player_struct, jumping_counter) +DEFINE_FIELD_X(DukePlayer, player_struct, airleft) +DEFINE_FIELD_X(DukePlayer, player_struct, knee_incs) +DEFINE_FIELD_X(DukePlayer, player_struct, access_incs) +DEFINE_FIELD_X(DukePlayer, player_struct, ftq) +DEFINE_FIELD_X(DukePlayer, player_struct, access_wallnum) +DEFINE_FIELD_X(DukePlayer, player_struct, got_access) +DEFINE_FIELD_X(DukePlayer, player_struct, weapon_ang) +DEFINE_FIELD_X(DukePlayer, player_struct, firstaid_amount) +DEFINE_FIELD_X(DukePlayer, player_struct, i) +DEFINE_FIELD_X(DukePlayer, player_struct, one_parallax_sectnum) +DEFINE_FIELD_X(DukePlayer, player_struct, over_shoulder_on) +DEFINE_FIELD_X(DukePlayer, player_struct, fist_incs) +DEFINE_FIELD_X(DukePlayer, player_struct, cheat_phase) +DEFINE_FIELD_X(DukePlayer, player_struct, extra_extra8) +DEFINE_FIELD_X(DukePlayer, player_struct, quick_kick) +DEFINE_FIELD_X(DukePlayer, player_struct, last_quick_kick) +DEFINE_FIELD_X(DukePlayer, player_struct, heat_amount) +DEFINE_FIELD_X(DukePlayer, player_struct, timebeforeexit) +DEFINE_FIELD_X(DukePlayer, player_struct, customexitsound) +DEFINE_FIELD_X(DukePlayer, player_struct, weaprecs) +DEFINE_FIELD_X(DukePlayer, player_struct, weapreccnt) +DEFINE_FIELD_X(DukePlayer, player_struct, interface_toggle_flag) +DEFINE_FIELD_X(DukePlayer, player_struct, dead_flag) +DEFINE_FIELD_X(DukePlayer, player_struct, show_empty_weapon) +DEFINE_FIELD_X(DukePlayer, player_struct, scuba_amount) +DEFINE_FIELD_X(DukePlayer, player_struct, jetpack_amount) +DEFINE_FIELD_X(DukePlayer, player_struct, steroids_amount) +DEFINE_FIELD_X(DukePlayer, player_struct, shield_amount) +DEFINE_FIELD_X(DukePlayer, player_struct, pycount) +DEFINE_FIELD_X(DukePlayer, player_struct, frag_ps) +DEFINE_FIELD_X(DukePlayer, player_struct, transporter_hold) +DEFINE_FIELD_X(DukePlayer, player_struct, last_full_weapon) +DEFINE_FIELD_X(DukePlayer, player_struct, footprintshade) +DEFINE_FIELD_X(DukePlayer, player_struct, boot_amount) +DEFINE_FIELD_X(DukePlayer, player_struct, on_warping_sector) +DEFINE_FIELD_X(DukePlayer, player_struct, footprintcount) +DEFINE_FIELD_X(DukePlayer, player_struct, hbomb_on) +DEFINE_FIELD_X(DukePlayer, player_struct, jumping_toggle) +DEFINE_FIELD_X(DukePlayer, player_struct, rapid_fire_hold) +DEFINE_FIELD_X(DukePlayer, player_struct, on_ground) +DEFINE_FIELD_X(DukePlayer, player_struct, inven_icon) +DEFINE_FIELD_X(DukePlayer, player_struct, buttonpalette) +DEFINE_FIELD_X(DukePlayer, player_struct, jetpack_on) +DEFINE_FIELD_X(DukePlayer, player_struct, spritebridge) +DEFINE_FIELD_X(DukePlayer, player_struct, lastrandomspot) +DEFINE_FIELD_X(DukePlayer, player_struct, scuba_on) +DEFINE_FIELD_X(DukePlayer, player_struct, footprintpal) +DEFINE_FIELD_X(DukePlayer, player_struct, heat_on) +DEFINE_FIELD_X(DukePlayer, player_struct, holster_weapon) +DEFINE_FIELD_X(DukePlayer, player_struct, falling_counter) +DEFINE_FIELD_X(DukePlayer, player_struct, refresh_inventory) +DEFINE_FIELD_X(DukePlayer, player_struct, toggle_key_flag) +DEFINE_FIELD_X(DukePlayer, player_struct, knuckle_incs) +DEFINE_FIELD_X(DukePlayer, player_struct, walking_snd_toggle) +DEFINE_FIELD_X(DukePlayer, player_struct, palookup) +DEFINE_FIELD_X(DukePlayer, player_struct, quick_kick_msg) +DEFINE_FIELD_X(DukePlayer, player_struct, max_secret_rooms) +DEFINE_FIELD_X(DukePlayer, player_struct, secret_rooms) +DEFINE_FIELD_X(DukePlayer, player_struct, max_actors_killed) +DEFINE_FIELD_X(DukePlayer, player_struct, actors_killed) +DEFINE_FIELD_X(DukePlayer, player_struct, resurrected) +DEFINE_FIELD_X(DukePlayer, player_struct, stairs) +DEFINE_FIELD_X(DukePlayer, player_struct, detonate_count) +DEFINE_FIELD_X(DukePlayer, player_struct, noise_x) +DEFINE_FIELD_X(DukePlayer, player_struct, noise_y) +DEFINE_FIELD_X(DukePlayer, player_struct, noise_radius) +DEFINE_FIELD_X(DukePlayer, player_struct, drink_timer) +DEFINE_FIELD_X(DukePlayer, player_struct, eat_timer) +DEFINE_FIELD_X(DukePlayer, player_struct, SlotWin) +DEFINE_FIELD_X(DukePlayer, player_struct, recoil) +DEFINE_FIELD_X(DukePlayer, player_struct, detonate_time) +DEFINE_FIELD_X(DukePlayer, player_struct, yehaa_timer) +DEFINE_FIELD_X(DukePlayer, player_struct, drink_amt) +DEFINE_FIELD_X(DukePlayer, player_struct, eat) +DEFINE_FIELD_X(DukePlayer, player_struct, drunkang) +DEFINE_FIELD_X(DukePlayer, player_struct, eatang) +DEFINE_FIELD_X(DukePlayer, player_struct, shotgun_state) +DEFINE_FIELD_X(DukePlayer, player_struct, donoise) +DEFINE_FIELD_X(DukePlayer, player_struct, keys) +DEFINE_FIELD_X(DukePlayer, player_struct, drug_aspect) +DEFINE_FIELD_X(DukePlayer, player_struct, drug_timer) +DEFINE_FIELD_X(DukePlayer, player_struct, SeaSick) +DEFINE_FIELD_X(DukePlayer, player_struct, MamaEnd) +DEFINE_FIELD_X(DukePlayer, player_struct, moto_drink) +DEFINE_FIELD_X(DukePlayer, player_struct, TiltStatus) +DEFINE_FIELD_X(DukePlayer, player_struct, oTiltStatus) +DEFINE_FIELD_X(DukePlayer, player_struct, VBumpNow) +DEFINE_FIELD_X(DukePlayer, player_struct, VBumpTarget) +DEFINE_FIELD_X(DukePlayer, player_struct, TurbCount) +DEFINE_FIELD_X(DukePlayer, player_struct, drug_stat) +DEFINE_FIELD_X(DukePlayer, player_struct, DrugMode) +DEFINE_FIELD_X(DukePlayer, player_struct, lotag800kill) +DEFINE_FIELD_X(DukePlayer, player_struct, sea_sick_stat) +DEFINE_FIELD_X(DukePlayer, player_struct, hurt_delay2) +DEFINE_FIELD_X(DukePlayer, player_struct, nocheat) +DEFINE_FIELD_X(DukePlayer, player_struct, OnMotorcycle) +DEFINE_FIELD_X(DukePlayer, player_struct, OnBoat) +DEFINE_FIELD_X(DukePlayer, player_struct, moto_underwater) +DEFINE_FIELD_X(DukePlayer, player_struct, NotOnWater) +DEFINE_FIELD_X(DukePlayer, player_struct, MotoOnGround) +DEFINE_FIELD_X(DukePlayer, player_struct, moto_do_bump) +DEFINE_FIELD_X(DukePlayer, player_struct, moto_bump_fast) +DEFINE_FIELD_X(DukePlayer, player_struct, moto_on_oil) +DEFINE_FIELD_X(DukePlayer, player_struct, moto_on_mud) +DEFINE_FIELD_X(DukePlayer, player_struct, vehForwardScale) +DEFINE_FIELD_X(DukePlayer, player_struct, vehReverseScale) +DEFINE_FIELD_X(DukePlayer, player_struct, MotoSpeed) +DEFINE_FIELD_X(DukePlayer, player_struct, vehTurnLeft) +DEFINE_FIELD_X(DukePlayer, player_struct, vehTurnRight) +DEFINE_FIELD_X(DukePlayer, player_struct, vehBraking) +DEFINE_FIELD_X(DukePlayer, player_struct, holoduke_on) + +DEFINE_ACTION_FUNCTION(_DukePlayer, IsFrozen) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + ACTION_RETURN_BOOL(self->GetActor()->s->pal == 1 && self->last_extra < 2); +} + +DEFINE_ACTION_FUNCTION(_DukePlayer, GetGameVar) +{ + PARAM_SELF_STRUCT_PROLOGUE(player_struct); + PARAM_STRING(name); + PARAM_INT(def); + ACTION_RETURN_INT(GetGameVar(name, def, self->GetActor(), self->GetPlayerNum())); +} + +DEFINE_ACTION_FUNCTION(_Duke, GetViewPlayer) +{ + ACTION_RETURN_POINTER(&ps[screenpeek]); +} + +DEFINE_ACTION_FUNCTION(_Duke, MaxPlayerHealth) +{ + ACTION_RETURN_INT(gs.max_player_health); +} + +DEFINE_ACTION_FUNCTION(_Duke, MaxAmmoAmount) +{ + PARAM_PROLOGUE; + PARAM_INT(weap); + int max = weap < 0 || weap >= MAX_WEAPONS ? 0 : gs.max_ammo_amount[weap]; + ACTION_RETURN_INT(max); +} + END_DUKE_NS diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 856703d6d..7103dceaa 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -762,9 +762,9 @@ static void shootrpg(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, i if (isWorldTour()) // Twentieth Anniversary World Tour { float siz = actor->s->yrepeat / 80.0f; - xoffs *= siz; - yoffs *= siz; - aoffs *= siz; + xoffs = int(xoffs * siz); + yoffs = int(yoffs * siz); + aoffs = int(aoffs * siz); } spj->x += xoffs; @@ -1315,7 +1315,7 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum { if (act->s->picnum == HEAVYHBOMB && act->GetOwner() == p->GetActor()) { - p->gotweapon.Set(HANDBOMB_WEAPON); + p->gotweapon[HANDBOMB_WEAPON] = true; j = HANDREMOTE_WEAPON; break; } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 0c2befe90..378488dc4 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -65,16 +65,11 @@ void incur_damage_r(struct player_struct* p) switch (gut) { - double ddamage; case 1: - ddamage = damage; - ddamage *= 0.75; - damage = ddamage; + damage = damage * 3 / 4; break; case 2: - ddamage = damage; - ddamage *= 0.25; - damage = ddamage; + damage /= 4; break; } @@ -1087,7 +1082,7 @@ void selectweapon_r(int snum, int weap) { if (act->s->picnum == HEAVYHBOMB && act->GetOwner() == p->GetActor()) { - p->gotweapon.Set(DYNAMITE_WEAPON); + p->gotweapon[DYNAMITE_WEAPON] = true; j = THROWINGDYNAMITE_WEAPON; break; } @@ -1504,7 +1499,7 @@ void checkweapons_r(struct player_struct* p) j->s->ang = p->angle.ang.asbuild(); j->saved_ammo = p->ammo_amount[MOTORCYCLE_WEAPON]; p->OnMotorcycle = 0; - p->gotweapon.Clear(MOTORCYCLE_WEAPON); + p->gotweapon[MOTORCYCLE_WEAPON] = false; p->horizon.horiz = q16horiz(0); p->moto_do_bump = 0; p->MotoSpeed = 0; @@ -1520,7 +1515,7 @@ void checkweapons_r(struct player_struct* p) j->s->ang = p->angle.ang.asbuild(); j->saved_ammo = p->ammo_amount[BOAT_WEAPON]; p->OnBoat = 0; - p->gotweapon.Clear(BOAT_WEAPON); + p->gotweapon[BOAT_WEAPON] = false; p->horizon.horiz = q16horiz(0); p->moto_do_bump = 0; p->MotoSpeed = 0; @@ -1695,7 +1690,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) if (p->MotoSpeed != 0 && p->on_ground == 1) { if (!p->VBumpNow && (krand() & 3) == 2) - p->VBumpTarget = (p->MotoSpeed / 16.) * ((krand() & 7) - 4); + p->VBumpTarget = short((p->MotoSpeed / 16.) * ((krand() & 7) - 4)); if (p->vehTurnLeft || p->moto_drink < 0) { @@ -1750,7 +1745,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) p->horizon.addadjustment(horiz - FixedToFloat(p->horizon.horiz.asq16())); } - int currSpeed = p->MotoSpeed; + int currSpeed = int(p->MotoSpeed); short velAdjustment; if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight)) { @@ -1965,7 +1960,7 @@ static void onBoat(int snum, ESyncBits &actions) if (p->MotoSpeed != 0 && p->on_ground == 1) { if (!p->VBumpNow && (krand() & 15) == 14) - p->VBumpTarget = (p->MotoSpeed / 16.) * ((krand() & 3) - 2); + p->VBumpTarget = short((p->MotoSpeed / 16.) * ((krand() & 3) - 2)); if (p->vehTurnLeft && p->moto_drink < 0) { @@ -2020,7 +2015,7 @@ static void onBoat(int snum, ESyncBits &actions) if (p->MotoSpeed > 0 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight)) { - int currSpeed = p->MotoSpeed * 4.; + int currSpeed = int(p->MotoSpeed * 4.); short velAdjustment = p->vehTurnLeft ? -10 : 10; auto angAdjustment = (velAdjustment < 0 ? 350 : -350) << BAMBITS; @@ -2128,7 +2123,7 @@ static void movement(int snum, ESyncBits actions, int psect, int fz, int cz, int } else { - p->poszv += gs.gravity - 80 + (120 - p->MotoSpeed); + p->poszv += gs.gravity - 80 + int(120 - p->MotoSpeed); if (!S_CheckActorSoundPlaying(pact, 189) && !S_CheckActorSoundPlaying(pact, 190)) S_PlayActorSound(190, pact); } @@ -2464,8 +2459,8 @@ void onMotorcycleHit(int snum, DDukeActor* victim) if (numplayers == 1) { Collision coll; - movesprite_ex(victim, bcos(p->TiltStatus * 20 + p->angle.ang.asbuild(), -8), - bsin(p->TiltStatus * 20 + p->angle.ang.asbuild(), -8), s->zvel, CLIPMASK0, coll); + int ang = int(p->TiltStatus * 20 + p->angle.ang.asbuild()); + movesprite_ex(victim, bcos(ang, -8), bsin(ang, -8), s->zvel, CLIPMASK0, coll); } } else @@ -2526,8 +2521,8 @@ void onBoatHit(int snum, DDukeActor* victim) if (numplayers == 1) { Collision coll; - movesprite_ex(victim, bcos(p->TiltStatus * 20 + p->angle.ang.asbuild(), -9), - bsin(p->TiltStatus * 20 + p->angle.ang.asbuild(), -9), s->zvel, CLIPMASK0, coll); + int ang = int(p->TiltStatus * 20 + p->angle.ang.asbuild()); + movesprite_ex(victim, bcos(ang, -9), bsin(ang, -9), s->zvel, CLIPMASK0, coll); } } else @@ -3137,7 +3132,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect) if (p->kickback_pic == 3) { p->ammo_amount[POWDERKEG_WEAPON]--; - p->gotweapon.Clear(POWDERKEG_WEAPON); + p->gotweapon[POWDERKEG_WEAPON] = false; if (p->on_ground && (actions & SB_CROUCH) && !p->OnMotorcycle) { k = 15; @@ -3181,7 +3176,7 @@ static void operateweapon(int snum, ESyncBits actions, int psect) if (p->kickback_pic > 40) { p->okickback_pic = p->kickback_pic = 0; - p->gotweapon.Clear(BOWLING_WEAPON); + p->gotweapon[BOWLING_WEAPON] = false; checkavailweapon(p); } break; @@ -4062,7 +4057,7 @@ void OnMotorcycle(struct player_struct *p, DDukeActor* motosprite) p->OnMotorcycle = 1; p->last_full_weapon = p->curr_weapon; p->curr_weapon = MOTORCYCLE_WEAPON; - p->gotweapon.Set(MOTORCYCLE_WEAPON); + p->gotweapon[MOTORCYCLE_WEAPON] = true; p->posxv = 0; p->posyv = 0; p->horizon.horiz = q16horiz(0); @@ -4093,7 +4088,7 @@ void OffMotorcycle(struct player_struct *p) if (!S_CheckActorSoundPlaying(pact,42)) S_PlayActorSound(42, pact); p->OnMotorcycle = 0; - p->gotweapon.Clear(MOTORCYCLE_WEAPON); + p->gotweapon[MOTORCYCLE_WEAPON] = false; p->curr_weapon = p->last_full_weapon; checkavailweapon(p); p->horizon.horiz = q16horiz(0); @@ -4139,7 +4134,7 @@ void OnBoat(struct player_struct *p, DDukeActor* boat) p->OnBoat = 1; p->last_full_weapon = p->curr_weapon; p->curr_weapon = BOAT_WEAPON; - p->gotweapon.Set(BOAT_WEAPON); + p->gotweapon[BOAT_WEAPON] = true; p->posxv = 0; p->posyv = 0; p->horizon.horiz = q16horiz(0); @@ -4157,7 +4152,7 @@ void OffBoat(struct player_struct *p) if (p->OnBoat) { p->OnBoat = 0; - p->gotweapon.Clear(BOAT_WEAPON); + p->gotweapon[BOAT_WEAPON] = false; p->curr_weapon = p->last_full_weapon; checkavailweapon(p); p->horizon.horiz = q16horiz(0); diff --git a/source/games/duke/src/prediction.cpp b/source/games/duke/src/prediction.cpp index 61c03059a..799ed9aa8 100644 --- a/source/games/duke/src/prediction.cpp +++ b/source/games/duke/src/prediction.cpp @@ -29,7 +29,6 @@ Modifications for JonoF's port by Jonathon Fowler (jf@jonof.id.au) #include "ns.h" // Must come before everything else! #include "duke3d.h" -#include "sbar.h" #include "m_argv.h" #include "mapinfo.h" #include "texturemanager.h" diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index d3ff8350c..2f9dbef2e 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -32,7 +32,6 @@ Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms #include "secrets.h" #include "statistics.h" #include "gamestate.h" -#include "sbar.h" #include "automap.h" #include "dukeactor.h" #include "interpolate.h" @@ -208,7 +207,7 @@ void resetplayerstats(int snum) if (p->OnMotorcycle) { p->OnMotorcycle = 0; - p->gotweapon.Clear(MOTORCYCLE_WEAPON); + p->gotweapon[MOTORCYCLE_WEAPON] = false; p->curr_weapon = isRRRA()? SLINGBLADE_WEAPON : KNEE_WEAPON; // just in case this is made available for the other games } p->lotag800kill = 0; @@ -227,7 +226,7 @@ void resetplayerstats(int snum) if (p->OnBoat) { p->OnBoat = 0; - p->gotweapon.Clear(BOAT_WEAPON); + p->gotweapon[BOAT_WEAPON] = false; p->curr_weapon = isRRRA()? SLINGBLADE_WEAPON : KNEE_WEAPON; // just in case this is made available for the other games } p->NotOnWater = 0; @@ -272,14 +271,14 @@ void resetweapons(int snum) p->ammo_amount[weapon] = 0; } - p->gotweapon.Zero(); + memset(p->gotweapon, 0, MAX_WEAPONS); p->oweapon_pos = p->weapon_pos = 6; p->okickback_pic = p->kickback_pic = 5; p->curr_weapon = PISTOL_WEAPON; - p->gotweapon.Set(PISTOL_WEAPON); - p->gotweapon.Set(KNEE_WEAPON); + p->gotweapon[PISTOL_WEAPON] = true; + p->gotweapon[KNEE_WEAPON] = true; p->ammo_amount[PISTOL_WEAPON] = std::min(gs.max_ammo_amount[PISTOL_WEAPON], 48); - p->gotweapon.Set(HANDREMOTE_WEAPON); + p->gotweapon[HANDREMOTE_WEAPON] = true; p->last_weapon = -1; p->show_empty_weapon= 0; @@ -296,7 +295,7 @@ void resetweapons(int snum) { chickenphase = 0; p->ammo_amount[KNEE_WEAPON] = 1; - p->gotweapon.Set(SLINGBLADE_WEAPON); + p->gotweapon[SLINGBLADE_WEAPON] = true; p->ammo_amount[SLINGBLADE_WEAPON] = 1; } OnEvent(EVENT_RESETWEAPONS, snum, nullptr, -1); @@ -518,7 +517,7 @@ void resetpspritevars(int g) for (j = 0; j < MAX_WEAPONS; j++) { tsbar[i].ammo_amount[j] = ps[i].ammo_amount[j]; - tsbar[i].gotweapon.Set(j, ps[i].gotweapon[j]); + tsbar[i].gotweapon[j] = ps[i].gotweapon[j]; } tsbar[i].shield_amount = ps[i].shield_amount; @@ -548,7 +547,7 @@ void resetpspritevars(int g) for (j = 0; j < MAX_WEAPONS; j++) { ps[i].ammo_amount[j] = tsbar[i].ammo_amount[j]; - ps[i].gotweapon.Set(j, tsbar[i].gotweapon[j]); + ps[i].gotweapon[j] = tsbar[i].gotweapon[j]; } ps[i].shield_amount = tsbar[i].shield_amount; ps[i].curr_weapon = tsbar[i].curr_weapon; @@ -772,22 +771,22 @@ void donewgame(MapRecord* map, int sk) if (aplWeaponWorksLike[i][0] == PISTOL_WEAPON) { p->curr_weapon = i; - p->gotweapon.Set(i); + p->gotweapon[i] = true; p->ammo_amount[i] = 48; } else if (aplWeaponWorksLike[i][0] == KNEE_WEAPON || aplWeaponWorksLike[i][0] == HANDREMOTE_WEAPON) { - p->gotweapon.Set(i); + p->gotweapon[i] = true; } } } else { p->curr_weapon = PISTOL_WEAPON; - p->gotweapon.Set(PISTOL_WEAPON); - p->gotweapon.Set(KNEE_WEAPON); + p->gotweapon[PISTOL_WEAPON] = true; + p->gotweapon[KNEE_WEAPON] = true; p->ammo_amount[PISTOL_WEAPON] = 48; - p->gotweapon.Set(HANDREMOTE_WEAPON); + p->gotweapon[HANDREMOTE_WEAPON] = true; p->last_weapon = -1; } @@ -1031,7 +1030,7 @@ void enterlevel(MapRecord *mi, int gamemode) if (clearweapon) { resetweapons(i); - ps[i].gotweapon.Clear(PISTOL_WEAPON); + ps[i].gotweapon[PISTOL_WEAPON] = false; ps[i].ammo_amount[PISTOL_WEAPON] = 0; ps[i].curr_weapon = KNEE_WEAPON; ps[i].kickback_pic = 0; @@ -1086,12 +1085,12 @@ void GameInterface::NewGame(MapRecord* map, int skill, bool) ud.multimode = 1; donewgame(map, skill); - enterlevel(map, 0); + enterlevel(map, 0); if (isShareware() && ud.recstat != 2) FTA(QUOTE_F1HELP, &ps[myconnectindex]); - PlayerColorChanged(); - inputState.ClearAllInput(); - gameaction = ga_level; + PlayerColorChanged(); + inputState.ClearAllInput(); + gameaction = ga_level; } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index cb86ffc62..4d25e99bc 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -658,7 +658,7 @@ void prelevel_r(int g) deletesprite(i); if (spr->picnum == RRTILE34) { - sectorextra[spr->sectnum] = spr->lotag; + sectorextra[spr->sectnum] = uint8_t(spr->lotag); deletesprite(i); } } diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index 71561d80f..b3f170c86 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -73,7 +73,7 @@ void renderView(spritetype* playersprite, int sectnum, int x, int y, int z, bina if (!testnewrenderer) { // do screen rotation. - renderSetRollAngle(rotscrnang.asbuildf()); + renderSetRollAngle((float)rotscrnang.asbuildf()); se40code(x, y, z, a, h, smoothratio); renderMirror(x, y, z, a, h, smoothratio); @@ -108,7 +108,7 @@ void GameInterface::UpdateCameras(double smoothratio) if (camsprite->GetOwner() && dist(p->GetActor(), camsprite) < VIEWSCREEN_ACTIVE_DISTANCE) { auto tex = tileGetTexture(sp->picnum); - TileFiles.MakeCanvas(TILE_VIEWSCR, tex->GetDisplayWidth(), tex->GetDisplayHeight()); + TileFiles.MakeCanvas(TILE_VIEWSCR, (int)tex->GetDisplayWidth(), (int)tex->GetDisplayHeight()); auto canvas = renderSetTarget(TILE_VIEWSCR); if (!canvas) return; @@ -122,7 +122,7 @@ void GameInterface::UpdateCameras(double smoothratio) { // Note: no ROR or camera here - Polymost has no means to detect these things before rendering the scene itself. renderDrawRoomsQ16(camera->x, camera->y, camera->z, ang.asq16(), IntToFixed(camera->shade), camera->sectnum); // why 'shade'...? - fi.animatesprites(pm_tsprite, pm_spritesortcnt, camera->x, camera->y, ang.asbuild(), smoothratio); + fi.animatesprites(pm_tsprite, pm_spritesortcnt, camera->x, camera->y, ang.asbuild(), (int)smoothratio); renderDrawMasks(); } else @@ -299,7 +299,7 @@ void displayrooms(int snum, double smoothratio) cang = buildang(interpolatedangle(ud.cameraactor->tempang, s->ang, smoothratio)); auto bh = buildhoriz(s->yvel); - renderView(s, s->sectnum, s->x, s->y, s->z - (4 << 8), cang, bh, buildang(0), smoothratio); + renderView(s, s->sectnum, s->x, s->y, s->z - (4 << 8), cang, bh, buildang(0), (int)smoothratio); } else { @@ -410,12 +410,12 @@ void displayrooms(int snum, double smoothratio) if (isRR() && sector[sect].lotag == 848 && !testnewrenderer) { - renderSetRollAngle(rotscrnang.asbuildf()); - geometryEffect(cposx, cposy, cposz, cang, choriz, sect, smoothratio); + renderSetRollAngle((float)rotscrnang.asbuildf()); + geometryEffect(cposx, cposy, cposz, cang, choriz, sect, (int)smoothratio); } else { - renderView(viewer, sect, cposx, cposy, cposz, cang, choriz, rotscrnang, smoothratio); + renderView(viewer, sect, cposx, cposy, cposz, cang, choriz, rotscrnang, (int)smoothratio); } } //GLInterface.SetMapFog(false); diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index e810c25dc..3f5cf3ae2 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -89,7 +89,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w, ("posz", w.posz) ("angle", w.angle) ("horizon", w.horizon) - ("gotweapon", w.gotweapon) + .Array("gotweapon", w.gotweapon, MAX_WEAPONS) ("pals", w.pals) ("fricx", w.fric.x) ("fricy", w.fric.y) diff --git a/source/games/duke/src/sbar.cpp b/source/games/duke/src/sbar.cpp index f4c85cf6a..21ef2de07 100644 --- a/source/games/duke/src/sbar.cpp +++ b/source/games/duke/src/sbar.cpp @@ -36,7 +36,6 @@ source as it is released. #include "v_font.h" #include "duke3d.h" #include "compat.h" -#include "sbar.h" #include "v_draw.h" #include "texturemanager.h" #include "mapinfo.h" @@ -44,216 +43,6 @@ source as it is released. BEGIN_DUKE_NS -IMPLEMENT_CLASS(DDukeCommonStatusBar, true, true) -IMPLEMENT_POINTERS_START(DDukeCommonStatusBar) -IMPLEMENT_POINTER(miniFont) -IMPLEMENT_POINTER(numberFont) -IMPLEMENT_POINTER(digiFont) -IMPLEMENT_POINTER(indexFont) -IMPLEMENT_POINTERS_END - -//========================================================================== -// -// very much a dummy to access the methods. -// The goal is to export this to a script. -// -//========================================================================== - -DDukeCommonStatusBar::DDukeCommonStatusBar() -{ - drawOffset.Y = 0; -} - - -//========================================================================== -// -// Frag bar - todo -// -//========================================================================== -#if 0 -void DDukeCommonStatusBar::displayfragbar(void) -{ - short i, j; - - j = 0; - - for (i = connecthead; i >= 0; i = connectpoint2[i]) - if (i > j) j = i; - - auto tex = tileGetTexture(TILE_FRAGBAR); - for (int y = 0; y < 32; y += 8) - DrawTexture(twod, tex, 0, 0, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, 1.001, DTA_ScaleY, 1.001, TAG_Done); - - for (i = connecthead; i >= 0; i = connectpoint2[i]) - { - m initext(21 + (73 * (i & 3)), 2 + ((i & 28) << 1), &ud.user_name[i][0], ps[i].GetActor()->s.pal, 2 + 8 + 16 + 128); - sprintf(tempbuf, "%d", ps[i].frag - ps[i].fraggedself); - m initext(17 + 50 + (73 * (i & 3)), 2 + ((i & 28) << 1), tempbuf, ps[i].GetActor()->s.pal, 2 + 8 + 16 + 128); - } -} -#endif -//========================================================================== -// -// Common inventory icon code for all styles -// -//========================================================================== - -std::pair DDukeCommonStatusBar::ontext(struct player_struct *p) -{ - std::pair retval(nullptr, CR_RED); - - int onstate = 0x80000000; - switch (p->inven_icon) - { - case ICON_HOLODUKE: - onstate = p->holoduke_on != nullptr; - break; - case ICON_JETPACK: - onstate = p->jetpack_on; - break; - case ICON_HEATS: - onstate = p->heat_on; - break; - } - - // Texts are intentionally not translated because the font is too small for making localization work and the translated words are too long. - if ((unsigned)onstate != 0x80000000 && !(g_gameType & (GAMEFLAG_WW2GI|GAMEFLAG_RRALL))) - { - retval.second = onstate > 0 ? 0 : 2; - retval.first = onstate > 0 ? "ON" : "OFF"; - } - if (p->inven_icon >= ICON_SCUBA) - { - retval.second = 2; - retval.first = "AUTO"; - } - return retval; -} - -//========================================================================== -// -// draws the inventory selector -// -//========================================================================== - -void DDukeCommonStatusBar::DrawInventory(const struct player_struct* p, double x, double y, int align) -{ - if (p->invdisptime <= 0)return; - - int n = 0, j = 0; - if (p->firstaid_amount > 0) n |= 1, j++; - if (p->steroids_amount > 0) n |= 2, j++; - if (p->holoduke_amount > 0) n |= 4, j++; - if (p->jetpack_amount > 0) n |= 8, j++; - if (p->heat_amount > 0) n |= 16, j++; - if (p->scuba_amount > 0) n |= 32, j++; - if (p->boot_amount > 0) n |= 64, j++; - - x -= (j * 11); - y -= 6; - - ; align |= DI_ITEM_CENTER; - for(int bit = 0; bit < 7; bit++) - { - int i = 1 << bit; - if (n & i) - { - int select = 1 << (p->inven_icon - 1); - double alpha = select == i ? 1.0 : 0.7; - DrawGraphic(tileGetTexture(item_icons[bit+1]), x, y, align, alpha, 0, 0, scale, scale); - if (select == i) DrawGraphic(tileGetTexture(TILE_ARROW), isWW2GI()? x + 7.5 : x, isWW2GI()? y + 0.5 : y, align, alpha, 0, 0, scale, scale); - x += 22; - } - } -} - -//========================================================================== -// -// Helper -// -//========================================================================== - -PalEntry DDukeCommonStatusBar::LightForShade(int shade) -{ - int ll = clamp((numshades - shade) * 255 / numshades, 0, 255); - return PalEntry(255, ll, ll, ll); -} - - -//========================================================================== -// -// Statistics output -// -//========================================================================== - -void DDukeCommonStatusBar::PrintLevelStats(int bottomy) -{ - FLevelStats stats{}; - auto pp = &ps[myconnectindex]; - stats.fontscale = isRR() ? 0.5 : 1.; - stats.screenbottomspace = bottomy; - stats.time = Scale(pp->player_par, 1000, REALGAMETICSPERSEC); - stats.font = SmallFont; - if (isNamWW2GI()) - { - // The stock font of these games is totally unusable for this. - stats.font = ConFont; - stats.spacing = ConFont->GetHeight() + 1; - } - - if (automapMode == am_full) - { - bool textfont = am_textfont; - if (!am_textfont) - { - // For non-English languages force use of the text font. The tiny one is simply too small to ever add localized characters to it. - auto p = GStrings["REQUIRED_CHARACTERS"]; - if (p && *p) textfont = true; - } - - if (!textfont) - { - stats.font = SmallFont2; - stats.spacing = 6; - } - else stats.spacing = stats.font->GetHeight() + 1; - stats.standardColor = (isNamWW2GI() && am_textfont)? CR_ORANGE : CR_UNTRANSLATED; - stats.letterColor = CR_GOLD; - DBaseStatusBar::PrintAutomapInfo(stats, textfont); - } - else if (hud_stats) - { - // JBF 20040124: display level stats in screen corner - - stats.spacing = isRR() ? 10 : 7; - stats.kills = pp->actors_killed; - stats.maxkills = !isRR() && ud.player_skill > 3 ? -2 : pp->max_actors_killed; - stats.frags = ud.multimode > 1 && !ud.coop ? pp->frag - pp->fraggedself : -1; - stats.secrets = pp->secret_rooms; - stats.maxsecrets = pp->max_secret_rooms; - if (isNamWW2GI()) - { - // The stock font of these games is totally unusable for this. - stats.letterColor = CR_ORANGE; - stats.standardColor = CR_YELLOW; - stats.completeColor = CR_FIRE; - } - else if (!isRR()) - { - stats.letterColor = CR_ORANGE; - stats.standardColor = CR_CREAM; - stats.completeColor = CR_FIRE; - } - else - { - stats.letterColor = CR_ORANGE; - stats.standardColor = - stats.completeColor = CR_UNTRANSLATED; - } - DBaseStatusBar::PrintLevelStats(stats); - } -} - //========================================================================== // // 3D viewport size management @@ -298,6 +87,20 @@ void DrawBorder() } } +void DrawStatusBar() +{ + DrawBorder(); + + SummaryInfo info{}; + + info.kills = ps[0].actors_killed; + info.maxkills = ps[0].max_actors_killed; + info.secrets = ps[0].secret_rooms; + info.maxsecrets = ps[0].max_secret_rooms; + info.time = Scale(PlayClock, 1000, 120); + UpdateStatusBar(&info); +} + //========================================================================== // // view sizing game interface diff --git a/source/games/duke/src/sbar.h b/source/games/duke/src/sbar.h deleted file mode 100644 index 135d0134b..000000000 --- a/source/games/duke/src/sbar.h +++ /dev/null @@ -1,35 +0,0 @@ -#pragma once - -#include -#include "statusbar.h" -#include "duke3d.h" - -BEGIN_DUKE_NS - - -class DDukeCommonStatusBar : public DBaseStatusBar -{ - DECLARE_ABSTRACT_CLASS(DDukeCommonStatusBar, DBaseStatusBar) - HAS_OBJECT_POINTERS - -protected: - TObjPtr numberFont; - TObjPtr indexFont; - TObjPtr miniFont; - TObjPtr digiFont; - double scale = 1; - std::array ammo_sprites; - std::array item_icons; - - DDukeCommonStatusBar(); - std::pair ontext(struct player_struct *p); - void DrawInventory(const struct player_struct* p, double x, double y, int align); - PalEntry LightForShade(int shade); -public: - void PrintLevelStats(int bottomy); - -}; - -void DrawBorder(); - -END_DUKE_NS diff --git a/source/games/duke/src/sbar_d.cpp b/source/games/duke/src/sbar_d.cpp deleted file mode 100644 index e55fdea14..000000000 --- a/source/games/duke/src/sbar_d.cpp +++ /dev/null @@ -1,491 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 1996, 2003 - 3D Realms Entertainment -Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) -Copyright (C) 2020 - Christoph Oelckers - -This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition - -Duke Nukem 3D is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Original Source: 1996 - Todd Replogle -Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms - -EDuke enhancements integrated: 04/13/2003 - Matt Saettler - -Note: EDuke source was in transition. Changes are in-progress in the -source as it is released. - -*/ -//------------------------------------------------------------------------- -#include "ns.h" // Must come before everything else! - -#include -#include "v_font.h" -#include "duke3d.h" -#include "compat.h" -#include "sbar.h" -#include "statusbar.h" -#include "v_draw.h" -#include "names_d.h" -#include "texturemanager.h" -#include "dukeactor.h" - -bool PickTexture(FRenderState* state, FGameTexture* tex, int paletteid, TexturePick& pick); - -BEGIN_DUKE_NS - -//========================================================================== -// -// very much a dummy to access the methods. -// The goal is to export this to a script. -// -//========================================================================== - -class DDukeStatusBar : public DDukeCommonStatusBar -{ - DECLARE_CLASS(DDukeStatusBar, DDukeCommonStatusBar) - - int fontheight[2]; -public: - - DDukeStatusBar() - { - numberFont = Create( BigFont, 0, Off, 1, 1 ); - indexFont = Create(IndexFont, 4, CellRight, 1, 1 ); - miniFont = Create(SmallFont2, 0, Off, 1, 1 ); - digiFont = Create(DigiFont, 1, Off, 1, 1 ); - - // optionally draw at the top of the screen. - SetSize(tileHeight(TILE_BOTTOMSTATUSBAR)); - scale = 1; - - ammo_sprites = { -1, AMMO, SHOTGUNAMMO, BATTERYAMMO, RPGAMMO, HBOMBAMMO, CRYSTALAMMO, DEVISTATORAMMO, TRIPBOMBSPRITE, FREEZEAMMO + 1, HBOMBAMMO, GROWAMMO, FLAMETHROWERAMMO + 1 }; - item_icons = { 0, FIRSTAID_ICON, STEROIDS_ICON, HOLODUKE_ICON, JETPACK_ICON, HEAT_ICON, AIRTANK_ICON, BOOT_ICON }; - - fontheight[1] = fontheight[0] = 0; - for (int i = 0; i < 9; i++) - { - auto zerotex = tileGetTexture(BIGALPHANUM - 10 + i); - if (zerotex) - { - int fh0 = zerotex->GetTexture()->CheckRealHeight(); - int fh1 = fh0; - TexturePick pick; - if (PickTexture(nullptr, zerotex, TRANSLATION(Translation_Remap, 0), pick)) - { - int oheight = zerotex->GetTexelHeight(); - int dheight = pick.texture->GetTexelHeight(); - int dReal = pick.texture->CheckRealHeight(); - fh1 = Scale(dReal, oheight, dheight); - } - if (fh0 > fontheight[0]) fontheight[0] = fh0; - if (fh1 > fontheight[1]) fontheight[1] = fh1; - } - } - } - - //========================================================================== - // - // Helpers - // - //========================================================================== - - int getinvamount(const struct player_struct* p) - { - switch (p->inven_icon) - { - case ICON_FIRSTAID: - return p->firstaid_amount; - case ICON_STEROIDS: - return (p->steroids_amount + 3) >> 2; - case ICON_HOLODUKE: - return (p->holoduke_amount + 15) / 24; - case ICON_JETPACK: - return (p->jetpack_amount + 15) >> 4; - case ICON_HEATS: - return p->heat_amount / 12; - case ICON_SCUBA: - return (p->scuba_amount + 63) >> 6; - case ICON_BOOTS: - return p->boot_amount >> 1; - } - - return -1; - } - - int GetMoraleOrShield(struct player_struct *p, int snum) - { - // special handling for WW2GI - int lAmount = GetGameVar("PLR_MORALE", -1, p->GetActor(), snum); - if (lAmount == -1) lAmount = p->shield_amount; - return lAmount; - } - - - //========================================================================== - // - // Fullscreen HUD variant #1 - // - //========================================================================== - - void FullscreenHUD1(struct player_struct* p, int snum) - { - int fh = fontheight[hw_hightile ? 1 : 0]; - FString format; - FGameTexture* img; - double imgScale; - double baseScale = (scale * (fh+1)); - double texty = -fh - 2.5; - - // - // Health - // - img = tileGetTexture(isNamWW2GI()? FIRSTAID_ICON : COLA); - imgScale = baseScale / img->GetDisplayHeight(); - DrawGraphic(img, 2, -1.5, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale); - - if (!althud_flashing || p->last_extra > (gs.max_player_health >> 2) || (PlayClock & 32) || (p->GetActor()->s->pal == 1 && p->last_extra < 2)) - { - int s = -8; - if (althud_flashing && p->last_extra > gs.max_player_health) - s += bsin(I_GetBuildTime() << 5) / 768; - int intens = clamp(255 - 6 * s, 0, 255); - format.Format("%d", p->last_extra); - SBar_DrawString(this, numberFont, format, 25, texty, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, intens / 255., 0, 0, 1, 1); - } - - // - // Armor - // - img = tileGetTexture(SHIELD); - imgScale = baseScale / img->GetDisplayHeight(); - DrawGraphic(img, 67.375, -1.5, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale); - - format.Format("%d", GetMoraleOrShield(p, snum)); - SBar_DrawString(this, numberFont, format, 85, texty, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - - // - // Weapon - // - int weapon = p->curr_weapon; - if (weapon == HANDREMOTE_WEAPON) weapon = HANDBOMB_WEAPON; - - int wicon = ammo_sprites[weapon]; - if (wicon > 0) - { - int ammo = p->ammo_amount[weapon]; - if (weapon != PISTOL_WEAPON || (weapon == PISTOL_WEAPON && !cl_showmagamt)) - { - format.Format("%d", ammo); - } - else - { - short clip = CalcMagazineAmount(ammo, isNam() ? 20 : 12, p->kickback_pic >= 1); - format.Format("%d/%d", clip, ammo - clip); - } - img = tileGetTexture(wicon); - imgScale = baseScale / img->GetDisplayHeight(); - auto imgX = 20.; - auto strlen = format.Len(); - - if (strlen > 1) - { - imgX += (imgX * 0.6) * (strlen - 1); - } - - if (weapon != KNEE_WEAPON && (!althud_flashing || PlayClock & 32 || ammo > (gs.max_ammo_amount[weapon] / 10))) - { - SBar_DrawString(this, numberFont, format, -3, texty, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - } - - DrawGraphic(img, -imgX, -1.5, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale); - } - - // - // Selected inventory item - // - unsigned icon = p->inven_icon; - if (icon > 0) - { - int x = 128; - - if (icon < ICON_MAX) - { - img = tileGetTexture(item_icons[icon]); - imgScale = baseScale / img->GetDisplayHeight(); - DrawGraphic(img, x, -1.5, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, imgScale, imgScale); - } - - int percentv = getinvamount(p); - format.Format("%3d%%", percentv); - int color = percentv > 50 ? 11 : percentv > 25 ? 23 : 2; - SBar_DrawString(this, miniFont, format, x + 36.5, -indexFont->mFont->GetHeight() + 0.5, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1, TRANSLATION(Translation_Remap, color)); - - auto text = ontext(p); - if (text.first) SBar_DrawString(this, miniFont, text.first, x + 36.5, -miniFont->mFont->GetHeight() - 9.5, DI_TEXT_ALIGN_RIGHT, - CR_UNDEFINED, 1, 0, 0, 1, 1, TRANSLATION(Translation_Remap, text.second)); - } - - // - // keys - // - if (p->got_access & 1) DrawGraphic(tileGetTexture(ACCESSCARD), -12, -23.5, DI_ITEM_RIGHT, 1, -1, -1, 0.5, 0.5, STYLE_Translucent, 0xffffffff, TRANSLATION(Translation_Remap, 0)); - if (p->got_access & 4) DrawGraphic(tileGetTexture(ACCESSCARD), -7 , -21.5, DI_ITEM_RIGHT, 1, -1, -1, 0.5, 0.5, STYLE_Translucent, 0xffffffff, TRANSLATION(Translation_Remap, 23)); - if (p->got_access & 2) DrawGraphic(tileGetTexture(ACCESSCARD), -2 , -19.5, DI_ITEM_RIGHT, 1, -1, -1, 0.5, 0.5, STYLE_Translucent, 0xffffffff, TRANSLATION(Translation_Remap, 21)); - } - - - //========================================================================== - // - // Fullscreen HUD variant #2 - // - //========================================================================== - - void FullscreenHUD2(struct player_struct *p) - { - // - // health - // - DrawGraphic(tileGetTexture(HEALTHBOX), 5, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - int health = (p->GetActor()->s->pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; - FStringf format("%d", health); - SBar_DrawString(this, digiFont, format, 20, -digiFont->mFont->GetHeight() * scale - 3, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - // - // ammo - // - DrawGraphic(tileGetTexture(AMMOBOX), 37, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - int wp = (p->curr_weapon == HANDREMOTE_WEAPON) ? HANDBOMB_WEAPON : p->curr_weapon; - format.Format("%d", p->ammo_amount[wp]); - SBar_DrawString(this, digiFont, format, 52, -digiFont->mFont->GetHeight() * scale - 3, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - // - // inventory - // - unsigned icon = p->inven_icon; - if (icon > 0) - { - int x = 73; - DrawGraphic(tileGetTexture(INVENTORYBOX), 69, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - if (icon < ICON_MAX) - DrawGraphic(tileGetTexture(item_icons[icon]), x, -13.5, DI_ITEM_LEFT|DI_ITEM_VCENTER, 1, -1, -1, scale, scale); - - int percentv = getinvamount(p); - format.Format("%3d%%", percentv); - int color = percentv > 50 ? 11 : percentv > 25 ? 23 : 2; - SBar_DrawString(this, miniFont, format, x + 34, -indexFont->mFont->GetHeight() - 3, DI_TEXT_ALIGN_RIGHT, color, 1, 0, 0, 1, 1, TRANSLATION(Translation_Remap, color)); - - auto text = ontext(p); - if (text.first) SBar_DrawString(this, miniFont, text.first, x + 34, -miniFont->mFont->GetHeight() - 14, DI_TEXT_ALIGN_RIGHT, CR_UNDEFINED, 1, 0, 0, 1, 1, TRANSLATION(Translation_Remap, text.second)); - } - } - - //========================================================================== - // - // Fullscreen HUD drawer - // - //========================================================================== - - void DrawHud(int snum, int style) - { - auto p = &ps[snum]; - BeginHUD(320, 200, 1.f); - if (style == 1) - { - DrawInventory(p, 0, -46, DI_SCREEN_CENTER_BOTTOM); - FullscreenHUD1(p, snum); - PrintLevelStats(tileHeight(BIGALPHANUM) +10); - } - else if (style == 2) - { - DrawInventory(p, (ud.multimode > 1) ? 56 : 65, -28, DI_SCREEN_CENTER_BOTTOM); - FullscreenHUD2(p); - PrintLevelStats(tileHeight(HEALTHBOX) + 4); - } - else - { - DrawInventory(p, 0, -28, DI_SCREEN_CENTER_BOTTOM); - PrintLevelStats(2); - } - } - - - //========================================================================== - // - // Helper for weapon display - // - //========================================================================== - - void DrawWeaponNum(int index, double x, double y, int num1, int num2, int shade, int numdigits) - { - /* - if (isShareware() && (ind > HANDBOMB_WEAPON || ind < 0)) - { - minitextshade(x + 1, y - 4, "ORDER", 20, 11, 2 + 8 + 16 + ROTATESPRITE_MAX); - return; - } - */ - FString format; - bool parsedDivisor = false; - - if (numdigits == 2) - { - if (num1 > 99) num1 = 99; - if (num2 > 99) num2 = 99; - format.Format("%2d/%d", num1, num2); - } - else - { - if (num1 > 999) num1 = 999; - if (num2 > 999) num2 = 999; - format.Format("%3d/%d", num1, num2); - } - y--; - DrawGraphic(tileGetTexture(THREEBYFIVE + index), x - 7, y, DI_ITEM_LEFT|DI_ITEM_VCENTER, 1, 0, 0, 1, 1, STYLE_Translucent, LightForShade(shade - 10), TRANSLATION(Translation_Remap, 7)); - auto pe = LightForShade(shade); - DrawGraphic(tileGetTexture(THREEBYFIVE + 10), x - 3, y, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, 0, 0, 1, 1, STYLE_Translucent, pe); - for (size_t i = 0; i < format.Len(); i++) - { - if (format[i] != ' ') - { - char c = format[i] == '/' ? 11 : format[i] - '0'; - DrawGraphic(tileGetTexture(THREEBYFIVE + c), x + 4 * i + (parsedDivisor ? 1 : 0), y, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, 0, 0, 1, 1, STYLE_Translucent, pe); - } - if (format[i] == '/') - { - parsedDivisor = true; - } - } - } - - //========================================================================== - // - // Weapon display (Duke only) - // - //========================================================================== - - void DrawWeaponAmounts(const struct player_struct* p, double x, double y) - { - int cw = p->curr_weapon; - - auto ShadeForWeapon = [=](int weapon, int optweapon = -1) - { - // Headache-inducing math at play here. - return (((!p->ammo_amount[weapon]) | (!p->gotweapon[weapon])) * 9) + 12 - 18 * ((cw == weapon) || (optweapon != -1 && cw == optweapon)); - }; - - DrawWeaponNum(2, x, y, p->ammo_amount[PISTOL_WEAPON], gs.max_ammo_amount[PISTOL_WEAPON], 12 - 20 * (cw == PISTOL_WEAPON), 3); - DrawWeaponNum(3, x, y + 6, p->ammo_amount[SHOTGUN_WEAPON], gs.max_ammo_amount[SHOTGUN_WEAPON], ShadeForWeapon(SHOTGUN_WEAPON), 3); - DrawWeaponNum(4, x, y + 12, p->ammo_amount[CHAINGUN_WEAPON], gs.max_ammo_amount[CHAINGUN_WEAPON], ShadeForWeapon(CHAINGUN_WEAPON), 3); - DrawWeaponNum(5, x + 39, y, p->ammo_amount[RPG_WEAPON], gs.max_ammo_amount[RPG_WEAPON], ShadeForWeapon(RPG_WEAPON), 2); - DrawWeaponNum(6, x + 39, y + 6, p->ammo_amount[HANDBOMB_WEAPON], gs.max_ammo_amount[HANDBOMB_WEAPON], ShadeForWeapon(HANDBOMB_WEAPON, HANDREMOTE_WEAPON), 2); - if (p->subweapon & (1 << GROW_WEAPON)) // original code says: if(!p->ammo_amount[SHRINKER_WEAPON] || cw == GROW_WEAPON) - DrawWeaponNum(7, x + 39, y + 12, p->ammo_amount[GROW_WEAPON], gs.max_ammo_amount[GROW_WEAPON], ShadeForWeapon(GROW_WEAPON), 2); - else - DrawWeaponNum(7, x + 39, y + 12, p->ammo_amount[SHRINKER_WEAPON], gs.max_ammo_amount[SHRINKER_WEAPON], ShadeForWeapon(SHRINKER_WEAPON), 2); - DrawWeaponNum(8, x + 70, y, p->ammo_amount[DEVISTATOR_WEAPON], gs.max_ammo_amount[DEVISTATOR_WEAPON], ShadeForWeapon(DEVISTATOR_WEAPON), 2); - DrawWeaponNum(9, x + 70, y + 6, p->ammo_amount[TRIPBOMB_WEAPON], gs.max_ammo_amount[TRIPBOMB_WEAPON], ShadeForWeapon(TRIPBOMB_WEAPON), 2); - DrawWeaponNum(0, x + 70, y + 12, p->ammo_amount[FREEZE_WEAPON], gs.max_ammo_amount[FREEZE_WEAPON], ShadeForWeapon(FREEZE_WEAPON), 2); - } - - //========================================================================== - // - // Status bar drawer - // - //========================================================================== - - void Statusbar(int snum) - { - auto p = &ps[snum]; - int h = tileHeight(BOTTOMSTATUSBAR); - int top = 200 - h; - int left = (320 - tileWidth(BOTTOMSTATUSBAR)) / 2; - BeginStatusBar(320, 200, h); - DrawInventory(p, 160, 154, 0); - if (hud_size == Hud_StbarOverlay) Set43ClipRect(); - DrawGraphic(tileGetTexture(BOTTOMSTATUSBAR), left, top, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); - twod->ClearClipRect(); - - FString format; - - if (ud.multimode > 1 && !ud.coop) - { - DrawGraphic(tileGetTexture(KILLSICON), 228, top + 8, DI_ITEM_OFFSETS, 1, 0, 0, 1, 1); - format.Format("%d", max(p->frag - p->fraggedself, 0)); - SBar_DrawString(this, digiFont, format, 287, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - } - else - { - auto key = tileGetTexture(ACCESS_ICON); - if (p->got_access & 4) DrawGraphic(key, 275.5, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, 1, 1, STYLE_Translucent, 0xffffffff, TRANSLATION(Translation_Remap, 23)); - if (p->got_access & 2) DrawGraphic(key, 288.5, top + 16, DI_ITEM_OFFSETS, 1, -1, -1, 1, 1, STYLE_Translucent, 0xffffffff, TRANSLATION(Translation_Remap, 21)); - if (p->got_access & 1) DrawGraphic(key, 282, top + 23, DI_ITEM_OFFSETS, 1, -1, -1, 1, 1, STYLE_Translucent, 0xffffffff, TRANSLATION(Translation_Remap, 0)); - } - DrawWeaponAmounts(p, 96, top + 15.5); - - int num = (p->GetActor()->s->pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; - format.Format("%d", num); - SBar_DrawString(this, digiFont, format, 31, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - format.Format("%d", GetMoraleOrShield(p, snum)); - SBar_DrawString(this, digiFont, format, 63, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - - if (p->curr_weapon != KNEE_WEAPON) - { - int wep = (p->curr_weapon == HANDREMOTE_WEAPON)? HANDBOMB_WEAPON : p->curr_weapon; - format.Format("%d", p->ammo_amount[wep]); - SBar_DrawString(this, digiFont, format, 207, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - } - - int icon = p->inven_icon; - if (icon) - { - int x = 232; - if (icon < ICON_MAX) - DrawGraphic(tileGetTexture(item_icons[icon]), x, top + 20.5, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, -1, -1, 1, 1); - - int percentv = getinvamount(p); - format.Format("%3d%%", percentv); - int color = percentv > 50 ? 11 : percentv > 25 ? 23 : 2; - SBar_DrawString(this, miniFont, format, x + 34, top + 24, DI_TEXT_ALIGN_RIGHT, CR_UNDEFINED, 1, 0, 0, 1, 1, TRANSLATION(Translation_Remap, color)); - - auto text = ontext(p); - if (text.first) SBar_DrawString(this, miniFont, text.first, x + 34, top + 14, DI_TEXT_ALIGN_RIGHT, CR_UNDEFINED, 1, 0, 0, 1, 1, TRANSLATION(Translation_Remap, text.second)); - } - PrintLevelStats(-1); - } - - void UpdateStatusBar() - { - if (hud_size >= Hud_Mini) - { - DrawHud(screenpeek, hud_size == Hud_Nothing ? 0 : hud_size == Hud_full ? 1 : 2); - } - else - { - Statusbar(screenpeek); - } - } -}; - -IMPLEMENT_CLASS(DDukeStatusBar, false, false) - -DBaseStatusBar* CreateDukeStatusBar() -{ - return Create(); -} - -END_DUKE_NS diff --git a/source/games/duke/src/sbar_r.cpp b/source/games/duke/src/sbar_r.cpp deleted file mode 100644 index 5de101c20..000000000 --- a/source/games/duke/src/sbar_r.cpp +++ /dev/null @@ -1,477 +0,0 @@ -//------------------------------------------------------------------------- -/* -Copyright (C) 1996, 2003 - 3D Realms Entertainment -Copyright (C) 2020 - Christoph Oelckers - -This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition - -Duke Nukem 3D is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -Original Source: 1996 - Todd Replogle -Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms - -*/ -//------------------------------------------------------------------------- -#include "ns.h" // Must come before everything else! - -#include "v_font.h" -#include "duke3d.h" -#include "compat.h" -#include "sbar.h" -#include "v_draw.h" -#include "names_r.h" -#include "texturemanager.h" -#include "dukeactor.h" -#include "v_video.h" -#include "v_draw.h" - -BEGIN_DUKE_NS - -//========================================================================== -// -// very much a dummy just to access the methods. -// The goal is to export this to a script. -// -//========================================================================== - -class DRedneckStatusBar : public DDukeCommonStatusBar -{ - DECLARE_CLASS(DRedneckStatusBar, DDukeCommonStatusBar) - -public: - DRedneckStatusBar() - { - numberFont = Create(BigFont, 0, Off, 1, 1 ); - miniFont = Create(SmallFont2, 0, Off, 1, 1 ); - digiFont = Create(DigiFont, 2, Off, 1, 1 ); - - // optionally draw at the top of the screen. - SetSize(tileHeight(BOTTOMSTATUSBAR)); - scale = 0.5; - ammo_sprites = { -1, AMMO, SHOTGUNAMMO, BATTERYAMMO, HBOMBAMMO, HBOMBAMMO, SAWAMMO, DEVISTATORAMMO, TRIPBOMBSPRITE, GROWSPRITEICON, HBOMBAMMO, -1, BOWLINGBALLSPRITE, MOTOAMMO, BOATAMMO, -1, RPG2SPRITE }; - item_icons = { 0, FIRSTAID_ICON, STEROIDS_ICON, HOLODUKE_ICON, JETPACK_ICON, HEAT_ICON, AIRTANK_ICON, BOOT_ICON }; - } - - - int getinvamount(const struct player_struct* p) - { - switch (p->inven_icon) - { - case ICON_FIRSTAID: - return p->firstaid_amount; - case ICON_STEROIDS: - return (p->steroids_amount + 3) >> 2; - case ICON_HOLODUKE: - return (p->holoduke_amount) / 400; - case ICON_JETPACK: - return (p->jetpack_amount) / 100; - case ICON_HEATS: - return p->heat_amount / 12; - case ICON_SCUBA: - return (p->scuba_amount + 63) >> 6; - case ICON_BOOTS: - return (p->boot_amount / 10) >> 1; - } - - return -1; - } - - - //========================================================================== - // - // Fullscreen HUD variant #1 for RR - // - //========================================================================== - - void FullscreenHUD1(struct player_struct* p, int snum) - { - FString format; - FGameTexture* img; - double imgScale; - double baseScale = (scale * numberFont->mFont->GetHeight()) * 0.76; - - // - // Health - // - img = tileGetTexture(SPINNINGNUKEICON1); - imgScale = baseScale / img->GetDisplayHeight(); - DrawGraphic(img, 2, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, imgScale, imgScale); - - if (!althud_flashing || p->last_extra > (gs.max_player_health >> 2) || (PlayClock & 32) || (p->GetActor()->s->pal == 1 && p->last_extra < 2)) - { - int s = -8; - if (althud_flashing && p->last_extra > gs.max_player_health) - s += bsin(I_GetBuildTime() << 5) / 768; - int intens = clamp(255 - 6 * s, 0, 255); - format.Format("%d", p->last_extra); - SBar_DrawString(this, numberFont, format, 26.5, -numberFont->mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, intens / 255., 0, 0, scale, scale); - } - - // - // drink - // - img = tileGetTexture(COLA); - imgScale = baseScale / img->GetDisplayHeight(); - DrawGraphic(img, 74, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, imgScale, imgScale); - format.Format("%d", p->drink_amt); - SBar_DrawString(this, numberFont, format, 86, -numberFont->mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - // - // eat - // - img = tileGetTexture(JETPACK); - imgScale = baseScale / img->GetDisplayHeight(); - DrawGraphic(img, 133.5, -2, DI_ITEM_LEFT_BOTTOM, 1, 0, 0, imgScale, imgScale); - format.Format("%d", p->eat); - SBar_DrawString(this, numberFont, format, 173, -numberFont->mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - // - // selected weapon - // - int weapon = p->curr_weapon; - if (weapon == HANDREMOTE_WEAPON) weapon = DYNAMITE_WEAPON; - - int wicon = ammo_sprites[weapon]; - if (wicon > 0) - { - int ammo = p->ammo_amount[weapon]; - bool reloadableWeapon = weapon == PISTOL_WEAPON || weapon == SHOTGUN_WEAPON; - if (!reloadableWeapon || (reloadableWeapon && !cl_showmagamt)) - { - format.Format("%d", ammo); - } - else - { - short clip; - switch (weapon) - { - case PISTOL_WEAPON: - clip = CalcMagazineAmount(ammo, 6, p->kickback_pic >= 1); - break; - case SHOTGUN_WEAPON: - clip = CalcMagazineAmount(ammo, 2, p->kickback_pic >= 4); - break; - } - format.Format("%d/%d", clip, ammo - clip); - } - img = tileGetTexture(wicon); - imgScale = baseScale / img->GetDisplayHeight(); - auto imgX = 22.5; - auto strlen = format.Len(); - - if (strlen > 1) - { - imgX += (imgX * 0.755) * (strlen - 1); - } - - if (weapon != KNEE_WEAPON && weapon != SLINGBLADE_WEAPON && (!althud_flashing || PlayClock & 32 || ammo > (gs.max_ammo_amount[weapon] / 10))) - { - SBar_DrawString(this, numberFont, format, -1, -numberFont->mFont->GetHeight() * scale + 4, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - - DrawGraphic(img, -imgX, -2, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale); - } - - // - // Selected inventory item - // - unsigned icon = p->inven_icon; - if (icon > 0) - { - int x = -130; - - if (icon < ICON_MAX) - { - img = tileGetTexture(item_icons[icon]); - imgScale = baseScale / img->GetDisplayHeight(); - DrawGraphic(img, x, -2, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale); - } - - int percentv = getinvamount(p); - if (icon <= 2) format.Format("%d%%", percentv); - else format.Format("%d", percentv); - SBar_DrawString(this, miniFont, format, x + 19, -miniFont->mFont->GetHeight() * scale - 1, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - auto text = ontext(p); - if (text.first) SBar_DrawString(this, miniFont, text.first, x + 20, -miniFont->mFont->GetHeight() * scale - 15, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - - // - // keys - // - if (p->keys[1]) DrawGraphic(tileGetTexture(ACCESSCARD), -28.5, -32 , DI_ITEM_BOTTOM, 1, -1, -1, scale, scale, STYLE_Translucent, 0xffffffff, TRANSLATION(Translation_Remap, 0)); - if (p->keys[3]) DrawGraphic(tileGetTexture(ACCESSCARD), -21.25, -28.375, DI_ITEM_BOTTOM, 1, -1, -1, scale, scale, STYLE_Translucent, 0xffffffff, TRANSLATION(Translation_Remap, 23)); - if (p->keys[2]) DrawGraphic(tileGetTexture(ACCESSCARD), -14, -24.75 , DI_ITEM_BOTTOM, 1, -1, -1, scale, scale, STYLE_Translucent, 0xffffffff, TRANSLATION(Translation_Remap, 21)); - } - - - //========================================================================== - // - // Fullscreen HUD variant #2 for RR - // - //========================================================================== - - void FullscreenHUD2(struct player_struct* p) - { - // - // health - // - DrawGraphic(tileGetTexture(HEALTHBOX), 2, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - int health = (p->GetActor()->s->pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; - FStringf format("%d", health); - SBar_DrawString(this, digiFont, format, 21.5, -digiFont->mFont->GetHeight() * scale - 5.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - // - // ammo - // - DrawGraphic(tileGetTexture(AMMOBOX), 41, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - int wp = p->curr_weapon == THROWINGDYNAMITE_WEAPON? DYNAMITE_WEAPON : p->curr_weapon; - format.Format("%d", p->ammo_amount[wp]); - SBar_DrawString(this, digiFont, format, 60.25, -digiFont->mFont->GetHeight() * scale - 5.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - // - // inventory - // - unsigned icon = p->inven_icon; - if (icon > 0) - { - int x = 84.5; - DrawGraphic(tileGetTexture(INVENTORYBOX), 77, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, scale, scale); - if (icon < ICON_MAX) - DrawGraphic(tileGetTexture(item_icons[icon]), x, -15.375, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, -1, -1, scale, scale); - - int percentv = getinvamount(p); - if (icon <= 2) format.Format("%d%%", percentv); - else format.Format("%d", percentv); - SBar_DrawString(this, miniFont, format, x + 31.5, -miniFont->mFont->GetHeight() * scale - 6.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - } - - //========================================================================== - // - // Fullscreen HUD drawer - // - //========================================================================== - - void DrawHud(int snum, int style) - { - auto p = &ps[snum]; - BeginHUD(320, 200, 1.f); - if (style == 1) - { - double y = -40; - if (ud.multimode > 1) - y -= 4; - if (ud.multimode > 4) - y -= 4; - DrawInventory(p, 0, y, DI_SCREEN_CENTER_BOTTOM); - FullscreenHUD1(p, snum); - PrintLevelStats(scale * tileHeight(BIGALPHANUM) + 10); - } - else if (style == 2) - { - DrawInventory(p, 56, -20, DI_SCREEN_CENTER_BOTTOM); - FullscreenHUD2(p); - PrintLevelStats(scale * tileHeight(HEALTHBOX) + 4); - } - else - { - DrawInventory(p, 0, -20, DI_SCREEN_CENTER_BOTTOM); - PrintLevelStats(2); - } - } - - //========================================================================== - // - // Status bar drawer (RR) - // - //========================================================================== - - void DrawWeaponBar(const struct player_struct* p, int top) - { - double sbscale = 32800. / 65536.; - - DrawGraphic(tileGetTexture(WEAPONBAR), 0, 158, DI_ITEM_OFFSETS, 1, 0, 0, sbscale, sbscale); - - for (int i = 0; i < 9; i++) - { - FGameTexture* img = nullptr; - FString format; - - if ((g_gameType & GAMEFLAG_RRRA) && i == 4 && p->curr_weapon == CHICKEN_WEAPON) - { - img = tileGetTexture(AMMO_ICON + 10); - format.Format("%d", p->ammo_amount[CHICKEN_WEAPON]); - } - else - { - if (p->gotweapon[i+1]) - { - img = tileGetTexture(AMMO_ICON + i); - format.Format("%d", p->ammo_amount[i+1]); - } - } - - if (img) - { - DrawGraphic(img, 18 + i * 32, top - 6.5, DI_ITEM_OFFSETS, 1, 0, 0, sbscale, sbscale); - } - - if (format.Len()) - { - SBar_DrawString(this, miniFont, format, 38 + i * 32, 162.75 - miniFont->mFont->GetHeight() * scale * 0.5, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale * .875, scale * .875); - } - } - } - - - //========================================================================== - // - // Status bar drawer (RR) - // - //========================================================================== - - void Statusbar(int snum) - { - auto p = &ps[snum]; - double h = tileHeight(BOTTOMSTATUSBAR) * scale; - double wh = 0; - if (hud_size < Hud_Stbar) wh = tileHeight(WEAPONBAR) * scale; - double left = (320 - tileWidth(BOTTOMSTATUSBAR) * scale) / 2; - - double top = 200 - h; - BeginStatusBar(320, 200, wh + h); - DrawInventory(p, 160, hud_size <= Hud_Stbar? 148 : 154, 0); - - if (hud_size <= Hud_Stbar) - DrawWeaponBar(p, top); - - if (hud_size == Hud_StbarOverlay) Set43ClipRect(); - DrawGraphic(tileGetTexture(BOTTOMSTATUSBAR), left, top, DI_ITEM_LEFT_TOP, 1, -1, -1, scale, scale); - twod->ClearClipRect(); - - FString format; - - if (ud.multimode > 1 && !ud.coop) - { - DrawGraphic(tileGetTexture(KILLSICON), 228, top + 8, DI_ITEM_OFFSETS, 1, 0, 0, 1, 1); - format.Format("%d", max(p->frag - p->fraggedself, 0)); - SBar_DrawString(this, digiFont, format, 287, top + 17, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - else - { - auto key = tileGetTexture(ACCESS_ICON); - if (p->keys[3]) DrawGraphic(key, 138, top + 13, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale, STYLE_Translucent, 0xffffffff, TRANSLATION(Translation_Remap, 23)); - if (p->keys[2]) DrawGraphic(key, 152, top + 13, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale, STYLE_Translucent, 0xffffffff, TRANSLATION(Translation_Remap, 21)); - if (p->keys[1]) DrawGraphic(key, 145, top + 21, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale, STYLE_Translucent, 0xffffffff, TRANSLATION(Translation_Remap, 0)); - } - - int num = (p->GetActor()->s->pal == 1 && p->last_extra < 2) ? 1 : p->last_extra; - format.Format("%d", num); - SBar_DrawString(this, digiFont, format, 66.5, top + 16, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - if (p->curr_weapon != KNEE_WEAPON) - { - int wep = (p->curr_weapon == HANDREMOTE_WEAPON) ? DYNAMITE_WEAPON : p->curr_weapon; - format.Format("%d", p->ammo_amount[wep]); - SBar_DrawString(this, digiFont, format, 110, top + 16, DI_TEXT_ALIGN_CENTER, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - - int icon = p->inven_icon; - if (icon) - { - int x = 182; - if (icon < ICON_MAX) - DrawGraphic(tileGetTexture(item_icons[icon]), x, top + 20.125, DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, -1, -1, scale, scale); - - int percentv = getinvamount(p); - if (icon <= 2) format.Format("%d%%", percentv); - else format.Format("%d", percentv); - SBar_DrawString(this, miniFont, format, x + 38, top + 23.5, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - - if (p->inven_icon == ICON_SCUBA || p->inven_icon == ICON_BOOTS) - SBar_DrawString(this, miniFont, "AUTO", x + 39, top + 13, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, scale, scale); - } - - p->drunkang = ((p->drink_amt * 8) + 1647) & 2047; - if (p->drink_amt >= 100) - { - p->drink_amt = 100; - p->drunkang = 400; - } - - DrawRotated(tileGetTexture(GUTMETER), 256, top + 15, DI_ITEM_RELCENTER, p->drunkang * -BAngToDegree, 1, scale, scale, 0xffffffff, 0); - DrawRotated(tileGetTexture(GUTMETER), 292, top + 15, DI_ITEM_RELCENTER, p->eatang * -BAngToDegree, 1, scale, scale, 0xffffffff, 0); - - if (p->drink_amt >= 0 && p->drink_amt <= 30) - { - DrawGraphic(tileGetTexture(GUTMETER_LIGHT1), 239, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - else if (p->drink_amt >= 31 && p->drink_amt <= 65) - { - DrawGraphic(tileGetTexture(GUTMETER_LIGHT2), 248, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - else if (p->drink_amt >= 66 && p->drink_amt <= 87) - { - DrawGraphic(tileGetTexture(GUTMETER_LIGHT3), 256, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - else - { - DrawGraphic(tileGetTexture(GUTMETER_LIGHT4), 265, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - - if (p->eat >= 0 && p->eat <= 30) - { - DrawGraphic(tileGetTexture(GUTMETER_LIGHT1), 276, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - else if (p->eat >= 31 && p->eat <= 65) - { - DrawGraphic(tileGetTexture(GUTMETER_LIGHT2), 285, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - else if (p->eat >= 66 && p->eat <= 87) - { - DrawGraphic(tileGetTexture(GUTMETER_LIGHT3), 294, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - else - { - DrawGraphic(tileGetTexture(GUTMETER_LIGHT4), 302, top + 24, DI_ITEM_OFFSETS, 1, -1, -1, scale, scale); - } - PrintLevelStats(-1); - } - - void UpdateStatusBar() - { - if (hud_size >= Hud_Mini) - { - DrawHud(screenpeek, hud_size == Hud_Nothing ? 0 : hud_size == Hud_full ? 1 : 2); - } - else - { - Statusbar(screenpeek); - } - } - -}; - -IMPLEMENT_CLASS(DRedneckStatusBar, false, false) - -DBaseStatusBar* CreateRedneckStatusBar() -{ - return Create(); -} - - -END_DUKE_NS diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 8cc7d4919..8aeb1f6ba 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -1090,10 +1090,10 @@ void operateactivators(int low, int plnum) { p[5] = !p[5]; - sector[p[0]].floorshade = sector[p[0]].ceilingshade = p[3]; + sector[p[0]].floorshade = sector[p[0]].ceilingshade = (int8_t)p[3]; wal = &wall[sector[p[0]].wallptr]; for (j = sector[p[0]].wallnum; j > 0; j--, wal++) - wal->shade = p[3]; + wal->shade = (int8_t)p[3]; } } @@ -1267,8 +1267,8 @@ void moveclouds(double smoothratio) cloudclock = myclock + 6; // cloudx/y were an array, but all entries were always having the same value so a single pair is enough. - cloudx += ps[screenpeek].angle.ang.fcos() * 0.5f; - cloudy += ps[screenpeek].angle.ang.fsin() * 0.5f; + cloudx += (float)ps[screenpeek].angle.ang.fcos() * 0.5f; + cloudy += (float)ps[screenpeek].angle.ang.fsin() * 0.5f; for (int i = 0; i < numclouds; i++) { if (!testnewrenderer) diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index 9617b033e..3e1a61df1 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -196,7 +196,7 @@ static inline int S_GetPitch(int num) float S_ConvertPitch(int lpitch) { - return pow(2, lpitch / 1200.); // I hope I got this right that ASS uses a linear scale where 1200 is a full octave. + return powf(2, lpitch / 1200.f); // I hope I got this right that ASS uses a linear scale where 1200 is a full octave. } int S_GetUserFlags(int num) @@ -413,7 +413,7 @@ void GameInterface::UpdateSounds(void) if (c != nullptr) { - listener.angle = -ca * BAngRadian; // Build uses a period of 2048. + listener.angle = -float(ca * BAngRadian); // Build uses a period of 2048. listener.velocity.Zero(); listener.position = GetSoundPos(c); listener.underwater = false; @@ -674,7 +674,7 @@ void S_MenuSound(void) static bool cd_disabled = false; // This is in case mus_redbook is enabled but no tracks found so that the regular music system can be switched on. -static void MusPlay(const char* label, const char* music, bool loop) +static void MusPlay(const char* music, bool loop) { if (isWorldTour()) { @@ -688,26 +688,26 @@ static void MusPlay(const char* label, const char* music, bool loop) int file = fileSystem.GetFileContainer(num); if (file == 1) { - Mus_Play(label, alternative, loop); + Mus_Play(alternative, loop); return; } } } } - int result = Mus_Play(label, music, loop); + int result = Mus_Play(music, loop); // do not remain silent if playing World Tour when the user has deleted the music. if (!result && isWorldTour()) { FString alternative = music; alternative.Substitute(".ogg", ".mid"); - Mus_Play(label, alternative, loop); + Mus_Play(alternative, loop); } } void S_PlayLevelMusic(MapRecord *mi) { if (isRR() && mi->music.IsEmpty() && mus_redbook && !cd_disabled) return; - MusPlay(mi->labelName, mi->music, true); + MusPlay(mi->music, true); } void S_PlaySpecialMusic(unsigned int m) @@ -716,7 +716,7 @@ void S_PlaySpecialMusic(unsigned int m) auto& musicfn = specialmusic[m]; if (musicfn.IsNotEmpty()) { - MusPlay(nullptr, musicfn, true); + MusPlay(musicfn, true); } } @@ -741,10 +741,10 @@ void S_PlayRRMusic(int newTrack) g_cdTrack = 2; FStringf filename("redneck%s%02d.ogg", isRRRA()? "rides" : "", g_cdTrack); - if (Mus_Play(nullptr, filename, false)) return; + if (Mus_Play(filename, false)) return; filename.Format("track%02d.ogg", g_cdTrack); - if (Mus_Play(nullptr, filename, false)) return; + if (Mus_Play(filename, false)) return; } // If none of the tracks managed to start, disable the CD music for this session so that regular music can play if defined. cd_disabled = true; @@ -827,7 +827,7 @@ void S_ParseDeveloperCommentary() } } sc.MustGetStringName(";"); - if (Commentaries.Size() <= num) Commentaries.Resize(num + 1); + if (Commentaries.Size() <= (unsigned)num) Commentaries.Resize(num + 1); Commentaries[num] = std::move(path); } //sc.MustGetStringName(";"); @@ -849,7 +849,7 @@ void StopCommentary() bool StartCommentary(int tag, DDukeActor* actor) { - if (wt_commentary && Commentaries.Size() > tag && Commentaries[tag].IsNotEmpty()) + if (wt_commentary && Commentaries.Size() > (unsigned)tag && Commentaries[tag].IsNotEmpty()) { FSoundID id = soundEngine->FindSound(Commentaries[tag]); if (id == 0) diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index d63d6cfc0..7a2067c49 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -1120,7 +1120,7 @@ int spawn_r(int j, int pn) case SHIELD: case AIRTANK: case TRIPBOMBSPRITE: - case JETPACK: + case COWPIE: case HOLODUKE: case FIRSTGUNSPRITE: @@ -1142,7 +1142,7 @@ int spawn_r(int j, int pn) case BOOTS: case AMMO: case AMMOLOTS: - case COLA: + case BEER: case FIRSTAID: case SIXPAK: @@ -1224,7 +1224,7 @@ int spawn_r(int j, int pn) sp->xrepeat = 8; sp->yrepeat = 8; break; - case COLA: + case BEER: sp->xrepeat = 5; sp->yrepeat = 4; break; @@ -1242,7 +1242,7 @@ int spawn_r(int j, int pn) sp->xrepeat = 16; sp->yrepeat = 16; break; - case JETPACK: + case COWPIE: sp->xrepeat = 8; sp->yrepeat = 6; break; diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 9dbbbc151..3b352ab2b 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -8,6 +8,7 @@ extern spritetype sprite_s[]; BEGIN_DUKE_NS + // all the struct types from JFDuke's duke3d.h struct STATUSBARTYPE @@ -18,7 +19,7 @@ struct STATUSBARTYPE short firstaid_amount, steroids_amount, holoduke_amount, jetpack_amount; short heat_amount, scuba_amount, boot_amount; short last_weapon, weapon_pos, kickback_pic; - FixedBitArray gotweapon; // must be the same type as in player_struct + bool gotweapon[MAX_WEAPONS]; }; struct weaponhit @@ -50,7 +51,7 @@ struct weaponhit floorz = ceilingz = lastvx = lastvy = aflags = saved_ammo = 0; memset(temp_data, 0, sizeof(temp_data)); } - int GetIndex() const { return this - array(); } + int GetIndex() const { return int(this - array()); } // Wrapper around some ugliness. The 'owner' field gets abused by some actors, so better wrap its real use in access functions to keep things in order. inline weaponhit* GetOwner() @@ -171,8 +172,7 @@ struct player_struct uint16_t frags[MAXPLAYERS]; - // using a bit field for this to save a bit of space. - FixedBitArray gotweapon; + bool gotweapon[MAX_WEAPONS]; // Palette management uses indices into the engine's palette table now. PalEntry pals; diff --git a/source/games/exhumed/src/2d.cpp b/source/games/exhumed/src/2d.cpp index c6035b582..c11b8e4b6 100644 --- a/source/games/exhumed/src/2d.cpp +++ b/source/games/exhumed/src/2d.cpp @@ -137,10 +137,10 @@ void DrawRel(int tile, double x, double y, int shade) // this might be static within the DoPlasma function? static uint8_t* PlasmaBuffer; static int nPlasmaTile = kTile4092; -static unsigned int nSmokeBottom; -static unsigned int nSmokeRight; -static unsigned int nSmokeTop; -static unsigned int nSmokeLeft; +static int nSmokeBottom; +static int nSmokeRight; +static int nSmokeTop; +static int nSmokeLeft; static int nextPlasmaTic; static int plasma_A[5] = { 0 }; static int plasma_B[5] = { 0 }; @@ -313,7 +313,7 @@ void menu_DoPlasma() if (badOffset) continue; - unsigned int nSmokeOffset = 0; + int nSmokeOffset = 0; if (plasma_A[j]) { diff --git a/source/games/exhumed/src/bullet.cpp b/source/games/exhumed/src/bullet.cpp index 22ff887b2..a54d37fb1 100644 --- a/source/games/exhumed/src/bullet.cpp +++ b/source/games/exhumed/src/bullet.cpp @@ -644,8 +644,8 @@ int BuildBullet(short nSprite, int nType, int, int, int val1, int nAngle, int va nRepeat = 30; } - sprite[nBulletSprite].xrepeat = nRepeat; - sprite[nBulletSprite].yrepeat = nRepeat; + sprite[nBulletSprite].xrepeat = (uint8_t)nRepeat; + sprite[nBulletSprite].yrepeat = (uint8_t)nRepeat; sprite[nBulletSprite].xoffset = 0; sprite[nBulletSprite].yoffset = 0; sprite[nBulletSprite].ang = nAngle; diff --git a/source/games/exhumed/src/cd.cpp b/source/games/exhumed/src/cd.cpp index 9eb9c685a..d2fcab59d 100644 --- a/source/games/exhumed/src/cd.cpp +++ b/source/games/exhumed/src/cd.cpp @@ -48,11 +48,11 @@ bool playCDtrack(int nTrack, bool bLoop) // try ogg vorbis now from root directory. sprintf(filename, "exhumed%02d.ogg", nTrack); - if (!Mus_Play(nullptr, filename, true)) + if (!Mus_Play(filename, true)) { // try ogg vorbis now from GOG MUSIC subdirectory. sprintf(filename, "track%02d.ogg", nTrack); - Mus_Play(nullptr, filename, true); + Mus_Play(filename, true); } return true; } diff --git a/source/games/exhumed/src/cheats.cpp b/source/games/exhumed/src/cheats.cpp index 0dc38b898..d0de7c83b 100644 --- a/source/games/exhumed/src/cheats.cpp +++ b/source/games/exhumed/src/cheats.cpp @@ -203,18 +203,17 @@ static void cmd_Give(int player, uint8_t** stream, bool skip) if (buttons & kButtonCheatGuns) // LOBOCOP cheat { FillWeapons(player); - if (player == myconnectindex) StatusMessage(150, GStrings("TXT_EX_WEAPONS")); + if (player == myconnectindex) Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_WEAPONS")); } if (buttons & kButtonCheatKeys) // LOBOPICK cheat { PlayerList[player].keys = 0xFFFF; - if (player == myconnectindex) StatusMessage(150, GStrings("TXT_EX_KEYS")); - RefreshStatus(); + if (player == myconnectindex) Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_KEYS")); } if (buttons & kButtonCheatItems) // LOBOSWAG cheat { FillItems(player); - if (player == myconnectindex) StatusMessage(150, GStrings("TXT_EX_ITEMS")); + if (player == myconnectindex) Printf(PRINT_NOTIFY, "%s\n", GStrings("TXT_EX_ITEMS")); } } diff --git a/source/games/exhumed/src/exhumed.cpp b/source/games/exhumed/src/exhumed.cpp index 0c46756c0..354946b35 100644 --- a/source/games/exhumed/src/exhumed.cpp +++ b/source/games/exhumed/src/exhumed.cpp @@ -334,7 +334,7 @@ void GameInterface::Ticker() if (localInput.actions & SB_INVPREV) { - int nItem = nPlayerItem[nLocalPlayer]; + int nItem = PlayerList[nLocalPlayer].nItem; int i; for (i = 6; i > 0; i--) @@ -346,12 +346,12 @@ void GameInterface::Ticker() break; } - if (i > 0) SetPlayerItem(nLocalPlayer, nItem); + if (i > 0) PlayerList[nLocalPlayer].nItem = nItem; } if (localInput.actions & SB_INVNEXT) { - int nItem = nPlayerItem[nLocalPlayer]; + int nItem = PlayerList[nLocalPlayer].nItem; int i; for (i = 6; i > 0; i--) @@ -363,14 +363,14 @@ void GameInterface::Ticker() break; } - if (i > 0) SetPlayerItem(nLocalPlayer, nItem); + if (i > 0) PlayerList[nLocalPlayer].nItem = nItem; } if (localInput.actions & SB_INVUSE) { - if (nPlayerItem[nLocalPlayer] != -1) + if (PlayerList[nLocalPlayer].nItem != -1) { - localInput.setItemUsed(nPlayerItem[nLocalPlayer]); + localInput.setItemUsed(PlayerList[nLocalPlayer].nItem); } } @@ -482,10 +482,6 @@ static void SetTileNames() void GameInterface::app_init() { - int i; - //int esi = 1; - //int edi = esi; - #if 0 help_disabled = true; #endif @@ -510,9 +506,6 @@ void GameInterface::app_init() seq_LoadSequences(); InitStatus(); - for (i = 0; i < kMaxPlayers; i++) { - nPlayerLives[i] = kDefaultLives; - } resettiming(); GrabPalette(); diff --git a/source/games/exhumed/src/gameloop.cpp b/source/games/exhumed/src/gameloop.cpp index 644e45d1b..04142292e 100644 --- a/source/games/exhumed/src/gameloop.cpp +++ b/source/games/exhumed/src/gameloop.cpp @@ -168,7 +168,7 @@ void GameInterface::LevelCompleted(MapRecord *to_map, int skill) { if (to_map->levelNumber > nBestLevel) nBestLevel = to_map->levelNumber - 1; - if (to_map->gameflags & LEVEL_EX_COUNTDOWN) nPlayerLives[0] = 0; + if (to_map->gameflags & LEVEL_EX_COUNTDOWN) PlayerList[0].nLives = 0; if (to_map->gameflags & LEVEL_EX_TRAINING) { gameaction = ga_nextlevel; diff --git a/source/games/exhumed/src/grenade.cpp b/source/games/exhumed/src/grenade.cpp index b50c0506d..c8aaf60d7 100644 --- a/source/games/exhumed/src/grenade.cpp +++ b/source/games/exhumed/src/grenade.cpp @@ -259,7 +259,7 @@ void ExplodeGrenade(short nGrenade) short nDamage = BulletInfo[kWeaponGrenade].nDamage; - if (nPlayerDouble[nPlayer] > 0) { + if (PlayerList[nPlayer].nDouble > 0) { nDamage *= 2; } diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index c44154707..96576d205 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -104,12 +104,6 @@ void FillWeapons(short nPlayer) } CheckClip(nPlayer); - - if (nPlayer == nLocalPlayer) - { - short nWeapon = PlayerList[nPlayer].nCurrentWeapon; - SetCounter(PlayerList[nPlayer].nAmmo[nWeapon]); - } } void ResetPlayerWeapons(short nPlayer) @@ -172,20 +166,6 @@ void SetNewWeapon(short nPlayer, short nWeapon) } PlayerList[nPlayer].field_38 = nWeapon; - - if (nPlayer == nLocalPlayer) - { - int nCounter; - - if (nWeapon >= kWeaponSword && nWeapon <= kWeaponRing) { - nCounter = PlayerList[nPlayer].nAmmo[nWeapon]; - } - else { - nCounter = 0; - } - - SetCounterImmediate(nCounter); - } } void SetNewWeaponImmediate(short nPlayer, short nWeapon) @@ -247,21 +227,6 @@ void FireWeapon(short nPlayer) void SetWeaponStatus(short nPlayer) { - if (nPlayer != nLocalPlayer) - return; - - short nWeapon = PlayerList[nPlayer].nCurrentWeapon; - - if (nWeapon < 0) - { - nCounterBullet = -1; - SetCounterImmediate(0); - } - else - { - nCounterBullet = WeaponInfo[nWeapon].nAmmoType; - SetCounterImmediate(PlayerList[nPlayer].nAmmo[nCounterBullet]); - } } uint8_t WeaponCanFire(short nPlayer) @@ -391,7 +356,7 @@ void MoveWeapons(short nPlayer) short var_3C = WeaponInfo[nWeapon].b[eax] + SeqOffsets[nSeq]; - int var_1C = (nPlayerDouble[nPlayer] > 0) + 1; + int var_1C = (PlayerList[nPlayer].nDouble > 0) + 1; frames = var_1C - 1; @@ -764,7 +729,7 @@ loc_flag: { short nDamage = BulletInfo[kWeaponSword].nDamage; - if (nPlayerDouble[nPlayer]) { + if (PlayerList[nPlayer].nDouble) { nDamage *= 2; } @@ -883,7 +848,7 @@ loc_flag: case kWeaponMummified: { short nDamage = BulletInfo[kWeaponMummified].nDamage; - if (nPlayerDouble[nPlayer]) { + if (PlayerList[nPlayer].nDouble) { nDamage *= 2; } @@ -946,7 +911,7 @@ void DrawWeapons(double smooth) int8_t nShade = sector[initsect].ceilingshade; - int nDouble = nPlayerDouble[nLocalPlayer]; + int nDouble = PlayerList[nLocalPlayer].nDouble; int nPal = kPalNormal; if (nDouble) @@ -969,7 +934,7 @@ void DrawWeapons(double smooth) if (cl_hudinterpolation) { nBobAngle = interpolatedangle(buildang(obobangle), buildang(bobangle), smooth).asbuildf(); - nVal = interpolatedvaluef(ototalvel[nLocalPlayer], totalvel[nLocalPlayer], smooth, 17); + nVal = interpolatedvaluef(ototalvel[nLocalPlayer], totalvel[nLocalPlayer], smooth, 16) * 0.5; } else { diff --git a/source/games/exhumed/src/init.cpp b/source/games/exhumed/src/init.cpp index 031a057aa..1bd543b8f 100644 --- a/source/games/exhumed/src/init.cpp +++ b/source/games/exhumed/src/init.cpp @@ -185,7 +185,6 @@ void InitLevel(MapRecord* map) } EndLevel = 0; lastfps = 0; - InitStatus(); ResetView(); ResetEngine(); totalmoves = 0; @@ -195,9 +194,7 @@ void InitLevel(MapRecord* map) lPlayerYVel = 0; movefifopos = movefifoend; - RefreshStatus(); - - if (!mus_redbook && map->music.IsNotEmpty()) Mus_Play(map->labelName, map->music, true); // Allow non-CD music if defined for the current level + if (!mus_redbook && map->music.IsNotEmpty()) Mus_Play(map->music, true); // Allow non-CD music if defined for the current level playCDtrack(map->cdSongId, true); setLevelStarted(currentLevel); } diff --git a/source/games/exhumed/src/input.cpp b/source/games/exhumed/src/input.cpp index 83e5abc6f..1801b721c 100644 --- a/source/games/exhumed/src/input.cpp +++ b/source/games/exhumed/src/input.cpp @@ -84,10 +84,6 @@ void SendInput() void CheckKeys2() { - if (PlayerList[nLocalPlayer].nHealth <= 0) - { - SetAirFrame(); - } } diff --git a/source/games/exhumed/src/items.cpp b/source/games/exhumed/src/items.cpp index 25b2bb945..250f91c13 100644 --- a/source/games/exhumed/src/items.cpp +++ b/source/games/exhumed/src/items.cpp @@ -141,8 +141,8 @@ void BuildItemAnim(short nSprite) else { sprite[nSprite].owner = -1; - sprite[nSprite].yrepeat = nItemAnimInfo[nItem].repeat; - sprite[nSprite].xrepeat = nItemAnimInfo[nItem].repeat; + sprite[nSprite].yrepeat = (uint8_t)nItemAnimInfo[nItem].repeat; + sprite[nSprite].xrepeat = (uint8_t)nItemAnimInfo[nItem].repeat; } } @@ -172,18 +172,17 @@ void FillItems(short nPlayer) if (nPlayer == nLocalPlayer) { ItemFlash(); - SetMagicFrame(); } - if (nPlayerItem[nPlayer] == -1) { - SetPlayerItem(nPlayer, 0); + if (PlayerList[nPlayer].nItem == -1) { + PlayerList[nPlayer].nItem = 0; } } static bool UseEye(short nPlayer) { - if (nPlayerInvisible[nPlayer] >= 0) - nPlayerInvisible[nPlayer] = 900; + if (PlayerList[nPlayer].nInvisible >= 0) + PlayerList[nPlayer].nInvisible = 900; int nSprite = PlayerList[nPlayer].nSprite; @@ -208,7 +207,6 @@ static bool UseMask(short nPlayer) if (nPlayer == nLocalPlayer) { - SetAirFrame(); D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].nSprite); } return true; @@ -216,12 +214,12 @@ static bool UseMask(short nPlayer) bool UseTorch(short nPlayer) { - if (!nPlayerTorch[nPlayer]) + if (!PlayerList[nPlayer].nTorch) { SetTorch(nPlayer, 1); } - nPlayerTorch[nPlayer] = 900; + PlayerList[nPlayer].nTorch = 900; return true; } @@ -233,7 +231,6 @@ bool UseHeart(short nPlayer) if (nPlayer == nLocalPlayer) { ItemFlash(); - SetHealthFrame(1); D3PlayFX(StaticSound[kSound31], PlayerList[nPlayer].nSprite); } return true; @@ -258,7 +255,7 @@ bool UseScarab(short nPlayer) // faster firing static bool UseHand(short nPlayer) { - nPlayerDouble[nPlayer] = 1350; + PlayerList[nPlayer].nDouble = 1350; if (nPlayer == nLocalPlayer) { @@ -301,11 +298,6 @@ void UseItem(short nPlayer, short nItem) int nMagic = nItemMagic[nItem]; - if (nPlayer == nLocalPlayer) - { - BuildStatusAnim(156 + (nItemCount * 2), 0); - } - if (!nItemCount) { for (nItem = 0; nItem < 6; nItem++) @@ -321,11 +313,7 @@ void UseItem(short nPlayer, short nItem) } PlayerList[nPlayer].nMagic -= nMagic; - SetPlayerItem(nPlayer, nItem); - - if (nPlayer == nLocalPlayer) { - SetMagicFrame(); - } + PlayerList[nPlayer].nItem = nItem; } // TODO - bool return type? @@ -337,8 +325,8 @@ int GrabItem(short nPlayer, short nItem) PlayerList[nPlayer].items[nItem]++; - if (nPlayerItem[nPlayer] < 0 || nItem == nPlayerItem[nPlayer]) { - SetPlayerItem(nPlayer, nItem); + if (PlayerList[nPlayer].nItem < 0 || nItem == PlayerList[nPlayer].nItem) { + PlayerList[nPlayer].nItem = nItem; } return 1; @@ -476,9 +464,9 @@ void DoRegenerates() } sprite[nSprite].zvel = 0; - sprite[nSprite].yrepeat = sprite[nSprite].xvel; - sprite[nSprite].xrepeat = sprite[nSprite].xvel; - sprite[nSprite].pal = sprite[nSprite].yvel; + sprite[nSprite].yrepeat = (uint8_t)sprite[nSprite].xvel; + sprite[nSprite].xrepeat = (uint8_t)sprite[nSprite].xvel; + sprite[nSprite].pal = (uint8_t)sprite[nSprite].yvel; sprite[nSprite].yvel = sprite[nSprite].zvel; // setting to 0 sprite[nSprite].xvel = sprite[nSprite].zvel; // setting to 0 nRegenerates--; diff --git a/source/games/exhumed/src/lavadude.cpp b/source/games/exhumed/src/lavadude.cpp index 6be1de29c..e36fa7600 100644 --- a/source/games/exhumed/src/lavadude.cpp +++ b/source/games/exhumed/src/lavadude.cpp @@ -212,8 +212,8 @@ int BuildLava(short nSprite, int x, int y, int, short nSector, short nAngle, int void FuncLava(int a, int nDamage, int nRun) { - short nLava = RunData[nRun].nVal; - assert(nLava >= 0 && nLava < LavaList.Size()); + unsigned nLava = RunData[nRun].nVal; + assert(nLava < LavaList.Size()); short nAction = LavaList[nLava].nAction; short nSeq = LavadudeSeq[nAction].a + SeqOffsets[kSeqLavag]; diff --git a/source/games/exhumed/src/lighting.cpp b/source/games/exhumed/src/lighting.cpp index 3b8b62a8c..5429739aa 100644 --- a/source/games/exhumed/src/lighting.cpp +++ b/source/games/exhumed/src/lighting.cpp @@ -216,7 +216,7 @@ void AddFlash(short nSector, int x, int y, int z, int val) assert(nSector >= 0 && nSector < kMaxSectors); int var_28 = 0; - unsigned int var_1C = val >> 8; + int var_1C = val >> 8; if (var_1C >= nFlashDepth) { return; @@ -225,7 +225,7 @@ void AddFlash(short nSector, int x, int y, int z, int val) unsigned int var_20 = val & 0x80; unsigned int var_18 = val & 0x40; - val = ((var_1C + 1) << 8) | char(val); + val = ((var_1C + 1) << 8) | (val & 0xff); int var_14 = 0; @@ -387,7 +387,7 @@ void AddFlash(short nSector, int x, int y, int z, int val) shade = -127; } - sprite[nSprite].shade = shade; + sprite[nSprite].shade = (int8_t)shade; } } } @@ -462,12 +462,12 @@ void UndoFlashes() assert(pShade != NULL); - short var_2C = (*pShade) + 6; - int var_30 = sFlash[nFlash].shade; + int thisshade = (*pShade) + 6; + int maxshade = sFlash[nFlash].shade; - if (var_2C < var_30) + if (thisshade < maxshade) { - *pShade = var_2C; + *pShade = (int8_t)thisshade; edi = nFlash; continue; } diff --git a/source/games/exhumed/src/map.cpp b/source/games/exhumed/src/map.cpp index 80d7357cc..ba85c0746 100644 --- a/source/games/exhumed/src/map.cpp +++ b/source/games/exhumed/src/map.cpp @@ -40,7 +40,7 @@ void GrabMap() void UpdateMap() { - if (sector[initsect].ceilingpal != 3 || (nPlayerTorch[nLocalPlayer] != 0)) { + if (sector[initsect].ceilingpal != 3 || (PlayerList[nLocalPlayer].nTorch != 0)) { MarkSectorSeen(initsect); } } diff --git a/source/games/exhumed/src/move.cpp b/source/games/exhumed/src/move.cpp index fdd31dede..d9b6a4bb4 100644 --- a/source/games/exhumed/src/move.cpp +++ b/source/games/exhumed/src/move.cpp @@ -201,7 +201,6 @@ void MoveThings() actortime.Unclock(); } - MoveStatus(); DoBubbleMachines(); DoDrips(); DoMovingSects(); diff --git a/source/games/exhumed/src/movie.cpp b/source/games/exhumed/src/movie.cpp index b5c57a221..a184e03e8 100644 --- a/source/games/exhumed/src/movie.cpp +++ b/source/games/exhumed/src/movie.cpp @@ -154,7 +154,7 @@ public: uint8_t* pFrame = CurFrame; - int nRead = fp.Read(&yOffset, sizeof(yOffset)); + int nRead = (int)fp.Read(&yOffset, sizeof(yOffset)); nSize -= nRead; pFrame += yOffset * 200; // row position @@ -169,7 +169,7 @@ public: if (nPixels) { - int nRead = fp.Read(pFrame, nPixels); + int nRead = (int)fp.Read(pFrame, nPixels); pFrame += nRead; nSize -= nRead; } diff --git a/source/games/exhumed/src/namelist.h b/source/games/exhumed/src/namelist.h index 8d7076723..cad2b2f24 100644 --- a/source/games/exhumed/src/namelist.h +++ b/source/games/exhumed/src/namelist.h @@ -1,3 +1,13 @@ +x(Torch1, 338) +x(Torch2, 350) +x(TileRamsesGold, 590) +x(TileRamsesWorkTile, 591) +x(TileRamsesNormal, 592) +x(TileStatusBar, 657) +x(KeyIcon1, 675) +x(KeyIcon2, 679) +x(KeyIcon3, 683) +x(KeyIcon4, 687) x(CrosshairTile, 1579) x(SkullJaw, 3437) x(PowerslaveLogo, 3442) diff --git a/source/games/exhumed/src/names.h b/source/games/exhumed/src/names.h index ed087cf72..743ede805 100644 --- a/source/games/exhumed/src/names.h +++ b/source/games/exhumed/src/names.h @@ -20,12 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. enum { -kTorch1 = 338, -kTorch2 = 350, -kTileRamsesGold = 590, -kTileRamsesWorkTile = 591, -kTileRamsesNormal = 592, -kTileStatusBar = 657, kTile985 = 985, kTile986 = 986, kTile3000 = 3000, diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 7bc0d3fc3..3c25d47aa 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -41,6 +41,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS +extern short nStatusSeqOffset; + struct PlayerSave { int x; @@ -99,13 +101,8 @@ short nPlayerOldWeapon[kMaxPlayers]; short nPlayerClip[kMaxPlayers]; short nPlayerPushSound[kMaxPlayers]; short nTauntTimer[kMaxPlayers]; -short nPlayerTorch[kMaxPlayers]; uint16_t nPlayerWeapons[kMaxPlayers]; // each set bit represents a weapon the player has -short nPlayerLives[kMaxPlayers]; -short nPlayerItem[kMaxPlayers]; Player PlayerList[kMaxPlayers]; -short nPlayerInvisible[kMaxPlayers]; -short nPlayerDouble[kMaxPlayers]; short nPlayerViewSect[kMaxPlayers]; short nPlayerFloorSprite[kMaxPlayers]; PlayerSave sPlayerSave[kMaxPlayers]; @@ -219,12 +216,12 @@ void InitPlayerInventory(short nPlayer) { memset(&PlayerList[nPlayer], 0, sizeof(Player)); - nPlayerItem[nPlayer] = -1; + PlayerList[nPlayer].nItem = -1; nPlayerSwear[nPlayer] = 4; ResetPlayerWeapons(nPlayer); - nPlayerLives[nPlayer] = kDefaultLives; + PlayerList[nPlayer].nLives = kDefaultLives; PlayerList[nPlayer].nSprite = -1; PlayerList[nPlayer].nRun = -1; @@ -389,19 +386,19 @@ void RestartPlayer(short nPlayer) plr->invincibility = 0; } - nPlayerTorch[nPlayer] = 0; + PlayerList[nPlayer].nTorch = 0; plr->nMaskAmount = 0; SetTorch(nPlayer, 0); - nPlayerInvisible[nPlayer] = 0; + PlayerList[nPlayer].nInvisible = 0; plr->bIsFiring = 0; plr->field_3FOUR = 0; nPlayerViewSect[nPlayer] = sPlayerSave[nPlayer].nSector; plr->field_3A = 0; - nPlayerDouble[nPlayer] = 0; + PlayerList[nPlayer].nDouble = 0; plr->nSeq = kSeqJoe; @@ -415,7 +412,6 @@ void RestartPlayer(short nPlayer) plr->field_3C = 0; plr->nAir = 100; - airpages = 0; if (!(currentLevel->gameflags & LEVEL_EX_MULTI)) { @@ -454,7 +450,6 @@ void RestartPlayer(short nPlayer) { nLocalSpr = nSprite; - SetMagicFrame(); RestoreGreenPal(); plr->bPlayerPan = plr->bLockPan = false; @@ -467,10 +462,6 @@ void RestartPlayer(short nPlayer) nDeathType[nPlayer] = 0; nQuake[nPlayer] = 0; - - if (nPlayer == nLocalPlayer) { - SetHealthFrame(0); - } } int GrabPlayer() @@ -532,7 +523,7 @@ void StartDeathSeq(int nPlayer, int nVal) PlayerList[nPlayer].horizon.ohoriz = PlayerList[nPlayer].horizon.horiz = q16horiz(0); oeyelevel[nPlayer] = eyelevel[nPlayer] = -14080; - nPlayerInvisible[nPlayer] = 0; + PlayerList[nPlayer].nInvisible = 0; dVertPan[nPlayer] = 15; sprite[nSprite].cstat &= 0x7FFF; @@ -564,26 +555,16 @@ void StartDeathSeq(int nPlayer, int nVal) if (nTotalPlayers == 1) { - short nLives = nPlayerLives[nPlayer]; - - if (nLives > 0) { - BuildStatusAnim((3 * (nLives - 1)) + 7, 0); - } - if (!(currentLevel->gameflags & LEVEL_EX_TRAINING)) { // if not on the training level - nPlayerLives[nPlayer]--; + PlayerList[nPlayer].nLives--; } - if (nPlayerLives[nPlayer] < 0) { - nPlayerLives[nPlayer] = 0; + if (PlayerList[nPlayer].nLives < 0) { + PlayerList[nPlayer].nLives = 0; } } ototalvel[nPlayer] = totalvel[nPlayer] = 0; - - if (nPlayer == nLocalPlayer) { - RefreshStatus(); - } } int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount) @@ -605,13 +586,6 @@ int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount) PlayerList[nPlayer].nAmmo[nWeapon] = nAmmoAmount; - if (nPlayer == nLocalPlayer) - { - if (nWeapon == nCounterBullet) { - SetCounter(nAmmoAmount); - } - } - if (nWeapon == 1) { if (!nPistolClip[nPlayer]) { @@ -748,7 +722,6 @@ void FuncPlayer(int a, int nDamage, int nRun) if (nPlayer == nLocalPlayer) { TintPalette(nDamage, 0, 0); - SetHealthFrame(-1); } } @@ -846,10 +819,10 @@ void FuncPlayer(int a, int nDamage, int nRun) sprite[nPlayerSprite].picnum = seq_GetSeqPicnum(PlayerList[nPlayer].nSeq, PlayerSeq[nHeightTemplate[nAction]].a, var_EC); sprite[nDopple].picnum = sprite[nPlayerSprite].picnum; - if (nPlayerTorch[nPlayer] > 0) + if (PlayerList[nPlayer].nTorch > 0) { - nPlayerTorch[nPlayer]--; - if (nPlayerTorch[nPlayer] == 0) + PlayerList[nPlayer].nTorch--; + if (PlayerList[nPlayer].nTorch == 0) { SetTorch(nPlayer, 0); } @@ -866,18 +839,18 @@ void FuncPlayer(int a, int nDamage, int nRun) } } - if (nPlayerDouble[nPlayer] > 0) + if (PlayerList[nPlayer].nDouble > 0) { - nPlayerDouble[nPlayer]--; - if (nPlayerDouble[nPlayer] == 150 && nPlayer == nLocalPlayer) { + PlayerList[nPlayer].nDouble--; + if (PlayerList[nPlayer].nDouble == 150 && nPlayer == nLocalPlayer) { PlayAlert("WEAPON POWER IS ABOUT TO EXPIRE"); } } - if (nPlayerInvisible[nPlayer] > 0) + if (PlayerList[nPlayer].nInvisible > 0) { - nPlayerInvisible[nPlayer]--; - if (nPlayerInvisible[nPlayer] == 0) + PlayerList[nPlayer].nInvisible--; + if (PlayerList[nPlayer].nInvisible == 0) { sprite[nPlayerSprite].cstat &= 0x7FFF; // set visible short nFloorSprite = nPlayerFloorSprite[nPlayerSprite]; @@ -886,7 +859,7 @@ void FuncPlayer(int a, int nDamage, int nRun) sprite[nFloorSprite].cstat &= 0x7FFF; // set visible } } - else if (nPlayerInvisible[nPlayer] == 150 && nPlayer == nLocalPlayer) + else if (PlayerList[nPlayer].nInvisible == 150 && nPlayer == nLocalPlayer) { PlayAlert("INVISIBILITY IS ABOUT TO EXPIRE"); } @@ -1266,13 +1239,8 @@ sectdone: // if underwater if (var_5C) { - airpages = 1; if (PlayerList[nPlayer].nMaskAmount > 0) { - if (nPlayer == nLocalPlayer) { - BuildStatusAnim(132, 0); - } - D3PlayFX(StaticSound[kSound30], nPlayerSprite); PlayerList[nPlayer].nAir = 100; @@ -1293,11 +1261,6 @@ sectdone: StartDeathSeq(nPlayer, 0); } - if (nPlayer == nLocalPlayer) - { - SetHealthFrame(-1); - } - PlayerList[nPlayer].nAir = 0; if (PlayerList[nPlayer].nHealth < 300) @@ -1312,16 +1275,6 @@ sectdone: } DoBubbles(nPlayer); - SetAirFrame(); - } - else - { - if (nPlayer == nLocalPlayer) - { - BuildStatusAnim(132, 0); - } - - airpages = 0; } } } @@ -1329,9 +1282,9 @@ sectdone: // loc_1B0B9 if (var_5C) // if underwater { - if (nPlayerTorch[nPlayer] > 0) + if (PlayerList[nPlayer].nTorch > 0) { - nPlayerTorch[nPlayer] = 0; + PlayerList[nPlayer].nTorch = 0; SetTorch(nPlayer, 0); } } @@ -1358,23 +1311,15 @@ sectdone: nBreathTimer[nPlayer] = 1; } - airpages = 0; - nBreathTimer[nPlayer]--; if (nBreathTimer[nPlayer] <= 0) { nBreathTimer[nPlayer] = 90; - if (nPlayer == nLocalPlayer) - { - // animate lungs - BuildStatusAnim(132, 0); - } } if (PlayerList[nPlayer].nAir < 100) { PlayerList[nPlayer].nAir = 100; - SetAirFrame(); } } @@ -1429,11 +1374,11 @@ sectdone: int var_44 = 0; // item lotags start at 6 (1-5 reserved?) so 0-offset them - int var_6C = var_70 - 6; + int itemtype = var_70 - 6; - if (var_6C <= 54) + if (itemtype <= 54) { - switch (var_6C) + switch (itemtype) { do_default: default: @@ -1595,11 +1540,6 @@ do_default_b: } } - if (nLocalPlayer == nPlayer) - { - SetHealthFrame(1); - } - if (var_70 == 12) { sprite[nValB].hitag = 0; @@ -1669,11 +1609,6 @@ do_default_b: } } - if (nLocalPlayer == nPlayer) - { - SetHealthFrame(1); - } - if (var_70 == 12) { sprite[nValB].hitag = 0; @@ -1743,11 +1678,6 @@ do_default_b: } } - if (nLocalPlayer == nPlayer) - { - SetHealthFrame(1); - } - if (var_70 == 12) { sprite[nValB].hitag = 0; @@ -1800,8 +1730,6 @@ do_default_b: PlayerList[nPlayer].nAir = 100; // TODO - constant } - SetAirFrame(); - if (nBreathTimer[nPlayer] < 89) { D3PlayFX(StaticSound[kSound13], nPlayerSprite); @@ -1869,15 +1797,11 @@ do_default_b: { var_88 = -1; - if (nPlayerLives[nPlayer] >= kMaxPlayerLives) { + if (PlayerList[nPlayer].nLives >= kMaxPlayerLives) { break; } - nPlayerLives[nPlayer]++; - - if (nPlayer == nLocalPlayer) { - BuildStatusAnim(146 + ((nPlayerLives[nPlayer] - 1) * 2), 0); - } + PlayerList[nPlayer].nLives++; var_8C = 32; var_44 = 32; @@ -2276,98 +2200,18 @@ do_default_b: break; } - // Lots of repeated code for door key handling case 39: // Power key - { - int ecx = 4096; - - var_88 = -1; - - if (PlayerList[nPlayer].keys != ecx) - { - if (nPlayer == nLocalPlayer) { - BuildStatusAnim(36, 0); - } - - PlayerList[nPlayer].keys |= ecx; - - if (nTotalPlayers > 1) - { - goto do_default_b; - } - else - { - goto do_default; - } - } - - break; - } case 40: // Time key - { - int ecx = 4096 << 1; - - var_88 = -1; - - if (PlayerList[nPlayer].keys != ecx) - { - if (nPlayer == nLocalPlayer) { - BuildStatusAnim(36 + 2, 0); - } - - PlayerList[nPlayer].keys |= ecx; - - if (nTotalPlayers > 1) - { - goto do_default_b; - } - else - { - goto do_default; - } - } - - break; - } case 41: // War key - { - int ecx = 4096 << 2; - - var_88 = -1; - - if (PlayerList[nPlayer].keys != ecx) - { - if (nPlayer == nLocalPlayer) { - BuildStatusAnim(36 + 4, 0); - } - - PlayerList[nPlayer].keys |= ecx; - - if (nTotalPlayers > 1) - { - goto do_default_b; - } - else - { - goto do_default; - } - } - - break; - } case 42: // Earth key { - int ecx = 4096 << 3; + int keybit = 4096 << (itemtype - 39); var_88 = -1; - if (PlayerList[nPlayer].keys != ecx) + if (!(PlayerList[nPlayer].keys & keybit)) { - if (nPlayer == nLocalPlayer) { - BuildStatusAnim(36 + 6, 0); - } - - PlayerList[nPlayer].keys |= ecx; + PlayerList[nPlayer].keys |= keybit; if (nTotalPlayers > 1) { @@ -2396,11 +2240,6 @@ do_default_b: PlayerList[nPlayer].nMagic = 1000; } - if (nLocalPlayer == nPlayer) - { - SetMagicFrame(); - } - goto do_default; } @@ -2679,7 +2518,7 @@ loc_1BD2E: PlayerList[nPlayer].nCurrentWeapon = nPlayerOldWeapon[nPlayer]; - if (nPlayerLives[nPlayer] && nNetTime) + if (PlayerList[nPlayer].nLives && nNetTime) { if (nAction != 20) { @@ -2840,6 +2679,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, Player& w, Player* ("invincible", w.invincibility) ("air", w.nAir) ("seq", w.nSeq) + ("item", w.nItem) ("maskamount", w.nMaskAmount) ("keys", w.keys) ("magic", w.nMagic) @@ -2854,6 +2694,10 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, Player& w, Player* ("seq", w.nSeq) ("horizon", w.horizon) ("angle", w.angle) + ("lives", w.nLives) + ("double", w.nDouble) + ("invisible", w.nInvisible) + ("torch", w.nTorch) .EndObject(); } return arc; @@ -2902,13 +2746,8 @@ void SerializePlayer(FSerializer& arc) .Array("clip", nPlayerClip, PlayerCount) .Array("pushsound", nPlayerPushSound, PlayerCount) .Array("taunttimer", nTauntTimer, PlayerCount) - .Array("torch", nPlayerTorch, PlayerCount) .Array("weapons", nPlayerWeapons, PlayerCount) - .Array("lives", nPlayerLives, PlayerCount) - .Array("item", nPlayerItem, PlayerCount) .Array("list", PlayerList, PlayerCount) - .Array("invisible", nPlayerInvisible, PlayerCount) - .Array("double", nPlayerDouble, PlayerCount) .Array("viewsect", nPlayerViewSect, PlayerCount) .Array("floorspr", nPlayerFloorSprite, PlayerCount) .Array("save", sPlayerSave, PlayerCount) @@ -2916,9 +2755,59 @@ void SerializePlayer(FSerializer& arc) .Array("eyelevel", eyelevel, PlayerCount) .Array("netstartsprite", nNetStartSprite, PlayerCount) .Array("grenade", nPlayerGrenade, PlayerCount) - .Array("d282a", word_D282A, PlayerCount) - .EndObject(); + .Array("d282a", word_D282A, PlayerCount); + arc.EndObject(); } } + +DEFINE_FIELD_X(ExhumedPlayer, Player, nHealth); +DEFINE_FIELD_X(ExhumedPlayer, Player, nLives); +DEFINE_FIELD_X(ExhumedPlayer, Player, nDouble); +DEFINE_FIELD_X(ExhumedPlayer, Player, nInvisible); +DEFINE_FIELD_X(ExhumedPlayer, Player, nTorch); +DEFINE_FIELD_X(ExhumedPlayer, Player, field_2); +DEFINE_FIELD_X(ExhumedPlayer, Player, nAction); +DEFINE_FIELD_X(ExhumedPlayer, Player, nSprite); +DEFINE_FIELD_X(ExhumedPlayer, Player, bIsMummified); +DEFINE_FIELD_X(ExhumedPlayer, Player, invincibility); +DEFINE_FIELD_X(ExhumedPlayer, Player, nAir); +DEFINE_FIELD_X(ExhumedPlayer, Player, nSeq); +DEFINE_FIELD_X(ExhumedPlayer, Player, nMaskAmount); +DEFINE_FIELD_X(ExhumedPlayer, Player, keys); +DEFINE_FIELD_X(ExhumedPlayer, Player, nMagic); +DEFINE_FIELD_X(ExhumedPlayer, Player, nItem); +DEFINE_FIELD_X(ExhumedPlayer, Player, items); +DEFINE_FIELD_X(ExhumedPlayer, Player, nAmmo); // TODO - kMaxWeapons? +DEFINE_FIELD_X(ExhumedPlayer, Player, pad); + +DEFINE_FIELD_X(ExhumedPlayer, Player, nCurrentWeapon); +DEFINE_FIELD_X(ExhumedPlayer, Player, field_3FOUR); +DEFINE_FIELD_X(ExhumedPlayer, Player, bIsFiring); +DEFINE_FIELD_X(ExhumedPlayer, Player, field_38); +DEFINE_FIELD_X(ExhumedPlayer, Player, field_3A); +DEFINE_FIELD_X(ExhumedPlayer, Player, field_3C); +DEFINE_FIELD_X(ExhumedPlayer, Player, nRun); +DEFINE_FIELD_X(ExhumedPlayer, Player, bPlayerPan); +DEFINE_FIELD_X(ExhumedPlayer, Player, bLockPan); + +DEFINE_ACTION_FUNCTION(_Exhumed, GetViewPlayer) +{ + ACTION_RETURN_POINTER(&PlayerList[nLocalPlayer]); +} + +DEFINE_ACTION_FUNCTION(_ExhumedPlayer, IsUnderwater) +{ + PARAM_SELF_STRUCT_PROLOGUE(Player); + auto nLocalPlayer = self - PlayerList; + ACTION_RETURN_BOOL(SectFlag[nPlayerViewSect[nLocalPlayer]] & kSectUnderwater); +} + +DEFINE_ACTION_FUNCTION(_ExhumedPlayer, GetAngle) +{ + PARAM_SELF_STRUCT_PROLOGUE(Player); + ACTION_RETURN_INT(sprite[self->nSprite].ang); +} + + END_PS_NS diff --git a/source/games/exhumed/src/player.h b/source/games/exhumed/src/player.h index 0715cdbd2..cf63e6d26 100644 --- a/source/games/exhumed/src/player.h +++ b/source/games/exhumed/src/player.h @@ -50,6 +50,10 @@ extern int lPlayerYVel; struct Player { short nHealth; + short nLives; + short nDouble; + short nInvisible; + short nTorch; short field_2; short nAction; short nSprite; @@ -60,7 +64,8 @@ struct Player short nMaskAmount; uint16_t keys; short nMagic; - char items[8]; + short nItem; + uint8_t items[8]; short nAmmo[7]; // TODO - kMaxWeapons? short pad[2]; @@ -80,13 +85,8 @@ struct Player extern short PlayerCount; -extern short nPlayerTorch[]; - extern short nPlayerLives[]; -extern short nPlayerItem[]; extern Player PlayerList[]; -extern short nPlayerInvisible[]; -extern short nPlayerDouble[]; extern short nPlayerViewSect[]; extern short nPlayerFloorSprite[]; diff --git a/source/games/exhumed/src/ramses.cpp b/source/games/exhumed/src/ramses.cpp index 404e9e281..270006fad 100644 --- a/source/games/exhumed/src/ramses.cpp +++ b/source/games/exhumed/src/ramses.cpp @@ -150,7 +150,7 @@ void InitSpiritHead() } else { - nPupData = headfd.Read(cPupData, sizeof(cPupData)); + nPupData = (int)headfd.Read(cPupData, sizeof(cPupData)); pPupData = cPupData; } nMouthTile = 0; @@ -383,13 +383,13 @@ void DoSpiritHead() { sprite[nSpiritSprite].xrepeat -= 2; if (sprite[nSpiritSprite].xrepeat < nSpiritRepeatX) - sprite[nSpiritSprite].xrepeat = nSpiritRepeatX; + sprite[nSpiritSprite].xrepeat = (uint8_t)nSpiritRepeatX; } if (sprite[nSpiritSprite].yrepeat > nSpiritRepeatY) { sprite[nSpiritSprite].yrepeat -= 2; if (sprite[nSpiritSprite].yrepeat < nSpiritRepeatY) - sprite[nSpiritSprite].yrepeat = nSpiritRepeatY; + sprite[nSpiritSprite].yrepeat = (uint8_t)nSpiritRepeatY; } int nCount = 0; diff --git a/source/games/exhumed/src/save.cpp b/source/games/exhumed/src/save.cpp index e51bc81a5..0c2f218d8 100644 --- a/source/games/exhumed/src/save.cpp +++ b/source/games/exhumed/src/save.cpp @@ -133,7 +133,6 @@ void GameInterface::SerializeGameState(FSerializer& arc) } Mus_ResumeSaved(); - RefreshStatus(); } } diff --git a/source/games/exhumed/src/sequence.cpp b/source/games/exhumed/src/sequence.cpp index d6315508b..39414e89e 100644 --- a/source/games/exhumed/src/sequence.cpp +++ b/source/games/exhumed/src/sequence.cpp @@ -421,7 +421,7 @@ int seq_DrawGunSequence(int nSeqOffset, short dx, double xOffs, double yOffs, in nShade = -100; double alpha = 1; - if (nPlayerInvisible[nLocalPlayer]) { + if (PlayerList[nLocalPlayer].nInvisible) { alpha = 0.3; } @@ -503,12 +503,12 @@ int seq_PlotArrowSequence(short nSprite, short nSeq, int nVal) if (ChunkFlag[nFrameBase] & 1) { - pTSprite->xoffset = ChunkXpos[nFrameBase]; + pTSprite->xoffset = (int8_t)ChunkXpos[nFrameBase]; pTSprite->cstat |= 4; } else { - pTSprite->xoffset = -ChunkXpos[nFrameBase]; + pTSprite->xoffset = (int8_t)-ChunkXpos[nFrameBase]; } pTSprite->yoffset = -ChunkYpos[nFrameBase]; @@ -588,7 +588,7 @@ int seq_PlotSequence(short nSprite, short edx, short nFrame, short ecx) if (ChunkFlag[nBase] & 1) { - tsp->xoffset = ChunkXpos[nBase]; + tsp->xoffset = (int8_t)ChunkXpos[nBase]; tsp->cstat |= 4; // x-flipped } else diff --git a/source/games/exhumed/src/snake.cpp b/source/games/exhumed/src/snake.cpp index 72e1e20c9..72985f612 100644 --- a/source/games/exhumed/src/snake.cpp +++ b/source/games/exhumed/src/snake.cpp @@ -94,7 +94,7 @@ void ExplodeSnakeSprite(int nSprite, short nPlayer) { short nDamage = BulletInfo[kWeaponStaff].nDamage; - if (nPlayerDouble[nPlayer] > 0) { + if (PlayerList[nPlayer].nDouble > 0) { nDamage *= 2; } diff --git a/source/games/exhumed/src/sound.cpp b/source/games/exhumed/src/sound.cpp index 3504bc2f6..3cf70cab7 100644 --- a/source/games/exhumed/src/sound.cpp +++ b/source/games/exhumed/src/sound.cpp @@ -455,9 +455,9 @@ void EXSoundEngine::CalcPosVel(int type, const void* source, const float pt[3], else if (type == SOURCE_Swirly) { int which = *(int*)source; - float phase = (PlayClock << (4 + which)) * BAngRadian; - pos->X = fcampos.X + 256 * cos(phase); - pos->Z = fcampos.Z + 256 * sin(phase); + double phase = (PlayClock << (4 + which)) * BAngRadian; + pos->X = fcampos.X + float(256 * cos(phase)); + pos->Z = fcampos.Z + float(256 * sin(phase)); } else if (type == SOURCE_EXBoss) { @@ -518,7 +518,7 @@ void GameInterface::UpdateSounds() } auto fv = GetSoundPos(&pos); SoundListener listener; - listener.angle = -ang * BAngRadian; // Build uses a period of 2048. + listener.angle = float(-ang * BAngRadian); // Build uses a period of 2048. listener.velocity.Zero(); listener.position = GetSoundPos(&pos); listener.underwater = false; @@ -636,7 +636,7 @@ void PlayFX2(unsigned short nSound, short nSprite, int sectf, EChanFlags chanfla FSoundChan* chan = nullptr; if (nSprite >= 0) { - chan = soundEngine->StartSound(SOURCE_Actor, &sprite[nSprite], nullptr, CHAN_BODY, chanflags| CHANF_OVERLAP, nSound+1, nVolume / 255.f,fullvol? 0.5 : ATTN_NORM, nullptr, (11025 + nPitch) / 11025.f); + chan = soundEngine->StartSound(SOURCE_Actor, &sprite[nSprite], nullptr, CHAN_BODY, chanflags| CHANF_OVERLAP, nSound+1, nVolume / 255.f,fullvol? 0.5f : ATTN_NORM, nullptr, (11025 + nPitch) / 11025.f); } else { diff --git a/source/games/exhumed/src/status.cpp b/source/games/exhumed/src/status.cpp index 1864e6191..8305c74a8 100644 --- a/source/games/exhumed/src/status.cpp +++ b/source/games/exhumed/src/status.cpp @@ -1,32 +1,35 @@ //------------------------------------------------------------------------- /* -Copyright (C) 2010-2019 EDuke32 developers and contributors -Copyright (C) 2019 sirlemonhead, Nuke.YKT -This file is part of PCExhumed. -PCExhumed is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License version 2 -as published by the Free Software Foundation. +Copyright (C) 2020-2021 Christoph Oelckers + +This file is part of Raze. + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +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 General Public License for more details. + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ //------------------------------------------------------------------------- + #include "ns.h" #include "engine.h" #include "player.h" -#include "aistuff.h" #include "status.h" #include "exhumed.h" #include "sequence.h" #include "names.h" #include "view.h" #include "v_2ddrawer.h" -#include "multipatchtexture.h" -#include "texturemanager.h" #include "statusbar.h" #include "v_draw.h" #include "automap.h" @@ -40,940 +43,80 @@ BEGIN_PS_NS // All this must be moved into the status bar once it is made persistent! -const int kMaxStatusAnims = 50; - short nStatusSeqOffset; -short nHealthFrames; -short nMagicFrames; - -short nHealthLevel; -short nMagicLevel; -short nHealthFrame; -short nMagicFrame; - -short nMaskY; - -int magicperline; -int airperline; -int healthperline; -int nAirFrames; -int nCounter; -int nCounterDest; - -short nItemFrames; - -int16_t nItemSeq; -short nDigit[3]; - -short nItemFrame; -short nMeterRange; - -short airframe; - -int16_t nFirstAnim; -int16_t nLastAnim; -short nItemAltSeq; - -short airpages = 0; - -short ammodelay = 3; - -short nCounterBullet = -1; - - -// 8 bytes -struct statusAnim -{ - int16_t s1; - int16_t s2; -// int16_t nPage; - int8_t nPrevAnim; - int8_t nNextAnim; - uint8_t StatusAnimFlags; -}; - -FreeListArray StatusAnim; - -short nItemSeqOffset[] = {91, 72, 76, 79, 68, 87, 83}; - -void SetCounterDigits(); -void SetItemSeq(); -void SetItemSeq2(int nSeqOffset); -void DestroyStatusAnim(short nAnim); - -FSerializer& Serialize(FSerializer& arc, const char* keyname, statusAnim& w, statusAnim* def) -{ - if (arc.BeginObject(keyname)) - { - arc("s1", w.s1) - ("s2", w.s2) - ("prev", w.nPrevAnim) - ("next", w.nNextAnim) - ("flags", w.StatusAnimFlags) - .EndObject(); - } - return arc; -} - void InitStatus() { nStatusSeqOffset = SeqOffsets[kSeqStatus]; - nHealthFrames = SeqSize[nStatusSeqOffset + 1]; - int nPicNum = seq_GetSeqPicnum(kSeqStatus, 1, 0); - nMagicFrames = SeqSize[nStatusSeqOffset + 129]; - nHealthFrame = 0; - nMagicFrame = 0; - nHealthLevel = 0; - nMagicLevel = 0; - nMeterRange = tileHeight(nPicNum); - magicperline = 1000 / nMeterRange; - healthperline = 800 / nMeterRange; - nAirFrames = SeqSize[nStatusSeqOffset + 133]; - airperline = 100 / nAirFrames; - nCounter = 0; - nCounterDest = 0; - - memset(nDigit, 0, sizeof(nDigit)); - - SetCounter(0); - SetHealthFrame(0); - SetMagicFrame(); - - StatusAnim.Clear(); - - nLastAnim = -1; - nFirstAnim = -1; - nItemSeq = -1; -} - -int ItemTimer(int num, int plr) -{ - switch (num) { - case 1: //Scarab item - return (PlayerList[plr].invincibility * 100) / 900; - case 3: //Hand item - return (nPlayerDouble[plr] * 100) / 1350; - case 5: //Mask - return (PlayerList[plr].nMaskAmount * 100) / 1350; - case 4: //Invisible - return (nPlayerInvisible[plr] * 100) / 900; - case 2: //Torch - return (nPlayerTorch[plr] * 100) / 900; - } - - return -1; -} - -int BuildStatusAnim(int val, int nFlags) -{ - // destroy this anim if it already exists - for (int i = nFirstAnim; i >= 0; i = StatusAnim[i].nPrevAnim) - { - if (StatusAnim[i].s1 == val) { - DestroyStatusAnim(i); - break; - } - } - - int nStatusAnim = StatusAnim.Get(); - - StatusAnim[nStatusAnim].nPrevAnim = -1; - StatusAnim[nStatusAnim].nNextAnim = nLastAnim; - - if (nLastAnim < 0) { - nFirstAnim = nStatusAnim; - } - else { - StatusAnim[nLastAnim].nPrevAnim = nStatusAnim; - } - - nLastAnim = nStatusAnim; - - StatusAnim[nStatusAnim].s1 = val; - StatusAnim[nStatusAnim].s2 = 0; - StatusAnim[nStatusAnim].StatusAnimFlags = nFlags; - return nStatusAnim; -} - -void RefreshStatus() -{ - short nLives = nPlayerLives[nLocalPlayer]; - if (nLives < 0 || nLives > kMaxPlayerLives) { - //Error("illegal value for nPlayerLives #%d\n", nLocalPlayer); - nLives = 0; - } - - // draws the red dots that indicate the lives amount - BuildStatusAnim(145 + (2 * nLives), 0); - - uint16_t nKeys = PlayerList[nLocalPlayer].keys; - - int val = 37; - - for (int i = 0; i < 4; i++) - { - if (nKeys & 0x1000) { - BuildStatusAnim(val, 0); - } - - nKeys >>= 1; - val += 2; - } - - SetPlayerItem(nLocalPlayer, nPlayerItem[nLocalPlayer]); - SetHealthFrame(0); - SetMagicFrame(); - SetAirFrame(); -} - -void MoveStatusAnims() -{ - for (int i = nFirstAnim; i >= 0; i = StatusAnim[i].nPrevAnim) - { - seq_MoveSequence(-1, nStatusSeqOffset + StatusAnim[i].s1, StatusAnim[i].s2); - - StatusAnim[i].s2++; - - short nSize = SeqSize[nStatusSeqOffset + StatusAnim[i].s1]; - - if (StatusAnim[i].s2 >= nSize) - { - if (StatusAnim[i].StatusAnimFlags & 0x10) { - StatusAnim[i].s2 = 0; - } - else { - StatusAnim[i].s2 = nSize - 1; // restart it - } - } - } -} - -void DestroyStatusAnim(short nAnim) -{ - int8_t nPrev = StatusAnim[nAnim].nPrevAnim; - int8_t nNext = StatusAnim[nAnim].nNextAnim; - - if (nNext >= 0) { - StatusAnim[nNext].nPrevAnim = nPrev; - } - - if (nPrev >= 0) { - StatusAnim[nPrev].nNextAnim = nNext; - } - - if (nAnim == nFirstAnim) { - nFirstAnim = nPrev; - } - - if (nAnim == nLastAnim) { - nLastAnim = nNext; - } - - StatusAnim.Release(nAnim); -} - -void SetMagicFrame() -{ - nMagicLevel = (1000 - PlayerList[nLocalPlayer].nMagic) / magicperline; - - if (nMagicLevel >= nMeterRange) { - nMagicLevel = nMeterRange - 1; - } - - if (nMagicLevel < 0) { - nMagicLevel = 0; - } - - SetItemSeq(); -} - -void SetHealthFrame(short nVal) -{ - nHealthLevel = (800 - PlayerList[nLocalPlayer].nHealth) / healthperline; - - if (nHealthLevel >= nMeterRange ) { - nHealthLevel = nMeterRange - 1; - } - - if (nHealthLevel < 0) { - nHealthLevel = 0; - } - - if (nVal < 0) { - BuildStatusAnim(4, 0); - } -} - -void SetAirFrame() -{ - airframe = PlayerList[nLocalPlayer].nAir / airperline; - - if (airframe >= nAirFrames) - { - airframe = nAirFrames - 1; - } - else if (airframe < 0) - { - airframe = 0; - } -} - -void SetCounter(short nVal) -{ - if (nVal <= 999) - { - if (nVal < 0) { - nVal = 0; - } - } - else { - nVal = 999; - } - - nCounterDest = nVal; -} - -void SetCounterImmediate(short nVal) -{ - SetCounter(nVal); - nCounter = nCounterDest; - - SetCounterDigits(); -} - -void SetCounterDigits() -{ - nDigit[2] = 3 * (nCounter / 100 % 10); - nDigit[1] = 3 * (nCounter / 10 % 10); - nDigit[0] = 3 * (nCounter % 10); -} - -void SetItemSeq() -{ - short nItem = nPlayerItem[nLocalPlayer]; - if (nItem < 0) - { - nItemSeq = -1; - return; - } - - short nOffset = nItemSeqOffset[nItem]; - - SetItemSeq2(nOffset); -} - -void SetItemSeq2(int nSeqOffset) -{ - short nItem = nPlayerItem[nLocalPlayer]; - - if (nItemMagic[nItem] <= PlayerList[nLocalPlayer].nMagic) { - nItemAltSeq = 0; - } - else { - nItemAltSeq = 2; - } - - nItemFrame = 0; - nItemSeq = nSeqOffset + nItemAltSeq; - nItemFrames = SeqSize[nItemSeq + nStatusSeqOffset]; -} - -void SetPlayerItem(short nPlayer, short nItem) -{ - nPlayerItem[nPlayer] = nItem; - - if (nPlayer == nLocalPlayer) - { - SetItemSeq(); - if (nItem >= 0) { - BuildStatusAnim(156 + (2 * PlayerList[nLocalPlayer].items[nItem]), 0); - } - } -} - -void MoveStatus() -{ - if (nItemSeq >= 0) - { - nItemFrame++; - - if (nItemFrame >= nItemFrames) - { - if (nItemSeq == 67) { - SetItemSeq(); - } - else - { - nItemSeq -= nItemAltSeq; - - if (nItemAltSeq || totalmoves & 0x1F) - { - if (nItemSeq < 2) { - nItemAltSeq = 0; - } - } - else - { - nItemAltSeq = 1; - } - - nItemFrame = 0; - nItemSeq += nItemAltSeq; - nItemFrames = SeqSize[nStatusSeqOffset + nItemSeq]; - } - } - } - - nHealthFrame++; - if (nHealthFrame >= nHealthFrames) { - nHealthFrame = 0; - } - - nMagicFrame++; - if (nMagicFrame >= nMagicFrames) { - nMagicFrame = 0; - } - - MoveStatusAnims(); - - if (nCounter == nCounterDest) - { - nCounter = nCounterDest; - ammodelay = 3; - return; - } - else - { - ammodelay--; - if (ammodelay > 0) { - return; - } - } - - int eax = nCounterDest - nCounter; - - if (eax <= 0) - { - if (eax >= -30) - { - for (int i = 0; i < 3; i++) - { - nDigit[i]--; - - if (nDigit[i] < 0) - { - nDigit[i] += 30; - } - - if (nDigit[i] < 27) { - break; - } - } - } - else - { - nCounter += (nCounterDest - nCounter) >> 1; - SetCounterDigits(); - return; - } - } - else - { - if (eax <= 30) - { - for (int i = 0; i < 3; i++) - { - nDigit[i]++; - - if (nDigit[i] <= 27) { - break; - } - - if (nDigit[i] >= 30) { - nDigit[i] -= 30; - } - } - } - else - { - nCounter += (nCounterDest - nCounter) >> 1; - SetCounterDigits(); - return; - } - } - - if (!(nDigit[0] % 3)) { - nCounter = nDigit[0] / 3 + 100 * (nDigit[2] / 3) + 10 * (nDigit[1] / 3); - } - - eax = nCounterDest - nCounter; - if (eax < 0) { - eax = -eax; - } - - ammodelay = 4 - (eax >> 1); - if (ammodelay < 1) { - ammodelay = 1; - } } -class DExhumedStatusBar : public DBaseStatusBar +//--------------------------------------------------------------------------- +// +// This is to hide the dirt from the script code. +// These sequence arrays later need to be refactored +// if this is ever supposed to become a useful feature, +// so hide the dirty internals behind a handful of functions. +// +//--------------------------------------------------------------------------- + +struct ChunkFrame { - DECLARE_CLASS(DExhumedStatusBar, DBaseStatusBar) - HAS_OBJECT_POINTERS + FTextureID tex; + int x, y; + int flags; - TObjPtr textfont, numberFont; - -public: - DExhumedStatusBar() + void GetChunkFrame(int nFrameBase) { - textfont = Create(SmallFont, 1, Off, 1, 1 ); - numberFont = Create(BigFont, 0, Off, 1, 1 ); - } - -private: - - //--------------------------------------------------------------------------- - // - // draws a sequence animation to the status bar - // - //--------------------------------------------------------------------------- - - void DrawStatusSequence(short nSequence, uint16_t edx, double ebx, double xoffset = 0) - { - edx += SeqBase[nSequence]; - - short nFrameBase = FrameBase[edx]; - int16_t nFrameSize = FrameSize[edx]; - - while (1) - { - nFrameSize--; - if (nFrameSize < 0) - break; - - int flags = 0; - - double x = ChunkXpos[nFrameBase] + xoffset; - double y = ChunkYpos[nFrameBase] + ebx; - - if (hud_size <= Hud_StbarOverlay) - { - x += 161; - y += 100; - } - else - { - if (x < 0) - { - x += 160; - flags |= DI_SCREEN_LEFT_BOTTOM; - } - else if (x > 0) - { - x -= 159; // graphics do not match up precisely. - flags |= DI_SCREEN_RIGHT_BOTTOM; - } - y -= 100; - } - - int tile = ChunkPict[nFrameBase]; - - short chunkFlag = ChunkFlag[nFrameBase]; - - if (chunkFlag & 3) - { - // This is hard to align with bad offsets, so skip that treatment for mirrored elements. - flags |= DI_ITEM_RELCENTER; - } - else - { - x -= tileWidth(tile) * .5; - y -= tileHeight(tile) * .5; - flags |= DI_ITEM_OFFSETS; - } - - if (chunkFlag & 1) - flags |= DI_MIRROR; - if (chunkFlag & 2) - flags |= DI_MIRRORY; - - DrawGraphic(tileGetTexture(tile), x, y, flags, 1, -1, -1, 1, 1); - nFrameBase++; - } - } - - //--------------------------------------------------------------------------- - // - // draws a sequence animation to the status bar - // - //--------------------------------------------------------------------------- - - FGameTexture * GetStatusSequencePic(short nSequence, uint16_t edx) - { - edx += SeqBase[nSequence]; - int nFrameBase = FrameBase[edx]; - return tileGetTexture(ChunkPict[nFrameBase]); - } - - int GetStatusSequenceTile(short nSequence, uint16_t edx) - { - edx += SeqBase[nSequence]; - int nFrameBase = FrameBase[edx]; - return ChunkPict[nFrameBase]; - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DrawStatusAnims() - { - for (int i = nFirstAnim; i >= 0; i = StatusAnim[i].nPrevAnim) - { - int nSequence = nStatusSeqOffset + StatusAnim[i].s1; - DrawStatusSequence(nSequence, StatusAnim[i].s2, StatusAnim[i].s1 >= 37 && StatusAnim[i].s1 <= 43 ? 0.5 : 0, 0.5); - } - } - - - //--------------------------------------------------------------------------- - // - // Frag display - very ugly and may have to be redone if multiplayer support gets added. - // - //--------------------------------------------------------------------------- - - void DrawMulti() - { - char stringBuf[30]; - if (nNetPlayerCount) - { - BeginHUD(320, 200, 1); - - int shade; - - if ((PlayClock / 120) & 1) { - shade = -100; - } - else { - shade = 127; - } - - int nTile = kTile3593; - - int xx = 320 / (nTotalPlayers + 1); - int x = xx - 160; - - for (int i = 0; i < nTotalPlayers; i++) - { - DrawGraphic(tileGetTexture(nTile), x, 7, DI_ITEM_CENTER, 1, -1, -1, 1, 1); - - if (i != nLocalPlayer) { - shade = -100; - } - - sprintf(stringBuf, "%d", nPlayerScore[i]); - SBar_DrawString(this, textfont, stringBuf, x, 0, DI_ITEM_TOP|DI_TEXT_ALIGN_CENTER, i != nLocalPlayer ? CR_UNTRANSLATED : CR_GOLD, 1, -1, 0, 1, 1); - x += xx; - nTile++; - } - - if (nNetTime >= 0) - { - int y = 0; - - if (nNetTime) - { - int v12 = (nNetTime + 29) / 30 % 60; - int v13 = (nNetTime + 29) / 1800; - nNetTime += 29; - - sprintf(stringBuf, "%d.%02d", v13, v12); - - y += 20; - nNetTime -= 29; - SBar_DrawString(this, textfont, stringBuf, 0, 10, DI_ITEM_TOP | DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, -1, 0, 1, 1); - } - } - - } - } - - //========================================================================== - // - // Fullscreen HUD variant #1 - // - //========================================================================== - - void DrawHUD2() - { - BeginHUD(320, 200, 1); - - auto pp = &PlayerList[nLocalPlayer]; - - FString format; - FGameTexture* img; - double imgScale; - double baseScale = numberFont->mFont->GetHeight() * 0.75; - - - // - // Health - // - img = GetStatusSequencePic(nStatusSeqOffset + 125, 0); - imgScale = baseScale / img->GetDisplayHeight(); - DrawGraphic(img, 1.5, -1, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale); - - if (!althud_flashing || pp->nHealth > 150 || (PlayClock & 32)) - { - int s = -8; - if (althud_flashing && pp->nHealth > 800) - s += bsin(PlayClock << 5, -10); - int intens = clamp(255 - 4 * s, 0, 255); - auto pe = PalEntry(255, intens, intens, intens); - format.Format("%d", pp->nHealth >> 3); - SBar_DrawString(this, numberFont, format, 13, -numberFont->mFont->GetHeight()+3, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - } - - // - // Air - // - if (SectFlag[nPlayerViewSect[nLocalPlayer]] & kSectUnderwater) - { - img = GetStatusSequencePic(nStatusSeqOffset + 133, airframe); - imgScale = baseScale / img->GetDisplayHeight(); - DrawGraphic(img, -4, -22, DI_ITEM_RIGHT_BOTTOM, 1., -1, -1, imgScale, imgScale); - } - - // - // Magic - // - if (nItemSeq >= 0) - { - int tile = GetStatusSequenceTile(nItemSeq + nStatusSeqOffset, nItemFrame); - int tile2 = tile; - if (tile2 > 744 && tile2 < 751) tile2 = 744; - - imgScale = baseScale / tileHeight(tile2); - DrawGraphic(tileGetTexture(tile), 70, -1, DI_ITEM_CENTER_BOTTOM, 1., -1, -1, imgScale, imgScale); - - - - format.Format("%d", pp->nMagic / 10); - - short nItem = nPlayerItem[nLocalPlayer]; - int timer = ItemTimer(nItem, nLocalPlayer); - if (timer > 0) - { - format.AppendFormat("/%d", timer); - } - SBar_DrawString(this, numberFont, format, 79.5, -numberFont->mFont->GetHeight() + 3, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - } - // - // Weapon - // - const short ammo_sprites[] = { -1, -1 }; - - int weapon = pp->nCurrentWeapon; - int wicon = 0;// ammo_sprites[weapon]; - int ammo = nCounterDest;// pp->WpnAmmo[weapon]; - if (ammo > 0) // wicon > 0 - { - format.Format("%d", ammo); - img = tileGetTexture(wicon); - imgScale = baseScale / img->GetDisplayHeight(); - auto imgX = 21.125; - auto strlen = format.Len(); - - if (strlen > 1) - { - imgX += (imgX * 0.855) * (strlen - 1); - } - - if ((!althud_flashing || PlayClock & 32 || ammo > 10))// (DamageData[weapon].max_ammo / 10))) - { - SBar_DrawString(this, numberFont, format, -3, -numberFont->mFont->GetHeight()+3, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - } - - //DrawGraphic(img, -imgX, -1, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale); - } - -#if 0 - // - // Selected inventory item - // - img = tileGetTexture(icons[pp->InventoryNum]); - imgScale = baseScale / img->GetDisplayHeight(); - int x = 165; - DrawGraphic(img, x, -1, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, imgScale, imgScale); - - PlayerUpdateInventoryState(pp, x + 3.0, -18.0, 1, 1); - PlayerUpdateInventoryPercent(pp, x + 3.5, -20.5, 1, 1); -#endif - - - // - // keys - // - - uint16_t nKeys = PlayerList[nLocalPlayer].keys; - - int val = 675; - int x = -134; - - for (int i = 0; i < 4; i++) - { - if (nKeys & 0x1000) - { - auto tex = tileGetTexture(val); - if (tex && tex->isValid()) - { - DrawGraphic(tex, x, -2, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, 1, 1); - } - } - - nKeys >>= 1; - val += 4; - x += 20; - } - } - - - - //--------------------------------------------------------------------------- - // - // draw the full status bar - // - //--------------------------------------------------------------------------- - - void DrawStatus() - { - if (hud_size <= Hud_StbarOverlay) - { - // draw the main bar itself - BeginStatusBar(320, 200, 40); - if (hud_size == Hud_StbarOverlay) Set43ClipRect(); - DrawGraphic(tileGetTexture(kTileStatusBar), 160, 200, DI_ITEM_CENTER_BOTTOM, 1, -1, -1, 1, 1); - twod->ClearClipRect(); - } - else if (hud_size == Hud_Mini) - { - auto lh = TexMan.GetGameTextureByName("hud_l"); - auto rh = TexMan.GetGameTextureByName("hud_r"); - BeginHUD(320, 200, 1); - if (lh) DrawGraphic(lh, 0, 0, DI_ITEM_LEFT_BOTTOM | DI_SCREEN_LEFT_BOTTOM, 1, -1, -1, 1, 1); - if (rh) DrawGraphic(rh, 0, 0, DI_ITEM_RIGHT_BOTTOM | DI_SCREEN_RIGHT_BOTTOM, 1, -1, -1, 1, 1); - } - else if (hud_size == Hud_full) - { - DrawHUD2(); - return; - } - - if (/*!bFullScreen &&*/ nNetTime) - { - DrawStatusSequence(nStatusSeqOffset + 127, 0, 0); - DrawStatusSequence(nStatusSeqOffset + 129, nMagicFrame, nMagicLevel); - DrawStatusSequence(nStatusSeqOffset + 131, 0, 0); // magic pool frame (bottom) - - DrawStatusSequence(nStatusSeqOffset + 128, 0, 0); - DrawStatusSequence(nStatusSeqOffset + 1, nHealthFrame, nHealthLevel); - DrawStatusSequence(nStatusSeqOffset + 125, 0, 0); // draw ankh on health pool - DrawStatusSequence(nStatusSeqOffset + 130, 0, 0); // draw health pool frame (top) - - if (nItemSeq >= 0) { - DrawStatusSequence(nItemSeq + nStatusSeqOffset, nItemFrame, 1); - } - - // draws health level dots, animates breathing lungs and other things - DrawStatusAnims(); - - // draw the blue air level meter when underwater (but not responsible for animating the breathing lungs otherwise) - if (SectFlag[nPlayerViewSect[nLocalPlayer]] & kSectUnderwater) - { - DrawStatusSequence(nStatusSeqOffset + 133, airframe, 0, 0.5); - } - - - // draw compass - if (hud_size <= Hud_StbarOverlay) DrawStatusSequence(nStatusSeqOffset + 35, ((inita + 128) & kAngleMask) >> 8, 0, 0.5); - - //if (hud_size < Hud_full) - { - // draw ammo count - DrawStatusSequence(nStatusSeqOffset + 44, nDigit[2], 0, 0.5); - DrawStatusSequence(nStatusSeqOffset + 45, nDigit[1], 0, 0.5); - DrawStatusSequence(nStatusSeqOffset + 46, nDigit[0], 0, 0.5); - } - } - - DrawMulti(); - - if (nSnakeCam >= 0) - { - BeginHUD(320, 200, 1); - SBar_DrawString(this, textfont, "S E R P E N T C A M", 0, 0, DI_TEXT_ALIGN_CENTER | DI_SCREEN_CENTER_TOP, CR_UNTRANSLATED, 1, -1, 0, 1, 1); - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void PrintLevelStats(int bottomy) - { - FLevelStats stats{}; - stats.fontscale = 1.; - stats.spacing = SmallFont->GetHeight(); - stats.screenbottomspace = bottomy; - stats.font = SmallFont; - stats.letterColor = CR_RED; - stats.standardColor = CR_UNTRANSLATED; - stats.time = Scale(PlayClock, 1000, 120); - - if (automapMode == am_full) - { - DBaseStatusBar::PrintAutomapInfo(stats, true); - } - else if (hud_stats) - { - - stats.completeColor = CR_DARKGREEN; - stats.kills = nCreaturesKilled; - stats.maxkills = nCreaturesTotal; - stats.frags = -1; - stats.secrets = 0; - stats.maxsecrets = 0; - - DBaseStatusBar::PrintLevelStats(stats); - } - } - - - - -public: - void UpdateStatusBar() - { - if (hud_size <= Hud_full) - { - DrawStatus(); - } - PrintLevelStats(hud_size == Hud_Nothing ? 0 : hud_size == Hud_full? 22 : 40); + x = ChunkXpos[nFrameBase]; + y = ChunkYpos[nFrameBase]; + auto ttex = tileGetTexture(ChunkPict[nFrameBase]); + if (ttex) tex = ttex->GetID(); + else tex.SetInvalid(); + flags = ChunkFlag[nFrameBase]; } }; -IMPLEMENT_CLASS(DExhumedStatusBar, false, true) -IMPLEMENT_POINTERS_START(DExhumedStatusBar) -IMPLEMENT_POINTER(textfont) -IMPLEMENT_POINTER(numberFont) -IMPLEMENT_POINTERS_END +DEFINE_ACTION_FUNCTION(_ChunkFrame, GetChunkFrame) +{ + PARAM_SELF_STRUCT_PROLOGUE(ChunkFrame); + PARAM_INT(index); + self->GetChunkFrame(index); + return 0; +} + +DEFINE_ACTION_FUNCTION(_Exhumed, GetStatusSequence) +{ + PARAM_PROLOGUE; + PARAM_INT(nSequence); + PARAM_INT(frameindex); + + frameindex += SeqBase[nStatusSeqOffset + nSequence]; + if (numret > 0) ret[0].SetInt(FrameBase[frameindex]); + if (numret > 1) ret[1].SetInt(FrameSize[frameindex]); + return min(numret, 2); +} + +DEFINE_ACTION_FUNCTION(_Exhumed, MoveStatusSequence) +{ + PARAM_PROLOGUE; + PARAM_INT(s1); + PARAM_INT(s2); + seq_MoveSequence(-1, nStatusSeqOffset + s1, s2); + ACTION_RETURN_INT(SeqSize[nStatusSeqOffset + s1]); +} + +int SizeOfStatusSequence(int s1) +{ + return SeqSize[nStatusSeqOffset + s1]; +} + +DEFINE_ACTION_FUNCTION_NATIVE(_Exhumed, SizeOfStatusSequence, SizeOfStatusSequence) +{ + PARAM_PROLOGUE; + PARAM_INT(s1); + ACTION_RETURN_INT(SeqSize[nStatusSeqOffset + s1]); +} void UpdateFrame() { @@ -999,7 +142,6 @@ void StatusMessage(int messageTime, const char* fmt, ...) va_end(ap); } - void DrawStatusBar() { if (nFreeze == 2) return; // Hide when Ramses is talking. @@ -1007,7 +149,20 @@ void DrawStatusBar() { UpdateFrame(); } - StatusBar->UpdateStatusBar(); + SummaryInfo info{}; + info.kills = nCreaturesKilled; + info.maxkills = nCreaturesTotal; + // got no secrets in the game + info.time = Scale(PlayClock, 1000, 120); + UpdateStatusBar(&info); + + if (nSnakeCam >= 0) + { + const char* text = "S E R P E N T C A M"; + int width = SmallFont->StringWidth(text); + DrawText(twod, SmallFont, CR_UNTRANSLATED, 160 - width / 2, 1, text, DTA_FullscreenScale, FSMode_Fit320x200, TAG_DONE); + } + } END_PS_NS diff --git a/source/games/exhumed/src/status.h b/source/games/exhumed/src/status.h index 8536652dd..1cf9bccc7 100644 --- a/source/games/exhumed/src/status.h +++ b/source/games/exhumed/src/status.h @@ -21,22 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_PS_NS -extern short nMaskY; -extern short nCounterBullet; -extern short airpages; - -void RefreshStatus(); void InitStatus(); -void SetPlayerItem(short nPlayer, short nItem); -void SetMagicFrame(); -void SetHealthFrame(short nVal); -void SetAirFrame(); -void MoveStatus(); -void DrawSnakeCamStatus(); -void DrawStatus(); -int BuildStatusAnim(int val, int nFlags); -void SetCounter(short nVal); -void SetCounterImmediate(short nVal); END_PS_NS diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index a98975f63..d85559532 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -336,7 +336,7 @@ void DrawView(double smoothRatio, bool sceneonly) static uint8_t sectorCeilingPal[MAXSECTORS]; static uint8_t wallPal[MAXWALLS]; int const viewingRange = viewingrange; - int const vr = xs_CRoundToInt(65536.f * tanf(r_fov * (pi::pi() / 360.f))); + int const vr = xs_CRoundToInt(65536. * tan(r_fov * (pi::pi() / 360.))); videoSetCorrectedAspect(); @@ -360,7 +360,7 @@ void DrawView(double smoothRatio, bool sceneonly) if (!testnewrenderer) { - renderSetRollAngle(rotscrnang.asbuildf()); + renderSetRollAngle((float)rotscrnang.asbuildf()); renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa.asq16(), nCamerapan.asq16(), nSector); analyzesprites(pm_tsprite, pm_spritesortcnt, nCamerax, nCameray, viewz, smoothRatio); renderDrawMasks(); @@ -439,7 +439,7 @@ void DrawView(double smoothRatio, bool sceneonly) { RestoreGreenPal(); if (nEnemyPal > -1) { - sprite[enemy].pal = nEnemyPal; + sprite[enemy].pal = (uint8_t)nEnemyPal; } DrawMap(smoothRatio); diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index 79f8601e5..5cbff79b5 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -309,7 +309,7 @@ DoDebrisCurrent(SPRITEp sp) // faster than move_sprite //move_missile(sp-sprite, nx, ny, 0, Z(2), Z(0), 0, ACTORMOVETICS); - ret = move_sprite(sp-sprite, nx, ny, 0, u->ceiling_dist, u->floor_dist, 0, ACTORMOVETICS); + ret = move_sprite(int(sp-sprite), nx, ny, 0, u->ceiling_dist, u->floor_dist, 0, ACTORMOVETICS); // attempt to move away from wall if (ret) @@ -319,7 +319,7 @@ DoDebrisCurrent(SPRITEp sp) nx = MulScale(DIV4(sectu->speed), bcos(sectu->ang + rang), 14); nx = MulScale(DIV4(sectu->speed), bsin(sectu->ang + rang), 14); - move_sprite(sp-sprite, nx, ny, 0, u->ceiling_dist, u->floor_dist, 0, ACTORMOVETICS); + move_sprite(int(sp-sprite), nx, ny, 0, u->ceiling_dist, u->floor_dist, 0, ACTORMOVETICS); } sp->z = u->loz; @@ -617,7 +617,7 @@ KeepActorOnFloor(short SpriteNum) } int -DoActorBeginSlide(short SpriteNum, short ang, short vel, short dec) +DoActorBeginSlide(int SpriteNum, short ang, short vel, short dec) { USERp u = User[SpriteNum].Data(); diff --git a/source/games/sw/src/break.cpp b/source/games/sw/src/break.cpp index 5fd3e09b2..2c9b35d70 100644 --- a/source/games/sw/src/break.cpp +++ b/source/games/sw/src/break.cpp @@ -823,7 +823,7 @@ bool HitBreakWall(WALLp wp, int hit_x, int hit_y, int hit_z, short ang, short ty //if (hit_x == INT32_MAX) { short sectnum; - WallBreakPosition(wp - wall, §num, &hit_x, &hit_y, &hit_z, &ang); + WallBreakPosition(short(wp - wall), §num, &hit_x, &hit_y, &hit_z, &ang); } AutoBreakWall(wp, hit_x, hit_y, hit_z, ang, type); diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index 20cfe4c7d..e0b8f3c7c 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -806,12 +806,12 @@ SetupBunny(short SpriteNum) } int -GetBunnyJumpHeight(short jump_speed, short jump_grav) +GetBunnyJumpHeight(int jump_speed, int jump_grav) { int jump_iterations; int height; - jump_speed = labs(jump_speed); + jump_speed = abs(jump_speed); jump_iterations = jump_speed / (jump_grav * ACTORMOVETICS); @@ -973,7 +973,7 @@ DoBunnyQuickJump(short SpriteNum) // Random Chance of like sexes fighting if (u->lo_sp) { - short hit_sprite = u->lo_sp - sprite; + short hit_sprite = short(u->lo_sp - sprite); SPRITEp tsp = u->lo_sp; USERp tu = User[hit_sprite].Data(); @@ -1015,7 +1015,7 @@ DoBunnyQuickJump(short SpriteNum) // Get layed! if (u->lo_sp && u->spal == PALETTE_PLAYER8) // Only males check this { - short hit_sprite = u->lo_sp - sprite; + short hit_sprite = short(u->lo_sp - sprite); SPRITEp tsp = u->lo_sp; USERp tu = User[hit_sprite].Data(); diff --git a/source/games/sw/src/cheats.cpp b/source/games/sw/src/cheats.cpp index dc33c96e4..37ec5947b 100644 --- a/source/games/sw/src/cheats.cpp +++ b/source/games/sw/src/cheats.cpp @@ -234,7 +234,7 @@ static void ItemCheat(int player) for (int inv = 0; inv < MAX_INVENTORY; inv++) { p->InventoryPercent[inv] = 100; - p->InventoryAmount[inv] = InventoryData[inv].MaxInv; + p->InventoryAmount[inv] = (uint8_t)InventoryData[inv].MaxInv; } PlayerUpdateInventory(p, p->InventoryNum); @@ -321,7 +321,7 @@ static void cmd_Give(int player, uint8_t** stream, bool skip) for (int inv = 0; inv < MAX_INVENTORY; inv++) { p->InventoryPercent[inv] = 100; - p->InventoryAmount[inv] = InventoryData[inv].MaxInv; + p->InventoryAmount[inv] = (uint8_t)InventoryData[inv].MaxInv; } PlayerUpdateInventory(p, p->InventoryNum); diff --git a/source/games/sw/src/colormap.cpp b/source/games/sw/src/colormap.cpp index 0b648808a..6845fc44f 100644 --- a/source/games/sw/src/colormap.cpp +++ b/source/games/sw/src/colormap.cpp @@ -54,7 +54,7 @@ MapColors(short num, COLOR_MAP cm, short create, uint8_t *tempbuf) inc = cm.ToRange/((float)cm.FromRange); for (i = 0; i < cm.FromRange; i++) - tempbuf[i + cm.FromColor] = (i*inc) + cm.ToColor; + tempbuf[i + cm.FromColor] = uint8_t((i*inc) + cm.ToColor); } diff --git a/source/games/sw/src/coolie.cpp b/source/games/sw/src/coolie.cpp index ddfe249c6..d6a7743f3 100644 --- a/source/games/sw/src/coolie.cpp +++ b/source/games/sw/src/coolie.cpp @@ -474,7 +474,7 @@ void EnemyDefaults(short SpriteNum, ACTOR_ACTION_SETp action, PERSONALITYp perso if (u->lo_sectp) // && SectUser[u->lo_sectp - sector]) { int i; - short sectnum = u->lo_sectp - sector; + short sectnum = short(u->lo_sectp - sector); if (SectUser[sectnum].Data() && TEST(u->lo_sectp->extra, SECTFX_SINK)) { @@ -519,7 +519,7 @@ void EnemyDefaults(short SpriteNum, ACTOR_ACTION_SETp action, PERSONALITYp perso // for actors this tells the number of weapons available // for player it tells the current weapon - u->WeaponNum = wpn_cnt; + u->WeaponNum = int8_t(wpn_cnt); } int diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 7bb9dc414..bd4db7c79 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -185,7 +185,7 @@ SetActorRotation(spritetype* tsprite, int& spritesortcnt, short tSpriteNum, int return 0; // Get the offset into the State animation - StateOffset = State - StateStart; + StateOffset = short(State - StateStart); // Get the rotation angle Rotation = GetRotation(tsprite, spritesortcnt, tSpriteNum, viewx, viewy); @@ -338,8 +338,8 @@ DoShadows(spritetype* tsprite, int& spritesortcnt, tspriteptr_t tsp, int viewz, xrepeat = min(xrepeat, short(255)); yrepeat = min(yrepeat, short(255)); - New->xrepeat = xrepeat; - New->yrepeat = yrepeat; + New->xrepeat = uint8_t(xrepeat); + New->yrepeat = uint8_t(yrepeat); if (tilehasmodelorvoxel(tsp->picnum,tsp->pal)) { @@ -435,8 +435,8 @@ DoMotionBlur(spritetype* tsprite, int& spritesortcnt, tspritetype const * const New->z += dz; dz += nz; - New->xrepeat = xrepeat; - New->yrepeat = yrepeat; + New->xrepeat = uint8_t(xrepeat); + New->yrepeat = uint8_t(yrepeat); xrepeat -= repeat_adj; yrepeat -= repeat_adj; @@ -566,8 +566,8 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view ang = NORM_ANGLE(ang + 12); - smr4 = smoothratio + IntToFixed(MoveSkip4); - smr2 = smoothratio + IntToFixed(MoveSkip2); + smr4 = int(smoothratio) + IntToFixed(MoveSkip4); + smr2 = int(smoothratio) + IntToFixed(MoveSkip2); for (tSpriteNum = spritesortcnt - 1; tSpriteNum >= 0; tSpriteNum--) { @@ -768,10 +768,11 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view else // Otherwise just interpolate the player sprite { PLAYERp pp = tu->PlayerP; - tsp->x -= MulScale(pp->posx - pp->oposx, 65536-smoothratio, 16); - tsp->y -= MulScale(pp->posy - pp->oposy, 65536-smoothratio, 16); - tsp->z -= MulScale(pp->posz - pp->oposz, 65536-smoothratio, 16); - tsp->ang -= MulScale(pp->angle.ang.asbuild() - pp->angle.oang.asbuild(), 65536-smoothratio, 16); + int sr = 65536 - int(smoothratio); + tsp->x -= MulScale(pp->posx - pp->oposx, sr, 16); + tsp->y -= MulScale(pp->posy - pp->oposy, sr, 16); + tsp->z -= MulScale(pp->posz - pp->oposz, sr, 16); + tsp->ang -= MulScale(pp->angle.ang.asbuild() - pp->angle.oang.asbuild(), sr, 16); } } @@ -794,7 +795,7 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view newshade = tsp->shade; newshade += 6; if (newshade > 127) newshade = 127; - tsp->shade = newshade; + tsp->shade = int8_t(newshade); } if (TEST(sector[tsp->sectnum].ceilingstat, CEILING_STAT_PLAX)) @@ -803,7 +804,7 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view newshade += sector[tsp->sectnum].ceilingshade; if (newshade > 127) newshade = 127; if (newshade < -128) newshade = -128; - tsp->shade = newshade; + tsp->shade = int8_t(newshade); } else { @@ -811,7 +812,7 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view newshade += sector[tsp->sectnum].floorshade; if (newshade > 127) newshade = 127; if (newshade < -128) newshade = -128; - tsp->shade = newshade; + tsp->shade = int8_t(newshade); } if (tsp->hitag == 9998) @@ -1474,13 +1475,14 @@ drawscreen(PLAYERp pp, double smoothratio) PreDraw(); PreUpdatePanel(smoothratio); - pm_smoothratio = (int)smoothratio; + int sr = (int)smoothratio; + pm_smoothratio = sr; if (!ScreenSavePic) { DoInterpolations(smoothratio / 65536.); // Stick at beginning of drawscreen if (cl_sointerpolation) - so_dointerpolations(smoothratio); // Stick at beginning of drawscreen + so_dointerpolations(sr); // Stick at beginning of drawscreen } // TENSW: when rendering with prediction, the only thing that counts should @@ -1490,9 +1492,9 @@ drawscreen(PLAYERp pp, double smoothratio) else camerapp = pp; - tx = interpolatedvalue(camerapp->oposx, camerapp->posx, smoothratio); - ty = interpolatedvalue(camerapp->oposy, camerapp->posy, smoothratio); - tz = interpolatedvalue(camerapp->oposz, camerapp->posz, smoothratio); + tx = interpolatedvalue(camerapp->oposx, camerapp->posx, sr); + ty = interpolatedvalue(camerapp->oposy, camerapp->posy, sr); + tz = interpolatedvalue(camerapp->oposz, camerapp->posz, sr); // Interpolate the player's angle while on a sector object, just like VoidSW. // This isn't needed for the turret as it was fixable, but moving sector objects are problematic. @@ -1597,7 +1599,7 @@ drawscreen(PLAYERp pp, double smoothratio) if (!testnewrenderer) { - renderSetRollAngle(trotscrnang.asbuildf()); + renderSetRollAngle((float)trotscrnang.asbuildf()); polymost_drawscreen(pp, tx, ty, tz, tang, thoriz, tsectnum); } else diff --git a/source/games/sw/src/eel.cpp b/source/games/sw/src/eel.cpp index ab96b766f..7f29ec025 100644 --- a/source/games/sw/src/eel.cpp +++ b/source/games/sw/src/eel.cpp @@ -605,7 +605,7 @@ int DoEelMove(short SpriteNum) ASSERT(u->Rot != NULL); - if (SpriteOverlap(SpriteNum, u->tgt_sp - sprite)) + if (SpriteOverlap(SpriteNum, int16_t(u->tgt_sp - sprite))) NewStateGroup(SpriteNum, u->ActorActionSet->CloseAttack[0]); if (TEST(u->Flags,SPR_SLIDING)) diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 33940eb16..c554dc6bc 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -404,7 +404,7 @@ void InitRunLevel(void) if (currentLevel) { - PlaySong(currentLevel->labelName, currentLevel->music, currentLevel->cdSongId); + PlaySong(currentLevel->music, currentLevel->cdSongId); } InitPrediction(&Player[myconnectindex]); @@ -531,9 +531,9 @@ void GameInterface::LevelCompleted(MapRecord* map, int skill) SummaryInfo info{}; - info.kills = Player->Kills; + info.kills = Player[screenpeek].Kills; info.maxkills = TotalKillable; - info.secrets = Player->SecretsFound; + info.secrets = Player[screenpeek].SecretsFound; info.maxsecrets = LevelSecrets; info.time = PlayClock / 120; @@ -542,7 +542,7 @@ void GameInterface::LevelCompleted(MapRecord* map, int skill) if (map == nullptr) { FinishAnim = false; - PlaySong(nullptr, ThemeSongs[0], ThemeTrack[0]); + PlaySong(ThemeSongs[0], ThemeTrack[0]); if (isShareware()) { PlayOrderSound(); diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index f2c7d24ad..5eb8a4103 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -976,7 +976,7 @@ struct PLAYERstruct char cookieQuote[256]; // Should be an FString but must be POD for now so that PLAYER remains POD. int cookieTime; - char WpnReloadState; + uint8_t WpnReloadState; }; extern PLAYER Player[MAX_SW_PLAYERS_REG+1]; @@ -1261,7 +1261,7 @@ struct USER short inactive_time; // length of time actor has been unaware of his tgt int sx,sy,sz; short sang; - char spal; // save off default palette number + uint8_t spal; // save off default palette number int ret; //holder for move_sprite return value @@ -1924,7 +1924,7 @@ SECT_USERp GetSectUser(short sectnum); // 1. The variables were unmaintained and could refer to handles that had been reused already. // 2. No proper sound ownership tracking. // 3. In some cases items that were supposed to use the same check referred to different handle variables. -// In short: I was very broken. This is a list of all sound items used this way, now each one gets a dedicated channel +// In short: It was very broken. This is a list of all sound items used this way, now each one gets a dedicated channel // so that proper checks can be performed and sound ownership be tracked. enum @@ -1984,8 +1984,8 @@ short AnimSetVelAdj(short anim_ndx, short vel_adj); void EnemyDefaults(short SpriteNum, ACTOR_ACTION_SETp action, PERSONALITYp person); void getzrangepoint(int x, int y, int z, short sectnum, int32_t* ceilz, int32_t* ceilhit, int32_t* florz, int32_t* florhit); -int move_sprite(short spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics); -int move_missile(short spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics); +int move_sprite(int spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics); +int move_missile(int spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics); int DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, int skip_targets); void change_sprite_stat(short, short); diff --git a/source/games/sw/src/input.cpp b/source/games/sw/src/input.cpp index a3c3a72b7..802d5af7f 100644 --- a/source/games/sw/src/input.cpp +++ b/source/games/sw/src/input.cpp @@ -80,6 +80,7 @@ enum static void processWeapon(PLAYERp const pp) { + if (pp->PlayerSprite < 0) return; USERp u = User[pp->PlayerSprite].Data(); int i; @@ -161,7 +162,9 @@ static void processWeapon(PLAYERp const pp) void GameInterface::GetInput(InputPacket *packet, ControlInfo* const hidInput) { - if (paused || M_Active()) + PLAYERp pp = &Player[myconnectindex]; + + if (paused || M_Active() || pp->PlayerSprite <= -1) { loc = {}; return; @@ -169,7 +172,6 @@ void GameInterface::GetInput(InputPacket *packet, ControlInfo* const hidInput) double const scaleAdjust = InputScale(); InputPacket input {}; - PLAYERp pp = &Player[myconnectindex]; ApplyGlobalInput(loc, hidInput); processMovement(&input, &loc, hidInput, scaleAdjust, 0, !pp->sop, pp->sop_control ? 3. / 1.40625 : 1.); diff --git a/source/games/sw/src/interpso.cpp b/source/games/sw/src/interpso.cpp index d7b757458..07674083b 100644 --- a/source/games/sw/src/interpso.cpp +++ b/source/games/sw/src/interpso.cpp @@ -197,7 +197,7 @@ void so_addinterpolation(SECTOR_OBJECTp sop) } int i; - SectIterator it(*sectp - sector); + SectIterator it(int(*sectp - sector)); while ((i = it.NextIndex()) >= 0) if (sprite[i].statnum == STAT_VATOR && SP_TAG1(sprite+i) == SECT_VATOR) break; diff --git a/source/games/sw/src/inv.h b/source/games/sw/src/inv.h index 3147b2518..505486aed 100644 --- a/source/games/sw/src/inv.h +++ b/source/games/sw/src/inv.h @@ -49,9 +49,12 @@ typedef struct extern INVENTORY_DATA InventoryData[MAX_INVENTORY+1]; -#define INVF_AUTO_USE (BIT(0)) -#define INVF_TIMED (BIT(1)) -#define INVF_COUNT (BIT(2)) +enum EInvFlags +{ + INVF_AUTO_USE = 1, + INVF_TIMED = 2, + INVF_COUNT = 4 +}; void PlayerUpdateInventory(PLAYERp pp,short InventoryNum); void InventoryKeys(PLAYERp pp); diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index 70ad98837..55d648e29 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -1424,7 +1424,7 @@ PlayerInitChemBomb(PLAYERp pp) MissileSetPos(w, DoChemBomb, 1000); - pp->SpriteP->clipdist = oclipdist; + pp->SpriteP->clipdist = uint8_t(oclipdist); wp->clipdist = 80L >> 2; wu->xchange = MOVEx(wp->xvel, wp->ang); @@ -1479,7 +1479,7 @@ InitSpriteChemBomb(int16_t SpriteNum) SET(wp->cstat, CSTAT_SPRITE_YCENTER); SET(wp->cstat, CSTAT_SPRITE_BLOCK); - wp->zvel = -RANDOM_RANGE(100) * HORIZ_MULT; + wp->zvel = short(-RANDOM_RANGE(100) * HORIZ_MULT); wp->clipdist = 80L >> 2; @@ -1541,7 +1541,7 @@ InitChemBomb(short SpriteNum) if (SpriteInUnderwaterArea(wp)) SET(wu->Flags, SPR_UNDERWATER); - wp->zvel = -RANDOM_RANGE(100) * HORIZ_MULT; + wp->zvel = short(-RANDOM_RANGE(100) * HORIZ_MULT); wp->clipdist = 0; if (u->ID == MUSHROOM_CLOUD || u->ID == 3121 || u->ID == SUMO_RUN_R0) // 3121 == GRENADE_EXP @@ -1862,7 +1862,7 @@ PlayerInitCaltrops(PLAYERp pp) MissileSetPos(w, DoCaltrops, 1000); - pp->SpriteP->clipdist = oclipdist; + pp->SpriteP->clipdist = uint8_t(oclipdist); wp->clipdist = 80L >> 2; wu->xchange = MOVEx(wp->xvel, wp->ang); @@ -1920,7 +1920,7 @@ InitCaltrops(int16_t SpriteNum) wu->floor_dist = Z(3); wu->Counter = 0; - wp->zvel = -RANDOM_RANGE(100) * HORIZ_MULT; + wp->zvel = short(-RANDOM_RANGE(100) * HORIZ_MULT); // wp->clipdist = 80L>>2; @@ -1982,7 +1982,7 @@ InitPhosphorus(int16_t SpriteNum) wu->floor_dist = Z(3); wu->Counter = 0; - wp->zvel = -RANDOM_RANGE(100) * HORIZ_MULT; + wp->zvel = short(-RANDOM_RANGE(100) * HORIZ_MULT); wu->xchange = MOVEx(wp->xvel, wp->ang); wu->ychange = MOVEy(wp->xvel, wp->ang); @@ -2067,7 +2067,7 @@ InitBloodSpray(int16_t SpriteNum, bool dogib, short velocity) wu->floor_dist = Z(3); wu->Counter = 0; - wp->zvel = ((-10 - RANDOM_RANGE(50)) * HORIZ_MULT); + wp->zvel = short((-10 - RANDOM_RANGE(50)) * HORIZ_MULT); wu->xchange = MOVEx(wp->xvel, wp->ang); wu->ychange = MOVEy(wp->xvel, wp->ang); diff --git a/source/games/sw/src/light.cpp b/source/games/sw/src/light.cpp index 64ca1bfcd..796dac5a5 100644 --- a/source/games/sw/src/light.cpp +++ b/source/games/sw/src/light.cpp @@ -251,7 +251,7 @@ void DoLightingMatch(short match, short state) else { // turn it off till next switch - short spal = sp->pal; + auto spal = sp->pal; RESET_BOOL1(sp); sp->pal = 0; sp->shade = LIGHT_MaxDark(sp); @@ -318,7 +318,7 @@ void DoLighting(void) else { // turn off lighting - even colored lighting - short spal = sp->pal; + auto spal = sp->pal; sp->pal = 0; sp->shade = LIGHT_MaxDark(sp); SectorLightShade(sp, sp->shade); @@ -410,7 +410,7 @@ void DoLighting(void) else { // turn off lighting - even colored lighting - short spal = sp->pal; + auto spal = sp->pal; sp->pal = 0; sp->shade = LIGHT_MaxDark(sp); SectorLightShade(sp, sp->shade); diff --git a/source/games/sw/src/light.h b/source/games/sw/src/light.h index 7f1ef9668..99bc37005 100644 --- a/source/games/sw/src/light.h +++ b/source/games/sw/src/light.h @@ -38,8 +38,8 @@ void DoLighting(void); #define LIGHT_Match(sp) (SP_TAG2((sp))) #define LIGHT_Type(sp) (SP_TAG3((sp))) #define LIGHT_MaxTics(sp) (SP_TAG4((sp))) -#define LIGHT_MaxBright(sp) (SP_TAG5((sp))) -#define LIGHT_MaxDark(sp) (SP_TAG6((sp))) +inline int8_t LIGHT_MaxBright(spritetype* sp) { return int8_t(SP_TAG5(sp)); } +inline int8_t LIGHT_MaxDark(spritetype* sp) { return int8_t(SP_TAG6(sp)); } #define LIGHT_ShadeInc(sp) (SP_TAG7((sp))) #define LIGHT_Dir(sp) (!!(TEST((sp)->extra, SPRX_BOOL10))) diff --git a/source/games/sw/src/morph.cpp b/source/games/sw/src/morph.cpp index 3db13aeb7..6e44949dc 100644 --- a/source/games/sw/src/morph.cpp +++ b/source/games/sw/src/morph.cpp @@ -372,7 +372,7 @@ MorphTornado(SECTOR_OBJECTp sop) sop->morph_z = ceilingz; } - alignceilslope(*sectp - sector, mx, my, sop->morph_z); + alignceilslope(int16_t(*sectp - sector), mx, my, sop->morph_z); } } } @@ -453,7 +453,7 @@ MorphFloor(SECTOR_OBJECTp sop) if (SectUser[*sectp - sector].Data() && TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT)) { - alignflorslope(*sectp - sector, mx, my, floorz + sop->morph_z); + alignflorslope(int16_t(*sectp - sector), mx, my, floorz + sop->morph_z); } } } @@ -469,7 +469,7 @@ SOBJ_AlignFloorToPoint(SECTOR_OBJECTp sop, int x, int y, int z) if (SectUser[*sectp - sector].Data() && TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT)) { - alignflorslope(*sectp - sector, x, y, z); + alignflorslope(int16_t(*sectp - sector), x, y, z); } } } @@ -485,7 +485,7 @@ SOBJ_AlignCeilingToPoint(SECTOR_OBJECTp sop, int x, int y, int z) if (SectUser[*sectp - sector].Data() && TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT)) { - alignceilslope(*sectp - sector, x, y, z); + alignceilslope(int16_t(*sectp - sector), x, y, z); } } } @@ -501,8 +501,8 @@ SOBJ_AlignFloorCeilingToPoint(SECTOR_OBJECTp sop, int x, int y, int z) if (SectUser[*sectp - sector].Data() && TEST(SectUser[*sectp - sector]->flags, SECTFU_SO_SLOPE_CEILING_TO_POINT)) { - alignflorslope(*sectp - sector, x, y, z); - alignceilslope(*sectp - sector, x, y, z); + alignflorslope(int16_t(*sectp - sector), x, y, z); + alignceilslope(int16_t(*sectp - sector), x, y, z); } } } diff --git a/source/games/sw/src/namelist.h b/source/games/sw/src/namelist.h index 40809cc19..9b1c0ca3b 100644 --- a/source/games/sw/src/namelist.h +++ b/source/games/sw/src/namelist.h @@ -216,3 +216,85 @@ x(BONUS_GRAB08, 5159) x(BONUS_GRAB09, 5160) x(TITLE_PIC, 2324) + +x(PanelMedkit, 2396) +x(PanelRepairKit, 2399) +x(PanelCloak, 2397) +x(PanelNightVision, 2398) +x(PanelChemBomb, 2407) +x(PanelFlashBomb, 2408) +x(PanelCaltrops, 2409) + +x(PANEL_FONT_G0, 3636) +x(PANEL_FONT_G1, 3637) +x(PANEL_FONT_G2, 3638) +x(PANEL_FONT_G3, 3639) +x(PANEL_FONT_G4, 3640) +x(PANEL_FONT_G5, 3641) +x(PANEL_FONT_G6, 3642) +x(PANEL_FONT_G7, 3643) +x(PANEL_FONT_G8, 3644) +x(PANEL_FONT_G9, 3645) +x(PANEL_SM_FONT_G0, 3601) +x(PANEL_SM_FONT_G1, 3602) +x(PANEL_SM_FONT_G2, 3603) +x(PANEL_SM_FONT_G3, 3604) +x(PANEL_SM_FONT_G4, 3605) +x(PANEL_SM_FONT_G5, 3606) +x(PANEL_SM_FONT_G6, 3607) +x(PANEL_SM_FONT_G7, 3608) +x(PANEL_SM_FONT_G8, 3609) +x(PANEL_SM_FONT_G9, 3610) +x(PANEL_SM_FONT_G10, 3600) +x(PANEL_SM_FONT_G11, 3611) +x(PANEL_SM_FONT_Y0, 3613) +x(PANEL_SM_FONT_Y1, 3614) +x(PANEL_SM_FONT_Y2, 3615) +x(PANEL_SM_FONT_Y3, 3616) +x(PANEL_SM_FONT_Y4, 3617) +x(PANEL_SM_FONT_Y5, 3618) +x(PANEL_SM_FONT_Y6, 3619) +x(PANEL_SM_FONT_Y7, 3620) +x(PANEL_SM_FONT_Y8, 3621) +x(PANEL_SM_FONT_Y9, 3622) +x(PANEL_SM_FONT_Y10, 3612) +x(PANEL_SM_FONT_Y11, 3623) +x(PANEL_SM_FONT_R0, 3625) +x(PANEL_SM_FONT_R1, 3626) +x(PANEL_SM_FONT_R2, 3627) +x(PANEL_SM_FONT_R3, 3628) +x(PANEL_SM_FONT_R4, 3629) +x(PANEL_SM_FONT_R5, 3630) +x(PANEL_SM_FONT_R6, 3631) +x(PANEL_SM_FONT_R7, 3632) +x(PANEL_SM_FONT_R8, 3633) +x(PANEL_SM_FONT_R9, 3634) +x(PANEL_SM_FONT_R10, 3624) +x(PANEL_SM_FONT_R11, 3635) +x(PANEL_KEY_RED, 2392) +x(PANEL_KEY_GREEN, 2393) +x(PANEL_KEY_BLUE, 2394) +x(PANEL_KEY_YELLOW, 2395) +x(PANEL_SKELKEY_GOLD, 2448) +x(PANEL_SKELKEY_SILVER, 2449) +x(PANEL_SKELKEY_BRONZE, 2458) +x(PANEL_SKELKEY_RED, 2459) +x(MINI_BAR_HEALTH_BOX_PIC, 2437) +x(MINI_BAR_AMMO_BOX_PIC, 2437) +x(MINI_BAR_INVENTORY_BOX_PIC, 2438) +x(SelectionBox, 2435) +x(FRAG_BAR, 2920) + +x(COMPASS_TIC, 2380) +x(COMPASS_TIC2, 2381) +x(COMPASS_NORTH, 2382) +x(COMPASS_NORTH2, 2383) +x(COMPASS_SOUTH, 2384) +x(COMPASS_SOUTH2, 2385) +x(COMPASS_EAST, 2386) +x(COMPASS_EAST2, 2387) +x(COMPASS_WEST, 2388) +x(COMPASS_WEST2, 2389) +x(COMPASS_MID_TIC, 2390) +x(COMPASS_MID_TIC2, 2391) + diff --git a/source/games/sw/src/ninja.cpp b/source/games/sw/src/ninja.cpp index 217f0c0ac..892f50774 100644 --- a/source/games/sw/src/ninja.cpp +++ b/source/games/sw/src/ninja.cpp @@ -2392,7 +2392,7 @@ InitPlayerSprite(PLAYERp pp) short sp_num; SPRITE *sp; USERp u; - int pnum = pp - Player; + int pnum = int(pp - Player); extern bool NewGame; COVER_SetReverb(0); // Turn off any echoing that may have been going before @@ -2468,7 +2468,7 @@ SpawnPlayerUnderSprite(PLAYERp pp) USERp pu = User[pp->PlayerSprite].Data(), u; SPRITEp psp = &sprite[pp->PlayerSprite]; SPRITEp sp; - int pnum = pp - Player, sp_num; + int pnum = int(pp - Player), sp_num; sp_num = pp->PlayerUnderSprite = SpawnSprite(STAT_PLAYER_UNDER0 + pnum, NINJA_RUN_R0, NULL, pp->cursectnum, pp->posx, pp->posy, pp->posz, pp->angle.ang.asbuild(), 0); diff --git a/source/games/sw/src/panel.cpp b/source/games/sw/src/panel.cpp index e8c0aee6c..97c34e28e 100644 --- a/source/games/sw/src/panel.cpp +++ b/source/games/sw/src/panel.cpp @@ -212,7 +212,7 @@ void ArmorCalc(int damage_amt, int *armor_damage, int *player_damage) // note: this could easily be converted to a mulscale and save a // bit of processing for floats - damage_percent = ((0.6 * damage_amt)+0.5); + damage_percent = int((0.6 * damage_amt)+0.5); *player_damage = damage_amt - damage_percent; *armor_damage = damage_percent; @@ -373,7 +373,7 @@ void PlayerUpdateWeapon(PLAYERp pp, short WeaponNum) if (Prediction) return; - u->WeaponNum = WeaponNum; + u->WeaponNum = int8_t(WeaponNum); } void PlayerUpdateKills(PLAYERp pp, short value) @@ -713,7 +713,7 @@ WeaponOK(PLAYERp pp) FindWeaponNum = wpn_order[wpn_ndx]; } - u->WeaponNum = FindWeaponNum; + u->WeaponNum = int8_t(FindWeaponNum); if (u->WeaponNum == WPN_HOTHEAD) { @@ -999,7 +999,7 @@ pSwordPresent(PANEL_SPRITEp psp) if (psp->y < SWORD_YOFF) { psp->oy = psp->y = SWORD_YOFF; - psp->yorig = psp->y; + psp->yorig = int(psp->y); pSetState(psp, psp->RestState); } } @@ -1031,9 +1031,9 @@ pSwordSlide(PANEL_SPRITEp psp) psp->oy = psp->y; psp->xfract = LSW(nx); - psp->x = FixedToFloat(nx); + psp->x = nx * (1. / FRACUNIT); psp->yfract = LSW(ny); - psp->y = FixedToFloat(ny); + psp->y = ny * (1. / FRACUNIT); psp->vel += vel_adj * synctics; } @@ -1064,9 +1064,9 @@ pSwordSlideDown(PANEL_SPRITEp psp) psp->oy = psp->y; psp->xfract = LSW(nx); - psp->x = FixedToFloat(nx); + psp->x = nx * (1. / FRACUNIT); psp->yfract = LSW(ny); - psp->y = FixedToFloat(ny); + psp->y = ny * (1. / FRACUNIT); psp->vel += vel_adj * synctics; @@ -1082,7 +1082,7 @@ pSwordSlideDown(PANEL_SPRITEp psp) pStatePlusOne(psp); psp->ox = psp->x = SWORDR_XOFF; psp->oy = psp->y = SWORD_YOFF; - psp->yorig = psp->y; + psp->yorig = int(psp->y); psp->ang = 1024; psp->PlayerP->SwordAng = SwordAngTable[RANDOM_RANGE(SIZ(SwordAngTable))]; psp->vel = vel; @@ -1095,7 +1095,7 @@ pSwordSlideDown(PANEL_SPRITEp psp) pSetState(psp, psp->PresentState); psp->ox = psp->x = SWORD_XOFF; psp->oy = psp->y = SWORD_YOFF + tileHeight(psp->picndx); - psp->yorig = psp->y; + psp->yorig = int(psp->y); } } @@ -1126,9 +1126,9 @@ pSwordSlideR(PANEL_SPRITEp psp) psp->oy = psp->y; psp->xfract = LSW(nx); - psp->x = FixedToFloat(nx); + psp->x = nx * (1. / FRACUNIT); psp->yfract = LSW(ny); - psp->y = FixedToFloat(ny); + psp->y = ny * (1. / FRACUNIT); psp->vel += vel_adj * synctics; } @@ -1159,9 +1159,9 @@ pSwordSlideDownR(PANEL_SPRITEp psp) psp->oy = psp->y; psp->xfract = LSW(nx); - psp->x = FixedToFloat(nx); + psp->x = nx * (1. / FRACUNIT); psp->yfract = LSW(ny); - psp->y = FixedToFloat(ny); + psp->y = ny * (1. / FRACUNIT); psp->vel += vel_adj * synctics; @@ -1177,7 +1177,7 @@ pSwordSlideDownR(PANEL_SPRITEp psp) pStatePlusOne(psp); psp->ox = psp->x = SWORD_XOFF + 80; psp->oy = psp->y = SWORD_YOFF; - psp->yorig = psp->y; + psp->yorig = int(psp->y); psp->PlayerP->SwordAng = SwordAngTable[RANDOM_RANGE(SIZ(SwordAngTable))]; psp->ang = 1024; psp->vel = vel; @@ -1190,7 +1190,7 @@ pSwordSlideDownR(PANEL_SPRITEp psp) pSetState(psp, psp->PresentState); psp->ox = psp->x = SWORD_XOFF; psp->oy = psp->y = SWORD_YOFF + tileHeight(psp->picndx); - psp->yorig = psp->y; + psp->yorig = int(psp->y); } } @@ -1200,8 +1200,8 @@ pSwordBobSetup(PANEL_SPRITEp psp) if (TEST(psp->flags, PANF_BOB)) return; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); psp->sin_amt = SWORD_SWAY_AMT; psp->sin_ndx = 0; @@ -1486,8 +1486,8 @@ pStarBobSetup(PANEL_SPRITEp psp) if (TEST(psp->flags, PANF_BOB)) return; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); psp->sin_amt = 10; psp->sin_ndx = 0; @@ -1500,8 +1500,8 @@ pLStarBobSetup(PANEL_SPRITEp psp) if (TEST(psp->flags, PANF_BOB)) return; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); psp->sin_amt = 6; psp->sin_ndx = 0; @@ -2259,8 +2259,8 @@ pUziPresent(PANEL_SPRITEp psp) psp->oy = psp->y = UZI_YOFF; psp->ox = psp->x; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); pSetState(psp, psp->RestState); } } @@ -2281,8 +2281,8 @@ pUziPresentReload(PANEL_SPRITEp psp) { psp->oy = psp->y = UZI_YOFF; psp->ox = psp->x; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); pSetState(psp, psp->RestState); } } @@ -2293,8 +2293,8 @@ pUziBobSetup(PANEL_SPRITEp psp) if (TEST(psp->flags, PANF_BOB)) return; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); psp->sin_amt = 12; psp->sin_ndx = 0; @@ -2959,7 +2959,7 @@ pShotgunPresent(PANEL_SPRITEp psp) if (psp->y < SHOTGUN_YOFF) { psp->oy = psp->y = SHOTGUN_YOFF; - psp->yorig = psp->y; + psp->yorig = int(psp->y); pSetState(psp, psp->RestState); } } @@ -2970,8 +2970,8 @@ pShotgunBobSetup(PANEL_SPRITEp psp) if (TEST(psp->flags, PANF_BOB)) return; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); psp->sin_amt = 12; psp->sin_ndx = 0; @@ -3425,7 +3425,7 @@ pRailPresent(PANEL_SPRITEp psp) if (psp->y < RAIL_YOFF) { psp->oy = psp->y = RAIL_YOFF; - psp->yorig = psp->y; + psp->yorig = int(psp->y); pSetState(psp, psp->RestState); } } @@ -3436,8 +3436,8 @@ pRailBobSetup(PANEL_SPRITEp psp) if (TEST(psp->flags, PANF_BOB)) return; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); psp->sin_amt = 12; psp->sin_ndx = 0; @@ -3847,7 +3847,7 @@ pHotheadPresent(PANEL_SPRITEp psp) if (psp->y < HOTHEAD_YOFF) { psp->oy = psp->y = HOTHEAD_YOFF; - psp->yorig = psp->y; + psp->yorig = int(psp->y); pSetState(psp, psp->RestState); //pSetState(psp, HotheadTurnStates[psp->PlayerP->WpnFlameType]); } @@ -3859,8 +3859,8 @@ pHotheadBobSetup(PANEL_SPRITEp psp) if (TEST(psp->flags, PANF_BOB)) return; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); psp->sin_amt = HOTHEAD_BOB_X_AMT; psp->sin_ndx = 0; @@ -4309,7 +4309,7 @@ pMicroPresent(PANEL_SPRITEp psp) if (psp->y < MICRO_YOFF) { psp->oy = psp->y = MICRO_YOFF; - psp->yorig = psp->y; + psp->yorig = int(psp->y); if (pp->WpnRocketType == 2 && !pp->NukeInitialized) { pp->TestNukeInit = false; @@ -4326,8 +4326,8 @@ pMicroBobSetup(PANEL_SPRITEp psp) if (TEST(psp->flags, PANF_BOB)) return; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); psp->sin_amt = MICRO_BOB_X_AMT; psp->sin_ndx = 0; @@ -4733,7 +4733,7 @@ pHeartPresent(PANEL_SPRITEp psp) if (psp->y < HEART_YOFF) { psp->oy = psp->y = HEART_YOFF; - psp->yorig = psp->y; + psp->yorig = int(psp->y); pSetState(psp, psp->RestState); } } @@ -4744,8 +4744,8 @@ pHeartBobSetup(PANEL_SPRITEp psp) if (TEST(psp->flags, PANF_BOB)) return; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); psp->sin_amt = 12; psp->sin_ndx = 0; @@ -5318,7 +5318,7 @@ pGrenadePresent(PANEL_SPRITEp psp) psp->ox = psp->x = GRENADE_XOFF; psp->oy = psp->y = GRENADE_YOFF; psp->rotate_ang = 0; - psp->yorig = psp->y; + psp->yorig = int(psp->y); pSetState(psp, psp->RestState); } } @@ -5329,8 +5329,8 @@ pGrenadeBobSetup(PANEL_SPRITEp psp) if (TEST(psp->flags, PANF_BOB)) return; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); psp->sin_amt = 12; psp->sin_ndx = 0; @@ -5569,7 +5569,7 @@ pMinePresent(PANEL_SPRITEp psp) { psp->oy = psp->y = MINE_YOFF; psp->rotate_ang = 0; - psp->yorig = psp->y; + psp->yorig = int(psp->y); pSetState(psp, psp->RestState); } } @@ -5580,8 +5580,8 @@ pMineBobSetup(PANEL_SPRITEp psp) if (TEST(psp->flags, PANF_BOB)) return; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); psp->sin_amt = 12; psp->sin_ndx = 0; @@ -6201,7 +6201,7 @@ pFistPresent(PANEL_SPRITEp psp) if (psp->y < FIST_YOFF) { psp->oy = psp->y = FIST_YOFF; - psp->yorig = psp->y; + psp->yorig = int(psp->y); rnd = RANDOM_RANGE(1000); if (rnd > 500) @@ -6248,7 +6248,7 @@ pFistSlide(PANEL_SPRITEp psp) //psp->xfract = LSW(nx); //psp->x = FixedToFloat(nx); psp->yfract = LSW(ny); - psp->y = FixedToFloat(ny); + psp->y = ny * (1. / FRACUNIT); psp->vel += vel_adj * synctics; } @@ -6284,9 +6284,9 @@ pFistSlideDown(PANEL_SPRITEp psp) psp->oy = psp->y; psp->xfract = LSW(nx); - psp->x = FixedToFloat(nx); + psp->x = nx * (1. / FRACUNIT); psp->yfract = LSW(ny); - psp->y = FixedToFloat(ny); + psp->y = ny * (1. / FRACUNIT); psp->vel += vel_adj * synctics; @@ -6314,7 +6314,7 @@ pFistSlideDown(PANEL_SPRITEp psp) psp->ox = psp->x = FIST_XOFF; psp->oy = psp->y = FIST_YOFF; - psp->yorig = psp->y; + psp->yorig = int(psp->y); psp->PlayerP->FistAng = FistAngTable[RANDOM_RANGE(SIZ(FistAngTable))]; psp->ang = 1024; psp->vel = vel; @@ -6330,7 +6330,7 @@ pFistSlideDown(PANEL_SPRITEp psp) psp->ox = psp->x = FISTR_XOFF+100; psp->oy = psp->y = FIST_YOFF; - psp->yorig = psp->y; + psp->yorig = int(psp->y); psp->ang = 1024; psp->PlayerP->FistAng = FistAngTable[RANDOM_RANGE(SIZ(FistAngTable))]; psp->vel = vel; @@ -6343,7 +6343,7 @@ pFistSlideDown(PANEL_SPRITEp psp) pSetState(psp, psp->PresentState); psp->ox = psp->x = FIST_XOFF; psp->oy = psp->y = FIST_YOFF + tileHeight(psp->picndx); - psp->yorig = psp->y; + psp->yorig = int(psp->y); } } @@ -6377,7 +6377,7 @@ pFistSlideR(PANEL_SPRITEp psp) //psp->xfract = LSW(nx); //psp->x = FixedToFloat(nx); psp->yfract = LSW(ny); - psp->y = FixedToFloat(ny); + psp->y = ny * (1. / FRACUNIT); psp->vel += vel_adj * synctics; } @@ -6413,9 +6413,9 @@ pFistSlideDownR(PANEL_SPRITEp psp) psp->oy = psp->y; psp->xfract = LSW(nx); - psp->x = FixedToFloat(nx); + psp->x = nx * (1. / FRACUNIT); psp->yfract = LSW(ny); - psp->y = FixedToFloat(ny); + psp->y = ny * (1. / FRACUNIT); psp->vel += vel_adj * synctics; @@ -6436,7 +6436,7 @@ pFistSlideDownR(PANEL_SPRITEp psp) psp->ox = psp->x = FISTR_XOFF+100; psp->oy = psp->y = FIST_YOFF; - psp->yorig = psp->y; + psp->yorig = int(psp->y); psp->ang = 1024; psp->PlayerP->FistAng = FistAngTable[RANDOM_RANGE(SIZ(FistAngTable))]; psp->vel = vel; @@ -6452,7 +6452,7 @@ pFistSlideDownR(PANEL_SPRITEp psp) psp->ox = psp->x = FIST_XOFF; psp->oy = psp->y = FIST_YOFF; - psp->yorig = psp->y; + psp->yorig = int(psp->y); psp->PlayerP->FistAng = FistAngTable[RANDOM_RANGE(SIZ(FistAngTable))]; psp->ang = 1024; psp->vel = vel; @@ -6465,7 +6465,7 @@ pFistSlideDownR(PANEL_SPRITEp psp) pSetState(psp, psp->PresentState); psp->ox = psp->x = FIST_XOFF; psp->oy = psp->y = FIST_YOFF + tileHeight(psp->picndx); - psp->yorig = psp->y; + psp->yorig = int(psp->y); } } @@ -6475,8 +6475,8 @@ pFistBobSetup(PANEL_SPRITEp psp) if (TEST(psp->flags, PANF_BOB)) return; - psp->xorig = psp->x; - psp->yorig = psp->y; + psp->xorig = int(psp->x); + psp->yorig = int(psp->y); psp->sin_amt = FIST_SWAY_AMT; psp->sin_ndx = 0; @@ -6921,7 +6921,7 @@ pDisplaySprites(PLAYERp pp, double smoothratio) y += looking_arc; // initilize pal here - jack with it below - pal = psp->pal; + pal = uint8_t(psp->pal); if (DrawBeforeView) if (!TEST(psp->flags, PANF_DRAW_BEFORE_VIEW)) @@ -7054,7 +7054,7 @@ pDisplaySprites(PLAYERp pp, double smoothratio) } if (pal == PALETTE_FOG || pal == PALETTE_DIVE || pal == PALETTE_DIVE_LAVA) - pal = psp->pal; // Set it back + pal = uint8_t(psp->pal); // Set it back } /////////// diff --git a/source/games/sw/src/panel.h b/source/games/sw/src/panel.h index 3a64f3f6f..0ff3c5b03 100644 --- a/source/games/sw/src/panel.h +++ b/source/games/sw/src/panel.h @@ -33,8 +33,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS -#define FRAG_BAR 2920 - #define PRI_FRONT_MAX 250 #define PRI_FRONT 192 #define PRI_MID 128 diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 3ae5d7172..276bc2152 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -55,6 +55,7 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "raze_music.h" #include "v_draw.h" #include "gamestate.h" +#include "vm.h" BEGIN_SW_NS @@ -1198,7 +1199,7 @@ DoPickTarget(SPRITEp sp, uint32_t max_delta_ang, int skip_targets) // Get the angle difference // delta_ang = labs(pp->angle.ang.asbuild() - angle2); - delta_ang = labs(getincangle(angle2, sp->ang)); + delta_ang = short(abs(getincangle(angle2, sp->ang))); // If delta_ang not in the range skip this one if (delta_ang > (int)max_delta_ang) @@ -1554,13 +1555,13 @@ DoPlayerTurnVehicle(PLAYERp pp, float avel, int z, int floor_dist) if (sop->drive_angspeed) { float drive_oavel = pp->drive_avel; - pp->drive_avel = (MulScaleF(avel, sop->drive_angspeed, 16) + (drive_oavel * (sop->drive_angslide - 1))) / sop->drive_angslide; + pp->drive_avel = float((MulScaleF(avel, sop->drive_angspeed, 16) + (drive_oavel * (sop->drive_angslide - 1))) / sop->drive_angslide); avel = pp->drive_avel; } else { - avel = avel * synctics * 0.125; + avel *= synctics * 0.125f; } if (avel != 0) @@ -1583,13 +1584,13 @@ DoPlayerTurnVehicleRect(PLAYERp pp, int *x, int *y, int *ox, int *oy) if (sop->drive_angspeed) { float drive_oavel = pp->drive_avel; - pp->drive_avel = (MulScaleF(pp->input.avel, sop->drive_angspeed, 16) + (drive_oavel * (sop->drive_angslide - 1))) / sop->drive_angslide; + pp->drive_avel = float((MulScaleF(pp->input.avel, sop->drive_angspeed, 16) + (drive_oavel * (sop->drive_angslide - 1))) / sop->drive_angslide); avel = pp->drive_avel; } else { - avel = pp->input.avel * synctics * 0.125; + avel = pp->input.avel * synctics * 0.125f; } if (avel != 0) @@ -1612,16 +1613,16 @@ DoPlayerTurnTurret(PLAYERp pp, float avel) if (sop->drive_angspeed) { float drive_oavel = pp->drive_avel; - pp->drive_avel = (MulScaleF(avel, sop->drive_angspeed, 16) + (drive_oavel * (sop->drive_angslide - 1))) / sop->drive_angslide; + pp->drive_avel = float((MulScaleF(avel, sop->drive_angspeed, 16) + (drive_oavel * (sop->drive_angslide - 1))) / sop->drive_angslide); avel = pp->drive_avel; } else { - avel = avel * synctics * 0.25; + avel = avel * synctics * 0.25f; } - if (avel != 0) + if (fabs(avel) >= FLT_EPSILON) { new_ang = pp->angle.ang + degang(avel); @@ -1629,9 +1630,9 @@ DoPlayerTurnTurret(PLAYERp pp, float avel) { diff = getincanglebam(buildang(sop->limit_ang_center), new_ang); - if (labs(diff.asbuild()) >= sop->limit_ang_delta) + if (labs(diff.signedbuild()) >= sop->limit_ang_delta) { - if (diff.asbam() < 0) + if (diff.asbam() > INT32_MAX) new_ang = buildang(sop->limit_ang_center - sop->limit_ang_delta); else new_ang = buildang(sop->limit_ang_center + sop->limit_ang_delta); @@ -2458,7 +2459,7 @@ void DoTankTreads(PLAYERp pp) for (sectp = pp->sop->sectp, j = 0; *sectp; sectp++, j++) { - SectIterator it(*sectp - sector); + SectIterator it(int(*sectp - sector)); while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; @@ -2694,7 +2695,7 @@ DriveCrush(PLAYERp pp, int *x, int *y) // if it ends up actually in the drivable sector kill it for (sectp = sop->sectp; *sectp; sectp++) { - SectIterator it((*sectp) - sector); + SectIterator it(int(*sectp - sector)); while ((i = it.NextIndex()) >= 0) { sp = &sprite[i]; @@ -2861,7 +2862,7 @@ DoPlayerMoveVehicle(PLAYERp pp) else u->ret = 0; - VehicleMoveHit(sp - sprite); + VehicleMoveHit(short(sp - sprite)); } if (!TEST(sop->flags, SOBJ_NO_QUAKE)) @@ -2906,7 +2907,7 @@ DoPlayerMoveVehicle(PLAYERp pp) if (vel > 13000) { - VehicleMoveHit(sp - sprite); + VehicleMoveHit(short(sp - sprite)); pp->slide_xvect = -pp->xvect<<1; pp->slide_yvect = -pp->yvect<<1; if (!TEST(sop->flags, SOBJ_NO_QUAKE)) @@ -3462,7 +3463,11 @@ DoPlayerClimb(PLAYERp pp) DoPlayerZrange(pp); - ASSERT(pp->LadderSector >= 0 && pp->LadderSector <= MAXSECTORS); + if (pp->LadderSector < 0 || pp->LadderSector > MAXSECTORS) + { + Printf("Bad ladder sector!\n"); + return; + } // moving UP if (climbvel > 0) @@ -3573,8 +3578,6 @@ DoPlayerClimb(PLAYERp pp) if (wal >= 0) { - pp->LadderSector = wall[wal].nextsector; - lsp = FindNearSprite(pp->SpriteP, STAT_CLIMB_MARKER); // determine where the player is supposed to be in relation to the ladder @@ -3583,7 +3586,7 @@ DoPlayerClimb(PLAYERp pp) ny = MOVEy(100, lsp->ang); // set ladder sector - pp->LadderSector = wall[wal].nextsector; + pp->LadderSector = wall[wal].nextsector >= 0? wall[wal].nextsector : wall[wal].sector; // set players "view" distance from the ladder - needs to be farther than // the sprite @@ -3994,7 +3997,7 @@ PlayerOnLadder(PLAYERp pp) } #endif - pp->LadderSector = wall[wal].nextsector; + pp->LadderSector = wall[wal].nextsector >= 0 ? wall[wal].nextsector : wall[wal].sector; //DSPRINTF(ds, "Ladder Sector %d", pp->LadderSector); MONO_PRINT(ds); @@ -4809,7 +4812,7 @@ DoPlayerDive(PLAYERp pp) int nx,ny; PlaySound(DIGI_BUBBLES, pp, v3df_none); - bubble = SpawnBubble(pp->SpriteP - sprite); + bubble = SpawnBubble(short(pp->SpriteP - sprite)); if (bubble >= 0) { bp = &sprite[bubble]; @@ -7318,7 +7321,7 @@ void PlayerSpawnPosition(PLAYERp pp) { SPRITEp sp; - short pnum = pp - Player; + short pnum = short(pp - Player); short spawn_sprite = 0, pos_num = pnum; int fz,cz; int i; @@ -7595,4 +7598,175 @@ saveable_module saveable_player = saveable_player_data, SIZ(saveable_player_data) }; + +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, sop_remote) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, jump_count) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, jump_speed) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, down_speed) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, up_speed) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, z_speed) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, oz_speed) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, climb_ndx) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, hiz) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, loz) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, ceiling_dist) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, floor_dist) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, circle_camera_dist) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, six) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, siy) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, siz) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, siang) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, xvect) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, yvect) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, oxvect) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, oyvect) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, friction) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, slide_xvect) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, slide_yvect) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, slide_ang) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, slide_dec) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, drive_avel) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, view_outside_dang) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, circle_camera_ang) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, camera_check_time_delay) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, cursectnum) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, lastcursectnum) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, turn180_target) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, hvel) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, tilt) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, tilt_dest) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, recoil_amt) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, recoil_speed) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, recoil_ndx) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, recoil_horizoff) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, oldposx) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, oldposy) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, oldposz) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, RevolveX) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, RevolveY) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, RevolveDeltaAng) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, pnum) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, LadderSector) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, lx) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, ly) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, JumpDuration) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WadeDepth) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, bob_amt) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, bob_ndx) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, bcnt) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, bob_z) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, obob_z) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, playerreadyflag) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, Flags) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, Flags2) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, HasKey) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, SwordAng) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnGotOnceFlags) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnFlags) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnAmmo) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnNum) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnRocketType) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnRocketHeat) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnRocketNuke) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnFlameType) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnFirstType) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WeaponType) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, FirePause) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, InventoryNum) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, InventoryBarTics) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, InventoryTics) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, InventoryPercent) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, InventoryAmount) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, InventoryActive) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, DiveTics) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, DiveDamageTics) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, DeathType) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, Kills) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, SecretsFound) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, Armor) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, MaxHealth) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, UziShellLeftAlt) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, UziShellRightAlt) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, TeamColor) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, FadeTics) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, FadeAmt) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, NightVision) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, StartColor) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, IsAI) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, fta) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, ftq) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, NumFootPrints) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnUziType) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnShotgunType) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnShotgunAuto) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnShotgunLastShell) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnRailType) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, Bloody) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, InitingNuke) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, TestNukeInit) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, NukeInitialized) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, FistAng) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnKungFuMove) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, HitBy) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, Reverb) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, Heads) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, PlayerVersion) +DEFINE_FIELD_X(SWPlayer, PLAYERstruct, WpnReloadState) + +DEFINE_ACTION_FUNCTION(_SWPlayer, WeaponNum) +{ + PARAM_SELF_STRUCT_PROLOGUE(PLAYERstruct); + USERp uu = User[self->PlayerSprite].Data(); + ACTION_RETURN_INT(uu->WeaponNum); +} + +DEFINE_ACTION_FUNCTION(_SWPlayer, Health) +{ + PARAM_SELF_STRUCT_PROLOGUE(PLAYERstruct); + USERp uu = User[self->PlayerSprite].Data(); + ACTION_RETURN_INT(uu->Health); +} + +DEFINE_ACTION_FUNCTION(_SWPlayer, MaxUserHealth) +{ + PARAM_SELF_STRUCT_PROLOGUE(PLAYERstruct); + USERp uu = User[self->PlayerSprite].Data(); + ACTION_RETURN_INT(uu->MaxHealth); +} + +DEFINE_ACTION_FUNCTION(_SWPlayer, GetBuildAngle) +{ + PARAM_SELF_STRUCT_PROLOGUE(PLAYERstruct); + ACTION_RETURN_INT(self->angle.ang.asbuild()); +} + +DEFINE_ACTION_FUNCTION(_SW, WeaponMaxAmmo) +{ + PARAM_PROLOGUE; + PARAM_INT(wp); + ACTION_RETURN_INT(DamageData[wp].max_ammo); +} + +DEFINE_ACTION_FUNCTION(_SW, InventoryFlags) +{ + PARAM_PROLOGUE; + PARAM_INT(inv); + INVENTORY_DATAp id = &InventoryData[inv]; + ACTION_RETURN_INT(id->Flags); +} + +DEFINE_ACTION_FUNCTION(_SW, GetViewPlayer) +{ + PARAM_PROLOGUE; + ACTION_RETURN_POINTER(&Player[screenpeek]); +} + +DEFINE_ACTION_FUNCTION(_SW, RealWeapon) +{ + PARAM_PROLOGUE; + PARAM_INT(inv); + int w = DamageData[inv].with_weapon; + ACTION_RETURN_INT(w == -1? inv : w); +} + END_SW_NS diff --git a/source/games/sw/src/quake.cpp b/source/games/sw/src/quake.cpp index d15e03687..caa3b0138 100644 --- a/source/games/sw/src/quake.cpp +++ b/source/games/sw/src/quake.cpp @@ -268,7 +268,7 @@ int SpawnQuake(short sectnum, int x, int y, int z, sp->extra = 0; QUAKE_Match(sp) = -1; - QUAKE_Zamt(sp) = amt; + QUAKE_Zamt(sp) = uint8_t(amt); QUAKE_Radius(sp) = radius/8; QUAKE_Duration(sp) = tics; QUAKE_AngAmt(sp) = 8; diff --git a/source/games/sw/src/ripper.cpp b/source/games/sw/src/ripper.cpp index 6c56ec857..2ec0e154e 100644 --- a/source/games/sw/src/ripper.cpp +++ b/source/games/sw/src/ripper.cpp @@ -863,12 +863,12 @@ SetupRipper(short SpriteNum) } int -GetJumpHeight(short jump_speed, short jump_grav) +GetJumpHeight(int jump_speed, int jump_grav) { int jump_iterations; int height; - jump_speed = labs(jump_speed); + jump_speed = abs(jump_speed); jump_iterations = jump_speed / (jump_grav * ACTORMOVETICS); diff --git a/source/games/sw/src/rooms.cpp b/source/games/sw/src/rooms.cpp index cf561f10b..9f614a576 100644 --- a/source/games/sw/src/rooms.cpp +++ b/source/games/sw/src/rooms.cpp @@ -838,14 +838,18 @@ FindCeilingView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum if (*sectnum < 0) return false; - ASSERT(sp); - ASSERT(sp->hitag == VIEW_THRU_FLOOR); + if (!sp || sp->hitag != VIEW_THRU_FLOOR) + { + *sectnum = 0; + return false; + } - pix_diff = labs(z - sector[sp->sectnum].floorz) >> 8; - newz = sector[sp->sectnum].floorz + ((pix_diff / 128) + 1) * Z(128); if (!testnewrenderer) { + pix_diff = labs(z - sector[sp->sectnum].floorz) >> 8; + newz = sector[sp->sectnum].floorz + ((pix_diff / 128) + 1) * Z(128); + it.Reset(STAT_FAF); while ((i = it.NextIndex()) >= 0) { @@ -932,15 +936,18 @@ FindFloorView(short match, int32_t* x, int32_t* y, int32_t z, int16_t* sectnum) if (*sectnum < 0) return false; - ASSERT(sp); - ASSERT(sp->hitag == VIEW_THRU_CEILING); - - // move ceiling multiple of 128 so that the wall tile will line up - pix_diff = labs(z - sector[sp->sectnum].ceilingz) >> 8; - newz = sector[sp->sectnum].ceilingz - ((pix_diff / 128) + 1) * Z(128); + if (!sp || sp->hitag != VIEW_THRU_CEILING) + { + *sectnum = 0; + return false; + } if (!testnewrenderer) { + // move ceiling multiple of 128 so that the wall tile will line up + pix_diff = labs(z - sector[sp->sectnum].ceilingz) >> 8; + newz = sector[sp->sectnum].ceilingz - ((pix_diff / 128) + 1) * Z(128); + it.Reset(STAT_FAF); while ((i = it.NextIndex()) >= 0) { diff --git a/source/games/sw/src/saveable.cpp b/source/games/sw/src/saveable.cpp index 0c1674c97..85917d0e5 100644 --- a/source/games/sw/src/saveable.cpp +++ b/source/games/sw/src/saveable.cpp @@ -131,7 +131,7 @@ int Saveable_FindDataSym(void *ptr, saveddatasym *sym) sym->module = 1+m; sym->index = i; - sym->offset = (intptr_t)ptr - (intptr_t)saveablemodules[m]->data[i].base; + sym->offset = unsigned((intptr_t)ptr - (intptr_t)saveablemodules[m]->data[i].base); return 0; } diff --git a/source/games/sw/src/sbar.cpp b/source/games/sw/src/sbar.cpp index 325c5f6b9..403cca123 100644 --- a/source/games/sw/src/sbar.cpp +++ b/source/games/sw/src/sbar.cpp @@ -46,1003 +46,6 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms BEGIN_SW_NS -enum -{ - ID_PanelMedkit = 2396, - ID_PanelRepairKit = 2399, - ID_PanelCloak = 2397, //2400 - ID_PanelNightVision = 2398, - ID_PanelChemBomb = 2407, - ID_PanelFlashBomb = 2408, - ID_PanelCaltrops = 2409, -}; - -static const short icons[] = { - ID_PanelMedkit, - ID_PanelRepairKit, - ID_PanelCloak, - ID_PanelNightVision, - ID_PanelChemBomb, - ID_PanelFlashBomb, - ID_PanelCaltrops, -}; - -class DSWStatusBar : public DBaseStatusBar -{ - DECLARE_CLASS(DSWStatusBar, DBaseStatusBar) - HAS_OBJECT_POINTERS - - TObjPtr miniFont, numberFont; - - enum - { - PANEL_HEALTH_BOX_X = 20, - PANEL_BOX_Y = (174 - 6), - PANEL_HEALTH_XOFF = 2, - PANEL_HEALTH_YOFF = 4, - - PANEL_AMMO_BOX_X = 197, - PANEL_AMMO_XOFF = 1, - PANEL_AMMO_YOFF = 4, - - WSUM_X = 93, - WSUM_Y = PANEL_BOX_Y+1, - WSUM_XOFF = 25, - WSUM_YOFF = 6, - - PANEL_KEYS_BOX_X = 276, - PANEL_KEYS_XOFF = 0, - PANEL_KEYS_YOFF = 2, - - PANEL_ARMOR_BOX_X = 56, - PANEL_ARMOR_XOFF = 2, - PANEL_ARMOR_YOFF = 4, - - FRAG_YOFF = 2, - - INVENTORY_BOX_X = 231, - INVENTORY_BOX_Y = (176-8), - - INVENTORY_PIC_XOFF = 1, - INVENTORY_PIC_YOFF = 1, - - INVENTORY_PERCENT_XOFF = 19, - INVENTORY_PERCENT_YOFF = 13, - - INVENTORY_STATE_XOFF = 19, - INVENTORY_STATE_YOFF = 1, - - MINI_BAR_Y = 174 , - MINI_BAR_HEALTH_BOX_X = 4, - MINI_BAR_AMMO_BOX_X = 32, - MINI_BAR_INVENTORY_BOX_X = 64, - MINI_BAR_INVENTORY_BOX_Y = MINI_BAR_Y, - - }; - - enum - { - PANEL_FONT_G = 3636, - PANEL_FONT_Y = 3646, - PANEL_FONT_R = 3656, - - PANEL_SM_FONT_G = 3601, - PANEL_SM_FONT_Y = 3613, - PANEL_SM_FONT_R = 3625, - - PANEL_KEY_RED = 2392, - PANEL_KEY_GREEN = 2393, - PANEL_KEY_BLUE = 2394, - PANEL_KEY_YELLOW = 2395, - PANEL_SKELKEY_GOLD = 2448, - PANEL_SKELKEY_SILVER= 2449, - PANEL_SKELKEY_BRONZE= 2458, - PANEL_SKELKEY_RED = 2459, - - MINI_BAR_HEALTH_BOX_PIC = 2437, - MINI_BAR_AMMO_BOX_PIC = 2437, - MINI_BAR_INVENTORY_BOX_PIC = 2438, - - ID_SelectionBox = 2435, - }; - - -public: - DSWStatusBar() - { - numberFont = Create( BigFont, 0, Off, 1, 1 ); - miniFont = Create(SmallFont2, 0, Off, 1, 1 ); - } - -private: - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DisplayPanelNumber(double xs, double ys, int number) - { - char buffer[32]; - char* ptr; - double x; - - mysnprintf(buffer, 32, "%03d", number); - - for (ptr = buffer, x = xs; *ptr; ptr++) - { - if (!isdigit(*ptr)) - { - continue; - } - int tex = PANEL_FONT_G + (*ptr - '0'); - DrawGraphic(tileGetTexture(tex), x, ys, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); - x += tileWidth(tex) + 1; - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DisplaySummaryString(double xs, double ys, int color, int shade, const char* buffer) - { - double x; - const char* ptr; - char ch; - int font_pic; - static const short font_base[] = { PANEL_SM_FONT_G, PANEL_SM_FONT_Y, PANEL_SM_FONT_R }; - - assert(color < 3); - for (ptr = buffer, x = xs; *ptr; ptr++) - { - ch = *ptr; - if (ch == ' ') - { - x += 4; - continue; - } - - switch (ch) - { - case '\\': - ch = '0' - 1; // one pic before 0 - break; - case ':': - ch = '9' + 1; // one pic after nine - break; - } - - font_pic = font_base[color] + (ch - '0'); - DrawGraphic(tileGetTexture(font_pic), x, ys, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1, STYLE_Translucent, shadeToLight(shade)); - x += tileWidth(font_pic) + 1; - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DisplayTimeLimit(PLAYERp pp) - { - int seconds = gNet.TimeLimitClock / 120; - sprintf(ds, "%03d:%02d", seconds / 60, seconds % 60); - DisplaySummaryString(PANEL_KEYS_BOX_X + 1, PANEL_BOX_Y + 6, 0, 0, ds); - } - - //--------------------------------------------------------------------------- - // - // todo: migrate to FFont to support localization - // - //--------------------------------------------------------------------------- - - void DisplayTinyString(double xs, double ys, const char* buffer, int pal) - { - SBar_DrawString(this, miniFont, buffer, xs, ys, DI_ITEM_LEFT_TOP, CR_UNTRANSLATED, 1, -1, -1, 1, 1); - } - - void DisplayFragString(PLAYERp pp, double xs, double ys, const char* buffer) - { - DisplayTinyString(xs, ys, buffer, User[pp->SpriteP - sprite]->spal); - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DisplayFragNumbers() - { - for (int pnum = 0; pnum < 4; pnum++) - { - char buffer[32]; - short xs, ys; - short frag_bar; - - static int xoffs[] = - { - 69, 147, 225, 303 - }; - - ys = FRAG_YOFF; - - // frag bar 0 or 1 - frag_bar = ((pnum) / 4); - // move y down according to frag bar number - ys = ys + (tileHeight(FRAG_BAR) - 2) * frag_bar; - - // move x over according to the number of players - xs = xoffs[MOD4(pnum)]; - - mysnprintf(buffer, 32, "%03d", Player[pnum].Kills); - - DisplayFragString(&Player[pnum], xs, ys, buffer); - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DisplayFragNames() - { - for (int pnum = 0; pnum < 4; pnum++) - { - short xs, ys; - short frag_bar; - - static int xoffs[] = - { - 7, 85, 163, 241 - }; - - ys = FRAG_YOFF; - - // frag bar 0 or 1 - frag_bar = ((pnum) / 4); - // move y down according to frag bar number - ys = ys + (tileHeight(FRAG_BAR) - 2) * frag_bar; - - // move x over according to the number of players - xs = xoffs[MOD4(pnum)]; - - DisplayFragString(&Player[pnum], xs, ys, Player[pnum].PlayerName); - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DisplayFragBar(PLAYERp pp) - { - // must draw this in HUD mode and align to the top center - short i, num_frag_bars; - int y; - - if (numplayers <= 1) - return; - - if (gNet.MultiGameType == MULTI_GAME_COOPERATIVE) - return; - - // if player sprite has not been initialized we have no business - // sticking a frag bar up. Prevents processing from MenuLevel etc. - if (!pp->SpriteP) - return; - - //num_frag_bars = ((numplayers-1)/4)+1; - num_frag_bars = ((OrigCommPlayers - 1) / 4) + 1; - - for (i = windowxy1.x; i <= windowxy2.x; i++) - { - y = (tileHeight(FRAG_BAR) * num_frag_bars) - (2 * (num_frag_bars - 1)); - y = y * (ydim / 200.0); - } - - for (i = 0, y = 0; i < num_frag_bars; i++) - { - DrawGraphic(tileGetTexture(FRAG_BAR), 0, y, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); - y += tileHeight(FRAG_BAR) - 2; - } - DisplayFragNames(); - DisplayFragNumbers(); - } - - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void PlayerUpdateWeaponSummary(PLAYERp pp, int UpdateWeaponNum) - { - USERp u = User[pp->PlayerSprite].Data(); - int x, y; - int pos; - int column; - int WeaponNum, wpntmp; - int color, shade; - char ds[32]; - - WeaponNum = UpdateWeaponNum; - - if (DamageData[WeaponNum].with_weapon != -1) - { - WeaponNum = DamageData[WeaponNum].with_weapon; - } - - static short wsum_xoff[3] = { 0,36,66 }; - static const char* wsum_fmt2[3] = { "%3d/%-3d", "%2d/%-2d", "%2d/%-2d" }; - - pos = WeaponNum - 1; - column = pos / 3; - if (column > 2) column = 2; - x = WSUM_X + wsum_xoff[column]; - y = WSUM_Y + (WSUM_YOFF * (pos % 3)); - - if (UpdateWeaponNum == u->WeaponNum) - { - shade = 0; - color = 0; - } - else - { - shade = 11; - color = 0; - } - - wpntmp = WeaponNum + 1; - if (wpntmp > 9) - wpntmp = 0; - mysnprintf(ds, 32, "%d:", wpntmp); - - if (TEST(pp->WpnFlags, BIT(WeaponNum))) - DisplaySummaryString(x, y, 1, shade, ds); - else - DisplaySummaryString(x, y, 2, shade + 6, ds); - - mysnprintf(ds, 32, wsum_fmt2[column], pp->WpnAmmo[WeaponNum], DamageData[WeaponNum].max_ammo); - DisplaySummaryString(x + 6, y, color, shade, ds); - } - - void PlayerUpdateWeaponSummaryAll(PLAYERp pp) - { - for (int i = WPN_STAR; i <= WPN_HEART; i++) - { - PlayerUpdateWeaponSummary(pp, i); - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DisplayKeys(PLAYERp pp, double xs, double ys, double scalex = 1, double scaley = 1) - { - double x, y; - int row, col; - int i, xsize, ysize; - - static short StatusKeyPics[] = - { - PANEL_KEY_RED, - PANEL_KEY_BLUE, - PANEL_KEY_GREEN, - PANEL_KEY_YELLOW, - PANEL_SKELKEY_GOLD, - PANEL_SKELKEY_SILVER, - PANEL_SKELKEY_BRONZE, - PANEL_SKELKEY_RED - }; - - - xsize = tileWidth(PANEL_KEY_RED) + 1; - ysize = tileHeight(PANEL_KEY_RED) + 2; - - i = 0; - for (row = 0; row < 2; row++) - { - for (col = 0; col < 2; col++) - { - if (pp->HasKey[i]) - { - x = xs + PANEL_KEYS_XOFF + (row * xsize); - y = ys + PANEL_KEYS_YOFF + (col * ysize); - DrawGraphic(tileGetTexture(StatusKeyPics[i]), x, y, DI_ITEM_LEFT_TOP, 1, -1, -1, scalex, scaley); - } - i++; - } - } - - // Check for skeleton keys - i = 0; - for (row = 0; row < 2; row++) - { - for (col = 0; col < 2; col++) - { - if (pp->HasKey[i + 4]) - { - x = xs + PANEL_KEYS_XOFF + (row * xsize); - y = ys + PANEL_KEYS_YOFF + (col * ysize); - DrawGraphic(tileGetTexture(StatusKeyPics[i + 4]), x, y, DI_ITEM_LEFT_TOP, 1, -1, -1, scalex, scaley); - } - i++; - } - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void PlayerUpdateInventoryPercent(PLAYERp pp, int InventoryBoxX, int InventoryBoxY, int InventoryXoff, int InventoryYoff) - { - char ds[32]; - INVENTORY_DATAp id = &InventoryData[pp->InventoryNum]; - - int x = InventoryBoxX + INVENTORY_PERCENT_XOFF + InventoryXoff; - int y = InventoryBoxY + INVENTORY_PERCENT_YOFF + InventoryYoff; - - if (TEST(id->Flags, INVF_COUNT)) - { - mysnprintf(ds, 32, "%d", pp->InventoryAmount[pp->InventoryNum]); - } - else - { - mysnprintf(ds, 32, "%d%c", pp->InventoryPercent[pp->InventoryNum], '%'); - } - DisplayTinyString(x, y, ds, 0); - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void PlayerUpdateInventoryPic(PLAYERp pp, int InventoryBoxX, int InventoryBoxY, int InventoryXoff, int InventoryYoff) - { - INVENTORY_DATAp id = &InventoryData[pp->InventoryNum]; - int x = InventoryBoxX + INVENTORY_PIC_XOFF + InventoryXoff; - int y = InventoryBoxY + INVENTORY_PIC_YOFF + InventoryYoff; - DrawGraphic(tileGetTexture(icons[pp->InventoryNum]), x, y, DI_ITEM_LEFT_TOP, 1, -1, -1, id->Scale/65536., id->Scale / 65536.); - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void PlayerUpdateInventoryState(PLAYERp pp, double InventoryBoxX, double InventoryBoxY, int InventoryXoff, int InventoryYoff) - { - char ds[32]; - INVENTORY_DATAp id = &InventoryData[pp->InventoryNum]; - - double x = InventoryBoxX + INVENTORY_STATE_XOFF + InventoryXoff; - double y = InventoryBoxY + INVENTORY_STATE_YOFF + InventoryYoff; - - if (TEST(id->Flags, INVF_AUTO_USE)) - { - DisplayTinyString(x, y, "AUTO", 0); - } - else if (TEST(id->Flags, INVF_TIMED)) - { - DisplayTinyString(x, y, pp->InventoryActive[pp->InventoryNum] ? "ON" : "OFF", 0); - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DisplayBarInventory(PLAYERp pp) - { - int InventoryBoxX = INVENTORY_BOX_X; - int InventoryBoxY = INVENTORY_BOX_Y; - - int InventoryXoff = -1; - int InventoryYoff = 0; - - // put pic - if (pp->InventoryAmount[pp->InventoryNum]) - { - PlayerUpdateInventoryPic(pp, InventoryBoxX, InventoryBoxY, 0, InventoryYoff); - // Auto/On/Off - PlayerUpdateInventoryState(pp, InventoryBoxX, InventoryBoxY, InventoryXoff, InventoryYoff); - // Percent count/Item count - PlayerUpdateInventoryPercent(pp, InventoryBoxX, InventoryBoxY, InventoryXoff, InventoryYoff); - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DrawCompass(PLAYERp pp) - { - enum - { - COMPASS_TIC = 2380, - COMPASS_TIC2 = 2381, - - COMPASS_NORTH = 2382, - COMPASS_NORTH2 = 2383, - - COMPASS_SOUTH = 2384, - COMPASS_SOUTH2 = 2385, - - COMPASS_EAST = 2386, - COMPASS_EAST2 = 2387, - - COMPASS_WEST = 2388, - COMPASS_WEST2 = 2389, - - COMPASS_MID_TIC = 2390, - COMPASS_MID_TIC2 = 2391, - - COMPASS_X = 140, - COMPASS_Y = (162-5), - }; - - auto NORM_CANG = [](int ang) { return (((ang)+32) & 31); }; - - int start_ang, ang; - int x_size = tileWidth(COMPASS_NORTH); - int x; - int i; - - static const short CompassPic[32] = - { - COMPASS_EAST, COMPASS_EAST2, - COMPASS_TIC, COMPASS_TIC2, - COMPASS_MID_TIC, COMPASS_MID_TIC2, - COMPASS_TIC, COMPASS_TIC2, - - COMPASS_SOUTH, COMPASS_SOUTH2, - COMPASS_TIC, COMPASS_TIC2, - COMPASS_MID_TIC, COMPASS_MID_TIC2, - COMPASS_TIC, COMPASS_TIC2, - - COMPASS_WEST, COMPASS_WEST2, - COMPASS_TIC, COMPASS_TIC2, - COMPASS_MID_TIC, COMPASS_MID_TIC2, - COMPASS_TIC, COMPASS_TIC2, - - COMPASS_NORTH, COMPASS_NORTH2, - COMPASS_TIC, COMPASS_TIC2, - COMPASS_MID_TIC, COMPASS_MID_TIC2, - COMPASS_TIC, COMPASS_TIC2, - }; - - static const short CompassShade[10] = - { - //20, 16, 11, 6, 1, 1, 6, 11, 16, 20 - 25, 19, 15, 9, 1, 1, 9, 15, 19, 25 - }; - - ang = pp->angle.ang.asbuild(); - - if (pp->sop_remote) - ang = 0; - - start_ang = (ang + 32) >> 6; - - start_ang = NORM_CANG(start_ang - 4); - - for (i = 0, x = COMPASS_X; i < 10; i++) - { - DrawGraphic(tileGetTexture(CompassPic[NORM_CANG(start_ang + i)]), x, COMPASS_Y, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1, STYLE_Translucent, shadeToLight(CompassShade[i])); - x += x_size; - } - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DrawStatusBar() - { - auto pp = Player + screenpeek; - USERp u = User[pp->PlayerSprite].Data(); - BeginStatusBar(320, 200, tileHeight(STATUS_BAR)); - - if (hud_size == Hud_StbarOverlay) Set43ClipRect(); - int left = (320 - tileWidth(STATUS_BAR)) / 2; - DrawGraphic(tileGetTexture(STATUS_BAR), left, 200, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, 1, 1); - twod->ClearClipRect(); - DisplayPanelNumber(PANEL_HEALTH_BOX_X + PANEL_HEALTH_XOFF, PANEL_BOX_Y + PANEL_HEALTH_YOFF, u->Health); - DisplayPanelNumber(PANEL_ARMOR_BOX_X + PANEL_ARMOR_XOFF, PANEL_BOX_Y + PANEL_ARMOR_YOFF, pp->Armor); - if (u->WeaponNum != WPN_FIST && u->WeaponNum != WPN_SWORD) - DisplayPanelNumber(PANEL_AMMO_BOX_X + PANEL_AMMO_XOFF, PANEL_BOX_Y + PANEL_AMMO_YOFF, pp->WpnAmmo[u->WeaponNum]); - PlayerUpdateWeaponSummaryAll(pp); - if (gNet.MultiGameType != MULTI_GAME_COMMBAT) - DisplayKeys(pp, PANEL_KEYS_BOX_X, PANEL_BOX_Y); - else if (gNet.TimeLimit) - DisplayTimeLimit(pp); - DisplayBarInventory(pp); - DrawCompass(pp); - PrintLevelStats(-3); - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DisplayMinibarInventory(PLAYERp pp) - { - int InventoryBoxX = MINI_BAR_INVENTORY_BOX_X; - int InventoryBoxY = MINI_BAR_INVENTORY_BOX_Y - 200; - - int InventoryXoff = 0; - int InventoryYoff = 1; - - if (pp->InventoryAmount[pp->InventoryNum]) - { - PlayerUpdateInventoryPic(pp, InventoryBoxX, InventoryBoxY, InventoryXoff+1, InventoryYoff); - // Auto/On/Off - PlayerUpdateInventoryState(pp, InventoryBoxX, InventoryBoxY, InventoryXoff, InventoryYoff); - // Percent count/Item count - PlayerUpdateInventoryPercent(pp, InventoryBoxX, InventoryBoxY, InventoryXoff, InventoryYoff); - } - } - - //--------------------------------------------------------------------------- - // - // Used in DrawHUD2() for determining whether a reloadable weapon is reloading. - // - //--------------------------------------------------------------------------- - - bool DoReloadStatus(char *reloadstate, int ammo) - { - bool reloading = ammo == 0 && *reloadstate != 2; - - if (ammo == 0 && *reloadstate == 0) - { - *reloadstate = 1; - } - else if (ammo) - { - *reloadstate = 0; - } - - return reloading; - } - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DrawHUD1() - { - BeginHUD(320, 200, 1); - auto pp = Player + screenpeek; - USERp u = User[pp->PlayerSprite].Data(); - int x, y; - INVENTORY_DATAp id; - - x = MINI_BAR_HEALTH_BOX_X; - y = -26; - - DrawGraphic(tileGetTexture(MINI_BAR_HEALTH_BOX_PIC), x, y, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); - - x = MINI_BAR_HEALTH_BOX_X + 3; - DisplayPanelNumber(x, y + 5, u->Health); - - if (u->WeaponNum != WPN_SWORD && u->WeaponNum != WPN_FIST) - { - x = MINI_BAR_AMMO_BOX_X; - DrawGraphic(tileGetTexture(MINI_BAR_AMMO_BOX_PIC), x, y, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); - - x = MINI_BAR_AMMO_BOX_X + 3; - DisplayPanelNumber(x, y + 5, pp->WpnAmmo[u->WeaponNum]); - } - PrintLevelStats(30); - - if (!pp->InventoryAmount[pp->InventoryNum]) - return; - - // Inventory Box - x = MINI_BAR_INVENTORY_BOX_X; - - DrawGraphic(tileGetTexture(MINI_BAR_INVENTORY_BOX_PIC), x, y, DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); - DisplayMinibarInventory(pp); - } - - //========================================================================== - // - // Fullscreen HUD variant #1 - // - //========================================================================== - - void DrawHUD2() - { - BeginHUD(320, 200, 1); - - auto pp = Player + screenpeek; - USERp u = User[pp->PlayerSprite].Data(); - - FString format; - FGameTexture* img; - double imgScale; - double baseScale = numberFont->mFont->GetHeight() * 0.83125; - - // - // Health - // - img = tileGetTexture(ICON_SM_MEDKIT); - imgScale = baseScale / img->GetDisplayHeight(); - DrawGraphic(img, 1.5, -1, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale); - - if (!althud_flashing || u->Health > (u->MaxHealth >> 2) || (PlayClock & 32)) - { - int s = -8; - if (althud_flashing && u->Health > u->MaxHealth) - s += bsin(PlayClock << 5, -10); - int intens = clamp(255 - 4 * s, 0, 255); - auto pe = PalEntry(255, intens, intens, intens); - format.Format("%d", u->Health); - SBar_DrawString(this, numberFont, format, 24.25, -numberFont->mFont->GetHeight() + 2, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - } - - // - // Armor - // - img = tileGetTexture(ICON_ARMOR); - imgScale = baseScale / img->GetDisplayHeight(); - DrawGraphic(img, 80.75, -1, DI_ITEM_LEFT_BOTTOM, 1., -1, -1, imgScale, imgScale); - - format.Format("%d", pp->Armor); - SBar_DrawString(this, numberFont, format, 108.5, -numberFont->mFont->GetHeight() + 2, DI_TEXT_ALIGN_LEFT, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - - // - // Weapon - // - const short ammo_sprites[] = { -1, ICON_STAR, ICON_LG_SHOTSHELL, ICON_LG_UZI_AMMO, ICON_MICRO_BATTERY, ICON_LG_GRENADE, ICON_LG_MINE, ICON_RAIL_AMMO, - ICON_FIREBALL_LG_AMMO, ICON_HEART_LG_AMMO, ICON_FIREBALL_LG_AMMO, ICON_FIREBALL_LG_AMMO,ICON_MICRO_BATTERY, -1 }; - - int weapon = u->WeaponNum; - int wicon = ammo_sprites[weapon]; - if (wicon > 0) - { - int ammo = pp->WpnAmmo[weapon]; - bool reloadableWeapon = weapon == WPN_SHOTGUN || weapon == WPN_UZI; - if (!reloadableWeapon || (reloadableWeapon && !cl_showmagamt)) - { - format.Format("%d", ammo); - } - else - { - short capacity; - switch (weapon) - { - case WPN_SHOTGUN: - capacity = 4; - break; - case WPN_UZI: - capacity = pp->WpnUziType ? 50 : 100; - break; - } - short clip = CalcMagazineAmount(ammo, capacity, DoReloadStatus(&pp->WpnReloadState, ammo % capacity)); - format.Format("%d/%d", clip, ammo - clip); - } - img = tileGetTexture(wicon); - imgScale = baseScale / img->GetDisplayHeight(); - auto imgX = 21.125; - auto strlen = format.Len(); - - if (strlen > 1) - { - imgX += (imgX * 0.855) * (strlen - 1); - } - - if ((!althud_flashing || PlayClock & 32 || ammo > (DamageData[weapon].max_ammo / 10))) - { - SBar_DrawString(this, numberFont, format, -1.5, -numberFont->mFont->GetHeight() + 2, DI_TEXT_ALIGN_RIGHT, CR_UNTRANSLATED, 1, 0, 0, 1, 1); - } - - DrawGraphic(img, -imgX, -1, DI_ITEM_RIGHT_BOTTOM, 1, -1, -1, imgScale, imgScale); - } - - // - // Selected inventory item - // - img = tileGetTexture(icons[pp->InventoryNum]); - imgScale = baseScale / img->GetDisplayHeight(); - int x = 165; - DrawGraphic(img, x, -1, DI_ITEM_LEFT_BOTTOM, 1, -1, -1, imgScale, imgScale); - - PlayerUpdateInventoryState(pp, x + 3.0, -18.0, 1, 1); - PlayerUpdateInventoryPercent(pp, x + 3.5, -20.5, 1, 1); - - // - // keys - // - DisplayKeys(pp, -25, -38, 0.8625, 0.8625); - PrintLevelStats(int(baseScale + 4)); - } - - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- - - void DrawInventoryIcon(double xs, double ys, int align, int InventoryNum, int amount, bool selected) - { - double x, y; - const int INVENTORY_ICON_WIDTH = 28; - - // check invalid value - assert(InventoryNum < MAX_INVENTORY); - - x =xs + (InventoryNum * INVENTORY_ICON_WIDTH); - y = ys; - auto tex = icons[InventoryNum]; - auto scale = InventoryData[InventoryNum].Scale / 65536.; - DrawGraphic(tileGetTexture(tex), x, y, align | DI_ITEM_LEFT_TOP, amount? 1. : 0.333, -1, -1, scale, scale); - if (selected) - { - DrawGraphic(tileGetTexture(ID_SelectionBox), x-5, y-5, align | DI_ITEM_LEFT_TOP, 1, -1, -1, 1, 1); - } - } - - ////////////////////////////////////////////////////////////////////// - // - // INVENTORY BAR - // - ////////////////////////////////////////////////////////////////////// - - void DrawInventory(double xs, double ys, int align) - { - auto pp = Player + screenpeek; - short inv = 0; - INVENTORY_DATAp id; - - if (!pp->InventoryBarTics) - { - return; - } - - for (id = InventoryData; id->Name; id++, inv++) - { - DrawInventoryIcon(xs, ys, align, inv, pp->InventoryAmount[inv], inv == pp->InventoryNum); - } - } - - //========================================================================== - // - // Statistics output - // - //========================================================================== - - void PrintLevelStats(int bottomy) - { - FLevelStats stats{}; - stats.fontscale = 1; - stats.spacing = 7; - stats.screenbottomspace = bottomy; - stats.font = SmallFont; - stats.time = Scale(PlayClock, 1000, 120); - - if (automapMode == am_full) - { - stats.letterColor = CR_SAPPHIRE; - stats.standardColor = CR_UNTRANSLATED; - - bool textfont = am_textfont; - if (!am_textfont) - { - // For non-English languages force use of the text font. The tiny one is simply too small to ever add localized characters to it. - auto p = GStrings["REQUIRED_CHARACTERS"]; - if (p && *p) textfont = true; - } - - if (!textfont) - { - stats.font = SmallFont2; - stats.spacing = 6; - } - else stats.spacing = SmallFont->GetHeight() + 1; - DBaseStatusBar::PrintAutomapInfo(stats, textfont); - } - // JBF 20040124: display level stats in screen corner - else if (hud_stats && !(CommEnabled || numplayers > 1)) - { - auto pp = Player + screenpeek; - - stats.kills = Player->Kills; - stats.maxkills = TotalKillable; - stats.frags = -1; - stats.secrets = Player->SecretsFound; - stats.maxsecrets = LevelSecrets; - - stats.letterColor = CR_RED; - stats.standardColor = CR_TAN; - stats.completeColor = CR_FIRE; - - DBaseStatusBar::PrintLevelStats(stats); - } - } - - - //--------------------------------------------------------------------------- - // - // - // - //--------------------------------------------------------------------------- -public: - void UpdateStatusBar() - { - int nPalette = 0; - double inv_x, inv_y; - int align; - - if (hud_size == Hud_Nothing) - { - align = DI_SCREEN_RIGHT_BOTTOM; - inv_x = -210; - inv_y = -28; - PrintLevelStats(2); - } - else if (hud_size == Hud_full) - { - align = DI_SCREEN_CENTER_BOTTOM; - inv_x = -80; - inv_y = -40; - DrawHUD2(); - } - else if (hud_size == Hud_Mini) - { - align = DI_SCREEN_RIGHT_BOTTOM; - inv_x = -210; - inv_y = -28; - DrawHUD1(); - } - else - { - align = 0; - inv_x = 80; - inv_y = 130; - DrawStatusBar(); - } - DrawInventory(inv_x, inv_y, align); - } - -}; - -IMPLEMENT_CLASS(DSWStatusBar, false, true) -IMPLEMENT_POINTERS_START(DSWStatusBar) -IMPLEMENT_POINTER(miniFont) -IMPLEMENT_POINTER(numberFont) -IMPLEMENT_POINTERS_END - //--------------------------------------------------------------------------- // // @@ -1087,7 +90,16 @@ void UpdateStatusBar() UpdateFrame(); } - StatusBar->UpdateStatusBar(); + SummaryInfo info{}; + info.kills = Player[screenpeek].Kills; + info.maxkills = TotalKillable; + info.secrets = Player[screenpeek].SecretsFound; + info.maxsecrets = LevelSecrets; + info.time = Scale(PlayClock, 1000, 120); + + ::UpdateStatusBar(&info); + + PLAYERp pp = &Player[screenpeek]; if (pp->cookieTime > 0) { diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index dbd0f8844..0ad5cf85c 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -1512,7 +1512,7 @@ void DoDeleteSpriteMatch(short match) if (StatList[stat] == STAT_LIGHTING) { // set shade to darkest and then kill it - sprite[i].shade = SPRITE_TAG6(i); + sprite[i].shade = int8_t(SPRITE_TAG6(i)); sprite[i].pal = 0; SectorLightShade(&sprite[i], sprite[i].shade); DiffuseLighting(&sprite[i]); @@ -3211,8 +3211,8 @@ DoPanning(void) nx = MulScale(sp->xvel, bcos(sp->ang), 20); ny = MulScale(sp->xvel, bsin(sp->ang), 20); - sectp->addfloorxpan(nx); - sectp->addfloorypan(ny); + sectp->addfloorxpan((float)nx); + sectp->addfloorypan((float)ny); } it.Reset(STAT_CEILING_PAN); @@ -3224,8 +3224,8 @@ DoPanning(void) nx = MulScale(sp->xvel, bcos(sp->ang), 20); ny = MulScale(sp->xvel, bsin(sp->ang), 20); - sectp->addceilingxpan(nx); - sectp->addceilingypan(ny); + sectp->addceilingxpan((float)nx); + sectp->addceilingypan((float)ny); } it.Reset(STAT_WALL_PAN); @@ -3237,8 +3237,8 @@ DoPanning(void) nx = MulScale(sp->xvel, bcos(sp->ang), 20); ny = MulScale(sp->xvel, bsin(sp->ang), 20); - wallp->addxpan(nx); - wallp->addypan(ny); + wallp->addxpan((float)nx); + wallp->addypan((float)ny); } } diff --git a/source/games/sw/src/serp.cpp b/source/games/sw/src/serp.cpp index 911a29605..e905cc8ea 100644 --- a/source/games/sw/src/serp.cpp +++ b/source/games/sw/src/serp.cpp @@ -817,7 +817,7 @@ int DoDeathSpecial(short SpriteNum) if (!SW_SHAREWARE) { // Resume the regular music - in a hack-free fashion. - PlaySong(currentLevel->labelName, currentLevel->music, currentLevel->cdSongId); + PlaySong(currentLevel->music, currentLevel->cdSongId); } BossSpriteNum[0] = -2; diff --git a/source/games/sw/src/skull.cpp b/source/games/sw/src/skull.cpp index bb343a84c..3b8ac043b 100644 --- a/source/games/sw/src/skull.cpp +++ b/source/games/sw/src/skull.cpp @@ -394,7 +394,7 @@ int DoSkullJump(short SpriteNum) DISTANCE(sp->x, sp->y, u->tgt_sp->x, u->tgt_sp->y, dist, a, b, c); if (dist < 1000 && - SpriteOverlapZ(SpriteNum, u->tgt_sp - sprite, Z(32))) + SpriteOverlapZ(SpriteNum, short(u->tgt_sp - sprite), Z(32))) { UpdateSinglePlayKills(SpriteNum); DoSkullBeginDeath(SpriteNum); @@ -806,7 +806,7 @@ int DoBettyJump(short SpriteNum) DISTANCE(sp->x, sp->y, u->tgt_sp->x, u->tgt_sp->y, dist, a, b, c); if (dist < 1000 && - SpriteOverlapZ(SpriteNum, u->tgt_sp - sprite, Z(32))) + SpriteOverlapZ(SpriteNum, short(u->tgt_sp - sprite), Z(32))) { UpdateSinglePlayKills(SpriteNum); DoBettyBeginDeath(SpriteNum); diff --git a/source/games/sw/src/sounds.cpp b/source/games/sw/src/sounds.cpp index 16ce58cf3..580b5faf9 100644 --- a/source/games/sw/src/sounds.cpp +++ b/source/games/sw/src/sounds.cpp @@ -102,7 +102,7 @@ AMB_INFO ambarray[] = float S_ConvertPitch(int lpitch) { - return pow(2, lpitch / 1200.); + return powf(2, lpitch / 1200.f); } //========================================================================== @@ -157,7 +157,7 @@ short SoundDist(int x, int y, int z, int basedist) if (retval < 0) retval = 0; if (retval > 255) retval = 255; - return retval; + return short(retval); } //========================================================================== @@ -598,7 +598,7 @@ void GameInterface::UpdateSounds(void) PLAYERp pp = Player + screenpeek; SoundListener listener; - listener.angle = -pp->angle.ang.asbuild() * BAngRadian; // Build uses a period of 2048. + listener.angle = float(-pp->angle.ang.asbuild() * BAngRadian); // Build uses a period of 2048. listener.velocity.Zero(); listener.position = GetSoundPos(&pp->pos); listener.underwater = false; @@ -935,16 +935,16 @@ int PlayerYellVocs[] = // //========================================================================== -bool PlaySong(const char* mapname, const char* song_file_name, int cdaudio_track, bool isThemeTrack) //(nullptr, nullptr, -1, false) starts the normal level music. +bool PlaySong(const char* song_file_name, int cdaudio_track, bool isThemeTrack) //(nullptr, nullptr, -1, false) starts the normal level music. { // Play CD audio if enabled. if (cdaudio_track >= 0 && (mus_redbook || !song_file_name || *song_file_name == 0)) { FStringf trackname("shadow%02d.ogg", cdaudio_track); - if (!Mus_Play(mapname, trackname, true)) + if (!Mus_Play(trackname, true)) { trackname.Format("track%02d.ogg", cdaudio_track); - if (!Mus_Play(mapname, trackname, true)) + if (!Mus_Play(trackname, true)) { Printf("Can't find CD track %i!\n", cdaudio_track); } @@ -955,14 +955,14 @@ bool PlaySong(const char* mapname, const char* song_file_name, int cdaudio_track { return true; } - if (!Mus_Play(mapname, song_file_name, true)) + if (!Mus_Play(song_file_name, true)) { // try the CD track anyway if no MIDI could be found (the original game doesn't have any MIDI, it was CD Audio only, this avoids no music playing if mus_redbook is off.) FStringf trackname("shadow%02d.ogg", cdaudio_track); - if (!Mus_Play(mapname, trackname, true)) + if (!Mus_Play(trackname, true)) { trackname.Format("track%02d.ogg", cdaudio_track); - if (!Mus_Play(nullptr, trackname, true)) return false; + if (!Mus_Play(trackname, true)) return false; } } return true; @@ -1011,7 +1011,7 @@ DEFINE_ACTION_FUNCTION(_SW, PlaySong) { PARAM_PROLOGUE; PARAM_INT(song); - PlaySong(nullptr, ThemeSongs[song], ThemeTrack[song], true); + PlaySong(ThemeSongs[song], ThemeTrack[song], true); return 0; } diff --git a/source/games/sw/src/sounds.h b/source/games/sw/src/sounds.h index 5adda2407..5a2c13042 100644 --- a/source/games/sw/src/sounds.h +++ b/source/games/sw/src/sounds.h @@ -86,7 +86,7 @@ void StopFX(void); void StopSound(void); void StartAmbientSound(void); void StopAmbientSound(void); -bool PlaySong(const char *mapname, const char *song_file_name, int cdaudio_track, bool isThemeTrack = false); //(nullptr, nullptr, -1, false) starts the normal level music. +bool PlaySong(const char *song_file_name, int cdaudio_track, bool isThemeTrack = false); //(nullptr, nullptr, -1, false) starts the normal level music. void PlaySoundRTS(int rts_num); // diff --git a/source/games/sw/src/spike.cpp b/source/games/sw/src/spike.cpp index 68cdc8bd0..e49a46f86 100644 --- a/source/games/sw/src/spike.cpp +++ b/source/games/sw/src/spike.cpp @@ -364,7 +364,7 @@ int DoSpike(short SpriteNum) // change target u->jump_speed = u->vel_tgt; - u->vel_rate = labs(u->vel_rate); + u->vel_rate = (short)abs(u->vel_rate); u->z_tgt = sp->z; SetSpikeInactive(SpriteNum); @@ -474,7 +474,7 @@ int DoSpikeAuto(short SpriteNum) { // change target u->jump_speed = u->vel_tgt; - u->vel_rate = labs(u->vel_rate); + u->vel_rate = (short)abs(u->vel_rate); u->z_tgt = sp->z; u->Tics = u->WaitTics; diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 6646bae45..bc6a1ec1b 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -1113,7 +1113,7 @@ bool ActorSpawn(SPRITEp sp) { bool ret = true; - short SpriteNum = sp - sprite; + short SpriteNum = short(sp - sprite); switch (sp->picnum) { @@ -5255,7 +5255,7 @@ DoCoin(short SpriteNum) { if (u->StateStart != s_GreenCoin) { - offset = u->State - u->StateStart; + offset = int(u->State - u->StateStart); ChangeState(SpriteNum, s_GreenCoin); u->State = u->StateStart + offset; } @@ -5264,7 +5264,7 @@ DoCoin(short SpriteNum) { if (u->StateStart != s_YellowCoin) { - offset = u->State - u->StateStart; + offset = int(u->State - u->StateStart); ChangeState(SpriteNum, s_YellowCoin); u->State = u->StateStart + offset; } @@ -5568,7 +5568,7 @@ DoGet(short SpriteNum) continue; } - if (!SpriteOverlap(SpriteNum, pp->SpriteP - sprite)) + if (!SpriteOverlap(SpriteNum, short(pp->SpriteP - sprite))) { continue; } @@ -6031,7 +6031,7 @@ KeyMain: { //sprintf(ds,"Nuclear Warhead"); PutStringInfo(Player+pnum, quoteMgr.GetQuote(QUOTE_WPNNUKE)); - pp->WpnRocketNuke = DamageData[DMG_NUCLEAR_EXP].weapon_pickup; + pp->WpnRocketNuke =uint8_t(DamageData[DMG_NUCLEAR_EXP].weapon_pickup); SetFadeAmt(pp,ITEMFLASHAMT,ITEMFLASHCLR); // Flash blue on item pickup if (pp == Player+myconnectindex) PlaySound(DIGI_ITEM, sp, v3df_dontpan); @@ -6333,7 +6333,7 @@ KeyMain: { //sprintf(ds,"Heat Seeker Card"); PutStringInfo(Player+pnum, quoteMgr.GetQuote(QUOTE_AMMONUKE)); - pp->WpnRocketHeat = DamageData[DMG_NUCLEAR_EXP].ammo_pickup; + pp->WpnRocketHeat = uint8_t(DamageData[DMG_NUCLEAR_EXP].ammo_pickup); SetFadeAmt(pp,ITEMFLASHAMT,ITEMFLASHCLR); // Flash blue on item pickup if (pp == Player+myconnectindex) PlaySound(DIGI_ITEM, sp, v3df_dontpan); @@ -6935,7 +6935,7 @@ SpriteControl(void) */ int -move_sprite(short spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics) +move_sprite(int spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics) { int daz; int retval=0, zh; @@ -7183,7 +7183,7 @@ MissileZrange(short SpriteNum) int -move_missile(short spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics) +move_missile(int spritenum, int xchange, int ychange, int zchange, int ceildist, int flordist, uint32_t cliptype, int numtics) { int daz; int retval, zh; diff --git a/source/games/sw/src/sumo.cpp b/source/games/sw/src/sumo.cpp index 628770099..f6c8d9c27 100644 --- a/source/games/sw/src/sumo.cpp +++ b/source/games/sw/src/sumo.cpp @@ -797,7 +797,7 @@ int DoSumoDeathMelt(short SpriteNum) if (!SW_SHAREWARE) { // Resume the regular music - in a hack-free fashion. - PlaySong(currentLevel->labelName, currentLevel->music, currentLevel->cdSongId); + PlaySong(currentLevel->music, currentLevel->cdSongId); } BossSpriteNum[1] = -2; // Sprite is gone, set it back to keep it valid! @@ -868,7 +868,7 @@ BossHealthMeter(void) bosswasseen[0] = true; if (!SW_SHAREWARE) { - PlaySong(nullptr, ThemeSongs[2], ThemeTrack[2], true); + PlaySong(ThemeSongs[2], ThemeTrack[2], true); } } else if (i == 1 && !bosswasseen[1]) @@ -876,7 +876,7 @@ BossHealthMeter(void) bosswasseen[1] = true; if (!SW_SHAREWARE) { - PlaySong(nullptr, ThemeSongs[3], ThemeTrack[3], true); + PlaySong(ThemeSongs[3], ThemeTrack[3], true); } } else if (i == 2 && !bosswasseen[2]) @@ -884,7 +884,7 @@ BossHealthMeter(void) bosswasseen[2] = true; if (!SW_SHAREWARE) { - PlaySong(nullptr, ThemeSongs[4], ThemeTrack[4], true); + PlaySong(ThemeSongs[4], ThemeTrack[4], true); } } } diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index 509b7e765..d454e4596 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -266,7 +266,7 @@ ActorFindTrack(short SpriteNum, int8_t player_dir, int track_type, short *track_ { //DSPRINTF(ds,"Found track point in sector %d\n",track_sect); MONO_PRINT(ds); - return near_track - &Track[0]; + return short(near_track - &Track[0]); } return -1; @@ -705,9 +705,9 @@ TrackSetup(void) } SPRITEp -FindBoundSprite(short tag) +FindBoundSprite(int tag) { - short sn; + int sn; StatIterator it(STAT_ST1); while ((sn = it.NextIndex()) >= 0) @@ -748,7 +748,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) // search for 2 sprite bounding tags - BoundSprite = FindBoundSprite(500 + ((sop - SectorObject) * 5)); + BoundSprite = FindBoundSprite(500 + (int(sop - SectorObject) * 5)); //DSPRINTF(ds,"tagnum %d, so num %d",500 + ((sop - SectorObject) * 5), sop - SectorObject); MONO_PRINT(ds); @@ -757,14 +757,14 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) xlow = BoundSprite->x; ylow = BoundSprite->y; - KillSprite(BoundSprite - sprite); + KillSprite(short(BoundSprite - sprite)); - BoundSprite = FindBoundSprite(501 + ((sop - SectorObject) * 5)); + BoundSprite = FindBoundSprite(501 + (int(sop - SectorObject) * 5)); ASSERT(BoundSprite != NULL); xhigh = BoundSprite->x; yhigh = BoundSprite->y; - KillSprite(BoundSprite - sprite); + KillSprite(short(BoundSprite - sprite)); // set radius for explosion checking - based on bounding box u->Radius = DIV4((xhigh - xlow) + (yhigh - ylow)); @@ -778,7 +778,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop) sop->xmid = BoundSprite->x; sop->ymid = BoundSprite->y; sop->zmid = BoundSprite->z; - KillSprite(BoundSprite - sprite); + KillSprite(short(BoundSprite - sprite)); } #if 0 @@ -2802,7 +2802,7 @@ void VehicleSetSmoke(SECTOR_OBJECTp sop, ANIMATORp animator) for (sectp = sop->sectp; *sectp; sectp++) { - SectIterator it(*sectp - sector); + SectIterator it(int(*sectp - sector)); while ((SpriteNum = it.NextIndex()) >= 0) { sp = &sprite[SpriteNum]; @@ -2925,7 +2925,7 @@ DoTornadoObject(SECTOR_OBJECTp sop) void DoAutoTurretObject(SECTOR_OBJECTp sop) { - short SpriteNum = sop->sp_child - sprite; + short SpriteNum = short(sop->sp_child - sprite); SPRITEp shootp; USERp u = User[SpriteNum].Data(); short delta_ang; @@ -3045,7 +3045,7 @@ DoActorHitTrackEndPoint(USERp u) else { RESET(u->Flags, SPR_RUN_AWAY); - DoActorSetSpeed(sp - sprite, NORM_SPEED); + DoActorSetSpeed(short(sp - sprite), NORM_SPEED); u->track = -1; } } @@ -3066,7 +3066,7 @@ DoActorHitTrackEndPoint(USERp u) else { RESET(u->Flags, SPR_FIND_PLAYER); - DoActorSetSpeed(sp - sprite, NORM_SPEED); + DoActorSetSpeed(short(sp - sprite), NORM_SPEED); u->track = -1; } } diff --git a/source/games/sw/src/vator.cpp b/source/games/sw/src/vator.cpp index 6b97b4433..6f239279d 100644 --- a/source/games/sw/src/vator.cpp +++ b/source/games/sw/src/vator.cpp @@ -504,7 +504,7 @@ int DoVator(short SpriteNum) // change target u->jump_speed = u->vel_tgt; - u->vel_rate = labs(u->vel_rate); + u->vel_rate = short(abs(u->vel_rate)); u->z_tgt = sp->z; RESET_BOOL8(sp); @@ -663,7 +663,7 @@ int DoVatorAuto(short SpriteNum) { // change target u->jump_speed = u->vel_tgt; - u->vel_rate = labs(u->vel_rate); + u->vel_rate = short(abs(u->vel_rate)); u->z_tgt = sp->z; u->Tics = u->WaitTics; diff --git a/source/games/sw/src/wallmove.cpp b/source/games/sw/src/wallmove.cpp index 220b92c0b..0b0cd8bb6 100644 --- a/source/games/sw/src/wallmove.cpp +++ b/source/games/sw/src/wallmove.cpp @@ -127,14 +127,14 @@ int DoWallMove(SPRITEp sp) } if (shade1) - wallp->shade = shade1; + wallp->shade = int8_t(shade1); if (picnum1) wallp->picnum = picnum1; // find the previous wall - prev_wall = PrevWall(wallp - wall); + prev_wall = PrevWall(short(wallp - wall)); if (shade2) - wall[prev_wall].shade = shade2; + wall[prev_wall].shade = int8_t(shade2); if (picnum2) wall[prev_wall].picnum = picnum2; } @@ -143,7 +143,7 @@ int DoWallMove(SPRITEp sp) SP_TAG9(sp)--; if ((signed char)SP_TAG9(sp) <= 0) { - KillSprite(sp - sprite); + KillSprite(short(sp - sprite)); } else { diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index c0eaf4278..b901c971b 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -3236,7 +3236,7 @@ SpawnShrap(short ParentNum, short Secondary) else if (TEST(parent->extra, SPRX_BREAKABLE)) { // if no user - if (!User[parent - sprite].Data()) + if (!User[short(parent - sprite)].Data()) { // Jump to shrap type shrap_type = SP_TAG8(parent); @@ -3245,7 +3245,7 @@ SpawnShrap(short ParentNum, short Secondary) else { // has a user - is programmed - change_sprite_stat(parent - sprite, STAT_MISC); + change_sprite_stat(short(parent - sprite), STAT_MISC); RESET(parent->extra, SPRX_BREAKABLE); RESET(parent->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); } @@ -3536,42 +3536,42 @@ AutoShrap: p = WoodShrap; shrap_xsize = shrap_ysize = 24; shrap_bounce = true; - ChangeState(parent - sprite, s_BreakBarrel); + ChangeState(short(parent - sprite), s_BreakBarrel); break; case BREAK_LIGHT: PlaySound(DIGI_BREAKGLASS,parent,v3df_dontpan|v3df_doppler); p = GlassShrap; shrap_xsize = shrap_ysize = 24; shrap_bounce = true; - ChangeState(parent - sprite, s_BreakLight); + ChangeState(short(parent - sprite), s_BreakLight); break; case BREAK_PEDISTAL: PlaySound(DIGI_BREAKSTONES,parent,v3df_dontpan|v3df_doppler); p = StoneShrap; shrap_xsize = shrap_ysize = 24; shrap_bounce = true; - ChangeState(parent - sprite, s_BreakPedistal); + ChangeState(short(parent - sprite), s_BreakPedistal); break; case BREAK_BOTTLE1: PlaySound(DIGI_BREAKGLASS,parent,v3df_dontpan|v3df_doppler); p = GlassShrap; shrap_xsize = shrap_ysize = 8; shrap_bounce = true; - ChangeState(parent - sprite, s_BreakBottle1); + ChangeState(short(parent - sprite), s_BreakBottle1); break; case BREAK_BOTTLE2: PlaySound(DIGI_BREAKGLASS,parent,v3df_dontpan|v3df_doppler); p = GlassShrap; shrap_xsize = shrap_ysize = 8; shrap_bounce = true; - ChangeState(parent - sprite, s_BreakBottle2); + ChangeState(short(parent - sprite), s_BreakBottle2); break; case BREAK_MUSHROOM: PlaySound(DIGI_BREAKDEBRIS,parent,v3df_dontpan|v3df_doppler); p = StoneShrap; shrap_xsize = shrap_ysize = 4; shrap_bounce = true; - SetSuicide(parent - sprite); // kill next iteration + SetSuicide(short(parent - sprite)); // kill next iteration break; case BOLT_EXP: return false; @@ -3838,10 +3838,10 @@ AutoShrap: break; } - sp->shade = shrap_shade; - sp->xrepeat = shrap_xsize; - sp->yrepeat = shrap_ysize; - sp->clipdist = 16L >> 2; + sp->shade = int8_t(shrap_shade); + sp->xrepeat = uint8_t(shrap_xsize); + sp->yrepeat = uint8_t(shrap_ysize); + sp->clipdist = 16 >> 2; if (shrap_owner >= 0) { @@ -3853,7 +3853,7 @@ AutoShrap: sp->z += Z(RANDOM_RANGE(shrap_rand_zamt) - (shrap_rand_zamt/2)); } - sp->pal = u->spal = shrap_pal; + sp->pal = u->spal = uint8_t(shrap_pal); sp->xvel = p->min_vel*2; sp->xvel += RANDOM_RANGE(p->max_vel - p->min_vel); @@ -4327,12 +4327,12 @@ SpawnBlood(short SpriteNum, short Weapon, short hit_ang, int hit_x, int hit_y, i SET(nu->Flags, SPR_BOUNCE); - np->shade = shrap_shade; - np->xrepeat = shrap_xsize; - np->yrepeat = shrap_ysize; - np->clipdist = 16L >> 2; + np->shade = int8_t(shrap_shade); + np->xrepeat = uint8_t(shrap_xsize); + np->yrepeat = uint8_t(shrap_ysize); + np->clipdist = 16 >> 2; - np->pal = nu->spal = shrap_pal; + np->pal = nu->spal = uint8_t(shrap_pal); np->xvel = p->min_vel; np->xvel += RANDOM_RANGE(p->max_vel - p->min_vel); @@ -4372,7 +4372,7 @@ VehicleMoveHit(short SpriteNum) SECTOR_OBJECTp sop; SECTOR_OBJECTp hsop; bool TestKillSectorObject(SECTOR_OBJECTp); - short controller; + int controller; if (!u->ret) return false; @@ -4381,7 +4381,7 @@ VehicleMoveHit(short SpriteNum) // sprite controlling sop cp = sop->controller; - controller = cp - sprite; + controller = int(cp - sprite); switch (TEST(u->ret, HIT_MASK)) { @@ -4507,7 +4507,7 @@ WeaponMoveHit(short SpriteNum) if (u->lo_sp->lotag == TAG_SPRITE_HIT_MATCH) { - if (MissileHitMatch(SpriteNum, -1, u->lo_sp - sprite)) + if (MissileHitMatch(SpriteNum, -1, short(u->lo_sp - sprite))) return true; //DoMatchEverything(NULL, u->lo_sp->hitag, -1); //return(true); @@ -4532,7 +4532,7 @@ WeaponMoveHit(short SpriteNum) { if (u->hi_sp->lotag == TAG_SPRITE_HIT_MATCH) { - if (MissileHitMatch(SpriteNum, -1, u->hi_sp - sprite)) + if (MissileHitMatch(SpriteNum, -1, short(u->hi_sp - sprite))) return true; //DoMatchEverything(NULL, u->hi_sp->hitag, -1); //return(true); @@ -4546,7 +4546,7 @@ WeaponMoveHit(short SpriteNum) if ((sop = DetectSectorObject(sectp))) { //if (sop->max_damage != -9999) - DoDamage(sop->sp_child - sprite, SpriteNum); + DoDamage(short(sop->sp_child - sprite), SpriteNum); return true; } } @@ -4665,7 +4665,7 @@ WeaponMoveHit(short SpriteNum) if ((sop = DetectSectorObjectByWall(wph))) { if (sop->max_damage != -999) - DoDamage(sop->sp_child - sprite, SpriteNum); + DoDamage(short(sop->sp_child - sprite), SpriteNum); return true; } } @@ -5546,7 +5546,7 @@ ActorStdMissile(short SpriteNum, short Weapon) return 0; } int -ActorDamageSlide(short SpriteNum, short damage, short ang) +ActorDamageSlide(int SpriteNum, int damage, int ang) { USERp u = User[SpriteNum].Data(); int slide_vel,slide_dec; @@ -5554,7 +5554,7 @@ ActorDamageSlide(short SpriteNum, short damage, short ang) if (TEST(u->Flags, SPR_CLIMBING)) return false; - damage = labs(damage); + damage = abs(damage); if (!damage) return false; @@ -5586,11 +5586,11 @@ ActorDamageSlide(short SpriteNum, short damage, short ang) } int -PlayerDamageSlide(PLAYERp pp, short damage, short ang) +PlayerDamageSlide(PLAYERp pp, int damage, short ang) { int slide_vel; - damage = labs(damage); + damage = abs(damage); if (!damage) return false; @@ -8607,7 +8607,7 @@ InitPlasmaFountain(SPRITEp wp, SPRITEp sp) np->shade = -40; if (wp) SetOwner(wp->owner, SpriteNum); - SetAttach(sp - sprite, SpriteNum); + SetAttach(short(sp - sprite), SpriteNum); np->yrepeat = 0; np->clipdist = 8>>2; @@ -8646,9 +8646,9 @@ DoPlasmaFountain(int16_t Weapon) if (!u->Counter) { - SpawnBlood(ap-sprite, Weapon, 0, 0, 0, 0); + SpawnBlood(short(ap-sprite), Weapon, 0, 0, 0, 0); if (RANDOM_RANGE(1000) > 600) - InitBloodSpray(ap-sprite, false, 105); + InitBloodSpray(short(ap-sprite), false, 105); } } @@ -11970,8 +11970,8 @@ DoFireball(int16_t Weapon) if (TEST(hsp->extra, SPRX_BURNABLE)) { if (!hu) - hu = SpawnUser(hsp - sprite, hsp->picnum, NULL); - SpawnFireballFlames(Weapon, hsp - sprite); + hu = SpawnUser(short(sp - sprite), hsp->picnum, NULL); + SpawnFireballFlames(Weapon, short(hsp - sprite)); hit_burn = true; } @@ -12673,9 +12673,9 @@ MissileSetPos(short Weapon, ANIMATORp DoWeapon, int dist) oldzvel = wp->zvel; // make missile move in smaller increments - wp->xvel = (dist * 6L) / MISSILEMOVETICS; + wp->xvel = short((dist * 6) / MISSILEMOVETICS); //wp->zvel = (wp->zvel*4) / MISSILEMOVETICS; - wp->zvel = (wp->zvel*6L) / MISSILEMOVETICS; + wp->zvel = short((wp->zvel*6) / MISSILEMOVETICS); // some Weapon Animators use this wu->xchange = MOVEx(wp->xvel, wp->ang); @@ -12717,9 +12717,9 @@ TestMissileSetPos(short Weapon, ANIMATORp DoWeapon, int dist, int zvel) oldzvel = wp->zvel; // make missile move in smaller increments - wp->xvel = (dist * 6L) / MISSILEMOVETICS; + wp->xvel = short((dist * 6) / MISSILEMOVETICS); //wp->zvel = (wp->zvel*4) / MISSILEMOVETICS; - zvel = (zvel*6L) / MISSILEMOVETICS; + zvel = short((zvel*6) / MISSILEMOVETICS); // some Weapon Animators use this wu->xchange = MOVEx(wp->xvel, wp->ang); @@ -12875,7 +12875,7 @@ InitSpellRing(PLAYERp pp) sp->hitag = LUMINOUS; //Always full brightness sp->xvel = 500; //sp->owner = pp->SpriteP - sprite; - SetOwner(pp->SpriteP - sprite, SpriteNum); + SetOwner(short(pp->SpriteP - sprite), SpriteNum); sp->shade = -40; sp->xrepeat = 32; sp->yrepeat = 32; @@ -13382,7 +13382,6 @@ InitSpellNapalm(PLAYERp pp) SPRITEp sp; USERp u; unsigned i; - short oclipdist; short ammo; typedef struct @@ -13427,7 +13426,7 @@ InitSpellNapalm(PLAYERp pp) } //sp->owner = pp->SpriteP - sprite; - SetOwner(pp->SpriteP - sprite, SpriteNum); + SetOwner(short(pp->SpriteP - sprite), SpriteNum); sp->shade = -40; sp->xrepeat = 32; sp->yrepeat = 32; @@ -13441,7 +13440,7 @@ InitSpellNapalm(PLAYERp pp) u->ceiling_dist = Z(1); u->Dist = 200; - oclipdist = pp->SpriteP->clipdist; + auto oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 1; if (mp[i].dist_over != 0) @@ -13480,7 +13479,6 @@ InitEnemyNapalm(short SpriteNum) USERp u = User[SpriteNum].Data(), wu; short dist; unsigned i; - short oclipdist; typedef struct { @@ -13529,7 +13527,7 @@ InitEnemyNapalm(short SpriteNum) wu->ceiling_dist = Z(1); wu->Dist = 200; - oclipdist = sp->clipdist; + auto oclipdist = sp->clipdist; sp->clipdist = 1; if (mp[i].dist_over != 0) @@ -13565,7 +13563,6 @@ InitSpellMirv(PLAYERp pp) short SpriteNum; SPRITEp sp; USERp u; - short oclipdist; PlaySound(DIGI_MIRVFIRE, pp, v3df_none); @@ -13582,11 +13579,11 @@ InitSpellMirv(PLAYERp pp) Set3DSoundOwner(SpriteNum); //sp->owner = pp->SpriteP - sprite; - SetOwner(pp->SpriteP - sprite, SpriteNum); + SetOwner(short(pp->SpriteP - sprite), SpriteNum); sp->shade = -40; sp->xrepeat = 72; sp->yrepeat = 72; - sp->clipdist = 32L >> 2; + sp->clipdist = 32 >> 2; sp->zvel = -pp->horizon.horiz.asq16() >> 9; SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_YCENTER); RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); @@ -13595,7 +13592,7 @@ InitSpellMirv(PLAYERp pp) u->ceiling_dist = Z(16); u->Dist = 200; - oclipdist = pp->SpriteP->clipdist; + auto oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 0; u->xchange = MOVEx(sp->xvel, sp->ang); @@ -13683,7 +13680,7 @@ InitSwordAttack(PLAYERp pp) for (i = 0; i < (int)SIZ(dangs); i++) { if (RANDOM_RANGE(1000) < 500) continue; // Don't spawn bubbles every time - bubble = SpawnBubble(pp->SpriteP - sprite); + bubble = SpawnBubble(short(pp->SpriteP - sprite)); if (bubble >= 0) { bp = &sprite[bubble]; @@ -13861,7 +13858,7 @@ InitFistAttack(PLAYERp pp) for (i = 0; i < (int)SIZ(dangs); i++) { - bubble = SpawnBubble(pp->SpriteP - sprite); + bubble = SpawnBubble(short(pp->SpriteP - sprite)); if (bubble >= 0) { bp = &sprite[bubble]; @@ -14052,7 +14049,6 @@ InitSumoNapalm(short SpriteNum) USERp u = User[SpriteNum].Data(), wu; short dist; short i,j,ang; - short oclipdist; typedef struct { @@ -14098,7 +14094,7 @@ InitSumoNapalm(short SpriteNum) wu->ceiling_dist = Z(1); wu->Dist = 200; - oclipdist = sp->clipdist; + auto oclipdist = sp->clipdist; sp->clipdist = 1; if (mp[i].dist_over != 0) @@ -14245,12 +14241,12 @@ InitMiniSumoClap(short SpriteNum) if (dist < CLOSE_RANGE_DIST_FUDGE(u->tgt_sp, sp, 1000)) { - if (SpriteOverlapZ(SpriteNum, u->tgt_sp - sprite, Z(20))) + if (SpriteOverlapZ(SpriteNum, short(u->tgt_sp - sprite), Z(20))) { if (FAFcansee(u->tgt_sp->x,u->tgt_sp->y,SPRITEp_MID(u->tgt_sp),u->tgt_sp->sectnum,sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum)) { PlaySound(DIGI_CGTHIGHBONE, sp, v3df_follow|v3df_dontpan); - DoDamage(u->tgt_sp - sprite, SpriteNum); + DoDamage(short(u->tgt_sp - sprite), SpriteNum); } } } @@ -14259,7 +14255,7 @@ InitMiniSumoClap(short SpriteNum) if (FAFcansee(u->tgt_sp->x,u->tgt_sp->y,SPRITEp_MID(u->tgt_sp),u->tgt_sp->sectnum,sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum)) { PlaySound(DIGI_30MMEXPLODE, sp, v3df_none); - SpawnFireballFlames(SpriteNum, u->tgt_sp - sprite); + SpawnFireballFlames(SpriteNum, short(u->tgt_sp - sprite)); } } @@ -14422,7 +14418,7 @@ AimHitscanToTarget(SPRITEp sp, int *z, short *ang, int z_ratio) if (!u->tgt_sp) return -1; - hit_sprite = u->tgt_sp - sprite; + hit_sprite = short(u->tgt_sp - sprite); hp = &sprite[hit_sprite]; hu = User[hit_sprite].Data(); @@ -14685,7 +14681,6 @@ InitHeartAttack(PLAYERp pp) SPRITEp sp; USERp u; short i = 0; - short oclipdist; typedef struct { @@ -14712,7 +14707,7 @@ InitHeartAttack(PLAYERp pp) sp->hitag = LUMINOUS; //Always full brightness //sp->owner = pp->SpriteP - sprite; - SetOwner(pp->SpriteP - sprite, SpriteNum); + SetOwner(short(pp->SpriteP - sprite), SpriteNum); sp->shade = -10; sp->xrepeat = 52; sp->yrepeat = 52; @@ -14726,7 +14721,7 @@ InitHeartAttack(PLAYERp pp) u->ceiling_dist = Z(1); u->Dist = 200; - oclipdist = pp->SpriteP->clipdist; + auto oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 1; u->xchange = MOVEx(sp->xvel, sp->ang); @@ -14760,7 +14755,6 @@ InitHeartAttack(PLAYERp pp) SPRITEp sp; USERp u; short i = 0; - short oclipdist; USERp pu = User[pp->PlayerSprite].Data(); typedef struct @@ -14802,7 +14796,7 @@ InitHeartAttack(PLAYERp pp) u->ceiling_dist = Z(1); u->Dist = 200; - oclipdist = pp->SpriteP->clipdist; + auto oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 1; u->xchange = MOVEx(sp->xvel, sp->ang); @@ -15084,7 +15078,6 @@ InitLaser(PLAYERp pp) SPRITEp wp; int nx, ny, nz; short w; - short oclipdist; DoPlayerBeginRecoil(pp, RAIL_RECOIL_AMT); @@ -15128,7 +15121,7 @@ InitLaser(PLAYERp pp) // at certain angles the clipping box was big enough to block the // initial positioning of the fireball. - oclipdist = pp->SpriteP->clipdist; + auto oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 0; wp->ang = NORM_ANGLE(wp->ang + 512); @@ -15189,7 +15182,6 @@ InitRail(PLAYERp pp) SPRITEp wp; int nx, ny, nz; short w; - short oclipdist; int zvel; if (SW_SHAREWARE) return false; // JBF: verify @@ -15238,7 +15230,7 @@ InitRail(PLAYERp pp) // at certain angles the clipping box was big enough to block the // initial positioning - oclipdist = pp->SpriteP->clipdist; + auto oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 0; wp->clipdist = 32L>>2; @@ -15282,7 +15274,6 @@ InitZillaRail(short SpriteNum) SPRITEp wp; int nx, ny, nz; short w; - short oclipdist; int zvel; if (SW_SHAREWARE) return false; // JBF: verify @@ -15324,7 +15315,7 @@ InitZillaRail(short SpriteNum) // at certain angles the clipping box was big enough to block the // initial positioning - oclipdist = sp->clipdist; + auto oclipdist = sp->clipdist; sp->clipdist = 0; wp->clipdist = 32L>>2; @@ -15367,7 +15358,6 @@ InitRocket(PLAYERp pp) SPRITEp wp; int nx, ny, nz; short w; - short oclipdist; int zvel; #if 0 @@ -15455,7 +15445,7 @@ InitRocket(PLAYERp pp) // at certain angles the clipping box was big enough to block the // initial positioning of the fireball. - oclipdist = pp->SpriteP->clipdist; + auto oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 0; wp->ang = NORM_ANGLE(wp->ang + 512); @@ -15501,7 +15491,6 @@ InitBunnyRocket(PLAYERp pp) SPRITEp wp; int nx, ny, nz; short w; - short oclipdist; int zvel; #if 0 @@ -15583,7 +15572,7 @@ InitBunnyRocket(PLAYERp pp) // at certain angles the clipping box was big enough to block the // initial positioning of the fireball. - oclipdist = pp->SpriteP->clipdist; + auto oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 0; wp->ang = NORM_ANGLE(wp->ang + 512); @@ -15630,7 +15619,6 @@ InitNuke(PLAYERp pp) SPRITEp wp; int nx, ny, nz; short w; - short oclipdist; int zvel; @@ -15688,7 +15676,7 @@ InitNuke(PLAYERp pp) // at certain angles the clipping box was big enough to block the // initial positioning of the fireball. - oclipdist = pp->SpriteP->clipdist; + auto oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 0; wp->ang = NORM_ANGLE(wp->ang + 512); @@ -15823,7 +15811,6 @@ InitMicro(PLAYERp pp) SPRITEp wp,hp; int nx, ny, nz, dist; short w; - short oclipdist; short i,ang; TARGET_SORTp ts = TargetSort; @@ -15898,7 +15885,7 @@ InitMicro(PLAYERp pp) // at certain angles the clipping box was big enough to block the // initial positioning of the fireball. - oclipdist = pp->SpriteP->clipdist; + auto oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 0; wp->ang = NORM_ANGLE(wp->ang + 512); @@ -16308,7 +16295,6 @@ InitSerpSpell(short SpriteNum) USERp u = User[SpriteNum].Data(), nu; int dist; short New, i; - short oclipdist; static short lat_ang[] = { @@ -16351,7 +16337,7 @@ InitSerpSpell(short SpriteNum) nu->floor_dist = Z(16); nu->Dist = 200; - oclipdist = sp->clipdist; + auto oclipdist = sp->clipdist; sp->clipdist = 1; np->ang = NORM_ANGLE(np->ang + lat_ang[i]); @@ -16425,7 +16411,6 @@ InitSerpMonstSpell(short SpriteNum) USERp u = User[SpriteNum].Data(), nu; int dist; short New, i; - short oclipdist; static short lat_ang[] = { @@ -16470,7 +16455,7 @@ InitSerpMonstSpell(short SpriteNum) nu->Dist = 200; - oclipdist = sp->clipdist; + auto oclipdist = sp->clipdist; sp->clipdist = 1; np->ang = NORM_ANGLE(np->ang + lat_ang[i]); @@ -16587,7 +16572,6 @@ InitEnemyRail(short SpriteNum) int nx, ny, nz, dist, nang; short w; short pnum=0; -// short oclipdist; if (SW_SHAREWARE) return false; // JBF: verify @@ -17646,7 +17630,7 @@ BulletHitSprite(SPRITEp sp, short hit_sprite, int hit_x, int hit_y, int hit_z, s break; } - SetOwner(sp - sprite, New); + SetOwner(short(sp - sprite), New); wp->ang = sp->ang; setspritez(New, &hit_pos); @@ -17688,7 +17672,12 @@ int SpawnWallHole(short hit_sect, short hit_wall, int hit_x, int hit_y, int hit_ sp = &sprite[SpriteNum]; sp->owner = -1; sp->xrepeat = sp->yrepeat = 16; - sp->cstat = sp->pal = sp->shade = sp->extra = sp->clipdist = sp->xoffset = sp->yoffset = 0; + sp->cstat = 0; + sp->pal = 0; + sp->shade = 0; + sp->extra = 0; + sp->clipdist = 0; + sp->xoffset = sp->yoffset = 0; sp->x = hit_x; sp->y = hit_y; sp->z = hit_z; @@ -18534,7 +18523,7 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp) nsect = sp->sectnum; if (RANDOM_P2(1024) < 200) - InitTracerTurret(sp - sprite, pp->PlayerSprite, pp->horizon.horiz.asq16()); + InitTracerTurret(short(sp - sprite), pp->PlayerSprite, pp->horizon.horiz.asq16()); daang = 64; if (WeaponAutoAimHitscan(sp, &daz, &daang, false) != -1) @@ -18662,19 +18651,19 @@ InitSobjGun(PLAYERp pp) { case 32: case 0: - SpawnVis(sp - sprite, -1, -1, -1, -1, 8); - SpawnBigGunFlames(sp - sprite, pp->PlayerSprite, pp->sop); - SetGunQuake(sp - sprite); - InitTankShell(sp - sprite, pp); + SpawnVis(short(sp - sprite), -1, -1, -1, -1, 8); + SpawnBigGunFlames(short(sp - sprite), pp->PlayerSprite, pp->sop); + SetGunQuake(short(sp - sprite)); + InitTankShell(short(sp - sprite), pp); if (!SP_TAG5(sp)) pp->FirePause = 80; else pp->FirePause = SP_TAG5(sp); break; case 1: - SpawnVis(sp - sprite, -1, -1, -1, -1, 32); - SpawnBigGunFlames(-(sp - sprite), pp->PlayerSprite, pp->sop); - InitSobjMachineGun(sp - sprite, pp); + SpawnVis(short(sp - sprite), -1, -1, -1, -1, 32); + SpawnBigGunFlames(-short(sp - sprite), pp->PlayerSprite, pp->sop); + InitSobjMachineGun(short(sp - sprite), pp); if (!SP_TAG5(sp)) pp->FirePause = 10; else @@ -18682,8 +18671,8 @@ InitSobjGun(PLAYERp pp) break; case 2: if (SW_SHAREWARE) break; - SpawnVis(sp - sprite, -1, -1, -1, -1, 32); - InitTurretLaser(sp - sprite, pp); + SpawnVis(short(sp - sprite), -1, -1, -1, -1, 32); + InitTurretLaser(short(sp - sprite), pp); if (!SP_TAG5(sp)) pp->FirePause = 120; else @@ -18691,8 +18680,8 @@ InitSobjGun(PLAYERp pp) break; case 3: if (SW_SHAREWARE) break; - SpawnVis(sp - sprite, -1, -1, -1, -1, 32); - InitTurretRail(sp - sprite, pp); + SpawnVis(short(sp - sprite), -1, -1, -1, -1, 32); + InitTurretRail(short(sp - sprite), pp); if (!SP_TAG5(sp)) pp->FirePause = 120; else @@ -18700,8 +18689,8 @@ InitSobjGun(PLAYERp pp) break; case 4: if (SW_SHAREWARE) break; - SpawnVis(sp - sprite, -1, -1, -1, -1, 32); - InitTurretFireball(sp - sprite, pp); + SpawnVis(short(sp - sprite), -1, -1, -1, -1, 32); + InitTurretFireball(short(sp - sprite), pp); if (!SP_TAG5(sp)) pp->FirePause = 20; else @@ -18709,8 +18698,8 @@ InitSobjGun(PLAYERp pp) break; case 5: if (SW_SHAREWARE) break; - SpawnVis(sp - sprite, -1, -1, -1, -1, 32); - InitTurretRocket(sp - sprite, pp); + SpawnVis(short(sp - sprite), -1, -1, -1, -1, 32); + InitTurretRocket(short(sp - sprite), pp); if (!SP_TAG5(sp)) pp->FirePause = 100; else @@ -18718,8 +18707,8 @@ InitSobjGun(PLAYERp pp) break; case 6: if (SW_SHAREWARE) break; - SpawnVis(sp - sprite, -1, -1, -1, -1, 32); - InitTurretMicro(sp - sprite, pp); + SpawnVis(short(sp - sprite), -1, -1, -1, -1, 32); + InitTurretMicro(short(sp - sprite), pp); if (!SP_TAG5(sp)) pp->FirePause = 100; else @@ -18932,7 +18921,7 @@ InitTurretMgun(SECTOR_OBJECTp sop) daang = 512; if ((hitinfo.sprite = WeaponAutoAimHitscan(sp, &daz, &daang, false)) != -1) { - delta = labs(getincangle(sp->ang, daang)); + delta = short(abs(getincangle(sp->ang, daang))); if (delta > 128) { // don't shoot if greater than 128 @@ -19231,7 +19220,6 @@ InitGrenade(PLAYERp pp) SPRITEp wp; int nx, ny, nz; short w; - short oclipdist; int zvel; bool auto_aim = false; @@ -19292,7 +19280,7 @@ InitGrenade(PLAYERp pp) ////DSPRINTF(ds,"horiz %d, ho %d, ho+ho %d", pp->horizon.horiz.asbuild()), pp->horizon.horizoff.asbuild()), pp->horizon.horizoff.asbuild() + pp->horizon.horiz.asbuild()); //MONO_PRINT(ds); - oclipdist = pp->SpriteP->clipdist; + auto oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 0; wp->ang = NORM_ANGLE(wp->ang + 512); @@ -19530,11 +19518,9 @@ HelpMissileLateral(int16_t Weapon, int dist) SPRITEp sp = &sprite[Weapon]; USERp u = User[Weapon].Data(); int xchange, ychange; - short old_xvel; - short old_clipdist; - old_xvel = sp->xvel; - old_clipdist = sp->clipdist; + auto old_xvel = sp->xvel; + auto old_clipdist = sp->clipdist; sp->xvel = dist; xchange = MOVEx(sp->xvel, sp->ang); @@ -19565,7 +19551,6 @@ InitFireball(PLAYERp pp) int nx = 0, ny = 0, nz; short w; USERp wu; - short oclipdist; int zvel; PlayerUpdateAmmo(pp, WPN_HOTHEAD, -1); @@ -19607,7 +19592,7 @@ InitFireball(PLAYERp pp) // at certain angles the clipping box was big enough to block the // initial positioning of the fireball. - oclipdist = pp->SpriteP->clipdist; + auto oclipdist = pp->SpriteP->clipdist; pp->SpriteP->clipdist = 0; wp->ang = NORM_ANGLE(wp->ang + 512); @@ -19945,11 +19930,11 @@ SpriteWarpToUnderwater(SPRITEp sp) if (GetOverlapSector(sp->x, sp->y, &over, &under) == 2) { - changespritesect(sp - sprite, under); + changespritesect(short(sp - sprite), under); } else { - changespritesect(sp - sprite, over); + changespritesect(short(sp - sprite), over); } //sp->z = sector[under_sp->sectnum].ceilingz + Z(6); @@ -20028,14 +20013,14 @@ SpriteWarpToSurface(SPRITEp sp) if (GetOverlapSector(sp->x, sp->y, &over, &under)) { - changespritesect(sp - sprite, over); + changespritesect(short(sp - sprite), over); } sp->z = sector[over_sp->sectnum].floorz - Z(2); // set z range and wade depth so we know how high to set view - DoActorZrange(sp - sprite); - MissileWaterAdjust(sp - sprite); + DoActorZrange(short(sp - sprite)); + MissileWaterAdjust(short(sp - sprite)); sp->backuppos(); @@ -20191,7 +20176,7 @@ MissileHitDiveArea(short SpriteNum) return false; SET(u->Flags, SPR_UNDERWATER); - SpawnSplash(sp - sprite); + SpawnSplash(short(sp - sprite)); SpriteWarpToUnderwater(sp); //SpawnUnderSplash(sp - sprite); u->ret = 0; @@ -20209,7 +20194,7 @@ MissileHitDiveArea(short SpriteNum) { return false; } - SpawnSplash(sp - sprite); + SpawnSplash(short(sp - sprite)); u->ret = 0; return true; } @@ -20572,7 +20557,12 @@ int QueueHole(short hit_sect, short hit_wall, int hit_x, int hit_y, int hit_z) sp = &sprite[SpriteNum]; sp->owner = -1; sp->xrepeat = sp->yrepeat = 16; - sp->cstat = sp->pal = sp->shade = sp->extra = sp->clipdist = sp->xoffset = sp->yoffset = 0; + sp->cstat = 0; + sp->pal = 0; + sp->shade = 0; + sp->extra = 0; + sp->clipdist = 0; + sp->xoffset = sp->yoffset = 0; sp->x = hit_x; sp->y = hit_y; sp->z = hit_z; @@ -20655,7 +20645,12 @@ int QueueFloorBlood(short hit_sprite) else sp->hitag = 0; sp->xrepeat = sp->yrepeat = 8; - sp->cstat = sp->pal = sp->shade = sp->extra = sp->clipdist = sp->xoffset = sp->yoffset = 0; + sp->cstat = 0; + sp->pal = 0; + sp->shade = 0; + sp->extra = 0; + sp->clipdist = 0; + sp->xoffset = sp->yoffset = 0; sp->x = hsp->x; sp->y = hsp->y; sp->z = hsp->z + Z(1); @@ -20756,7 +20751,12 @@ int QueueFootPrint(short hit_sprite) sp->owner = -1; sp->xrepeat = 48; sp->yrepeat = 54; - sp->cstat = sp->pal = sp->shade = sp->extra = sp->clipdist = sp->xoffset = sp->yoffset = 0; + sp->cstat = 0; + sp->pal = 0; + sp->shade = 0; + sp->extra = 0; + sp->clipdist = 0; + sp->xoffset = sp->yoffset = 0; sp->x = hsp->x; sp->y = hsp->y; sp->z = hsp->z; @@ -20891,7 +20891,12 @@ int QueueWallBlood(short hit_sprite, short ang) sp->owner = -1; sp->xrepeat = 30; sp->yrepeat = 40; // yrepeat will grow towards 64, it's default size - sp->cstat = sp->pal = sp->shade = sp->extra = sp->clipdist = sp->xoffset = sp->yoffset = 0; + sp->cstat = 0; + sp->pal = 0; + sp->shade = 0; + sp->extra = 0; + sp->clipdist = 0; + sp->xoffset = sp->yoffset = 0; sp->x = hitinfo.pos.x; sp->y = hitinfo.pos.y; sp->z = hitinfo.pos.z; @@ -21015,7 +21020,6 @@ int QueueGeneric(short SpriteNum, short pic) { SPRITEp sp = &sprite[SpriteNum]; SPRITEp osp; - short xrepeat,yrepeat; if (TEST(sector[sp->sectnum].extra, SECTFX_LIQUID_MASK) == SECTFX_LIQUID_WATER) { @@ -21035,8 +21039,8 @@ int QueueGeneric(short SpriteNum, short pic) return -1; } - xrepeat = sp->xrepeat; - yrepeat = sp->yrepeat; + auto xrepeat = sp->xrepeat; + auto yrepeat = sp->yrepeat; // can and should kill the user portion if (GenericQueue[GenericQueueHead] == -1) diff --git a/source/games/sw/src/weapon.h b/source/games/sw/src/weapon.h index 0d096ddb6..8b1ab5a7e 100644 --- a/source/games/sw/src/weapon.h +++ b/source/games/sw/src/weapon.h @@ -90,7 +90,6 @@ const char *DeathString(short SpriteNum); // // Damage Amounts defined in damage.h // -extern DAMAGE_DATA DamageData[]; // Damage Times - takes damage after this many tics #define DAMAGE_BLADE_TIME (10) @@ -157,7 +156,7 @@ extern short target_ang; bool SpriteOverlap(short, short); int SpawnShotgunSparks(PLAYERp pp, short hit_sect, short hit_wall, int hit_x, int hit_y, int hit_z, short hit_ang); -int DoActorBeginSlide(short SpriteNum, short ang, short vel, short dec); +int DoActorBeginSlide(int SpriteNum, short ang, short vel, short dec); int GetOverlapSector(int x, int y, short *over, short *under); bool MissileHitDiveArea(short SpriteNum); @@ -222,7 +221,7 @@ int AddSpriteToSectorObject(short SpriteNum,SECTOR_OBJECTp sop); void QueueReset(void); int PlayerCheckDeath(PLAYERp pp,short Weapon); bool SpriteWarpToUnderwater(SPRITEp sp); -int PlayerDamageSlide(PLAYERp pp,short damage,short ang); +int PlayerDamageSlide(PLAYERp pp,int damage,short ang); bool VehicleMoveHit(short SpriteNum); int SpawnSplash(short SpriteNum); int SpawnMineExp(int16_t Weapon); diff --git a/source/games/sw/src/zilla.cpp b/source/games/sw/src/zilla.cpp index 37e234bb0..c513c4701 100644 --- a/source/games/sw/src/zilla.cpp +++ b/source/games/sw/src/zilla.cpp @@ -775,7 +775,7 @@ int DoZillaDeathMelt(short SpriteNum) if (!SW_SHAREWARE) { // Resume the regular music - in a hack-free fashion. - PlaySong(currentLevel->labelName, currentLevel->music, currentLevel->cdSongId); + PlaySong(currentLevel->music, currentLevel->cdSongId); } //KeepActorOnFloor(SpriteNum); diff --git a/source/games/whaven/src/ai.h b/source/games/whaven/src/ai.h index 9e6478ce3..d88f0fe53 100644 --- a/source/games/whaven/src/ai.h +++ b/source/games/whaven/src/ai.h @@ -44,9 +44,9 @@ struct EnemyInfo spr.clipdist = clipdist; spr.hitag = getHealth(*this, spr); if(sizx != -1) - spr.xrepeat = sizx; + spr.xrepeat = (uint8_t)sizx; if(sizy != -1) - spr.yrepeat = sizy; + spr.yrepeat = (uint8_t)sizy; spr.lotag = 100; int tflag = 0; diff --git a/source/games/whaven/src/animatesprites.cpp b/source/games/whaven/src/animatesprites.cpp index 54aae59cf..ac28c33f0 100644 --- a/source/games/whaven/src/animatesprites.cpp +++ b/source/games/whaven/src/animatesprites.cpp @@ -353,8 +353,8 @@ void analyzesprites(PLAYER& plr, int dasmoothratio,spritetype* tsprite, int& spr tshadow.z = fz + 1; tshadow.statnum = 99; - tshadow.xrepeat = siz; - tshadow.yrepeat = (short) (tspr.yrepeat >> 3); + tshadow.xrepeat = (uint8_t)siz; + tshadow.yrepeat = (uint8_t) (tspr.yrepeat >> 3); if (tshadow.yrepeat < 4) tshadow.yrepeat = 4; diff --git a/source/games/whaven/src/music.cpp b/source/games/whaven/src/music.cpp index 01e1b3dcb..145d85e17 100644 --- a/source/games/whaven/src/music.cpp +++ b/source/games/whaven/src/music.cpp @@ -25,7 +25,7 @@ static bool playthesong(int which, bool looped) { char buffer[40]; mysnprintf(buffer, 40, "%s/%04d", isWh2()? "F_SONGS" : "SONGS", which); - return Mus_Play(currentLevel->labelName, buffer, looped); + return Mus_Play(buffer, looped); } static bool loadlevelsongs(int which) @@ -47,7 +47,7 @@ void startmusic(int level) // allow music override from MAPINFO. if (currentLevel->music.IsNotEmpty()) { - Mus_Play(currentLevel->labelName, currentLevel->music, true); + Mus_Play(currentLevel->music, true); oldsong = -1; return; } diff --git a/source/games/whaven/src/render.cpp b/source/games/whaven/src/render.cpp index 44eaedcbd..7c5b18d02 100644 --- a/source/games/whaven/src/render.cpp +++ b/source/games/whaven/src/render.cpp @@ -27,9 +27,9 @@ void drawscreen(int num, double dasmoothratio, bool sceneonly) { auto& prevloc = gPrevPlayerLoc[num]; - cposx = prevloc.x + MulScale(cposx - prevloc.x, dasmoothratio, 16); - cposy = prevloc.y + MulScale(cposy - prevloc.y, dasmoothratio, 16); - cposz = prevloc.z + MulScale(cposz - prevloc.z, dasmoothratio, 16); + cposx = prevloc.x + MulScale(cposx - prevloc.x, (int)dasmoothratio, 16); + cposy = prevloc.y + MulScale(cposy - prevloc.y, (int)dasmoothratio, 16); + cposz = prevloc.z + MulScale(cposz - prevloc.z, (int)dasmoothratio, 16); if (cl_syncinput) { @@ -73,7 +73,7 @@ void drawscreen(int num, double dasmoothratio, bool sceneonly) inpreparemirror = true; renderSetRollAngle(1024); renderDrawRoomsQ16(cposx, cposy, cposz, cang.asq16(), choriz.asq16(), floormirrorsector[i]); - analyzesprites(plr, dasmoothratio, pm_tsprite, pm_spritesortcnt); + analyzesprites(plr, (int)dasmoothratio, pm_tsprite, pm_spritesortcnt); renderDrawMasks(); renderSetRollAngle(0); inpreparemirror = false; @@ -91,9 +91,9 @@ void drawscreen(int num, double dasmoothratio, bool sceneonly) if (!testnewrenderer) { - renderSetRollAngle(crotscrnang.asbuildf()); + renderSetRollAngle((float)crotscrnang.asbuildf()); renderDrawRoomsQ16(cposx, cposy, cposz, cang.asq16(), choriz.asq16(), plr.sector); - analyzesprites(plr, dasmoothratio, pm_tsprite, pm_spritesortcnt); + analyzesprites(plr, (int)dasmoothratio, pm_tsprite, pm_spritesortcnt); renderDrawMasks(); } else diff --git a/source/games/whaven/src/sound.cpp b/source/games/whaven/src/sound.cpp index 8a2373ae5..a083d7835 100644 --- a/source/games/whaven/src/sound.cpp +++ b/source/games/whaven/src/sound.cpp @@ -140,7 +140,7 @@ void GameInterface::UpdateSounds() if (player[pyrn].spritenum >= 0) { - listener.angle = -FixedToFloat(player[pyrn].angle.ang.asq16()) * pi::pi() / 1024; // Build uses a period of 2048. + listener.angle = float(-FixedToFloat(player[pyrn].angle.ang.asq16()) * pi::pi() / 1024); // Build uses a period of 2048. listener.velocity.Zero(); vec3_t ppos{ player[pyrn].x, player[pyrn].y, player[pyrn].z }; listener.position = GetSoundPos(&ppos); @@ -166,7 +166,7 @@ int playsound_internal(int sn, spritetype *spr, int x, int y, int loop, int chan int sourcetype = spr ? SOURCE_Actor : x != 0 || y != 0 ? SOURCE_Unattached : SOURCE_None; vec3_t pos = { x, y, 0 }; auto spos = GetSoundPos(&pos); - float attn = sourcetype == SOURCE_None ? 0 : 1; + float attn = sourcetype == SOURCE_None ? ATTN_NONE : ATTN_NORM; int flags = sourcetype == SOURCE_Unattached ? CHANF_LISTENERZ : CHANF_NONE; if (loop != 0) flags |= CHANF_LOOP; auto sfx = soundEngine->StartSound(sourcetype, spr, &spos, chan, EChanFlags::FromInt(flags), sn, 1.f, attn); diff --git a/source/games/whaven/src/spellbooks.cpp b/source/games/whaven/src/spellbooks.cpp index 0b6f9d3be..6b695a4f9 100644 --- a/source/games/whaven/src/spellbooks.cpp +++ b/source/games/whaven/src/spellbooks.cpp @@ -71,9 +71,9 @@ void castaorb(PLAYER& plr) { spritesound(S_GENERALMAGIC2, &sprite[plr.spritenum]); } else { - daang = BClampAngle(plr.angle.ang.asbuild() - 36); + daang = (float)BClampAngle(plr.angle.ang.asbuild() - 36); for (k = 0; k < 10; k++) { - daang = BClampAngle(daang + (k << 1)); + daang = (float)BClampAngle(int(daang) + (k << 1)); shootgun(plr, daang, 2); } spritesound(S_SPELL1, &sprite[plr.spritenum]); diff --git a/source/games/whaven/src/weapons.cpp b/source/games/whaven/src/weapons.cpp index 4295ef95a..8347ee221 100644 --- a/source/games/whaven/src/weapons.cpp +++ b/source/games/whaven/src/weapons.cpp @@ -2277,7 +2277,7 @@ void swingdapunch(PLAYER& plr, int daweapon) { } void swingdaweapon(PLAYER& plr) { - float daang = FixedToFloat(plr.angle.ang.asq16()); + float daang = (float)FixedToFloat(plr.angle.ang.asq16()); if (plr.currweaponframe == BOWWALK + 5 && plr.ammo[6] > 0) { plr.currweaponfired = 5; diff --git a/source/games/whaven/src/wh.h b/source/games/whaven/src/wh.h index 807f95e79..62f530356 100644 --- a/source/games/whaven/src/wh.h +++ b/source/games/whaven/src/wh.h @@ -418,7 +418,7 @@ inline void showmessage(const char* msg, int) inline bool isValidSector(int num) { - return ((unsigned)num < numsectors); + return ((unsigned)num < (unsigned)numsectors); } inline int BClampAngle(int a) diff --git a/source/games/whaven/src/whfx.cpp b/source/games/whaven/src/whfx.cpp index 4da4cd44d..4af636409 100644 --- a/source/games/whaven/src/whfx.cpp +++ b/source/games/whaven/src/whfx.cpp @@ -302,7 +302,7 @@ void movewater(uint8_t* dapic) { void skypanfx() { for (int i = 0; i < skypancnt; i++) { - sector[skypanlist[i]].setceilingxpan(-((PlayClock >> 2) & 255)); + sector[skypanlist[i]].setceilingxpan(-float(PlayClock & 255)); } } @@ -312,32 +312,32 @@ void panningfx() { switch (whichdir) { case 0: - sector[floorpanninglist[i]].setfloorypan(((PlayClock >> 2) & 255)); + sector[floorpanninglist[i]].setfloorypan(float(PlayClock & 255)); break; case 1: - sector[floorpanninglist[i]].setfloorxpan(-((PlayClock >> 2) & 255)); - sector[floorpanninglist[i]].setfloorypan(((PlayClock >> 2) & 255)); + sector[floorpanninglist[i]].setfloorxpan(-float(PlayClock & 255)); + sector[floorpanninglist[i]].setfloorypan(float(PlayClock & 255)); break; case 2: - sector[floorpanninglist[i]].setfloorxpan(-((PlayClock >> 2) & 255)); + sector[floorpanninglist[i]].setfloorxpan(-float(PlayClock & 255)); break; case 3: - sector[floorpanninglist[i]].setfloorxpan(-((PlayClock >> 2) & 255)); - sector[floorpanninglist[i]].setfloorypan(-((PlayClock >> 2) & 255)); + sector[floorpanninglist[i]].setfloorxpan(-float(PlayClock & 255)); + sector[floorpanninglist[i]].setfloorypan(-float(PlayClock & 255)); break; case 4: - sector[floorpanninglist[i]].setfloorypan(-((PlayClock >> 2) & 255)); + sector[floorpanninglist[i]].setfloorypan(-float(PlayClock & 255)); break; case 5: - sector[floorpanninglist[i]].setfloorxpan(((PlayClock >> 2) & 255)); - sector[floorpanninglist[i]].setfloorypan(-((PlayClock >> 2) & 255)); + sector[floorpanninglist[i]].setfloorxpan(float(PlayClock & 255)); + sector[floorpanninglist[i]].setfloorypan(-float(PlayClock & 255)); break; case 6: - sector[floorpanninglist[i]].setfloorxpan(((PlayClock >> 2) & 255)); + sector[floorpanninglist[i]].setfloorxpan(float(PlayClock & 255)); break; case 7: - sector[floorpanninglist[i]].setfloorxpan(((PlayClock >> 2) & 255)); - sector[floorpanninglist[i]].setfloorypan(((PlayClock >> 2) & 255)); + sector[floorpanninglist[i]].setfloorxpan(float(PlayClock & 255)); + sector[floorpanninglist[i]].setfloorypan(float(PlayClock & 255)); break; default: sector[floorpanninglist[i]].setfloorxpan(0); @@ -351,11 +351,11 @@ void panningfx() { int startwall = sector[dasector].wallptr; int endwall = startwall + sector[dasector].wallnum - 1; for (int s = startwall; s <= endwall; s++) - wall[s].setxpan((PlayClock >> 2) & 255); + wall[s].setxpan(float(PlayClock & 255)); } for (int i = 0; i < ypanningwallcnt; i++) - wall[ypanningwalllist[i]].setypan(~(PlayClock & 255)); + wall[ypanningwalllist[i]].setypan((float)~(PlayClock & 255)); } void revolvefx() { diff --git a/source/games/whaven/src/whmap.cpp b/source/games/whaven/src/whmap.cpp index dc88e12f6..e13accf44 100644 --- a/source/games/whaven/src/whmap.cpp +++ b/source/games/whaven/src/whmap.cpp @@ -677,8 +677,9 @@ boolean prepareboard(const char* fname) { break; case PINE: - spr.xrepeat = treesize = (short) (((krand() % 5) + 3) << 4); - spr.yrepeat = treesize; + treesize = (short) (((krand() % 5) + 3) << 4); + spr.xrepeat = (uint8_t)treesize; + spr.yrepeat = (uint8_t)treesize; break; case GYSER: @@ -731,8 +732,8 @@ boolean prepareboard(const char* fname) { if(isItemSprite(i)) { Item& item = items[(spr.detail & 0xFF) - ITEMSBASE]; if(item.sizx != -1 && item.sizy != -1) { - spr.xrepeat = (short) item.sizx; - spr.yrepeat = (short) item.sizy; + spr.xrepeat = (uint8_t)item.sizx; + spr.yrepeat = (uint8_t)item.sizy; } if(item.treasures) diff --git a/source/games/whaven/src/whobj.cpp b/source/games/whaven/src/whobj.cpp index 374d06d05..ff9ee3ef1 100644 --- a/source/games/whaven/src/whobj.cpp +++ b/source/games/whaven/src/whobj.cpp @@ -15,6 +15,8 @@ short torchpattern[] = { 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 4, 4, 6, 6, 4, 4, 6 int monsterwarptime; short adjusthp(int hp) { +#if 0 + // this doesn't do much because 'factor' will always be 0 due to integer division float factor = (krand() % 20) / 100; int howhard = difficulty; @@ -22,6 +24,9 @@ short adjusthp(int hp) { return (short) ((hp * (factor + 1)) * howhard); else return (short) ((hp - (hp * (factor))) * howhard); +#else + return (short)(hp * difficulty); +#endif } void timerprocess(PLAYER& plr) { diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 258bad5d6..724c508c7 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -84,8 +84,8 @@ void GLInstance::Draw(EDrawType type, size_t start, size_t count) { assert (BufferLock > 0); applyMapFog(); - renderState.vindex = start; - renderState.vcount = count; + renderState.vindex = (int)start; + renderState.vcount = (int)count; renderState.primtype = type; rendercommands.Push(renderState); clearMapFog(); @@ -115,7 +115,7 @@ void GLInstance::DoDraw() } else { - FHWModelRenderer mr(*screen->RenderState(), 0); + FHWModelRenderer mr(*screen->RenderState(), -1); state.SetDepthFunc(DF_LEqual); state.EnableTexture(true); rs.model->BuildVertexBuffer(&mr); diff --git a/source/libsmackerdec/src/HuffmanVLC.cpp b/source/libsmackerdec/src/HuffmanVLC.cpp index 3f7fd45f8..400e622f8 100644 --- a/source/libsmackerdec/src/HuffmanVLC.cpp +++ b/source/libsmackerdec/src/HuffmanVLC.cpp @@ -65,7 +65,7 @@ void VLC_InitTable(VLCtable &table, uint32_t maxLength, uint32_t size, int *leng uint32_t VLC_GetSize(VLCtable &table) { - return table.size(); + return uint32_t(table.size()); } } // close namespace SmackerCommon diff --git a/source/libsmackerdec/src/SmackerDecoder.cpp b/source/libsmackerdec/src/SmackerDecoder.cpp index 7b00caed8..c981d35a6 100644 --- a/source/libsmackerdec/src/SmackerDecoder.cpp +++ b/source/libsmackerdec/src/SmackerDecoder.cpp @@ -69,7 +69,7 @@ SmackerHandle Smacker_Open(const char* fileName) classInstances.push_back(newDecoder); // get a handle ID - newHandle.instanceIndex = classInstances.size() - 1; + newHandle.instanceIndex = int(classInstances.size()) - 1; // loaded ok, make handle valid newHandle.isValid = true; @@ -1116,7 +1116,7 @@ void SmackerDecoder::GotoFrame(uint32_t frameNum) currentFrame = 0; nextPos = firstFrameFilePos; - for (int i = 0; i < frameNum + 1; i++) + for (unsigned i = 0; i < frameNum + 1; i++) GetNextFrame(); } diff --git a/wadsrc/static/engine/grpinfo.txt b/wadsrc/static/engine/grpinfo.txt index 2fd0789ef..ede549a10 100644 --- a/wadsrc/static/engine/grpinfo.txt +++ b/wadsrc/static/engine/grpinfo.txt @@ -239,6 +239,18 @@ grpinfo GameID "DukeDC" } +grpinfo +{ + name "Duke it out in D.C." + scriptname "DUKEDC.CON" + size 8410183 + crc 0x777c77b1 + flags GAMEFLAG_DUKE|GAMEFLAG_ADDON|GAMEFLAG_DUKEDC + dependency DUKE15_CRC + gamefilter "Duke.DukeDC.15" + GameID "DukeDC" +} + grpinfo { name "Duke Caribbean: Life's a Beach (1.3)" @@ -284,7 +296,7 @@ grpinfo name "Duke Caribbean: Life's a Beach" size 22213819 crc DUKECB_CRC - flags GAMEFLAG_DUKE|GAMEFLAG_ADDON|GAMEFLAG_DUKEVACA + flags GAMEFLAG_DUKE|GAMEFLAG_ADDON dependency DUKE15_CRC gamefilter "Duke.Vacation.15" FgColor 0x00004f @@ -298,7 +310,21 @@ grpinfo scriptname "VACATION.CON" size 22397273 crc 0x65B5F690 - flags GAMEFLAG_DUKE|GAMEFLAG_ADDON|GAMEFLAG_DUKEVACA + flags GAMEFLAG_DUKE|GAMEFLAG_ADDON + dependency DUKE15_CRC + gamefilter "Duke.Vacation.15" + FgColor 0x00004f + BkColor 0x8f8fff + GameID "DukeVacation" +} + +grpinfo +{ + name "Duke Caribbean: Life's a Beach" + scriptname "VACATION.CON" + size 22201375 + crc 0xb28e883c + flags GAMEFLAG_DUKE|GAMEFLAG_ADDON dependency DUKE15_CRC gamefilter "Duke.Vacation.15" FgColor 0x00004f @@ -312,7 +338,7 @@ grpinfo scriptname "NWINTER.CON" size 16169365 crc DUKENW_CRC - flags GAMEFLAG_DUKE|GAMEFLAG_ADDON|GAMEFLAG_DUKENW + flags GAMEFLAG_DUKE|GAMEFLAG_ADDON dependency DUKE15_CRC gamefilter "Duke.NWinter" FgColor 0 @@ -326,7 +352,7 @@ grpinfo scriptname "NWINTER.CON" size 10965909 crc 0xC7EFBFA9 - flags GAMEFLAG_DUKE|GAMEFLAG_ADDON|GAMEFLAG_DUKENW + flags GAMEFLAG_DUKE|GAMEFLAG_ADDON dependency DUKE15_CRC gamefilter "Duke.NWinter" FgColor 0 diff --git a/wadsrc/static/filter/blood/engine/rmapinfo.txt b/wadsrc/static/filter/blood/engine/rmapinfo.txt index f05bb05c4..482dbc52c 100644 --- a/wadsrc/static/filter/blood/engine/rmapinfo.txt +++ b/wadsrc/static/filter/blood/engine/rmapinfo.txt @@ -18,4 +18,5 @@ gameinfo { summaryscreen = BloodCutscenes.BuildSPSummary mpsummaryscreen = BloodCutscenes.BuildMPSummary + statusbarclass = BloodStatusBar } diff --git a/wadsrc/static/filter/duke/engine/rmapinfo.txt b/wadsrc/static/filter/duke/engine/rmapinfo.txt index 4462a9795..f2259245b 100644 --- a/wadsrc/static/filter/duke/engine/rmapinfo.txt +++ b/wadsrc/static/filter/duke/engine/rmapinfo.txt @@ -71,4 +71,5 @@ gameinfo { summaryscreen = DukeCutscenes.BuildSPSummary mpsummaryscreen = DukeCutscenes.BuildMPSummary + statusbarclass = DukeStatusBar } \ No newline at end of file diff --git a/wadsrc/static/filter/exhumed/engine/rmapinfo.txt b/wadsrc/static/filter/exhumed/engine/rmapinfo.txt index 5fafd97b6..6d5dcad9e 100644 --- a/wadsrc/static/filter/exhumed/engine/rmapinfo.txt +++ b/wadsrc/static/filter/exhumed/engine/rmapinfo.txt @@ -13,7 +13,6 @@ episode LEV0 cluster 1 { - name = "Exhumed" gameover { function = ExhumedCutscenes.BuildGameoverScene @@ -22,12 +21,10 @@ cluster 1 cluster 2 { - name = "$TXT_EX_MAP00" } cluster 3 { - name = "Multiplayer" } cluster 4 @@ -303,4 +300,5 @@ cutscenes gameinfo { summaryscreen = ExhumedCutscenes.BuildMap + statusbarclass = ExhumedStatusBar } diff --git a/wadsrc/static/filter/nam/engine/rmapinfo.txt b/wadsrc/static/filter/nam/engine/rmapinfo.txt new file mode 100644 index 000000000..f2259245b --- /dev/null +++ b/wadsrc/static/filter/nam/engine/rmapinfo.txt @@ -0,0 +1,75 @@ +//This sets up the missing things that cannot be inferred from the setup in the .CON files. + +cluster 1 +{ + outro + { + function = DukeCutscenes.BuildE1End + } +} + +cluster 2 +{ + outro + { + function = DukeCutscenes.BuildE2End + } + interbackground = "BONUSSCREEN2" +} + +cluster 3 +{ + outro + { + function = DukeCutscenes.BuildE3End + } +} + +cluster 4 +{ + outro + { + function = DukeCutscenes.BuildE4End + } +} + +cluster 5 +{ + outro + { + function = DukeCutscenes.BuildE5End + } +} + +map { 4, 1 } +{ + intro + { + function = DukeCutscenes.BuildE4Intro + } +} + +cutscenes +{ + intro + { + function = DukeCutscenes.BuildIntro + } + + sharewareend + { + function = DukeCutscenes.BuildSharewareEnd + } + + loadscreen + { + function = DukeCutscenes.BuildLoading + } +} + +gameinfo +{ + summaryscreen = DukeCutscenes.BuildSPSummary + mpsummaryscreen = DukeCutscenes.BuildMPSummary + statusbarclass = DukeStatusBar +} \ No newline at end of file diff --git a/wadsrc/static/filter/redneck.redneck/engine/rmapinfo.txt b/wadsrc/static/filter/redneck.redneck/engine/rmapinfo.txt index dcbd6a8d9..8d9e1d751 100644 --- a/wadsrc/static/filter/redneck.redneck/engine/rmapinfo.txt +++ b/wadsrc/static/filter/redneck.redneck/engine/rmapinfo.txt @@ -121,4 +121,5 @@ gameinfo { summaryscreen = RRCutscenes.BuildSPSummary mpsummaryscreen = DukeCutscenes.BuildMPSummary // identical with Duke's + statusbarclass = RedneckStatusBar } diff --git a/wadsrc/static/filter/redneck.ridesagain/engine/rmapinfo.txt b/wadsrc/static/filter/redneck.ridesagain/engine/rmapinfo.txt index bd8cda805..d6ca9561a 100644 --- a/wadsrc/static/filter/redneck.ridesagain/engine/rmapinfo.txt +++ b/wadsrc/static/filter/redneck.ridesagain/engine/rmapinfo.txt @@ -117,4 +117,5 @@ gameinfo { summaryscreen = RRCutscenes.BuildSPSummary mpsummaryscreen = DukeCutscenes.BuildMPSummary // identical with Duke's + statusbarclass = RedneckStatusBar } diff --git a/wadsrc/static/filter/redneck.route66/engine/rmapinfo.txt b/wadsrc/static/filter/redneck.route66/engine/rmapinfo.txt index 59246e710..79104d930 100644 --- a/wadsrc/static/filter/redneck.route66/engine/rmapinfo.txt +++ b/wadsrc/static/filter/redneck.route66/engine/rmapinfo.txt @@ -106,4 +106,5 @@ gameinfo { summaryscreen = RRCutscenes.BuildSPSummary mpsummaryscreen = DukeCutscenes.BuildMPSummary // identical with Duke's + statusbarclass = RedneckStatusBar } diff --git a/wadsrc/static/filter/shadowwarrior/engine/SWCustom.txt b/wadsrc/static/filter/shadowwarrior/engine/SWCustom.txt index 1241f473f..dc8e78abc 100644 --- a/wadsrc/static/filter/shadowwarrior/engine/SWCustom.txt +++ b/wadsrc/static/filter/shadowwarrior/engine/SWCustom.txt @@ -351,7 +351,7 @@ weapon 3 maxammo 99 mindamage 5 maxdamage 10 - pickup 9 + pickup -1 weaponpickup 9 } weapon 4 @@ -361,7 +361,7 @@ weapon 4 maxammo 20 mindamage 5 maxdamage 10 - pickup 5 + pickup -1 weaponpickup 5 } weapon 5 @@ -401,8 +401,8 @@ weapon 8 maxammo 50 mindamage 15 maxdamage 30 - pickup 6 - weaponpickup 8 + pickup 8 + weaponpickup 6 } weapon 9 { @@ -421,8 +421,8 @@ weapon 10 maxammo 52 mindamage 4 maxdamage 4 - pickup 8 - weaponpickup 24 + pickup 24 + weaponpickup 8 } weapon 11 { @@ -431,7 +431,7 @@ weapon 11 maxammo 80 mindamage 10 maxdamage 25 - pickup 30 + pickup 60 weaponpickup 30 } weapon 12 @@ -441,7 +441,7 @@ weapon 12 maxammo 5 mindamage 75 maxdamage 100 - pickup 1 + pickup 6 weaponpickup 1 } fortune diff --git a/wadsrc/static/filter/shadowwarrior/engine/rmapinfo.txt b/wadsrc/static/filter/shadowwarrior/engine/rmapinfo.txt index 877cda926..72ef780bc 100644 --- a/wadsrc/static/filter/shadowwarrior/engine/rmapinfo.txt +++ b/wadsrc/static/filter/shadowwarrior/engine/rmapinfo.txt @@ -59,5 +59,6 @@ gameinfo { summaryscreen = SWCutscenes.BuildSPSummary mpsummaryscreen = SWCutscenes.BuildMPSummary + statusbarclass = SWStatusBar } diff --git a/wadsrc/static/filter/witchaven.witchaven/engine/rmapinfo.txt b/wadsrc/static/filter/witchaven.witchaven/engine/rmapinfo.txt index 3ad507a5d..82a7326e1 100644 --- a/wadsrc/static/filter/witchaven.witchaven/engine/rmapinfo.txt +++ b/wadsrc/static/filter/witchaven.witchaven/engine/rmapinfo.txt @@ -182,5 +182,6 @@ cutscenes gameinfo { + StatusbarClass = WHStatusBar } diff --git a/wadsrc/static/filter/witchaven.witchaven2/engine/rmapinfo.txt b/wadsrc/static/filter/witchaven.witchaven2/engine/rmapinfo.txt index 8e45dbb35..37e45b354 100644 --- a/wadsrc/static/filter/witchaven.witchaven2/engine/rmapinfo.txt +++ b/wadsrc/static/filter/witchaven.witchaven2/engine/rmapinfo.txt @@ -127,5 +127,6 @@ cutscenes gameinfo { + StatusbarClass = WHStatusBar } diff --git a/wadsrc/static/filter/ww2gi/engine/rmapinfo.txt b/wadsrc/static/filter/ww2gi/engine/rmapinfo.txt new file mode 100644 index 000000000..f2259245b --- /dev/null +++ b/wadsrc/static/filter/ww2gi/engine/rmapinfo.txt @@ -0,0 +1,75 @@ +//This sets up the missing things that cannot be inferred from the setup in the .CON files. + +cluster 1 +{ + outro + { + function = DukeCutscenes.BuildE1End + } +} + +cluster 2 +{ + outro + { + function = DukeCutscenes.BuildE2End + } + interbackground = "BONUSSCREEN2" +} + +cluster 3 +{ + outro + { + function = DukeCutscenes.BuildE3End + } +} + +cluster 4 +{ + outro + { + function = DukeCutscenes.BuildE4End + } +} + +cluster 5 +{ + outro + { + function = DukeCutscenes.BuildE5End + } +} + +map { 4, 1 } +{ + intro + { + function = DukeCutscenes.BuildE4Intro + } +} + +cutscenes +{ + intro + { + function = DukeCutscenes.BuildIntro + } + + sharewareend + { + function = DukeCutscenes.BuildSharewareEnd + } + + loadscreen + { + function = DukeCutscenes.BuildLoading + } +} + +gameinfo +{ + summaryscreen = DukeCutscenes.BuildSPSummary + mpsummaryscreen = DukeCutscenes.BuildMPSummary + statusbarclass = DukeStatusBar +} \ No newline at end of file diff --git a/wadsrc/static/zscript.txt b/wadsrc/static/zscript.txt index 73f70d7ea..d2af31ee5 100644 --- a/wadsrc/static/zscript.txt +++ b/wadsrc/static/zscript.txt @@ -29,25 +29,32 @@ version "4.3" #include "zscript/constants.zs" #include "zscript/razebase.zs" #include "zscript/screenjob.zs" - +#include "zscript/statusbar.zs" #include "zscript/games/duke/dukegame.zs" +#include "zscript/games/duke/ui/sbar.zs" +#include "zscript/games/duke/ui/sbar_d.zs" +#include "zscript/games/duke/ui/sbar_r.zs" #include "zscript/games/duke/ui/screens.zs" #include "zscript/games/duke/ui/cutscenes.zs" #include "zscript/games/duke/ui/menu.zs" #include "zscript/games/blood/bloodgame.zs" #include "zscript/games/blood/ui/menu.zs" +#include "zscript/games/blood/ui/sbar.zs" #include "zscript/games/blood/ui/screens.zs" #include "zscript/games/sw/swgame.zs" #include "zscript/games/sw/ui/menu.zs" +#include "zscript/games/sw/ui/sbar.zs" #include "zscript/games/sw/ui/screens.zs" #include "zscript/games/exhumed/exhumedgame.zs" #include "zscript/games/exhumed/ui/menu.zs" +#include "zscript/games/exhumed/ui/sbar.zs" #include "zscript/games/exhumed/ui/screens.zs" #include "zscript/games/wh/whgame.zs" +#include "zscript/games/wh/ui/sbar.zs" #include "zscript/games/wh/ui/menu_wh1.zs" #include "zscript/games/wh/ui/menu_wh2.zs" #include "zscript/games/wh/ui/screens.zs" diff --git a/wadsrc/static/zscript/engine/dynarrays.zs b/wadsrc/static/zscript/engine/dynarrays.zs index 1db4a6224..009350b8e 100644 --- a/wadsrc/static/zscript/engine/dynarrays.zs +++ b/wadsrc/static/zscript/engine/dynarrays.zs @@ -151,6 +151,7 @@ struct DynArray_String native native void Append (DynArray_String other); native uint Find(String item) const; native uint Push (String item); + native vararg uint PushV(String item, ...); native bool Pop (); native void Delete (uint index, int deletecount = 1); native void Insert (uint index, String item); diff --git a/wadsrc/static/zscript/engine/ui/statusbar/statusbarcore.zs b/wadsrc/static/zscript/engine/ui/statusbar/statusbarcore.zs index 2300f33c5..86f93773c 100644 --- a/wadsrc/static/zscript/engine/ui/statusbar/statusbarcore.zs +++ b/wadsrc/static/zscript/engine/ui/statusbar/statusbarcore.zs @@ -39,13 +39,16 @@ class StatusBarCore native ui DI_SCREEN_HOFFSET = 0x60000 | DI_SCREEN_MANUAL_ALIGN, DI_SCREEN_HMASK = 0x60000 | DI_SCREEN_MANUAL_ALIGN, - DI_SCREEN_LEFT_TOP = DI_SCREEN_TOP|DI_SCREEN_LEFT, - DI_SCREEN_RIGHT_TOP = DI_SCREEN_TOP|DI_SCREEN_RIGHT, - DI_SCREEN_LEFT_BOTTOM = DI_SCREEN_BOTTOM|DI_SCREEN_LEFT, - DI_SCREEN_RIGHT_BOTTOM = DI_SCREEN_BOTTOM|DI_SCREEN_RIGHT, - DI_SCREEN_CENTER = DI_SCREEN_VCENTER|DI_SCREEN_HCENTER, - DI_SCREEN_CENTER_BOTTOM = DI_SCREEN_BOTTOM|DI_SCREEN_HCENTER, - DI_SCREEN_OFFSETS = DI_SCREEN_HOFFSET|DI_SCREEN_VOFFSET, + DI_SCREEN_LEFT_TOP = DI_SCREEN_TOP | DI_SCREEN_LEFT, + DI_SCREEN_RIGHT_TOP = DI_SCREEN_TOP | DI_SCREEN_RIGHT, + DI_SCREEN_LEFT_BOTTOM = DI_SCREEN_BOTTOM | DI_SCREEN_LEFT, + DI_SCREEN_LEFT_CENTER = DI_SCREEN_VCENTER | DI_SCREEN_LEFT, + DI_SCREEN_RIGHT_BOTTOM = DI_SCREEN_BOTTOM | DI_SCREEN_RIGHT, + DI_SCREEN_RIGHT_CENTER = DI_SCREEN_VCENTER | DI_SCREEN_RIGHT, + DI_SCREEN_CENTER = DI_SCREEN_VCENTER | DI_SCREEN_HCENTER, + DI_SCREEN_CENTER_TOP = DI_SCREEN_TOP | DI_SCREEN_HCENTER, + DI_SCREEN_CENTER_BOTTOM = DI_SCREEN_BOTTOM | DI_SCREEN_HCENTER, + DI_SCREEN_OFFSETS = DI_SCREEN_HOFFSET | DI_SCREEN_VOFFSET, DI_ITEM_AUTO = 0, // equivalent with bottom center, which is the default alignment. @@ -105,8 +108,12 @@ class StatusBarCore native ui native static String FormatNumber(int number, int minsize = 0, int maxsize = 0, int format = 0, String prefix = ""); native double, double, double, double StatusbarToRealCoords(double x, double y=0, double w=0, double h=0); - native void DrawTexture(TextureID texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent); - native void DrawImage(String texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent); + native void DrawTexture(TextureID texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0, double clipwidth = -1); + native void DrawImage(String texture, Vector2 pos, int flags = 0, double Alpha = 1., Vector2 box = (-1, -1), Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0, double clipwidth = -1); + + native void DrawTextureRotated(TextureID texid, Vector2 pos, int flags, double angle, double alpha = 1, Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0); + native void DrawImageRotated(String texid, Vector2 pos, int flags, double angle, double alpha = 1, Vector2 scale = (1, 1), ERenderStyle style = STYLE_Translucent, Color col = 0xffffffff, int translation = 0); + native void DrawString(HUDFont font, String string, Vector2 pos, int flags = 0, int translation = Font.CR_UNTRANSLATED, double Alpha = 1., int wrapwidth = -1, int linespacing = 4, Vector2 scale = (1, 1), int pt = 0, ERenderStyle style = STYLE_Translucent); native double, double, double, double TransformRect(double x, double y, double w, double h, int flags = 0); native void Fill(Color col, double x, double y, double w, double h, int flags = 0); diff --git a/wadsrc/static/zscript/games/blood/bloodgame.zs b/wadsrc/static/zscript/games/blood/bloodgame.zs index 839b2f6cb..d8aa05251 100644 --- a/wadsrc/static/zscript/games/blood/bloodgame.zs +++ b/wadsrc/static/zscript/games/blood/bloodgame.zs @@ -1,8 +1,136 @@ // contains all global Blood definitions struct Blood native { + // POWERUPS ///////////////////////////////////////////////////// + enum EPowerupType { + kPwUpFeatherFall = 12, + kPwUpShadowCloak = 13, + kPwUpDeathMask = 14, + kPwUpJumpBoots = 15, + kPwUpTwoGuns = 17, + kPwUpDivingSuit = 18, + kPwUpGasMask = 19, + kPwUpCrystalBall = 21, + kPwUpDoppleganger = 23, + kPwUpReflectShots = 24, + kPwUpBeastVision = 25, + kPwUpShadowCloakUseless = 26, + kPwUpDeliriumShroom = 28, + kPwUpGrowShroom = 29, + kPwUpShrinkShroom = 30, + kPwUpDeathMaskUseless = 31, + kPwUpAsbestArmor = 39, + kMaxPowerUps = 51, + }; + native static void PlayIntroMusic(); native static bool OriginalLoadScreen(); // doing it generically would necessitate exporting the tile manage which we do not want. native static void sndStartSample(int resid, int volume, int channel, bool loop = false, int chanflags = 0); native static void sndStartSampleNamed(String sname, int volume, int channel); + native static TextureID PowerupIcon(int pwup); + native static BloodPlayer GetViewPlayer(); + + // These are just dummies to make the MP statusbar code compile. + + static void GetPlayers(Array players) + { + players.Clear(); + players.Push(GetViewPlayer()); + } + static int getGameType() + { + return 0; + } } + +struct PACKINFO // not native! +{ + bool isActive; + int curAmount; +} + +struct BloodPlayer native +{ + native int GetHealth(); // health is stored in the XSPRITE which cannot be safely exported to scripting at the moment due to pending refactoring. + native int powerupCheck(int pwup); + //spritetype* pSprite; + //XSPRITE* pXSprite; + //DUDEINFO* pDudeInfo; + //PlayerHorizon horizon; + //PlayerAngle angle; + native uint8 newWeapon; + native int weaponQav; + native int qavCallback; + native bool isRunning; + native int posture; // stand, crouch, swim + native int sceneQav; // by NoOne: used to keep qav id + native int bobPhase; + native int bobAmp; + native int bobHeight; + native int bobWidth; + native int swayPhase; + native int swayAmp; + native int swayHeight; + native int swayWidth; + native int nPlayer; // Connect id + native int nSprite; + native int lifeMode; + native int zView; + native int zViewVel; + native int zWeapon; + native int zWeaponVel; + native int slope; + native bool isUnderwater; + native bool hasKey[8]; + native int8 hasFlag; + native int damageControl[7]; + native int8 curWeapon; + native int8 nextWeapon; + native int weaponTimer; + native int weaponState; + native int weaponAmmo; //rename + native bool hasWeapon[14]; + native int weaponMode[14]; + native int weaponOrder[2][14]; + native int ammoCount[12]; + native bool qavLoop; + native int fuseTime; + native int throwTime; + native int throwPower; + //native Aim aim; // world + native int aimTarget; // aim target sprite + native int aimTargetsCount; + native short aimTargets[16]; + native int deathTime; + native int pwUpTime[51]; // kMaxPowerUps + native int fragCount; + native int fragInfo[8]; + native int teamId; + native int underwaterTime; + native int bubbleTime; + native int restTime; + native int kickPower; + native int laughCount; + native bool godMode; + native bool fallScream; + native bool cantJump; + native int packItemTime; // pack timer + native int packItemId; // pack id 1: diving suit, 2: crystal ball, 3: beast vision 4: jump boots + native PACKINFO packSlots[5]; // at325 [1]: diving suit, [2]: crystal ball, [3]: beast vision [4]: jump boots + native int armor[3]; // armor + native int voodooTarget; + native int flickerEffect; + native int tiltEffect; + native int visibility; + native int painEffect; + native int blindEffect; + native int chokeEffect; + native int handTime; + native bool hand; // if true, there is hand start choking the player + native int pickupEffect; + native bool flashEffect; // if true, reduce pPlayer->visibility counter + native int quakeEffect; + native int player_par; + native int nWaterPal; + //POSTURE pPosture[kModeMax][kPostureMax]; +}; diff --git a/wadsrc/static/zscript/games/blood/ui/sbar.zs b/wadsrc/static/zscript/games/blood/ui/sbar.zs new file mode 100644 index 000000000..b597dd3bc --- /dev/null +++ b/wadsrc/static/zscript/games/blood/ui/sbar.zs @@ -0,0 +1,762 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2010-2019 EDuke32 developers and contributors +Copyright (C) 2019 Nuke.YKT +Copyright (C) 2020-2021 Christoph Oelckers + +This file is part of Raze. + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. + +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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +//------------------------------------------------------------------------- + +class BloodStatusBar : RazeStatusBar +{ + static const String gPackIcons[] = { "PackIcon1", "PackIcon2", "PackIcon3", "PackIcon4", "PackIcon5" }; + + HUDFont smallf, tinyf; + int team_score[2], team_ticker[2]; // placeholders for MP display + bool gBlueFlagDropped, gRedFlagDropped; // also placeholders until we know where MP will go. + + override void Init() + { + smallf = HUDFont.Create(SmallFont, 0, Mono_Off, 0, 0); + tinyf = HUDFont.Create(Font.FindFont("DIGIFONT"), 4, Mono_CellRight, 0, 0); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + int texWidth(String name) + { + let tex = TexMan.CheckForTexture(name, TexMan.Type_Any); + let siz = TexMan.GetScaledSize(tex); + return siz.x; + } + + int texHeight(String name) + { + let tex = TexMan.CheckForTexture(name, TexMan.Type_Any); + let siz = TexMan.GetScaledSize(tex); + return siz.y; + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DrawStatNumber(String pFormat, int nNumber, String nametemplate, double x, double y, int nShade, int nPalette, double nScale = 1, int align = 0) + { + String texname = String.Format("%s%d", nametemplate, 1); + double width = (texWidth(texname) + 1) * nScale; + + String tempbuf = String.Format(pFormat, nNumber); + x += 0.5; + y += 0.5; // This is needed because due to using floating point math, this code rounds slightly differently which for the numbers can be a problem. + for (uint i = 0; i < tempbuf.length(); i++, x += width) + { + int c = tempbuf.ByteAt(i); + if (c < "0" || c > "9") continue; + texname = String.Format("%s%d", nametemplate, c - int("0")); + int flags = align | DI_ITEM_RELCENTER; + DrawImage(texname, (x, y), flags, 1, (-1, -1), (nScale, nScale), STYLE_Translucent, Raze.shadeToLight(nShade), Translation.MakeID(Translation_Remap, nPalette)); + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DrawCharArray(String text, String nametemplate, double x, double y) + { + String texname = String.Format("%s%d", nametemplate, 1); + double width = (texWidth(texname) + 1); + + x += 0.5; + y += 0.5; // This is needed because due to using floating point math, this code rounds slightly differently which for the numbers can be a problem. + + for (uint i = 0; i < text.length(); i++, x += width) + { + int c = text.ByteAt(i); + // Hackasaurus rex to give me a slash when drawing the weapon count of a reloadable gun. + if (c == 47) + { + DrawImage("SBarSlash", (x, y), DI_ITEM_RELCENTER); + } + else + { + if (c < "0" || c > "9") continue; + texname = String.Format("%s%d", nametemplate, c - int("0")); + DrawImage(texname, (x, y), DI_ITEM_RELCENTER); + } + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void TileHGauge(String nTile, double x, double y, int nMult, int nDiv, double sc = 1) + { + int w = texWidth(nTile); + double bx = w * sc * nMult / nDiv + x; + double scale = (bx - x) / w; + DrawImage(nTile, (x, y), DI_ITEM_LEFT_TOP, 1., (-1, -1), (sc, sc), clipwidth:scale); + } + + + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DoLevelStats(BloodPlayer pPlayer, int bottomy, Summaryinfo summary) + { + StatsPrintInfo stats; + + stats.fontscale = 1.; + stats.spacing = SmallFont.GetHeight() + 1; + stats.screenbottomspace = bottomy; + stats.statfont = SmallFont; + stats.letterColor = TEXTCOLOR_DARKRED; + stats.standardColor = TEXTCOLOR_DARKGRAY; + + if (automapMode == am_full) + { + bool textfont = am_textfont; + if (!am_textfont) + { + // For non-English languages force use of the text font. The tiny one is simply too small to ever add localized characters to it. + let p = StringTable.Localize("$REQUIRED_CHARACTERS"); + if (p.length() > 0) textfont = true; + } + + if (!textfont) + { + stats.statfont = SmallFont2; + stats.spacing = 6; + } + if (hud_size <= Hud_StbarOverlay) stats.screenbottomspace = 56; + PrintAutomapInfo(stats, textfont); + } + if (automapMode == am_off && hud_stats) + { + stats.completeColor = TEXTCOLOR_DARKGREEN; + + PrintLevelStats(stats, summary); + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + const nPowerUps = 11; + + void drawPowerUps(BloodPlayer pPlayer) + { + static const float powerScale[] = { 0.4f, 0.4f, 0.3f, 0.3f, 0.4f, 0.3f, 0.4f, 0.5f, 0.3f, 0.4f, 0.4f }; + static const int powerYoffs[] = { 0, 5, 9, 5, 9, 7, 4, 5, 9, 4, 4 }; + + static const int powerOrder[] = { Blood.kPwUpShadowCloak, Blood.kPwUpReflectShots, Blood.kPwUpDeathMask, Blood.kPwUpTwoGuns, Blood.kPwUpShadowCloakUseless, Blood.kPwUpFeatherFall, + Blood.kPwUpGasMask, Blood.kPwUpDoppleganger, Blood.kPwUpAsbestArmor, Blood.kPwUpGrowShroom, Blood.kPwUpShrinkShroom }; + + if (!hud_powerupduration) + return; + + int powersort[nPowerUps]; + + for (int i = 0; i < nPowerUps; i++) powersort[i] = i; + + for (int i = 0; i < nPowerUps; i++) + { + for (int j = i + 1; j < nPowerUps; j++) + { + int power1 = powersort[i]; + int power2 = powersort[j]; + if (pPlayer.pwUpTime[powerOrder[power1]] > pPlayer.pwUpTime[powerOrder[power2]]) + { + powersort[i] = power2; + powersort[j] = power1; + } + } + } + + int warningTime = 5; + int x = 15; + int y = -50; + for (int i = 0; i < nPowerUps; i++) + { + int order = powersort[i]; + int power = powerOrder[order]; + int time = pPlayer.pwUpTime[power]; + if (time > 0) + { + int remainingSeconds = time / 100; + if (remainingSeconds > warningTime || (PlayClock & 32)) + { + DrawTexture(Blood.PowerUpIcon(power), (x, y + powerYoffs[order]), DI_SCREEN_LEFT_CENTER | DI_ITEM_RELCENTER, scale:(powerScale[order], powerScale[order])); + } + + DrawStatNumber("%d", remainingSeconds, "SBarNumberInv", x + 15, y, 0, remainingSeconds > warningTime ? 0 : Translation.MakeID(Translation_Remap, 2), 0.5, DI_SCREEN_LEFT_CENTER); + y += 20; + } + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void drawInventory(BloodPlayer pPlayer, int x, int y) + { + int packs[5]; + if (pPlayer.packItemTime) + { + int nPacks = 0; + int width = 0; + for (int i = 0; i < 5; i++) + { + if (pPlayer.packSlots[i].curAmount) + { + packs[nPacks++] = i; + width += texWidth(gPackIcons[i]) + 1; + } + } + width /= 2; + x -= width; + for (int i = 0; i < nPacks; i++) + { + int nPack = packs[i]; + DrawImage("PackBG", (x + 1, y - 8), DI_ITEM_RELCENTER, style:STYLE_Normal); + DrawImage("PackBG", (x + 1, y - 6), DI_ITEM_RELCENTER, style:STYLE_Normal); + DrawImage(gPackIcons[nPack], (x + 1, y + 1), DI_ITEM_RELCENTER, style:STYLE_Normal); + if (nPack == pPlayer.packItemId) + DrawImage("PackSelect", (x + 1, y + 1), DI_ITEM_RELCENTER); + int nShade; + if (pPlayer.packSlots[nPack].isActive) + nShade = 4; + else + nShade = 24; + DrawStatNumber("%3d", pPlayer.packSlots[nPack].curAmount, "SBarPackAmount", x - 4, y - 13, nShade, 0); + x += texWidth(gPackIcons[nPack]) + 1; + } + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DrawPackItemInStatusBar(BloodPlayer pPlayer, int x, int y, int x2, int y2) + { + let id = pPlayer.packItemId; + //id = 0; + if (id < 0) return; + + DrawImage(gPackIcons[id], (x, y), DI_ITEM_RELCENTER, style:STYLE_Normal); + DrawStatNumber("%3d", pPlayer.packSlots[id].curAmount, "SBarPackAmount", x2, y2, 0, 0); + } + + void DrawPackItemInStatusBar2(BloodPlayer pPlayer, int x, int y, int x2, int y2, double nScale) + { + static const String packIcons2[] = { "Pack2Icon1", "Pack2Icon2", "Pack2Icon3", "Pack2Icon4", "Pack2Icon5" }; + static const float packScale[] = { 0.5f, 0.3f, 0.6f, 0.5f, 0.4f }; + static const int packYoffs[] = { 0, 0, 0, -4, 0 }; + + if (pPlayer.packItemId < 0) return; + let sc = packScale[pPlayer.packItemId]; + DrawImage(packIcons2[pPlayer.packItemId], (x, y + packYoffs[pPlayer.packItemId]), DI_ITEM_RELCENTER, scale:(sc, sc), style:STYLE_Normal); + DrawStatNumber("%3d", pPlayer.packSlots[pPlayer.packItemId].curAmount, "SBarNumberInv", x2, y2, 0, 0, nScale); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void drawPlayerSlots(Array players) + { + for (int nRows = (players.Size() - 1) / 4; nRows >= 0; nRows--) + { + for (int nCol = 0; nCol < 4; nCol++) + { + DrawImage("SBPlayerSlot", (-120 + nCol * 80, 4 + nRows * 9), DI_ITEM_RELCENTER|DI_SCREEN_CENTER_TOP, style:STYLE_Normal, col:0xffc0c0c0); + } + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + + void drawPlayerFrags(Array players) + { + drawPlayerSlots(players); + for (int i = 0; i < players.Size(); i++) + { + int x = -160 + 80 * (i & 3); + int y = 9 * (i / 4); + int col = players[i].teamId & 3; + int cr = col == 0? Font.CR_UNDEFINED : col == 1? Font.CR_BLUE : Font.CR_RED; + DrawString(tinyf, Raze.PlayerName(i), (x + 4, y), DI_SCREEN_CENTER_TOP, cr, 1., -1, -1); + String gTempStr = String.Format("%2d", players[i].fragCount); + DrawString(tinyf, gTempStr, (x + 76, y), DI_SCREEN_CENTER_TOP, cr, 1., -1, -1); + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void drawPlayerFlags(Array players) + { + String gTempStr; + drawPlayerSlots(players); + for (int i = 0; i < players.Size(); i++) + { + int x = -160 + 80 * (i & 3); + int y = 9 * (i / 4); + int col = players[i].teamId & 3; + gTempStr = String.Format("%s", Raze.PlayerName(i)); + int cr = col == 0? Font.CR_UNDEFINED : col == 1? Font.CR_BLUE : Font.CR_RED; + DrawString(tinyf, gTempStr.MakeUpper(), (x + 4, y), DI_SCREEN_CENTER_TOP, cr, 1., -1, -1); + + x += 76; + if (players[i].hasFlag & 2) + { + DrawString(tinyf, "F", (x, y), DI_SCREEN_CENTER_TOP, Font.CR_BLUE/*12*/, 1., -1, -1); + x -= 6; + } + + if (players[i].hasFlag & 1) + DrawString(tinyf, "F", (x, y), DI_SCREEN_CENTER_TOP, Font.CR_RED/*11*/, 1., -1, -1); + } + } + + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void drawCtfHudVanilla(Array players) + { + String gTempStr; + int x = 1, y = 1; + if (team_ticker[0] == 0 || (PlayClock & 8)) + { + DrawString(smallf, "$TXT_COLOR_BLUE", (x, y), 0, Font.CR_LIGHTBLUE, 1., -1, -1); + gTempStr = String.Format("%-3d", team_score[0]); + DrawString(smallf, gTempStr, (x, y + 10), 0, Font.CR_LIGHTBLUE, 1., -1, -1); + } + x = -2; + if (team_ticker[1] == 0 || (PlayClock & 8)) + { + DrawString(smallf, "$TXT_COLOR_RED", (x, y), DI_TEXT_ALIGN_RIGHT, Font.CR_BRICK, 1., -1, -1); + gTempStr = String.Format("%3d", team_score[1]); + DrawString(smallf, gTempStr, (x, y + 10), DI_TEXT_ALIGN_RIGHT, Font.CR_BRICK, 1., -1, -1); + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void flashTeamScore(int team, bool show) + { + if (team_ticker[team] == 0 || (PlayClock & 8)) + { + if (show) + DrawStatNumber("%d", team_score[team], "SBarNumberInv", -30, team ? 25 : -10, 0, team ? 2 : 10, 0.75, DI_SCREEN_RIGHT_CENTER); + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void drawCtfHud(BloodPlayer pPlayer, Array players) + { + if (hud_size == Hud_Nothing) + { + flashTeamScore(0, false); + flashTeamScore(1, false); + return; + } + + bool blueFlagTaken = false; + bool redFlagTaken = false; + int blueFlagCarrierColor = 0; + int redFlagCarrierColor = 0; + for (int i = 0; i < players.Size(); i++) + { + if ((players[i].hasFlag & 1) != 0) + { + blueFlagTaken = true; + blueFlagCarrierColor = players[i].teamId & 3; + } + if ((players[i].hasFlag & 2) != 0) + { + redFlagTaken = true; + redFlagCarrierColor = players[i].teamId & 3; + } + } + + bool meHaveBlueFlag = pPlayer.hasFlag & 1; + int trans10 = Translation.MakeID(Translation_Remap, 10); + int trans2 = Translation.MakeID(Translation_Remap, 2); + DrawImage(meHaveBlueFlag ? "FlagHave" : "FlagHaveNot", (0, 75 - 100), DI_SCREEN_RIGHT_CENTER|DI_ITEM_RELCENTER, scale:(0.35, 0.35), translation:trans10); + if (gBlueFlagDropped) + DrawImage("FlagDropped", (305 - 320, 83 - 100), DI_SCREEN_RIGHT_CENTER|DI_ITEM_RELCENTER, translation:trans10); + else if (blueFlagTaken) + DrawImage("FlagTaken", (307 - 320, 77 - 100), DI_SCREEN_RIGHT_CENTER|DI_ITEM_RELCENTER, translation:blueFlagCarrierColor ? trans2 : trans10); + flashTeamScore(0, true); + + bool meHaveRedFlag = pPlayer.hasFlag & 2; + DrawImage(meHaveRedFlag ? "FlagHave" : "FlagHaveNot", (0, 10), DI_SCREEN_RIGHT_CENTER|DI_ITEM_RELCENTER, scale:(0.35, 0.35), translation:trans2); + if (gRedFlagDropped) + DrawImage("FlagDropped", (305 - 320, 17), DI_SCREEN_RIGHT_CENTER|DI_ITEM_RELCENTER, translation:trans2); + else if (redFlagTaken) + DrawImage("FlagTaken", (307 - 320, 11), DI_SCREEN_RIGHT_CENTER|DI_ITEM_RELCENTER, translation:redFlagCarrierColor ? trans2 : trans10); + flashTeamScore(1, true); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void drawMultiHUD(BloodPlayer pPlayer, int nGameType) + { + if (nGameType >= 1) + { + Array players; + Blood.GetPlayers(players); + if (nGameType == 3) + { + if (hud_ctf_Vanilla) + { + drawCtfHudVanilla(players); + } + else + { + drawCtfHud(pPlayer, players); + drawPlayerFlags(players); + } + } + else + { + drawPlayerFrags(players); + } + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + int DrawStatusBar(BloodPlayer pPlayer, int nPalette) + { + int th = texHeight("Statusbar"); + BeginStatusBar(false, 320, 200, th); + + + int health = pPlayer.GetHealth(); + DrawImage("Statusbar", (160, 200), DI_ITEM_CENTER_BOTTOM); + DrawPackItemInStatusBar(pPlayer, 265, 186, 260, 172); + + if (health >= 16 || (PlayClock & 16) || health == 0) + { + DrawStatNumber("%3d", health >> 4, "SBarHealthAmount", 86, 183, 0, 0); + } + if (pPlayer.curWeapon && pPlayer.weaponAmmo != -1) + { + int num = pPlayer.ammoCount[pPlayer.weaponAmmo]; + if (pPlayer.weaponAmmo == 6) + num /= 10; + DrawStatNumber("%3d", num, "SBarWeaponNum", 216, 183, 0, 0); + } + for (int i = 9; i >= 1; i--) + { + int x = 135 + ((i - 1) / 3) * 23; + int y = 182 + ((i - 1) % 3) * 6; + int num = pPlayer.ammoCount[i]; + if (i == 6) + num /= 10; + DrawStatNumber("%3d", num, "SBarAmmoAmount", x, y, i == pPlayer.weaponAmmo ? -128 : 32, 10); + } + DrawStatNumber("%2d", pPlayer.ammoCount[10], "SBarAmmoAmount", 291, 194, pPlayer.weaponAmmo == 10 ? -128 : 32, 10); + DrawStatNumber("%2d", pPlayer.ammoCount[11], "SBarAmmoAmount", 309, 194, pPlayer.weaponAmmo == 11 ? -128 : 32, 10); + + if (pPlayer.armor[1]) + { + TileHGauge("Armor1Gauge", 44, 174, pPlayer.armor[1], 3200); + DrawStatNumber("%3d", pPlayer.armor[1] >> 4, "SBarAmmoAmount", 50, 177, 0, 0); + } + if (pPlayer.armor[0]) + { + TileHGauge("Armor3Gauge", 44, 182, pPlayer.armor[0], 3200); + DrawStatNumber("%3d", pPlayer.armor[0] >> 4, "SBarAmmoAmount", 50, 185, 0, 0); + } + if (pPlayer.armor[2]) + { + TileHGauge("Armor2Gauge", 44, 190, pPlayer.armor[2], 3200); + DrawStatNumber("%3d", pPlayer.armor[2] >> 4, "SBarAmmoAmount", 50, 193, 0, 0); + } + + for (int i = 0; i < 6; i++) + { + String nTile = String.Format("KEYICON%d", i + 1); + double x = 73.5 + (i & 1) * 173; + double y = 171.5 + (i >> 1) * 11; + if (pPlayer.hasKey[i + 1]) + DrawImage(nTile, (x, y), DI_ITEM_RELCENTER, style:STYLE_Normal); + else + DrawImage(nTile, (x, y), DI_ITEM_RELCENTER, style:STYLE_Normal, col: 0xff606060, translation:Translation.MakeID(Translation_Remap, 5)); + } + DrawImage("BlinkIcon", (118.5, 185.5), DI_ITEM_RELCENTER, col:0xff606060); + DrawImage("BlinkIcon", (201.5, 185.5), DI_ITEM_RELCENTER, col:0xff606060); + if (pPlayer.throwPower) + { + TileHGauge("ThrowGauge", 124, 175.5, pPlayer.throwPower, 1); + } + drawInventory(pPlayer, 166, 200 - th); + // Depending on the scale we can lower the stats display. This needs some tweaking but this catches the important default case already. + return (hud_statscale <= 0.501f || hud_scalefactor < 0.7) && screen.GetAspectRatio() > 1.6 ? 28 : 56; + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + int DrawHUD1(BloodPlayer pPlayer, int nPalette) + { + BeginHUD(1, false, 320, 200); + DrawImage("FullHUD", (34, 187 - 200), DI_ITEM_RELCENTER, style:STYLE_Normal, col:0xffc0c0c0, translation:nPalette); + int health = pPlayer.GetHealth(); + if (health >= 16 || (PlayClock & 16) || health == 0) + { + DrawStatNumber("%3d", health >> 4, "SBarHealthAmount", 8, 183 - 200, 0, 0); + } + if (pPlayer.curWeapon && pPlayer.weaponAmmo != -1) + { + int num = pPlayer.ammoCount[pPlayer.weaponAmmo]; + if (pPlayer.weaponAmmo == 6) + num /= 10; + DrawStatNumber("%3d", num, "SBarWeaponNum", 42, 183 - 200, 0, 0); + } + DrawImage("ArmorBox", (284 - 320, 187 - 200), DI_ITEM_RELCENTER, style:STYLE_Normal, col:0xffc0c0c0, translation:nPalette); + if (pPlayer.armor[1]) + { + TileHGauge("Armor1Gauge", 250 - 320, 175 - 200, pPlayer.armor[1], 3200); + DrawStatNumber("%3d", pPlayer.armor[1] >> 4, "SBarAmmoAmount", 255 - 320, 178 - 200, 0, 0); + } + if (pPlayer.armor[0]) + { + TileHGauge("Armor3Gauge", 250 - 320, 183 - 200, pPlayer.armor[0], 3200); + DrawStatNumber("%3d", pPlayer.armor[0] >> 4, "SBarAmmoAmount", 255 - 320, 186 - 200, 0, 0); + } + if (pPlayer.armor[2]) + { + TileHGauge("Armor2Gauge", 250 - 320, 191 - 200, pPlayer.armor[2], 3200); + DrawStatNumber("%3d", pPlayer.armor[2] >> 4, "SBarAmmoAmount", 255 - 320, 194 - 200, 0, 0); + } + + DrawPackItemInStatusBar(pPlayer, 286 - 320, 186 - 200, 302 - 320, 183 - 200); + + for (int i = 0; i < 6; i++) + { + String nTile = String.Format("KEYICON%d", i + 1); + int x; + int y = -6; + if (i & 1) + { + x = -(78 + (i >> 1) * 10); + } + else + { + x = 73 + (i >> 1) * 10; + } + if (pPlayer.hasKey[i + 1]) + DrawImage(nTile, (x, y), DI_ITEM_RELCENTER, style:STYLE_Normal); + } + return 28; + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + int DrawHUD2(BloodPlayer pPlayer) + { + static const String ammoIcons[] = { "", "AmmoIcon1", "AmmoIcon2", "AmmoIcon3", "AmmoIcon4", "AmmoIcon5", "AmmoIcon6", + "AmmoIcon7", "AmmoIcon8", "AmmoIcon9", "AmmoIcon10", "AmmoIcon11" }; + + static const float ammoScale[] = { 0, 0.5f, 0.8f, 0.7f, 0.5f, 0.7f, 0.5f, 0.3f, 0.3f, 0.6f, 0.5f, 0.45f }; + static const int ammoYoffs[] = { 0, 0, 0, 3, -6, 2, 4, -6, -6, -6, 2, 2 }; + + int health = pPlayer.GetHealth(); + BeginHUD(1, false, 320, 200); + DrawImage("HealthIcon", (12, 195 - 200), DI_ITEM_RELCENTER, scale:(0.56, 0.56)); + DrawStatNumber("%d", health >> 4, "SBarNumberHealth", 28, 187 - 200, 0, 0); + if (pPlayer.armor[1]) + { + DrawImage("Armor1Icon", (70, 186 - 200), DI_ITEM_RELCENTER, scale:(0.5, 0.5)); + DrawStatNumber("%3d", pPlayer.armor[1] >> 4, "SBarNumberArmor2_", 83, 187 - 200, 0, 0, 0.65); + } + if (pPlayer.armor[0]) + { + DrawImage("Armor3Icon", (112, 195 - 200), DI_ITEM_RELCENTER, scale:(0.5, 0.5)); + DrawStatNumber("%3d", pPlayer.armor[0] >> 4, "SBarNumberArmor1_", 125, 187 - 200, 0, 0, 0.65); + } + if (pPlayer.armor[2]) + { + DrawImage("Armor2Icon", (155, 196 - 200), DI_ITEM_RELCENTER, scale:(0.5, 0.5)); + DrawStatNumber("%3d", pPlayer.armor[2] >> 4, "SBarNumberArmor3_", 170, 187 - 200, 0, 0, 0.65); + } + + DrawPackItemInStatusBar2(pPlayer, 216 - 320, 194 - 200, 231 - 320, 187 - 200, 0.7); + + if (pPlayer.curWeapon && pPlayer.weaponAmmo != -1) + { + int num = pPlayer.ammoCount[pPlayer.weaponAmmo]; + if (pPlayer.weaponAmmo == 6) + num /= 10; + if (ammoIcons[pPlayer.weaponAmmo]) + { + let scale = ammoScale[pPlayer.weaponAmmo]; + DrawImage(ammoIcons[pPlayer.weaponAmmo], (304 - 320, -8 + ammoYoffs[pPlayer.weaponAmmo]), DI_ITEM_RELCENTER, scale:(scale, scale)); + } + + bool reloadableWeapon = pPlayer.curWeapon == 3 && !pPlayer.powerupCheck(Blood.kPwUpTwoGuns); + if (!reloadableWeapon || (reloadableWeapon && !cl_showmagamt)) + { + DrawStatNumber("%3d", num, "SBarNumberAmmo", 267 - 320, 187 - 200, 0, 0); + } + else + { + int clip = CalcMagazineAmount(num, 2, pPlayer.weaponState == 1); + int total = num - clip; + String format = String.Format("%d/%d", clip, num - clip); + + DrawCharArray(format, "SBarNumberAmmo", (total < 10 ? 267 : 258) - 320, 187 - 200); + } + } + + for (int i = 0; i < 6; i++) + { + if (pPlayer.hasKey[i + 1]) + { + let tile = String.Format("HUDKEYICON%d", i + 1); + DrawImage(tile, (-60 + 10 * i, 170 - 200), DI_ITEM_RELCENTER, scale:(0.25, 0.25)); + } + } + + BeginStatusBar(false, 320, 200, 28); + if (pPlayer.throwPower) + TileHGauge("ThrowGauge", 124, 175, pPlayer.throwPower, 1); + else + drawInventory(pPlayer, 166, 200 - texHeight("FULLHUD") / 2 - 30); + return 28; + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + override void UpdateStatusBar(SummaryInfo summary) + { + int nPalette = 0; + let pPlayer = Blood.GetViewPlayer(); + int y = 0; + + int nGameType = Blood.getGameType(); + if (nGameType == 3) + { + if (pPlayer.teamId & 1) + nPalette = 7; + else + nPalette = 10; + + nPalette = Translation.MakeID(Translation_Remap, nPalette); + } + + if (hud_size == Hud_full) + { + y = DrawHUD2(pPlayer); + } + else if (hud_size > Hud_Stbar) + { + BeginStatusBar(false, 320, 200, 28); + if (pPlayer.throwPower) + TileHGauge("ThrowGauge", 124, 175, pPlayer.throwPower, 1); + else if (hud_size > Hud_StbarOverlay) + drawInventory(pPlayer, 166, 200 - texHeight("FullHUD") / 2); + } + if (hud_size == Hud_Mini) + { + y = DrawHUD1(pPlayer, nPalette); + } + else if (hud_size <= Hud_StbarOverlay) + { + y = DrawStatusBar(pPlayer, nPalette); + } + DoLevelStats(pPlayer, y, summary); + + // All remaining parts must be done with HUD alignment rules, even when showing a status bar. + BeginHUD(1, false, 320, 200); + drawPowerUps(pPlayer); + + drawMultiHUD(pPlayer, nGameType); + } +} + diff --git a/wadsrc/static/zscript/games/duke/dukegame.zs b/wadsrc/static/zscript/games/duke/dukegame.zs index ef06f96bd..97f49acac 100644 --- a/wadsrc/static/zscript/games/duke/dukegame.zs +++ b/wadsrc/static/zscript/games/duke/dukegame.zs @@ -49,10 +49,26 @@ struct Duke native BASEPALCOUNT }; + enum dukeinvicon_t + { + ICON_NONE, // 0 + ICON_FIRSTAID, + ICON_STEROIDS, + ICON_HOLODUKE, + ICON_JETPACK, + ICON_HEATS, // 5 + ICON_SCUBA, + ICON_BOOTS, + ICON_MAX + }; + native static void PlaySpecialMusic(int which); native static int PlaySound(int num, int channel = CHAN_AUTO, int flags = 0, float vol =0.8f); native static void StopSound(int num); native static bool CheckSoundPlaying(int num); + native static DukePlayer GetViewPlayer(); + native static int MaxPlayerHealth(); + native static int MaxAmmoAmount(int weap); static void PlayBonusMusic() { @@ -111,6 +127,206 @@ struct Duke native } +struct DukePlayer +{ + // The sound code wants to read a vector out of this so we need to define one for the main coordinate. + /* + union + { + vec3_t pos; + struct { int32_t posx, posy, posz; }; + }; + + // player's horizon and angle structs. + PlayerHorizon horizon; + PlayerAngle angle; + + uint16_t frags[MAXPLAYERS]; + */ + + native bool gotweapon[DukeWpn.MAX_WEAPONS]; + + // Palette management uses indices into the engine's palette table now. + native color pals; + + // this was a global variable originally. + //vec2_t fric; + + // weapon drawer variables and their interpolation counterparts. + native int weapon_sway; + native int oweapon_sway; + native int16 weapon_pos, kickback_pic, random_club_frame; + native int16 oweapon_pos, okickback_pic, orandom_club_frame; + native uint8 hard_landing; + native uint8 ohard_landing; + + // Store current psectlotag as determined in processinput() for use with scaling angle aiming. + native int16 psectlotag; + + // From here on it is unaltered from JFDuke with the exception of a few fields that are no longer needed and were removed. + native int exitx, exity, loogiex[64], loogiey[64], numloogs, loogcnt; + native int invdisptime; + native int bobposx, bobposy, oposx, oposy, oposz, pyoff, opyoff; + native int posxv, posyv, poszv, last_pissed_time, truefz, truecz; + native int player_par, visibility; + native int bobcounter; + native int randomflamex, crack_time; + + native int aim_mode, ftt; + + native int16 cursectnum, last_extra, subweapon; + native int16 ammo_amount[DukeWpn.MAX_WEAPONS], frag, fraggedself; + + native int16 curr_weapon, last_weapon, tipincs, wantweaponfire; + native int16 holoduke_amount, hurt_delay, hbomb_hold_delay; + native int16 jumping_counter, airleft, knee_incs, access_incs; + native int16 ftq, access_wallnum; + native int16 got_access, weapon_ang, firstaid_amount; + native int16 i, one_parallax_sectnum; + native int16 over_shoulder_on, fist_incs; + native int16 cheat_phase; + native int16 extra_extra8, quick_kick, last_quick_kick; + native int16 heat_amount, timebeforeexit, customexitsound; + //DDukeActor* actorsqu, *wackedbyactor, *on_crane, *holoduke_on, *somethingonplayer, *access_spritenum, *dummyplayersprite, *newOwner; // later + native voidptr holoduke_on; // cannot do it as a proper actor pointer - but the status bar needs it. + + native int16 weaprecs[256], weapreccnt; + native uint interface_toggle_flag; + + native int16 dead_flag, show_empty_weapon; // JBF 20031220: added orotscrnang + native int16 scuba_amount, jetpack_amount, steroids_amount, shield_amount; + native int16 pycount, frag_ps; + native int16 transporter_hold, last_full_weapon, footprintshade, boot_amount; + + native uint8 on_warping_sector, footprintcount; + native uint8 hbomb_on, jumping_toggle, rapid_fire_hold, on_ground; + //char name[32]; + native uint8 inven_icon, buttonpalette; + + native uint8 jetpack_on, spritebridge, lastrandomspot; + native uint8 scuba_on, footprintpal, heat_on; + + native uint8 holster_weapon; + native uint8 falling_counter; + native uint8 refresh_inventory; + + native uint8 toggle_key_flag, knuckle_incs; // ,select_dir; + native uint8 walking_snd_toggle, palookup; + native bool quick_kick_msg; + + native int max_secret_rooms, secret_rooms, max_actors_killed, actors_killed; + + native bool resurrected; + + // Redneck Rampage additions. Those which did not have names in the reconstructed source got one from either RedneckGDX or RedNukem. + // Items were reordered by size. + native int stairs; + native int detonate_count; // at57e + native int noise_x, noise_y, noise_radius; // at286, at28a, at290 + native int drink_timer; // at58e + native int eat_timer; // at592 + native int SlotWin; + native int16 recoil; + native int16 detonate_time; // at57c + native int16 yehaa_timer; + native int16 drink_amt, eat, drunkang, eatang; + native uint8 shotgun_state[2]; + native uint8 donoise; // at28e + native uint8 keys[5]; + + // RRRA. The same as for the RR block applies. + native int drug_aspect; + native int drug_timer; + native int SeaSick; + native int16 MamaEnd; // raat609 + native int16 moto_drink; + native float TiltStatus, oTiltStatus; + native int16 VBumpNow, VBumpTarget, TurbCount; + native int16 drug_stat[3]; // raat5f1..5 + native uint8 DrugMode, lotag800kill; + native uint8 sea_sick_stat; // raat5dd + native uint8 hurt_delay2, nocheat; + native uint8 OnMotorcycle, OnBoat, moto_underwater, NotOnWater, MotoOnGround; + native uint8 moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud; + native double vehForwardScale, vehReverseScale, MotoSpeed; + native bool vehTurnLeft, vehTurnRight, vehBraking; + + // input stuff. + //InputPacket sync; + + /* + DDukeActor* GetActor(); + int GetPlayerNum(); + + void apply_seasick(double factor); + void backuppos(bool noclipping = false); + void backupweapon(); + void checkhardlanding(); + void playerweaponsway(int xvel); + + float adjustavel(float avel) + { + return (psectlotag == ST_2_UNDERWATER)? avel * 0.875f : avel; + } + */ + + native bool IsFrozen(); + native int GetGameVar(String varname, int defval); + + +} + +struct DukeWpn +{ + enum dukeweapon_t + { + KNEE_WEAPON, // 0 + PISTOL_WEAPON, + SHOTGUN_WEAPON, + CHAINGUN_WEAPON, + RPG_WEAPON, + HANDBOMB_WEAPON, // 5 + SHRINKER_WEAPON, + DEVISTATOR_WEAPON, + TRIPBOMB_WEAPON, + FREEZE_WEAPON, + HANDREMOTE_WEAPON, // 10 + GROW_WEAPON, + FLAMETHROWER_WEAPON, // World Tour + + MIN_WEAPON = 0, + MAX_WEAPON = 9, + MAX_WEAPONS = 17 + } +} + +struct RRWpn +{ + enum redneck_weapon_t + { + // These names have been pieced together from RedneckGDX and RedNukem because the reconstructed source recycled Duke's names for the first 11 weapons. + // Names for 0-2 are the same + KNEE_WEAPON, // 0 + PISTOL_WEAPON, + SHOTGUN_WEAPON, + RIFLEGUN_WEAPON, + DYNAMITE_WEAPON, + CROSSBOW_WEAPON, // 5 + THROWSAW_WEAPON, + ALIENBLASTER_WEAPON, + POWDERKEG_WEAPON, + TIT_WEAPON, + THROWINGDYNAMITE_WEAPON, // 10 + BUZZSAW_WEAPON, + BOWLING_WEAPON, + MOTORCYCLE_WEAPON, + BOAT_WEAPON, + SLINGBLADE_WEAPON, // 15 + CHICKEN_WEAPON, + MAX_WEAPONS + } +} + struct DukeSnd native { // This really needs to be done better... diff --git a/wadsrc/static/zscript/games/duke/ui/sbar.zs b/wadsrc/static/zscript/games/duke/ui/sbar.zs new file mode 100644 index 000000000..c8434bf50 --- /dev/null +++ b/wadsrc/static/zscript/games/duke/ui/sbar.zs @@ -0,0 +1,220 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) +Copyright (C) 2020-2021 - Christoph Oelckers + +This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms + +EDuke enhancements integrated: 04/13/2003 - Matt Saettler + +Note: EDuke source was in transition. Changes are in-progress in the +source as it is released. + +*/ +//------------------------------------------------------------------------- + + +class DukeCommonStatusBar : RazeStatusBar +{ + + HUDFont numberFont; + HUDFont miniFont; + HUDFont digiFont; + double scale; + Array ammo_sprites; + Array item_icons; + + int tileHeight(String tex) + { + let img = TexMan.CheckForTexture(tex, TexMan.TYPE_Any); + let siz = TexMan.GetScaledSize(img); + return int(siz.Y); + } + + //========================================================================== + // + // Frag bar - todo + // + //========================================================================== + /* + void displayfragbar(void) + { + short i, j; + + j = 0; + + for (i = connecthead; i >= 0; i = connectpoint2[i]) + if (i > j) j = i; + + auto tex = tileGetTexture(TILE_FRAGBAR); + for (int y = 0; y < 32; y += 8) + DrawTexture(twod, tex, 0, 0, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, 1.001, DTA_ScaleY, 1.001, TAG_Done); + + for (i = connecthead; i >= 0; i = connectpoint2[i]) + { + m initext(21 + (73 * (i & 3)), 2 + ((i & 28) << 1), &ud.user_name[i][0], ps[i].GetActor().s.pal, 2 + 8 + 16 + 128); + sprintf(tempbuf, "%d", ps[i].frag - ps[i].fraggedself); + m initext(17 + 50 + (73 * (i & 3)), 2 + ((i & 28) << 1), tempbuf, ps[i].GetActor().s.pal, 2 + 8 + 16 + 128); + } + } + */ + //========================================================================== + // + // Common inventory icon code for all styles + // + //========================================================================== + + String, int ontext(DukePlayer p) + { + String first = ""; + int second = 6; + + int onstate = 0x80000000; + switch (p.inven_icon) + { + case Duke.ICON_HOLODUKE: + onstate = p.holoduke_on != null; + break; + case Duke.ICON_JETPACK: + onstate = p.jetpack_on; + break; + case Duke.ICON_HEATS: + onstate = p.heat_on; + break; + } + + // Texts are intentionally not translated because the font is too small for making localization work and the translated words are too long. + if (onstate != 0x80000000 && !(gameinfo.gameType & (GAMEFLAG_WW2GI|GAMEFLAG_RRALL))) + { + second = onstate > 0 ? 0 : 2; + first = onstate > 0 ? "ON" : "OFF"; + } + if (p.inven_icon >= Duke.ICON_SCUBA) + { + second = 2; + first = "AUTO"; + } + return first, second; + } + + //========================================================================== + // + // draws the inventory selector + // + //========================================================================== + + void DrawInventory(DukePlayer p, double x, double y, int align) + { + if (p.invdisptime <= 0)return; + + int n = 0, j = 0; + if (p.firstaid_amount > 0) { n |= 1; j++; } + if (p.steroids_amount > 0) { n |= 2; j++; } + if (p.holoduke_amount > 0) { n |= 4; j++; } + if (p.jetpack_amount > 0) { n |= 8; j++; } + if (p.heat_amount > 0) { n |= 16; j++; } + if (p.scuba_amount > 0) { n |= 32; j++; } + if (p.boot_amount > 0) { n |= 64; j++; } + + x -= (j * 11); + y -= 6; + + align |= DI_ITEM_CENTER; + for(int bit = 0; bit < 7; bit++) + { + int i = 1 << bit; + if (n & i) + { + int select = 1 << (p.inven_icon - 1); + double alpha = select == i ? 1.0 : 0.7; + DrawImage(item_icons[bit+1], (x, y), align, alpha, scale:(scale, scale)); + if (select == i) DrawImage("ARROW", (Raze.isWW2GI()? x + 7.5 : x, Raze.isWW2GI()? y + 0.5 : y), align, alpha, scale:(scale, scale)); + x += 22; + } + } + } + + //========================================================================== + // + // Statistics output + // + //========================================================================== + + void DoLevelStats(int bottomy, SummaryInfo info) + { + StatsPrintInfo stats; + stats.fontscale = Raze.isRR() ? 0.5 : 1.; + stats.screenbottomspace = bottomy; + stats.statfont = SmallFont; + if (Raze.isNamWW2GI()) + { + // The stock font of these games is totally unusable for this. + stats.statfont = ConFont; + stats.spacing = ConFont.GetHeight() + 1; + } + + if (automapMode == am_full) + { + bool textfont = am_textfont; + if (!am_textfont) + { + // For non-English languages force use of the text font. The tiny one is simply too small to ever add localized characters to it. + let p = StringTable.Localize("$REQUIRED_CHARACTERS"); + if (p.length() > 0) textfont = true; + } + + if (!textfont) + { + stats.statfont = SmallFont2; + stats.spacing = 6; + } + else stats.spacing = stats.statfont.GetHeight() + 1; + stats.standardColor = (Raze.isNamWW2GI() && am_textfont)? Font.TEXTCOLOR_ORANGE : Font.TEXTCOLOR_UNTRANSLATED; + stats.letterColor = Font.TEXTCOLOR_GOLD; + PrintAutomapInfo(stats, textfont); + } + else if (hud_stats) + { + stats.letterColor = Font.TEXTCOLOR_ORANGE; + if (Raze.isNamWW2GI()) + { + stats.spacing = 8; + stats.standardColor = Font.TEXTCOLOR_YELLOW; + stats.completeColor = Font.TEXTCOLOR_FIRE; + } + else if (!Raze.isRR()) + { + stats.spacing = 7; + stats.standardColor = Font.TEXTCOLOR_CREAM; + stats.completeColor = Font.TEXTCOLOR_FIRE; + } + else + { + stats.spacing = 10; + stats.standardColor = + stats.completeColor = Font.TEXTCOLOR_UNTRANSLATED; + } + PrintLevelStats(stats, info); + } + } + +} \ No newline at end of file diff --git a/wadsrc/static/zscript/games/duke/ui/sbar_d.zs b/wadsrc/static/zscript/games/duke/ui/sbar_d.zs new file mode 100644 index 000000000..5cb3bc9ee --- /dev/null +++ b/wadsrc/static/zscript/games/duke/ui/sbar_d.zs @@ -0,0 +1,479 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) +Copyright (C) 2020 - Christoph Oelckers + +This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms + +EDuke enhancements integrated: 04/13/2003 - Matt Saettler + +Note: EDuke source was in transition. Changes are in-progress in the +source as it is released. + +*/ +//------------------------------------------------------------------------- + + +class DukeStatusBar : DukeCommonStatusBar +{ + int fontheight[2]; + TextureID ThreeByFive[12]; + HUDFont indxfont; + + override void Init() + { + numberFont = HUDFont.Create(BigFont, 0, Mono_Off, 1, 1 ); + indxfont = HUDFont.Create(Font.FindFont("IndexFont"), 4, Mono_CellRight, 1, 1 ); + miniFont = HUDFont.Create(SmallFont2, 0, Mono_Off, 1, 1 ); + digiFont = HUDFont.Create(Font.FindFont("DigiFont"), 1, Mono_Off, 1, 1 ); + + // optionally draw at the top of the screen. + SetSize(tileHeight("BOTTOMSTATUSBAR"), 320, 200); + scale = 1; + + ammo_sprites.PushV("", "AMMO", "SHOTGUNAMMO", "BATTERYAMMO", "RPGAMMO", "HBOMBAMMO", "CRYSTALAMMO", "DEVISTATORAMMO", "TRIPBOMBSPRITE", "FREEZEAMMO1", "HBOMBAMMO", "GROWAMMO", "FLAMETHROWERAMMO1" ); + item_icons.PushV("", "FIRSTAID_ICON", "STEROIDS_ICON", "HOLODUKE_ICON", "JETPACK_ICON", "HEAT_ICON", "AIRTANK_ICON", "BOOT_ICON" ); + + // get the true size of the font. + fontheight[1] = fontheight[0] = 0; + for (int i = 0; i <= 9; i++) + { + let name = String.Format("BIGALPHANUM%d", i); + let zerotex = TexMan.CheckForTexture(name, TexMan.Type_Any); + if (zerotex.IsValid()) + { + int fh0 = TexMan.CheckRealHeight(zerotex); + int fh1 = fh0; + let hitex = Raze.PickTexture(zerotex); + if (hitex.IsValid()) + { + let osize = TexMan.GetScaledSize(zerotex); + let dsize = TexMan.GetScaledSize(hitex); + int dReal = TexMan.CheckRealHeight(hitex); + fh1 = int(dReal * osize.Y / dsize.Y); + } + if (fh0 > fontheight[0]) fontheight[0] = fh0; + if (fh1 > fontheight[1]) fontheight[1] = fh1; + } + } + for (int i = 0; i <= 11; i++) + { + let str = String.Format("THREEBYFIVE%d", i); + ThreeByFive[i] = TexMan.CheckForTexture(str, TexMan.Type_Any); + } + } + + //========================================================================== + // + // Helpers + // + //========================================================================== + + int getinvamount(DukePlayer p) + { + switch (p.inven_icon) + { + case Duke.ICON_FIRSTAID: + return p.firstaid_amount; + case Duke.ICON_STEROIDS: + return (p.steroids_amount + 3) >> 2; + case Duke.ICON_HOLODUKE: + return (p.holoduke_amount + 15) / 24; + case Duke.ICON_JETPACK: + return (p.jetpack_amount + 15) >> 4; + case Duke.ICON_HEATS: + return p.heat_amount / 12; + case Duke.ICON_SCUBA: + return (p.scuba_amount + 63) >> 6; + case Duke.ICON_BOOTS: + return p.boot_amount >> 1; + } + + return -1; + } + + int GetMoraleOrShield(DukePlayer p) + { + // special handling for WW2GI + int lAmount = p.GetGameVar("PLR_MORALE", -1); + if (lAmount == -1) lAmount = p.shield_amount; + return lAmount; + } + + + //========================================================================== + // + // Fullscreen HUD variant #1 + // + //========================================================================== + + void FullscreenHUD1(DukePlayer p) + { + int fh = fontheight[hw_hightile ? 1 : 0]; + String format; + TextureID img; + double imgScale; + double baseScale = (scale * (fh+1)); + double texty = -fh - 2.5; + + // + // Health + // + img = TexMan.CheckForTexture(Raze.isNamWW2GI()? "FIRSTAID_ICON" : "COLA"); + let siz = TexMan.GetScaledSize(img); + imgScale = baseScale / siz.Y; + DrawTexture(img, (2, -1.5), DI_ITEM_LEFT_BOTTOM, scale:(imgScale, imgScale)); + + if (!hud_flashing || p.last_extra > (Duke.MaxPlayerHealth() >> 2) || (PlayClock & 32) || (p.IsFrozen() && p.last_extra < 2)) + { + int s = -8; + if (hud_flashing && p.last_extra > Duke.MaxPlayerHealth()) + s += Raze.bsin(Raze.GetBuildTime() << 5) / 768; + int intens = clamp(255 - 6 * s, 0, 255); + format = String.Format("%d", p.last_extra); + DrawString(numberFont, format, (25, texty), DI_TEXT_ALIGN_LEFT, Font.CR_UNTRANSLATED, intens / 255., 0, 0); + } + + // + // Armor + // + img = TexMan.CheckForTexture("SHIELD"); + siz = TexMan.GetScaledSize(img); + imgScale = baseScale / siz.Y; + DrawTexture(img, (67.375, -1.5), DI_ITEM_LEFT_BOTTOM, scale:(imgScale, imgScale)); + + format = String.Format("%d", GetMoraleOrShield(p)); + DrawString(numberFont, format, (85, texty), DI_TEXT_ALIGN_LEFT, Font.CR_UNTRANSLATED, 1, 0, 0); + + // + // Weapon + // + int weapon = p.curr_weapon; + if (weapon == DukeWpn.HANDREMOTE_WEAPON) weapon = DukeWpn.HANDBOMB_WEAPON; + + let wicon = ammo_sprites[weapon]; + if (wicon.length() > 0) + { + int ammo = p.ammo_amount[weapon]; + if (weapon != DukeWpn.PISTOL_WEAPON || (weapon == DukeWpn.PISTOL_WEAPON && !cl_showmagamt)) + { + format = String.Format("%d", ammo); + } + else + { + int clip = CalcMagazineAmount(ammo, Raze.isNam() ? 20 : 12, p.kickback_pic >= 1); + format = String.Format("%d/%d", clip, ammo - clip); + } + img = TexMan.CheckForTexture(wicon, TexMan.TYPE_Any); + siz = TexMan.GetScaledSize(img); + imgScale = baseScale / siz.Y; + let imgX = 20.; + let strlen = format.length(); + + if (strlen > 1) + { + imgX += (imgX * 0.6) * (strlen - 1); + } + + if (weapon != DukeWpn.KNEE_WEAPON && (!hud_flashing || PlayClock & 32 || ammo > (Duke.MaxAmmoAmount(weapon) / 10))) + { + DrawString(numberFont, format, (-3, texty), DI_TEXT_ALIGN_RIGHT, Font.CR_UNTRANSLATED); + } + + DrawTexture(img, (-imgX, -1.5), DI_ITEM_RIGHT_BOTTOM, scale:(imgScale, imgScale)); + } + + // + // Selected inventory item + // + uint icon = p.inven_icon; + if (icon > 0) + { + int x = 128; + + if (icon < Duke.ICON_MAX) + { + img = TexMan.CheckForTexture(item_icons[icon], TexMan.TYPE_Any); + siz = TexMan.GetScaledSize(img); + imgScale = baseScale / siz.Y; + DrawTexture(img, (x, -1.5), DI_ITEM_LEFT_BOTTOM, scale:(imgScale, imgScale)); + } + + int percentv = getinvamount(p); + format = String.Format("%3d%%", percentv); + int color = percentv > 50 ? 11 : percentv > 25 ? 23 : 2; + DrawString(miniFont, format, (x + 36.5, -indxfont.mFont.GetHeight() + 0.5), DI_TEXT_ALIGN_RIGHT, pt:Translation.MakeID(Translation_Remap, color)); + + String text; + int pal; + [text, pal] = ontext(p); + if (text.length() > 0) DrawString(miniFont, text, (x + 36.5, -miniFont.mFont.GetHeight() - 9.5), DI_TEXT_ALIGN_RIGHT, pt:Translation.MakeID(Translation_Remap, pal)); + } + + // + // keys + // + if (p.got_access & 1) DrawImage("ACCESSCARD", (-12, -23.5), DI_ITEM_RIGHT, 1, (-1, -1), (0.5, 0.5), STYLE_Translucent, 0xffffffff, Translation.MakeID(Translation_Remap, 0)); + if (p.got_access & 4) DrawImage("ACCESSCARD", (-7 , -21.5), DI_ITEM_RIGHT, 1, (-1, -1), (0.5, 0.5), STYLE_Translucent, 0xffffffff, Translation.MakeID(Translation_Remap, 23)); + if (p.got_access & 2) DrawImage("ACCESSCARD", (-2 , -19.5), DI_ITEM_RIGHT, 1, (-1, -1), (0.5, 0.5), STYLE_Translucent, 0xffffffff, Translation.MakeID(Translation_Remap, 21)); + } + + + //========================================================================== + // + // Fullscreen HUD variant #2 + // + //========================================================================== + + void FullscreenHUD2(DukePlayer p) + { + // + // health + // + DrawImage("HEALTHBOX", (5, -2), DI_ITEM_LEFT_BOTTOM, scale:(scale, scale)); + int health = p.IsFrozen() ? 1 : p.last_extra; + String format = String.Format("%d", health); + DrawString(digiFont, format, (20, -digiFont.mFont.GetHeight() * scale - 3), DI_TEXT_ALIGN_CENTER, Font.CR_UNTRANSLATED, scale:(scale, scale)); + + // + // ammo + // + DrawImage("AMMOBOX", (37, -2), DI_ITEM_LEFT_BOTTOM, scale:(scale, scale)); + int wp = (p.curr_weapon == DukeWpn.HANDREMOTE_WEAPON) ? DukeWpn.HANDBOMB_WEAPON : p.curr_weapon; + format = String.Format("%d", p.ammo_amount[wp]); + DrawString(digiFont, format, (52, -digiFont.mFont.GetHeight() * scale - 3), DI_TEXT_ALIGN_CENTER, Font.CR_UNTRANSLATED, scale:(scale, scale)); + + // + // inventory + // + uint icon = p.inven_icon; + if (icon > 0) + { + int x = 73; + DrawImage("INVENTORYBOX", (69, -2), DI_ITEM_LEFT_BOTTOM, scale:(scale, scale)); + if (icon < Duke.ICON_MAX) + DrawImage(item_icons[icon], (x, -13.5), DI_ITEM_LEFT|DI_ITEM_VCENTER, scale:(scale, scale)); + + int percentv = getinvamount(p); + format = String.Format("%3d%%", percentv); + int color = percentv > 50 ? 11 : percentv > 25 ? 23 : 2; + DrawString(miniFont, format, (x + 34, -indxfont.mFont.GetHeight() - 3), DI_TEXT_ALIGN_RIGHT, pt:Translation.MakeID(Translation_Remap, color)); + + String text; + int pal; + [text, pal] = ontext(p); + if (text.length() > 0) DrawString(miniFont, text, (x + 34, -miniFont.mFont.GetHeight() - 14), DI_TEXT_ALIGN_RIGHT, pt:Translation.MakeID(Translation_Remap, pal)); + } + } + + //========================================================================== + // + // Fullscreen HUD drawer + // + //========================================================================== + + void DrawHud(DukePlayer p, int style, SummaryInfo info) + { + BeginHUD(1, false, 320, 200); + if (style == 1) + { + DrawInventory(p, 0, -46, DI_SCREEN_CENTER_BOTTOM); + FullscreenHUD1(p); + DoLevelStats(tileHeight("BIGALPHANUM") +10, info); + } + else if (style == 2) + { + DrawInventory(p, netgame ? 56 : 65, -28, DI_SCREEN_CENTER_BOTTOM); + FullscreenHUD2(p); + DoLevelStats(tileHeight("HEALTHBOX") + 4, info); + } + else + { + DrawInventory(p, 0, -28, DI_SCREEN_CENTER_BOTTOM); + DoLevelStats(2, info); + } + } + + + //========================================================================== + // + // Helper for weapon display + // + //========================================================================== + + void DrawWeaponNum(int index, double x, double y, int num1, int num2, int shade, int numdigits) + { + /* + if (isShareware() && (ind > DukeWpn.HANDBOMB_WEAPON || ind < 0)) + { + minitextshade(x + 1, y - 4, "ORDER", 20, 11, 2 + 8 + 16 + ROTATESPRITE_MAX); + return; + } + */ + String format; + bool parsedDivisor = false; + + if (numdigits == 2) + { + if (num1 > 99) num1 = 99; + if (num2 > 99) num2 = 99; + format = String.Format("%2d/%d", num1, num2); + } + else + { + if (num1 > 999) num1 = 999; + if (num2 > 999) num2 = 999; + format = String.Format("%3d/%d", num1, num2); + } + y--; + DrawTexture(ThreeByFive[index], (x - 7, y), DI_ITEM_LEFT|DI_ITEM_VCENTER, 1, (-1, -1), (1, 1), STYLE_Translucent, Raze.ShadeToLight(shade - 10), Translation.MakeID(Translation_Remap, 7)); + let pe = Raze.ShadeToLight(shade); + DrawTexture(ThreeByFive[10], (x - 3, y), DI_ITEM_LEFT | DI_ITEM_VCENTER, 1, (-1, -1), (1, 1), STYLE_Translucent, pe); + for (int i = 0; i < format.Length(); i++) + { + int cc = format.ByteAt(i); + if (cc != " ") + { + int c = cc == "/" ? 11 : cc - int("0"); + DrawTexture(ThreeByFive[c], (x + 4 * i + (parsedDivisor ? 1 : 0), y), DI_ITEM_LEFT | DI_ITEM_VCENTER, col:pe); + } + if (cc == "/") + { + parsedDivisor = true; + } + } + } + + //========================================================================== + // + // Weapon display (Duke only) + // + //========================================================================== + + int ShadeForWeapon(DukePlayer p, int weapon, int optweapon = -1) + { + // Headache-inducing math at play here. + return (((!p.ammo_amount[weapon]) | (!p.gotweapon[weapon])) * 9) + 12 - 18 * ((p.curr_weapon == weapon) || (optweapon != -1 && p.curr_weapon == optweapon)); + } + + + void DrawWeaponAmounts(DukePlayer p, double x, double y) + { + int cw = p.curr_weapon; + + DrawWeaponNum(2, x, y, p.ammo_amount[DukeWpn.PISTOL_WEAPON], Duke.MaxAmmoAmount(DukeWpn.PISTOL_WEAPON), 12 - 20 * (cw == DukeWpn.PISTOL_WEAPON), 3); + DrawWeaponNum(3, x, y + 6, p.ammo_amount[DukeWpn.SHOTGUN_WEAPON], Duke.MaxAmmoAmount(DukeWpn.SHOTGUN_WEAPON), ShadeForWeapon(p, DukeWpn.SHOTGUN_WEAPON), 3); + DrawWeaponNum(4, x, y + 12, p.ammo_amount[DukeWpn.CHAINGUN_WEAPON], Duke.MaxAmmoAmount(DukeWpn.CHAINGUN_WEAPON), ShadeForWeapon(p, DukeWpn.CHAINGUN_WEAPON), 3); + DrawWeaponNum(5, x + 39, y, p.ammo_amount[DukeWpn.RPG_WEAPON], Duke.MaxAmmoAmount(DukeWpn.RPG_WEAPON), ShadeForWeapon(p, DukeWpn.RPG_WEAPON), 2); + DrawWeaponNum(6, x + 39, y + 6, p.ammo_amount[DukeWpn.HANDBOMB_WEAPON], Duke.MaxAmmoAmount(DukeWpn.HANDBOMB_WEAPON), ShadeForWeapon(p, DukeWpn.HANDBOMB_WEAPON, DukeWpn.HANDREMOTE_WEAPON), 2); + if (p.subweapon & (1 << DukeWpn.GROW_WEAPON)) // original code says: if(!p.ammo_amount[SHRINKER_WEAPON] || cw == GROW_WEAPON) + DrawWeaponNum(7, x + 39, y + 12, p.ammo_amount[DukeWpn.GROW_WEAPON], Duke.MaxAmmoAmount(DukeWpn.GROW_WEAPON), ShadeForWeapon(p, DukeWpn.GROW_WEAPON), 2); + else + DrawWeaponNum(7, x + 39, y + 12, p.ammo_amount[DukeWpn.SHRINKER_WEAPON], Duke.MaxAmmoAmount(DukeWpn.SHRINKER_WEAPON), ShadeForWeapon(p, DukeWpn.SHRINKER_WEAPON), 2); + DrawWeaponNum(8, x + 70, y, p.ammo_amount[DukeWpn.DEVISTATOR_WEAPON], Duke.MaxAmmoAmount(DukeWpn.DEVISTATOR_WEAPON), ShadeForWeapon(p, DukeWpn.DEVISTATOR_WEAPON), 2); + DrawWeaponNum(9, x + 70, y + 6, p.ammo_amount[DukeWpn.TRIPBOMB_WEAPON], Duke.MaxAmmoAmount(DukeWpn.TRIPBOMB_WEAPON), ShadeForWeapon(p, DukeWpn.TRIPBOMB_WEAPON), 2); + DrawWeaponNum(0, x + 70, y + 12, p.ammo_amount[DukeWpn.FREEZE_WEAPON], Duke.MaxAmmoAmount(DukeWpn.FREEZE_WEAPON), ShadeForWeapon(p, DukeWpn.FREEZE_WEAPON), 2); + } + + //========================================================================== + // + // Status bar drawer + // + //========================================================================== + + void Statusbar(DukePlayer p) + { + let bsb = TexMan.CheckForTexture("BOTTOMSTATUSBAR", Texman.Type_Any); + let siz = TexMan.GetScaledSize(bsb); + int h = int(siz.Y); + int top = 200 - h; + int left = (320 - int(siz.X)) / 2; + BeginStatusBar(false, 320, 200, h); + DrawInventory(p, 160, 154, 0); + if (hud_size == Hud_StbarOverlay) Set43ClipRect(); + DrawTexture(bsb, (left, top), DI_ITEM_LEFT_TOP, 1); + screen.ClearClipRect(); + + String format; + + /* + if (ud.multimode > 1 && !ud.coop) + { + DrawTexture("KILLSICON", (228, top + 8), DI_ITEM_OFFSETS, 1, 0, 0); + format = String.Format("%d", max(p.frag - p.fraggedself, 0)); + DrawString(digiFont, format, (287, top + 17), DI_TEXT_ALIGN_CENTER); + } + else*/ + { + let key = TexMan.CheckForTexture("ACCESS_ICON", TexMan.Type_Any); + if (p.got_access & 4) DrawTexture(key, (275.5, top + 16), DI_ITEM_OFFSETS, style:STYLE_Translucent, translation:Translation.MakeID(Translation_Remap, 23)); + if (p.got_access & 2) DrawTexture(key, (288.5, top + 16), DI_ITEM_OFFSETS, style:STYLE_Translucent, translation:Translation.MakeID(Translation_Remap, 21)); + if (p.got_access & 1) DrawTexture(key, (282, top + 23), DI_ITEM_OFFSETS, style:STYLE_Translucent, translation:Translation.MakeID(Translation_Remap, 0)); + } + DrawWeaponAmounts(p, 96, top + 15.5); + + int num = (p.IsFrozen()) ? 1 : p.last_extra; + format = String.Format("%d", num); + DrawString(digiFont, format, (31, top + 17), DI_TEXT_ALIGN_CENTER); + format = String.Format("%d", GetMoraleOrShield(p)); + DrawString(digiFont, format, (63, top + 17), DI_TEXT_ALIGN_CENTER); + + if (p.curr_weapon != DukeWpn.KNEE_WEAPON) + { + int wep = (p.curr_weapon == DukeWpn.HANDREMOTE_WEAPON)? DukeWpn.HANDBOMB_WEAPON : p.curr_weapon; + format = String.Format("%d", p.ammo_amount[wep]); + DrawString(digiFont, format, (207, top + 17), DI_TEXT_ALIGN_CENTER); + } + + int icon = p.inven_icon; + if (icon) + { + int x = 232; + if (icon < Duke.ICON_MAX) + DrawImage(item_icons[icon], (x, top + 20.5), DI_ITEM_LEFT | DI_ITEM_VCENTER); + + int percentv = getinvamount(p); + format = String.Format("%3d%%", percentv); + int color = percentv > 50 ? 11 : percentv > 25 ? 23 : 2; + DrawString(miniFont, format, (x + 34, top + 24), DI_TEXT_ALIGN_RIGHT, Font.CR_UNDEFINED, 1, 0, 0, (1, 1), Translation.MakeID(Translation_Remap, color)); + + String text; + int pal; + [text, pal] = ontext(p); + if (text.length() > 0) DrawString(miniFont, text, (x + 34, top + 14), DI_TEXT_ALIGN_RIGHT, Font.CR_UNDEFINED, 1, 0, 0, (1, 1), Translation.MakeID(Translation_Remap, pal)); + } + } + + override void UpdateStatusBar(SummaryInfo info) + { + let p = Duke.GetViewPlayer(); + if (hud_size >= Hud_Mini) + { + DrawHud(p, hud_size == Hud_Nothing ? 0 : hud_size == Hud_full ? 1 : 2, info); + } + else + { + Statusbar(p); + DoLevelStats(-1, info); + } + } +} diff --git a/wadsrc/static/zscript/games/duke/ui/sbar_r.zs b/wadsrc/static/zscript/games/duke/ui/sbar_r.zs new file mode 100644 index 000000000..67c446997 --- /dev/null +++ b/wadsrc/static/zscript/games/duke/ui/sbar_r.zs @@ -0,0 +1,448 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2020 - Christoph Oelckers + +This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms + +*/ +//------------------------------------------------------------------------- + + +class RedneckStatusBar : DukeCommonStatusBar +{ + override void Init() + { + numberFont = HudFont.Create(BigFont, 0, Mono_Off, 1, 1 ); + miniFont = HudFont.Create(SmallFont2, 0, Mono_Off, 1, 1 ); + digiFont = HudFont.Create(Font.FindFont("DigiFont"), 2, Mono_Off, 1, 1 ); + + // optionally draw at the top of the screen. + SetSize(tileHeight("BOTTOMSTATUSBAR"), 320, 200); + scale = 0.5; + + ammo_sprites.PushV("", "AMMO", "SHOTGUNAMMO", "BATTERYAMMO", "HBOMBAMMO", "HBOMBAMMO", "SAWAMMO", "DEVISTATORAMMO", + "TRIPBOMBSPRITE", "GROWSPRITEICON", "HBOMBAMMO", "", "BOWLINGBALLSPRITE", "MOTOAMMO", "BOATAMMO", "", "RPG2SPRITE"); + item_icons.PushV("", "FIRSTAID_ICON", "STEROIDS_ICON", "HOLODUKE_ICON", "JETPACK_ICON", "HEAT_ICON", "AIRTANK_ICON", "BOOT_ICON" ); + } + + + int getinvamount(DukePlayer p) + { + switch (p.inven_icon) + { + case Duke.ICON_FIRSTAID: + return p.firstaid_amount; + case Duke.ICON_STEROIDS: + return (p.steroids_amount + 3) >> 2; + case Duke.ICON_HOLODUKE: + return (p.holoduke_amount) / 400; + case Duke.ICON_JETPACK: + return (p.jetpack_amount) / 100; + case Duke.ICON_HEATS: + return p.heat_amount / 12; + case Duke.ICON_SCUBA: + return (p.scuba_amount + 63) >> 6; + case Duke.ICON_BOOTS: + return (p.boot_amount / 10) >> 1; + } + + return -1; + } + + + //========================================================================== + // + // Fullscreen HUD variant #1 for RR + // + //========================================================================== + + void FullscreenHUD1(DukePlayer p) + { + String format; + TextureID img; + double imgScale; + double baseScale = (scale * numberFont.mFont.GetHeight()) * 0.76; + + // + // Health + // + img = TexMan.CheckForTexture("SPINNINGNUKEICON1"); + let siz = TexMan.GetScaledSize(img); + imgScale = baseScale / siz.Y; + DrawTexture(img, (2, -2), DI_ITEM_LEFT_BOTTOM, scale:(imgScale, imgScale)); + + if (!hud_flashing || p.last_extra > (Duke.MaxPlayerHealth() >> 2) || (PlayClock & 32) || (p.IsFrozen() && p.last_extra < 2)) + { + int s = -8; + if (hud_flashing && p.last_extra > Duke.MaxPlayerHealth()) + s += Raze.bsin(Raze.GetBuildTime() << 5) / 768; + int intens = clamp(255 - 6 * s, 0, 255); + format = String.Format("%d", p.last_extra); + DrawString(numberFont, format, (26.5, -numberFont.mFont.GetHeight() * scale + 4), DI_TEXT_ALIGN_LEFT, Font.CR_UNTRANSLATED, intens / 255., 0, 0, (scale, scale)); + } + + // + // drink + // + img = TexMan.CheckForTexture("BEER"); + siz = TexMan.GetScaledSize(img); + imgScale = baseScale / siz.Y; + DrawTexture(img, (74, -2), DI_ITEM_LEFT_BOTTOM, scale:(imgScale, imgScale)); + format = String.Format("%d", p.drink_amt); + DrawString(numberFont, format, (86, -numberFont.mFont.GetHeight() * scale + 4), DI_TEXT_ALIGN_LEFT, scale:(scale, scale)); + + // + // eat + // + img = TexMan.CheckForTexture("COWPIE"); + siz = TexMan.GetScaledSize(img); + imgScale = baseScale / siz.Y; + DrawTexture(img, (133.5, -2), DI_ITEM_LEFT_BOTTOM, scale:(imgScale, imgScale)); + format = String.Format("%d", p.eat); + DrawString(numberFont, format, (173, -numberFont.mFont.GetHeight() * scale + 4), DI_TEXT_ALIGN_LEFT, scale:(scale, scale)); + + // + // selected weapon + // + int weapon = p.curr_weapon; + if (weapon == RRWpn.THROWINGDYNAMITE_WEAPON) weapon = RRWpn.DYNAMITE_WEAPON; + + let wicon = ammo_sprites[weapon]; + if (wicon.length() > 0) + { + int ammo = p.ammo_amount[weapon]; + bool reloadableWeapon = weapon == RRWpn.PISTOL_WEAPON || weapon == RRWpn.SHOTGUN_WEAPON; + if (!reloadableWeapon || (reloadableWeapon && !cl_showmagamt)) + { + format = String.Format("%d", ammo); + } + else + { + int clip; + switch (weapon) + { + case RRWpn.PISTOL_WEAPON: + clip = CalcMagazineAmount(ammo, 6, p.kickback_pic >= 1); + break; + case RRWpn.SHOTGUN_WEAPON: + clip = CalcMagazineAmount(ammo, 2, p.kickback_pic >= 4); + break; + } + format = String.Format("%d/%d", clip, ammo - clip); + } + img = TexMan.CheckForTexture(wicon, TexMan.TYPE_Any); + siz = TexMan.GetScaledSize(img); + imgScale = baseScale / siz.Y; + let imgX = 22.5; + let strlen = format.Length(); + + if (strlen > 1) + { + imgX += (imgX * 0.755) * (strlen - 1); + } + + if (weapon != RRWpn.KNEE_WEAPON && weapon != RRWpn.SLINGBLADE_WEAPON && (!hud_flashing || PlayClock & 32 || ammo > (Duke.MaxAmmoAmount(weapon) / 10))) + { + DrawString(numberFont, format, (-1, -numberFont.mFont.GetHeight() * scale + 4), DI_TEXT_ALIGN_RIGHT, scale:(scale, scale)); + } + + DrawTexture(img, (-imgX, -2), DI_ITEM_RIGHT_BOTTOM, scale:(imgScale, imgScale)); + } + + // + // Selected inventory item + // + uint icon = p.inven_icon; + if (icon > 0) + { + int x = -130; + + if (icon < Duke.ICON_MAX) + { + img = TexMan.CheckForTexture(item_icons[icon], TexMan.TYPE_Any); + siz = TexMan.GetScaledSize(img); + imgScale = baseScale / siz.Y; + DrawTexture(img, (x, -2), DI_ITEM_RIGHT_BOTTOM, scale:(imgScale, imgScale)); + } + + int percentv = getinvamount(p); + if (icon <= 2) format = String.Format("%d%%", percentv); + else format = String.Format("%d", percentv); + DrawString(miniFont, format, (x + 19, -miniFont.mFont.GetHeight() * scale - 1), DI_TEXT_ALIGN_RIGHT, scale:(scale, scale)); + + let text = ontext(p); + if (text.length() > 0) DrawString(miniFont, text, (x + 20, -miniFont.mFont.GetHeight() * scale - 15), DI_TEXT_ALIGN_RIGHT, scale:(scale, scale)); + } + + // + // keys + // + if (p.keys[1]) DrawImage("ACCESSCARD", (-28.5, -32 ), DI_ITEM_BOTTOM, 1, (-1, -1), (scale, scale), STYLE_Translucent, 0xffffffff, Translation.MakeID(Translation_Remap, 0)); + if (p.keys[3]) DrawImage("ACCESSCARD", (-21.25, -28.375), DI_ITEM_BOTTOM, 1, (-1, -1), (scale, scale), STYLE_Translucent, 0xffffffff, Translation.MakeID(Translation_Remap, 23)); + if (p.keys[2]) DrawImage("ACCESSCARD", (-14, -24.75 ), DI_ITEM_BOTTOM, 1, (-1, -1), (scale, scale), STYLE_Translucent, 0xffffffff, Translation.MakeID(Translation_Remap, 21)); + } + + + //========================================================================== + // + // Fullscreen HUD variant #2 for RR + // + //========================================================================== + + void FullscreenHUD2(DukePlayer p) + { + // + // health + // + DrawImage("HEALTHBOX", (2, -2), DI_ITEM_LEFT_BOTTOM, scale:(scale, scale)); + int health = p.IsFrozen() ? 1 : p.last_extra; + String format = String.Format("%d", health); + DrawString(digiFont, format, (21.5, -digiFont.mFont.GetHeight() * scale - 5.5), DI_TEXT_ALIGN_CENTER, scale:(scale, scale)); + + // + // ammo + // + DrawImage("AMMOBOX", (41, -2), DI_ITEM_LEFT_BOTTOM, scale:(scale, scale)); + int wp = p.curr_weapon == RRWpn.THROWINGDYNAMITE_WEAPON? RRWpn.DYNAMITE_WEAPON : p.curr_weapon; + format = String.Format("%d", p.ammo_amount[wp]); + DrawString(digiFont, format, (60.25, -digiFont.mFont.GetHeight() * scale - 5.5), DI_TEXT_ALIGN_CENTER, scale:(scale, scale)); + + // + // inventory + // + uint icon = p.inven_icon; + if (icon > 0) + { + int x = 84; + DrawImage("INVENTORYBOX", (77, -2), DI_ITEM_LEFT_BOTTOM, scale:(scale, scale)); + if (icon < Duke.ICON_MAX) + DrawImage(item_icons[icon], (x, -15.375), DI_ITEM_LEFT|DI_ITEM_VCENTER, scale:(scale, scale)); + + int percentv = getinvamount(p); + if (icon <= 2) format = String.Format("%d%%", percentv); + else format = String.Format("%d", percentv); + DrawString(miniFont, format, (x + 31.5, -miniFont.mFont.GetHeight() * scale - 6.5), DI_TEXT_ALIGN_RIGHT, scale:(scale, scale)); + } + } + + //========================================================================== + // + // Fullscreen HUD drawer + // + //========================================================================== + + void DrawHud(DukePlayer p, int style, SummaryInfo info) + { + BeginHUD(1, false, 320, 200); + if (style == 1) + { + double y = -40; + //if (ud.multimode > 1) y -= 4; + //if (ud.multimode > 4) y -= 4; + DrawInventory(p, 0, y, DI_SCREEN_CENTER_BOTTOM); + FullscreenHUD1(p); + DoLevelStats(int(scale * tileHeight("BIGALPHANUM") + 10), info); + } + else if (style == 2) + { + DrawInventory(p, 56, -20, DI_SCREEN_CENTER_BOTTOM); + FullscreenHUD2(p); + DoLevelStats(int(scale * tileHeight("HEALTHBOX") + 4), info); + } + else + { + DrawInventory(p, 0, -20, DI_SCREEN_CENTER_BOTTOM); + DoLevelStats(2, info); + } + } + + //========================================================================== + // + // Status bar drawer (RR) + // + //========================================================================== + + void DrawWeaponBar(DukePlayer p, int top) + { + double sbscale = 32800. / 65536.; + + DrawImage("WEAPONBAR", (0, 158), DI_ITEM_OFFSETS, scale:(sbscale, sbscale)); + + for (int i = 0; i < 9; i++) + { + String format, texname; + + if ((gameinfo.gameType & GAMEFLAG_RRRA) && i == 4 && p.curr_weapon == RRWpn.CHICKEN_WEAPON) + { + texname = "AMMO_ICON10"; + format = String.Format("%d", p.ammo_amount[RRWpn.CHICKEN_WEAPON]); + } + else + { + if (p.gotweapon[i+1]) + { + texname = "AMMO_ICON" .. i; + format = String.Format("%d", p.ammo_amount[i+1]); + } + } + + DrawImage(texname, (18 + i * 32, top - 6.5), DI_ITEM_OFFSETS, scale:(sbscale, sbscale)); + + if (format.Length()) + { + DrawString(miniFont, format, (38 + i * 32, 162.75 - miniFont.mFont.GetHeight() * scale * 0.5), DI_TEXT_ALIGN_CENTER, scale:(scale * .875, scale * .875)); + } + } + } + + + //========================================================================== + // + // Status bar drawer (RR) + // + //========================================================================== + + void Statusbar(DukePlayer p) + { + let bsb = TexMan.CheckForTexture("BOTTOMSTATUSBAR", Texman.Type_Any); + let siz = TexMan.GetScaledSize(bsb) * scale; + + double wh = 0; + if (hud_size < Hud_Stbar) wh = tileHeight("WEAPONBAR") * scale; + + double h = siz.Y; + double top = 200 - h; + int left = (320 - int(siz.X)) / 2; + BeginStatusBar(false, 320, 200, int(wh + h)); + DrawInventory(p, 160, hud_size <= Hud_Stbar? 148 : 154, 0); + + if (hud_size <= Hud_Stbar) + DrawWeaponBar(p, int(top)); + + if (hud_size == Hud_StbarOverlay) Set43ClipRect(); + DrawTexture(bsb, (left, top), DI_ITEM_LEFT_TOP, scale:(scale, scale)); + screen.ClearClipRect(); + + String format; + + /* + if (ud.multimode > 1 && !ud.coop) + { + DrawTexture("KILLSICON", (228, top + 8), DI_ITEM_OFFSETS, 1, 0, 0); + format = String.Format("%d", max(p.frag - p.fraggedself, 0)); + DrawString(digiFont, format, (287, top + 17), DI_TEXT_ALIGN_CENTER, Font.CR_UNTRANSLATED, 1, 0, 0, (scale, scale)); + } + else*/ + { + let key = TexMan.CheckForTexture("ACCESS_ICON", TexMan.Type_Any); + if (p.keys[3]) DrawTexture(key, (138, top + 13), DI_ITEM_OFFSETS, 1, (-1, -1), (scale, scale), STYLE_Translucent, 0xffffffff, Translation.MakeID(Translation_Remap, 23)); + if (p.keys[2]) DrawTexture(key, (152, top + 13), DI_ITEM_OFFSETS, 1, (-1, -1), (scale, scale), STYLE_Translucent, 0xffffffff, Translation.MakeID(Translation_Remap, 21)); + if (p.keys[1]) DrawTexture(key, (145, top + 21), DI_ITEM_OFFSETS, 1, (-1, -1), (scale, scale), STYLE_Translucent, 0xffffffff, Translation.MakeID(Translation_Remap, 0)); + } + + int num = (p.IsFrozen()) ? 1 : p.last_extra; + format = String.Format("%d", num); + DrawString(digiFont, format, (66.5, top + 16), DI_TEXT_ALIGN_CENTER, scale:(scale, scale)); + + if (p.curr_weapon != RRWpn.KNEE_WEAPON) + { + int wep = (p.curr_weapon == RRWpn.THROWINGDYNAMITE_WEAPON) ? RRWpn.DYNAMITE_WEAPON : p.curr_weapon; + format = String.Format("%d", p.ammo_amount[wep]); + DrawString(digiFont, format, (110, top + 16), DI_TEXT_ALIGN_CENTER, scale:(scale, scale)); + } + + int icon = p.inven_icon; + if (icon) + { + int x = 182; + if (icon < Duke.ICON_MAX) + DrawImage(item_icons[icon], (x, top + 20.125), DI_ITEM_LEFT | DI_ITEM_VCENTER, scale:(scale, scale)); + + int percentv = getinvamount(p); + if (icon <= 2) format = String.Format("%d%%", percentv); + else format = String.Format("%d", percentv); + DrawString(miniFont, format, (x + 38, top + 23.5), DI_TEXT_ALIGN_RIGHT, scale:(scale, scale)); + + if (p.inven_icon == Duke.ICON_SCUBA || p.inven_icon == Duke.ICON_BOOTS) + DrawString(miniFont, "AUTO", (x + 39, top + 13), DI_TEXT_ALIGN_RIGHT, scale:(scale, scale)); + } + + p.drunkang = ((p.drink_amt * 8) + 1647) & 2047; + if (p.drink_amt >= 100) + { + p.drink_amt = 100; + p.drunkang = 400; + } + + DrawImageRotated("GUTMETER", (256, top + 15), DI_ITEM_RELCENTER, p.drunkang * -Raze.BAngToDegree, 1, (scale, scale)); + DrawImageRotated("GUTMETER", (292, top + 15), DI_ITEM_RELCENTER, p.eatang * -Raze.BAngToDegree, 1, (scale, scale)); + + if (p.drink_amt >= 0 && p.drink_amt <= 30) + { + DrawImage("GUTMETER_LIGHT1", (239, top + 24), DI_ITEM_OFFSETS, scale:(scale, scale)); + } + else if (p.drink_amt >= 31 && p.drink_amt <= 65) + { + DrawImage("GUTMETER_LIGHT2", (248, top + 24), DI_ITEM_OFFSETS, scale:(scale, scale)); + } + else if (p.drink_amt >= 66 && p.drink_amt <= 87) + { + DrawImage("GUTMETER_LIGHT3", (256, top + 24), DI_ITEM_OFFSETS, scale:(scale, scale)); + } + else + { + DrawImage("GUTMETER_LIGHT4", (265, top + 24), DI_ITEM_OFFSETS, scale:(scale, scale)); + } + + if (p.eat >= 0 && p.eat <= 30) + { + DrawImage("GUTMETER_LIGHT1", (276, top + 24), DI_ITEM_OFFSETS, scale:(scale, scale)); + } + else if (p.eat >= 31 && p.eat <= 65) + { + DrawImage("GUTMETER_LIGHT2", (285, top + 24), DI_ITEM_OFFSETS, scale:(scale, scale)); + } + else if (p.eat >= 66 && p.eat <= 87) + { + DrawImage("GUTMETER_LIGHT3", (294, top + 24), DI_ITEM_OFFSETS, scale:(scale, scale)); + } + else + { + DrawImage("GUTMETER_LIGHT4", (302, top + 24), DI_ITEM_OFFSETS, scale:(scale, scale)); + } + } + + override void UpdateStatusBar(SummaryInfo info) + { + let p = Duke.GetViewPlayer(); + if (hud_size >= Hud_Mini) + { + DrawHud(p, hud_size == Hud_Nothing ? 0 : hud_size == Hud_full ? 1 : 2, info); + } + else + { + Statusbar(p); + DoLevelStats(-1, info); + } + } + +} diff --git a/wadsrc/static/zscript/games/exhumed/exhumedgame.zs b/wadsrc/static/zscript/games/exhumed/exhumedgame.zs index 49597d2f8..33382b585 100644 --- a/wadsrc/static/zscript/games/exhumed/exhumedgame.zs +++ b/wadsrc/static/zscript/games/exhumed/exhumedgame.zs @@ -7,14 +7,17 @@ struct Exhumed native native static bool LocalSoundPlaying(); native static void playCDTrack(int track, bool looped); native static void DrawPlasma(); - + native static int, int GetStatusSequence(int seq, int index); + native static int MoveStatusSequence(int s1, int s2); + native static int SizeOfStatusSequence(int s1); + native static ExhumedPlayer GetViewPlayer(); static void DrawAbs(String img, int x, int y, int shade = 0) { Screen.DrawTexture(TexMan.CheckForTexture(img, TexMan.Type_Any), false, x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TopLeft, true, DTA_Color, Raze.shadeToLight(shade)); } - static void DRawRel(String img, int x, int y, int shade = 0) + static void DrawRel(String img, int x, int y, int shade = 0) { let tex = TexMan.CheckForTexture(img, TexMan.Type_Any); if (!tex.IsValid()) return; @@ -27,6 +30,56 @@ struct Exhumed native } } +struct ExhumedPlayer native +{ + native int16 nHealth; + native int16 nLives; + native int16 nDouble; + native int16 nInvisible; + native int16 nTorch; + native int16 field_2; + native int16 nAction; + native int16 nSprite; + native int16 bIsMummified; + native int16 invincibility; + native int16 nAir; + native int16 nSeq; + native int16 nMaskAmount; + native uint16 keys; + native int16 nMagic; + native int16 nItem; + native uint8 items[8]; + native int16 nAmmo[7]; // TODO - kMaxWeapons? + native int16 pad[2]; + + native int16 nCurrentWeapon; + native int16 field_3FOUR; + native int16 bIsFiring; + native int16 field_38; + native int16 field_3A; + native int16 field_3C; + native int16 nRun; + native bool bPlayerPan, bLockPan; + //fixedhoriz nDestVertPan; + + //PlayerHorizon horizon; + //PlayerAngle angle; + + native bool IsUnderwater(); + native int GetAngle(); +} + +enum EEWeap +{ + kWeaponSword = 0, + kWeaponPistol, + kWeaponM60, + kWeaponFlamer, + kWeaponGrenade, + kWeaponStaff, + kWeaponRing, + kWeaponMummified +} struct ExhumedSnd native { diff --git a/wadsrc/static/zscript/games/exhumed/ui/sbar.zs b/wadsrc/static/zscript/games/exhumed/ui/sbar.zs new file mode 100644 index 000000000..a70387b0d --- /dev/null +++ b/wadsrc/static/zscript/games/exhumed/ui/sbar.zs @@ -0,0 +1,781 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 2010-2019 EDuke32 developers and contributors +Copyright (C) 2019 sirlemonhead, Nuke.YKT +Copyright (C) 2020-2021 Christoph Oelckers + +This file is part of Raze. + +This is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License version 2 +as published by the Free Software Foundation. +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 General Public License for more details. +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ +//------------------------------------------------------------------------- + +struct ChunkFrame // this wraps the internal (mis-)representation of the chunk data. +{ + TextureID tex; + int x, y; + int flags; + + native void GetChunkFrame(int nFrameBase); +} + +class ExhumedStatusBar : RazeStatusBar +{ + HUDFont textfont, numberFont; + + int keyanims[4]; + int airframe, lungframe; + + int nSelectedItem; + int nHealthLevel; + int nMagicLevel; + int nMeterRange; + int nHurt; + int nHealthFrame; + int nMagicFrame; + int nItemAltSeq; + int nItemSeq; + int nItemFrames; + int nItemFrame; + int totalmoves; + + + int nCounter; + int nCounterDest; + int nDigit[3]; + int ammodelay; + int nLastWeapon; + + enum EConst + { + KeySeq = 36, + } + + override void Init() + { + textfont = HUDFont.Create(SmallFont, 1, Mono_Off, 1, 1); + numberFont = HUDFont.Create(BigFont, 0, Mono_Off, 1, 1); + + let nPicNum = GetStatusSequencePic(0, 0); + let siz = TexMan.GetScaledSize(nPicNum); + nMeterRange = siz.Y; + Reset(); + } + + override void Reset() + { + airframe = lungframe = nHurt = nHealthFrame = nMagicFrame = nItemAltSeq = nItemFrames = nItemFrame = nCounter = 0; + + nDigit[0] = nDigit[1] = nDigit[2] = 0; + nHealthLevel = -1; + nMagicLevel = -1; + nSelectedItem = -1; + nItemSeq = -1; + ammodelay = 3; + nLastWeapon = -1; + totalmoves = 0; + nCounterDest = 0; + } + + //--------------------------------------------------------------------------- + // + // draws a sequence animation to the status bar + // + //--------------------------------------------------------------------------- + + void DrawStatusSequence(int nSequence, int frameindex, double yoffset, double xoffset = 0) + { + int nFrameBase, nFrameSize; + [nFrameBase, nFrameSize] = Exhumed.GetStatusSequence(nSequence, frameindex); + + for(; nFrameSize > 0; nFrameSize--, nFrameBase++) + { + int flags = 0; + ChunkFrame chunk; + chunk.GetChunkFrame(nFrameBase); + + double x = chunk.x + xoffset; + double y = chunk.y + yoffset; + + if (hud_size <= Hud_StbarOverlay) + { + x += 161; + y += 100; + } + else + { + if (x < 0) + { + x += 160; + flags |= DI_SCREEN_LEFT_BOTTOM; + } + else if (x > 0) + { + x -= 159; // graphics do not match up precisely. + flags |= DI_SCREEN_RIGHT_BOTTOM; + } + y -= 100; + } + + if (chunk.flags & 3) + { + // This is hard to align with bad offsets, so skip that treatment for mirrored elements. + flags |= DI_ITEM_RELCENTER; + } + else + { + let tsiz = TexMan.GetScaledSize(chunk.tex); + x -= tsiz.x * .5; + y -= tsiz.y * .5; + flags |= DI_ITEM_OFFSETS; + } + + if (chunk.flags & 1) + flags |= DI_MIRROR; + if (chunk.flags & 2) + flags |= DI_MIRRORY; + + DrawTexture(chunk.tex, (x, y), flags); + } + } + + //--------------------------------------------------------------------------- + // + // draws a sequence animation to the status bar + // + //--------------------------------------------------------------------------- + + TextureID GetStatusSequencePic(int nSequence, int frameindex) + { + int nFrameBase = Exhumed.GetStatusSequence(nSequence, frameindex); + ChunkFrame chunk; + chunk.GetChunkFrame(nFrameBase); + return chunk.tex; + } + + //--------------------------------------------------------------------------- + // + // Frag display - very ugly and may have to be redone if multiplayer support gets added. + // + //--------------------------------------------------------------------------- + + void DrawMulti() + { + /* + char stringBuf[30]; + if (netgame) + { + BeginHUD(1, false, 320, 200); + + int shade; + + if ((PlayClock / 120) & 1) + shade = -100; + else + shade = 127; + + int nTile = 3593; + + int xx = 320 / (nTotalPlayers + 1); + int x = xx - 160; + + for (int i = 0; i < nTotalPlayers; i++) + { + DrawImage(String.Format("#%05d", nTile)), (x, 7), DI_ITEM_CENTER); + + if (i != nLocalPlayer) { + shade = -100; + } + + sprintf(stringBuf, "%d", nPlayerScore[i]); + DrawString(this, textfont, stringBuf, x, 0, DI_ITEM_TOP | DI_TEXT_ALIGN_CENTER, i != nLocalPlayer ? CR_UNTRANSLATED : CR_GOLD, 1, -1, 0, 1, 1); + x += xx; + nTile++; + } + } + */ + } + + //========================================================================== + // + // Fullscreen HUD variant #1 + // + //========================================================================== + + int ItemTimer(ExhumedPlayer pPlayer, int num) + { + switch (num) { + case 1: //Scarab item + return (pPlayer.invincibility * 100) / 900; + case 3: //Hand item + return (pPlayer.nDouble * 100) / 1350; + case 5: //Mask + return (pPlayer.nMaskAmount * 100) / 1350; + case 4: //Invisible + return (pPlayer.nInvisible * 100) / 900; + case 2: //Torch + return (pPlayer.nTorch * 100) / 900; + } + + return -1; + } + + void DrawHUD2(ExhumedPlayer pp) + { + BeginHUD(1, false, 320, 200); + + String format; + TextureID img; + double imgScale; + double baseScale = numberFont.mFont.GetHeight() * 0.75; + + + // + // Health + // + img = GetStatusSequencePic(125, 0); + let size = TexMan.GetScaledSize(img); + imgScale = baseScale / size.Y; + DrawTexture(img, (1.5, -1), DI_ITEM_LEFT_BOTTOM, scale:(imgScale, imgScale)); + + if (!hud_flashing || pp.nHealth > 150 || (PlayClock & 32)) + { + int s = -8; + if (hud_flashing && pp.nHealth > 800) + s += Raze.bsin(PlayClock << 5, -10); + int intens = clamp(255 - 4 * s, 0, 255); + format = String.Format("%d", pp.nHealth >> 3); + DrawString(numberFont, format, (13, -numberFont.mFont.GetHeight() + 3), DI_TEXT_ALIGN_LEFT, Font.CR_UNTRANSLATED, intens / 255.); + } + + // + // Air + // + if (pp.isUnderwater()) + { + img = GetStatusSequencePic(133, airframe); + let size = TexMan.GetScaledSize(img); + imgScale = baseScale / size.Y; + DrawTexture(img, (-4, -22), DI_ITEM_RIGHT_BOTTOM, scale:(imgScale, imgScale)); + } + + // + // Magic + // + if (nItemSeq >= 0) + { + img = GetStatusSequencePic(nItemSeq, nItemFrame); + //int tile = GetStatusSequenceTile(nItemSeq, nItemFrame); + //int tile2 = tile; + //if (tile2 > 744 && tile2 < 751) tile2 = 744; + + let size = TexMan.GetScaledSize(img); + imgScale = baseScale / size.Y; + DrawTexture(img, (70, -1), DI_ITEM_CENTER_BOTTOM, scale:(imgScale, imgScale)); + + format = String.Format("%d", pp.nMagic / 10); + + int nItem = pp.nItem; + int timer = ItemTimer(pp, nItem); + if (timer > 0) + { + format.AppendFormat("/%d", timer); + } + DrawString(numberFont, format, (79.5, -numberFont.mFont.GetHeight() + 3), DI_TEXT_ALIGN_LEFT); + } + // + // Weapon + // + int weapon = pp.nCurrentWeapon; + int ammo = nCounterDest; + if (ammo > 0) // wicon > 0 + { + format = String.Format("%d", ammo); + /* non-implemented weapon icon. + int wicon = 0;// ammo_sprites[weapon]; + img = tileGetTexture(wicon); + imgScale = baseScale / img.GetDisplayHeight(); + let imgX = 21.125; + let strlen = format.Len(); + + if (strlen > 1) + { + imgX += (imgX * 0.855) * (strlen - 1); + } + */ + + if ((!hud_flashing || PlayClock & 32 || ammo > 10))// (DamageData[weapon].max_ammo / 10))) + { + DrawString(numberFont, format, (-3, -numberFont.mFont.GetHeight() + 3), DI_TEXT_ALIGN_RIGHT); + } + + //DrawGraphic(img, (-imgX, -1), DI_ITEM_RIGHT_BOTTOM, scale:(imgScale, imgScale)); + } + + // + // keys + // + + int nKeys = pp.keys; + int x = -134; + + for (int i = 0; i < 4; i++) + { + if (nKeys & (0x1000 << i)) + { + DrawImage(String.Format("KeyIcon%d", i+1), (x, -2), DI_ITEM_LEFT_BOTTOM); + } + x += 20; + } + } + + + + //--------------------------------------------------------------------------- + // + // draw the full status bar + // + //--------------------------------------------------------------------------- + + void DrawStatus(ExhumedPlayer pp) + { + if (hud_size <= Hud_StbarOverlay) + { + // draw the main bar itself + BeginStatusBar(false, 320, 200, 40); + if (hud_size == Hud_StbarOverlay) Set43ClipRect(); + DrawImage("TileStatusBar", (160, 200), DI_ITEM_CENTER_BOTTOM); + screen.ClearClipRect(); + } + else if (hud_size == Hud_Mini) + { + BeginHUD(1, false, 320, 200); + DrawImage("hud_l", (0, 0), DI_ITEM_LEFT_BOTTOM | DI_SCREEN_LEFT_BOTTOM); + DrawImage("hud_r", (0, 0), DI_ITEM_RIGHT_BOTTOM | DI_SCREEN_RIGHT_BOTTOM); + } + else if (hud_size == Hud_full) + { + DrawHUD2(pp); + return; + } + + for (int i = 0; i < 4; i++) + { + if (pp.keys & (4096 << i)) + { + DrawStatusSequence(KeySeq + 2 * i, keyanims[i], 0.5, 0.5); + } + } + + //if (/*!bFullScreen &&*/ nNetTime) + { + DrawStatusSequence(127, 0, 0); + DrawStatusSequence(129, nMagicFrame, nMagicLevel); + DrawStatusSequence(131, 0, 0); // magic pool frame (bottom) + + DrawStatusSequence(128, 0, 0); + DrawStatusSequence(1, nHealthFrame, nHealthLevel); + DrawStatusSequence(125, 0, 0); // draw ankh on health pool + DrawStatusSequence(130, 0, 0); // draw health pool frame (top) + + // Item on the magic pool + if (nItemSeq >= 0) DrawStatusSequence(nItemSeq, nItemFrame, 1); + + // draw the blue air level meter when underwater + if (pp.isUnderwater()) DrawStatusSequence(133, airframe, 0, 0.5); + else DrawStatusSequence(132, lungframe, 0); + + // item count dots. + if (nSelectedItem >= 0) + { + int count = pp.items[nSelectedItem]; + DrawStatusSequence(156 + 2 * count, 0, 0); + } + + // life dots. + DrawStatusSequence(145 + (2 * pp.nLives), 0, 0); + + if (nHurt > 0) DrawStatusSequence(4, nHurt - 1, 0); + + // draw compass + if (hud_size <= Hud_StbarOverlay) DrawStatusSequence(35, ((pp.GetAngle() + 128) & Raze.kAngleMask) >> 8, 0, 0.5); + + //if (hud_size < Hud_full) + { + // draw ammo count + DrawStatusSequence(44, nDigit[2], 0, 0.5); + DrawStatusSequence(45, nDigit[1], 0, 0.5); + DrawStatusSequence(46, nDigit[0], 0, 0.5); + } + } + + DrawMulti(); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DoLevelStats(int bottomy, Summaryinfo summary) + { + StatsPrintInfo stats; + + stats.fontscale = 1.; + stats.spacing = SmallFont.GetHeight(); + stats.screenbottomspace = bottomy; + stats.statfont = SmallFont; + stats.letterColor = TEXTCOLOR_RED; + stats.standardColor = TEXTCOLOR_UNTRANSLATED; + + if (automapMode == am_full) + { + PrintAutomapInfo(stats, true); + } + else if (automapMode == am_off && hud_stats) + { + stats.completeColor = TEXTCOLOR_DARKGREEN; + PrintLevelStats(stats, summary); + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void SetItemSeq(ExhumedPlayer pp) + { + static const int nItemSeqOffset[] = { 91, 72, 76, 79, 68, 87, 83 }; + static const int nItemMagic[] = { 500, 1000, 100, 500, 400, 200, 700, 0 }; + + int nItem = pp.nItem; + if (nItem < 0) + { + nItemSeq = -1; + return; + } + + if (nItemMagic[nItem] <= pp.nMagic) nItemAltSeq = 0; + else nItemAltSeq = 2; + + nItemFrame = 0; + nItemSeq = nItemSeqOffset[nItem] + nItemAltSeq; + nItemFrames = Exhumed.SizeofStatusSequence(nItemSeq); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void SetMagicFrame(ExhumedPlayer pp) + { + int magicperline = 1000 / nMeterRange; + + int newMagicLevel = (1000 - pp.nMagic) / magicperline; + newMagicLevel = clamp(newMagicLevel, 0, nMeterRange - 1); + if (newMagicLevel != nMagicLevel) SetItemSeq(pp); + nMagicLevel = newMagicLevel; + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void SetHealthFrame(ExhumedPlayer pp) + { + if (nHurt) + { + nHurt++; + if (nHurt > Exhumed.SizeofStatusSequence(4)) nHurt = 0; + } + + int healthperline = 800 / nMeterRange; + + int newHealthLevel = (800 - pp.nHealth) / healthperline; + newHealthLevel = clamp(newHealthLevel, 0, nMeterRange - 1); + if (newHealthLevel > nHealthLevel) nHurt = 1; + nHealthLevel = newHealthLevel; + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void SetCounter(int nVal) + { + nCounterDest = clamp(nVal, 0, 999); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void SetCounterImmediate(int nVal) + { + SetCounter(nVal); + nCounter = nCounterDest; + SetCounterDigits(); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void SetCounterDigits() + { + nDigit[2] = 3 * (nCounter / 100 % 10); + nDigit[1] = 3 * (nCounter / 10 % 10); + nDigit[0] = 3 * (nCounter % 10); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void UpdateCounter(ExhumedPlayer pp) + { + int nWeapon = pp.nCurrentWeapon; + + if (nWeapon < 0) + { + SetCounterImmediate(0); + } + else + { + int thiscount; + + if (nWeapon >= kWeaponSword && nWeapon <= kWeaponRing) + thiscount = pp.nAmmo[nWeapon]; + else + thiscount = 0; + + if (nWeapon != nLastWeapon) SetCounterImmediate(thiscount); + else SetCounter(thiscount); + } + nLastWeapon = nWeapon; + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void MoveStatus(ExhumedPlayer pp) + { + if (nItemSeq >= 0) + { + nItemFrame++; + + if (nItemFrame >= nItemFrames) + { + if (nItemSeq == 67) { + SetItemSeq(pp); + } + else + { + nItemSeq -= nItemAltSeq; + + if (nItemAltSeq || (totalmoves & 0x1F)) + { + if (nItemSeq < 2) { + nItemAltSeq = 0; + } + } + else + { + nItemAltSeq = 1; + } + + nItemFrame = 0; + nItemSeq += nItemAltSeq; + nItemFrames = Exhumed.SizeofStatusSequence(nItemSeq); + } + } + } + + nHealthFrame++; + if (nHealthFrame >= Exhumed.SizeofStatusSequence(1)) nHealthFrame = 0; + + nMagicFrame++; + if (nMagicFrame >= Exhumed.SizeofStatusSequence(129)) nMagicFrame = 0; + + if (nCounter == nCounterDest) + { + nCounter = nCounterDest; + ammodelay = 3; + return; + } + else + { + ammodelay--; + if (ammodelay > 0) + return; + } + + int eax = nCounterDest - nCounter; + + if (eax <= 0) + { + if (eax >= -30) + { + for (int i = 0; i < 3; i++) + { + nDigit[i]--; + + if (nDigit[i] < 0) + { + nDigit[i] += 30; + } + + if (nDigit[i] < 27) { + break; + } + } + } + else + { + nCounter += (nCounterDest - nCounter) >> 1; + SetCounterDigits(); + return; + } + } + else + { + if (eax <= 30) + { + for (int i = 0; i < 3; i++) + { + nDigit[i]++; + + if (nDigit[i] <= 27) + break; + + if (nDigit[i] >= 30) + nDigit[i] -= 30; + } + } + else + { + nCounter += (nCounterDest - nCounter) >> 1; + SetCounterDigits(); + return; + } + } + + if (!(nDigit[0] % 3)) + nCounter = nDigit[0] / 3 + 100 * (nDigit[2] / 3) + 10 * (nDigit[1] / 3); + + eax = nCounterDest - nCounter; + if (eax < 0) + eax = -eax; + + ammodelay = max(1, 4 - (eax >> 1)); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void SetPlayerItem(ExhumedPlayer pp) + { + if (nSelectedItem != pp.nItem) + { + nSelectedItem = pp.nItem; + SetItemSeq(pp); + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + override void Tick() + { + totalmoves++; + let pp = Exhumed.GetViewPlayer(); + SetMagicFrame(pp); + SetHealthFrame(pp); + SetPlayerItem(pp); + UpdateCounter(pp); + MoveStatus(pp); + for (int i = 0; i < 4; i++) + { + int seq = KeySeq + 2 * i; + if (pp.keys & (4096 << i)) + { + if (keyanims[i] < Exhumed.SizeofStatusSequence(seq) - 1) + { + Exhumed.MoveStatusSequence(seq, 0); // this plays the pickup sound. + keyanims[i]++; + } + } + else + { + keyanims[i] = 0; + } + } + + if (pp.isUnderwater()) + { + + int nAirFrames = Exhumed.SizeofStatusSequence(133); + int airperline = 100 / nAirFrames; + + airframe = pp.nAir / airperline; + + if (airframe >= nAirFrames) + { + airframe = nAirFrames - 1; + } + else if (airframe < 0) + { + airframe = 0; + } + lungframe = 0; + } + else + { + int size = Exhumed.SizeofStatusSequence(132); + if (++lungframe == size) lungframe = 0; + } + } + + + override void UpdateStatusBar(SummaryInfo info) + { + if (hud_size <= Hud_full) + { + DrawStatus(Exhumed.GetViewPlayer()); + } + DoLevelStats(hud_size == Hud_Nothing ? 0 : hud_size == Hud_full ? 22 : 40, info); + } +} diff --git a/wadsrc/static/zscript/games/sw/swgame.zs b/wadsrc/static/zscript/games/sw/swgame.zs index 3c2f60179..66217368a 100644 --- a/wadsrc/static/zscript/games/sw/swgame.zs +++ b/wadsrc/static/zscript/games/sw/swgame.zs @@ -27,6 +27,9 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms struct SW native { + const MAX_INVENTORY = 7; + const MAX_WEAPONS = 14; + enum ESWSoundFlag { v3df_none = 0, // Default, take no action, use all defaults @@ -42,10 +45,86 @@ struct SW native v3df_nolookup = 128, // don't use ambient table lookup } + enum EWeaponAndDamage + { + WPN_FIST, + WPN_STAR, + WPN_SHOTGUN, + WPN_UZI, + WPN_MICRO, + WPN_GRENADE, + WPN_MINE, + WPN_RAIL, + WPN_HOTHEAD, + WPN_HEART, + + WPN_NAPALM, + WPN_RING, + WPN_ROCKET, + WPN_SWORD, + + // extra weapons connected to other + + // spell + DMG_NAPALM, + DMG_MIRV_METEOR, + DMG_SERP_METEOR, + + // radius damage + DMG_ELECTRO_SHARD, + DMG_SECTOR_EXP, + DMG_BOLT_EXP, + DMG_TANK_SHELL_EXP, + DMG_FIREBALL_EXP, + DMG_NAPALM_EXP, + DMG_SKULL_EXP, + DMG_BASIC_EXP, + DMG_GRENADE_EXP, + DMG_MINE_EXP, + DMG_MINE_SHRAP, + DMG_MICRO_EXP, + DMG_NUCLEAR_EXP, + DMG_RADIATION_CLOUD, + DMG_FLASHBOMB, + + DMG_FIREBALL_FLAMES, + + // actor + DMG_RIPPER_SLASH, + DMG_SKEL_SLASH, + DMG_COOLG_BASH, + DMG_COOLG_FIRE, + DMG_GORO_CHOP, + DMG_GORO_FIREBALL, + DMG_SERP_SLASH, + DMG_LAVA_BOULDER, + DMG_LAVA_SHARD, + DMG_HORNET_STING, + DMG_EEL_ELECTRO, + + // misc + DMG_SPEAR_TRAP, + DMG_VOMIT, + + // inanimate objects + DMG_BLADE, + } + + enum EInvFlags + { + INVF_AUTO_USE = 1, + INVF_TIMED = 2, + INVF_COUNT = 4 + } + native static void PlaySound(int sound, int flags, int channel = CHAN_AUTO, int cflags = 0); native static void StopSound(); native static bool IsSoundPlaying(int channel); // soundEngine.IsSourcePlayingSomething(SOURCE_None, nullptr, CHAN_VOICE)) native static void PlaySong(int trackid); + native static int WeaponMaxAmmo(int weap); + native static int InventoryFlags(int inv); + native static SWPlayer GetViewPlayer(); + native static int RealWeapon(int wp); //--------------------------------------------------------------------------- // // @@ -76,6 +155,188 @@ struct SW native } +struct SWPlayer native +{ + // variable that fit in the sprite or user structure + /* + union + { + struct { int32_t posx, posy, posz; }; + vec3_t pos; + }; + */ + + // interpolation + //int oposx, oposy, oposz; + + // holds last valid move position + //int16 lv_sectnum; + //int lv_x,lv_y,lv_z; + + // can't do the pointers yet. + /* + SPRITEp remote_sprite; + REMOTE_CONTROL remote; + SECTOR_OBJECTp sop_remote; + SECTOR_OBJECTp sop; // will either be sop_remote or sop_control + SECTORp hi_sectp, lo_sectp; + SPRITEp hi_sp, lo_sp; + SPRITEp last_camera_sp; + PlayerHorizon horizon; + PlayerAngle angle; + binangle RevolveAng; + // under vars are for wading and swimming + //int16 PlayerSprite, PlayerUnderSprite; + SPRITEp SpriteP, UnderSpriteP; + PLAYER_ACTION_FUNCp DoPlayerAction; + ESyncBits KeyPressBits; + + SECTOR_OBJECTp sop_control; // sector object pointer + SECTOR_OBJECTp sop_riding; // sector object pointer + + struct + { + PANEL_SPRITEp Next, Prev; + } PanelSpriteList; + PANEL_SPRITEp CurWpn; + PANEL_SPRITEp Wpn[SW.MAX_WEAPONS]; + PANEL_SPRITEp Chops; + */ + native voidptr sop_remote; // the status bar needs to check this - remove once the underlying type can be supported. + + native int jump_count, jump_speed; // jumping + native int16 down_speed, up_speed; // diving + native int z_speed,oz_speed; // used for diving and flying instead of down_speed, up_speed + native int climb_ndx; + native int hiz,loz; + native int ceiling_dist,floor_dist; + native int circle_camera_dist; + native int six,siy,siz; // save player interp position for PlayerSprite + native int16 siang; + + native int xvect, yvect; + native int oxvect, oyvect; + native int friction; + native int slide_xvect, slide_yvect; + native int16 slide_ang; + native int slide_dec; + native float drive_avel; + + native int16 view_outside_dang; // outside view delta ang + native int16 circle_camera_ang; + native int16 camera_check_time_delay; + + native int16 cursectnum,lastcursectnum; + native int turn180_target; // 180 degree turn + + // variables that do not fit into sprite structure + native int hvel,tilt,tilt_dest; + native int16 recoil_amt; + native int16 recoil_speed; + native int16 recoil_ndx; + native int recoil_horizoff; + + native int oldposx,oldposy,oldposz; + native int RevolveX, RevolveY; + native int16 RevolveDeltaAng; + + native int16 pnum; // carry along the player number + + native int16 LadderSector; + native int lx,ly; // ladder x and y + native int16 JumpDuration; + native int16 WadeDepth; + native int16 bob_amt; + native int16 bob_ndx; + native int16 bcnt; // bob count + native int bob_z, obob_z; + + // must start out as 0 + native int playerreadyflag; + + native int Flags, Flags2; + + // Key stuff + native uint8 HasKey[8]; + + // Weapon stuff + native int16 SwordAng; + native int WpnGotOnceFlags; // for no respawn mode where weapons are allowed grabbed only once + native int WpnFlags; + native int16 WpnAmmo[SW.MAX_WEAPONS]; + native int16 WpnNum; + native uint8 WpnRocketType; // rocket type + native uint8 WpnRocketHeat; // 5 to 0 range + native uint8 WpnRocketNuke; // 1, you have it, or you don't + native uint8 WpnFlameType; // Guardian weapons fire + native uint8 WpnFirstType; // First weapon type - Sword/Shuriken + native uint8 WeaponType; // for weapons with secondary functions + native int16 FirePause; // for sector objects - limits rapid firing + // + // Inventory Vars + // + native int16 InventoryNum; + native int16 InventoryBarTics; + native int16 InventoryTics[SW.MAX_INVENTORY]; + native int16 InventoryPercent[SW.MAX_INVENTORY]; + native int8 InventoryAmount[SW.MAX_INVENTORY]; + native bool InventoryActive[SW.MAX_INVENTORY]; + + native int16 DiveTics; + native int16 DiveDamageTics; + + // Death stuff + native uint16 DeathType; + native int16 Kills; + //native int16 Killer; //who killed me + //native int16 KilledPlayer[MAX_SW_PLAYERS_REG]; + native int16 SecretsFound; + + // Health + native int16 Armor; + native int16 MaxHealth; + + //char RocketBarrel; + + native uint8 UziShellLeftAlt; + native uint8 UziShellRightAlt; + native uint8 TeamColor; // used in team play and also used in regular mulit-play for show + + // palette fading up and down for player hit and get items + native int16 FadeTics; // Tics between each fade cycle + native int16 FadeAmt; // Current intensity of fade + native bool NightVision; // Is player's night vision active? + native uint8 StartColor; // Darkest color in color range being used + //native int16 electro[64]; + native bool IsAI; // Is this and AI character? + native int16 fta,ftq; // First time active and first time quote, for talking in multiplayer games + native int16 NumFootPrints; // Number of foot prints left to lay down + native uint8 WpnUziType; // Toggle between single or double uzi's if you own 2. + native uint8 WpnShotgunType; // Shotgun has normal or fully automatic fire + native uint8 WpnShotgunAuto; // 50-0 automatic shotgun rounds + native uint8 WpnShotgunLastShell; // Number of last shell fired + native uint8 WpnRailType; // Normal Rail Gun or EMP Burst Mode + native bool Bloody; // Is player gooey from the slaughter? + native bool InitingNuke; + native bool TestNukeInit; + native bool NukeInitialized; // Nuke already has counted down + native int16 FistAng; // KungFu attack angle + native uint8 WpnKungFuMove; // KungFu special moves + native int16 HitBy; // SpriteNum of whatever player was last hit by + native int16 Reverb; // Player's current reverb setting + native int16 Heads; // Number of Accursed Heads orbiting player + native int PlayerVersion; + native uint8 WpnReloadState; + + native int WeaponNum(); + native int GetBuildAngle(); + native int Health(); + native int MaxUserHealth(); +} + + + + struct SWSnd native { enum ESounds diff --git a/wadsrc/static/zscript/games/sw/ui/sbar.zs b/wadsrc/static/zscript/games/sw/ui/sbar.zs new file mode 100644 index 000000000..dd4b9625f --- /dev/null +++ b/wadsrc/static/zscript/games/sw/ui/sbar.zs @@ -0,0 +1,935 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1997, 2005 - 3D Realms Entertainment + +This file is part of Shadow Warrior version 1.2 + +Shadow Warrior is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +Original Source: 1997 - Frank Maddin and Jim Norwood +Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms +*/ +//------------------------------------------------------------------------- + + +class SWStatusBar : RazeStatusBar +{ + static const String icons[] = { + "PanelMedkit", + "PanelRepairKit", + "PanelCloak", + "PanelNightVision", + "PanelChemBomb", + "PanelFlashBomb", + "PanelCaltrops" + }; + + enum EConstants + { + PANEL_HEALTH_BOX_X = 20, + PANEL_BOX_Y = (174 - 6), + PANEL_HEALTH_XOFF = 2, + PANEL_HEALTH_YOFF = 4, + + PANEL_AMMO_BOX_X = 197, + PANEL_AMMO_XOFF = 1, + PANEL_AMMO_YOFF = 4, + + WSUM_X = 93, + WSUM_Y = PANEL_BOX_Y + 1, + WSUM_XOFF = 25, + WSUM_YOFF = 6, + + PANEL_KEYS_BOX_X = 276, + PANEL_KEYS_XOFF = 0, + PANEL_KEYS_YOFF = 2, + + PANEL_ARMOR_BOX_X = 56, + PANEL_ARMOR_XOFF = 2, + PANEL_ARMOR_YOFF = 4, + + FRAG_YOFF = 2, + + INVENTORY_BOX_X = 231, + INVENTORY_BOX_Y = (176 - 8), + + INVENTORY_PIC_XOFF = 1, + INVENTORY_PIC_YOFF = 1, + + INVENTORY_PERCENT_XOFF = 19, + INVENTORY_PERCENT_YOFF = 13, + + INVENTORY_STATE_XOFF = 19, + INVENTORY_STATE_YOFF = 1, + + MINI_BAR_Y = 174, + MINI_BAR_HEALTH_BOX_X = 4, + MINI_BAR_AMMO_BOX_X = 32, + MINI_BAR_INVENTORY_BOX_X = 64, + MINI_BAR_INVENTORY_BOX_Y = MINI_BAR_Y, + + } + + TextureID PanelFont[10]; + TextureID SmallSBFont[3][12]; + HUDFont numberFont, miniFont; + + override void Init() + { + numberFont = HudFont.Create(BigFont, 0, Mono_Off, 1, 1); + miniFont = HudFont.Create(SmallFont2, 0, Mono_Off, 1, 1); + for (int i = 0; i < 10; i++) PanelFont[i] = TexMan.CheckForTexture(String.Format("PANEL_FONT_G%d", i), TexMan.Type_Any); + for (int i = 0; i < 12; i++) + { + SmallSBFont[0][i] = TexMan.CheckForTexture(String.Format("PANEL_SM_FONT_G%d", i), TexMan.Type_Any); + SmallSBFont[1][i] = TexMan.CheckForTexture(String.Format("PANEL_SM_FONT_Y%d", i), TexMan.Type_Any); + SmallSBFont[2][i] = TexMan.CheckForTexture(String.Format("PANEL_SM_FONT_R%d", i), TexMan.Type_Any); + } + } + + int tileHeight(String tex) + { + let img = TexMan.CheckForTexture(tex, TexMan.TYPE_Any); + let siz = TexMan.GetScaledSize(img); + return int(siz.Y); + } + + int tileWidth(String tex) + { + let img = TexMan.CheckForTexture(tex, TexMan.TYPE_Any); + let siz = TexMan.GetScaledSize(img); + return int(siz.X); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DisplayPanelNumber(double x, double y, int number) + { + String buffer; + + buffer = String.Format("%03d", number); + + for (int i = 0; i < buffer.length(); i++) + { + let c = buffer.ByteAt(i); + if (c < "0" || c > "9") + { + continue; + } + let tex = PanelFont[c - 48]; + DrawTexture(tex, (x, y), DI_ITEM_LEFT_TOP); + let siz = TexMan.GetScaledSize(tex); + x += siz.X + 1; + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DisplaySummaryString(double x, double y, int color, int shade, String buffer) + { + for (int i = 0; i < buffer.length(); i++) + { + let ch = buffer.ByteAt(i); + + if (ch == "/") ch = 10; + else if (ch == ":") ch = 11; + else if (ch >= "0" && ch <= "9") ch -= 48; + else + { + if (ch != " ") Console.Printf("Invalid char %c", ch); + x += 4; + continue; + } + + let font_pic = SmallSBFont[color][ch]; + DrawTexture(font_pic, (x, y), DI_ITEM_LEFT_TOP, col:Raze.shadeToLight(shade)); + let siz = TexMan.GetScaledSize(font_pic); + x += siz.X + 1; + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DisplayTimeLimit(SWPlayer pp) + { + int seconds = 0;// gNet.TimeLimitClock / 120; + let ds = String.Format("%03d:%02d", seconds / 60, seconds % 60); + DisplaySummaryString(PANEL_KEYS_BOX_X + 1, PANEL_BOX_Y + 6, 0, 0, ds); + } + + //--------------------------------------------------------------------------- + // + // todo: migrate to FFont to support localization + // + //--------------------------------------------------------------------------- + + void DisplayTinyString(double xs, double ys, String buffer, int pal) + { + DrawString(miniFont, buffer, (xs, ys), DI_ITEM_LEFT_TOP); + } + + void DisplayFragString(SWPlayer pp, double xs, double ys, String buffer) + { + DisplayTinyString(xs, ys, buffer, 0/*pp.DisplayColor()*/); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DisplayFragNumbers() + { + for (int pnum = 0; pnum < 4; pnum++) + { + String buffer; + int xs, ys; + int frag_bar; + + static const int xoffs[] = + { + 69, 147, 225, 303 + }; + + ys = FRAG_YOFF; + + // frag bar 0 or 1 + frag_bar = ((pnum) / 4); + // move y down according to frag bar number + ys = ys + (tileHeight("FRAG_BAR") - 2) * frag_bar; + + // move x over according to the number of players + xs = xoffs[pnum]; + + buffer.Format("%03d", Raze.PlayerFrags(pnum, -1)); + DisplayFragString(null/*&Player[pnum]*/, xs, ys, buffer); + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DisplayFragNames() + { + for (int pnum = 0; pnum < 4; pnum++) + { + int xs, ys; + int frag_bar; + + static const int xoffs[] = + { + 7, 85, 163, 241 + }; + + ys = FRAG_YOFF; + + // frag bar 0 or 1 + frag_bar = ((pnum) / 4); + // move y down according to frag bar number + ys = ys + (tileHeight("FRAG_BAR") - 2) * frag_bar; + + // move x over according to the number of players + xs = xoffs[pnum]; + + DisplayFragString(null/*&Player[pnum]*/, xs, ys, Raze.PlayerName(pnum)); + } + } + + //--------------------------------------------------------------------------- + // + // This cannot remain as it is. + // + //--------------------------------------------------------------------------- + + void DisplayFragBar(SWPlayer pp) + { + // must draw this in HUD mode and align to the top center + int i, num_frag_bars; + int y; + + int numplayers = 1; + + if (numplayers <= 1) return; + //if (gNet.MultiGameType == MULTI_GAME_COOPERATIVE) return; + + num_frag_bars = ((numplayers-1)/4)+1; + + for (i = 0, y = 0; i < num_frag_bars; i++) + { + DrawImage("FRAG_BAR", (0, y), DI_ITEM_LEFT_TOP); + y += tileHeight("FRAG_BAR") - 2; + } + DisplayFragNames(); + DisplayFragNumbers(); + } + + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void PlayerUpdateWeaponSummary(SWPlayer pp, int UpdateWeaponNum) + { + int x, y; + int pos; + int column; + int WeaponNum, wpntmp; + int colr, shade; + String ds; + + WeaponNum = SW.RealWeapon(UpdateWeaponNum); + + static const int wsum_xoff[] = { 0,36,66 }; + static const String wsum_fmt2[] = { "%3d/%-3d", "%2d/%-2d", "%2d/%-2d" }; + + pos = WeaponNum - 1; + column = pos / 3; + if (column > 2) column = 2; + x = WSUM_X + wsum_xoff[column]; + y = WSUM_Y + (WSUM_YOFF * (pos % 3)); + + if (UpdateWeaponNum == pp.WeaponNum()) + { + shade = 0; + colr = 0; + } + else + { + shade = 11; + colr = 0; + } + + wpntmp = WeaponNum + 1; + if (wpntmp > 9) + wpntmp = 0; + ds = String.Format("%d:", wpntmp); + + if (pp.WpnFlags & (1 << WeaponNum)) + DisplaySummaryString(x, y, 1, shade, ds); + else + DisplaySummaryString(x, y, 2, shade + 6, ds); + + ds = String.Format(wsum_fmt2[column], pp.WpnAmmo[WeaponNum], SW.WeaponMaxAmmo(WeaponNum)); + DisplaySummaryString(x + 6, y, colr, shade, ds); + } + + void PlayerUpdateWeaponSummaryAll(SWPlayer pp) + { + for (int i = SW.WPN_STAR; i <= SW.WPN_HEART; i++) + { + PlayerUpdateWeaponSummary(pp, i); + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DisplayKeys(SWPlayer pp, double xs, double ys, double scalex = 1, double scaley = 1) + { + double x, y; + int row, col; + int i; + + static const String StatusKeyPics[] = + { + "PANEL_KEY_RED", + "PANEL_KEY_BLUE", + "PANEL_KEY_GREEN", + "PANEL_KEY_YELLOW", + "PANEL_SKELKEY_GOLD", + "PANEL_SKELKEY_SILVER", + "PANEL_SKELKEY_BRONZE", + "PANEL_SKELKEY_RED" + }; + let tex = TexMan.CheckForTexture("PANEL_KEY_RED", TexMan.Type_Any); + let size = TexMan.GetScaledSize(tex) + (1, 2); + + i = 0; + for (row = 0; row < 2; row++) + { + for (col = 0; col < 2; col++) + { + if (pp.HasKey[i]) + { + x = xs + PANEL_KEYS_XOFF + (row * size.X); + y = ys + PANEL_KEYS_YOFF + (col * size.Y); + DrawImage(StatusKeyPics[i], (x, y), DI_ITEM_LEFT_TOP, scale:(scalex, scaley)); + } + i++; + } + } + + // Check for skeleton keys + i = 0; + for (row = 0; row < 2; row++) + { + for (col = 0; col < 2; col++) + { + if (pp.HasKey[i + 4]) + { + x = xs + PANEL_KEYS_XOFF + (row * size.X); + y = ys + PANEL_KEYS_YOFF + (col * size.Y); + DrawImage(StatusKeyPics[i + 4], (x, y), DI_ITEM_LEFT_TOP, scale:(scalex, scaley)); + } + i++; + } + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void PlayerUpdateInventoryPercent(SWPlayer pp, int InventoryBoxX, int InventoryBoxY, int InventoryXoff, int InventoryYoff) + { + String ds; + + int x = InventoryBoxX + INVENTORY_PERCENT_XOFF + InventoryXoff; + int y = InventoryBoxY + INVENTORY_PERCENT_YOFF + InventoryYoff; + + if (SW.InventoryFlags(pp.InventoryNum) & SW.INVF_COUNT) + { + ds = String.Format("%d", pp.InventoryAmount[pp.InventoryNum]); + } + else + { + ds = String.Format("%d%%", pp.InventoryPercent[pp.InventoryNum]); + } + DisplayTinyString(x, y, ds, 0); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void PlayerUpdateInventoryPic(SWPlayer pp, int InventoryBoxX, int InventoryBoxY, int InventoryXoff, int InventoryYoff) + { + int x = InventoryBoxX + INVENTORY_PIC_XOFF + InventoryXoff; + int y = InventoryBoxY + INVENTORY_PIC_YOFF + InventoryYoff; + DrawImage(icons[pp.InventoryNum], (x, y), DI_ITEM_LEFT_TOP); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void PlayerUpdateInventoryState(SWPlayer pp, double InventoryBoxX, double InventoryBoxY, int InventoryXoff, int InventoryYoff) + { + double x = InventoryBoxX + INVENTORY_STATE_XOFF + InventoryXoff; + double y = InventoryBoxY + INVENTORY_STATE_YOFF + InventoryYoff; + + let flags = SW.InventoryFlags(pp.InventoryNum); + + if (flags & SW.INVF_AUTO_USE) + { + DisplayTinyString(x, y, "AUTO", 0); + } + else if (flags & SW.INVF_TIMED) + { + DisplayTinyString(x, y, pp.InventoryActive[pp.InventoryNum] ? "ON" : "OFF", 0); + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DisplayBarInventory(SWPlayer pp) + { + int InventoryBoxX = INVENTORY_BOX_X; + int InventoryBoxY = INVENTORY_BOX_Y; + + int InventoryXoff = -1; + int InventoryYoff = 0; + + // put pic + if (pp.InventoryAmount[pp.InventoryNum]) + { + PlayerUpdateInventoryPic(pp, InventoryBoxX, InventoryBoxY, 0, InventoryYoff); + // Auto/On/Off + PlayerUpdateInventoryState(pp, InventoryBoxX, InventoryBoxY, InventoryXoff, InventoryYoff); + // Percent count/Item count + PlayerUpdateInventoryPercent(pp, InventoryBoxX, InventoryBoxY, InventoryXoff, InventoryYoff); + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + int NORM_CANG(int ang) + { + return (((ang)+32) & 31); + } + + enum EXY + { + COMPASS_X = 140, + COMPASS_Y = (162 - 5), + }; + + + void DrawCompass(SWPlayer pp) + { + int start_ang, ang; + int x_size = tileWidth("COMPASS_NORTH"); + int x; + int i; + + static const String CompassPic[] = + { + "COMPASS_EAST", "COMPASS_EAST2", + "COMPASS_TIC", "COMPASS_TIC2", + "COMPASS_MID_TIC", "COMPASS_MID_TIC2", + "COMPASS_TIC", "COMPASS_TIC2", + + "COMPASS_SOUTH", "COMPASS_SOUTH2", + "COMPASS_TIC", "COMPASS_TIC2", + "COMPASS_MID_TIC", "COMPASS_MID_TIC2", + "COMPASS_TIC", "COMPASS_TIC2", + + "COMPASS_WEST", "COMPASS_WEST2", + "COMPASS_TIC", "COMPASS_TIC2", + "COMPASS_MID_TIC", "COMPASS_MID_TIC2", + "COMPASS_TIC", "COMPASS_TIC2", + + "COMPASS_NORTH", "COMPASS_NORTH2", + "COMPASS_TIC", "COMPASS_TIC2", + "COMPASS_MID_TIC", "COMPASS_MID_TIC2", + "COMPASS_TIC", "COMPASS_TIC2" + }; + + static const int CompassShade[] = + { + //20, 16, 11, 6, 1, 1, 6, 11, 16, 20 + 25, 19, 15, 9, 1, 1, 9, 15, 19, 25 + }; + + ang = pp.GetBuildAngle(); + + if (pp.sop_remote) + ang = 0; + + start_ang = (ang + 32) >> 6; + + start_ang = NORM_CANG(start_ang - 4); + + for (i = 0, x = COMPASS_X; i < 10; i++) + { + DrawImage(CompassPic[NORM_CANG(start_ang + i)], (x, COMPASS_Y), DI_ITEM_LEFT_TOP, col:Raze.shadeToLight(CompassShade[i])); + x += x_size; + } + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DrawStatusBar(SWPlayer pp) + { + let wnum = pp.WeaponNum(); + BeginStatusBar(false, 320, 200, tileHeight("STATUS_BAR")); + + if (hud_size == Hud_StbarOverlay) Set43ClipRect(); + DrawImage("STATUS_BAR", (160, 200), DI_ITEM_CENTER_BOTTOM); + screen.ClearClipRect(); + DisplayPanelNumber(PANEL_HEALTH_BOX_X + PANEL_HEALTH_XOFF, PANEL_BOX_Y + PANEL_HEALTH_YOFF, pp.Health()); + DisplayPanelNumber(PANEL_ARMOR_BOX_X + PANEL_ARMOR_XOFF, PANEL_BOX_Y + PANEL_ARMOR_YOFF, pp.Armor); + if (wnum != SW.WPN_FIST && wnum != SW.WPN_SWORD) DisplayPanelNumber(PANEL_AMMO_BOX_X + PANEL_AMMO_XOFF, PANEL_BOX_Y + PANEL_AMMO_YOFF, pp.WpnAmmo[wnum]); + PlayerUpdateWeaponSummaryAll(pp); + + /* + if (gNet.MultiGameType != MULTI_GAME_COMMBAT) + DisplayKeys(pp, PANEL_KEYS_BOX_X, PANEL_BOX_Y); + else if (gNet.TimeLimit) + DisplayTimeLimit(pp); + */ + DisplayKeys(pp, PANEL_KEYS_BOX_X, PANEL_BOX_Y); + + DisplayBarInventory(pp); + DrawCompass(pp); + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DisplayMinibarInventory(SWPlayer pp) + { + int InventoryBoxX = MINI_BAR_INVENTORY_BOX_X; + int InventoryBoxY = MINI_BAR_INVENTORY_BOX_Y - 200; + + int InventoryXoff = 0; + int InventoryYoff = 1; + + if (pp.InventoryAmount[pp.InventoryNum]) + { + PlayerUpdateInventoryPic(pp, InventoryBoxX, InventoryBoxY, InventoryXoff + 1, InventoryYoff); + // Auto/On/Off + PlayerUpdateInventoryState(pp, InventoryBoxX, InventoryBoxY, InventoryXoff, InventoryYoff); + // Percent count/Item count + PlayerUpdateInventoryPercent(pp, InventoryBoxX, InventoryBoxY, InventoryXoff, InventoryYoff); + } + } + + //--------------------------------------------------------------------------- + // + // Used in DrawHUD2() for determining whether a reloadable weapon is reloading. + // + //--------------------------------------------------------------------------- + + bool, int DoReloadStatus(int reloadstate, int ammo) + { + bool reloading = ammo == 0 && reloadstate != 2; + + if (ammo == 0 && reloadstate == 0) + { + reloadstate = 1; + } + else if (ammo) + { + reloadstate = 0; + } + + return reloading, reloadstate; + } + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DrawHUD1(SWPlayer pp) + { + BeginHUD(1, false, 320, 200); + + int x = MINI_BAR_HEALTH_BOX_X; + int y = -26; + + DrawImage("MINI_BAR_HEALTH_BOX_PIC", (x, y), DI_ITEM_LEFT_TOP); + + x = MINI_BAR_HEALTH_BOX_X + 3; + DisplayPanelNumber(x, y + 5, pp.Health()); + + let wnum = pp.WeaponNum(); + if (wnum != SW.WPN_SWORD && wnum != SW.WPN_FIST) + { + x = MINI_BAR_AMMO_BOX_X; + DrawImage("MINI_BAR_AMMO_BOX_PIC", (x, y), DI_ITEM_LEFT_TOP); + + x = MINI_BAR_AMMO_BOX_X + 3; + DisplayPanelNumber(x, y + 5, pp.WpnAmmo[wnum]); + } + + if (!pp.InventoryAmount[pp.InventoryNum]) + return; + + // Inventory Box + x = MINI_BAR_INVENTORY_BOX_X; + + DrawImage("MINI_BAR_INVENTORY_BOX_PIC", (x, y), DI_ITEM_LEFT_TOP); + DisplayMinibarInventory(pp); + } + + //========================================================================== + // + // Fullscreen HUD variant #1 + // + //========================================================================== + + void DrawHUD2(SWPlayer pp, SummaryInfo info) + { + BeginHUD(1, false, 320, 200); + + String format; + double imgScale; + double baseScale = numberFont.mFont.GetHeight() * 0.83125; + + // + // Health + // + let img = TexMan.CheckForTexture("ICON_SM_MEDKIT", TexMan.Type_Any); + let siz = TexMan.GetScaledSize(img); + imgScale = baseScale / siz.Y; + DrawTexture(img, (1.5, -1), DI_ITEM_LEFT_BOTTOM, scale:(imgScale, imgScale)); + + let Health = pp.Health(); + let MaxHealth = pp.MaxUserHealth(); + if (!hud_flashing || Health > (MaxHealth >> 2) || (PlayClock & 32)) + { + int s = -8; + if (hud_flashing && Health > MaxHealth) + s += Raze.bsin(PlayClock << 5, -10); + int intens = clamp(255 - 4 * s, 0, 255); + let pe = Color(255, intens, intens, intens); + format = String.Format("%d", Health); + DrawString(numberFont, format, (24.25, -numberFont.mFont.GetHeight() + 2), DI_TEXT_ALIGN_LEFT); + } + + // + // Armor + // + img = TexMan.CheckForTexture("ICON_ARMOR", TexMan.Type_Any); + siz = TexMan.GetScaledSize(img); + imgScale = baseScale / siz.Y; + DrawTexture(img, (80.75, -1), DI_ITEM_LEFT_BOTTOM, scale:(imgScale, imgScale)); + + format = String.Format("%d", pp.Armor); + DrawString(numberFont, format, (108.5, -numberFont.mFont.GetHeight() + 2), DI_TEXT_ALIGN_LEFT); + + // + // Weapon + // + static const String ammo_sprites[] = { "", "ICON_STAR", "ICON_LG_SHOTSHELL", "ICON_LG_UZI_AMMO", "ICON_MICRO_BATTERY", "ICON_LG_GRENADE", "ICON_LG_MINE", "ICON_RAIL_AMMO", + "ICON_FIREBALL_LG_AMMO", "ICON_HEART_LG_AMMO", "ICON_FIREBALL_LG_AMMO", "ICON_FIREBALL_LG_AMMO", "ICON_MICRO_BATTERY", "" }; + + int weapon = pp.WeaponNum(); + String wicon = ammo_sprites[weapon]; + if (wicon.length() > 0) + { + int ammo = pp.WpnAmmo[weapon]; + bool reloadableWeapon = weapon == SW.WPN_SHOTGUN || weapon == SW.WPN_UZI; + if (!reloadableWeapon || (reloadableWeapon && !cl_showmagamt)) + { + format = String.Format("%d", ammo); + } + else + { + int capacity; + switch (weapon) + { + case SW.WPN_SHOTGUN: + capacity = 4; + break; + case SW.WPN_UZI: + capacity = pp.WpnUziType ? 50 : 100; + break; + } + bool reload; + [reload, pp.WpnReloadState] = DoReloadStatus(pp.WpnReloadState, ammo % capacity); + int clip = CalcMagazineAmount(ammo, capacity, reload); + format = String.Format("%d/%d", clip, ammo - clip); + } + img = TexMan.CheckForTexture(wicon, TexMan.Type_Any); + siz = TexMan.GetScaledSize(img); + imgScale = baseScale / siz.Y; + let imgX = 21.125; + let strlen = format.Length(); + + if (strlen > 1) + { + imgX += (imgX * 0.855) * (strlen - 1); + } + + if ((!hud_flashing || PlayClock & 32 || ammo > (SW.WeaponMaxAmmo(weapon) / 10))) + { + DrawString(numberFont, format, (-1.5, -numberFont.mFont.GetHeight() + 2), DI_TEXT_ALIGN_RIGHT); + } + + DrawTexture(img, (-imgX, -1), DI_ITEM_RIGHT_BOTTOM, scale:(imgScale, imgScale)); + } + + // + // Selected inventory item + // + img = TexMan.CheckForTexture(icons[pp.InventoryNum], TexMan.Type_Any); + siz = TexMan.GetScaledSize(img); + imgScale = baseScale / siz.Y; + int x = 165; + DrawTexture(img, (x, -1), DI_ITEM_LEFT_BOTTOM, scale:(imgScale, imgScale)); + + PlayerUpdateInventoryState(pp, x + 3.0, -18.0, 1, 1); + //PlayerUpdateInventoryPercent(pp, x + 3.5, -20.5, 1, 1); // function takes integer coordinates. + PlayerUpdateInventoryPercent(pp, x + 3, -20, 1, 1); + + // + // keys + // + DisplayKeys(pp, -25, -38, 0.8625, 0.8625); + DoLevelStats(int(baseScale + 4), info); + } + + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + void DrawInventoryIcon(double xs, double ys, int align, int InventoryNum, int amount, bool selected) + { + double x, y; + int INVENTORY_ICON_WIDTH = 28; + + + x = xs + (InventoryNum * INVENTORY_ICON_WIDTH); + y = ys; + let tex = icons[InventoryNum]; + DrawImage(tex, (x, y), align | DI_ITEM_LEFT_TOP, amount ? 1. : 0.333); + if (selected) + { + DrawImage("SelectionBox", (x - 5, y - 5), align | DI_ITEM_LEFT_TOP); + } + } + + ////////////////////////////////////////////////////////////////////// + // + // INVENTORY BAR + // + ////////////////////////////////////////////////////////////////////// + + void DrawInventory(SWPlayer pp, double xs, double ys, int align) + { + if (!pp.InventoryBarTics) + { + return; + } + + for (int i = 0; i < pp.InventoryAmount.size(); i++) + { + DrawInventoryIcon(xs, ys, align, i, pp.InventoryAmount[i], i == pp.InventoryNum); + } + } + + //========================================================================== + // + // Statistics output + // + //========================================================================== + + void DoLevelStats(int bottomy, SummaryInfo info) + { + StatsPrintInfo stats; + stats.fontscale = 1; + stats.spacing = 7; + stats.screenbottomspace = bottomy; + stats.statfont = SmallFont; + + if (automapMode == am_full) + { + stats.letterColor = Font.TEXTCOLOR_SAPPHIRE; + stats.standardColor = Font.TEXTCOLOR_UNTRANSLATED; + + bool textfont = am_textfont; + if (!am_textfont) + { + // For non-English languages force use of the text font. The tiny one is simply too small to ever add localized characters to it. + let p = StringTable.Localize("$REQUIRED_CHARACTERS"); + if (p.length() > 0) textfont = true; + } + + if (!textfont) + { + stats.statfont = SmallFont2; + stats.spacing = 6; + } + else stats.spacing = SmallFont.GetHeight() + 1; + PrintAutomapInfo(stats, textfont); + } + // JBF 20040124: display level stats in screen corner + else if (hud_stats && !(netgame /*|| numplayers > 1*/)) + { + stats.letterColor = Font.TEXTCOLOR_RED; + stats.standardColor = Font.TEXTCOLOR_TAN; + stats.completeColor = Font.TEXTCOLOR_FIRE; + PrintLevelStats(stats, info); + } + } + + + //--------------------------------------------------------------------------- + // + // + // + //--------------------------------------------------------------------------- + + override void UpdateStatusBar(SummaryInfo info) + { + let pp = SW.GetViewPlayer(); + int nPalette = 0; + double inv_x, inv_y; + int align; + + if (hud_size == Hud_Nothing) + { + align = DI_SCREEN_RIGHT_BOTTOM; + inv_x = -210; + inv_y = -28; + DoLevelStats(2, info); + } + else if (hud_size == Hud_full) + { + align = DI_SCREEN_CENTER_BOTTOM; + inv_x = -80; + inv_y = -40; + DrawHUD2(pp, info); + } + else if (hud_size == Hud_Mini) + { + align = DI_SCREEN_RIGHT_BOTTOM; + inv_x = -210; + inv_y = -28; + DrawHUD1(pp); + DoLevelStats(30, info); + } + else + { + align = 0; + inv_x = 80; + inv_y = 130; + DrawStatusBar(pp); + DoLevelStats(-3, info); + } + DrawInventory(pp, inv_x, inv_y, align); + } +} + diff --git a/wadsrc/static/zscript/games/wh/ui/sbar.zs b/wadsrc/static/zscript/games/wh/ui/sbar.zs new file mode 100644 index 000000000..a918d63c9 --- /dev/null +++ b/wadsrc/static/zscript/games/wh/ui/sbar.zs @@ -0,0 +1,4 @@ + +class WHStatusBar : RazeStatusBar +{ +} diff --git a/wadsrc/static/zscript/razebase.zs b/wadsrc/static/zscript/razebase.zs index 59580144f..c69ee2486 100644 --- a/wadsrc/static/zscript/razebase.zs +++ b/wadsrc/static/zscript/razebase.zs @@ -37,6 +37,30 @@ enum EGameType }; +enum AM_Mode +{ + am_off, + am_overlay, + am_full, + am_count +} + +enum EHudSize +{ + Hud_Current = -1, + Hud_Frame50 = 0, + Hud_Frame60, + Hud_Frame70, + Hud_Frame80, + Hud_Frame90, + Hud_Stbar, + Hud_StbarOverlay, + Hud_Mini, + Hud_full, + Hud_Nothing, + Hud_MAX +} + struct UserConfigStruct native { native readonly bool nomonsters; @@ -49,6 +73,8 @@ extend struct _ native @UserConfigStruct userConfig; native readonly MapRecord currentLevel; native readonly int paused; + native readonly int automapMode; + native readonly int PlayClock; } struct MapRecord native @@ -114,6 +140,9 @@ struct SummaryInfo native struct Raze { + const kAngleMask = 0x7FF; + const BAngToDegree = 360. / 2048.; + static int calcSinTableValue(int ang) { return int(16384 * sin((360./2048) * ang)); @@ -128,6 +157,8 @@ struct Raze native static double GetTimeFrac(); native static int bsin(int angle, int shift = 0); native static int bcos(int angle, int shift = 0); + native static TextureID PickTexture(TextureID texid); + native static int GetBuildTime(); static bool specialKeyEvent(InputEvent ev) { @@ -218,27 +249,3 @@ class RazeMenuDelegate : MenuDelegateBase native override void MenuDismissed(); } - -// dummy definitions for the status bar. We need them to create the class descriptors - -class BaseStatusBar : StatusBarCore native -{} - - -class BloodStatusBar : BaseStatusBar native -{} - -class DukeCommonStatusBar : BaseStatusBar native -{} - -class DukeStatusBar : DukeCommonStatusBar native -{} - -class RedneckStatusBar : DukeCommonStatusBar native -{} - -class ExhumedStatusBar : BaseStatusBar native -{} - -class SWStatusBar : BaseStatusBar native -{} diff --git a/wadsrc/static/zscript/statusbar.zs b/wadsrc/static/zscript/statusbar.zs new file mode 100644 index 000000000..9f8a50878 --- /dev/null +++ b/wadsrc/static/zscript/statusbar.zs @@ -0,0 +1,180 @@ + + +struct StatsPrintInfo +{ + int screenbottomspace; + int spacing; // uses fontheight if 0 or less. + String letterColor, standardColor, completeColor; + double fontscale; + Font statfont; +}; + + +//============================================================================ +// +// +// +//============================================================================ + +class RazeStatusBar : StatusBarCore +{ + virtual void Init() + { + } + + virtual void Tick() {} + virtual void Reset() {} + virtual void UpdateStatusBar(SummaryInfo info) {} + + void drawStatText(Font statFont, double x, double y, String text, double scale) + { + Screen.DrawText(statfont, Font.CR_UNTRANSLATED, x + scale, y + scale, text, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_LegacyRenderStyle, STYLE_TranslucentStencil, DTA_Color, 0); + Screen.DrawText(statfont, Font.CR_UNTRANSLATED, x, y, text, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DTA_KeepRatio, true, DTA_ScaleX, scale, DTA_ScaleY, scale); + } + + //============================================================================ + // + // Prints the current level statistics + // hud_statscale is the desired display scale for the stat display + // hud_scalefactor is the desired display scale for the actual status bar / HUD + // + //============================================================================ + + void PrintLevelStats(StatsPrintInfo info, SummaryInfo stats) + { + + double y; + double scale = info.fontscale * hud_statscale; + if (info.spacing <= 0) info.spacing = info.statfont.GetHeight() * info.fontscale; + double spacing = info.spacing * hud_statscale; + if (info.screenbottomspace < 0) + { + y = 200 - (RelTop - info.screenbottomspace) * hud_scalefactor - spacing; + } + else + { + y = 200 - info.screenbottomspace * hud_scalefactor - spacing; + } + + double y1, y2, y3; + + if (stats.maxsecrets > 0) // don't bother if there are no secrets. + { + y1 = y; + y -= spacing; + } + if (stats.maxkills != -1) + { + y2 = y; + y -= spacing; + } + y3 = y; + + String text; + + text = String.Format("%sT: %s%d:%02d", info.letterColor, info.standardColor, stats.time / 60000, (stats.time % 60000) / 1000); + drawStatText(info.statFont, 2 * hud_statscale, y3, text, scale); + + if (stats.maxkills != -1) + { + if (stats.maxkills == -3) text.Format("%sF: %s%d", info.letterColor, info.standardColor, stats.kills); + else if (stats.maxkills == -2) text.Format("%sK: %s%d", info.letterColor, info.standardColor, stats.kills); + else text = String.Format("%sK: %s%d/%d", info.letterColor, + stats.kills == stats.maxkills ? info.completeColor : info.standardColor, stats.kills, stats.maxkills); + + drawStatText(info.statFont, 2 * hud_statscale, y2, text, scale); + } + + if (stats.maxsecrets > 0) // don't bother if there are no secrets. + { + text = String.Format("%sS: %s%d/%d", info.letterColor, stats.secrets >= stats.maxsecrets ? info.completeColor : info.standardColor, stats.secrets, stats.maxsecrets); + if (stats.supersecrets > 0) text.AppendFormat("+%d", stats.supersecrets); + + drawStatText(info.statFont, 2 * hud_statscale, y1, text, scale); + } + } + + //============================================================================ + // + // Prints the automap label + // hud_statscale is the desired display scale for the stat display + // hud_scalefactor is the desired display scale for the actual status bar / HUD + // + //============================================================================ + + void PrintAutomapInfo(StatsPrintInfo info, bool forcetextfont = false) + { + let TEXTCOLOR_ESCAPESTR= "\034"; + let lev = currentLevel; + String mapname; + if (am_showlabel) + mapname.Format("%s%s: %s%s", info.letterColor, lev.GetLabelName(), info.standardColor, lev.DisplayName()); + else + mapname.Format("%s%s", info.standardColor, lev.DisplayName()); + + forcetextfont |= am_textfont; + double y; + double scale = info.fontScale * (forcetextfont ? hud_statscale : 1); // the tiny default font used by all games here cannot be scaled for readability purposes. + if (info.spacing <= 0) info.spacing = info.statfont.GetHeight() * info.fontScale; + double spacing = info.spacing * (forcetextfont ? hud_statscale : 1); + if (am_nameontop) + { + y = spacing + 1; + } + else if (info.screenbottomspace < 0) + { + y = 200 - RelTop - spacing; + } + else + { + y = 200 - info.screenbottomspace - spacing; + } + let cluster = lev.GetCluster(); + String volname; + if (cluster) volname = cluster.name; + if (volname.length() == 0 && am_nameontop) y = 1; + + Screen.DrawText(info.statfont, Font.CR_UNTRANSLATED, 2 * hud_statscale, y, mapname, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true); + y -= spacing; + if (volname.length() > 0) + Screen.DrawText(info.statfont, Font.CR_UNTRANSLATED, 2 * hud_statscale, y, volname, DTA_FullscreenScale, FSMode_ScaleToHeight, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, + DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_KeepRatio, true); + } + + //============================================================================ + // + // + // + //============================================================================ + + int CalcMagazineAmount(int ammo_remaining, int clip_capacity, bool reloading) + { + // Determine amount in clip. + int clip_amount = ammo_remaining % clip_capacity; + + // Set current clip value to clip capacity if wrapped around to zero, otherwise use determined value. + int clip_current = ammo_remaining != 0 && clip_amount == 0 ? clip_capacity : clip_amount; + + // Return current clip value if weapon has rounds or is not on a reload cycle. + return ammo_remaining == 0 || (reloading && clip_amount == 0) ? 0 : clip_current; + } + + //============================================================================ + // + // + // + //============================================================================ + + void Set43ClipRect() + { + let screenratio = screen.GetAspectRatio(); + if (screenratio < 1.34) return; + + int width = int(screen.GetWidth() * 1.333 / screenratio); + int left = (screen.GetWidth() - width) / 2; + screen.SetClipRect(left, 0, width, screen.GetHeight()); + } +}