Skip to content

Commit

Permalink
Add ReserveSubcommandIndex()
Browse files Browse the repository at this point in the history
  • Loading branch information
mateofio committed Apr 13, 2019
1 parent bddbf04 commit 5debe86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/game_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ int Game_Interpreter::GetThisEventId() const {
return event_id;
}


void Game_Interpreter::SetSubcommandIndex(int indent, int idx) {
uint8_t& Game_Interpreter::ReserveSubcommandIndex(int indent) {
auto* frame = GetFrame();
assert(frame);

Expand All @@ -273,7 +272,11 @@ void Game_Interpreter::SetSubcommandIndex(int indent, int idx) {
// the array with uninitialized values.
path.resize(indent + 1, subcommand_sentinel);
}
path[indent] = idx;
return path[indent];
}

void Game_Interpreter::SetSubcommandIndex(int indent, int idx) {
ReserveSubcommandIndex(indent) = idx;
}

int Game_Interpreter::GetSubcommandIndex(int indent) const {
Expand Down
1 change: 1 addition & 0 deletions src/game_interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ class Game_Interpreter
void OnChangeSystemGraphicReady(FileRequestResult* result);

void SetSubcommandIndex(int indent, int idx);
uint8_t& ReserveSubcommandIndex(int indent);
int GetSubcommandIndex(int indent) const;

FileRequestBinding request_id;
Expand Down

0 comments on commit 5debe86

Please sign in to comment.