Skip to content

Commit

Permalink
fix getparam and setparam arg indices
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewdean authored and igorlira committed Aug 30, 2024
1 parent 8440500 commit c870752
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions vm-rust/src/player/bytecode/get_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,20 @@ impl GetSetBytecodeHandler {

pub fn get_param(ctx: &BytecodeHandlerContext) -> Result<HandlerExecutionResult, ScriptError> {
reserve_player_mut(|player| {
let param_number = player.get_ctx_current_bytecode(ctx).obj as usize;
let param_number = player.get_ctx_current_bytecode(ctx).obj as u32 / get_current_variable_multiplier(player, ctx);
let scope = player.scopes.get_mut(ctx.scope_ref).unwrap();
let result = scope.args.get(param_number).unwrap_or(&DatumRef::Void).clone();
let result = scope.args.get(param_number as usize).unwrap_or(&DatumRef::Void).clone();
scope.stack.push(result);
});
Ok(HandlerExecutionResult::Advance)
}

pub fn set_param(ctx: &BytecodeHandlerContext) -> Result<HandlerExecutionResult, ScriptError> {
reserve_player_mut(|player| {
let bytecode_obj = player.get_ctx_current_bytecode(ctx).obj as usize;
let bytecode_obj = player.get_ctx_current_bytecode(ctx).obj as u32 / get_current_variable_multiplier(player, ctx);
let scope = player.scopes.get_mut(ctx.scope_ref).unwrap();
let arg_count = scope.args.len();
let arg_index = bytecode_obj;
let arg_index = bytecode_obj as usize;
let value_ref = scope.stack.pop().unwrap();

if arg_index < scope.args.len() {
Expand Down

0 comments on commit c870752

Please sign in to comment.