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
|
2001-04-16 16:26:44 +00:00
|
|
|
// Copyright (C) 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
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2002-01-29 19:16:38 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-11-18 01:44:40 +00:00
|
|
|
#include "common/types.h"
|
2003-03-07 00:22:12 +00:00
|
|
|
#include "common/globals.h"
|
2002-07-14 21:04:50 +00:00
|
|
|
|
2005-11-19 12:27:06 +00:00
|
|
|
#include "common/Tick.h"
|
|
|
|
|
|
2001-03-16 11:38:14 +00:00
|
|
|
#include <Atlas/Objects/Encoder.h>
|
|
|
|
|
#include <Atlas/Net/Stream.h>
|
|
|
|
|
#include <Atlas/Objects/Decoder.h>
|
* client/ClientConnection.cpp, client/ClientConnection.h,
tools/cycmd.cpp: Switched to using skstream to completely handle
client socket connections.
* client/ClientConnection.cpp, client/ClientConnection.h,
common/log.cpp, rulesets/EntityFactory.h, rulesets/MemMap.h,
server/server.cpp, tools/cycmd.cpp: Removed unused includes.
* client/Py_CreatorClient.cpp, client/client.cpp,
client/define_world.cpp, 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_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/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, server/server.cpp:
Reorganised python header files so that each header includes
all the code relevant for a particular type. Tidied up
the type implementations. Added prototypes to init_python_api()
to the Python_API.h header, and removed other dependencies from
it.
Al Riddoch <alriddoch@zepler.org>
2001-10-19 11:35:07 +00:00
|
|
|
#include <Atlas/Codec.h>
|
2005-08-27 23:18:48 +00:00
|
|
|
#include <Atlas/Objects/Entity.h>
|
|
|
|
|
#include <Atlas/Objects/Anonymous.h>
|
|
|
|
|
#include <Atlas/Objects/Operation.h>
|
2001-04-02 22:03:42 +00:00
|
|
|
|
2006-01-04 15:06:46 +00:00
|
|
|
#include <varconf/config.h>
|
2004-10-05 14:57:11 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
#include "common/Monitor.h"
|
|
|
|
|
#include "common/Connect.h"
|
2006-08-09 00:04:17 +00:00
|
|
|
#include "common/compose.hpp"
|
2004-04-23 17:50:38 +00:00
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
#include <skstream/skstream_unix.h>
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2004-08-27 08:21:38 +00:00
|
|
|
#include <sigc++/connection.h>
|
2001-12-06 16:16:50 +00:00
|
|
|
|
2002-01-29 19:16:38 +00:00
|
|
|
#ifndef READLINE_CXX_SANE // defined in config.h
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
2006-08-09 00:04:17 +00:00
|
|
|
#define USE_VARARGS
|
|
|
|
|
#define PREFER_STDARG
|
2001-08-14 17:52:50 +00:00
|
|
|
#include <readline/readline.h>
|
|
|
|
|
#include <readline/history.h>
|
2002-01-29 19:16:38 +00:00
|
|
|
#ifndef READLINE_CXX_SANE
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2001-03-30 17:17:47 +00:00
|
|
|
|
2002-12-06 10:53:57 +00:00
|
|
|
#include <iostream>
|
2005-11-18 00:03:47 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
2002-12-06 10:53:57 +00:00
|
|
|
#include <cstdio>
|
|
|
|
|
|
2003-08-07 23:03:26 +00:00
|
|
|
using Atlas::Message::Element;
|
2004-08-17 Al Riddoch <alriddoch@zepler.org>
* tests/Areatest.cpp, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/Linetest.cpp, tests/Planttest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Thingtest.cpp, tests/Worldtest.cpp,
tests/inheritancetest.cpp, tests/utilitytest.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp, tools/cydbload.cpp, tools/cyisoload.cpp,
tools/cyloadrules.cpp, tools/cypasswd.cpp: Convert code to using
Atlas Message typedefs as found in Atlas-C++ 0.6 to aid
conversion later.
2004-08-17 13:23:28 +00:00
|
|
|
using Atlas::Message::MapType;
|
|
|
|
|
using Atlas::Message::ListType;
|
|
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
using Atlas::Objects::Root;
|
|
|
|
|
|
2002-12-06 10:53:57 +00:00
|
|
|
using Atlas::Objects::Operation::Appearance;
|
2005-06-25 08:37:23 +00:00
|
|
|
using Atlas::Objects::Operation::Create;
|
2005-11-19 04:18:55 +00:00
|
|
|
using Atlas::Objects::Operation::Delete;
|
2002-12-06 10:53:57 +00:00
|
|
|
using Atlas::Objects::Operation::Disappearance;
|
2001-04-02 22:03:42 +00:00
|
|
|
using Atlas::Objects::Operation::Get;
|
|
|
|
|
using Atlas::Objects::Operation::Set;
|
2002-07-26 16:47:39 +00:00
|
|
|
using Atlas::Objects::Operation::Look;
|
2005-08-27 23:18:48 +00:00
|
|
|
using Atlas::Objects::Operation::Login;
|
2002-07-26 16:47:39 +00:00
|
|
|
using Atlas::Objects::Operation::Logout;
|
2002-09-08 21:39:25 +00:00
|
|
|
using Atlas::Objects::Operation::Talk;
|
2005-11-19 12:27:06 +00:00
|
|
|
using Atlas::Objects::Operation::Tick;
|
2005-08-27 23:18:48 +00:00
|
|
|
using Atlas::Objects::Operation::RootOperation;
|
|
|
|
|
using Atlas::Objects::Entity::RootEntity;
|
|
|
|
|
using Atlas::Objects::Entity::Anonymous;
|
|
|
|
|
|
|
|
|
|
using Atlas::Objects::smart_dynamic_cast;
|
|
|
|
|
|
|
|
|
|
using Atlas::Objects::Operation::Monitor;
|
|
|
|
|
using Atlas::Objects::Operation::Connect;
|
2001-04-02 22:03:42 +00:00
|
|
|
|
2005-06-25 08:37:23 +00:00
|
|
|
struct command {
|
|
|
|
|
const char * cmd_string;
|
|
|
|
|
const char * cmd_description;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct command commands[] = {
|
2005-11-18 00:03:47 +00:00
|
|
|
{ "add_agent", "Create an in-game agent", },
|
2005-06-25 08:37:23 +00:00
|
|
|
{ "connect", "Connect server to a peer", },
|
2005-11-19 17:50:08 +00:00
|
|
|
{ "cancel", "Cancel the current admin task", },
|
2005-06-25 08:37:23 +00:00
|
|
|
{ "get", "Examine a class on the server", },
|
2005-11-18 00:03:47 +00:00
|
|
|
{ "find_by_name", "Find an entity with the given name", },
|
|
|
|
|
{ "find_by_type", "Find an entity with the given type", },
|
|
|
|
|
{ "flush", "Flush entities from the server", },
|
2005-06-25 08:37:23 +00:00
|
|
|
{ "help", "Display this help", },
|
|
|
|
|
{ "install", "Install a new type", },
|
|
|
|
|
{ "look", "Return the current server lobby", },
|
|
|
|
|
{ "logout", "Log user out of server", },
|
|
|
|
|
{ "monitor", "Enable in-game op monitoring", },
|
|
|
|
|
{ "query", "Examine an object on the server", },
|
|
|
|
|
{ "reload", "Reload the script for a type", },
|
|
|
|
|
{ "stat", "Return current server status", },
|
|
|
|
|
{ "unmonitor", "Disable in-game op monitoring", },
|
|
|
|
|
{ NULL, "Guard", }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
* tools/cydbload.cpp: Added parameter handling so any file can
be loaded into the database.
* tools/cycmd.cpp: Cleaned up usage and help functions.
* tools/cyisoload.cpp: Cleaned up usage(), and made sure build
completes okay if libraries are missing, and missing
functionality is reported to the user.
* server/server.cpp: Added config options that specifies that
the contents of the db should loaded on server startup. Cleaned
up some debug code.
* server/WorldTime.cpp, server/WorldRouter.cpp,
server/Connection.cpp, rulesets/Structure.h,
rulesets/Python_API.cpp, rulesets/Py_WorldTime.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp,
physics/Vector3D.h, common/persistance.cpp,
common/database.h, common/database.cpp: Removed output either
to debug mode, or removed altogether.
* common/BaseEntity.h, common/BaseEntity.cpp: Removed redundant header
includes.
* server/ServerRouting.cpp, common/persistance.h,
common/persistance.cpp: Modified admin account function names it
fit convention.
* module/Location.h: Fixed collision detection so that entities
with velocity set to 0 still get checked.
* rulesets/Entity.cpp, rulesets/Thing.cpp, rulesets/Character.cpp,
rulesets/BaseMind.cpp, rulesets/Creator.cpp,
rulesets/ExternalMind.cpp, rulesets/Food.cpp, rulesets/MemMap.cpp,
rulesets/Movement.cpp, rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Location.cpp, rulesets/Py_*.cpp, rulesets/World.cpp:
Removed unnecessary #includes.
Al Riddoch <alriddoch@zepler.org>
2001-06-04 11:22:27 +00:00
|
|
|
static void help()
|
2001-04-02 22:03:42 +00:00
|
|
|
{
|
2005-11-18 00:03:47 +00:00
|
|
|
size_t max_length = 0;
|
|
|
|
|
|
|
|
|
|
for (struct command * I = &commands[0]; I->cmd_string != NULL; ++I) {
|
|
|
|
|
max_length = std::max(max_length, strlen(I->cmd_string));
|
|
|
|
|
}
|
|
|
|
|
max_length += 2;
|
|
|
|
|
|
2001-08-14 17:52:50 +00:00
|
|
|
std::cout << "Cyphesis commands:" << std::endl << std::endl;
|
2005-11-17 11:21:14 +00:00
|
|
|
|
|
|
|
|
for (struct command * I = &commands[0]; I->cmd_string != NULL; ++I) {
|
|
|
|
|
std::cout << " " << I->cmd_string
|
2005-11-18 00:03:47 +00:00
|
|
|
<< std::string(max_length - strlen(I->cmd_string), ' ')
|
2005-11-17 11:21:14 +00:00
|
|
|
<< I->cmd_description << std::endl;
|
|
|
|
|
}
|
2002-11-01 12:12:01 +00:00
|
|
|
std::cout << std::endl << std::flush;
|
2001-04-02 22:03:42 +00:00
|
|
|
}
|
2001-03-16 14:27:58 +00:00
|
|
|
|
2005-11-18 01:44:40 +00:00
|
|
|
class AdminTask {
|
|
|
|
|
protected:
|
|
|
|
|
bool m_complete;
|
2005-11-19 04:18:55 +00:00
|
|
|
|
|
|
|
|
AdminTask() : m_complete(false) { }
|
2005-11-18 01:44:40 +00:00
|
|
|
public:
|
|
|
|
|
virtual ~AdminTask() { }
|
|
|
|
|
|
2005-11-19 04:18:55 +00:00
|
|
|
virtual void setup(const std::string & arg, OpVector &) = 0;
|
2005-11-18 01:44:40 +00:00
|
|
|
virtual void operation(const RootOperation &, OpVector &) = 0;
|
|
|
|
|
|
|
|
|
|
bool isComplete() const { return m_complete; }
|
|
|
|
|
};
|
|
|
|
|
|
2005-11-19 04:18:55 +00:00
|
|
|
class Flusher : public AdminTask {
|
|
|
|
|
protected:
|
|
|
|
|
const std::string agentId;
|
|
|
|
|
std::string type;
|
|
|
|
|
public:
|
|
|
|
|
explicit Flusher(const std::string & agent_id) : agentId(agent_id) { }
|
|
|
|
|
|
|
|
|
|
void setup(const std::string & arg, OpVector & ret) {
|
|
|
|
|
type = arg;
|
|
|
|
|
|
|
|
|
|
Look l;
|
|
|
|
|
|
|
|
|
|
Anonymous lmap;
|
|
|
|
|
lmap->setParents(std::list<std::string>(1, type));
|
|
|
|
|
l->setArgs1(lmap);
|
|
|
|
|
l->setFrom(agentId);
|
|
|
|
|
|
|
|
|
|
ret.push_back(l);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void operation(const RootOperation & op, OpVector & res) {
|
|
|
|
|
if (op->getClassNo() == Atlas::Objects::Operation::SIGHT_NO) {
|
2005-11-19 17:50:08 +00:00
|
|
|
// We have a sight op, check if its the sight of an entity we
|
|
|
|
|
// want to delete.
|
2005-11-19 04:18:55 +00:00
|
|
|
const std::vector<Root> & args = op->getArgs();
|
|
|
|
|
if (args.empty()) {
|
2005-11-19 17:50:08 +00:00
|
|
|
std::cerr << "Got empty sight" << std::endl << std::flush;
|
2005-11-19 04:18:55 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const Root & arg = args.front();
|
|
|
|
|
assert(arg.isValid());
|
|
|
|
|
RootEntity sight_ent = smart_dynamic_cast<RootEntity>(arg);
|
|
|
|
|
if (!sight_ent.isValid()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!sight_ent->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
|
2005-11-19 17:50:08 +00:00
|
|
|
std::cerr << "Got sight no ID" << std::endl << std::flush;
|
2005-11-19 04:18:55 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2005-11-19 12:27:06 +00:00
|
|
|
if (!sight_ent->hasAttrFlag(Atlas::Objects::PARENTS_FLAG)) {
|
2005-11-19 17:50:08 +00:00
|
|
|
std::cerr << "Got sight no PARENTS" << std::endl << std::flush;
|
2005-11-19 12:27:06 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (sight_ent->getParents().empty() ||
|
|
|
|
|
sight_ent->getParents().front() != type) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-11-19 04:18:55 +00:00
|
|
|
const std::string & id = sight_ent->getId();
|
|
|
|
|
|
2005-11-19 17:50:08 +00:00
|
|
|
std::cout << "Deleting: " << type << "(" << id << ")"
|
|
|
|
|
<< std::endl << std::flush;
|
2005-11-19 04:18:55 +00:00
|
|
|
|
|
|
|
|
Delete d;
|
|
|
|
|
|
|
|
|
|
Anonymous dmap;
|
|
|
|
|
dmap->setId(id);
|
|
|
|
|
d->setArgs1(dmap);
|
|
|
|
|
d->setFrom(agentId);
|
|
|
|
|
d->setTo(id);
|
|
|
|
|
|
|
|
|
|
res.push_back(d);
|
|
|
|
|
|
2005-11-19 12:27:06 +00:00
|
|
|
Tick t;
|
|
|
|
|
|
|
|
|
|
t->setFrom(agentId);
|
|
|
|
|
t->setTo(agentId);
|
|
|
|
|
t->setFutureSeconds(0.1);
|
|
|
|
|
t->setAttr("sub_to", "flusher");
|
|
|
|
|
|
|
|
|
|
res.push_back(t);
|
|
|
|
|
} else if (op->getParents().front() == "tick") {
|
2005-11-19 17:50:08 +00:00
|
|
|
// We have a tick op, check if its the one we sent ourselves
|
|
|
|
|
// to schedule the next look.
|
2005-11-19 12:27:06 +00:00
|
|
|
Element val;
|
|
|
|
|
if (op->copyAttr("sub_to", val) != 0 ||
|
|
|
|
|
!val.isString() || val.String() != "flusher") {
|
|
|
|
|
std::cout << "Not for us" << std::endl << std::flush;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-19 04:18:55 +00:00
|
|
|
Look l;
|
|
|
|
|
|
|
|
|
|
Anonymous lmap;
|
|
|
|
|
lmap->setParents(std::list<std::string>(1, type));
|
|
|
|
|
l->setArgs1(lmap);
|
|
|
|
|
l->setFrom(agentId);
|
|
|
|
|
|
|
|
|
|
res.push_back(l);
|
2005-11-19 17:50:08 +00:00
|
|
|
} else if (op->getParents().front() == "unseen") {
|
|
|
|
|
// We have an unseen op, which signals our last look returned
|
|
|
|
|
// no results.
|
|
|
|
|
m_complete = true;
|
2005-11-19 04:18:55 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2005-11-19 23:24:07 +00:00
|
|
|
class OperationMonitor : public AdminTask {
|
|
|
|
|
protected:
|
|
|
|
|
int op_count;
|
|
|
|
|
int start_time;
|
|
|
|
|
public:
|
|
|
|
|
int count() {
|
|
|
|
|
return op_count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int startTime() {
|
|
|
|
|
return start_time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void setup(const std::string & arg, OpVector &) {
|
|
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
|
start_time = tv.tv_sec;
|
|
|
|
|
op_count = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void operation(const RootOperation & op, OpVector &) {
|
|
|
|
|
++op_count;
|
|
|
|
|
std::cout << op->getParents().front() << "(from=\"" << op->getFrom()
|
|
|
|
|
<< "\",to=\"" << op->getTo() << "\")"
|
|
|
|
|
<< std::endl << std::flush;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
2006-02-18 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, common/BaseWorld.h, common/Property.h,
modules/Location.h, rulesets/Entity.cpp, rulesets/Entity.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Connection.cpp, server/Connection.h,
server/Persistor.cpp, server/Persistor.h, server/Persistor_impl.h,
tools/cycmd.cpp: Update usage of sigc++ to the native 2.0 API
rather than the deprecated compatability API. Eleminate the
manual disconnection code for deleted objects, as this is now
handled automatically by sigc::trackable.
2006-02-18 21:56:43 +00:00
|
|
|
class Interactive : public Atlas::Objects::ObjectsDecoder,
|
|
|
|
|
virtual public sigc::trackable
|
2001-03-16 11:38:14 +00:00
|
|
|
{
|
|
|
|
|
private:
|
2006-08-09 00:04:17 +00:00
|
|
|
bool error_flag, reply_flag, login_flag, avatar_flag, server_flag;
|
2001-03-16 11:38:14 +00:00
|
|
|
int cli_fd;
|
2005-08-27 23:18:48 +00:00
|
|
|
Atlas::Objects::ObjectsEncoder * encoder;
|
|
|
|
|
Atlas::Codec * codec;
|
2003-08-13 00:29:20 +00:00
|
|
|
Stream ios;
|
2001-03-22 11:12:38 +00:00
|
|
|
std::string password;
|
2002-12-06 10:53:57 +00:00
|
|
|
std::string username;
|
2006-08-09 00:04:17 +00:00
|
|
|
std::string accountType;
|
2002-07-26 16:47:39 +00:00
|
|
|
std::string accountId;
|
2005-06-25 08:37:23 +00:00
|
|
|
std::string agentId;
|
2006-08-09 00:04:17 +00:00
|
|
|
std::string agentName;
|
|
|
|
|
std::string serverName;
|
2006-08-10 13:35:40 +00:00
|
|
|
std::string systemType;
|
2006-08-09 00:04:17 +00:00
|
|
|
std::string prompt;
|
2002-12-06 10:53:57 +00:00
|
|
|
bool exit;
|
2005-11-18 01:44:40 +00:00
|
|
|
AdminTask * currentTask;
|
2002-05-03 15:00:01 +00:00
|
|
|
|
2005-12-14 17:16:21 +00:00
|
|
|
void output(const Element & item, int depth = 0);
|
2001-03-16 11:38:14 +00:00
|
|
|
protected:
|
2005-08-27 23:18:48 +00:00
|
|
|
|
|
|
|
|
void objectArrived(const Atlas::Objects::Root &);
|
|
|
|
|
|
|
|
|
|
void appearanceArrived(const RootOperation &);
|
|
|
|
|
void disappearanceArrived(const RootOperation &);
|
|
|
|
|
void infoArrived(const RootOperation &);
|
|
|
|
|
void errorArrived(const RootOperation &);
|
|
|
|
|
void sightArrived(const RootOperation &);
|
|
|
|
|
void soundArrived(const RootOperation &);
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
int negotiate();
|
2006-08-09 00:04:17 +00:00
|
|
|
void updatePrompt();
|
2001-03-16 11:38:14 +00:00
|
|
|
public:
|
2003-08-13 00:47:13 +00:00
|
|
|
Interactive() : error_flag(false), reply_flag(false), login_flag(false),
|
2006-08-09 00:04:17 +00:00
|
|
|
avatar_flag(false), server_flag(false), encoder(0),
|
|
|
|
|
codec(0), serverName("cyphesis"), prompt("cyphesis> "),
|
|
|
|
|
exit(false), currentTask(0)
|
2005-11-18 01:44:40 +00:00
|
|
|
{ }
|
2004-11-24 01:19:31 +00:00
|
|
|
~Interactive() {
|
|
|
|
|
if (encoder != 0) {
|
|
|
|
|
delete encoder;
|
|
|
|
|
}
|
|
|
|
|
if (codec != 0) {
|
|
|
|
|
delete codec;
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
void send(const RootOperation &);
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
int connect(const std::string & host);
|
|
|
|
|
int login();
|
2006-08-09 00:04:17 +00:00
|
|
|
int setup();
|
2001-06-09 18:46:27 +00:00
|
|
|
void exec(const std::string & cmd, const std::string & arg);
|
2001-03-16 11:38:14 +00:00
|
|
|
void loop();
|
2006-08-08 11:36:49 +00:00
|
|
|
void poll(bool rewrite_prompt = true);
|
2002-12-06 10:53:57 +00:00
|
|
|
void getLogin();
|
|
|
|
|
void runCommand(char *);
|
2005-11-19 04:18:55 +00:00
|
|
|
int runTask(AdminTask * task, const std::string & arg);
|
2005-11-19 17:50:08 +00:00
|
|
|
int endTask();
|
2001-10-06 16:52:02 +00:00
|
|
|
|
|
|
|
|
void setPassword(const std::string & passwd) {
|
|
|
|
|
password = passwd;
|
|
|
|
|
}
|
2002-12-06 10:53:57 +00:00
|
|
|
|
|
|
|
|
void setUsername(const std::string & uname) {
|
|
|
|
|
username = uname;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void gotCommand(char *);
|
2001-03-16 11:38:14 +00:00
|
|
|
};
|
|
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
2005-12-14 17:16:21 +00:00
|
|
|
void Interactive<Stream>::output(const Element & item, int depth)
|
2002-05-03 15:00:01 +00:00
|
|
|
{
|
2003-08-07 23:03:26 +00:00
|
|
|
switch (item.getType()) {
|
2004-08-17 Al Riddoch <alriddoch@zepler.org>
* tests/Areatest.cpp, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/Linetest.cpp, tests/Planttest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Thingtest.cpp, tests/Worldtest.cpp,
tests/inheritancetest.cpp, tests/utilitytest.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp, tools/cydbload.cpp, tools/cyisoload.cpp,
tools/cyloadrules.cpp, tools/cypasswd.cpp: Convert code to using
Atlas Message typedefs as found in Atlas-C++ 0.6 to aid
conversion later.
2004-08-17 13:23:28 +00:00
|
|
|
case Element::TYPE_INT:
|
2005-08-30 Al Riddoch <alriddoch@zepler.org>
* common/AtlasFileLoader.cpp, common/Database.cpp,
common/FormattedXMLWriter.cpp, common/Property.cpp,
common/accountbase.cpp, rulesets/Character.cpp,
rulesets/Entity_getLocation.h, rulesets/MemMap.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Object.cpp, rulesets/Thing.cpp,
server/Admin.cpp, server/Connection.cpp, server/EntityFactory.cpp,
server/WorldRouter.cpp, tools/AdminClient.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp: After an Element has been checked
with isFoo(), it is more efficient to get its value using Foo()
rather than asFoo() which repeats the check.
2005-08-30 20:43:19 +00:00
|
|
|
std::cout << item.Int();
|
2002-05-03 15:00:01 +00:00
|
|
|
break;
|
2004-08-17 Al Riddoch <alriddoch@zepler.org>
* tests/Areatest.cpp, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/Linetest.cpp, tests/Planttest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Thingtest.cpp, tests/Worldtest.cpp,
tests/inheritancetest.cpp, tests/utilitytest.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp, tools/cydbload.cpp, tools/cyisoload.cpp,
tools/cyloadrules.cpp, tools/cypasswd.cpp: Convert code to using
Atlas Message typedefs as found in Atlas-C++ 0.6 to aid
conversion later.
2004-08-17 13:23:28 +00:00
|
|
|
case Element::TYPE_FLOAT:
|
2005-08-30 Al Riddoch <alriddoch@zepler.org>
* common/AtlasFileLoader.cpp, common/Database.cpp,
common/FormattedXMLWriter.cpp, common/Property.cpp,
common/accountbase.cpp, rulesets/Character.cpp,
rulesets/Entity_getLocation.h, rulesets/MemMap.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Object.cpp, rulesets/Thing.cpp,
server/Admin.cpp, server/Connection.cpp, server/EntityFactory.cpp,
server/WorldRouter.cpp, tools/AdminClient.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp: After an Element has been checked
with isFoo(), it is more efficient to get its value using Foo()
rather than asFoo() which repeats the check.
2005-08-30 20:43:19 +00:00
|
|
|
std::cout << item.Float();
|
2002-05-03 15:00:01 +00:00
|
|
|
break;
|
2004-08-17 Al Riddoch <alriddoch@zepler.org>
* tests/Areatest.cpp, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/Linetest.cpp, tests/Planttest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Thingtest.cpp, tests/Worldtest.cpp,
tests/inheritancetest.cpp, tests/utilitytest.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp, tools/cydbload.cpp, tools/cyisoload.cpp,
tools/cyloadrules.cpp, tools/cypasswd.cpp: Convert code to using
Atlas Message typedefs as found in Atlas-C++ 0.6 to aid
conversion later.
2004-08-17 13:23:28 +00:00
|
|
|
case Element::TYPE_STRING:
|
2005-08-30 Al Riddoch <alriddoch@zepler.org>
* common/AtlasFileLoader.cpp, common/Database.cpp,
common/FormattedXMLWriter.cpp, common/Property.cpp,
common/accountbase.cpp, rulesets/Character.cpp,
rulesets/Entity_getLocation.h, rulesets/MemMap.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Object.cpp, rulesets/Thing.cpp,
server/Admin.cpp, server/Connection.cpp, server/EntityFactory.cpp,
server/WorldRouter.cpp, tools/AdminClient.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp: After an Element has been checked
with isFoo(), it is more efficient to get its value using Foo()
rather than asFoo() which repeats the check.
2005-08-30 20:43:19 +00:00
|
|
|
std::cout << "\"" << item.String() << "\"";
|
2002-05-03 15:00:01 +00:00
|
|
|
break;
|
2004-08-17 Al Riddoch <alriddoch@zepler.org>
* tests/Areatest.cpp, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/Linetest.cpp, tests/Planttest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Thingtest.cpp, tests/Worldtest.cpp,
tests/inheritancetest.cpp, tests/utilitytest.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp, tools/cydbload.cpp, tools/cyisoload.cpp,
tools/cyloadrules.cpp, tools/cypasswd.cpp: Convert code to using
Atlas Message typedefs as found in Atlas-C++ 0.6 to aid
conversion later.
2004-08-17 13:23:28 +00:00
|
|
|
case Element::TYPE_LIST:
|
2005-12-14 17:16:21 +00:00
|
|
|
{
|
2003-05-11 22:31:57 +00:00
|
|
|
std::cout << "[ ";
|
2005-08-30 Al Riddoch <alriddoch@zepler.org>
* common/AtlasFileLoader.cpp, common/Database.cpp,
common/FormattedXMLWriter.cpp, common/Property.cpp,
common/accountbase.cpp, rulesets/Character.cpp,
rulesets/Entity_getLocation.h, rulesets/MemMap.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Object.cpp, rulesets/Thing.cpp,
server/Admin.cpp, server/Connection.cpp, server/EntityFactory.cpp,
server/WorldRouter.cpp, tools/AdminClient.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp: After an Element has been checked
with isFoo(), it is more efficient to get its value using Foo()
rather than asFoo() which repeats the check.
2005-08-30 20:43:19 +00:00
|
|
|
ListType::const_iterator I = item.List().begin();
|
|
|
|
|
ListType::const_iterator Iend = item.List().end();
|
2004-11-06 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientConnection.cpp, client/BaseClient.cpp,
client/CharacterClient.cpp, client/ClientConnection.cpp,
common/Database.cpp, common/FormattedXMLWriter.cpp,
common/inheritance.cpp, common/refno.h, common/terrain_utils.cpp,
common/type_utils.h, common/utility.cpp, modules/WorldTime.cpp,
modules/WorldTime.h, physics/Collision.cpp, rulesets/Area.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Line.cpp, rulesets/MemMap.cpp, rulesets/MemMap_methods.h,
rulesets/Movement.cpp, rulesets/Plant.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/PythonMindScript.cpp,
rulesets/PythonThingScript.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/TerrainProperty.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/Account.cpp,
server/CommClient.cpp, server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp, server/Persistance.cpp,
server/Player.cpp, server/Restoration.cpp, server/ServerRouting.cpp,
server/WorldRouter.cpp, tests/EntityExerciser.h,
tests/IGEntityExerciser.h, tests/inheritancetest.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cydbload.cpp,
tools/cyloadrules.cpp:
Tweak for loops to avoid creating a temporary iterator each
iteration.
* tests/type_utilstest.cpp: New test for function which does
list conversions.
2004-11-06 20:36:03 +00:00
|
|
|
for(; I != Iend; ++I) {
|
2005-12-14 17:16:21 +00:00
|
|
|
output(*I, depth);
|
|
|
|
|
std::cout << " ";
|
2002-05-03 15:00:01 +00:00
|
|
|
}
|
2005-12-14 17:16:21 +00:00
|
|
|
std::cout << "]";
|
2002-05-03 15:00:01 +00:00
|
|
|
}
|
|
|
|
|
break;
|
2004-08-17 Al Riddoch <alriddoch@zepler.org>
* tests/Areatest.cpp, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/Linetest.cpp, tests/Planttest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Thingtest.cpp, tests/Worldtest.cpp,
tests/inheritancetest.cpp, tests/utilitytest.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp, tools/cydbload.cpp, tools/cyisoload.cpp,
tools/cyloadrules.cpp, tools/cypasswd.cpp: Convert code to using
Atlas Message typedefs as found in Atlas-C++ 0.6 to aid
conversion later.
2004-08-17 13:23:28 +00:00
|
|
|
case Element::TYPE_MAP:
|
2005-12-14 17:16:21 +00:00
|
|
|
{
|
|
|
|
|
std::cout << "{" << std::endl << std::flush;
|
2005-08-30 Al Riddoch <alriddoch@zepler.org>
* common/AtlasFileLoader.cpp, common/Database.cpp,
common/FormattedXMLWriter.cpp, common/Property.cpp,
common/accountbase.cpp, rulesets/Character.cpp,
rulesets/Entity_getLocation.h, rulesets/MemMap.cpp,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Object.cpp, rulesets/Thing.cpp,
server/Admin.cpp, server/Connection.cpp, server/EntityFactory.cpp,
server/WorldRouter.cpp, tools/AdminClient.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp: After an Element has been checked
with isFoo(), it is more efficient to get its value using Foo()
rather than asFoo() which repeats the check.
2005-08-30 20:43:19 +00:00
|
|
|
MapType::const_iterator I = item.Map().begin();
|
|
|
|
|
MapType::const_iterator Iend = item.Map().end();
|
2004-11-06 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientConnection.cpp, client/BaseClient.cpp,
client/CharacterClient.cpp, client/ClientConnection.cpp,
common/Database.cpp, common/FormattedXMLWriter.cpp,
common/inheritance.cpp, common/refno.h, common/terrain_utils.cpp,
common/type_utils.h, common/utility.cpp, modules/WorldTime.cpp,
modules/WorldTime.h, physics/Collision.cpp, rulesets/Area.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Line.cpp, rulesets/MemMap.cpp, rulesets/MemMap_methods.h,
rulesets/Movement.cpp, rulesets/Plant.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/PythonMindScript.cpp,
rulesets/PythonThingScript.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/TerrainProperty.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/Account.cpp,
server/CommClient.cpp, server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp, server/Persistance.cpp,
server/Player.cpp, server/Restoration.cpp, server/ServerRouting.cpp,
server/WorldRouter.cpp, tests/EntityExerciser.h,
tests/IGEntityExerciser.h, tests/inheritancetest.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cydbload.cpp,
tools/cyloadrules.cpp:
Tweak for loops to avoid creating a temporary iterator each
iteration.
* tests/type_utilstest.cpp: New test for function which does
list conversions.
2004-11-06 20:36:03 +00:00
|
|
|
for(; I != Iend; ++I) {
|
2005-12-14 17:16:21 +00:00
|
|
|
std::cout << std::string((depth + 1) * 4, ' ') << I->first << ": ";
|
|
|
|
|
output(I->second, depth + 1);
|
|
|
|
|
std::cout << std::endl;
|
2002-05-03 15:00:01 +00:00
|
|
|
}
|
2005-12-14 17:16:21 +00:00
|
|
|
std::cout << std::string(depth * 4, ' ') << "}";
|
2002-05-03 15:00:01 +00:00
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
std::cout << "(\?\?\?)";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
2005-08-27 23:18:48 +00:00
|
|
|
void Interactive<Stream>::objectArrived(const Atlas::Objects::Root & obj)
|
|
|
|
|
{
|
|
|
|
|
RootOperation op = Atlas::Objects::smart_dynamic_cast<RootOperation>(obj);
|
|
|
|
|
if (!op.isValid()) {
|
|
|
|
|
std::cerr << "Non op object received from client" << std::endl << std::flush;
|
2006-07-10 01:10:47 +00:00
|
|
|
if (!obj->isDefaultParents() && !obj->getParents().empty()) {
|
|
|
|
|
std::cerr << "NOTICE: Unexpected object has parent "
|
|
|
|
|
<< obj->getParents().front()
|
|
|
|
|
<< std::endl << std::flush;
|
|
|
|
|
}
|
|
|
|
|
if (!obj->isDefaultObjtype()) {
|
|
|
|
|
std::cerr << "NOTICE: Unexpected object has objtype "
|
|
|
|
|
<< obj->getObjtype()
|
|
|
|
|
<< std::endl << std::flush;
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-19 04:18:55 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentTask != 0) {
|
|
|
|
|
OpVector res;
|
|
|
|
|
currentTask->operation(op, res);
|
|
|
|
|
OpVector::const_iterator Iend = res.end();
|
|
|
|
|
for (OpVector::const_iterator I = res.begin(); I != Iend; ++I) {
|
|
|
|
|
encoder->streamObjectsMessage(*I);
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-19 11:42:01 +00:00
|
|
|
ios << std::flush;
|
|
|
|
|
|
2005-11-19 04:18:55 +00:00
|
|
|
if (currentTask->isComplete()) {
|
|
|
|
|
delete currentTask;
|
|
|
|
|
currentTask = 0;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (op->getClassNo()) {
|
|
|
|
|
case Atlas::Objects::Operation::APPEARANCE_NO:
|
|
|
|
|
appearanceArrived(op);
|
|
|
|
|
break;
|
|
|
|
|
case Atlas::Objects::Operation::DISAPPEARANCE_NO:
|
|
|
|
|
disappearanceArrived(op);
|
|
|
|
|
break;
|
|
|
|
|
case Atlas::Objects::Operation::INFO_NO:
|
|
|
|
|
infoArrived(op);
|
|
|
|
|
break;
|
|
|
|
|
case Atlas::Objects::Operation::ERROR_NO:
|
|
|
|
|
errorArrived(op);
|
|
|
|
|
break;
|
|
|
|
|
case Atlas::Objects::Operation::SIGHT_NO:
|
|
|
|
|
sightArrived(op);
|
|
|
|
|
break;
|
|
|
|
|
case Atlas::Objects::Operation::SOUND_NO:
|
|
|
|
|
soundArrived(op);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class Stream>
|
|
|
|
|
void Interactive<Stream>::appearanceArrived(const RootOperation & op)
|
2002-12-06 10:53:57 +00:00
|
|
|
{
|
2004-05-07 15:54:23 +00:00
|
|
|
if (accountId.empty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
if (accountId != op->getTo()) {
|
2004-05-07 15:54:23 +00:00
|
|
|
// This is an IG op we are monitoring
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
if (op->getArgs().empty()) {
|
2002-12-06 10:53:57 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
RootEntity ent = smart_dynamic_cast<RootEntity>(op->getArgs().front());
|
|
|
|
|
if (!ent.isValid()) {
|
|
|
|
|
std::cerr << "Got Appearance of non-entity" << std::endl << std::flush;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!ent->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cerr << "Got Appearance of non-string ID" << std::endl << std::flush;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
const std::string & id = ent->getId();
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << "Appearance(id: " << id << ")";
|
2005-08-27 23:18:48 +00:00
|
|
|
if (!ent->hasAttrFlag(Atlas::Objects::Entity::LOC_FLAG)) {
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << std::endl << std::flush;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
const std::string & loc = ent->getLoc();
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << " in " << loc << std::endl;
|
|
|
|
|
if (loc == "lobby") {
|
|
|
|
|
std::cout << id << " has logged in." << std::endl;
|
|
|
|
|
}
|
|
|
|
|
std::cout << std::flush;
|
|
|
|
|
}
|
|
|
|
|
|
2004-04-24 14:10:20 +00:00
|
|
|
template <class Stream>
|
2005-08-27 23:18:48 +00:00
|
|
|
void Interactive<Stream>::disappearanceArrived(const RootOperation & op)
|
2002-12-06 10:53:57 +00:00
|
|
|
{
|
2004-05-07 15:54:23 +00:00
|
|
|
if (accountId.empty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
if (accountId != op->getTo()) {
|
2004-05-07 15:54:23 +00:00
|
|
|
// This is an IG op we are monitoring
|
2005-08-27 23:18:48 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (op->getArgs().empty()) {
|
2004-05-07 15:54:23 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
RootEntity ent = smart_dynamic_cast<RootEntity>(op->getArgs().front());
|
|
|
|
|
if (!ent.isValid()) {
|
|
|
|
|
std::cerr << "Got Disappearance of non-entity" << std::endl << std::flush;
|
2002-12-06 10:53:57 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
if (!ent->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cerr << "Got Disappearance of non-string ID" << std::endl << std::flush;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
const std::string & id = ent->getId();
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << "Disappearance(id: " << id << ")";
|
2005-08-27 23:18:48 +00:00
|
|
|
if (!ent->hasAttrFlag(Atlas::Objects::Entity::LOC_FLAG)) {
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << std::endl << std::flush;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
const std::string & loc = ent->getLoc();
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << " in " << loc << std::endl;
|
|
|
|
|
if (loc == "lobby") {
|
|
|
|
|
std::cout << id << " has logged out." << std::endl;
|
|
|
|
|
}
|
|
|
|
|
std::cout << std::flush;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
2005-08-27 23:18:48 +00:00
|
|
|
void Interactive<Stream>::infoArrived(const RootOperation & op)
|
2001-03-16 14:27:58 +00:00
|
|
|
{
|
|
|
|
|
reply_flag = true;
|
2005-08-27 23:18:48 +00:00
|
|
|
if (op->getArgs().empty()) {
|
2002-07-26 16:47:39 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
const Root & ent = op->getArgs().front();
|
2003-08-13 00:47:13 +00:00
|
|
|
if (login_flag) {
|
2006-08-09 00:04:17 +00:00
|
|
|
std::cout << "login success" << std::endl << std::flush;
|
2005-08-27 23:18:48 +00:00
|
|
|
if (!ent->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
|
2002-07-26 16:47:39 +00:00
|
|
|
std::cerr << "ERROR: Response to login does not contain account id"
|
|
|
|
|
<< std::endl << std::flush;
|
|
|
|
|
|
|
|
|
|
} else {
|
2005-08-27 23:18:48 +00:00
|
|
|
accountId = ent->getId();
|
2002-07-26 16:47:39 +00:00
|
|
|
}
|
2006-08-09 00:04:17 +00:00
|
|
|
if (ent->hasAttrFlag(Atlas::Objects::PARENTS_FLAG)) {
|
|
|
|
|
const std::list<std::string> & parents = ent->getParents();
|
|
|
|
|
if (!parents.empty()) {
|
|
|
|
|
accountType = parents.front();
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-06-29 22:56:41 +00:00
|
|
|
} else if (avatar_flag) {
|
2005-06-25 08:37:23 +00:00
|
|
|
std::cout << "Create agent success" << std::endl << std::flush;
|
2005-08-27 23:18:48 +00:00
|
|
|
if (!ent->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
|
2005-06-25 08:37:23 +00:00
|
|
|
std::cerr << "ERROR: Response to agent create does not contain agent id"
|
|
|
|
|
<< std::endl << std::flush;
|
|
|
|
|
|
|
|
|
|
} else {
|
2005-08-27 23:18:48 +00:00
|
|
|
agentId = ent->getId();
|
|
|
|
|
avatar_flag = false;
|
2005-06-25 08:37:23 +00:00
|
|
|
}
|
2006-08-09 00:04:17 +00:00
|
|
|
} else if (server_flag) {
|
|
|
|
|
std::cout << "Server query success" << std::endl << std::flush;
|
2006-08-10 13:35:40 +00:00
|
|
|
if (!ent->isDefaultName()) {
|
|
|
|
|
serverName = ent->getName();
|
|
|
|
|
std::string::size_type p = serverName.find(".");
|
|
|
|
|
if (p != std::string::npos) {
|
|
|
|
|
serverName = serverName.substr(0, p);
|
|
|
|
|
}
|
|
|
|
|
updatePrompt();
|
|
|
|
|
}
|
|
|
|
|
Element raw_attr;
|
|
|
|
|
if (ent->copyAttr("server", raw_attr) == 0) {
|
|
|
|
|
if (raw_attr.isString()) {
|
|
|
|
|
systemType = raw_attr.String();
|
2006-08-09 00:04:17 +00:00
|
|
|
updatePrompt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
server_flag = false;
|
2003-08-13 00:47:13 +00:00
|
|
|
} else {
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << "Info(" << std::endl;
|
2005-08-27 23:18:48 +00:00
|
|
|
MapType entmap = ent->asMessage();
|
|
|
|
|
MapType::const_iterator Iend = entmap.end();
|
|
|
|
|
for (MapType::const_iterator I = entmap.begin(); I != Iend; ++I) {
|
2004-08-17 Al Riddoch <alriddoch@zepler.org>
* tests/Areatest.cpp, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/Linetest.cpp, tests/Planttest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Thingtest.cpp, tests/Worldtest.cpp,
tests/inheritancetest.cpp, tests/utilitytest.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp, tools/cydbload.cpp, tools/cyisoload.cpp,
tools/cyloadrules.cpp, tools/cypasswd.cpp: Convert code to using
Atlas Message typedefs as found in Atlas-C++ 0.6 to aid
conversion later.
2004-08-17 13:23:28 +00:00
|
|
|
const Element & item = I->second;
|
2005-12-14 17:16:21 +00:00
|
|
|
std::cout << " " << I->first << ": ";
|
|
|
|
|
output(item, 1);
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << std::endl;
|
2001-03-22 11:12:38 +00:00
|
|
|
}
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << ")" << std::endl << std::flush;
|
2001-03-16 14:27:58 +00:00
|
|
|
// Display results of command
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
2005-08-27 23:18:48 +00:00
|
|
|
void Interactive<Stream>::errorArrived(const RootOperation & op)
|
2001-03-16 14:27:58 +00:00
|
|
|
{
|
|
|
|
|
reply_flag = true;
|
|
|
|
|
error_flag = true;
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << "Error(";
|
2005-08-27 23:18:48 +00:00
|
|
|
const std::vector<Root> & args = op->getArgs();
|
|
|
|
|
const Root & arg = args.front();
|
|
|
|
|
Element message_attr;
|
2005-08-30 23:53:34 +00:00
|
|
|
if (arg->copyAttr("message", message_attr) == 0 && message_attr.isString()) {
|
2005-08-27 23:18:48 +00:00
|
|
|
std::cout << message_attr.asString();
|
2001-03-16 14:27:58 +00:00
|
|
|
}
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << ")" << std::endl << std::flush;
|
2001-03-16 14:27:58 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
2005-08-27 23:18:48 +00:00
|
|
|
void Interactive<Stream>::sightArrived(const RootOperation & op)
|
2002-07-26 16:47:39 +00:00
|
|
|
{
|
2004-05-07 15:54:23 +00:00
|
|
|
if (accountId.empty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
if (accountId != op->getTo() && agentId != op->getTo()) {
|
2004-05-07 15:54:23 +00:00
|
|
|
// This is an IG op we are monitoring
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-07-26 16:47:39 +00:00
|
|
|
reply_flag = true;
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << "Sight(" << std::endl;
|
2005-08-27 23:18:48 +00:00
|
|
|
const MapType & ent = op->getArgs().front()->asMessage();
|
2004-11-06 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientConnection.cpp, client/BaseClient.cpp,
client/CharacterClient.cpp, client/ClientConnection.cpp,
common/Database.cpp, common/FormattedXMLWriter.cpp,
common/inheritance.cpp, common/refno.h, common/terrain_utils.cpp,
common/type_utils.h, common/utility.cpp, modules/WorldTime.cpp,
modules/WorldTime.h, physics/Collision.cpp, rulesets/Area.cpp,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Entity.cpp,
rulesets/Line.cpp, rulesets/MemMap.cpp, rulesets/MemMap_methods.h,
rulesets/Movement.cpp, rulesets/Plant.cpp, rulesets/Py_Map.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/PythonMindScript.cpp,
rulesets/PythonThingScript.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/TerrainProperty.cpp,
rulesets/Thing.cpp, rulesets/World.cpp, server/Account.cpp,
server/CommClient.cpp, server/CommServer.cpp, server/Connection.cpp,
server/EntityFactory.cpp, server/Lobby.cpp, server/Persistance.cpp,
server/Player.cpp, server/Restoration.cpp, server/ServerRouting.cpp,
server/WorldRouter.cpp, tests/EntityExerciser.h,
tests/IGEntityExerciser.h, tests/inheritancetest.cpp,
tools/cycmd.cpp, tools/cyconvertrules.cpp, tools/cydbload.cpp,
tools/cyloadrules.cpp:
Tweak for loops to avoid creating a temporary iterator each
iteration.
* tests/type_utilstest.cpp: New test for function which does
list conversions.
2004-11-06 20:36:03 +00:00
|
|
|
MapType::const_iterator Iend = ent.end();
|
|
|
|
|
for (MapType::const_iterator I = ent.begin(); I != Iend; ++I) {
|
2004-08-17 Al Riddoch <alriddoch@zepler.org>
* tests/Areatest.cpp, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/Linetest.cpp, tests/Planttest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Thingtest.cpp, tests/Worldtest.cpp,
tests/inheritancetest.cpp, tests/utilitytest.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp, tools/cydbload.cpp, tools/cyisoload.cpp,
tools/cyloadrules.cpp, tools/cypasswd.cpp: Convert code to using
Atlas Message typedefs as found in Atlas-C++ 0.6 to aid
conversion later.
2004-08-17 13:23:28 +00:00
|
|
|
const Element & item = I->second;
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << " " << I->first << ":";
|
2005-12-14 17:16:21 +00:00
|
|
|
output(item, 1);
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << std::endl;
|
2002-07-26 16:47:39 +00:00
|
|
|
}
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << ")" << std::endl << std::flush;
|
2002-07-26 16:47:39 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
2005-08-27 23:18:48 +00:00
|
|
|
void Interactive<Stream>::soundArrived(const RootOperation & op)
|
2002-09-08 21:39:25 +00:00
|
|
|
{
|
2004-05-07 15:54:23 +00:00
|
|
|
if (accountId.empty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
if (accountId != op->getTo()) {
|
2004-05-07 15:54:23 +00:00
|
|
|
// This is an IG op we are monitoring
|
|
|
|
|
return;
|
|
|
|
|
}
|
2002-09-08 21:39:25 +00:00
|
|
|
reply_flag = true;
|
2005-08-27 23:18:48 +00:00
|
|
|
const MapType & arg = op->getArgs().front()->asMessage();
|
2004-08-17 Al Riddoch <alriddoch@zepler.org>
* tests/Areatest.cpp, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/Linetest.cpp, tests/Planttest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Thingtest.cpp, tests/Worldtest.cpp,
tests/inheritancetest.cpp, tests/utilitytest.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp, tools/cydbload.cpp, tools/cyisoload.cpp,
tools/cyloadrules.cpp, tools/cypasswd.cpp: Convert code to using
Atlas Message typedefs as found in Atlas-C++ 0.6 to aid
conversion later.
2004-08-17 13:23:28 +00:00
|
|
|
MapType::const_iterator I = arg.find("from");
|
2003-08-07 23:03:26 +00:00
|
|
|
if (I == arg.end() || !I->second.isString()) {
|
2002-09-08 21:39:25 +00:00
|
|
|
std::cout << "Sound arg has no from" << std::endl << std::flush;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-08-07 23:03:26 +00:00
|
|
|
const std::string & from = I->second.asString();
|
2002-09-08 21:39:25 +00:00
|
|
|
I = arg.find("args");
|
2003-08-07 23:03:26 +00:00
|
|
|
if (I == arg.end() || !I->second.isList()
|
|
|
|
|
|| I->second.asList().empty()
|
|
|
|
|
|| !I->second.asList().front().isMap()) {
|
2002-09-08 21:39:25 +00:00
|
|
|
std::cout << "Sound arg has no args" << std::endl << std::flush;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2004-08-17 Al Riddoch <alriddoch@zepler.org>
* tests/Areatest.cpp, tests/Entitytest.cpp, tests/Foodtest.cpp,
tests/Linetest.cpp, tests/Planttest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Thingtest.cpp, tests/Worldtest.cpp,
tests/inheritancetest.cpp, tests/utilitytest.cpp, tools/cycmd.cpp,
tools/cyconvertrules.cpp, tools/cydbload.cpp, tools/cyisoload.cpp,
tools/cyloadrules.cpp, tools/cypasswd.cpp: Convert code to using
Atlas Message typedefs as found in Atlas-C++ 0.6 to aid
conversion later.
2004-08-17 13:23:28 +00:00
|
|
|
const MapType & ent = I->second.asList().front().asMap();
|
2002-09-08 21:39:25 +00:00
|
|
|
I = ent.find("say");
|
2003-08-07 23:03:26 +00:00
|
|
|
if (I == ent.end() || !I->second.isString()) {
|
2002-09-08 21:39:25 +00:00
|
|
|
std::cout << "Sound arg arg has no say" << std::endl << std::flush;
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-08-07 23:03:26 +00:00
|
|
|
const std::string & say = I->second.asString();
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << "[" << from << "] " << say
|
2002-09-08 21:39:25 +00:00
|
|
|
<< std::endl << std::flush;
|
|
|
|
|
}
|
|
|
|
|
|
2006-02-18 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, common/BaseWorld.h, common/Property.h,
modules/Location.h, rulesets/Entity.cpp, rulesets/Entity.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Connection.cpp, server/Connection.h,
server/Persistor.cpp, server/Persistor.h, server/Persistor_impl.h,
tools/cycmd.cpp: Update usage of sigc++ to the native 2.0 API
rather than the deprecated compatability API. Eleminate the
manual disconnection code for deleted objects, as this is now
handled automatically by sigc::trackable.
2006-02-18 21:56:43 +00:00
|
|
|
sigc::signal<void, char *> CmdLine;
|
2002-12-06 10:53:57 +00:00
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
|
|
|
|
void Interactive<Stream>::gotCommand(char * cmd)
|
2001-03-16 11:38:14 +00:00
|
|
|
{
|
2002-12-06 10:53:57 +00:00
|
|
|
CmdLine.emit(cmd);
|
|
|
|
|
}
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
|
|
|
|
void Interactive<Stream>::runCommand(char * cmd)
|
2002-12-06 10:53:57 +00:00
|
|
|
{
|
|
|
|
|
if (cmd == NULL) {
|
|
|
|
|
exit = true;
|
2006-08-09 00:04:17 +00:00
|
|
|
std::cout << std::endl << std::flush;
|
2002-12-06 10:53:57 +00:00
|
|
|
return;
|
|
|
|
|
}
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2002-12-06 10:53:57 +00:00
|
|
|
if (*cmd == 0) {
|
|
|
|
|
free(cmd);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2002-12-06 10:53:57 +00:00
|
|
|
add_history(cmd);
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2002-12-06 10:53:57 +00:00
|
|
|
char * arg = strchr(cmd, ' ');
|
|
|
|
|
if (arg != NULL) {
|
|
|
|
|
*arg++ = 0;
|
|
|
|
|
int len = strlen(arg);
|
|
|
|
|
while ((len > 0) && (arg[--len] == ' ')) { arg[len] = 0; }
|
|
|
|
|
} else {
|
|
|
|
|
arg = "";
|
2001-03-16 11:38:14 +00:00
|
|
|
}
|
2002-12-06 10:53:57 +00:00
|
|
|
|
|
|
|
|
exec(cmd, arg);
|
2001-03-16 11:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
2005-11-19 04:18:55 +00:00
|
|
|
template <class Stream>
|
|
|
|
|
int Interactive<Stream>::runTask(AdminTask * task, const std::string & arg)
|
|
|
|
|
{
|
|
|
|
|
assert(task != 0);
|
|
|
|
|
|
|
|
|
|
if (currentTask != 0) {
|
|
|
|
|
std::cout << "Busy" << std::endl << std::flush;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
currentTask = task;
|
|
|
|
|
|
|
|
|
|
OpVector res;
|
|
|
|
|
|
|
|
|
|
currentTask->setup(arg, res);
|
|
|
|
|
|
|
|
|
|
OpVector::const_iterator Iend = res.end();
|
|
|
|
|
for (OpVector::const_iterator I = res.begin(); I != Iend; ++I) {
|
|
|
|
|
encoder->streamObjectsMessage(*I);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-11-19 17:50:08 +00:00
|
|
|
template <class Stream>
|
|
|
|
|
int Interactive<Stream>::endTask()
|
|
|
|
|
{
|
|
|
|
|
if (currentTask == 0) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
delete currentTask;
|
|
|
|
|
currentTask = 0;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2005-06-25 08:37:23 +00:00
|
|
|
int completion_iterator = 0;
|
|
|
|
|
|
|
|
|
|
char * completion_generator(const char * text, int state)
|
|
|
|
|
{
|
|
|
|
|
if (state == 0) {
|
|
|
|
|
completion_iterator = 0;
|
|
|
|
|
}
|
|
|
|
|
for (int i = completion_iterator; commands[i].cmd_string != 0; ++i) {
|
|
|
|
|
if (strncmp(text, commands[i].cmd_string, strlen(text)) == 0) {
|
|
|
|
|
completion_iterator = i + 1;
|
|
|
|
|
return strdup(commands[i].cmd_string);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
|
|
|
|
void Interactive<Stream>::loop()
|
2002-12-06 10:53:57 +00:00
|
|
|
{
|
2006-08-09 00:04:17 +00:00
|
|
|
rl_callback_handler_install(prompt.c_str(),
|
|
|
|
|
&Interactive<Stream>::gotCommand);
|
2005-06-25 08:37:23 +00:00
|
|
|
rl_completion_entry_function = &completion_generator;
|
2006-02-18 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, common/BaseWorld.h, common/Property.h,
modules/Location.h, rulesets/Entity.cpp, rulesets/Entity.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Connection.cpp, server/Connection.h,
server/Persistor.cpp, server/Persistor.h, server/Persistor_impl.h,
tools/cycmd.cpp: Update usage of sigc++ to the native 2.0 API
rather than the deprecated compatability API. Eleminate the
manual disconnection code for deleted objects, as this is now
handled automatically by sigc::trackable.
2006-02-18 21:56:43 +00:00
|
|
|
CmdLine.connect(sigc::mem_fun(this, &Interactive<Stream>::runCommand));
|
2002-12-06 10:53:57 +00:00
|
|
|
while (!exit) {
|
|
|
|
|
poll();
|
|
|
|
|
};
|
2006-08-09 00:04:17 +00:00
|
|
|
std::cout << std::endl << std::flush;
|
2002-12-06 10:53:57 +00:00
|
|
|
rl_callback_handler_remove();
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
2006-08-08 11:36:49 +00:00
|
|
|
void Interactive<Stream>::poll(bool rewrite_prompt)
|
2003-08-07 23:03:26 +00:00
|
|
|
// poll the codec if select says there is something there.
|
2001-03-16 11:38:14 +00:00
|
|
|
{
|
|
|
|
|
fd_set infds;
|
|
|
|
|
struct timeval tv;
|
|
|
|
|
|
|
|
|
|
FD_ZERO(&infds);
|
|
|
|
|
|
|
|
|
|
FD_SET(cli_fd, &infds);
|
2002-12-06 10:53:57 +00:00
|
|
|
FD_SET(STDIN_FILENO, &infds);
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2002-12-06 10:53:57 +00:00
|
|
|
tv.tv_sec = 0;
|
|
|
|
|
tv.tv_usec = 100000;
|
2001-03-16 11:38:14 +00:00
|
|
|
|
|
|
|
|
int retval = select(cli_fd+1, &infds, NULL, NULL, &tv);
|
|
|
|
|
|
|
|
|
|
if (retval) {
|
|
|
|
|
if (FD_ISSET(cli_fd, &infds)) {
|
2001-08-14 17:52:50 +00:00
|
|
|
if (ios.peek() == -1) {
|
|
|
|
|
std::cout << "Server disconnected" << std::endl << std::flush;
|
2002-12-06 10:53:57 +00:00
|
|
|
exit = true;
|
|
|
|
|
} else {
|
2006-08-08 11:36:49 +00:00
|
|
|
if (rewrite_prompt) {
|
|
|
|
|
std::cout << std::endl;
|
|
|
|
|
}
|
2003-08-07 23:03:26 +00:00
|
|
|
codec->poll();
|
2006-08-08 11:36:49 +00:00
|
|
|
if (rewrite_prompt) {
|
|
|
|
|
rl_forced_update_display();
|
|
|
|
|
}
|
2001-03-16 11:38:14 +00:00
|
|
|
}
|
2002-12-06 10:53:57 +00:00
|
|
|
}
|
|
|
|
|
if (FD_ISSET(STDIN_FILENO, &infds)) {
|
|
|
|
|
rl_callback_read_char();
|
2001-03-16 11:38:14 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
|
|
|
|
void Interactive<Stream>::getLogin()
|
2001-03-22 11:12:38 +00:00
|
|
|
{
|
2001-06-09 18:46:27 +00:00
|
|
|
// This needs to be re-written to hide input, so the password can be
|
|
|
|
|
// secret
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << "Username: " << std::flush;
|
|
|
|
|
std::cin >> username;
|
2001-03-22 11:12:38 +00:00
|
|
|
std::cout << "Password: " << std::flush;
|
|
|
|
|
std::cin >> password;
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-03 23:45:32 +00:00
|
|
|
template<>
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
int Interactive<tcp_socket_stream>::connect(const std::string & host)
|
2001-03-16 11:38:14 +00:00
|
|
|
{
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << "Connecting... " << std::flush;
|
2004-12-13 12:22:35 +00:00
|
|
|
ios.open(host, client_port_num);
|
* client/ClientConnection.cpp, client/ClientConnection.h,
tools/cycmd.cpp: Switched to using skstream to completely handle
client socket connections.
* client/ClientConnection.cpp, client/ClientConnection.h,
common/log.cpp, rulesets/EntityFactory.h, rulesets/MemMap.h,
server/server.cpp, tools/cycmd.cpp: Removed unused includes.
* client/Py_CreatorClient.cpp, client/client.cpp,
client/define_world.cpp, 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_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/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, server/server.cpp:
Reorganised python header files so that each header includes
all the code relevant for a particular type. Tidied up
the type implementations. Added prototypes to init_python_api()
to the Python_API.h header, and removed other dependencies from
it.
Al Riddoch <alriddoch@zepler.org>
2001-10-19 11:35:07 +00:00
|
|
|
if (!ios.is_open()) {
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << "failed." << std::endl << std::flush;
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
return -1;
|
2001-03-16 11:38:14 +00:00
|
|
|
}
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << "done." << std::endl << std::flush;
|
* client/ClientConnection.cpp, client/ClientConnection.h,
tools/cycmd.cpp: Switched to using skstream to completely handle
client socket connections.
* client/ClientConnection.cpp, client/ClientConnection.h,
common/log.cpp, rulesets/EntityFactory.h, rulesets/MemMap.h,
server/server.cpp, tools/cycmd.cpp: Removed unused includes.
* client/Py_CreatorClient.cpp, client/client.cpp,
client/define_world.cpp, 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_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/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, server/server.cpp:
Reorganised python header files so that each header includes
all the code relevant for a particular type. Tidied up
the type implementations. Added prototypes to init_python_api()
to the Python_API.h header, and removed other dependencies from
it.
Al Riddoch <alriddoch@zepler.org>
2001-10-19 11:35:07 +00:00
|
|
|
cli_fd = ios.getSocket();
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
return negotiate();
|
|
|
|
|
}
|
|
|
|
|
|
2005-03-03 23:45:32 +00:00
|
|
|
template<>
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
int Interactive<unix_socket_stream>::connect(const std::string & filename)
|
2003-08-13 00:29:20 +00:00
|
|
|
{
|
|
|
|
|
std::cout << "Connecting... " << std::flush;
|
|
|
|
|
ios.open(filename);
|
|
|
|
|
if (!ios.is_open()) {
|
|
|
|
|
std::cout << "failed." << std::endl << std::flush;
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
return -1;
|
2003-08-13 00:29:20 +00:00
|
|
|
}
|
|
|
|
|
std::cout << "done." << std::endl << std::flush;
|
|
|
|
|
cli_fd = ios.getSocket();
|
|
|
|
|
|
|
|
|
|
return negotiate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class Stream>
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
int Interactive<Stream>::negotiate()
|
2003-08-13 00:29:20 +00:00
|
|
|
{
|
2001-03-16 11:38:14 +00:00
|
|
|
// Do client negotiation with the server
|
2005-10-02 02:26:13 +00:00
|
|
|
Atlas::Net::StreamConnect conn("cycmd", ios);
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2001-08-14 17:52:50 +00:00
|
|
|
std::cout << "Negotiating... " << std::flush;
|
2005-08-27 23:18:48 +00:00
|
|
|
while (conn.getState() == Atlas::Negotiate::IN_PROGRESS) {
|
2003-08-07 23:03:26 +00:00
|
|
|
// conn.poll() does all the negotiation
|
|
|
|
|
conn.poll();
|
2001-03-16 11:38:14 +00:00
|
|
|
}
|
2002-12-06 10:53:57 +00:00
|
|
|
std::cout << "done." << std::endl << std::flush;
|
2001-03-16 11:38:14 +00:00
|
|
|
|
|
|
|
|
// Check whether negotiation was successful
|
2005-08-27 23:18:48 +00:00
|
|
|
if (conn.getState() == Atlas::Negotiate::FAILED) {
|
2001-08-14 17:52:50 +00:00
|
|
|
std::cerr << "Failed to negotiate." << std::endl;
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
return -1;
|
2001-03-16 11:38:14 +00:00
|
|
|
}
|
|
|
|
|
// Negotiation was successful
|
|
|
|
|
|
|
|
|
|
// Get the codec that negotiation established
|
2005-10-02 02:26:13 +00:00
|
|
|
codec = conn.getCodec(*this);
|
2001-03-16 11:38:14 +00:00
|
|
|
|
|
|
|
|
// Create the encoder
|
2005-08-27 23:18:48 +00:00
|
|
|
encoder = new Atlas::Objects::ObjectsEncoder(*codec);
|
2001-03-16 11:38:14 +00:00
|
|
|
|
|
|
|
|
// Send whatever codec specific data marks the beginning of a stream
|
2003-08-07 23:03:26 +00:00
|
|
|
codec->streamBegin();
|
2006-08-09 00:04:17 +00:00
|
|
|
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
return 0;
|
2001-03-16 11:38:14 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-09 00:04:17 +00:00
|
|
|
template <class Stream>
|
|
|
|
|
void Interactive<Stream>::updatePrompt()
|
|
|
|
|
{
|
|
|
|
|
std::string designation(">");
|
|
|
|
|
if (!username.empty()) {
|
|
|
|
|
prompt = username + "@";
|
|
|
|
|
if (accountType == "admin") {
|
|
|
|
|
designation = "#";
|
|
|
|
|
} else {
|
|
|
|
|
designation = "$";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
prompt = "";
|
|
|
|
|
}
|
|
|
|
|
prompt += serverName;
|
2006-08-10 13:35:40 +00:00
|
|
|
prompt += " ";
|
|
|
|
|
prompt += systemType;
|
2006-08-09 00:04:17 +00:00
|
|
|
prompt += designation;
|
|
|
|
|
prompt += " ";
|
|
|
|
|
rl_set_prompt(prompt.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
int Interactive<Stream>::login()
|
2001-03-16 11:38:14 +00:00
|
|
|
{
|
2004-01-22 03:03:07 +00:00
|
|
|
Atlas::Objects::Entity::Account account;
|
2005-08-27 23:18:48 +00:00
|
|
|
Login l;
|
2001-03-16 14:27:58 +00:00
|
|
|
error_flag = false;
|
|
|
|
|
reply_flag = false;
|
2003-08-13 00:47:13 +00:00
|
|
|
login_flag = true;
|
2001-03-16 14:27:58 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
account->setAttr("username", username);
|
|
|
|
|
account->setAttr("password", password);
|
2001-03-16 14:27:58 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
l->setArgs1(account);
|
2001-03-16 14:27:58 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
encoder->streamObjectsMessage(l);
|
* tools/cycmd.cpp: Ensure that login op is flushed after it is sent.
* server/Player.cpp: Arg order of std::string.compare() is
incompatable between recent libstdc++ versions. Switch
back to old version, still in most common use.
* rulesets/Thing.cpp: Set refno on ops handled in game.
* rulesets/Python_API.cpp: Modify Entity() python constructor
so that commonly used attributes from old atlas are translated
to their modern equivalents.
* rulesets/Py_Thing.cpp, rulesets/Py_Mind.cpp: Differentiate
between previously identical error messages in several places.
* rulesets/Py_Object.cpp: Rework conversion of python dict to
Atlas map to be more efficient and clean.
* rulesets/Py_Location.cpp: Rework setting of vector parts of
location so that it can accept vectors from python in more
formats, including lists and tuples.
* rulesets/Creator.h, rulesets/Character.h, common/BaseEntity.h:
Re-order virtual methods declarations to fit a convention.
* common/stringstream.h: Hardcode use of local stringstream class,
as the version provided with older libstdc++ seems to be broken.
* common/database.cpp: Use the common header to pick the right
stringstream implementation.
* common/BaseWorld.cpp, server/Persistance.cpp: Removed unused
stringstream include.
* rulesets/Creator.cpp: Added extra debug output.
* client/define_world.h, client/define_world.cpp, client/CommClient.h:
Use CreatorClient to store Creators mind, instead of BaseMind.
* client/client.cpp,
client/ObserverClient.h, client/ObserverClient.cpp,
client/CreatorClient.h, client/CommClient.h, client/CommClient.cpp:
Modify method names to fit capitalisation conventions.
* client/CreatorClient.cpp: Implement creation of in-game entities,
using creator entity.
* client/CommClient.cpp: Added correct client side monitoring of
creator entity.
* client/ClientConnection.h, client/ClientConnection.cpp: Added
pending method to establish if ops are in the queue. Switched send()
method so we only send ops. Add setting of serialno of sent
ops, starting with an offset of 512.
* client/CharacterClient.h: Removed unused member, opFound.
* client/CharacterClient.cpp: Debugged sendAndWait() method.
Al Riddoch <alriddoch@zepler.org>
2001-08-16 17:39:42 +00:00
|
|
|
|
|
|
|
|
ios << std::flush;
|
2001-03-16 14:27:58 +00:00
|
|
|
|
|
|
|
|
while (!reply_flag) {
|
2003-08-07 23:03:26 +00:00
|
|
|
codec->poll();
|
2001-03-16 14:27:58 +00:00
|
|
|
}
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2003-08-13 00:47:13 +00:00
|
|
|
login_flag = false;
|
|
|
|
|
|
2006-08-09 00:04:17 +00:00
|
|
|
if (!error_flag) {
|
|
|
|
|
updatePrompt();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class Stream>
|
|
|
|
|
int Interactive<Stream>::setup()
|
|
|
|
|
{
|
|
|
|
|
Get get;
|
|
|
|
|
|
|
|
|
|
encoder->streamObjectsMessage(get);
|
|
|
|
|
ios << std::flush;
|
|
|
|
|
server_flag = true;
|
|
|
|
|
|
|
|
|
|
reply_flag = true;
|
|
|
|
|
while (server_flag && !error_flag) {
|
|
|
|
|
codec->poll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
server_flag = false;
|
2001-03-16 14:27:58 +00:00
|
|
|
if (!error_flag) {
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
return 0;
|
2001-03-16 14:27:58 +00:00
|
|
|
}
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
return -1;
|
2001-03-16 14:27:58 +00:00
|
|
|
}
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2003-08-13 00:29:20 +00:00
|
|
|
template <class Stream>
|
|
|
|
|
void Interactive<Stream>::exec(const std::string & cmd, const std::string & arg)
|
2001-03-16 14:27:58 +00:00
|
|
|
{
|
2001-04-02 22:03:42 +00:00
|
|
|
bool reply_expected = true;
|
2001-03-22 11:12:38 +00:00
|
|
|
reply_flag = false;
|
|
|
|
|
error_flag = false;
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2001-04-02 22:03:42 +00:00
|
|
|
if (cmd == "stat") {
|
2004-01-22 03:03:07 +00:00
|
|
|
Get g;
|
2005-08-27 23:18:48 +00:00
|
|
|
encoder->streamObjectsMessage(g);
|
2004-06-09 22:06:11 +00:00
|
|
|
} else if (cmd == "install") {
|
|
|
|
|
size_t space = arg.find(' ');
|
|
|
|
|
if ((space == std::string::npos) || (space >= (arg.size() - 1))) {
|
|
|
|
|
std::cout << "usage: install <type id> <parent id>"
|
|
|
|
|
<< std::endl << std::flush;
|
|
|
|
|
} else {
|
2006-04-26 15:26:10 +00:00
|
|
|
Create c;
|
|
|
|
|
c->setFrom(accountId);
|
2005-08-27 23:18:48 +00:00
|
|
|
Anonymous ent;
|
|
|
|
|
ent->setId(std::string(arg, 0, space));
|
|
|
|
|
ent->setObjtype("class");
|
|
|
|
|
ent->setParents(std::list<std::string>(1, std::string(arg, space + 1)));
|
2006-04-26 15:26:10 +00:00
|
|
|
c->setArgs1(ent);
|
|
|
|
|
encoder->streamObjectsMessage(c);
|
2004-06-09 22:06:11 +00:00
|
|
|
}
|
|
|
|
|
reply_expected = false;
|
2002-07-26 16:47:39 +00:00
|
|
|
} else if (cmd == "look") {
|
2004-01-22 03:03:07 +00:00
|
|
|
Look l;
|
2005-08-27 23:18:48 +00:00
|
|
|
l->setFrom(accountId);
|
|
|
|
|
encoder->streamObjectsMessage(l);
|
2002-07-26 16:47:39 +00:00
|
|
|
} else if (cmd == "logout") {
|
2004-01-22 03:03:07 +00:00
|
|
|
Logout l;
|
2005-08-27 23:18:48 +00:00
|
|
|
l->setFrom(accountId);
|
2002-07-26 16:47:39 +00:00
|
|
|
if (!arg.empty()) {
|
2005-08-27 23:18:48 +00:00
|
|
|
Anonymous lmap;
|
|
|
|
|
lmap->setId(arg);
|
|
|
|
|
l->setArgs1(lmap);
|
2002-07-26 16:47:39 +00:00
|
|
|
reply_expected = false;
|
|
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
encoder->streamObjectsMessage(l);
|
2002-09-08 21:39:25 +00:00
|
|
|
} else if (cmd == "say") {
|
2004-01-22 03:03:07 +00:00
|
|
|
Talk t;
|
2005-08-27 23:18:48 +00:00
|
|
|
Anonymous ent;
|
|
|
|
|
ent->setAttr("say", arg);
|
|
|
|
|
t->setArgs1(ent);
|
|
|
|
|
t->setFrom(accountId);
|
|
|
|
|
encoder->streamObjectsMessage(t);
|
2002-12-06 10:53:57 +00:00
|
|
|
} else if ((cmd == "help") || (cmd == "?")) {
|
2001-04-02 22:03:42 +00:00
|
|
|
reply_expected = false;
|
|
|
|
|
help();
|
2001-04-05 18:01:12 +00:00
|
|
|
} else if (cmd == "query") {
|
2004-01-22 03:03:07 +00:00
|
|
|
Get g;
|
2001-04-05 18:01:12 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
Anonymous cmap;
|
|
|
|
|
cmap->setObjtype("obj");
|
2002-03-06 Al Riddoch <alriddoch@zepler.org>
* tools/cycmd.cpp, server/WorldRouter.cpp, server/EntityFactory.cpp,
server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/Thing.cpp, rulesets/Py_Operation.cpp,
rulesets/MemMap_methods.h, rulesets/MemMap.cpp, rulesets/Entity.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Use empty() instead of size() == 0 for STL sequence types.
* rulesets/ThingFactory.h, server/EntityFactory.cpp: Modified the
way adding classes to the inheritance tree is handled, so types
no longer have to inherit directly from a C++ class.
* server/WorldRouter.cpp: Modified the way broadcast operations are
handled to make them more efficient, and catch NULL pointers in
the world dictionary.
2002-03-06 00:23:28 +00:00
|
|
|
if (!arg.empty()) {
|
2005-08-27 23:18:48 +00:00
|
|
|
cmap->setId(arg);
|
2001-04-05 18:01:12 +00:00
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
g->setArgs1(cmap);
|
|
|
|
|
g->setFrom(accountId);
|
2001-04-05 18:01:12 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
encoder->streamObjectsMessage(g);
|
2005-05-15 20:32:29 +00:00
|
|
|
} else if (cmd == "reload") {
|
|
|
|
|
if (arg.empty()) {
|
|
|
|
|
reply_expected = false;
|
|
|
|
|
std::cout << "reload: Argument required" << std::endl << std::flush;
|
|
|
|
|
} else {
|
|
|
|
|
Set s;
|
|
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
Anonymous tmap;
|
|
|
|
|
tmap->setObjtype("class");
|
|
|
|
|
tmap->setId(arg);
|
|
|
|
|
s->setArgs1(tmap);
|
|
|
|
|
s->setFrom(accountId);
|
2005-05-15 20:32:29 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
encoder->streamObjectsMessage(s);
|
2005-05-15 20:32:29 +00:00
|
|
|
}
|
2002-11-01 12:12:01 +00:00
|
|
|
} else if (cmd == "get") {
|
2004-01-22 03:03:07 +00:00
|
|
|
Get g;
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
Anonymous cmap;
|
|
|
|
|
cmap->setObjtype("class");
|
2002-03-06 Al Riddoch <alriddoch@zepler.org>
* tools/cycmd.cpp, server/WorldRouter.cpp, server/EntityFactory.cpp,
server/Connection.cpp, server/Admin.cpp, server/Account.cpp,
rulesets/World.cpp, rulesets/Thing.cpp, rulesets/Py_Operation.cpp,
rulesets/MemMap_methods.h, rulesets/MemMap.cpp, rulesets/Entity.cpp,
rulesets/Character.cpp, rulesets/BaseMind.cpp:
Use empty() instead of size() == 0 for STL sequence types.
* rulesets/ThingFactory.h, server/EntityFactory.cpp: Modified the
way adding classes to the inheritance tree is handled, so types
no longer have to inherit directly from a C++ class.
* server/WorldRouter.cpp: Modified the way broadcast operations are
handled to make them more efficient, and catch NULL pointers in
the world dictionary.
2002-03-06 00:23:28 +00:00
|
|
|
if (!arg.empty()) {
|
2005-08-27 23:18:48 +00:00
|
|
|
cmap->setId(arg);
|
2001-04-02 22:03:42 +00:00
|
|
|
}
|
2005-08-27 23:18:48 +00:00
|
|
|
g->setArgs1(cmap);
|
|
|
|
|
g->setFrom(accountId);
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
encoder->streamObjectsMessage(g);
|
2004-04-23 17:50:38 +00:00
|
|
|
} else if (cmd == "monitor") {
|
2005-11-19 23:24:07 +00:00
|
|
|
AdminTask * task = new OperationMonitor;
|
|
|
|
|
if (runTask(task, arg) == 0) {
|
|
|
|
|
Monitor m;
|
2004-04-23 17:50:38 +00:00
|
|
|
|
2005-11-19 23:24:07 +00:00
|
|
|
m->setArgs1(Anonymous());
|
|
|
|
|
m->setFrom(accountId);
|
2004-04-23 17:50:38 +00:00
|
|
|
|
2005-11-19 23:24:07 +00:00
|
|
|
encoder->streamObjectsMessage(m);
|
|
|
|
|
}
|
2004-05-07 15:54:23 +00:00
|
|
|
|
2004-04-23 17:50:38 +00:00
|
|
|
reply_expected = false;
|
2005-11-19 23:24:07 +00:00
|
|
|
} else if (cmd == "unmonitor") {
|
|
|
|
|
OperationMonitor * om = dynamic_cast<OperationMonitor *>(currentTask);
|
2004-04-23 17:50:38 +00:00
|
|
|
|
2005-11-19 23:24:07 +00:00
|
|
|
if (om != 0) {
|
|
|
|
|
Monitor m;
|
2004-04-23 17:50:38 +00:00
|
|
|
|
2005-11-19 23:24:07 +00:00
|
|
|
m->setFrom(accountId);
|
2004-05-07 15:54:23 +00:00
|
|
|
|
2005-11-19 23:24:07 +00:00
|
|
|
encoder->streamObjectsMessage(m);
|
|
|
|
|
|
|
|
|
|
reply_expected = false;
|
|
|
|
|
|
|
|
|
|
struct timeval tv;
|
|
|
|
|
gettimeofday(&tv, NULL);
|
|
|
|
|
int monitor_time = tv.tv_sec - om->startTime();
|
|
|
|
|
|
|
|
|
|
std::cout << om->count() << " operations monitored in "
|
|
|
|
|
<< monitor_time << " seconds = "
|
|
|
|
|
<< om->count() / monitor_time
|
|
|
|
|
<< " operations per second"
|
|
|
|
|
<< std::endl << std::flush;
|
|
|
|
|
|
|
|
|
|
endTask();
|
|
|
|
|
}
|
2004-12-15 00:55:54 +00:00
|
|
|
} else if (cmd == "connect") {
|
|
|
|
|
reply_expected = false;
|
2005-08-27 23:18:48 +00:00
|
|
|
Connect m;
|
2004-12-15 00:55:54 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
Anonymous cmap;
|
|
|
|
|
cmap->setAttr("hostname", arg);
|
|
|
|
|
m->setArgs1(cmap);
|
|
|
|
|
m->setFrom(accountId);
|
2004-12-15 00:55:54 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
encoder->streamObjectsMessage(m);
|
2005-06-25 08:37:23 +00:00
|
|
|
} else if (cmd == "add_agent") {
|
|
|
|
|
Create c;
|
|
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
Anonymous cmap;
|
|
|
|
|
cmap->setParents(std::list<std::string>(1, "creator"));
|
2005-12-30 22:11:23 +00:00
|
|
|
cmap->setName("cycmd agent");
|
2005-08-27 23:18:48 +00:00
|
|
|
cmap->setObjtype("obj");
|
|
|
|
|
c->setArgs1(cmap);
|
|
|
|
|
c->setFrom(accountId);
|
2005-06-25 08:37:23 +00:00
|
|
|
|
2005-06-29 22:56:41 +00:00
|
|
|
avatar_flag = true;
|
|
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
encoder->streamObjectsMessage(c);
|
2005-06-25 08:37:23 +00:00
|
|
|
} else if (cmd == "find_by_name") {
|
|
|
|
|
if (agentId.empty()) {
|
2005-11-19 17:50:08 +00:00
|
|
|
std::cout << "Use add_agent to add an in-game agent first" << std::endl << std::flush;
|
2005-06-25 08:37:23 +00:00
|
|
|
reply_expected = false;
|
2005-11-18 00:03:47 +00:00
|
|
|
} else if (arg.empty()) {
|
|
|
|
|
std::cout << "Please specify the name to search for" << std::endl << std::flush;
|
|
|
|
|
reply_expected = false;
|
2005-06-25 08:37:23 +00:00
|
|
|
} else {
|
|
|
|
|
Look l;
|
|
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
Anonymous lmap;
|
|
|
|
|
lmap->setName(arg);
|
|
|
|
|
l->setArgs1(lmap);
|
|
|
|
|
l->setFrom(agentId);
|
2005-06-25 08:37:23 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
encoder->streamObjectsMessage(l);
|
2005-11-18 00:03:47 +00:00
|
|
|
|
|
|
|
|
reply_expected = false;
|
2005-06-25 08:37:23 +00:00
|
|
|
}
|
|
|
|
|
} else if (cmd == "find_by_type") {
|
|
|
|
|
if (agentId.empty()) {
|
2005-11-19 17:50:08 +00:00
|
|
|
std::cout << "Use add_agent to add an in-game agent first" << std::endl << std::flush;
|
2005-06-25 08:37:23 +00:00
|
|
|
reply_expected = false;
|
2005-11-18 00:03:47 +00:00
|
|
|
} else if (arg.empty()) {
|
|
|
|
|
std::cout << "Please specify the type to search for" << std::endl << std::flush;
|
|
|
|
|
reply_expected = false;
|
2005-06-25 08:37:23 +00:00
|
|
|
} else {
|
|
|
|
|
Look l;
|
|
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
Anonymous lmap;
|
|
|
|
|
lmap->setParents(std::list<std::string>(1, arg));
|
|
|
|
|
l->setArgs1(lmap);
|
|
|
|
|
l->setFrom(agentId);
|
2005-06-25 08:37:23 +00:00
|
|
|
|
2005-08-27 23:18:48 +00:00
|
|
|
encoder->streamObjectsMessage(l);
|
2005-11-18 00:03:47 +00:00
|
|
|
|
|
|
|
|
reply_expected = false;
|
|
|
|
|
}
|
|
|
|
|
} else if (cmd == "flush") {
|
|
|
|
|
if (agentId.empty()) {
|
2005-11-19 17:50:08 +00:00
|
|
|
std::cout << "Use add_agent to add an in-game agent first" << std::endl << std::flush;
|
2005-11-18 00:03:47 +00:00
|
|
|
reply_expected = false;
|
2005-11-19 04:18:55 +00:00
|
|
|
} else if (arg.empty()) {
|
|
|
|
|
std::cout << "Please specify the type to flush" << std::endl << std::flush;
|
|
|
|
|
reply_expected = false;
|
2005-11-18 00:03:47 +00:00
|
|
|
} else {
|
2005-11-19 04:18:55 +00:00
|
|
|
AdminTask * task = new Flusher(agentId);
|
|
|
|
|
runTask(task, arg);
|
|
|
|
|
reply_expected = false;
|
2005-06-25 08:37:23 +00:00
|
|
|
}
|
2005-11-19 17:50:08 +00:00
|
|
|
} else if (cmd == "cancel") {
|
|
|
|
|
if (endTask() != 0) {
|
|
|
|
|
std::cout << "No task currently running" << std::endl << std::flush;
|
|
|
|
|
}
|
2002-11-01 12:12:01 +00:00
|
|
|
} else {
|
2002-12-06 10:53:57 +00:00
|
|
|
reply_expected = false;
|
2004-05-07 15:54:23 +00:00
|
|
|
std::cout << cmd << ": Command not known" << std::endl << std::flush;
|
2001-04-02 22:03:42 +00:00
|
|
|
}
|
2001-03-16 11:38:14 +00:00
|
|
|
|
2001-08-14 17:52:50 +00:00
|
|
|
ios << std::flush;
|
2001-03-30 17:17:47 +00:00
|
|
|
|
2001-03-16 14:27:58 +00:00
|
|
|
if (!reply_expected) { return; }
|
2002-12-06 10:53:57 +00:00
|
|
|
// Wait for reply
|
2006-08-08 11:36:49 +00:00
|
|
|
time_t wait_start_time = time(NULL);
|
2001-03-16 14:27:58 +00:00
|
|
|
while (!reply_flag) {
|
2006-08-08 11:36:49 +00:00
|
|
|
if (time(NULL) - wait_start_time > 5) {
|
|
|
|
|
std::cout << cmd << ": No reply from server" << std::endl << std::flush;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
poll(false);
|
2001-03-16 14:27:58 +00:00
|
|
|
}
|
2001-03-16 11:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
* tools/cydbload.cpp: Added parameter handling so any file can
be loaded into the database.
* tools/cycmd.cpp: Cleaned up usage and help functions.
* tools/cyisoload.cpp: Cleaned up usage(), and made sure build
completes okay if libraries are missing, and missing
functionality is reported to the user.
* server/server.cpp: Added config options that specifies that
the contents of the db should loaded on server startup. Cleaned
up some debug code.
* server/WorldTime.cpp, server/WorldRouter.cpp,
server/Connection.cpp, rulesets/Structure.h,
rulesets/Python_API.cpp, rulesets/Py_WorldTime.cpp,
rulesets/Movement.cpp, rulesets/Entity.cpp,
physics/Vector3D.h, common/persistance.cpp,
common/database.h, common/database.cpp: Removed output either
to debug mode, or removed altogether.
* common/BaseEntity.h, common/BaseEntity.cpp: Removed redundant header
includes.
* server/ServerRouting.cpp, common/persistance.h,
common/persistance.cpp: Modified admin account function names it
fit convention.
* module/Location.h: Fixed collision detection so that entities
with velocity set to 0 still get checked.
* rulesets/Entity.cpp, rulesets/Thing.cpp, rulesets/Character.cpp,
rulesets/BaseMind.cpp, rulesets/Creator.cpp,
rulesets/ExternalMind.cpp, rulesets/Food.cpp, rulesets/MemMap.cpp,
rulesets/Movement.cpp, rulesets/Pedestrian.cpp, rulesets/Plant.cpp,
rulesets/Py_Location.cpp, rulesets/Py_*.cpp, rulesets/World.cpp:
Removed unnecessary #includes.
Al Riddoch <alriddoch@zepler.org>
2001-06-04 11:22:27 +00:00
|
|
|
static void usage(char * prg)
|
2001-03-16 11:38:14 +00:00
|
|
|
{
|
2004-06-09 21:19:41 +00:00
|
|
|
std::cerr << "usage: " << prg << " [ cmd [ server ] ]" << std::endl << std::flush;
|
2001-03-16 11:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char ** argv)
|
|
|
|
|
{
|
2004-10-05 14:57:11 +00:00
|
|
|
int optind;
|
2002-01-13 Al Riddoch <alriddoch@zepler.org>
* client/client.cpp, server/server.cpp, common/globals.cpp,
common/globals.h, tools/cycmd.cpp, tools/cydbload.cpp,
tools/cypasswd.cpp: Move code for handling loading of config
from the command line, user config and global config, into
globals.cpp, and make use of it in all tools.
* tools/cycmd.cpp: Fix objtype on server set commands.
* common/Database.cpp, common/Database.h: Implemented new database
interface to PostgreSQL to replace inadequate db3 code.
* common/database.cpp, common/database.h: Old code removed from the
build.
* common/accountbase.h, server/Admin.cpp, server/Persistance.cpp,
server/server.cpp, tools/cydbload.cpp: Fixed for minor changes
in the low level database API.
* common/globals.h, common/globals.cpp, rulesets/EntityFactory.cpp,
server/Admin.cpp, server/CommServer.cpp,
Remove varconf header from globals.h, and put in .cpp files
where it belongs.
2002-01-13 17:24:53 +00:00
|
|
|
|
2004-10-05 14:57:11 +00:00
|
|
|
if ((optind = loadConfig(argc, argv)) < 0) {
|
2002-01-13 Al Riddoch <alriddoch@zepler.org>
* client/client.cpp, server/server.cpp, common/globals.cpp,
common/globals.h, tools/cycmd.cpp, tools/cydbload.cpp,
tools/cypasswd.cpp: Move code for handling loading of config
from the command line, user config and global config, into
globals.cpp, and make use of it in all tools.
* tools/cycmd.cpp: Fix objtype on server set commands.
* common/Database.cpp, common/Database.h: Implemented new database
interface to PostgreSQL to replace inadequate db3 code.
* common/database.cpp, common/database.h: Old code removed from the
build.
* common/accountbase.h, server/Admin.cpp, server/Persistance.cpp,
server/server.cpp, tools/cydbload.cpp: Fixed for minor changes
in the low level database API.
* common/globals.h, common/globals.cpp, rulesets/EntityFactory.cpp,
server/Admin.cpp, server/CommServer.cpp,
Remove varconf header from globals.h, and put in .cpp files
where it belongs.
2002-01-13 17:24:53 +00:00
|
|
|
// Fatal error loading config file
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-05 14:57:11 +00:00
|
|
|
std::string server;
|
|
|
|
|
if (global_conf->findItem("client", "serverhost")) {
|
2004-10-05 15:34:18 +00:00
|
|
|
server = global_conf->getItem("client", "serverhost").as_string();
|
2004-10-05 14:57:11 +00:00
|
|
|
}
|
|
|
|
|
|
2004-12-16 02:12:39 +00:00
|
|
|
int useslave = 0;
|
2004-12-16 00:52:09 +00:00
|
|
|
if (global_conf->findItem("client", "useslave")) {
|
|
|
|
|
useslave = global_conf->getItem("client", "useslave");
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-09 18:46:27 +00:00
|
|
|
bool interactive = true;
|
|
|
|
|
std::string cmd;
|
2004-10-05 14:57:11 +00:00
|
|
|
if (optind < argc) {
|
|
|
|
|
if ((argc - optind) == 2) {
|
|
|
|
|
server = argv[optind + 1];
|
|
|
|
|
} else if ((argc - optind) > 2) {
|
2001-06-09 18:46:27 +00:00
|
|
|
usage(argv[0]);
|
|
|
|
|
return 1;
|
2001-03-16 11:38:14 +00:00
|
|
|
}
|
2004-10-05 14:57:11 +00:00
|
|
|
cmd = argv[optind];
|
2003-08-13 00:47:13 +00:00
|
|
|
interactive = false;
|
2001-03-16 11:38:14 +00:00
|
|
|
}
|
2003-08-13 00:29:20 +00:00
|
|
|
|
2004-10-05 14:57:11 +00:00
|
|
|
if (server.empty()) {
|
2004-12-16 00:52:09 +00:00
|
|
|
std::string localSocket = var_directory + "/tmp/";
|
|
|
|
|
if (useslave != 0) {
|
|
|
|
|
localSocket += slave_socket_name;
|
|
|
|
|
} else {
|
|
|
|
|
localSocket += client_socket_name;
|
|
|
|
|
}
|
2003-08-13 00:29:20 +00:00
|
|
|
|
2006-08-08 11:36:49 +00:00
|
|
|
std::cout << "Attempting local connection" << std::endl << std::flush;
|
2003-08-13 00:29:20 +00:00
|
|
|
Interactive<unix_socket_stream> bridge;
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
if (bridge.connect(localSocket) == 0) {
|
2003-08-13 00:29:20 +00:00
|
|
|
bridge.setUsername("admin");
|
|
|
|
|
|
2006-08-09 00:04:17 +00:00
|
|
|
bridge.setup();
|
2003-08-13 00:29:20 +00:00
|
|
|
std::cout << "Logging in... " << std::flush;
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
if (bridge.login() != 0) {
|
2003-08-13 00:29:20 +00:00
|
|
|
std::cout << "failed." << std::endl << std::flush;
|
|
|
|
|
bridge.getLogin();
|
|
|
|
|
|
|
|
|
|
std::cout << "Logging in... " << std::flush;
|
|
|
|
|
if (!bridge.login()) {
|
|
|
|
|
std::cout << "failed." << std::endl << std::flush;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
std::cout << "done." << std::endl << std::flush;
|
|
|
|
|
if (!interactive) {
|
|
|
|
|
bridge.exec(cmd, "");
|
|
|
|
|
return 0;
|
* aiclient/ClientConnection.cpp, aiclient/client.cpp,
client/ClientConnection.cpp, common/database.h, common/globals.cpp,
common/persistance.cpp, common/stringstream.h, server/CommClient.cpp,
server/CommServer.cpp, server/Persistance.cpp, tools/cyctrl.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cyisoload.cpp,
tools/cypasswd.cpp: Removed unused config.h.
* client/ObserverClient.cpp, common/const.h, tools/cycmd.cpp:
Use default password if the admin account cannot be fetched from
the database.
* client/Py_CreatorClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, rulesets/Character.cpp, rulesets/Creator.cpp,
rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.cpp,
rulesets/MemMap.cpp, rulesets/Py_Mind.cpp, rulesets/Py_Thing.cpp,
rulesets/Py_World.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/Connection.cpp, tools/cywatchdog.cpp:
Make many of the member variables of Entity protected, and add
the required accessors. Changed the name of the id attribute
to m_id.
* common/BaseWorld.h, common/database.cpp, common/persistance.cpp:
Removed unused includes.
* common/Chop.h, common/Cut.h, common/Eat.h, common/Fire.h,
common/Generic.h, common/Load.h, common/Nourish.h, common/Save.h,
common/Setup.h, common/Tick.h: Moved definition of virtual
functions into cpp file, to reduce wasted code.
* common/Makefile.am: Create cyphesis library, which can be used by
other applications to access cyphesis databases.
* common/config.h, common/database.h, server/Persistance.cpp,
tools/cydbload.cpp, tools/cyisoload.cpp, tools/cypasswd.cpp:
Remove conditional compilation of db code. db3 is now required.
* server/WorldRouter.h: Fixed getNewId() so it take const string.
* server/server.cpp: Removed python shutdown, so it does not
mess up the db if it causes a segfault.
Al Riddoch <alriddoch@zepler.org>
2001-10-17 14:09:42 +00:00
|
|
|
} else {
|
2003-08-13 00:29:20 +00:00
|
|
|
bridge.loop();
|
* aiclient/ClientConnection.cpp, aiclient/client.cpp,
client/ClientConnection.cpp, common/database.h, common/globals.cpp,
common/persistance.cpp, common/stringstream.h, server/CommClient.cpp,
server/CommServer.cpp, server/Persistance.cpp, tools/cyctrl.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cyisoload.cpp,
tools/cypasswd.cpp: Removed unused config.h.
* client/ObserverClient.cpp, common/const.h, tools/cycmd.cpp:
Use default password if the admin account cannot be fetched from
the database.
* client/Py_CreatorClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, rulesets/Character.cpp, rulesets/Creator.cpp,
rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.cpp,
rulesets/MemMap.cpp, rulesets/Py_Mind.cpp, rulesets/Py_Thing.cpp,
rulesets/Py_World.cpp, rulesets/Thing.cpp, server/Account.cpp,
server/Admin.cpp, server/Connection.cpp, tools/cywatchdog.cpp:
Make many of the member variables of Entity protected, and add
the required accessors. Changed the name of the id attribute
to m_id.
* common/BaseWorld.h, common/database.cpp, common/persistance.cpp:
Removed unused includes.
* common/Chop.h, common/Cut.h, common/Eat.h, common/Fire.h,
common/Generic.h, common/Load.h, common/Nourish.h, common/Save.h,
common/Setup.h, common/Tick.h: Moved definition of virtual
functions into cpp file, to reduce wasted code.
* common/Makefile.am: Create cyphesis library, which can be used by
other applications to access cyphesis databases.
* common/config.h, common/database.h, server/Persistance.cpp,
tools/cydbload.cpp, tools/cyisoload.cpp, tools/cypasswd.cpp:
Remove conditional compilation of db code. db3 is now required.
* server/WorldRouter.h: Fixed getNewId() so it take const string.
* server/server.cpp: Removed python shutdown, so it does not
mess up the db if it causes a segfault.
Al Riddoch <alriddoch@zepler.org>
2001-10-17 14:09:42 +00:00
|
|
|
}
|
2003-08-13 00:29:20 +00:00
|
|
|
return 0;
|
2001-10-06 16:52:02 +00:00
|
|
|
}
|
2004-10-05 14:57:11 +00:00
|
|
|
server = "localhost";
|
2001-03-30 17:17:47 +00:00
|
|
|
}
|
2003-08-13 00:29:20 +00:00
|
|
|
|
|
|
|
|
std::cerr << "Attempting tcp connection" << std::endl << std::flush;
|
|
|
|
|
|
|
|
|
|
Interactive<tcp_socket_stream> bridge;
|
2003-08-13 00:47:13 +00:00
|
|
|
|
2004-10-05 14:57:11 +00:00
|
|
|
if (bridge.connect(server) != 0) {
|
2001-10-06 16:52:02 +00:00
|
|
|
return 1;
|
2001-03-30 17:17:47 +00:00
|
|
|
}
|
2006-08-09 00:04:17 +00:00
|
|
|
bridge.setup();
|
2003-08-13 00:47:13 +00:00
|
|
|
if (!interactive) {
|
|
|
|
|
std::cerr << "WARNING: No login details available for remote host"
|
|
|
|
|
<< std::endl
|
|
|
|
|
<< "WARNING: Attempting command without logging in"
|
|
|
|
|
<< std::endl << std::flush;
|
|
|
|
|
} else {
|
|
|
|
|
bridge.getLogin();
|
|
|
|
|
std::cout << "Logging in... " << std::flush;
|
2004-10-02 Al Riddoch <alriddoch@zepler.org>
* 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, server/CommListener.cpp,
server/CommListener.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/server.cpp, tools/cycmd.cpp:
Use int for returning error status.
2004-10-03 00:38:55 +00:00
|
|
|
if (bridge.login() != 0) {
|
2003-08-13 00:47:13 +00:00
|
|
|
std::cout << "failed." << std::endl << std::flush;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
std::cout << "done." << std::endl << std::flush;
|
|
|
|
|
}
|
2001-03-16 11:38:14 +00:00
|
|
|
if (!interactive) {
|
|
|
|
|
bridge.exec(cmd, "");
|
2001-03-30 17:17:47 +00:00
|
|
|
} else {
|
2002-12-06 10:53:57 +00:00
|
|
|
bridge.loop();
|
2001-03-16 11:38:14 +00:00
|
|
|
}
|
2004-11-24 01:19:31 +00:00
|
|
|
delete global_conf;
|
2001-10-06 16:52:02 +00:00
|
|
|
return 0;
|
2001-03-16 11:38:14 +00:00
|
|
|
}
|