63 lines
1.3 KiB
C++
Raw Normal View History

// http://www.apache.org/licenses/LICENSE-2.0
// Copyright 2014 Perttu Ahola <celeron55@gmail.com>
2014-09-29 09:15:18 +03:00
#include "core/log.h"
2014-09-16 22:42:47 +03:00
#include "interface/module.h"
#include "interface/module_info.h"
2014-09-16 23:14:04 +03:00
#include "interface/server.h"
2014-09-17 01:04:51 +03:00
#include "interface/event.h"
2014-09-29 09:15:18 +03:00
#include "loader/api.h"
#define MODULE "__loader"
// __loader.cpp
// Minimal loader-invoker for games
2014-09-16 22:42:47 +03:00
2014-09-17 01:04:51 +03:00
using interface::Event;
2014-09-17 02:18:03 +03:00
namespace __loader {
2014-09-16 23:14:04 +03:00
struct Module: public interface::Module
2014-09-16 22:42:47 +03:00
{
interface::Server *m_server;
Module(interface::Server *server):
interface::Module(MODULE),
m_server(server){}
2014-09-16 22:42:47 +03:00
~Module(){}
2014-09-17 14:53:06 +03:00
void init()
2014-09-16 23:14:04 +03:00
{
m_server->sub_event(this, Event::t("core:load_modules"));
2014-09-16 23:14:04 +03:00
}
2014-09-16 22:42:47 +03:00
2014-09-17 18:52:59 +03:00
void event(const Event::Type &type, const Event::Private *p)
2014-09-17 01:04:51 +03:00
{
EVENT_VOIDN("core:load_modules", on_load_modules)
2014-09-17 01:04:51 +03:00
}
2014-09-17 16:43:05 +03:00
void on_load_modules()
{
interface::ModuleInfo info;
info.name = "loader";
info.path = m_server->get_builtin_modules_path()+"/"+info.name;
bool ok = m_server->load_module(info);
2014-09-29 09:15:18 +03:00
if(!ok){
m_server->shutdown(1, "Error loading builtin/loader");
2014-09-29 09:15:18 +03:00
return;
2014-09-17 02:18:03 +03:00
}
loader::access(m_server, [&](loader::Interface *i){
2014-09-29 09:15:18 +03:00
i->activate();
});
}
2014-09-16 23:14:04 +03:00
};
extern "C" {
BUILDAT_EXPORT void* createModule___loader(interface::Server *server){
2014-09-17 02:18:03 +03:00
return (void*)(new Module(server));
}
2014-09-16 23:14:04 +03:00
}
2014-09-16 22:42:47 +03:00
}
2014-09-24 14:53:57 +03:00
// vim: set noet ts=4 sw=4: