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

tile_num_in_direction can be called with either integer or pointer as the origin argument. Fixes #409 #410

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 12 additions & 2 deletions src/interpreter_extra.cc
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ static void opGiveExpPoints(Program* program)
int xp = programStackPopInteger(program);

if (pcAddExperience(xp) != 0) {
scriptError("\nScript Error: %s: op_give_exp_points: stat_pc_set failed");
scriptError("\nScript Error: %s: op_give_exp_points: stat_pc_set failed", program->name);
}
}

Expand Down Expand Up @@ -1537,9 +1537,19 @@ static void opGetTileInDirection(Program* program)
{
int distance = programStackPopInteger(program);
int rotation = programStackPopInteger(program);
int origin = programStackPopInteger(program);
ProgramValue originValue = programStackPopValue(program);

int tile = -1;
int origin = -1;

if (originValue.isInt()) {
origin = originValue.integerValue;
} else if (originValue.isPointer()) {
Object* object = static_cast<Object*>(originValue.pointerValue);
origin = object->tile;
} else {
scriptError("Script Error: %s: invalid arg %d to tile_num_in_direction", program->name, 0);
}

if (origin != -1) {
if (rotation < ROTATION_COUNT) {
Expand Down
Loading