Skip to content

Commit

Permalink
Merge pull request Wargus#590 from Wargus/war1gus_fix
Browse files Browse the repository at this point in the history
War1gus fix
  • Loading branch information
Jarod42 authored Dec 10, 2023
2 parents 61385bf + b96a908 commit edc1e9a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/include/movie.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion src/include/unittype.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/ui/icons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/ui/widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
50 changes: 50 additions & 0 deletions src/video/movie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(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 <string>
Expand Down

0 comments on commit edc1e9a

Please sign in to comment.