2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
2003-03-11 19:48:57 +00:00
|
|
|
// Copyright (C) 2000,2001 Alistair Riddoch
|
2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
//
|
|
|
|
|
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-03-11 19:48:57 +00:00
|
|
|
|
2006-10-26 00:48:00 +00:00
|
|
|
|
2004-12-16 02:12:39 +00:00
|
|
|
#include "CommMaster.h"
|
2009-01-28 02:48:34 +00:00
|
|
|
#include "Master.h"
|
2003-03-11 19:48:57 +00:00
|
|
|
#include "ServerRouting.h"
|
2009-03-12 00:50:25 +00:00
|
|
|
#include "EntityBuilder.h"
|
2009-03-24 03:08:45 +00:00
|
|
|
#include "Persistence.h"
|
2003-03-11 19:48:57 +00:00
|
|
|
#include "WorldRouter.h"
|
|
|
|
|
|
2018-11-03 16:43:33 +01:00
|
|
|
#include "rules/python/Python_API.h"
|
2018-10-31 21:38:35 +01:00
|
|
|
#include "rules/ai/MindFactory.h"
|
2003-03-11 19:48:57 +00:00
|
|
|
|
|
|
|
|
#include "common/log.h"
|
|
|
|
|
#include "common/debug.h"
|
|
|
|
|
#include "common/globals.h"
|
2009-03-20 15:31:38 +00:00
|
|
|
#include "common/Inheritance.h"
|
2003-03-11 19:48:57 +00:00
|
|
|
#include "common/system.h"
|
2009-01-28 02:48:34 +00:00
|
|
|
#include "common/compose.hpp"
|
2003-03-11 19:48:57 +00:00
|
|
|
|
2006-01-04 15:06:46 +00:00
|
|
|
#include <varconf/config.h>
|
2003-03-11 19:48:57 +00:00
|
|
|
|
2009-01-28 02:48:34 +00:00
|
|
|
class SlaveClientConnection;
|
|
|
|
|
|
2003-03-11 19:48:57 +00:00
|
|
|
static const bool debug_flag = false;
|
|
|
|
|
|
|
|
|
|
int main(int argc, char ** argv)
|
|
|
|
|
{
|
|
|
|
|
interactive_signals();
|
|
|
|
|
|
2004-10-03 13:55:54 +00:00
|
|
|
if (loadConfig(argc, argv, true) < 0) {
|
2003-03-11 19:48:57 +00:00
|
|
|
// Fatal error loading config file
|
|
|
|
|
return EXIT_CONFIG_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (daemon_flag) {
|
|
|
|
|
int pid = daemonise();
|
|
|
|
|
if (pid == -1) {
|
|
|
|
|
return EXIT_FORK_ERROR;
|
|
|
|
|
} else if (pid > 0) {
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If we are a daemon logging to syslog, we need to set it up.
|
|
|
|
|
initLogger();
|
|
|
|
|
|
|
|
|
|
// Initialise the persistance subsystem. If we have been built with
|
|
|
|
|
// database support, this will open the various databases used to
|
|
|
|
|
// store server data.
|
2009-01-28 02:48:34 +00:00
|
|
|
if (database_flag) {
|
2009-03-24 03:08:45 +00:00
|
|
|
Persistence * p = Persistence::instance();
|
2009-01-28 02:48:34 +00:00
|
|
|
int dbstatus = p->init();
|
|
|
|
|
if (dbstatus < 0) {
|
|
|
|
|
database_flag = false;
|
|
|
|
|
log(ERROR, "Error opening database. Database disabled.");
|
|
|
|
|
if (dbstatus == DATABASE_TABERR) {
|
|
|
|
|
log(INFO, "Database connection established, "
|
|
|
|
|
"but unable to create required tables.");
|
|
|
|
|
log(INFO, "Please ensure that any obsolete database "
|
|
|
|
|
"tables have been removed.");
|
|
|
|
|
} else {
|
|
|
|
|
log(INFO, "Unable to connect to the RDBMS.");
|
|
|
|
|
log(INFO, "Please ensure that the RDBMS is running, "
|
|
|
|
|
"the cyphesis database exists and is accessible "
|
|
|
|
|
"to the user running cyphesis.");
|
|
|
|
|
}
|
|
|
|
|
log(INFO, String::compose("To disable this message please run:\n\n"
|
|
|
|
|
" cyconfig --%1:usedatabase=false\n\n"
|
|
|
|
|
"to permanently disable database usage.",
|
|
|
|
|
instance));
|
|
|
|
|
}
|
2003-03-11 19:48:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If the restricted flag is set in the config file, then we
|
|
|
|
|
// don't allow connecting users to create accounts. Accounts must
|
|
|
|
|
// be created manually by the server administrator.
|
2007-11-05 19:24:50 +00:00
|
|
|
if (readConfigItem("cyphesis","restricted", restricted_flag) == 0) {
|
2003-03-11 19:48:57 +00:00
|
|
|
if (restricted_flag) {
|
|
|
|
|
log(INFO, "Setting restricted mode.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-11-05 19:24:50 +00:00
|
|
|
readConfigItem("cyphesis","inittime", timeoffset);
|
2003-03-11 19:48:57 +00:00
|
|
|
|
|
|
|
|
std::string mserver("metaserver.worldforge.org");
|
2007-11-05 19:24:50 +00:00
|
|
|
readConfigItem("cyphesis", "metaserver", mserver);
|
2003-03-11 19:48:57 +00:00
|
|
|
|
|
|
|
|
std::string serverName;
|
2007-11-05 19:24:50 +00:00
|
|
|
if (readConfigItem("cyphesis","servername", serverName) != 0) {
|
2003-03-11 19:48:57 +00:00
|
|
|
serverName = get_hostname();
|
|
|
|
|
}
|
2004-12-16 02:12:39 +00:00
|
|
|
|
|
|
|
|
std::string serverHostname("localhost");
|
2007-11-05 19:24:50 +00:00
|
|
|
readConfigItem("slave","server", serverHostname);
|
2003-03-11 19:48:57 +00:00
|
|
|
|
|
|
|
|
// Start up the python subsystem.
|
|
|
|
|
init_python_api();
|
|
|
|
|
|
|
|
|
|
{ // scope for CommServer
|
|
|
|
|
|
|
|
|
|
// Create commserver instance that will handle connections from clients.
|
|
|
|
|
// The commserver will create the other server related objects, and the
|
|
|
|
|
// world object pair (World + WorldRouter), and initialise the admin
|
|
|
|
|
// account. The primary ruleset name is passed in so it
|
|
|
|
|
// can be stored and queried by clients.
|
|
|
|
|
WorldRouter world;
|
|
|
|
|
|
2005-12-10 17:44:40 +00:00
|
|
|
// This ID is currently generated every time, but should perhaps be
|
|
|
|
|
// persistent in future.
|
|
|
|
|
std::string server_id, lobby_id;
|
2006-05-07 00:10:10 +00:00
|
|
|
long int_id, lobby_int_id;
|
|
|
|
|
|
|
|
|
|
if (((int_id = newId(server_id)) < 0) ||
|
|
|
|
|
((lobby_int_id = newId(lobby_id)) < 0)) {
|
|
|
|
|
log(CRITICAL, "Unable to get server IDs from Database");
|
|
|
|
|
return EXIT_DATABASE_ERROR;
|
|
|
|
|
}
|
2005-12-10 17:44:40 +00:00
|
|
|
|
2007-11-05 19:24:50 +00:00
|
|
|
ServerRouting server(world, ruleset, serverName,
|
2005-12-10 17:44:40 +00:00
|
|
|
server_id, int_id,
|
|
|
|
|
lobby_id, lobby_int_id);
|
2003-03-11 19:48:57 +00:00
|
|
|
|
|
|
|
|
CommServer commServer(server);
|
|
|
|
|
|
|
|
|
|
// This is where we should restore the database, before
|
|
|
|
|
// the listen sockets are open. Unlike earlier code, we are
|
|
|
|
|
// attempting to construct the internal state from the database,
|
|
|
|
|
// not creating a new world using the contents of the database as a
|
|
|
|
|
// template
|
|
|
|
|
|
2009-01-28 02:48:34 +00:00
|
|
|
CommUnixListener * listener = new CommUnixListener(commServer,
|
|
|
|
|
*new CommClientFactory<SlaveClientConnection>());
|
2004-12-16 00:52:09 +00:00
|
|
|
if (listener->setup(slave_socket_name) != 0) {
|
2003-03-11 19:48:57 +00:00
|
|
|
log(ERROR, "Could not create listen socket. Init failed.");
|
|
|
|
|
return EXIT_SOCKET_ERROR;
|
|
|
|
|
}
|
2004-12-15 23:37:24 +00:00
|
|
|
commServer.addSocket(listener);
|
2003-03-11 19:48:57 +00:00
|
|
|
|
2005-12-10 17:44:40 +00:00
|
|
|
std::string master_id;
|
2006-05-07 00:10:10 +00:00
|
|
|
if (newId(master_id) < 0) {
|
|
|
|
|
log(CRITICAL, "Unable to get master ID from Database");
|
|
|
|
|
return EXIT_DATABASE_ERROR;
|
|
|
|
|
}
|
2005-12-10 17:44:40 +00:00
|
|
|
|
2009-01-28 02:48:34 +00:00
|
|
|
CommMaster * master = new CommMaster(commServer);
|
2004-12-16 02:12:39 +00:00
|
|
|
if (master->connect(serverHostname) != 0) {
|
|
|
|
|
log(ERROR, "Could not connect to master. Init failed.");
|
|
|
|
|
return EXIT_SOCKET_ERROR;
|
|
|
|
|
}
|
2009-01-28 02:48:34 +00:00
|
|
|
master->setup(new Master(*master, commServer.m_server, master_id));
|
2004-12-16 02:12:39 +00:00
|
|
|
commServer.addSocket(master);
|
|
|
|
|
|
2003-03-11 19:48:57 +00:00
|
|
|
log(INFO, "Running");
|
|
|
|
|
|
|
|
|
|
// Inform things that want to know that we are running.
|
|
|
|
|
running();
|
|
|
|
|
|
|
|
|
|
// Loop until the exit flag is set. The exit flag can be set anywhere in
|
|
|
|
|
// the code easily.
|
|
|
|
|
while (!exit_flag) {
|
|
|
|
|
try {
|
2004-12-15 23:37:24 +00:00
|
|
|
commServer.poll();
|
2003-03-11 19:48:57 +00:00
|
|
|
}
|
|
|
|
|
catch (...) {
|
|
|
|
|
// It is hoped that commonly thrown exception, particularly
|
|
|
|
|
// exceptions that can be caused by external influences
|
|
|
|
|
// should be caught close to where they are thrown. If
|
|
|
|
|
// an exception makes it here then it should be debugged.
|
|
|
|
|
log(ERROR, "Exception caught in main()");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// exit flag has been set so we close down the databases, and indicate
|
|
|
|
|
// to the metaserver (if we are using one) that this server is going down.
|
|
|
|
|
// It is assumed that any preparation for the shutdown that is required
|
|
|
|
|
// by the game has been done before exit flag was set.
|
|
|
|
|
log(NOTICE, "Performing clean shutdown...");
|
|
|
|
|
|
|
|
|
|
} // close scope of CommServer, which cause the destruction of the
|
|
|
|
|
// server and world objects, and the entire world contents
|
|
|
|
|
|
2018-05-16 11:21:07 +02:00
|
|
|
Persistence::instance().shutdown();
|
2003-03-11 19:48:57 +00:00
|
|
|
|
2018-08-04 01:12:45 +02:00
|
|
|
EntityBuilder::instance().flushFactories();
|
2009-01-28 02:48:34 +00:00
|
|
|
EntityBuilder::del();
|
2003-03-11 19:48:57 +00:00
|
|
|
MindFactory::del();
|
|
|
|
|
|
|
|
|
|
Inheritance::clear();
|
|
|
|
|
|
|
|
|
|
// Shutdown the python interpretter. This frees lots of memory, and if
|
|
|
|
|
// the malloc heap is in any way corrupt, a segfault is likely to
|
|
|
|
|
// occur at this point. Previous occassions where pointers have been
|
|
|
|
|
// deleted twice elsewhere in the code, have resulted in a segfault
|
|
|
|
|
// at this point. AlRiddoch 10th November 2001
|
|
|
|
|
shutdown_python_api();
|
|
|
|
|
|
|
|
|
|
delete global_conf;
|
|
|
|
|
|
|
|
|
|
log(INFO, "Clean shutdown complete.");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|