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
|
2004-11-29 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.cpp,
common/BaseWorld.h, common/Burn.h, common/Chop.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Eat.h,
common/Generic.h, common/Load.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Save.h,
common/Setup.h, common/Tick.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/inheritance.cpp, common/inheritance.h,
common/log.cpp, common/log.h, common/op_switch.h, common/random.h,
common/serialno.h, common/system.cpp, common/system.h,
common/type_utils.h, common/types.h, common/utility.cpp,
common/utility.h: Update copyright dates in files as appropriate.
2004-11-29 21:42:00 +00:00
|
|
|
// Copyright (C) 2000-2003 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
|
2001-01-26 16:38:23 +00:00
|
|
|
|
2008-11-07 14:21:05 +00:00
|
|
|
// $Id$
|
2007-12-07 00:27:13 +00:00
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#endif
|
2006-10-26 00:48:00 +00:00
|
|
|
|
2000-08-13 20:36:18 +00:00
|
|
|
#include "log.h"
|
2002-07-14 21:04:50 +00:00
|
|
|
#include "globals.h"
|
2005-12-30 22:11:23 +00:00
|
|
|
#include "compose.hpp"
|
2000-08-13 20:36:18 +00:00
|
|
|
|
2002-07-14 21:04:50 +00:00
|
|
|
#include <iostream>
|
2005-12-30 22:11:23 +00:00
|
|
|
#include <fstream>
|
2000-08-13 20:36:18 +00:00
|
|
|
|
2008-04-28 Al Riddoch <alriddoch@googlemail.com>
* common/Database.cpp, common/globals.cpp, common/id.cpp,
common/log.cpp, modules/DateTime.cpp, rulesets/Container.h,
rulesets/Statistics.h, server/CommListener.cpp,
server/CommServer.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp:
Add includes required for recent compilers which include less
stuff implicitly in standard headers.
2008-04-28 17:26:08 +00:00
|
|
|
#include <cstring>
|
2009-09-17 02:24:22 +01:00
|
|
|
#include <ctime>
|
2008-04-28 Al Riddoch <alriddoch@googlemail.com>
* common/Database.cpp, common/globals.cpp, common/id.cpp,
common/log.cpp, modules/DateTime.cpp, rulesets/Container.h,
rulesets/Statistics.h, server/CommListener.cpp,
server/CommServer.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp:
Add includes required for recent compilers which include less
stuff implicitly in standard headers.
2008-04-28 17:26:08 +00:00
|
|
|
|
2002-07-14 21:04:50 +00:00
|
|
|
extern "C" {
|
2006-11-02 02:02:41 +00:00
|
|
|
#ifdef HAVE_SYSLOG_H
|
2002-07-14 21:04:50 +00:00
|
|
|
#include <syslog.h>
|
2006-11-02 02:02:41 +00:00
|
|
|
#endif // HAVE_SYSLOG_H
|
2004-12-05 21:39:20 +00:00
|
|
|
#include <errno.h>
|
2000-08-13 20:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
2007-03-19 16:17:06 +00:00
|
|
|
#ifndef _WIN32
|
2009-01-27 18:38:28 +00:00
|
|
|
static const char * TIME_FORMAT = "%FT%T";
|
2007-03-19 16:17:06 +00:00
|
|
|
#else
|
2009-01-27 18:38:28 +00:00
|
|
|
static const char * TIME_FORMAT = "%Y-%m-%dT%H:%M:%S";
|
2007-03-19 16:17:06 +00:00
|
|
|
#endif
|
|
|
|
|
|
2005-12-30 22:11:23 +00:00
|
|
|
static void logDate(std::ostream & log_stream)
|
2005-12-30 20:35:51 +00:00
|
|
|
{
|
2006-11-02 02:02:41 +00:00
|
|
|
struct tm * local_time;
|
2005-12-30 20:35:51 +00:00
|
|
|
const time_t now = time(NULL);
|
|
|
|
|
|
2006-11-02 02:02:41 +00:00
|
|
|
#ifdef HAVE_LOCALTIME_R
|
|
|
|
|
|
|
|
|
|
struct tm local_time_buffer;
|
|
|
|
|
|
2007-12-07 00:27:13 +00:00
|
|
|
local_time = &local_time_buffer;
|
2006-11-02 02:02:41 +00:00
|
|
|
|
2007-12-07 00:27:13 +00:00
|
|
|
if (localtime_r(&now, local_time) != local_time) {
|
2006-01-11 02:36:16 +00:00
|
|
|
log_stream << "[TIME_ERROR]";
|
2005-12-30 20:35:51 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2006-11-02 02:02:41 +00:00
|
|
|
#else // HAVE_LOCALTIME_R
|
|
|
|
|
local_time = localtime(&now);
|
|
|
|
|
#endif // HAVE_LOCALTIME_R
|
2005-12-30 20:35:51 +00:00
|
|
|
|
2006-11-02 02:02:41 +00:00
|
|
|
char buf[256];
|
2012-01-30 15:14:05 +00:00
|
|
|
size_t count = strftime(buf, sizeof(buf) / sizeof(char), TIME_FORMAT, local_time);
|
2005-12-30 20:35:51 +00:00
|
|
|
|
|
|
|
|
if (count == 0) {
|
2006-01-11 02:36:16 +00:00
|
|
|
log_stream << "[TIME_ERROR]";
|
2005-12-30 20:35:51 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2005-12-30 22:11:23 +00:00
|
|
|
log_stream << buf;
|
2005-12-30 20:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
2005-12-30 22:11:23 +00:00
|
|
|
static std::ofstream event_log;
|
|
|
|
|
|
2006-09-24 23:10:08 +00:00
|
|
|
static void open_event_log()
|
2000-08-13 20:36:18 +00:00
|
|
|
{
|
2005-12-30 22:11:23 +00:00
|
|
|
std::string event_log_file = var_directory + "/tmp/cyphesis_event.log";
|
|
|
|
|
|
|
|
|
|
event_log.open(event_log_file.c_str(), std::ios::out | std::ios::app);
|
|
|
|
|
|
|
|
|
|
if (!event_log.is_open()) {
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
log(ERROR, String::compose("Unable to open event log file \"%1\"",
|
|
|
|
|
event_log_file));
|
2005-12-30 22:11:23 +00:00
|
|
|
logSysError(ERROR);
|
|
|
|
|
}
|
2000-08-13 20:36:18 +00:00
|
|
|
}
|
|
|
|
|
|
2007-04-22 22:14:09 +00:00
|
|
|
bool testEventLog(const char * path)
|
|
|
|
|
{
|
|
|
|
|
event_log.open(path, std::ios::out);
|
2007-09-22 15:05:34 +00:00
|
|
|
return event_log.is_open();
|
2007-04-22 22:14:09 +00:00
|
|
|
}
|
|
|
|
|
|
2006-09-24 23:10:08 +00:00
|
|
|
void initLogger()
|
|
|
|
|
{
|
2006-11-02 02:02:41 +00:00
|
|
|
#ifdef HAVE_SYSLOG
|
2007-12-07 00:27:13 +00:00
|
|
|
std::string ident = String::compose("Cyphesis{%1}", instance);
|
2006-09-24 23:10:08 +00:00
|
|
|
if (daemon_flag) {
|
2007-12-07 00:27:13 +00:00
|
|
|
openlog(strdup(ident.c_str()), LOG_PID, LOG_DAEMON);
|
2006-09-24 23:10:08 +00:00
|
|
|
}
|
2006-11-02 02:02:41 +00:00
|
|
|
#endif // HAVE_SYSLOG
|
2006-09-24 23:10:08 +00:00
|
|
|
|
|
|
|
|
open_event_log();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void rotateLogger()
|
|
|
|
|
{
|
|
|
|
|
if (event_log.is_open()) {
|
|
|
|
|
event_log.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
open_event_log();
|
|
|
|
|
}
|
|
|
|
|
|
2009-12-08 12:25:58 +00:00
|
|
|
std::ostream & operator<<(std::ostream & s, LogLevel lvl)
|
|
|
|
|
{
|
|
|
|
|
switch (lvl) {
|
|
|
|
|
case INFO:
|
|
|
|
|
s << "INFO";
|
|
|
|
|
break;
|
|
|
|
|
case SCRIPT:
|
|
|
|
|
s << "SCRIPT";
|
|
|
|
|
break;
|
|
|
|
|
case NOTICE:
|
|
|
|
|
s << "NOTICE";
|
|
|
|
|
break;
|
|
|
|
|
case WARNING:
|
|
|
|
|
s << "WARNING";
|
|
|
|
|
break;
|
|
|
|
|
case ERROR:
|
|
|
|
|
s << "ERROR";
|
|
|
|
|
break;
|
|
|
|
|
case SCRIPT_ERROR:
|
|
|
|
|
s << "SCRIPT_ERROR";
|
|
|
|
|
break;
|
|
|
|
|
case CRITICAL:
|
|
|
|
|
s << "CRITICAL";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
s << "UNKNOWN";
|
|
|
|
|
break;
|
|
|
|
|
};
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h: Switch to taking a C++ string reference
rather than a char *, as it is not really an optimisation, and it
makes the code simpler to read and write.
* client/BaseClient.cpp, client/ClientConnection.cpp,
common/AtlasFileLoader.cpp, common/BaseEntity.cpp,
common/Database.cpp, common/globals.cpp, common/id.cpp,
common/inheritance.cpp, common/log.cpp, common/log.h,
rulesets/Character.cpp, rulesets/Creator.cpp, rulesets/Entity.cpp,
rulesets/MemMap.cpp, rulesets/Motion.cpp, rulesets/Pedestrian.cpp,
rulesets/Py_Object.cpp, rulesets/Py_RootEntity.cpp,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Python_API.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/ArithmeticFactory.cpp,
server/CommClient.cpp, server/CommListener.cpp,
server/CommMDNSPublisher.cpp, server/CommServer.cpp,
server/Connection.cpp, server/EntityFactory.cpp,
server/Persistance.cpp, server/Restoration.cpp,
server/ScriptFactory.cpp, server/TaskFactory.cpp,
server/WorldRouter.cpp, server/server.cpp: Convert over to using
new API correctly.
* data/mason.xml: Add biomass and transient to fircone, making its
script obsolete:
2007-07-29 03:33:33 +00:00
|
|
|
void log(LogLevel lvl, const std::string & msg)
|
2000-08-13 20:36:18 +00:00
|
|
|
{
|
2006-11-02 02:02:41 +00:00
|
|
|
#ifdef HAVE_SYSLOG
|
2002-07-14 21:04:50 +00:00
|
|
|
if (daemon_flag) {
|
|
|
|
|
int type;
|
|
|
|
|
switch (lvl) {
|
2003-08-30 11:41:58 +00:00
|
|
|
case SCRIPT:
|
2002-07-14 21:04:50 +00:00
|
|
|
case INFO:
|
|
|
|
|
type = LOG_INFO;
|
|
|
|
|
break;
|
|
|
|
|
case NOTICE:
|
|
|
|
|
type = LOG_NOTICE;
|
|
|
|
|
break;
|
|
|
|
|
case WARNING:
|
|
|
|
|
type = LOG_WARNING;
|
|
|
|
|
break;
|
2003-08-30 11:41:58 +00:00
|
|
|
case SCRIPT_ERROR:
|
2002-07-14 21:04:50 +00:00
|
|
|
case ERROR:
|
|
|
|
|
type = LOG_ERR;
|
|
|
|
|
break;
|
|
|
|
|
case CRITICAL:
|
|
|
|
|
type = LOG_CRIT;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
type = LOG_CRIT;
|
|
|
|
|
break;
|
|
|
|
|
};
|
2008-11-07 14:21:05 +00:00
|
|
|
syslog(type, "%s", msg.c_str());
|
2002-07-14 21:04:50 +00:00
|
|
|
} else {
|
2006-11-02 02:02:41 +00:00
|
|
|
#else // HAVE_SYSLOG
|
|
|
|
|
{
|
|
|
|
|
#endif // HAVE_SYSLOG
|
|
|
|
|
|
2005-12-30 22:11:23 +00:00
|
|
|
logDate(std::cerr);
|
2009-12-08 12:25:58 +00:00
|
|
|
std::cerr << " " << lvl << " " << msg << std::endl << std::flush;
|
2000-08-13 20:36:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
2004-12-05 21:24:21 +00:00
|
|
|
|
2009-10-19 08:57:06 +01:00
|
|
|
void log_formatted(LogLevel lvl, const std::string & msg)
|
|
|
|
|
{
|
|
|
|
|
std::string::size_type s = 0;
|
|
|
|
|
std::string::size_type p = msg.find('\n');
|
|
|
|
|
do {
|
|
|
|
|
log(lvl, msg.substr(s, p - s));
|
|
|
|
|
s = p + 1;
|
|
|
|
|
p = msg.find('\n', s);
|
|
|
|
|
} while (p != std::string::npos);
|
2009-10-19 20:01:04 +01:00
|
|
|
|
|
|
|
|
// If the last line is not terminated with a newline, print it.
|
|
|
|
|
if (s < msg.size()) {
|
|
|
|
|
log(lvl, msg.substr(s));
|
|
|
|
|
}
|
2009-10-19 08:57:06 +01:00
|
|
|
}
|
|
|
|
|
|
2007-07-29 Al Riddoch <alriddoch@zepler.org>
* common/log.cpp, common/log.h, common/BaseEntity.cpp,
common/BaseEntity.h: Switch to taking a C++ string reference rather
than a char *, for the rest of the logging and error related
calls.
* common/Database.cpp, common/log.cpp, common/log.h,
rulesets/PythonMindScript.cpp, server/Account.cpp,
server/Admin.cpp, server/Connection.cpp, server/Player.cpp,
tools/cyisoload.cpp: Convert over to using the new API correctly.
2007-07-29 12:22:58 +00:00
|
|
|
void logEvent(LogEvent lev, const std::string & msg)
|
2005-12-30 22:11:23 +00:00
|
|
|
{
|
|
|
|
|
if (!event_log.is_open()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2008-04-29 15:33:58 +00:00
|
|
|
const char * type;
|
2005-12-30 22:11:23 +00:00
|
|
|
switch (lev) {
|
|
|
|
|
case START:
|
|
|
|
|
type = "START";
|
|
|
|
|
break;
|
|
|
|
|
case STOP:
|
|
|
|
|
type = "STOP";
|
|
|
|
|
break;
|
|
|
|
|
case CONNECT:
|
|
|
|
|
type = "CONNECT";
|
|
|
|
|
break;
|
|
|
|
|
case DISCONNECT:
|
|
|
|
|
type = "DISCONNECT";
|
|
|
|
|
break;
|
|
|
|
|
case LOGIN:
|
|
|
|
|
type = "LOGIN";
|
|
|
|
|
break;
|
|
|
|
|
case LOGOUT:
|
|
|
|
|
type = "LOGOUT";
|
|
|
|
|
break;
|
|
|
|
|
case TAKE_CHAR:
|
|
|
|
|
type = "TAKE_CHAR";
|
|
|
|
|
break;
|
|
|
|
|
case DROP_CHAR:
|
|
|
|
|
type = "DROP_CHAR";
|
|
|
|
|
break;
|
2010-11-30 20:44:16 +00:00
|
|
|
case EXPORT_ENT:
|
|
|
|
|
type = "EXPORT_ENT";
|
|
|
|
|
break;
|
|
|
|
|
case IMPORT_ENT:
|
|
|
|
|
type = "IMPORT_ENT";
|
|
|
|
|
break;
|
|
|
|
|
case POSSESS_CHAR:
|
|
|
|
|
type = "POSSESS_CHAR";
|
|
|
|
|
break;
|
2005-12-30 22:11:23 +00:00
|
|
|
default:
|
|
|
|
|
type = "UNKNOWN";
|
|
|
|
|
break;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
logDate(event_log);
|
2010-11-30 21:42:11 +00:00
|
|
|
event_log << " " << instance << " " << type << " " << msg
|
|
|
|
|
<< std::endl << std::flush;
|
2005-12-30 22:11:23 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-05 21:24:21 +00:00
|
|
|
void logSysError(LogLevel lvl)
|
|
|
|
|
{
|
|
|
|
|
char * err = strerror(errno);
|
|
|
|
|
if (err != NULL) {
|
|
|
|
|
log(lvl, err);
|
|
|
|
|
} else {
|
|
|
|
|
log(ERROR, "Error getting error message from system.");
|
|
|
|
|
}
|
|
|
|
|
}
|