Skip to content

Commit

Permalink
Spawn Map Event - Support renaming an event
Browse files Browse the repository at this point in the history
  • Loading branch information
jetrotal committed Jul 13, 2024
1 parent 3273425 commit df36ee0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/game_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5147,9 +5147,11 @@ bool Game_Interpreter::CommandSpawnMapEvent(lcf::rpg::EventCommand const& com) {
int target_y = ValueOrVariable(com.parameters[6], com.parameters[7]);
int target_event = ValueOrVariable(com.parameters[8], com.parameters[9]);

std::string target_name = ToString(Game_Interpreter::CommandStringOrVariable(com, 10, 11));

if (src_map == 0) src_map = Game_Map::GetMapId();

Game_Map::CloneMapEvent(src_map, src_event, target_x, target_y, target_event);
Game_Map::CloneMapEvent(src_map, src_event, target_x, target_y, target_event, target_name);
return true;
}

Expand Down
4 changes: 3 additions & 1 deletion src/game_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ void Game_Map::SetupCommon() {
CreateMapEvents();
}

bool Game_Map::CloneMapEvent(int src_map_id, int src_event_id, int target_x, int target_y, int target_event_id = 0) {
bool Game_Map::CloneMapEvent(int src_map_id, int src_event_id, int target_x, int target_y, int target_event_id = 0, std::string target_name = "") {
std::unique_ptr<lcf::rpg::Map> source_map;

if (src_map_id == GetMapId()) source_map = std::make_unique<lcf::rpg::Map>(GetMap());
Expand Down Expand Up @@ -387,6 +387,8 @@ bool Game_Map::CloneMapEvent(int src_map_id, int src_event_id, int target_x, int
new_event.x = target_x;
new_event.y = target_y;

if (!target_name.empty()) new_event.name = lcf::DBString(target_name);

map->events.push_back(new_event);

events.emplace_back(GetMapId(), &map->events.back());
Expand Down
2 changes: 1 addition & 1 deletion src/game_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ namespace Game_Map {
/** Disposes Game_Map. */
void Dispose();

bool CloneMapEvent(int src_map_id, int src_event_id, int target_x, int target_y, int target_event_id);
bool CloneMapEvent(int src_map_id, int src_event_id, int target_x, int target_y, int target_event_id, std::string target_name);
bool DestroyMapEvent(const int event_id);

void TranslateMapMessages(int mapId, lcf::rpg::Map& map);
Expand Down

0 comments on commit df36ee0

Please sign in to comment.