commit dd49fee77cf0e9109de6b8b9f087a6be14ac1be1
parent c60256ea518d42ca0a2247b3c229becf58efaa1a
Author: bsandro <email@bsandro.tech>
Date: Fri, 21 Aug 2026 08:41:16 +0300
commands are variadic functions now
Diffstat:
8 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/commands/CREATE_MAP.c b/commands/CREATE_MAP.c
@@ -1,5 +1,5 @@
#include "core/command.h"
-void cmd_create_map() {
+void cmd_create_map(World *w, ...) {
puts("create map");
}
diff --git a/commands/MARCH.c b/commands/MARCH.c
@@ -1,5 +1,5 @@
#include "core/command.h"
-void cmd_march() {
+void cmd_march(World *w, ...) {
puts("march");
}
diff --git a/commands/SPAWN_HUNTER.c b/commands/SPAWN_HUNTER.c
@@ -1,5 +1,5 @@
#include "core/command.h"
-void cmd_spawn_hunter() {
+void cmd_spawn_hunter(World *w, ...) {
puts("spawn hunter");
}
diff --git a/commands/SPAWN_SWORDSMAN.c b/commands/SPAWN_SWORDSMAN.c
@@ -1,5 +1,5 @@
#include "core/command.h"
-void cmd_spawn_swordsman() {
+void cmd_spawn_swordsman(World *w, ...) {
puts("spawn swordsman");
}
diff --git a/core/command.h b/core/command.h
@@ -1,8 +1,9 @@
#pragma once
#include <stdio.h>
+#include "core/world.h"
-typedef void Command_Func(void);
+typedef void Command_Func(World *w, ...);
typedef struct Command {
const char *name;
diff --git a/core/map.h b/core/map.h
@@ -1,3 +1,5 @@
+#pragma once
+
typedef struct Map {
int w;
int h;
diff --git a/core/world.h b/core/world.h
@@ -1,3 +1,5 @@
+#pragma once
+
#include "map.h"
typedef struct World {
diff --git a/main.c b/main.c
@@ -11,10 +11,11 @@ int main(int argc, char **argv) {
if (argc>1) {
for (int i=0;i<COMMANDS_COUNT;++i) {
if (strcmp(COMMANDS[i].name, argv[1])==0) {
- COMMANDS[i].func();
+ COMMANDS[i].func(&w, "ehlo");
break;
}
}
+ puts("unknown command");
}
return 0;
}