Scene generators
authorJavier Sancho <jsf@jsancho.org>
Sun, 2 Jun 2019 17:36:27 +0000 (19:36 +0200)
committerJavier Sancho <jsf@jsancho.org>
Sun, 2 Jun 2019 17:36:27 +0000 (19:36 +0200)
mods/default/main.scm
src/Makefile.am
src/generators.h [new file with mode: 0644]
src/mods.cpp

index 7a64459f52d2908cfd6c4141e9ecdd46497001c1..9e518c2cfcd41fbdbfdca75ff846677ab86b092d 100644 (file)
@@ -31,4 +31,7 @@
     (display points)
     (newline)))
 
-(dm:register-generator "city-map-generator" city-map-generator)
+(dm:register-scene-generator
+  "Default city"
+  "city"
+  city-map-generator)
index e11bd0d47550850299750fc4fee31e2fde802e12..7ae7ce02384bd98771e82478fc177295187cf0ea 100644 (file)
@@ -1,4 +1,4 @@
 bin_PROGRAMS = $(top_builddir)/DungeonMaster
-__top_builddir__DungeonMaster_SOURCES = main.cpp mods.cpp paths.cpp
+__top_builddir__DungeonMaster_SOURCES = generators.cpp main.cpp mods.cpp paths.cpp
 __top_builddir__DungeonMaster_CPPFLAGS = @GUILE_CFLAGS@
 __top_builddir__DungeonMaster_LDFLAGS = @GUILE_LIBS@
diff --git a/src/generators.h b/src/generators.h
new file mode 100644 (file)
index 0000000..bf2f44f
--- /dev/null
@@ -0,0 +1,10 @@
+#include <libguile.h>
+
+struct SceneGenerator
+{
+  std::string name;
+  std::string type;
+  SCM proc;
+};
+
+int register_generator(SceneGenerator generator);
index fb65da3b071902bb0ac3664d29fd19148dbe0d38..63a3a8b3321af917d693764935d6f1686e109291 100644 (file)
@@ -1,20 +1,24 @@
 #include <dirent.h>
 #include <iostream>
 #include <libguile.h>
+#include "generators.h"
 #include "mods.h"
 #include "paths.h"
 
-SCM register_generator(SCM name, SCM proc)
+
+SCM register_scene_generator(SCM name, SCM type, SCM proc)
 {
-  printf ("Register: %s\n", scm_to_locale_string(name));
-  scm_call_1(proc, scm_from_int(-1));
+  SceneGenerator generator {scm_to_locale_string(name), scm_to_locale_string(type), proc };
+  register_generator(generator);
+  printf ("Register: %s (%s)\n", generator.name.c_str(), generator.type.c_str());
+  //scm_call_1(proc, scm_from_int(-1));
   return SCM_UNSPECIFIED;
 }
 
 void init_dungeon_master_module(void *unused)
 {
-  scm_c_define_gsubr("register-generator", 2, 0, 0, (scm_t_subr)register_generator);
-  scm_c_export("register-generator", NULL);
+  scm_c_define_gsubr("register-scene-generator", 3, 0, 0, (scm_t_subr)register_scene_generator);
+  scm_c_export("register-scene-generator", NULL);
 }
 
 void scm_init_dungeon_master_module()