From 5debe86536f66ddb74bc5d49aa17ef550d772ca4 Mon Sep 17 00:00:00 2001 From: Matthew Fioravante Date: Sat, 13 Apr 2019 11:39:44 -0400 Subject: [PATCH] Add ReserveSubcommandIndex() --- src/game_interpreter.cpp | 9 ++++++--- src/game_interpreter.h | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/game_interpreter.cpp b/src/game_interpreter.cpp index 9114d3caf16..e11420c9d7b 100644 --- a/src/game_interpreter.cpp +++ b/src/game_interpreter.cpp @@ -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); @@ -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 { diff --git a/src/game_interpreter.h b/src/game_interpreter.h index 2377e27459d..cddb66df7db 100644 --- a/src/game_interpreter.h +++ b/src/game_interpreter.h @@ -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;