fix ... in F_ARGS opcode assembly
This commit is contained in:
+11
-3
@@ -1895,6 +1895,15 @@ std::string assemble_quest_script(const std::string& text) {
|
||||
if (line_tokens.size() < 2) {
|
||||
throw runtime_error(string_printf("(line %zu) arguments required for %s", line_num, opcode_def->name));
|
||||
}
|
||||
strip_trailing_whitespace(line_tokens[1]);
|
||||
strip_leading_whitespace(line_tokens[1]);
|
||||
|
||||
if (starts_with(line_tokens[1], "...")) {
|
||||
if (!(opcode_def->flags & F_ARGS)) {
|
||||
throw runtime_error(string_printf("(line %zu) \'...\' can only be used with F_ARGS opcodes", line_num));
|
||||
}
|
||||
|
||||
} else { // Not "..."
|
||||
auto args = split_context(line_tokens[1], ',');
|
||||
if (args.size() != opcode_def->args.size()) {
|
||||
throw runtime_error(string_printf("(line %zu) incorrect argument count for %s", line_num, opcode_def->name));
|
||||
@@ -1948,9 +1957,7 @@ std::string assemble_quest_script(const std::string& text) {
|
||||
|
||||
if (opcode_def->flags & F_ARGS) {
|
||||
auto label_it = labels_by_name.find(arg);
|
||||
if (starts_with(line_tokens[1], "...")) {
|
||||
// Args were specified by preceding arg_push calls; nothing to do here
|
||||
} else if (arg.empty()) {
|
||||
if (arg.empty()) {
|
||||
throw runtime_error("argument is empty");
|
||||
} else if (label_it != labels_by_name.end()) {
|
||||
code_w.put_u8(0x4B); // arg_pushw
|
||||
@@ -2116,6 +2123,7 @@ std::string assemble_quest_script(const std::string& text) {
|
||||
throw runtime_error(string_printf("(arg %zu) %s", z + 1, e.what()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (opcode_def->flags & F_ARGS) {
|
||||
if ((opcode_def->opcode & 0xFF00) == 0x0000) {
|
||||
|
||||
Reference in New Issue
Block a user