1 /* Dungeon Master --- Adventure generator for GNU Guile
2 Copyright © 2019 Javier Sancho <jsf@jsancho.org>
4 Dungeon Master is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 Dungeon Master is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with Haunt. If not, see <http://www.gnu.org/licenses/>.
21 #include "generators.h"
26 SCM register_scene_generator(SCM name, SCM type, SCM proc)
28 SceneGenerator generator {scm_to_locale_string(name), scm_to_locale_string(type), proc };
29 register_generator(generator);
30 printf ("Register: %s (%s)\n", generator.name.c_str(), generator.type.c_str());
31 scm_call_1(proc, scm_from_int(-1));
32 return SCM_UNSPECIFIED;
35 void init_dungeon_master_module(void *unused)
37 scm_c_define_gsubr("register-scene-generator", 3, 0, 0, (scm_t_subr)register_scene_generator);
38 scm_c_export("register-scene-generator", NULL);
41 void scm_init_dungeon_master_module()
43 scm_c_define_module("dungeon-master", init_dungeon_master_module, NULL);
49 scm_init_dungeon_master_module();
51 std::set<std::string> paths = get_dm_paths();
58 for (const std::string &path : paths) {
59 mods_path = path + DIR_DELIM + "mods";
60 mods_dir = opendir(mods_path.c_str());
61 if (mods_dir != NULL) {
62 while (mod = readdir(mods_dir)) {
63 if (strcmp(mod->d_name, ".") != 0 && strcmp(mod->d_name, "..") != 0) {
64 mod_main = mods_path + DIR_DELIM + mod->d_name + DIR_DELIM + "main.scm";
65 scm_primitive_load(scm_from_locale_string(mod_main.c_str()));