Skip to content

Commit

Permalink
Merge pull request #3253 from agentswap/refine
Browse files Browse the repository at this point in the history
Refactor: Always check isMessageActive() at the beginning in game_Int…
  • Loading branch information
fdelapena authored Sep 1, 2024
2 parents 7bb57b9 + db86e37 commit fb5d659
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 32 deletions.
38 changes: 19 additions & 19 deletions src/game_interpreter_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,13 @@ bool Game_Interpreter_Map::CommandRecallToLocation(lcf::rpg::EventCommand const&
}

bool Game_Interpreter_Map::CommandEnemyEncounter(lcf::rpg::EventCommand const& com) { // code 10710
auto& frame = GetFrame();
auto& index = frame.current_command;

if (Game_Message::IsMessageActive()) {
return false;
}

auto& frame = GetFrame();
auto& index = frame.current_command;

BattleArgs args;

args.troop_id = ValueOrVariable(com.parameters[0], com.parameters[1]);
Expand Down Expand Up @@ -366,13 +366,13 @@ bool Game_Interpreter_Map::CommandEndBattle(lcf::rpg::EventCommand const& /* com
}

bool Game_Interpreter_Map::CommandOpenShop(lcf::rpg::EventCommand const& com) { // code 10720
auto& frame = GetFrame();
auto& index = frame.current_command;

if (Game_Message::IsMessageActive()) {
return false;
}

auto& frame = GetFrame();
auto& index = frame.current_command;

bool allow_buy = false;
bool allow_sell = false;

Expand All @@ -394,7 +394,7 @@ bool Game_Interpreter_Map::CommandOpenShop(lcf::rpg::EventCommand const& com) {
auto shop_type = com.parameters[1];

// Not used, but left here for documentation purposes
//bool has_shop_handlers = com.parameters[2] != 0;
// bool has_shop_handlers = com.parameters[2] != 0;

std::vector<int> goods;
for (auto it = com.parameters.begin() + 4; it < com.parameters.end(); ++it) {
Expand Down Expand Up @@ -544,13 +544,13 @@ bool Game_Interpreter_Map::CommandEndInn(lcf::rpg::EventCommand const& /* com */
}

bool Game_Interpreter_Map::CommandEnterHeroName(lcf::rpg::EventCommand const& com) { // code 10740
auto& frame = GetFrame();
auto& index = frame.current_command;

if (Game_Message::IsMessageActive()) {
return false;
}

auto& frame = GetFrame();
auto& index = frame.current_command;

auto actor_id = com.parameters[0];
auto charset = com.parameters[1];
auto use_default_name = com.parameters[2];
Expand Down Expand Up @@ -715,26 +715,26 @@ bool Game_Interpreter_Map::CommandPlayMovie(lcf::rpg::EventCommand const& com) {
}

bool Game_Interpreter_Map::CommandOpenSaveMenu(lcf::rpg::EventCommand const& /* com */) { // code 11910
auto& frame = GetFrame();
auto& index = frame.current_command;

if (Game_Message::IsMessageActive()) {
return false;
}

auto& frame = GetFrame();
auto& index = frame.current_command;

Scene::instance->SetRequestedScene(std::make_shared<Scene_Save>());
++index;
return false;
}

bool Game_Interpreter_Map::CommandOpenMainMenu(lcf::rpg::EventCommand const&) { // code 11950
auto& frame = GetFrame();
auto& index = frame.current_command;

if (Game_Message::IsMessageActive()) {
return false;
}

auto& frame = GetFrame();
auto& index = frame.current_command;

int subscreen_id = -1, actor_index = 0;
bool is_db_actor = false;

Expand All @@ -750,13 +750,13 @@ bool Game_Interpreter_Map::CommandOpenLoadMenu(lcf::rpg::EventCommand const& /*
return true;
}

auto& frame = GetFrame();
auto& index = frame.current_command;

if (Game_Message::IsMessageActive()) {
return false;
}

auto& frame = GetFrame();
auto& index = frame.current_command;

Scene::instance->SetRequestedScene(std::make_shared<Scene_Load>());
++index;
return false;
Expand Down
8 changes: 0 additions & 8 deletions src/game_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,14 +981,6 @@ int Game_Map::GetTerrainTag(int x, int y) {
return terrain_data[chip_index];
}

void Game_Map::GetEventsXY(std::vector<Game_Event*>& events, int x, int y) {
for (Game_Event& ev : GetEvents()) {
if (ev.IsInPosition(x, y) && ev.IsActive()) {
events.push_back(&ev);
}
}
}

Game_Event* Game_Map::GetEventAt(int x, int y, bool require_active) {
auto& events = GetEvents();
for (auto iter = events.rbegin(); iter != events.rend(); ++iter) {
Expand Down
2 changes: 0 additions & 2 deletions src/game_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,6 @@ namespace Game_Map {
*/
std::vector<Game_CommonEvent>& GetCommonEvents();

void GetEventsXY(std::vector<Game_Event*>& events, int x, int y);

/**
* @param x x position on the map
* @param y y position on the map
Expand Down
6 changes: 3 additions & 3 deletions src/tilemap_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,6 @@ void TilemapLayer::Draw(Bitmap& dst, uint8_t z_order, int render_ox, int render_
if (loop_h) map_x = mod(map_x, width);
if (loop_v) map_y = mod(map_y, height);

int map_draw_x = x * TILE_SIZE - mod_ox;
int map_draw_y = y * TILE_SIZE - mod_oy;

bool out_of_bounds =
map_x < 0 || map_x >= width ||
map_y < 0 || map_y >= height;
Expand All @@ -270,6 +267,9 @@ void TilemapLayer::Draw(Bitmap& dst, uint8_t z_order, int render_ox, int render_
continue;
}

int map_draw_x = x * TILE_SIZE - mod_ox;
int map_draw_y = y * TILE_SIZE - mod_oy;

// Get the tile data
TileData &tile = GetDataCache(map_x, map_y);

Expand Down

0 comments on commit fb5d659

Please sign in to comment.