Skip to content

Commit ec02ff7

Browse files
committed
Merge remote-tracking branch 'upstream/master' into chinese-font
2 parents f9da4eb + 8b6e90e commit ec02ff7

File tree

11 files changed

+77
-17
lines changed

11 files changed

+77
-17
lines changed

configure.ac

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,16 @@ PKG_CHECK_MODULES([ZLIB],[zlib])
3131

3232
# Checks for header files.
3333
AC_CHECK_HEADERS([stdint.h stdlib.h string.h unistd.h wchar.h])
34+
35+
36+
AC_EGREP_CPP(yes,
37+
[#ifdef EMSCRIPTEN
38+
yes
39+
#endif
40+
],[],[
3441
AC_LANG_PUSH([C++])
3542
AC_CHECK_HEADERS([boost/foreach.hpp],[],[AC_MSG_ERROR(['boost' is required but it doesn't seem to be installed on this system.])])
36-
AC_LANG_POP([C++])
43+
AC_LANG_POP([C++])])
3744

3845
# Checks for typedefs, structures, and compiler characteristics.
3946
AC_C_BIGENDIAN

src/game_battle.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ void Game_Battle::Quit() {
6767

6868
Game_Temp::battle_running = false;
6969

70+
std::vector<Game_Battler*> allies;
71+
Main_Data::game_party->GetBattlers(allies);
72+
// Remove conditions which end after battle
73+
for (std::vector<Game_Battler*>::iterator it = allies.begin(); it != allies.end(); it++) {
74+
(*it)->RemoveBattleStates();
75+
}
76+
7077
Game_Message::SetPositionFixed(message_is_fixed);
7178
Game_Message::SetPosition(message_position);
7279
}

src/game_battler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,10 @@ void Game_Battler::RemoveState(int state_id) {
211211
}
212212

213213
static bool NonPermanent(int state_id) {
214-
return Data::states[state_id - 1].type == 0;
214+
return Data::states[state_id - 1].type == RPG::State::Persistence_ends;
215215
}
216216

217-
void Game_Battler::RemoveStates() {
217+
void Game_Battler::RemoveBattleStates() {
218218
std::vector<int16_t>& states = GetStates();
219219
std::vector<int16_t>::iterator end = std::remove_if(states.begin(), states.end(), NonPermanent);
220220
states.erase(end, states.end());

src/game_battler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ class Game_Battler {
254254
/**
255255
* Removes all states which end after battle.
256256
*/
257-
void RemoveStates();
257+
void RemoveBattleStates();
258258

259259
/**
260260
* Removes all states.

src/game_interpreter.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ void Game_Interpreter::Setup(const std::vector<RPG::EventCommand>& _list, int _e
105105
index = 0;
106106

107107
CancelMenuCall();
108+
109+
if (main_flag) {
110+
Game_Message::SetFaceName("");
111+
}
112+
108113
if (!updating)
109114
Update();
110115
}
@@ -384,6 +389,9 @@ void Game_Interpreter::InputButton() {
384389

385390
bool Game_Interpreter::CommandEnd() {
386391
CloseMessageWindow();
392+
if (main_flag) {
393+
Game_Message::SetFaceName("");
394+
}
387395

388396
// FIXME: Hangs in some cases when Autostart events start
389397
//if (main_flag) {

src/output.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,12 @@ void Output::ErrorStr(std::string const& err) {
193193
std::cout << err << std::endl;
194194
std::cout << std::endl;
195195
std::cout << "EasyRPG Player will close now.";
196-
#ifdef GEKKO
196+
#if defined (GEKKO)
197197
// Wii stdin is non-blocking
198198
sleep(5);
199+
#elif defined (EMSCRIPTEN)
200+
// Don't show JavaScript Window.prompt from stdin call
201+
std::cout << " Process finished.";
199202
#else
200203
std::cout << " Press any key..." << std::endl;
201204
std::cin.get();

src/platform/sdl_main.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#include "graphics.h"
2121
#include "input.h"
2222
#include "audio.h"
23-
2423
#include <cstdlib>
2524
#include <SDL.h>
2625

src/player.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
#include <dbghelp.h>
6666
static void InitMiniDumpWriter();
6767
#endif
68+
#ifdef EMSCRIPTEN
69+
#include <emscripten.h>
70+
#endif
6871

6972
namespace Player {
7073
bool exit_flag;
@@ -138,15 +141,32 @@ void Player::Run() {
138141
Graphics::FrameReset();
139142

140143
// Main loop
144+
#ifdef EMSCRIPTEN
145+
emscripten_set_main_loop(Player::MainLoop, 0, 0);
146+
#else
147+
Player::MainLoop();
148+
#endif
149+
150+
Player::Exit();
151+
}
152+
153+
void Player::MainLoop() {
154+
#ifdef EMSCRIPTEN
155+
if (Scene::instance->type == Scene::Null) {
156+
emscripten_cancel_main_loop();
157+
return;
158+
}
159+
#else
141160
while (Scene::instance->type != Scene::Null) {
161+
#endif
142162
Scene::instance->MainFunction();
143163
for (size_t i = 0; i < Scene::old_instances.size(); ++i) {
144164
Graphics::Pop();
145165
}
146166
Scene::old_instances.clear();
167+
#ifndef EMSCRIPTEN
147168
}
148-
149-
Player::Exit();
169+
#endif
150170
}
151171

152172
void Player::Pause() {

src/player.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ namespace Player {
4242
*/
4343
void Run();
4444

45+
/**
46+
* Runs the game loop.
47+
*/
48+
void MainLoop();
49+
4550
/**
4651
* Pauses the game engine.
4752
*/

src/sdl_ui.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ uint32_t SdlUi::GetTicks() const {
162162
}
163163

164164
void SdlUi::Sleep(uint32_t time) {
165+
#ifndef EMSCRIPTEN
165166
SDL_Delay(time);
167+
#endif
166168
}
167169

168170
bool SdlUi::RequestVideoMode(int width, int height, bool fullscreen) {
@@ -648,19 +650,23 @@ void SdlUi::ProcessActiveEvent(SDL_Event &evnt) {
648650
// Filter SDL events with FilterUntilFocus until focus is
649651
// regained
650652
filtering_done = false;
651-
#if SDL_MAJOR_VERSION==1
653+
#ifndef EMSCRIPTEN
654+
# if SDL_MAJOR_VERSION==1
652655
SDL_SetEventFilter(&FilterUntilFocus);
653-
#else
656+
# else
654657
SDL_SetEventFilter(&FilterUntilFocus_SDL2, NULL);
658+
# endif
655659
#endif
656660

657661
SDL_WaitEvent(NULL);
658662

659-
#if SDL_MAJOR_VERSION==1
663+
#ifndef EMSCRIPTEN
664+
# if SDL_MAJOR_VERSION==1
660665
SDL_SetEventFilter(NULL);
661-
#else
666+
# else
662667
SDL_SetEventFilter(NULL, NULL);
663-
#endif
668+
# endif
669+
#endif
664670

665671
ShowCursor(last);
666672

0 commit comments

Comments
 (0)