Skip to content

CogDis: Battle background not shown in web player #2893

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Ghabry opened this issue Feb 9, 2023 · 1 comment
Closed

CogDis: Battle background not shown in web player #2893

Ghabry opened this issue Feb 9, 2023 · 1 comment
Assignees
Labels
Battle Emscripten WebAssembly/JavaScript port for web browsers Patch available
Milestone

Comments

@Ghabry
Copy link
Member

Ghabry commented Feb 9, 2023

Name of the game: Mother Cognitive Dissonance

Player platform: Web

Describe the issue in detail and how to reproduce it:

Start a battle. The background is missing due to async error.

@Ghabry Ghabry added Battle Emscripten WebAssembly/JavaScript port for web browsers labels Feb 9, 2023
@Ghabry Ghabry added this to the 0.7.1 milestone Feb 9, 2023
@Ghabry Ghabry self-assigned this Feb 9, 2023
@Ghabry
Copy link
Member Author

Ghabry commented Feb 23, 2023

Not tested yet but the fix should be simply using two request_id variables as the request does not fire the callback when the request gets overwritten.

diff --git a/src/background.cpp b/src/background.cpp
index d18bbfdc..30282818 100644
--- a/src/background.cpp
+++ b/src/background.cpp
@@ -35,7 +35,7 @@ Background::Background(const std::string& name) : Drawable(Priority_Background)
        if (!name.empty()) {
                FileRequestAsync* request = AsyncHandler::RequestFile("Backdrop", name);
                request->SetGraphicFile(true);
-               request_id = request->Bind(&Background::OnBackgroundGraphicReady, this);
+               bg_request_id = request->Bind(&Background::OnBackgroundGraphicReady, this);
                request->Start();
        }
 }
@@ -55,7 +55,7 @@ Background::Background(int terrain_id) : Drawable(Priority_Background)
        if (terrain->background_type == lcf::rpg::Terrain::BGAssociation_background && !terrain->background_name.empty()) {
                FileRequestAsync* request = AsyncHandler::RequestFile("Backdrop", terrain->background_name);
                request->SetGraphicFile(true);
-               request_id = request->Bind(&Background::OnBackgroundGraphicReady, this);
+               bg_request_id = request->Bind(&Background::OnBackgroundGraphicReady, this);
                request->Start();
                return;
        }
@@ -64,7 +64,7 @@ Background::Background(int terrain_id) : Drawable(Priority_Background)
        if (!terrain->background_a_name.empty()) {
                FileRequestAsync* request = AsyncHandler::RequestFile("Frame", terrain->background_a_name);
                request->SetGraphicFile(true);
-               request_id = request->Bind(&Background::OnBackgroundGraphicReady, this);
+               bg_request_id = request->Bind(&Background::OnBackgroundGraphicReady, this);
                request->Start();

                bg_hscroll = terrain->background_a_scrollh ? terrain->background_a_scrollh_speed : 0;
@@ -74,7 +74,7 @@ Background::Background(int terrain_id) : Drawable(Priority_Background)
        if (terrain->background_b && !terrain->background_b_name.empty()) {
                FileRequestAsync* request = AsyncHandler::RequestFile("Frame", terrain->background_b_name);
                request->SetGraphicFile(true);
-               request_id = request->Bind(&Background::OnForegroundFrameGraphicReady, this);
+               fg_request_id = request->Bind(&Background::OnForegroundFrameGraphicReady, this);
                request->Start();

                fg_hscroll = terrain->background_b_scrollh ? terrain->background_b_scrollh_speed : 0;
diff --git a/src/background.h b/src/background.h
index f8814871..1885d532 100644
--- a/src/background.h
+++ b/src/background.h
@@ -55,7 +55,8 @@ private:
        int fg_x = 0;
        int fg_y = 0;

-       FileRequestBinding request_id;
+       FileRequestBinding fg_request_id;
+       FileRequestBinding bg_request_id;
 };

 inline Tone Background::GetTone() const {

Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Mar 8, 2023
…e used

Fixes the battles in Mother: Cognitive Dissonance which uses fancy background effects

Fix EasyRPG#2893
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Mar 8, 2023
…e used

Fixes the battles in Mother: Cognitive Dissonance which uses fancy background effects

Fix EasyRPG#2893
Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Mar 12, 2023
…e used

Fixes the battles in Mother: Cognitive Dissonance which uses fancy background effects

Fix EasyRPG#2893
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Battle Emscripten WebAssembly/JavaScript port for web browsers Patch available
Development

No branches or pull requests

1 participant