Skip to content

Commit

Permalink
Maniac: Implement Erase Picture enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghabry committed Sep 9, 2021
1 parent 83788d7 commit b71338c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
44 changes: 37 additions & 7 deletions src/game_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2754,15 +2754,45 @@ bool Game_Interpreter::CommandErasePicture(lcf::rpg::EventCommand const& com) {
// Handling of RPG2k3 1.12 chunks
int id_type = com.parameters[1];

int max;
if (id_type < 2) {
pic_id = ValueOrVariable(id_type, pic_id);
max = pic_id;
} else {
max = com.parameters[2];
int pic_id_max;
switch (id_type) {
case 1:
// Erase single picture referenced by variable
pic_id = ValueOrVariable(Lookup_Variable, pic_id);
pic_id_max = pic_id;
break;
case 2:
// Erase [Arg0, Arg2]
pic_id_max = com.parameters[2];
break;
case 3:
// Erase [V[Arg0], V[Arg2]]
if (!Player::IsPatchManiac()) {
return true;
}
pic_id = ValueOrVariable(Lookup_Variable, pic_id);
pic_id_max = ValueOrVariable(Lookup_Variable, com.parameters[2]);
break;
case 4:
// Erase single picture referenced by variable indirect
if (!Player::IsPatchManiac()) {
return true;
}
pic_id = ValueOrVariable(Lookup_VariableIndirect, pic_id);
pic_id_max = pic_id;
break;
case 5:
// Erase all pictures
if (!Player::IsPatchManiac()) {
return true;
}
Main_Data::game_pictures->EraseAll();
return true;
default:
return true;
}

for (int i = pic_id; i <= max; ++i) {
for (int i = pic_id; i <= pic_id_max; ++i) {
if (i <= 0) {
Output::Error("ErasePicture: Requested invalid picture id ({})", i);
}
Expand Down
6 changes: 6 additions & 0 deletions src/game_pictures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,12 @@ void Game_Pictures::Erase(int id) {
}
}

void Game_Pictures::EraseAll() {
for (auto& pic: pictures) {
pic.Erase();
}
}

void Game_Pictures::RequestPictureSprite(Picture& pic) {
const auto& name = pic.data.name;
if (name.empty()) {
Expand Down
1 change: 1 addition & 0 deletions src/game_pictures.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class Game_Pictures {
void Show(int id, const ShowParams& params);
void Move(int id, const MoveParams& params);
void Erase(int id);
void EraseAll();

void Update(bool is_battle);

Expand Down

0 comments on commit b71338c

Please sign in to comment.