]> git.lizzy.rs Git - nothing.git/commitdiff
(#507) Refactor show_goal
authorrexim <reximkut@gmail.com>
Sun, 18 Nov 2018 17:54:21 +0000 (00:54 +0700)
committerrexim <reximkut@gmail.com>
Sun, 18 Nov 2018 17:54:29 +0000 (00:54 +0700)
src/game/level_script.c

index 8a79b4efcd2f08df3af97e4438dda08be844c113..5e3d033e2222025f6caa4917327f835d51dc6e10 100644 (file)
@@ -35,21 +35,14 @@ show_goal(void *param, Gc *gc, struct Scope *scope, struct Expr args)
     assert(gc);
     assert(scope);
 
-    if (!list_p(args)) {
-        return wrong_argument_type(gc, "listp", args);
-    }
-
-    if (length_of_list(args) != 1) {
-        return wrong_number_of_arguments(gc, length_of_list(args));
-    }
+    Level * const level = (Level*)param;
+    const char *goal_id = NULL;
 
-    if (!string_p(CAR(args))) {
-        return wrong_argument_type(gc, "stringp", args);
+    struct EvalResult result = unpack_args(gc, "s", args, &goal_id);
+    if (result.is_error) {
+        return result;
     }
 
-    const char * const goal_id = CAR(args).atom->str;
-    Level * const level = (Level*)param;
-
     level_show_goal(level, goal_id);
 
     return eval_success(NIL(gc));