diff --git a/robot.cpp b/robot.cpp index 08e82f5..caab3f8 100644 --- a/robot.cpp +++ b/robot.cpp @@ -36,6 +36,10 @@ static void emulate_robot(robot_code &code, robot_regs& r, char robot_id) { return; } + if (code.barrel_id >= BARRELS_COUNT) { + code.barrel_id = -1; + } + // приватизируем бочку if (code.barrel_id >= 0) { barrels[code.barrel_id].flags.robot = robot_id; @@ -46,7 +50,7 @@ static void emulate_robot(robot_code &code, robot_regs& r, char robot_id) { switch (code.code[code.PC] & (short)ROBOT_CMD_MASK) { case ROBOT_CMD_MOVE_TO_ZONE_code: // двигаемся в сторону цели - if (robot_move(r, (short)(cmd_arg & (~ROBOT_WITH_BARREL)), robot_id)) { + if (robot_move(r, (short)(cmd_arg & 0x7F), robot_id)) { code.PC++; } if (cmd_arg & ROBOT_WITH_BARREL && code.barrel_id >= 0) { @@ -81,7 +85,7 @@ static void emulate_robot(robot_code &code, robot_regs& r, char robot_id) { break; } barrels[code.barrel_id].flags.is_up = true; - r.mz.is_up = 1; + r.mz.is_up = true; } code.PC++; break; @@ -91,6 +95,10 @@ static void emulate_robot(robot_code &code, robot_regs& r, char robot_id) { if (code.barrel_id >= 0 && cmd_arg) { barrels[code.barrel_id].flags.is_up = false; r.mz.is_up = 0; + + if (r.dx.current_zone == ZONE_UNLOAD) { + barrels[code.barrel_id].flags.is_empty = true; + } } code.PC++; break; @@ -167,6 +175,11 @@ static void emulate_robot(robot_code &code, robot_regs& r, char robot_id) { void robot_main() { - emulate_robot(robot1_code, robot1, 1); - emulate_robot(robot2_code, robot2, 2); + if (hla_robot1_en) { + emulate_robot(robot1_code, robot1, 1); + } + + if (hla_robot2_en) { + emulate_robot(robot2_code, robot2, 2); + } }