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

CloneEvent fix #3357

Merged
merged 2 commits into from
Mar 25, 2025
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
5 changes: 4 additions & 1 deletion src/game_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,13 @@ bool Game_Map::CloneMapEvent(int src_map_id, int src_event_id, int target_x, int
}), new_event);

auto game_event = Game_Event(GetMapId(), &*insert_it);
game_event.data()->easyrpg_clone_event_id = source_event->ID;
game_event.data()->easyrpg_clone_map_id = src_map_id;

events.insert(
std::upper_bound(events.begin(), events.end(), game_event, [](const auto& e, const auto& e2) {
return e.GetId() < e2.GetId();
}), Game_Event(GetMapId(), &*insert_it));
}), std::move(game_event));

UpdateUnderlyingEventReferences();

Expand Down
12 changes: 7 additions & 5 deletions src/game_strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ std::string Game_Strings::FromFile(std::string_view filename, int encoding, bool
return file_content;
}

std::string_view Game_Strings::ToFile(Str_Params params, std::string filename, int encoding) {
bool Game_Strings::ToFile(Str_Params params, std::string filename, int encoding) {
std::string str = ToString(Get(params.string_id));

if (params.extract) {
Expand All @@ -242,13 +242,13 @@ std::string_view Game_Strings::ToFile(Str_Params params, std::string filename, i
if (!txt_out) {
if (!FileFinder::Save().MakeDirectory(txt_dir, false)) {
Output::Warning("Maniac String Op ToFile failed. Cannot create directory {}", txt_dir);
return {};
return false;
}

txt_out = FileFinder::Save().OpenOutputStream(filename);
if (!txt_out) {
Output::Warning("Maniac String Op ToFile failed. Cannot write to {}", filename);
return {};
return false;
}
}

Expand All @@ -262,7 +262,7 @@ std::string_view Game_Strings::ToFile(Str_Params params, std::string filename, i

AsyncHandler::SaveFilesystem();

return str;
return true;
}

std::string_view Game_Strings::PopLine(Str_Params params, int offset, int string_out_id) {
Expand Down Expand Up @@ -320,8 +320,10 @@ std::string_view Game_Strings::ExMatch(Str_Params params, std::string expr, int
if (string_out_id > 0) {
params.string_id = string_out_id;
Set(params, str_result);

return Get(params.string_id);
}
return str_result;
return {};
}

const Game_Strings::Strings_t& Game_Strings::RangeOp(Str_Params params, int string_id_1, std::string string, int op, int args[], Game_Variables& variables) {
Expand Down
2 changes: 1 addition & 1 deletion src/game_strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Game_Strings {
int InStr(Str_Params params, std::string search, int var_id, int begin, Game_Variables& variables) const;
int Split(Str_Params params, const std::string& delimiter, int string_out_id, int var_id, Game_Variables& variables);
static std::string FromFile(std::string_view filename, int encoding, bool& do_yield);
std::string_view ToFile(Str_Params params, std::string filename, int encoding);
bool ToFile(Str_Params params, std::string filename, int encoding);
std::string_view PopLine(Str_Params params, int offset, int string_out_id);
std::string_view ExMatch(Str_Params params, std::string expr, int var_id, int begin, int string_out_id, Game_Variables& variables);

Expand Down
Loading