2018-07-21 17:40:21 +02:00
|
|
|
/*
|
|
|
|
|
Copyright (C) 2018 Erik Ogenvik
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "CyPy_Server.h"
|
2018-10-31 21:38:35 +01:00
|
|
|
|
2018-07-22 19:47:35 +02:00
|
|
|
#include "CyPy_Entity.h"
|
|
|
|
|
#include "CyPy_Task.h"
|
|
|
|
|
#include "CyPy_World.h"
|
2018-07-24 23:00:06 +02:00
|
|
|
#include "CyPy_TerrainProperty.h"
|
2018-07-31 22:43:41 +02:00
|
|
|
#include "CyPy_UsageInstance.h"
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "CyPy_EntityProps.h"
|
2018-07-21 17:40:21 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
CyPy_Server::CyPy_Server() : ExtensionModule("server")
|
|
|
|
|
{
|
|
|
|
|
|
2018-07-22 19:47:35 +02:00
|
|
|
CyPy_Entity::init_type();
|
2018-11-03 16:43:33 +01:00
|
|
|
CyPy_EntityProps::init_type();
|
2018-07-22 19:47:35 +02:00
|
|
|
CyPy_Task::init_type();
|
|
|
|
|
CyPy_World::init_type();
|
2018-07-31 22:43:41 +02:00
|
|
|
|
2018-07-24 23:00:06 +02:00
|
|
|
CyPy_TerrainProperty::init_type();
|
2018-07-21 17:40:21 +02:00
|
|
|
|
2018-07-31 22:43:41 +02:00
|
|
|
CyPy_Usage::init_type();
|
|
|
|
|
CyPy_UsageInstance::init_type();
|
|
|
|
|
|
2018-07-21 17:40:21 +02:00
|
|
|
initialize("server");
|
|
|
|
|
|
|
|
|
|
Py::Dict d(moduleDictionary());
|
2018-07-22 19:47:35 +02:00
|
|
|
d["Thing"] = CyPy_Entity::type();
|
|
|
|
|
d["Task"] = CyPy_Task::type();
|
2018-07-21 17:40:21 +02:00
|
|
|
|
|
|
|
|
d["OPERATION_IGNORED"] = Py::Long(OPERATION_IGNORED);
|
|
|
|
|
d["OPERATION_HANDLED"] = Py::Long(OPERATION_HANDLED);
|
|
|
|
|
d["OPERATION_BLOCKED"] = Py::Long(OPERATION_BLOCKED);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2018-07-22 19:47:35 +02:00
|
|
|
|
|
|
|
|
void CyPy_Server::registerWorld(BaseWorld* world)
|
|
|
|
|
{
|
2018-10-31 21:38:35 +01:00
|
|
|
Py::Module server("server");
|
|
|
|
|
server.setAttr("world", CyPy_World::wrap(world));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string CyPy_Server::init()
|
|
|
|
|
{
|
|
|
|
|
PyImport_AppendInittab("server", []() {
|
|
|
|
|
static auto server = new CyPy_Server();
|
|
|
|
|
return server->module().ptr();
|
|
|
|
|
});
|
|
|
|
|
return "server";
|
2018-07-22 19:47:35 +02:00
|
|
|
}
|