Skip to content

Commit

Permalink
Merge pull request #796 from Ghabry/development
Browse files Browse the repository at this point in the history
Crash fixes + ATB
  • Loading branch information
fdelapena committed Mar 6, 2016
2 parents 1270b2c + 506c31a commit 1130586
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 26 deletions.
12 changes: 4 additions & 8 deletions src/audio_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ void SdlAudio::BGM_Pause() {
// Midi pause is not supported... (for some systems -.-)
#if SDL_MAJOR_VERSION>1
// SDL2_mixer bug, see above
Mix_MusicType mtype = Mix_GetMusicType(bgm.get());
if (mtype == MUS_WAV || mtype == MUS_OGG) {
if (bgs_playing) {
BGS_Pause();
return;
}
Expand All @@ -217,8 +216,7 @@ void SdlAudio::BGM_Pause() {
void SdlAudio::BGM_Resume() {
#if SDL_MAJOR_VERSION>1
// SDL2_mixer bug, see above
Mix_MusicType mtype = Mix_GetMusicType(bgm.get());
if (mtype == MUS_WAV || mtype == MUS_OGG) {
if (bgs_playing) {
BGS_Resume();
return;
}
Expand All @@ -229,8 +227,7 @@ void SdlAudio::BGM_Resume() {
void SdlAudio::BGM_Stop() {
#if SDL_MAJOR_VERSION>1
// SDL2_mixer bug, see above
Mix_MusicType mtype = Mix_GetMusicType(bgm.get());
if (mtype == MUS_WAV || mtype == MUS_OGG) {
if (bgs_playing) {
BGS_Stop();
return;
}
Expand Down Expand Up @@ -269,8 +266,7 @@ void SdlAudio::BGM_Fade(int fade) {

#if SDL_MAJOR_VERSION>1
// SDL2_mixer bug, see above
Mix_MusicType mtype = Mix_GetMusicType(bgm.get());
if (mtype == MUS_WAV || mtype == MUS_OGG) {
if (bgs_playing) {
BGS_Fade(fade);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/game_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ bool Game_Interpreter::CommandFlashScreen(RPG::EventCommand const& com) { // cod
int tenths = com.parameters[4];
bool wait = com.parameters[5] != 0;

if (Player::IsRPG2k()) {
if (com.parameters.size() <= 6) {
screen->FlashOnce(r, g, b, s, tenths);
if (wait)
SetupWait(tenths);
Expand Down
12 changes: 8 additions & 4 deletions src/game_interpreter_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1831,12 +1831,16 @@ bool Game_Interpreter_Map::CommandOpenLoadMenu(RPG::EventCommand const& com) {
}

bool Game_Interpreter_Map::CommandExitGame(RPG::EventCommand const& com) {
Player::exit_flag = true;
if (Scene::Find(Scene::GameBrowser)) {
Scene::PopUntil(Scene::GameBrowser);
} else {
Player::exit_flag = true;
}
return true;
}

bool Game_Interpreter_Map::CommandToggleAtbMode(RPG::EventCommand const& com) {
Output::Warning("Command Toggle ATB mode not supported");
Main_Data::game_data.system.atb_mode = !Main_Data::game_data.system.atb_mode;
return true;
}

Expand Down Expand Up @@ -2017,8 +2021,8 @@ bool Game_Interpreter_Map::CommandConditionalBranch(RPG::EventCommand const& com
result = Player::debug_flag;
break;
case 2:
// Is ATB wait?
Output::Warning("Branch: Is ATB wait not implemented");
// Is ATB wait on?
result = Main_Data::game_data.system.atb_mode == RPG::SaveSystem::AtbMode_atb_wait;
break;
case 3:
// Is Fullscreen active?
Expand Down
2 changes: 0 additions & 2 deletions src/game_temp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ int Game_Temp::battle_escape_mode;
int Game_Temp::battle_defeat_mode;
bool Game_Temp::battle_first_strike;
int Game_Temp::battle_result;
bool Game_Temp::battle_wait;

void Game_Temp::Init() {
menu_calling = false;
Expand Down Expand Up @@ -81,5 +80,4 @@ void Game_Temp::Init() {
battle_escape_mode = -1;
battle_defeat_mode = 0;
battle_first_strike = false;
battle_wait = false;
}
2 changes: 0 additions & 2 deletions src/game_temp.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <string>
#include "game_battler.h"
#include "graphics.h"
#include "rpg_music.h"

/**
* Game Temp static class.
Expand Down Expand Up @@ -75,7 +74,6 @@ class Game_Temp {
static int battle_defeat_mode;
static bool battle_first_strike;
static int battle_result;
static bool battle_wait;

enum BattleResult {
BattleVictory,
Expand Down
1 change: 0 additions & 1 deletion src/scene_end.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ void Scene_End::Update() {
switch (command_window->GetIndex()) {
case 0: // Yes
Audio().BGM_Fade(800);
Audio().BGS_Fade(800);
Scene::PopUntil(Scene::Title);
break;
case 1: // No
Expand Down
4 changes: 3 additions & 1 deletion src/scene_gamebrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "player.h"
#include "scene_title.h"
#include "bitmap.h"
#include "audio.h"

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
Expand All @@ -46,6 +47,7 @@ void Scene_GameBrowser::Continue() {
#ifdef _WIN32
SetCurrentDirectory(L"..");
#endif
Audio().BGM_Fade(800);

Main_Data::SetProjectPath(browser_dir);

Expand Down Expand Up @@ -168,7 +170,7 @@ void Scene_GameBrowser::BootGame() {

if (browser_dir.empty())
browser_dir = Main_Data::GetProjectPath();
Main_Data::SetProjectPath(gamelist_window->GetGamePath());
Main_Data::SetProjectPath(path);

EASYRPG_SHARED_PTR<FileFinder::DirectoryTree> tree = FileFinder::CreateDirectoryTree(path);
FileFinder::SetDirectoryTree(tree);
Expand Down
7 changes: 4 additions & 3 deletions src/scene_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void Scene_Menu::CreateCommandWindow() {
options.push_back(Data::terms.order);
break;
case Wait:
options.push_back(Game_Temp::battle_wait ? Data::terms.wait_on : Data::terms.wait_off);
options.push_back(Main_Data::game_data.system.atb_mode == RPG::SaveSystem::AtbMode_atb_wait ? Data::terms.wait_on : Data::terms.wait_off);
break;
default:
options.push_back(Data::terms.menu_quit);
Expand Down Expand Up @@ -197,8 +197,9 @@ void Scene_Menu::UpdateCommand() {
break;
case Wait:
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));
Game_Temp::battle_wait = !Game_Temp::battle_wait;
command_window->SetItemText(menu_index, Game_Temp::battle_wait ? Data::terms.wait_on : Data::terms.wait_off);
Main_Data::game_data.system.atb_mode = !Main_Data::game_data.system.atb_mode;
command_window->SetItemText(menu_index,
Main_Data::game_data.system.atb_mode == RPG::SaveSystem::AtbMode_atb_wait ? Data::terms.wait_on : Data::terms.wait_off);
break;
case Quit:
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));
Expand Down
2 changes: 0 additions & 2 deletions src/scene_title.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ void Scene_Title::Continue() {
// Fade out all audio and clear the cache when the game returns to the
// title screen e.g. by pressing F12
Audio().BGM_Fade(800);
Audio().BGS_Fade(800);

Cache::Clear();

Expand Down Expand Up @@ -200,7 +199,6 @@ void Scene_Title::CommandContinue() {

void Scene_Title::CommandShutdown() {
Game_System::SePlay(Game_System::GetSystemSE(Game_System::SFX_Decision));
Audio().BGS_Fade(800);
Graphics::Transition(Graphics::TransitionFadeOut, 32, true);
Scene::Pop();
}
Expand Down
4 changes: 2 additions & 2 deletions src/window_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ void Window_Base::DrawActorState(Game_Battler* actor, int cx, int cy) {
std::vector<int16_t> states = actor->GetStates();

// Unit has Normal state if no state is set
if (states.size() == 0) {
const RPG::State* state = actor->GetSignificantState();
if (!state) {
contents->TextDraw(cx, cy, Font::ColorDefault, Data::terms.normal_status);
} else {
const RPG::State* state = actor->GetSignificantState();
contents->TextDraw(cx, cy, state->color, state->name);
}
}
Expand Down

0 comments on commit 1130586

Please sign in to comment.