From: Javier Sancho Date: Sun, 2 Jun 2019 17:36:27 +0000 (+0200) Subject: Scene generators X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=fbd191437dc6e137521891bcddf0e75731f026fe;p=dungeon-master.git Scene generators --- diff --git a/mods/default/main.scm b/mods/default/main.scm index 7a64459..9e518c2 100644 --- a/mods/default/main.scm +++ b/mods/default/main.scm @@ -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) diff --git a/src/Makefile.am b/src/Makefile.am index e11bd0d..7ae7ce0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 index 0000000..bf2f44f --- /dev/null +++ b/src/generators.h @@ -0,0 +1,10 @@ +#include + +struct SceneGenerator +{ + std::string name; + std::string type; + SCM proc; +}; + +int register_generator(SceneGenerator generator); diff --git a/src/mods.cpp b/src/mods.cpp index fb65da3..63a3a8b 100644 --- a/src/mods.cpp +++ b/src/mods.cpp @@ -1,20 +1,24 @@ #include #include #include +#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()