#include "paths.h"
-SCM register_scene_generator(SCM name, SCM type, SCM proc)
+SCM register_scene_generator (SCM name, SCM type, SCM proc)
{
- 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));
+ 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)
+void init_dungeon_master_module (void *unused)
{
- scm_c_define_gsubr("register-scene-generator", 3, 0, 0, (scm_t_subr)register_scene_generator);
- scm_c_export("register-scene-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()
+void scm_init_dungeon_master_module ()
{
- scm_c_define_module("dungeon-master", init_dungeon_master_module, NULL);
+ scm_c_define_module ("dungeon-master", init_dungeon_master_module, NULL);
}
-void load_mods()
+void load_dmaster_mods ()
{
- scm_init_guile();
- scm_init_dungeon_master_module();
+ scm_init_guile ();
+ scm_init_dungeon_master_module ();
- std::set<std::string> paths = get_dm_paths();
+ std::set<std::string> paths = get_dmaster_paths ();
DIR* mods_dir;
struct dirent* mod;
std::string
mods_path,
mod_main;
- for (const std::string &path : paths) {
- mods_path = path + DIR_DELIM + "mods";
- mods_dir = opendir(mods_path.c_str());
- if (mods_dir != NULL) {
- while (mod = readdir(mods_dir)) {
- if (strcmp(mod->d_name, ".") != 0 && strcmp(mod->d_name, "..") != 0) {
- mod_main = mods_path + DIR_DELIM + mod->d_name + DIR_DELIM + "main.scm";
- scm_primitive_load(scm_from_locale_string(mod_main.c_str()));
- }
- }
+ for (const std::string &path : paths)
+ {
+ mods_path = path + PATH_DELIM + "mods";
+ mods_dir = opendir (mods_path.c_str ());
+ if (mods_dir != NULL)
+ {
+ while (mod = readdir (mods_dir))
+ {
+ if (strstr (mod->d_name, ".scm") != NULL) {
+ mod_main = mods_path + PATH_DELIM + mod->d_name;
+ scm_primitive_load (scm_from_locale_string (mod_main.c_str ()));
+ }
+ }
+ }
+ closedir (mods_dir);
}
- closedir(mods_dir);
- }
}
#include <unistd.h>
#include "paths.h"
-std::string get_exec_path()
+std::string get_exec_path ()
{
char pBuf[256];
- size_t len = sizeof(pBuf);
+ size_t len = sizeof (pBuf);
char szTmp[32];
- sprintf(szTmp, "/proc/%d/exe", getpid());
- int bytes = readlink(szTmp, pBuf, len);
+ sprintf (szTmp, "/proc/%d/exe", getpid ());
+ int bytes = readlink (szTmp, pBuf, len);
if (bytes > len - 1)
bytes = len - 1;
if (bytes >= 0)
pBuf[bytes] = '\0';
std::string exec_path = pBuf;
- return exec_path.substr(0, exec_path.rfind(PATH_DELIM) + 1);
+ return exec_path.substr (0, exec_path.rfind (PATH_DELIM) + 1);
}
-std::string get_home_path()
+std::string get_home_path ()
{
- return (std::string)getenv("HOME") + PATH_DELIM + "." + PROGRAM_NAME;
+ return (std::string) getenv ("HOME") + PATH_DELIM + "." + PROGRAM_NAME;
}
-std::set<std::string> get_data_paths() {
+std::set<std::string> get_dmaster_paths () {
std::set<std::string> paths;
- paths.insert(get_exec_path());
- paths.insert(DATA_PATH);
- paths.insert(get_home_path());
+ paths.insert (get_exec_path ());
+ paths.insert (DATA_PATH);
+ paths.insert (get_home_path ());
return paths;
}