From f1d9fb13a76234d081fc79a93a138f5c93582541 Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Sat, 9 Dec 2023 18:59:04 +0100 Subject: [PATCH 1/2] Fix empty `IconConfig::Name`/`CBuildRestrictionDistance::RestrictTypeName` found with war1gus. --- src/include/unittype.h | 6 +++++- src/ui/icons.cpp | 3 +++ src/ui/widgets.cpp | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/include/unittype.h b/src/include/unittype.h index 34213b2e06..8b43be4988 100644 --- a/src/include/unittype.h +++ b/src/include/unittype.h @@ -448,7 +448,11 @@ class CBuildRestrictionDistance : public CBuildRestriction public: CBuildRestrictionDistance() = default; - void Init() override {this->RestrictType = &UnitTypeByIdent(this->RestrictTypeName);} + void Init() override + { + this->RestrictType = + this->RestrictTypeName.empty() ? nullptr : &UnitTypeByIdent(this->RestrictTypeName); + } bool Check(const CUnit *builder, const CUnitType &type, const Vec2i &pos, CUnit *&ontoptarget) const override; int Distance = 0; /// distance to build (circle) diff --git a/src/ui/icons.cpp b/src/ui/icons.cpp index 3344917413..3e3a73d913 100644 --- a/src/ui/icons.cpp +++ b/src/ui/icons.cpp @@ -380,6 +380,9 @@ bool IconConfig::LoadNoLog() */ bool IconConfig::Load() { + if (this->Name.empty()) { + return false; + } if (LoadNoLog() == true) { ShowLoadProgress(_("Icon %s"), this->Name.c_str()); return true; diff --git a/src/ui/widgets.cpp b/src/ui/widgets.cpp index 4e502b7a11..99a537323e 100644 --- a/src/ui/widgets.cpp +++ b/src/ui/widgets.cpp @@ -354,6 +354,10 @@ CImageButton::CImageButton(const std::string &caption) : void CImageButton::draw(gcn::Graphics *graphics) /* override */ { if (!normalImage) { + if (this->getBackgroundColor().a == 0) { + return; + } + Button::draw(graphics); return; } From b96a908cb5cf320ecfb22d2c1bf3dbe532042f9c Mon Sep 17 00:00:00 2001 From: Jarod42 Date: Sat, 9 Dec 2023 20:15:41 +0100 Subject: [PATCH 2/2] Fix `Movie` after guichan update. --- src/include/movie.h | 3 +++ src/video/movie.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/src/include/movie.h b/src/include/movie.h index 3bff17d821..df31e8b920 100644 --- a/src/include/movie.h +++ b/src/include/movie.h @@ -94,6 +94,9 @@ class Movie : public gcn::SDLImage bool Load(const std::string &filename, int w, int h); bool IsPlaying() const { return true; } + // guichan + SDL_Surface *getSurface() const override; + public: CFile *f = nullptr; mutable bool need_data = true; diff --git a/src/video/movie.cpp b/src/video/movie.cpp index 91f585956c..1fa237657c 100644 --- a/src/video/movie.cpp +++ b/src/video/movie.cpp @@ -508,6 +508,56 @@ bool Movie::Load(const std::string &name, int w, int h) return true; } +SDL_Surface *Movie::getSurface() const /* override */ +{ + if (data == nullptr) { + data = (OggData *) calloc(sizeof(OggData), 1); + if (OggInit(f, data) || !data->video) { + OggFree(data); + f->close(); + ErrorPrint("Could not init OggData or not a video\n"); + return mSurface; + } + + data->File = f; + yuv_overlay = SDL_CreateTexture(TheRenderer, + SDL_PIXELFORMAT_YV12, + SDL_TEXTUREACCESS_STREAMING, + data->tinfo.frame_width, + data->tinfo.frame_height); + + if (yuv_overlay == nullptr) { + ErrorPrint("SDL_CreateYUVOverlay: %s\n", SDL_GetError()); + ErrorPrint( + "SDL_CreateYUVOverlay: %dx%d\n", data->tinfo.frame_width, data->tinfo.frame_height); + OggFree(data); + f->close(); + return mSurface; + } + + start_time = SDL_GetTicks(); + need_data = true; + TheoraProcessData(data); + RenderToSurface(mSurface, yuv_overlay, rect, data); + } + if (need_data) { + if (TheoraProcessData(data)) { + return mSurface; + } + need_data = false; + } + + const int diff = + SDL_GetTicks() - start_time + - static_cast(theora_granule_time(&data->tstate, data->tstate.granulepos) * 1000); + + if (diff > 0) { + RenderToSurface(mSurface, yuv_overlay, rect, data); + need_data = true; + } + return mSurface; +} + #else #include