Skip to content
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

Refactor: Always check isMessageActive() at the beginning in game_Int… #3253

Merged
merged 3 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions src/game_interpreter_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,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 @@ -364,13 +364,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 @@ -392,7 +392,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 @@ -542,13 +542,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 @@ -713,26 +713,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 @@ -748,13 +748,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
Loading