2006-01-19 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h, client/BaseClient.cpp,
client/BaseClient.h, client/CharacterClient.cpp,
client/CharacterClient.h, client/ClientConnection.cpp,
client/ClientConnection.h, client/CreatorClient.cpp,
client/CreatorClient.h, client/ObserverClient.cpp,
client/ObserverClient.h, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp,
client/define_world.cpp, client/define_world.h, common/Add.h,
common/Affect.h, common/AtlasFileLoader.cpp,
common/AtlasFileLoader.h, common/Attack.h, common/BaseEntity.cpp,
common/BaseEntity.h, common/BaseWorld.cpp, common/BaseWorld.h,
common/Burn.h, common/Chop.h, common/Connect.h, common/CustomOp.cpp,
common/CustomOp.h, common/CustomOp_impl.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Delve.h, common/Dig.h,
common/Eat.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/Generic.h, common/Load.h,
common/Monitor.h, common/Mow.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Property.cpp,
common/Property.h, common/Property_impl.h, common/Save.h,
common/Setup.h, common/Tick.h, common/Unseen.h, common/Update.h,
common/Use.h, common/Wield.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/id.cpp, common/id.h, common/inheritance.cpp,
common/inheritance.h, common/inheritance_impl.h, common/log.cpp,
common/log.h, common/newid.cpp, common/nls.h, common/op_switch.h,
common/operations.cpp, common/operations.h, common/random.h,
common/refno.h, common/serialno.cpp, common/serialno.h,
common/system.cpp, common/system.h, common/terrain_utils.cpp,
common/terrain_utils.h, common/type_utils.h, common/types.h,
common/utility.cpp, common/utility.h, modules/DateTime.cpp,
modules/DateTime.h, modules/Location.cpp, modules/Location.h,
modules/WorldTime.cpp, modules/WorldTime.h, physics/BBox.cpp,
physics/BBox.h, physics/Collision.cpp, physics/Collision.h,
physics/Quaternion.cpp, physics/Quaternion.h, physics/Vector3D.cpp,
physics/Vector3D.h, physics/VectorPol.h, rulesets/Area.cpp,
rulesets/Area.h, rulesets/AreaProperty.cpp, rulesets/AreaProperty.h,
rulesets/ArithmeticScript.cpp, rulesets/ArithmeticScript.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/CalendarProperty.cpp, rulesets/CalendarProperty.h,
rulesets/Character.cpp, rulesets/Character.h, rulesets/Combat.cpp,
rulesets/Combat.h, rulesets/Container.cpp, rulesets/Container.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/EntityProperties.cpp,
rulesets/Entity_getLocation.h, rulesets/Fell.cpp, rulesets/Fell.h,
rulesets/Food.cpp, rulesets/Food.h, rulesets/Line.cpp,
rulesets/Line.h, rulesets/LineProperty.cpp, rulesets/LineProperty.h,
rulesets/MemEntity.cpp, rulesets/MemEntity.h, rulesets/MemMap.cpp,
rulesets/MemMap.h, rulesets/MemMap_methods.h,
rulesets/MindFactory.cpp, rulesets/MindFactory.h, rulesets/Missile.h,
rulesets/Motion.cpp, rulesets/Motion.h, rulesets/Movement.cpp,
rulesets/Movement.h, rulesets/Pedestrian.cpp, rulesets/Pedestrian.h,
rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_BBox.cpp,
rulesets/Py_BBox.h, rulesets/Py_EntityWrapper.h,
rulesets/Py_Location.cpp, rulesets/Py_Location.h,
rulesets/Py_Map.cpp, rulesets/Py_Map.h, rulesets/Py_Mind.cpp,
rulesets/Py_Mind.h, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Operation.h,
rulesets/Py_Oplist.cpp, rulesets/Py_Oplist.h, rulesets/Py_Optime.cpp,
rulesets/Py_Optime.h, rulesets/Py_Point3D.cpp, rulesets/Py_Point3D.h,
rulesets/Py_Property.cpp, rulesets/Py_Property.h,
rulesets/Py_Quaternion.cpp, rulesets/Py_Quaternion.h,
rulesets/Py_RootEntity.cpp, rulesets/Py_RootEntity.h,
rulesets/Py_Statistics.cpp, rulesets/Py_Statistics.h,
rulesets/Py_Task.cpp, rulesets/Py_Task.h, rulesets/Py_Thing.cpp,
rulesets/Py_Thing.h, rulesets/Py_Vector3D.cpp,
rulesets/Py_Vector3D.h, rulesets/Py_World.cpp, rulesets/Py_World.h,
rulesets/Py_WorldTime.cpp, rulesets/Py_WorldTime.h,
rulesets/PythonArithmeticScript.cpp,
rulesets/PythonArithmeticScript.h, rulesets/PythonMindScript.cpp,
rulesets/PythonMindScript.h, rulesets/PythonScript.cpp,
rulesets/PythonScript.h, rulesets/PythonThingScript.cpp,
rulesets/PythonThingScript.h, rulesets/PythonWrapper.cpp,
rulesets/PythonWrapper.h, rulesets/Python_API.cpp,
rulesets/Python_API.h, rulesets/Python_Script_Utils.h,
rulesets/Script.cpp, rulesets/Script.h, rulesets/Stackable.cpp,
rulesets/Stackable.h, rulesets/Statistics.cpp, rulesets/Statistics.h,
rulesets/StatisticsProperty.cpp, rulesets/StatisticsProperty.h,
rulesets/Structure.cpp, rulesets/Structure.h, rulesets/Task.cpp,
rulesets/Task.h, rulesets/TaskScript.cpp, rulesets/TaskScript.h,
rulesets/TerrainProperty.cpp, rulesets/TerrainProperty.h,
rulesets/Thing.cpp, rulesets/Thing.h, rulesets/ThingFactory.cpp,
rulesets/ThingFactory.h, rulesets/World.cpp, rulesets/World.h,
rulesets/attributes.h, server/Account.cpp, server/Account.h,
server/Admin.cpp, server/Admin.h, server/ArithmeticFactory.cpp,
server/ArithmeticFactory.h, server/CommClient.cpp,
server/CommClient.h, server/CommIdleSocket.cpp,
server/CommIdleSocket.h, server/CommListener.cpp,
server/CommListener.h, server/CommLocalClient.cpp,
server/CommLocalClient.h, server/CommMDNSPublisher.cpp,
server/CommMDNSPublisher.h, server/CommMaster.cpp,
server/CommMaster.h, server/CommMetaClient.cpp,
server/CommMetaClient.h, server/CommPSQLSocket.cpp,
server/CommPSQLSocket.h, server/CommPeer.cpp,
server/CommPeer.h, server/CommPeerListener.cpp,
server/CommPeerListener.h, server/CommRemoteClient.cpp,
server/CommRemoteClient.h, server/CommServer.cpp,
server/CommServer.h, server/CommSlaveClient.cpp,
server/CommSlaveClient.h, server/CommSlaveListener.cpp,
server/CommSlaveListener.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/Connection_methods.h,
server/EntityFactory.cpp, server/EntityFactory.h,
server/ExternalMind.cpp, server/ExternalMind.h,
server/Idle.cpp, server/Idle.h, server/Lobby.cpp, server/Lobby.h,
server/Master.cpp, server/Master.h, server/Peer.cpp, server/Peer.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.cpp, server/PersistantThingFactory.h,
server/PersistantThingFactory_impl.h, server/Persistor.cpp,
server/Persistor.h, server/Persistor_impl.h,
server/Player.cpp, server/Player.h, server/Restoration.cpp,
server/Restoration.h, server/Restorer.cpp, server/Restorer.h,
server/Restorer_impl.h, server/ScriptFactory.cpp,
server/ScriptFactory.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/ServerRouting_methods.h,
server/SlaveClientConnection.cpp, server/SlaveClientConnection.h,
server/TaskFactory.cpp, server/TaskFactory.h,
server/TrustedConnection.cpp, server/TrustedConnection.h,
server/WorldRouter.cpp, server/WorldRouter.h,
server/server.cpp, server/server.h, server/slave.cpp,
tests/Areatest.cpp, tests/BaseEntitytest.cpp,
tests/Charactertest.cpp, tests/Containertest.cpp,
tests/Creatortest.cpp, tests/EntityExerciser.h,
tests/EntityFactorytest.cpp, tests/Entitytest.cpp,
tests/Foodtest.cpp, tests/IGEntityExerciser.h,
tests/Linetest.cpp, tests/Locationtest.cpp, tests/OOGThingtest.cpp,
tests/Planttest.cpp, tests/Propertytest.cpp, tests/Stackabletest.cpp,
tests/Structuretest.cpp, tests/Tasktest.cpp, tests/TestWorld.h,
tests/Thingtest.cpp, tests/WorldTimetest.cpp, tests/Worldtest.cpp,
tests/allOperations.h, tests/collisiontest.cpp, tests/consttest.cpp,
tests/distancetest.cpp, tests/emergencetest.cpp,
tests/inheritancetest.cpp, tests/logtest.cpp, tests/randomtest.cpp,
tests/systemtest.cpp, tests/transformtest.cpp,
tests/type_utilstest.cpp, tests/utilitytest.cpp,
tools/AdminClient.cpp, tools/AdminClient.h, tools/cyaddrules.cpp,
tools/cycmd.cpp, tools/cyconfig.cpp, tools/cyconvertrules.cpp,
tools/cyctrl.cpp, tools/cydbload.cpp, tools/cydumprules.cpp,
tools/cyisoload.cpp, tools/cyloadrules.cpp, tools/cypasswd.cpp,
tools/cywatchdog.cpp: Replace the copyright and license statements
with new versions that include disclaimer of warranty, and
permit distribution under later versions of the GPL.
2006-01-19 02:17:06 +00:00
|
|
|
// Cyphesis Online RPG Server and AI Engine
|
2004-11-29 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.cpp,
common/BaseWorld.h, common/Burn.h, common/Chop.h, common/Cut.h,
common/Database.cpp, common/Database.h, common/Eat.h,
common/Generic.h, common/Load.h, common/Nourish.h,
common/OOGThing.cpp, common/OOGThing.h, common/Save.h,
common/Setup.h, common/Tick.h, common/accountbase.cpp,
common/accountbase.h, common/const.cpp, common/const.h,
common/custom.cpp, common/debug.h, common/globals.cpp,
common/globals.h, common/inheritance.cpp, common/inheritance.h,
common/log.cpp, common/log.h, common/op_switch.h, common/random.h,
common/serialno.h, common/system.cpp, common/system.h,
common/type_utils.h, common/types.h, common/utility.cpp,
common/utility.h: Update copyright dates in files as appropriate.
2004-11-29 21:42:00 +00:00
|
|
|
// Copyright (C) 2000-2004 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
|
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
|
|
|
|
|
|
|
|
#include "Database.h"
|
|
|
|
|
|
2005-11-12 01:40:37 +00:00
|
|
|
#include "id.h"
|
2002-07-14 21:04:50 +00:00
|
|
|
#include "log.h"
|
2002-04-12 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.cpp,
common/Database.cpp, common/accountbase.h, modules/WorldTime.h,
rulesets/Py_World.cpp, server/Admin.cpp, server/Persistance.cpp,
server/Persistance.h:
Clean up includes.
* rulesets/Entity.cpp, rulesets/Entity.h: Write improved way of
handling immutable object attributes.
* server/EntityFactory.cpp, server/Player.cpp, server/Player.h:
Implement a character_types attribute on the player account,
by adding "playable" tag to rules database, and setting
up a set of character types when rules are read from database.
2002-04-12 21:54:44 +00:00
|
|
|
#include "debug.h"
|
|
|
|
|
#include "globals.h"
|
2005-09-13 01:01:58 +00:00
|
|
|
#include "compose.hpp"
|
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
|
|
|
|
2005-08-27 14:52:12 +00:00
|
|
|
#include <Atlas/Message/MEncoder.h>
|
|
|
|
|
#include <Atlas/Message/Element.h>
|
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
|
|
|
#include <Atlas/Codecs/XML.h>
|
|
|
|
|
|
2006-01-04 15:06:46 +00:00
|
|
|
#include <varconf/config.h>
|
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
|
|
|
|
2002-04-12 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.cpp,
common/Database.cpp, common/accountbase.h, modules/WorldTime.h,
rulesets/Py_World.cpp, server/Admin.cpp, server/Persistance.cpp,
server/Persistance.h:
Clean up includes.
* rulesets/Entity.cpp, rulesets/Entity.h: Write improved way of
handling immutable object attributes.
* server/EntityFactory.cpp, server/Player.cpp, server/Player.h:
Implement a character_types attribute on the player account,
by adding "playable" tag to rules database, and setting
up a set of character types when rules are read from database.
2002-04-12 21:54:44 +00:00
|
|
|
#include <iostream>
|
2004-11-16 12:27:27 +00:00
|
|
|
#include <sstream>
|
2002-04-12 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.cpp,
common/Database.cpp, common/accountbase.h, modules/WorldTime.h,
rulesets/Py_World.cpp, server/Admin.cpp, server/Persistance.cpp,
server/Persistance.h:
Clean up includes.
* rulesets/Entity.cpp, rulesets/Entity.h: Write improved way of
handling immutable object attributes.
* server/EntityFactory.cpp, server/Player.cpp, server/Player.h:
Implement a character_types attribute on the player account,
by adding "playable" tag to rules database, and setting
up a set of character types when rules are read from database.
2002-04-12 21:54:44 +00:00
|
|
|
|
2003-10-30 00:03:54 +00:00
|
|
|
#include <cassert>
|
|
|
|
|
|
2003-08-07 23:03:26 +00:00
|
|
|
using Atlas::Message::Element;
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/Lobby.cpp, server/Lobby.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
using Atlas::Message::MapType;
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
|
2003-01-11 18:21:31 +00:00
|
|
|
typedef Atlas::Codecs::XML Serialiser;
|
|
|
|
|
|
2003-10-27 12:04:53 +00:00
|
|
|
static const bool debug_flag = false;
|
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
|
|
|
|
|
|
|
|
Database * Database::m_instance = NULL;
|
|
|
|
|
|
2004-10-04 13:10:01 +00:00
|
|
|
static void databaseNotice(void * arg, const char * message)
|
|
|
|
|
{
|
|
|
|
|
std::string msg = std::string("DATABASE: ") + message;
|
|
|
|
|
// Remove the trailing \n from the message.
|
|
|
|
|
msg = msg.substr(0, msg.size() - 1);
|
|
|
|
|
log(NOTICE, msg.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-04 18:31:38 +00:00
|
|
|
Database::Database() : m_rule_db("rules"),
|
2003-10-24 23:50:12 +00:00
|
|
|
m_queryInProgress(false),
|
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
|
|
|
m_connection(NULL)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2002-11-24 02:51:54 +00:00
|
|
|
bool Database::tuplesOk()
|
|
|
|
|
{
|
|
|
|
|
bool status = false;
|
|
|
|
|
|
|
|
|
|
PGresult * res;
|
|
|
|
|
while ((res = PQgetResult(m_connection)) != NULL) {
|
2002-12-10 23:38:15 +00:00
|
|
|
if (PQresultStatus(res) == PGRES_TUPLES_OK) {
|
|
|
|
|
status = true;
|
|
|
|
|
}
|
2003-07-21 09:37:58 +00:00
|
|
|
PQclear(res);
|
2002-11-24 02:51:54 +00:00
|
|
|
};
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Database::commandOk()
|
|
|
|
|
{
|
|
|
|
|
bool status = false;
|
|
|
|
|
|
|
|
|
|
PGresult * res;
|
|
|
|
|
while ((res = PQgetResult(m_connection)) != NULL) {
|
2002-12-10 23:38:15 +00:00
|
|
|
if (PQresultStatus(res) == PGRES_COMMAND_OK) {
|
|
|
|
|
status = true;
|
2004-07-12 10:58:20 +00:00
|
|
|
} else {
|
|
|
|
|
reportError();
|
2002-12-10 23:38:15 +00:00
|
|
|
}
|
2003-07-21 09:37:58 +00:00
|
|
|
PQclear(res);
|
2002-11-24 02:51:54 +00:00
|
|
|
};
|
|
|
|
|
return status;
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-03 01:50:49 +00:00
|
|
|
int Database::initConnection(bool createDatabase)
|
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
|
|
|
{
|
|
|
|
|
std::stringstream conninfos;
|
|
|
|
|
if (global_conf->findItem("cyphesis", "dbserver")) {
|
2004-06-03 17:34:58 +00:00
|
|
|
std::string db_server(global_conf->getItem("cyphesis", "dbserver"));
|
|
|
|
|
if (db_server.empty()) {
|
|
|
|
|
log(WARNING, "Empty database hostname specified in config file. Using none.");
|
|
|
|
|
} else {
|
|
|
|
|
conninfos << "host=" << " ";
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string dbname = "cyphesis";
|
|
|
|
|
if (global_conf->findItem("cyphesis", "dbname")) {
|
2005-04-03 16:36:13 +00:00
|
|
|
dbname = global_conf->getItem("cyphesis", "dbname").as_string();
|
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
|
|
|
}
|
|
|
|
|
conninfos << "dbname=" << dbname << " ";
|
|
|
|
|
|
|
|
|
|
if (global_conf->findItem("cyphesis", "dbuser")) {
|
2004-06-03 17:34:58 +00:00
|
|
|
std::string db_user(global_conf->getItem("cyphesis", "dbuser"));
|
|
|
|
|
if (db_user.empty()) {
|
|
|
|
|
log(WARNING, "Empty username specified in config file. Using current user.");
|
|
|
|
|
} else {
|
|
|
|
|
conninfos << "user=" << db_user << " ";
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2002-03-03 00:48:28 +00:00
|
|
|
if (global_conf->findItem("cyphesis", "dbpasswd")) {
|
2005-04-03 16:36:13 +00:00
|
|
|
conninfos << "password=" << global_conf->getItem("cyphesis", "dbpasswd").as_string() << " ";
|
2002-03-03 00:48:28 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
const std::string cinfo = conninfos.str();
|
|
|
|
|
|
|
|
|
|
if (createDatabase) {
|
2002-06-24 10:27:06 +00:00
|
|
|
// Currently not able to create the database
|
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-04 13:10:01 +00:00
|
|
|
|
|
|
|
|
|
2002-11-24 02:51:54 +00:00
|
|
|
m_connection = PQconnectdb(cinfo.c_str());
|
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
|
|
|
|
2005-09-13 01:01:58 +00:00
|
|
|
if (m_connection == NULL) {
|
|
|
|
|
log(ERROR, "Database connection failed with unknown error");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (PQstatus(m_connection) != CONNECTION_OK) {
|
|
|
|
|
log(ERROR, String::compose("Connection to database failed: \"%1\"", PQerrorMessage(m_connection)).c_str());
|
2004-10-03 01:50:49 +00:00
|
|
|
return -1;
|
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-04 13:10:01 +00:00
|
|
|
PQsetNoticeProcessor(m_connection, databaseNotice, 0);
|
|
|
|
|
|
2004-10-03 01:50:49 +00:00
|
|
|
return 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
|
|
|
}
|
|
|
|
|
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
bool Database::initRule(bool createTables)
|
|
|
|
|
{
|
|
|
|
|
int status = 0;
|
2004-03-08 14:36:44 +00:00
|
|
|
clearPendingQuery();
|
2004-10-02 01:12:02 +00:00
|
|
|
status = PQsendQuery(m_connection, "SELECT * FROM rules WHERE id = 'test' AND contents = 'test'");
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
if (!status) {
|
2002-12-10 23:38:15 +00:00
|
|
|
reportError();
|
2002-11-24 02:51:54 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2004-07-12 10:58:20 +00:00
|
|
|
|
2002-11-24 02:51:54 +00:00
|
|
|
if (!tuplesOk()) {
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
debug(std::cout << "Rule table does not exist"
|
|
|
|
|
<< std::endl << std::flush;);
|
|
|
|
|
if (createTables) {
|
2004-10-02 01:12:02 +00:00
|
|
|
status = PQsendQuery(m_connection, "CREATE TABLE rules ( id varchar(80) PRIMARY KEY, ruleset varchar(32), contents text ) WITHOUT OIDS");
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
if (!status) {
|
2002-12-10 23:38:15 +00:00
|
|
|
reportError();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2002-12-11 01:30:05 +00:00
|
|
|
if (!commandOk()) {
|
2002-07-14 21:04:50 +00:00
|
|
|
log(ERROR, "Error creating rules table in database");
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
reportError();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2003-10-28 00:18:18 +00:00
|
|
|
allTables.insert("rules");
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
} else {
|
2002-07-14 21:04:50 +00:00
|
|
|
log(ERROR, "Server table does not exist in database");
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-10-28 00:18:18 +00:00
|
|
|
allTables.insert("rules");
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
void Database::shutdownConnection()
|
|
|
|
|
{
|
2002-11-24 02:51:54 +00:00
|
|
|
PQfinish(m_connection);
|
2006-05-06 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/newid.cpp, server/server.cpp:
Modify new ID checks so that code still runs when database is
unavailable, and events requiring new IDs fail cleanly.
* server/Connection.cpp: Report a failure to create a player
account if no ID available.
* rulesets/BaseMind.cpp: When processing appearance ops, handle
stamp more efficiently, report an error if ID is missing
from argument.
* server/IdlePSQLConnector.cpp, server/IdlePSQLConnector.h:
Implement re-connecting to the Database if connection is lost.
* rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/Thing.cpp:
Ensure STAMP is present on appearance op args.
* server/CommListener.cpp, server/CommListener.h,
server/CommPeerListener.cpp, server/CommPeerListener.h,
server/CommSlaveListener.cpp, server/CommSlaveListener.h,
server/CommUnixListener.cpp, server/CommUnixListener.h:
Add a return value to method for creating new client socket
objects, and use it to return failure if no ID is available
from the database for a new object.
* rulesets/Py_Point3D.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Python_API.cpp: Add "new" method for class wrappers, and
call the in place constructor from new rather than init. Re-write
internal function for creating new instances so it uses the "new"
method.
* rulesets/Py_Statistics.cpp: Remove some obsolete code inadvertedly
copied from another file. Comment out some unused code to get rid
of a warning.
* server/CommPSQLSocket.cpp: Clear the database connection from
destructor.
* tests/python_class.cpp: A new test for experimenting with new
Python wrappers.
2006-05-06 21:36:57 +00:00
|
|
|
m_connection = 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Database * Database::instance()
|
|
|
|
|
{
|
|
|
|
|
if (m_instance == NULL) {
|
|
|
|
|
m_instance = new Database();
|
|
|
|
|
}
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Database::decodeObject(const std::string & data,
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/Lobby.cpp, server/Lobby.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
MapType &o)
|
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
|
|
|
{
|
2003-01-12 03:21:54 +00:00
|
|
|
if (data.empty()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
std::stringstream str(data, std::ios::in);
|
|
|
|
|
|
2005-08-27 14:52:12 +00:00
|
|
|
Serialiser codec(str, m_d);
|
|
|
|
|
Atlas::Message::Encoder enc(codec);
|
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
|
|
|
|
|
|
|
|
// Clear the decoder
|
|
|
|
|
m_d.get();
|
|
|
|
|
|
2003-08-07 23:03:26 +00:00
|
|
|
codec.poll();
|
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
|
|
|
|
|
|
|
|
if (!m_d.check()) {
|
2002-07-14 21:04:50 +00:00
|
|
|
log(WARNING, "Database entry does not appear to be decodable");
|
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
|
|
|
return false;
|
|
|
|
|
}
|
2004-07-12 10:58:20 +00:00
|
|
|
|
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
|
|
|
o = m_d.get();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/Lobby.cpp, server/Lobby.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
bool Database::encodeObject(const MapType & o,
|
2003-01-11 18:21:31 +00:00
|
|
|
std::string & data)
|
|
|
|
|
{
|
|
|
|
|
std::stringstream str;
|
|
|
|
|
|
2005-08-27 14:52:12 +00:00
|
|
|
Serialiser codec(str, m_d);
|
|
|
|
|
Atlas::Message::Encoder enc(codec);
|
2003-01-11 18:21:31 +00:00
|
|
|
|
2003-08-07 23:03:26 +00:00
|
|
|
codec.streamBegin();
|
2005-08-27 14:52:12 +00:00
|
|
|
enc.streamMessageElement(o);
|
2003-08-07 23:03:26 +00:00
|
|
|
codec.streamEnd();
|
2003-01-11 18:21:31 +00:00
|
|
|
|
|
|
|
|
data = str.str();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
bool Database::getObject(const std::string & table, const std::string & key,
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/Lobby.cpp, server/Lobby.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
MapType & o)
|
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
|
|
|
{
|
2002-11-24 02:51:54 +00:00
|
|
|
debug(std::cout << "Database::getObject() " << table << "." << key
|
|
|
|
|
<< std::endl << std::flush;);
|
2004-10-02 01:12:02 +00:00
|
|
|
std::string query = std::string("SELECT * FROM ") + table + " WHERE id = '" + key + "'";
|
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
|
|
|
|
2003-10-27 01:59:53 +00:00
|
|
|
clearPendingQuery();
|
2002-11-24 02:51:54 +00:00
|
|
|
int status = PQsendQuery(m_connection, query.c_str());
|
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
|
|
|
if (!status) {
|
2002-12-10 23:38:15 +00:00
|
|
|
reportError();
|
2002-11-24 02:51:54 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PGresult * res;
|
|
|
|
|
if ((res = PQgetResult(m_connection)) == NULL) {
|
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
|
|
|
debug(std::cout << "Error accessing " << key << " in " << table
|
2002-03-06 19:40:55 +00:00
|
|
|
<< " table" << std::endl << std::flush;);
|
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
|
|
|
return false;
|
|
|
|
|
}
|
2002-11-24 02:51:54 +00:00
|
|
|
if ((PQntuples(res) < 1) || (PQnfields(res) < 2)) {
|
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
|
|
|
debug(std::cout << "No entry for " << key << " in " << table
|
|
|
|
|
<< " table" << std::endl << std::flush;);
|
2003-07-21 09:37:58 +00:00
|
|
|
PQclear(res);
|
|
|
|
|
while ((res = PQgetResult(m_connection)) != NULL) {
|
|
|
|
|
PQclear(res);
|
|
|
|
|
}
|
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
|
|
|
return false;
|
|
|
|
|
}
|
2002-11-24 02:51:54 +00:00
|
|
|
const char * data = PQgetvalue(res, 0, 1);
|
2002-03-06 19:40:55 +00:00
|
|
|
debug(std::cout << "Got record " << key << " from database, value " << data
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
<< std::endl << std::flush;);
|
2002-11-24 02:51:54 +00:00
|
|
|
|
|
|
|
|
bool ret = decodeObject(data, o);
|
2003-07-21 09:37:58 +00:00
|
|
|
PQclear(res);
|
2002-11-24 02:51:54 +00:00
|
|
|
|
2003-07-21 09:37:58 +00:00
|
|
|
while ((res = PQgetResult(m_connection)) != NULL) {
|
|
|
|
|
PQclear(res);
|
2002-11-24 02:51:54 +00:00
|
|
|
log(ERROR, "Extra database result to simple query.");
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return ret;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Database::putObject(const std::string & table,
|
|
|
|
|
const std::string & key,
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/Lobby.cpp, server/Lobby.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
const MapType & o,
|
2004-07-12 10:58:20 +00:00
|
|
|
const StringVector & c)
|
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
|
|
|
{
|
2002-11-24 02:51:54 +00:00
|
|
|
debug(std::cout << "Database::putObject() " << table << "." << key
|
|
|
|
|
<< std::endl << std::flush;);
|
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
|
|
|
std::stringstream str;
|
|
|
|
|
|
2005-08-27 14:52:12 +00:00
|
|
|
Serialiser codec(str, m_d);
|
|
|
|
|
Atlas::Message::Encoder enc(codec);
|
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
|
|
|
|
2003-08-07 23:03:26 +00:00
|
|
|
codec.streamBegin();
|
2005-08-27 14:52:12 +00:00
|
|
|
enc.streamMessageElement(o);
|
2003-08-07 23:03:26 +00:00
|
|
|
codec.streamEnd();
|
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
|
|
|
|
2002-03-06 19:40:55 +00:00
|
|
|
debug(std::cout << "Encoded to: " << str.str().c_str() << " "
|
|
|
|
|
<< str.str().size() << std::endl << std::flush;);
|
2004-07-12 10:58:20 +00:00
|
|
|
std::string query = std::string("INSERT INTO ") + table + " VALUES ('" + key;
|
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
|
|
|
StringVector::const_iterator Iend = c.end();
|
|
|
|
|
for (StringVector::const_iterator I = c.begin(); I != Iend; ++I) {
|
2004-07-12 10:58:20 +00:00
|
|
|
query += "', '";
|
|
|
|
|
query += *I;
|
|
|
|
|
}
|
|
|
|
|
query += "', '";
|
|
|
|
|
query += str.str();
|
2004-10-02 01:12:02 +00:00
|
|
|
query += "')";
|
2003-10-27 01:59:53 +00:00
|
|
|
return scheduleCommand(query);
|
2002-03-03 02:37:35 +00:00
|
|
|
}
|
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
|
|
|
|
2002-03-03 02:37:35 +00:00
|
|
|
bool Database::updateObject(const std::string & table,
|
|
|
|
|
const std::string & key,
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/Lobby.cpp, server/Lobby.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
const MapType & o)
|
2002-03-03 02:37:35 +00:00
|
|
|
{
|
2002-11-24 02:51:54 +00:00
|
|
|
debug(std::cout << "Database::updateObject() " << table << "." << key
|
|
|
|
|
<< std::endl << std::flush;);
|
2002-03-03 02:37:35 +00:00
|
|
|
std::stringstream str;
|
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
|
|
|
|
2005-08-27 14:52:12 +00:00
|
|
|
Serialiser codec(str, m_d);
|
|
|
|
|
Atlas::Message::Encoder enc(codec);
|
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
|
|
|
|
2003-08-07 23:03:26 +00:00
|
|
|
codec.streamBegin();
|
2005-08-27 14:52:12 +00:00
|
|
|
enc.streamMessageElement(o);
|
2003-08-07 23:03:26 +00:00
|
|
|
codec.streamEnd();
|
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
|
|
|
|
2002-07-14 16:10:17 +00:00
|
|
|
std::string query = std::string("UPDATE ") + table + " SET contents = '" +
|
2004-10-02 01:12:02 +00:00
|
|
|
str.str() + "' WHERE id='" + key + "'";
|
2003-10-27 01:59:53 +00:00
|
|
|
return scheduleCommand(query);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Database::delObject(const std::string & table, const std::string & key)
|
|
|
|
|
{
|
|
|
|
|
#if 0
|
|
|
|
|
Dbt key, data;
|
|
|
|
|
|
|
|
|
|
key.set_data((void*)keystr);
|
|
|
|
|
key.set_size(strlen(keystr) + 1);
|
|
|
|
|
|
|
|
|
|
int err;
|
|
|
|
|
if ((err = db.del(NULL, &key, 0)) != 0) {
|
|
|
|
|
debug(cout << "db.del.ERROR! " << err << endl << flush;);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
#endif
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-22 11:25:24 +00:00
|
|
|
bool Database::hasKey(const std::string & table, const std::string & key)
|
|
|
|
|
{
|
|
|
|
|
std::string query = std::string("SELECT id FROM ") + table +
|
2004-10-02 01:12:02 +00:00
|
|
|
" WHERE id='" + key + "'";
|
2004-07-22 11:25:24 +00:00
|
|
|
|
|
|
|
|
clearPendingQuery();
|
|
|
|
|
int status = PQsendQuery(m_connection, query.c_str());
|
|
|
|
|
|
|
|
|
|
if (!status) {
|
|
|
|
|
reportError();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PGresult * res;
|
|
|
|
|
bool ret = false;
|
|
|
|
|
if ((res = PQgetResult(m_connection)) == NULL) {
|
|
|
|
|
debug(std::cout << "Error accessing " << table
|
|
|
|
|
<< " table" << std::endl << std::flush;);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
int results = PQntuples(res);
|
|
|
|
|
if (results > 0) {
|
|
|
|
|
ret = true;
|
|
|
|
|
}
|
|
|
|
|
PQclear(res);
|
|
|
|
|
while ((res = PQgetResult(m_connection)) != NULL) {
|
|
|
|
|
PQclear(res);
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/Lobby.cpp, server/Lobby.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
bool Database::getTable(const std::string & table, MapType &o)
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
{
|
2004-10-02 01:12:02 +00:00
|
|
|
std::string query = std::string("SELECT * FROM ") + table;
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
|
2003-10-27 01:59:53 +00:00
|
|
|
clearPendingQuery();
|
2002-11-24 02:51:54 +00:00
|
|
|
int status = PQsendQuery(m_connection, query.c_str());
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
|
|
|
|
|
if (!status) {
|
2002-11-24 02:51:54 +00:00
|
|
|
reportError();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PGresult * res;
|
|
|
|
|
if ((res = PQgetResult(m_connection)) == NULL) {
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
debug(std::cout << "Error accessing " << table
|
2002-03-06 19:40:55 +00:00
|
|
|
<< " table" << std::endl << std::flush;);
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2002-11-24 02:51:54 +00:00
|
|
|
int results = PQntuples(res);
|
|
|
|
|
if ((results < 1) || (PQnfields(res) < 2)) {
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
debug(std::cout << "No entries in " << table
|
|
|
|
|
<< " table" << std::endl << std::flush;);
|
2003-07-21 09:37:58 +00:00
|
|
|
PQclear(res);
|
|
|
|
|
while ((res = PQgetResult(m_connection)) != NULL) {
|
|
|
|
|
PQclear(res);
|
|
|
|
|
}
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2004-07-12 10:58:20 +00:00
|
|
|
int id_column = PQfnumber(res, "id"),
|
|
|
|
|
contents_column = PQfnumber(res, "contents");
|
|
|
|
|
|
|
|
|
|
if (id_column == -1 || contents_column == -1) {
|
|
|
|
|
log(ERROR, "Could not find 'id' and 'contents' columns in database result");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/Lobby.cpp, server/Lobby.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
MapType t;
|
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(int i = 0; i < results; ++i) {
|
2004-07-12 10:58:20 +00:00
|
|
|
const char * key = PQgetvalue(res, i, id_column);
|
|
|
|
|
const char * data = PQgetvalue(res, i, contents_column);
|
2002-03-06 19:40:55 +00:00
|
|
|
debug(std::cout << "Got record " << key << " from database, value "
|
|
|
|
|
<< data << std::endl << std::flush;);
|
2004-07-12 10:58:20 +00:00
|
|
|
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
if (decodeObject(data, t)) {
|
|
|
|
|
o[key] = t;
|
|
|
|
|
}
|
2004-07-12 10:58:20 +00:00
|
|
|
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
}
|
2003-07-21 09:37:58 +00:00
|
|
|
PQclear(res);
|
2002-11-24 02:51:54 +00:00
|
|
|
|
|
|
|
|
while ((res = PQgetResult(m_connection)) != NULL) {
|
2003-07-21 09:37:58 +00:00
|
|
|
PQclear(res);
|
2002-11-24 02:51:54 +00:00
|
|
|
log(ERROR, "Extra database result to simple query.");
|
|
|
|
|
};
|
|
|
|
|
|
2002-01-27 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/Database.h,
server/Persistance.cpp, server/Persistance.h:
Add a new table to store rulesets, so they can be persisted, and
edited online. The new ruleset format integrates information
about the class hierarchy, scripting and default attributes.
Added low level method to fetch an entire database table as an
Atlas map.
* tools/cyloadrules.cpp: New tool to load rulesets in new xml
format into database table.
* server/EntityFactory.cpp, server/EntityFactory.h:
New re-written Entity Factory, to support new rules database
table, and better class definition capabilities.
* rulesets/EntityFactory.cpp, rulesets/EntityFactory.h:
Removed from build.
* client/CommClient.cpp: Redundant include removed.
* rulesets/ThingFactory.h: Add storage to factory for script
info and default attributes.
* server/WorldRouter.cpp: Switch to using new EntityFactory.
* server/server.cpp: Removed old ruleset loading code, and now
simply load the ruleset names from the config file.
* tools/cycmd.cpp: Exit correctly if connection fails.
2002-01-27 00:38:27 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2002-01-28 Al Riddoch <alriddoch@zepler.org>
* client/ClientConnection.cpp, client/CommClient.h,
common/globals.cpp, common/globals.h, server/server.cpp,
tools/cycmd.cpp:
Make the TCP port number a global config setting, and
ensure it is used everwhere, so it can be overriden, and all
clients and tools will use it. Modify behavoir so that any
settings overridden on the command line are made semi-permanent
in the users home directory, making it easier for users to run
two versions on one machine at the same time.
* common/Database.cpp, common/Database.h: Remove obsolete iterator
code. Add a method to clear a given database table.
* server/Persistance.h, tools/cyloadrules.cpp:
Automate loading of the ruleset given in the config file, and
the rulesets it depends on, ensuring that the rules table
is cleared first.
2002-01-28 11:40:10 +00:00
|
|
|
bool Database::clearTable(const std::string & table)
|
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-02 01:12:02 +00:00
|
|
|
std::string query = std::string("DELETE FROM ") + table;
|
2003-10-27 01:59:53 +00:00
|
|
|
return scheduleCommand(query);
|
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
|
|
|
}
|
|
|
|
|
|
2002-01-28 Al Riddoch <alriddoch@zepler.org>
* client/ClientConnection.cpp, client/CommClient.h,
common/globals.cpp, common/globals.h, server/server.cpp,
tools/cycmd.cpp:
Make the TCP port number a global config setting, and
ensure it is used everwhere, so it can be overriden, and all
clients and tools will use it. Modify behavoir so that any
settings overridden on the command line are made semi-permanent
in the users home directory, making it easier for users to run
two versions on one machine at the same time.
* common/Database.cpp, common/Database.h: Remove obsolete iterator
code. Add a method to clear a given database table.
* server/Persistance.h, tools/cyloadrules.cpp:
Automate loading of the ruleset given in the config file, and
the rulesets it depends on, ensuring that the rules table
is cleared first.
2002-01-28 11:40:10 +00:00
|
|
|
void Database::reportError()
|
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-04 13:10:01 +00:00
|
|
|
char * message = PQerrorMessage(m_connection);
|
|
|
|
|
assert(message != NULL);
|
|
|
|
|
|
|
|
|
|
if (strlen(message) < 2) {
|
|
|
|
|
log(WARNING, "Zero length database error message");
|
|
|
|
|
}
|
|
|
|
|
std::string msg = std::string("DATABASE: ") + message;
|
|
|
|
|
msg = msg.substr(0, msg.size() - 1);
|
2002-07-14 21:04:50 +00:00
|
|
|
log(ERROR, msg.c_str());
|
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
|
|
|
}
|
2002-11-25 15:41:04 +00:00
|
|
|
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
const DatabaseResult Database::runSimpleSelectQuery(const std::string & query)
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
{
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
debug(std::cout << "QUERY: " << query << std::endl << std::flush;);
|
2003-10-27 01:59:53 +00:00
|
|
|
clearPendingQuery();
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
int status = PQsendQuery(m_connection, query.c_str());
|
|
|
|
|
if (!status) {
|
2005-01-13 00:38:41 +00:00
|
|
|
log(ERROR, "runSimpleSelectQuery(): Database query error.");
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
reportError();
|
|
|
|
|
return DatabaseResult(0);
|
|
|
|
|
}
|
|
|
|
|
debug(std::cout << "done" << std::endl << std::flush;);
|
|
|
|
|
PGresult * res;
|
|
|
|
|
if ((res = PQgetResult(m_connection)) == NULL) {
|
|
|
|
|
log(ERROR, "Error selecting.");
|
|
|
|
|
reportError();
|
|
|
|
|
debug(std::cout << "Row query didn't work"
|
|
|
|
|
<< std::endl << std::flush;);
|
|
|
|
|
return DatabaseResult(0);
|
|
|
|
|
}
|
|
|
|
|
if (PQresultStatus(res) != PGRES_TUPLES_OK) {
|
|
|
|
|
log(ERROR, "Error selecting row.");
|
2003-10-27 12:04:53 +00:00
|
|
|
debug(std::cout << "QUERY: " << query << std::endl << std::flush;);
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
reportError();
|
2003-07-21 09:37:58 +00:00
|
|
|
PQclear(res);
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
res = 0;
|
|
|
|
|
}
|
2003-07-21 09:37:58 +00:00
|
|
|
PGresult * nres;
|
|
|
|
|
while ((nres = PQgetResult(m_connection)) != NULL) {
|
|
|
|
|
PQclear(nres);
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
log(ERROR, "Extra database result to simple query.");
|
|
|
|
|
};
|
|
|
|
|
return DatabaseResult(res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Database::runCommandQuery(const std::string & query)
|
|
|
|
|
{
|
2003-10-27 01:59:53 +00:00
|
|
|
clearPendingQuery();
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
int status = PQsendQuery(m_connection, query.c_str());
|
|
|
|
|
if (!status) {
|
2005-01-13 00:38:41 +00:00
|
|
|
log(ERROR, "runCommandQuery(): Database query error.");
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
reportError();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!commandOk()) {
|
|
|
|
|
log(ERROR, "Error running command query row.");
|
|
|
|
|
log(NOTICE, query.c_str());
|
|
|
|
|
reportError();
|
|
|
|
|
debug(std::cout << "Row query didn't work"
|
|
|
|
|
<< std::endl << std::flush;);
|
|
|
|
|
} else {
|
|
|
|
|
debug(std::cout << "Query worked" << std::endl << std::flush;);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2004-07-14 18:31:07 +00:00
|
|
|
bool Database::registerRelation(std::string & tablename,
|
|
|
|
|
const std::string & sourcetable,
|
|
|
|
|
const std::string & targettable,
|
|
|
|
|
RelationType kind)
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
{
|
2004-07-14 18:31:07 +00:00
|
|
|
tablename = sourcetable + "_" + targettable;
|
|
|
|
|
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
std::string query = "SELECT * FROM ";
|
2004-07-14 18:31:07 +00:00
|
|
|
query += tablename;
|
2004-10-02 01:12:02 +00:00
|
|
|
query += " WHERE source = 0 AND target = 0";
|
2004-07-14 18:31:07 +00:00
|
|
|
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
std::string createquery = "CREATE TABLE ";
|
2004-07-14 18:31:07 +00:00
|
|
|
createquery += tablename;
|
|
|
|
|
if ((kind == OneToOne) || (kind == ManyToOne)) {
|
|
|
|
|
createquery += " (source integer UNIQUE REFERENCES ";
|
2003-01-05 19:55:52 +00:00
|
|
|
} else {
|
2004-07-14 18:31:07 +00:00
|
|
|
createquery += " (source integer REFERENCES ";
|
2003-01-05 19:55:52 +00:00
|
|
|
}
|
2004-07-14 18:31:07 +00:00
|
|
|
createquery += sourcetable;
|
|
|
|
|
#if 0
|
|
|
|
|
// FIXME Referential integrity not supported on inherited tables.
|
2003-01-05 19:55:52 +00:00
|
|
|
if ((kind == OneToOne) || (kind == OneToMany)) {
|
2004-07-14 18:31:07 +00:00
|
|
|
createquery += " (id), target integer UNIQUE REFERENCES ";
|
2003-01-05 19:55:52 +00:00
|
|
|
} else {
|
2004-07-14 18:31:07 +00:00
|
|
|
createquery += " (id), target integer REFERENCES ";
|
2003-01-05 19:55:52 +00:00
|
|
|
}
|
2004-07-14 18:31:07 +00:00
|
|
|
createquery += targettable;
|
2004-10-02 01:12:02 +00:00
|
|
|
createquery += " (id))";
|
2004-07-14 18:31:07 +00:00
|
|
|
#else
|
|
|
|
|
if ((kind == OneToOne) || (kind == OneToMany)) {
|
2004-10-02 01:12:02 +00:00
|
|
|
createquery += " (id), target integer UNIQUE) WITHOUT OIDS";
|
2004-07-14 18:31:07 +00:00
|
|
|
} else {
|
2004-10-02 01:12:02 +00:00
|
|
|
createquery += " (id), target integer) WITHOUT OIDS";
|
2004-07-14 18:31:07 +00:00
|
|
|
}
|
|
|
|
|
#endif
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
|
|
|
|
|
debug(std::cout << "QUERY: " << query << std::endl << std::flush;);
|
2004-03-08 14:36:44 +00:00
|
|
|
clearPendingQuery();
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
int status = PQsendQuery(m_connection, query.c_str());
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
if (!status) {
|
2005-01-13 00:38:41 +00:00
|
|
|
log(ERROR, "registerRelation(): Database query error.");
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
reportError();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!tuplesOk()) {
|
|
|
|
|
debug(reportError(););
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
debug(std::cout << "Table does not yet exist"
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
<< std::endl << std::flush;);
|
|
|
|
|
} else {
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
debug(std::cout << "Table exists" << std::endl << std::flush;);
|
2004-07-14 18:31:07 +00:00
|
|
|
allTables.insert(tablename);
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
|
2004-07-16 16:15:11 +00:00
|
|
|
debug(std::cout << "CREATE QUERY: " << createquery
|
|
|
|
|
<< std::endl << std::flush;);
|
2003-01-05 19:55:52 +00:00
|
|
|
if (!runCommandQuery(createquery)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2004-07-14 18:31:07 +00:00
|
|
|
allTables.insert(tablename);
|
|
|
|
|
#if 0
|
2003-01-05 19:55:52 +00:00
|
|
|
if ((kind == ManyToOne) || (kind == OneToOne)) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
std::string indexQuery = "CREATE INDEX ";
|
2004-07-14 18:31:07 +00:00
|
|
|
indexQuery += tablename;
|
|
|
|
|
indexQuery += "_source_idx ON ";
|
|
|
|
|
indexQuery += tablename;
|
2004-10-02 01:12:02 +00:00
|
|
|
indexQuery += " (source)";
|
2003-01-05 19:55:52 +00:00
|
|
|
return runCommandQuery(indexQuery);
|
|
|
|
|
}
|
2004-07-14 18:31:07 +00:00
|
|
|
#else
|
|
|
|
|
return true;
|
|
|
|
|
#endif
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
2003-01-05 19:55:52 +00:00
|
|
|
const DatabaseResult Database::selectRelation(const std::string & name,
|
|
|
|
|
const std::string & id)
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
{
|
2004-07-14 18:31:07 +00:00
|
|
|
std::string query = "SELECT target FROM ";
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
query += name;
|
2004-07-14 18:31:07 +00:00
|
|
|
query += " WHERE source = ";
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
query += id;
|
|
|
|
|
|
|
|
|
|
debug(std::cout << "Selecting on id = " << id << " ... " << std::flush;);
|
|
|
|
|
|
|
|
|
|
return runSimpleSelectQuery(query);
|
|
|
|
|
}
|
|
|
|
|
|
2003-01-05 19:55:52 +00:00
|
|
|
bool Database::createRelationRow(const std::string & name,
|
|
|
|
|
const std::string & id,
|
|
|
|
|
const std::string & other)
|
|
|
|
|
{
|
|
|
|
|
std::string query = "INSERT INTO ";
|
|
|
|
|
query += name;
|
2004-07-14 18:31:07 +00:00
|
|
|
query += " (source, target) VALUES (";
|
2003-01-05 19:55:52 +00:00
|
|
|
query += id;
|
|
|
|
|
query += ", ";
|
|
|
|
|
query += other;
|
2004-10-02 01:12:02 +00:00
|
|
|
query += ")";
|
2003-01-05 19:55:52 +00:00
|
|
|
|
2003-10-27 01:59:53 +00:00
|
|
|
return scheduleCommand(query);
|
2003-01-05 19:55:52 +00:00
|
|
|
}
|
|
|
|
|
|
2003-01-12 15:06:09 +00:00
|
|
|
bool Database::removeRelationRow(const std::string & name,
|
|
|
|
|
const std::string & id)
|
|
|
|
|
{
|
|
|
|
|
std::string query = "DELETE FROM ";
|
|
|
|
|
query += name;
|
2004-09-14 16:39:30 +00:00
|
|
|
query += " WHERE source = ";
|
2003-01-12 15:06:09 +00:00
|
|
|
query += id;
|
|
|
|
|
|
2003-10-27 01:59:53 +00:00
|
|
|
return scheduleCommand(query);
|
2003-01-12 15:06:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Database::removeRelationRowByOther(const std::string & name,
|
|
|
|
|
const std::string & other)
|
|
|
|
|
{
|
|
|
|
|
std::string query = "DELETE FROM ";
|
|
|
|
|
query += name;
|
2004-09-14 16:39:30 +00:00
|
|
|
query += " WHERE target = ";
|
2003-01-12 15:06:09 +00:00
|
|
|
query += other;
|
|
|
|
|
|
2003-10-27 01:59:53 +00:00
|
|
|
// return runCommandQuery(query);
|
|
|
|
|
return scheduleCommand(query);
|
2003-01-12 15:06:09 +00:00
|
|
|
}
|
|
|
|
|
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
bool Database::registerSimpleTable(const std::string & name,
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/Lobby.cpp, server/Lobby.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
const MapType & row)
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
{
|
|
|
|
|
if (row.empty()) {
|
|
|
|
|
log(ERROR, "Attempt to create empty database table");
|
|
|
|
|
}
|
|
|
|
|
// Check whether the table exists
|
|
|
|
|
std::string query = "SELECT * FROM ";
|
|
|
|
|
std::string createquery = "CREATE TABLE ";
|
|
|
|
|
query += name;
|
|
|
|
|
createquery += name;
|
|
|
|
|
query += " WHERE id = 0";
|
|
|
|
|
createquery += " (id integer UNIQUE PRIMARY KEY";
|
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 = row.end();
|
|
|
|
|
for (MapType::const_iterator I = row.begin(); I != Iend; ++I) {
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
query += " AND ";
|
|
|
|
|
createquery += ", ";
|
|
|
|
|
const std::string & column = I->first;
|
|
|
|
|
query += column;
|
|
|
|
|
createquery += column;
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/Lobby.cpp, server/Lobby.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
const Element & type = I->second;
|
2003-08-07 23:03:26 +00:00
|
|
|
if (type.isString()) {
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
query += " LIKE 'foo'";
|
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
|
|
|
int size = type.String().size();
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
if (size == 0) {
|
|
|
|
|
createquery += " text";
|
|
|
|
|
} else {
|
|
|
|
|
char buf[32];
|
|
|
|
|
snprintf(buf, 32, "%d", size);
|
|
|
|
|
createquery += " varchar(";
|
|
|
|
|
createquery += buf;
|
|
|
|
|
createquery += ")";
|
|
|
|
|
}
|
2003-08-07 23:03:26 +00:00
|
|
|
} else if (type.isInt()) {
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
query += " = 1";
|
|
|
|
|
createquery += " integer";
|
2003-08-07 23:03:26 +00:00
|
|
|
} else if (type.isFloat()) {
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
query += " = 1.0";
|
|
|
|
|
createquery += " float";
|
|
|
|
|
} else {
|
2004-09-07 10:09:02 +00:00
|
|
|
log(ERROR, "Illegal column type in database simple row");
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
debug(std::cout << "QUERY: " << query << std::endl << std::flush;);
|
2004-03-08 14:36:44 +00:00
|
|
|
clearPendingQuery();
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
int status = PQsendQuery(m_connection, query.c_str());
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
if (!status) {
|
2005-01-13 00:38:41 +00:00
|
|
|
log(ERROR, "registerSimpleTable(): Database query error.");
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
reportError();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
if (!tuplesOk()) {
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
debug(reportError(););
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
debug(std::cout << "Table does not yet exist"
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
<< std::endl << std::flush;);
|
|
|
|
|
} else {
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
debug(std::cout << "Table exists" << std::endl << std::flush;);
|
2003-10-28 00:18:18 +00:00
|
|
|
allTables.insert(name);
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-02 01:12:02 +00:00
|
|
|
createquery += ") WITHOUT OIDS";
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
debug(std::cout << "CREATE QUERY: " << createquery
|
|
|
|
|
<< std::endl << std::flush;);
|
2003-10-28 00:18:18 +00:00
|
|
|
bool ret = runCommandQuery(createquery);
|
|
|
|
|
if (ret) {
|
|
|
|
|
allTables.insert(name);
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DatabaseResult Database::selectSimpleRow(const std::string & id,
|
|
|
|
|
const std::string & name)
|
|
|
|
|
{
|
|
|
|
|
std::string query = "SELECT * FROM ";
|
|
|
|
|
query += name;
|
|
|
|
|
query += " WHERE id = ";
|
|
|
|
|
query += id;
|
|
|
|
|
|
|
|
|
|
debug(std::cout << "Selecting on id = " << id << " ... " << std::flush;);
|
|
|
|
|
|
|
|
|
|
return runSimpleSelectQuery(query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DatabaseResult Database::selectSimpleRowBy(const std::string & name,
|
|
|
|
|
const std::string & column,
|
|
|
|
|
const std::string & value)
|
|
|
|
|
{
|
|
|
|
|
std::string query = "SELECT * FROM ";
|
|
|
|
|
query += name;
|
|
|
|
|
query += " WHERE ";
|
|
|
|
|
query += column;
|
|
|
|
|
query += " = ";
|
|
|
|
|
query += value;
|
|
|
|
|
|
|
|
|
|
debug(std::cout << "Selecting on " << column << " = " << value
|
|
|
|
|
<< " ... " << std::flush;);
|
|
|
|
|
|
|
|
|
|
return runSimpleSelectQuery(query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Database::createSimpleRow(const std::string & name,
|
|
|
|
|
const std::string & id,
|
|
|
|
|
const std::string & columns,
|
|
|
|
|
const std::string & values)
|
|
|
|
|
{
|
|
|
|
|
std::string query = "INSERT INTO ";
|
|
|
|
|
query += name;
|
|
|
|
|
query += " ( id, ";
|
|
|
|
|
query += columns;
|
|
|
|
|
query += " ) VALUES ( ";
|
|
|
|
|
query += id;
|
|
|
|
|
query += ", ";
|
|
|
|
|
query += values;
|
2004-10-02 01:12:02 +00:00
|
|
|
query += ")";
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
|
2003-10-27 01:59:53 +00:00
|
|
|
// return runCommandQuery(query);
|
|
|
|
|
return scheduleCommand(query);
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
}
|
|
|
|
|
|
2003-08-24 23:56:15 +00:00
|
|
|
bool Database::updateSimpleRow(const std::string & name,
|
2003-08-25 15:20:01 +00:00
|
|
|
const std::string & key,
|
|
|
|
|
const std::string & value,
|
2003-08-24 23:56:15 +00:00
|
|
|
const std::string & columns)
|
|
|
|
|
{
|
2003-10-27 01:59:53 +00:00
|
|
|
std::string query = "UPDATE ";
|
|
|
|
|
query += name;
|
|
|
|
|
query += " SET ";
|
|
|
|
|
query += columns;
|
|
|
|
|
query += " WHERE ";
|
|
|
|
|
query += key;
|
|
|
|
|
query += "='";
|
|
|
|
|
query += value;
|
2004-10-02 01:12:02 +00:00
|
|
|
query += "'";
|
2003-10-27 01:59:53 +00:00
|
|
|
|
|
|
|
|
// return runCommandQuery(query);
|
|
|
|
|
return scheduleCommand(query);
|
2003-08-24 23:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
bool Database::registerEntityIdGenerator()
|
|
|
|
|
{
|
2004-03-08 14:36:44 +00:00
|
|
|
clearPendingQuery();
|
2004-10-02 01:12:02 +00:00
|
|
|
int status = PQsendQuery(m_connection, "SELECT * FROM entity_ent_id_seq");
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
if (!status) {
|
2005-01-13 00:38:41 +00:00
|
|
|
log(ERROR, "registerEntityIdGenerator(): Database query error.");
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
reportError();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!tuplesOk()) {
|
|
|
|
|
debug(reportError(););
|
|
|
|
|
debug(std::cout << "Sequence does not yet exist"
|
|
|
|
|
<< std::endl << std::flush;);
|
|
|
|
|
} else {
|
|
|
|
|
debug(std::cout << "Sequence exists" << std::endl << std::flush;);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2004-10-02 01:12:02 +00:00
|
|
|
return runCommandQuery("CREATE SEQUENCE entity_ent_id_seq");
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
2005-11-12 01:40:37 +00:00
|
|
|
long Database::newId(std::string & id)
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
{
|
2003-10-27 01:59:53 +00:00
|
|
|
clearPendingQuery();
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
int status = PQsendQuery(m_connection,
|
2004-10-02 01:12:02 +00:00
|
|
|
"SELECT nextval('entity_ent_id_seq')");
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
if (!status) {
|
2005-01-13 00:38:41 +00:00
|
|
|
log(ERROR, "newId(): Database query error.");
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
reportError();
|
2005-11-12 01:40:37 +00:00
|
|
|
return -1;
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
}
|
|
|
|
|
PGresult * res;
|
|
|
|
|
if ((res = PQgetResult(m_connection)) == NULL) {
|
|
|
|
|
log(ERROR, "Error getting new ID.");
|
|
|
|
|
reportError();
|
2005-11-12 01:40:37 +00:00
|
|
|
return -1;
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
}
|
2003-07-21 09:37:58 +00:00
|
|
|
const char * cid = PQgetvalue(res, 0, 0);
|
|
|
|
|
id = cid;
|
|
|
|
|
PQclear(res);
|
|
|
|
|
while ((res = PQgetResult(m_connection)) != NULL) {
|
|
|
|
|
PQclear(res);
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
log(ERROR, "Extra database result to simple query.");
|
|
|
|
|
};
|
2006-05-06 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp, common/newid.cpp, server/server.cpp:
Modify new ID checks so that code still runs when database is
unavailable, and events requiring new IDs fail cleanly.
* server/Connection.cpp: Report a failure to create a player
account if no ID available.
* rulesets/BaseMind.cpp: When processing appearance ops, handle
stamp more efficiently, report an error if ID is missing
from argument.
* server/IdlePSQLConnector.cpp, server/IdlePSQLConnector.h:
Implement re-connecting to the Database if connection is lost.
* rulesets/Character.cpp, rulesets/Entity.cpp, rulesets/Thing.cpp:
Ensure STAMP is present on appearance op args.
* server/CommListener.cpp, server/CommListener.h,
server/CommPeerListener.cpp, server/CommPeerListener.h,
server/CommSlaveListener.cpp, server/CommSlaveListener.h,
server/CommUnixListener.cpp, server/CommUnixListener.h:
Add a return value to method for creating new client socket
objects, and use it to return failure if no ID is available
from the database for a new object.
* rulesets/Py_Point3D.cpp, rulesets/Py_Vector3D.cpp,
rulesets/Python_API.cpp: Add "new" method for class wrappers, and
call the in place constructor from new rather than init. Re-write
internal function for creating new instances so it uses the "new"
method.
* rulesets/Py_Statistics.cpp: Remove some obsolete code inadvertedly
copied from another file. Comment out some unused code to get rid
of a warning.
* server/CommPSQLSocket.cpp: Clear the database connection from
destructor.
* tests/python_class.cpp: A new test for experimenting with new
Python wrappers.
2006-05-06 21:36:57 +00:00
|
|
|
if (id.empty()) {
|
|
|
|
|
log(ERROR, "Unknown error getting ID from database.");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2005-11-23 11:55:08 +00:00
|
|
|
return forceIntegerId(id);
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-25 15:41:04 +00:00
|
|
|
bool Database::registerEntityTable(const std::string & classname,
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/Lobby.cpp, server/Lobby.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
const MapType & row,
|
2002-12-10 23:38:15 +00:00
|
|
|
const std::string & parent)
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
// TODO
|
|
|
|
|
// row probably needs to be richer to provide a more detailed, and possibly
|
|
|
|
|
// ordered description of each the columns required.
|
2002-11-25 15:41:04 +00:00
|
|
|
{
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
if (entityTables.find(classname) != entityTables.end()) {
|
|
|
|
|
log(ERROR, "Attempt to register entity table already registered.");
|
|
|
|
|
debug(std::cerr << "Table for class " << classname
|
2002-12-10 23:38:15 +00:00
|
|
|
<< " already registered." << std::endl << std::flush;);
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!parent.empty()) {
|
|
|
|
|
if (entityTables.empty()) {
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
log(ERROR, "Registering non-root entity table when no root registered.");
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
debug(std::cerr << "Table for class " << classname
|
2002-12-10 23:38:15 +00:00
|
|
|
<< " cannot be non-root."
|
|
|
|
|
<< std::endl << std::flush;);
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (entityTables.find(parent) == entityTables.end()) {
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
log(ERROR, "Registering entity table with non existant parent.");
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
debug(std::cerr << "Table for class " << classname
|
2002-12-10 23:38:15 +00:00
|
|
|
<< " cannot have non-existant parent " << parent
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
<< std::endl << std::flush;);
|
|
|
|
|
return false;
|
2002-12-10 23:38:15 +00:00
|
|
|
}
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
} else if (!entityTables.empty()) {
|
|
|
|
|
log(ERROR, "Attempt to create root entity class table when one already registered.");
|
|
|
|
|
debug(std::cerr << "Table for class " << classname
|
2002-12-10 23:38:15 +00:00
|
|
|
<< " cannot be root." << std::endl << std::flush;);
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// At this point we know the table request make sense.
|
|
|
|
|
entityTables[classname] = parent;
|
|
|
|
|
const std::string tablename = classname + "_ent";
|
2002-11-25 15:41:04 +00:00
|
|
|
// Check whether the table exists
|
|
|
|
|
std::string query = "SELECT * FROM ";
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
std::string createquery = "CREATE TABLE ";
|
2002-11-25 15:41:04 +00:00
|
|
|
query += tablename;
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
createquery += tablename;
|
2002-12-10 23:38:15 +00:00
|
|
|
if (!row.empty()) {
|
|
|
|
|
query += " WHERE ";
|
|
|
|
|
}
|
2003-01-05 21:44:56 +00:00
|
|
|
createquery += " (";
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
if (parent.empty()) {
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
createquery += "id integer UNIQUE PRIMARY KEY, ";
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
}
|
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 = row.end();
|
|
|
|
|
for (MapType::const_iterator I = row.begin(); I != Iend; ++I) {
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
if (I != row.begin()) {
|
|
|
|
|
query += " AND ";
|
2002-12-10 23:38:15 +00:00
|
|
|
createquery += ", ";
|
|
|
|
|
}
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
const std::string & column = I->first;
|
|
|
|
|
query += column;
|
|
|
|
|
createquery += column;
|
2004-08-07 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, common/BaseWorld.h,
common/Database.cpp, common/Database.h, common/FormattedXMLWriter.cpp,
common/FormattedXMLWriter.h, common/accountbase.cpp,
common/accountbase.h, common/custom.cpp, common/inheritance.cpp,
common/inheritance.h, common/operations.h, common/type_utils.h,
common/utility.cpp, common/utility.h, modules/Location.cpp,
modules/Location.h, rulesets/Area.cpp, rulesets/Area.h,
rulesets/BaseMind.cpp, rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Entity.cpp, rulesets/Entity.h,
rulesets/Entity_getLocation.h, rulesets/Food.cpp, rulesets/Line.cpp,
rulesets/Line.h, rulesets/MemMap.cpp, rulesets/MemMap.h,
rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Object.h,
rulesets/Py_Operation.cpp, rulesets/Py_Thing.cpp,
rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h,
rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/CommClient.h,
server/CommListener.cpp, server/CommListener.h,
server/CommLocalClient.cpp, server/CommLocalClient.h,
server/CommMetaClient.h, server/CommPSQLSocket.h,
server/CommRemoteClient.cpp, server/CommRemoteClient.h,
server/CommServer.cpp, server/CommServer.h, server/CommSocket.cpp,
server/CommSocket.h, server/CommUnixListener.cpp,
server/CommUnixListener.h, server/Connection.cpp,
server/Connection.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/Lobby.cpp, server/Lobby.h,
server/Persistance.cpp, server/Persistance.h,
server/PersistantThingFactory.h, server/Persistor.cpp,
server/Player.cpp, server/Player.h, server/Restorer.h,
server/Restorer_impl.h, server/ServerRouting.cpp,
server/ServerRouting.h, server/TrustedConnection.cpp,
server/TrustedConnection.h, server/WorldRouter.cpp,
server/WorldRouter.h: Convert code to using Atlas Message
typedefs as found in Atlas-C++ 0.6 to aid conversion later.
2004-08-16 14:26:47 +00:00
|
|
|
const Element & type = I->second;
|
2003-08-07 23:03:26 +00:00
|
|
|
if (type.isString()) {
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
query += " LIKE 'foo'";
|
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
|
|
|
int size = type.String().size();
|
2002-12-10 23:38:15 +00:00
|
|
|
if (size == 0) {
|
|
|
|
|
createquery += " text";
|
|
|
|
|
} else {
|
|
|
|
|
char buf[32];
|
|
|
|
|
snprintf(buf, 32, "%d", size);
|
|
|
|
|
createquery += " varchar(";
|
|
|
|
|
createquery += buf;
|
|
|
|
|
createquery += ")";
|
|
|
|
|
}
|
2003-08-07 23:03:26 +00:00
|
|
|
} else if (type.isInt()) {
|
|
|
|
|
if (type.asInt() == 0xb001) {
|
2003-07-19 18:29:57 +00:00
|
|
|
query += " = 't'";
|
|
|
|
|
createquery += " boolean";
|
|
|
|
|
} else {
|
|
|
|
|
query += " = 1";
|
|
|
|
|
createquery += " integer";
|
|
|
|
|
}
|
2003-08-07 23:03:26 +00:00
|
|
|
} else if (type.isFloat()) {
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
query += " = 1.0";
|
2002-12-10 23:38:15 +00:00
|
|
|
createquery += " float";
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
} else {
|
2002-12-10 23:38:15 +00:00
|
|
|
log(ERROR, "Illegal column type in database entity row");
|
|
|
|
|
}
|
2002-11-25 15:41:04 +00:00
|
|
|
}
|
|
|
|
|
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
debug(std::cout << "QUERY: " << query << std::endl << std::flush;);
|
2004-03-08 14:36:44 +00:00
|
|
|
clearPendingQuery();
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
int status = PQsendQuery(m_connection, query.c_str());
|
2002-11-25 15:41:04 +00:00
|
|
|
if (!status) {
|
2005-01-13 00:38:41 +00:00
|
|
|
log(ERROR, "registerEntityTable(): Database query error.");
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
reportError();
|
2002-11-25 15:41:04 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!tuplesOk()) {
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
debug(reportError(););
|
|
|
|
|
debug(std::cout << "Table does not yet exist"
|
2002-12-10 23:38:15 +00:00
|
|
|
<< std::endl << std::flush;);
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
} else {
|
2003-10-28 00:18:18 +00:00
|
|
|
if (parent.empty()) {
|
|
|
|
|
allTables.insert(tablename);
|
|
|
|
|
}
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
debug(std::cout << "Table exists" << std::endl << std::flush;);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
// create table
|
|
|
|
|
createquery += ")";
|
2004-07-16 16:15:11 +00:00
|
|
|
if (parent.empty()) {
|
2004-10-02 01:12:02 +00:00
|
|
|
createquery += " WITHOUT OIDS";
|
2004-07-16 16:15:11 +00:00
|
|
|
} else {
|
2002-12-10 23:38:15 +00:00
|
|
|
createquery += " INHERITS (";
|
|
|
|
|
createquery += parent;
|
2004-10-02 01:12:02 +00:00
|
|
|
createquery += "_ent)";
|
2002-11-25 Al Riddoch <alriddoch@zepler.org>
* common/Database.h, common/Database.cpp, server/Persistance.cpp:
Finish entity table creation code, and test it.
* rulesets/Entity.cpp, rulesets/Entity.h, rulesets/EntityFactory.h,
rulesets/PythonThingScript.cpp, rulesets/PythonThingScript.h,
rulesets/Python_API.cpp, rulesets/Python_API.h,
rulesets/Thing.cpp, rulesets/Thing.h, server/EntityFactory.cpp,
server/EntityFactory.h, server/WorldRouter.cpp: Sort out
some incorrect use of Thing instead of Entity. Move some code
from Thing into Entity.
2002-11-25 22:48:13 +00:00
|
|
|
}
|
|
|
|
|
debug(std::cout << "CREATE QUERY: " << createquery
|
2002-12-10 23:38:15 +00:00
|
|
|
<< std::endl << std::flush;);
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
|
2003-10-28 00:18:18 +00:00
|
|
|
bool ret = runCommandQuery(createquery);
|
|
|
|
|
if (ret && parent.empty()) {
|
|
|
|
|
allTables.insert(tablename);
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
2002-11-25 15:41:04 +00:00
|
|
|
}
|
2002-12-15 02:52:54 +00:00
|
|
|
|
|
|
|
|
bool Database::createEntityRow(const std::string & classname,
|
|
|
|
|
const std::string & id,
|
2002-12-18 18:27:06 +00:00
|
|
|
const std::string & columns,
|
|
|
|
|
const std::string & values)
|
2002-12-15 02:52:54 +00:00
|
|
|
{
|
|
|
|
|
TableDict::const_iterator I = entityTables.find(classname);
|
|
|
|
|
if (I == entityTables.end()) {
|
2002-12-21 01:15:19 +00:00
|
|
|
log(ERROR, "Attempt to insert into entity table not registered.");
|
2002-12-15 02:52:54 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
std::string query = "INSERT INTO ";
|
2002-12-21 01:15:19 +00:00
|
|
|
query += classname;
|
|
|
|
|
query += "_ent ( id, ";
|
2002-12-15 02:52:54 +00:00
|
|
|
query += columns;
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
query += " ) VALUES ( ";
|
2002-12-18 18:27:06 +00:00
|
|
|
query += id;
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
query += ", ";
|
2002-12-18 18:27:06 +00:00
|
|
|
query += values;
|
2004-10-02 01:12:02 +00:00
|
|
|
query += ")";
|
2002-12-19 16:23:28 +00:00
|
|
|
debug(std::cout << "QUERY: " << query << std::endl << std::flush;);
|
2002-12-21 01:15:19 +00:00
|
|
|
|
2003-10-27 01:59:53 +00:00
|
|
|
// return runCommandQuery(query);
|
|
|
|
|
return scheduleCommand(query);
|
2002-12-15 02:52:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Database::updateEntityRow(const std::string & classname,
|
|
|
|
|
const std::string & id,
|
|
|
|
|
const std::string & columns)
|
|
|
|
|
{
|
2002-12-30 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp: Don't make update requests if no columns
are given to be updated.
* common/Database.cpp, common/Database.h: Add new method to select
all rows in a given class table with a given location.
* rulesets/Entity.cpp, rulesets/Entity.h: Make update_flags
public.
* rulesets/Entity.cpp, rulesets/Thing.cpp, rulesets/attributes.h,
server/Persistor.cpp, server/Persistor_impl.h,
server/WorldRouter.cpp: Add new cont column to entity tables which
is zero if the entity has no contained entities.
* server/Restoration.cpp, server/Restoration.h, server/Restorer.cpp,
server/Restorer.h, server/Restorer_impl.h:
Modify restorers so they now use a database result iterator to
indicate the row they should restore from.
* server/Restoration.cpp: Implement new way of restoring world from
database using new function to fetch multiple complete entities
from database at the same time. Massive speedup.
2002-12-31 12:41:19 +00:00
|
|
|
if (columns.empty()) {
|
|
|
|
|
log(WARNING, "Update query passed to database with no columns.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2002-12-15 02:52:54 +00:00
|
|
|
TableDict::const_iterator I = entityTables.find(classname);
|
|
|
|
|
if (I == entityTables.end()) {
|
2002-12-21 01:15:19 +00:00
|
|
|
log(ERROR, "Attempt to update entity table not registered.");
|
2002-12-15 02:52:54 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
std::string query = "UPDATE ";
|
2002-12-21 01:15:19 +00:00
|
|
|
query += classname;
|
|
|
|
|
query += "_ent SET ";
|
2002-12-15 02:52:54 +00:00
|
|
|
query += columns;
|
|
|
|
|
query += " WHERE id='";
|
|
|
|
|
query += id;
|
2004-10-02 01:12:02 +00:00
|
|
|
query += "'";
|
2002-12-19 16:23:28 +00:00
|
|
|
debug(std::cout << "QUERY: " << query << std::endl << std::flush;);
|
2002-12-21 01:15:19 +00:00
|
|
|
|
2003-10-27 01:59:53 +00:00
|
|
|
return scheduleCommand(query);
|
2002-12-15 02:52:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Database::removeEntityRow(const std::string & classname,
|
|
|
|
|
const std::string & id)
|
|
|
|
|
{
|
|
|
|
|
TableDict::const_iterator I = entityTables.find(classname);
|
|
|
|
|
if (I == entityTables.end()) {
|
2002-12-21 01:15:19 +00:00
|
|
|
log(ERROR, "Attempt to remove from entity table not registered.");
|
2002-12-15 02:52:54 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
std::string query = "DELETE FROM ";
|
2002-12-21 01:15:19 +00:00
|
|
|
query += classname;
|
|
|
|
|
query += "_ent WHERE id='";
|
2002-12-15 02:52:54 +00:00
|
|
|
query += id;
|
2004-10-02 01:12:02 +00:00
|
|
|
query += "'";
|
2002-12-19 16:23:28 +00:00
|
|
|
debug(std::cout << "QUERY: " << query << std::endl << std::flush;);
|
2002-12-21 01:15:19 +00:00
|
|
|
|
2003-10-27 01:59:53 +00:00
|
|
|
// return runCommandQuery(query);
|
|
|
|
|
return scheduleCommand(query);
|
2002-12-15 02:52:54 +00:00
|
|
|
}
|
2002-12-21 01:15:19 +00:00
|
|
|
|
|
|
|
|
const DatabaseResult Database::selectEntityRow(const std::string & id,
|
|
|
|
|
const std::string & classname)
|
|
|
|
|
{
|
|
|
|
|
std::string table = (classname == "" ? "entity" : classname);
|
|
|
|
|
TableDict::const_iterator I = entityTables.find(classname);
|
|
|
|
|
if (I == entityTables.end()) {
|
|
|
|
|
log(ERROR, "Attempt to select from entity table not registered.");
|
|
|
|
|
return DatabaseResult(0);
|
|
|
|
|
}
|
|
|
|
|
std::string query = "SELECT * FROM ";
|
|
|
|
|
query += table;
|
|
|
|
|
query += "_ent WHERE id='";
|
|
|
|
|
query += id;
|
2004-10-02 01:12:02 +00:00
|
|
|
query += "'";
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
|
2002-12-30 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp: Don't make update requests if no columns
are given to be updated.
* common/Database.cpp, common/Database.h: Add new method to select
all rows in a given class table with a given location.
* rulesets/Entity.cpp, rulesets/Entity.h: Make update_flags
public.
* rulesets/Entity.cpp, rulesets/Thing.cpp, rulesets/attributes.h,
server/Persistor.cpp, server/Persistor_impl.h,
server/WorldRouter.cpp: Add new cont column to entity tables which
is zero if the entity has no contained entities.
* server/Restoration.cpp, server/Restoration.h, server/Restorer.cpp,
server/Restorer.h, server/Restorer_impl.h:
Modify restorers so they now use a database result iterator to
indicate the row they should restore from.
* server/Restoration.cpp: Implement new way of restoring world from
database using new function to fetch multiple complete entities
from database at the same time. Massive speedup.
2002-12-31 12:41:19 +00:00
|
|
|
debug(std::cout << "Selecting on id = " << id << " ... " << std::flush;);
|
2002-12-21 01:15:19 +00:00
|
|
|
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
return runSimpleSelectQuery(query);
|
2002-12-21 01:15:19 +00:00
|
|
|
}
|
2002-12-21 17:11:05 +00:00
|
|
|
|
2002-12-30 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp: Don't make update requests if no columns
are given to be updated.
* common/Database.cpp, common/Database.h: Add new method to select
all rows in a given class table with a given location.
* rulesets/Entity.cpp, rulesets/Entity.h: Make update_flags
public.
* rulesets/Entity.cpp, rulesets/Thing.cpp, rulesets/attributes.h,
server/Persistor.cpp, server/Persistor_impl.h,
server/WorldRouter.cpp: Add new cont column to entity tables which
is zero if the entity has no contained entities.
* server/Restoration.cpp, server/Restoration.h, server/Restorer.cpp,
server/Restorer.h, server/Restorer_impl.h:
Modify restorers so they now use a database result iterator to
indicate the row they should restore from.
* server/Restoration.cpp: Implement new way of restoring world from
database using new function to fetch multiple complete entities
from database at the same time. Massive speedup.
2002-12-31 12:41:19 +00:00
|
|
|
const DatabaseResult Database::selectOnlyByLoc(const std::string & loc,
|
|
|
|
|
const std::string & classname)
|
|
|
|
|
{
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
TableDict::const_iterator I = entityTables.find(classname);
|
|
|
|
|
if (I == entityTables.end()) {
|
|
|
|
|
log(ERROR, "Attempt to select from entity table not registered.");
|
|
|
|
|
return DatabaseResult(0);
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-30 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp: Don't make update requests if no columns
are given to be updated.
* common/Database.cpp, common/Database.h: Add new method to select
all rows in a given class table with a given location.
* rulesets/Entity.cpp, rulesets/Entity.h: Make update_flags
public.
* rulesets/Entity.cpp, rulesets/Thing.cpp, rulesets/attributes.h,
server/Persistor.cpp, server/Persistor_impl.h,
server/WorldRouter.cpp: Add new cont column to entity tables which
is zero if the entity has no contained entities.
* server/Restoration.cpp, server/Restoration.h, server/Restorer.cpp,
server/Restorer.h, server/Restorer_impl.h:
Modify restorers so they now use a database result iterator to
indicate the row they should restore from.
* server/Restoration.cpp: Implement new way of restoring world from
database using new function to fetch multiple complete entities
from database at the same time. Massive speedup.
2002-12-31 12:41:19 +00:00
|
|
|
std::string query = "SELECT * FROM ONLY ";
|
|
|
|
|
query += classname;
|
2003-01-12 15:06:09 +00:00
|
|
|
query += "_ent WHERE loc";
|
|
|
|
|
if (loc.empty()) {
|
2004-10-02 01:12:02 +00:00
|
|
|
query += " is null";
|
2003-01-12 15:06:09 +00:00
|
|
|
} else {
|
|
|
|
|
query += "=";
|
|
|
|
|
query += loc;
|
|
|
|
|
}
|
|
|
|
|
|
2002-12-30 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp: Don't make update requests if no columns
are given to be updated.
* common/Database.cpp, common/Database.h: Add new method to select
all rows in a given class table with a given location.
* rulesets/Entity.cpp, rulesets/Entity.h: Make update_flags
public.
* rulesets/Entity.cpp, rulesets/Thing.cpp, rulesets/attributes.h,
server/Persistor.cpp, server/Persistor_impl.h,
server/WorldRouter.cpp: Add new cont column to entity tables which
is zero if the entity has no contained entities.
* server/Restoration.cpp, server/Restoration.h, server/Restorer.cpp,
server/Restorer.h, server/Restorer_impl.h:
Modify restorers so they now use a database result iterator to
indicate the row they should restore from.
* server/Restoration.cpp: Implement new way of restoring world from
database using new function to fetch multiple complete entities
from database at the same time. Massive speedup.
2002-12-31 12:41:19 +00:00
|
|
|
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
return runSimpleSelectQuery(query);
|
2002-12-30 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp: Don't make update requests if no columns
are given to be updated.
* common/Database.cpp, common/Database.h: Add new method to select
all rows in a given class table with a given location.
* rulesets/Entity.cpp, rulesets/Entity.h: Make update_flags
public.
* rulesets/Entity.cpp, rulesets/Thing.cpp, rulesets/attributes.h,
server/Persistor.cpp, server/Persistor_impl.h,
server/WorldRouter.cpp: Add new cont column to entity tables which
is zero if the entity has no contained entities.
* server/Restoration.cpp, server/Restoration.h, server/Restorer.cpp,
server/Restorer.h, server/Restorer_impl.h:
Modify restorers so they now use a database result iterator to
indicate the row they should restore from.
* server/Restoration.cpp: Implement new way of restoring world from
database using new function to fetch multiple complete entities
from database at the same time. Massive speedup.
2002-12-31 12:41:19 +00:00
|
|
|
}
|
|
|
|
|
|
2002-12-21 17:11:05 +00:00
|
|
|
const DatabaseResult Database::selectClassByLoc(const std::string & loc)
|
|
|
|
|
{
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
std::string query = "SELECT id, class FROM entity_ent WHERE loc";
|
|
|
|
|
if (loc.empty()) {
|
2004-10-02 01:12:02 +00:00
|
|
|
query += " is null";
|
2002-12-28 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.cpp, common/BaseEntity.h, rulesets/Character.cpp,
rulesets/Food.cpp, rulesets/Thing.cpp, rulesets/World.cpp:
Add arg to error method specifying where the error should go. Use
this arg to ensure that errors don't get broadcast.
* common/Database.cpp, common/Database.h, common/const.cpp,
server/Persistor.cpp, server/Restoration.cpp,
server/WorldRouter.cpp
Change id and loc column in entity tables to integer for
performance. Add id generator sequence to database
* common/Database.cpp, common/Database.h, server/Persistance.cpp,
server/Persistance.h: Remove old legacy world, mind and server
tables as they are no longer used.
* common/BaseEntity.cpp, common/Load.h, common/Save.h,
common/custom.cpp, common/op_switch.h, common/operations.cpp,
common/operations.h, common/types.h, rulesets/BaseMind.cpp,
rulesets/BaseMind.h, rulesets/Character.cpp, rulesets/Character.h,
server/Admin.cpp, server/Admin.h, server/server.cpp,
tools/cycmd.cpp: Remove Load and Save ops.
* rulesets/Area.cpp, rulesets/Character.cpp, rulesets/Line.cpp,
rulesets/Plant.cpp: Fix != to |= when setting update flags.
* server/CommMetaClient.cpp, server/CommMetaClient.h,
server/CommServer.cpp, server/CommServer.h, server/server.cpp:
Add mechanism for sockets to be called whenever the server
is idle, so that they do period things. Use this mechanis,
to handle sending periodic packets to the metaserver, removing
special case code from CommServer.
2002-12-28 21:52:32 +00:00
|
|
|
} else {
|
|
|
|
|
query += "=";
|
|
|
|
|
query += loc;
|
|
|
|
|
}
|
2002-12-21 17:11:05 +00:00
|
|
|
|
2002-12-30 Al Riddoch <alriddoch@zepler.org>
* common/Database.cpp: Don't make update requests if no columns
are given to be updated.
* common/Database.cpp, common/Database.h: Add new method to select
all rows in a given class table with a given location.
* rulesets/Entity.cpp, rulesets/Entity.h: Make update_flags
public.
* rulesets/Entity.cpp, rulesets/Thing.cpp, rulesets/attributes.h,
server/Persistor.cpp, server/Persistor_impl.h,
server/WorldRouter.cpp: Add new cont column to entity tables which
is zero if the entity has no contained entities.
* server/Restoration.cpp, server/Restoration.h, server/Restorer.cpp,
server/Restorer.h, server/Restorer_impl.h:
Modify restorers so they now use a database result iterator to
indicate the row they should restore from.
* server/Restoration.cpp: Implement new way of restoring world from
database using new function to fetch multiple complete entities
from database at the same time. Massive speedup.
2002-12-31 12:41:19 +00:00
|
|
|
debug(std::cout << "Selecting on loc = " << loc << " ... " << std::flush;);
|
2002-12-21 17:11:05 +00:00
|
|
|
|
2003-01-03 Al Riddoch <alriddoch@zepler.org>
* common/BaseEntity.h, server/Persistor.h: Make inheritance of
SigC::Object virtual, although multiple inheritance is not planned.
* common/Database.cpp, common/Database.h: Remove legacy account
table, and add support for generic non-inherited tables for OOG
data.
* common/Database.cpp, common/Database.h: Add general methods for
running queries and reporting errors, and cut down duplicated
code elsewhere by using them.
* common/accountbase.cpp, common/accountbase.h: Remove code
that used old account table, and replace with stubs. New
account yet to be written.
* server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/Player.cpp, server/Player.h:
Allow an id to be specified when creating an account.
* server/Persistance.cpp: Re-write account persistance methods
to use new table.
* server/Restoration.cpp: Clarify debug output.
2003-01-03 17:14:28 +00:00
|
|
|
return runSimpleSelectQuery(query);
|
2002-12-21 17:11:05 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-06 22:18:32 +00:00
|
|
|
// Interface for tables for sparse sequences or arrays of data. Terrain
|
|
|
|
|
// control points and other spatial data.
|
|
|
|
|
|
2004-09-07 17:22:35 +00:00
|
|
|
static const char * array_axes[] = { "i", "j", "k", "l", "m" };
|
2004-09-07 10:09:02 +00:00
|
|
|
|
|
|
|
|
bool Database::registerArrayTable(const std::string & name,
|
|
|
|
|
unsigned int dimension,
|
|
|
|
|
const MapType & row)
|
2004-09-06 22:18:32 +00:00
|
|
|
{
|
2004-09-07 17:22:35 +00:00
|
|
|
assert(dimension <= 5);
|
2004-09-07 10:09:02 +00:00
|
|
|
|
|
|
|
|
if (row.empty()) {
|
|
|
|
|
log(ERROR, "Attempt to create empty array table");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string query("SELECT * from ");
|
|
|
|
|
std::string createquery("CREATE TABLE ");
|
2004-09-27 10:33:12 +00:00
|
|
|
std::string indexquery("CREATE UNIQUE INDEX ");
|
2004-09-07 10:09:02 +00:00
|
|
|
|
|
|
|
|
query += name;
|
|
|
|
|
query += " WHERE id = 0";
|
|
|
|
|
|
|
|
|
|
createquery += name;
|
2004-09-14 16:39:30 +00:00
|
|
|
// FIXME This is a foreign key to an inherited table.
|
|
|
|
|
// Implement referential integrity once PostgreSQL works.
|
2004-09-27 10:33:12 +00:00
|
|
|
createquery += " (id integer NOT NULL";
|
|
|
|
|
|
|
|
|
|
indexquery += name;
|
|
|
|
|
indexquery += "_point_idx on ";
|
|
|
|
|
indexquery += name;
|
|
|
|
|
indexquery += " (id";
|
2004-09-07 10:09:02 +00:00
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < dimension; ++i) {
|
|
|
|
|
query += " AND ";
|
|
|
|
|
query += array_axes[i];
|
|
|
|
|
query += " = 0";
|
|
|
|
|
|
|
|
|
|
createquery += ", ";
|
|
|
|
|
createquery += array_axes[i];
|
2004-09-07 17:22:35 +00:00
|
|
|
createquery += " integer NOT NULL";
|
2004-09-27 10:33:12 +00:00
|
|
|
|
|
|
|
|
indexquery += ", ";
|
|
|
|
|
indexquery += array_axes[i];
|
2004-09-07 10:09:02 +00:00
|
|
|
}
|
|
|
|
|
|
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 = row.end();
|
|
|
|
|
for (MapType::const_iterator I = row.begin(); I != Iend; ++I) {
|
2004-09-07 10:09:02 +00:00
|
|
|
const std::string & column = I->first;
|
|
|
|
|
|
|
|
|
|
query += " AND ";
|
|
|
|
|
query += column;
|
|
|
|
|
|
|
|
|
|
createquery += ", ";
|
|
|
|
|
createquery += column;
|
|
|
|
|
|
|
|
|
|
const Element & type = I->second;
|
|
|
|
|
|
|
|
|
|
if (type.isString()) {
|
|
|
|
|
query += " LIKE 'foo'";
|
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
|
|
|
int size = type.String().size();
|
2004-09-07 10:09:02 +00:00
|
|
|
if (size == 0) {
|
|
|
|
|
createquery += " text";
|
|
|
|
|
} else {
|
|
|
|
|
char buf[32];
|
|
|
|
|
snprintf(buf, 32, "%d", size);
|
|
|
|
|
createquery += " varchar(";
|
|
|
|
|
createquery += buf;
|
|
|
|
|
createquery += ")";
|
|
|
|
|
}
|
|
|
|
|
} else if (type.isInt()) {
|
|
|
|
|
query += " = 1";
|
|
|
|
|
createquery += " integer";
|
|
|
|
|
} else if (type.isFloat()) {
|
|
|
|
|
query += " = 1.0";
|
|
|
|
|
createquery += " float";
|
|
|
|
|
} else {
|
|
|
|
|
log(ERROR, "Illegal column type in database array row");
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-10-02 01:12:02 +00:00
|
|
|
|
2004-09-25 00:06:39 +00:00
|
|
|
debug(std::cout << "QUERY: " << query << std::endl << std::flush;);
|
2004-09-07 10:09:02 +00:00
|
|
|
clearPendingQuery();
|
|
|
|
|
int status = PQsendQuery(m_connection, query.c_str());
|
|
|
|
|
if (!status) {
|
2005-01-13 00:38:41 +00:00
|
|
|
log(ERROR, "registerArrayTable(): Database query error.");
|
2004-09-07 10:09:02 +00:00
|
|
|
reportError();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!tuplesOk()) {
|
|
|
|
|
debug(reportError(););
|
|
|
|
|
debug(std::cout << "Table does not yet exist"
|
|
|
|
|
<< std::endl << std::flush;);
|
|
|
|
|
} else {
|
|
|
|
|
debug(std::cout << "Table exists" << std::endl << std::flush;);
|
|
|
|
|
allTables.insert(name);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2004-10-02 01:12:02 +00:00
|
|
|
createquery += ") WITHOUT OIDS";
|
2004-09-07 10:09:02 +00:00
|
|
|
debug(std::cout << "CREATE QUERY: " << createquery
|
|
|
|
|
<< std::endl << std::flush;);
|
|
|
|
|
bool ret = runCommandQuery(createquery);
|
2004-09-27 10:33:12 +00:00
|
|
|
if (!ret) {
|
|
|
|
|
return false;
|
2004-09-07 10:09:02 +00:00
|
|
|
}
|
2004-10-02 01:12:02 +00:00
|
|
|
indexquery += ")";
|
2004-09-28 00:47:18 +00:00
|
|
|
debug(std::cout << "INDEX QUERY: " << indexquery
|
|
|
|
|
<< std::endl << std::flush;);
|
2004-09-27 10:33:12 +00:00
|
|
|
ret = runCommandQuery(indexquery);
|
|
|
|
|
if (!ret) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
allTables.insert(name);
|
|
|
|
|
return true;
|
2004-09-06 22:18:32 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-14 16:39:30 +00:00
|
|
|
const DatabaseResult Database::selectArrayRows(const std::string & name,
|
|
|
|
|
const std::string & id)
|
|
|
|
|
{
|
|
|
|
|
std::string query("SELECT * FROM ");
|
|
|
|
|
query += name;
|
|
|
|
|
query += " WHERE id = ";
|
|
|
|
|
query += id;
|
|
|
|
|
|
2004-09-25 00:06:39 +00:00
|
|
|
debug(std::cout << "ARRAY QUERY: " << query << std::endl << std::flush;);
|
2004-09-14 16:39:30 +00:00
|
|
|
|
|
|
|
|
return runSimpleSelectQuery(query);
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-07 10:09:02 +00:00
|
|
|
bool Database::createArrayRow(const std::string & name,
|
|
|
|
|
const std::string & id,
|
|
|
|
|
const std::vector<int> & key,
|
2004-09-07 17:22:35 +00:00
|
|
|
const MapType & data)
|
2004-09-06 22:18:32 +00:00
|
|
|
{
|
2004-09-07 17:22:35 +00:00
|
|
|
assert(key.size() > 0);
|
|
|
|
|
assert(key.size() <= 5);
|
|
|
|
|
assert(!data.empty());
|
|
|
|
|
|
|
|
|
|
std::stringstream query;
|
|
|
|
|
query << "INSERT INTO " << name << " ( id";
|
|
|
|
|
for (unsigned int i = 0; i < key.size(); ++i) {
|
|
|
|
|
query << ", " << array_axes[i];
|
|
|
|
|
}
|
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 = data.end();
|
|
|
|
|
for (MapType::const_iterator I = data.begin(); I != Iend; ++I) {
|
2004-09-07 17:22:35 +00:00
|
|
|
query << ", " << I->first;
|
|
|
|
|
}
|
|
|
|
|
query << " ) VALUES ( " << id;
|
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
|
|
|
std::vector<int>::const_iterator Jend = key.end();
|
|
|
|
|
for (std::vector<int>::const_iterator J = key.begin(); J != Jend; ++J) {
|
|
|
|
|
query << ", " << *J;
|
2004-09-07 17:22:35 +00:00
|
|
|
}
|
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
|
|
|
// We assume data has not been modified, so Iend is still valid
|
|
|
|
|
for (MapType::const_iterator I = data.begin(); I != Iend; ++I) {
|
2004-09-07 17:22:35 +00:00
|
|
|
const Element & e = I->second;
|
|
|
|
|
switch (e.getType()) {
|
|
|
|
|
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
|
|
|
query << ", " << e.Int();
|
2004-09-07 17:22:35 +00:00
|
|
|
break;
|
|
|
|
|
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
|
|
|
query << ", " << e.Float();
|
2004-09-07 17:22:35 +00:00
|
|
|
break;
|
|
|
|
|
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
|
|
|
query << ", " << e.String();
|
2004-09-07 17:22:35 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
log(ERROR, "Bad type constructing array database row for insert");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-10-02 01:12:02 +00:00
|
|
|
query << ")";
|
2004-09-07 17:22:35 +00:00
|
|
|
|
|
|
|
|
std::string qstr = query.str();
|
2004-09-28 00:47:18 +00:00
|
|
|
debug(std::cout << "QUery: " << qstr << std::endl << std::flush;);
|
2004-09-07 17:22:35 +00:00
|
|
|
return scheduleCommand(qstr);
|
2004-09-06 22:18:32 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-07 10:09:02 +00:00
|
|
|
bool Database::updateArrayRow(const std::string & name,
|
|
|
|
|
const std::string & id,
|
|
|
|
|
const std::vector<int> & key,
|
|
|
|
|
const Atlas::Message::MapType & data)
|
2004-09-06 22:18:32 +00:00
|
|
|
{
|
2004-09-17 17:19:55 +00:00
|
|
|
assert(key.size() > 0);
|
|
|
|
|
assert(key.size() <= 5);
|
|
|
|
|
assert(!data.empty());
|
|
|
|
|
|
|
|
|
|
std::stringstream query;
|
|
|
|
|
|
|
|
|
|
query << "UPDATE " << name << " SET ";
|
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 = data.end();
|
|
|
|
|
for (MapType::const_iterator I = data.begin(); I != Iend; ++I) {
|
2004-09-17 17:19:55 +00:00
|
|
|
if (I != data.begin()) {
|
|
|
|
|
query << ", ";
|
|
|
|
|
}
|
|
|
|
|
query << I->first << " = ";
|
|
|
|
|
const Element & e = I->second;
|
|
|
|
|
switch (e.getType()) {
|
|
|
|
|
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
|
|
|
query << e.Int();
|
2004-09-17 17:19:55 +00:00
|
|
|
break;
|
|
|
|
|
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
|
|
|
query << e.Float();
|
2004-09-17 17:19:55 +00:00
|
|
|
break;
|
|
|
|
|
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
|
|
|
query << "'" << e.String() << "'";
|
2004-09-17 17:19:55 +00:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
log(ERROR, "Bad type constructing array database row for update");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
query << " WHERE id='" << id << "'";
|
|
|
|
|
for (unsigned int i = 0; i < key.size(); ++i) {
|
|
|
|
|
query << " AND " << array_axes[i] << " = " << key[i];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string qstr = query.str();
|
2004-09-28 00:47:18 +00:00
|
|
|
debug(std::cout << "QUery: " << qstr << std::endl << std::flush;);
|
2004-09-17 17:19:55 +00:00
|
|
|
return scheduleCommand(qstr);
|
2004-09-06 22:18:32 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-07 10:09:02 +00:00
|
|
|
bool Database::removeArrayRow(const std::string & name,
|
|
|
|
|
const std::string & id,
|
|
|
|
|
const std::vector<int> & key)
|
2004-09-06 22:18:32 +00:00
|
|
|
{
|
2004-09-14 16:39:30 +00:00
|
|
|
/// Not sure we need this one yet, so lets no bother for now ;)
|
2004-09-06 22:18:32 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// General functions for handling queries at the low level.
|
|
|
|
|
|
2003-10-24 23:50:12 +00:00
|
|
|
void Database::queryResult(ExecStatusType status)
|
|
|
|
|
{
|
|
|
|
|
if (!m_queryInProgress || pendingQueries.empty()) {
|
|
|
|
|
log(ERROR, "Got database result when no query was pending.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
DatabaseQuery & q = pendingQueries.front();
|
|
|
|
|
if (q.second == PGRES_EMPTY_QUERY) {
|
|
|
|
|
log(ERROR, "Got database result which is already done.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (q.second == status) {
|
2003-10-27 12:04:53 +00:00
|
|
|
debug(std::cout << "Query status ok" << std::endl << std::flush;);
|
2003-10-24 23:50:12 +00:00
|
|
|
// Mark this query as done
|
|
|
|
|
q.second = PGRES_EMPTY_QUERY;
|
2003-10-27 01:59:53 +00:00
|
|
|
} else {
|
|
|
|
|
log(ERROR, "Database error from async query");
|
2004-09-28 00:47:18 +00:00
|
|
|
std::cerr << "Query error in : " << q.first << std::endl << std::flush;
|
2003-10-27 01:59:53 +00:00
|
|
|
reportError();
|
|
|
|
|
q.second = PGRES_EMPTY_QUERY;
|
2003-10-24 23:50:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Database::queryComplete()
|
|
|
|
|
{
|
|
|
|
|
if (!m_queryInProgress || pendingQueries.empty()) {
|
|
|
|
|
log(ERROR, "Got database query complete when no query was pending");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
DatabaseQuery & q = pendingQueries.front();
|
|
|
|
|
if (q.second != PGRES_EMPTY_QUERY) {
|
2003-10-27 01:59:53 +00:00
|
|
|
abort();
|
2003-10-24 23:50:12 +00:00
|
|
|
log(ERROR, "Got database query complete when query was not done");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2003-10-27 12:04:53 +00:00
|
|
|
debug(std::cout << "Query complete" << std::endl << std::flush;);
|
2003-10-24 23:50:12 +00:00
|
|
|
pendingQueries.pop_front();
|
|
|
|
|
m_queryInProgress = false;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-27 01:59:53 +00:00
|
|
|
bool Database::launchNewQuery()
|
2003-10-24 23:50:12 +00:00
|
|
|
{
|
|
|
|
|
if (m_queryInProgress) {
|
|
|
|
|
log(ERROR, "Launching new query when query is in progress");
|
2003-10-27 01:59:53 +00:00
|
|
|
return false;
|
2003-10-24 23:50:12 +00:00
|
|
|
}
|
|
|
|
|
if (pendingQueries.empty()) {
|
2003-10-27 12:04:53 +00:00
|
|
|
debug(std::cout << "No queries to launch" << std::endl << std::flush;);
|
2003-10-27 01:59:53 +00:00
|
|
|
return false;
|
2003-10-24 23:50:12 +00:00
|
|
|
}
|
2003-10-27 12:04:53 +00:00
|
|
|
debug(std::cout << pendingQueries.size() << " queries pending"
|
|
|
|
|
<< std::endl << std::flush;);
|
2003-10-24 23:50:12 +00:00
|
|
|
DatabaseQuery & q = pendingQueries.front();
|
2003-10-27 12:04:53 +00:00
|
|
|
debug(std::cout << "Launching async query: " << q.first
|
|
|
|
|
<< std::endl << std::flush;);
|
2003-10-24 23:50:12 +00:00
|
|
|
int status = PQsendQuery(m_connection, q.first.c_str());
|
|
|
|
|
if (!status) {
|
|
|
|
|
log(ERROR, "Database query error when launching.");
|
|
|
|
|
reportError();
|
2003-10-27 01:59:53 +00:00
|
|
|
return false;
|
2003-10-24 23:50:12 +00:00
|
|
|
} else {
|
2003-10-27 01:59:53 +00:00
|
|
|
m_queryInProgress = true;
|
2003-10-24 23:50:12 +00:00
|
|
|
PQflush(m_connection);
|
2003-10-27 01:59:53 +00:00
|
|
|
return true;
|
2003-10-24 23:50:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-27 01:59:53 +00:00
|
|
|
bool Database::scheduleCommand(const std::string & query)
|
2003-10-24 23:50:12 +00:00
|
|
|
{
|
|
|
|
|
pendingQueries.push_back(std::make_pair(query, PGRES_COMMAND_OK));
|
2003-10-27 01:59:53 +00:00
|
|
|
if (!m_queryInProgress) {
|
2003-10-27 12:04:53 +00:00
|
|
|
debug(std::cout << "Query: " << query << " launched"
|
|
|
|
|
<< std::endl << std::flush;);
|
2003-10-27 01:59:53 +00:00
|
|
|
return launchNewQuery();
|
|
|
|
|
} else {
|
2003-10-27 12:04:53 +00:00
|
|
|
debug(std::cout << "Query: " << query << " scheduled"
|
|
|
|
|
<< std::endl << std::flush;);
|
2003-10-27 01:59:53 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Database::clearPendingQuery()
|
|
|
|
|
{
|
|
|
|
|
if (!m_queryInProgress) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
assert(!pendingQueries.empty());
|
2003-10-27 12:04:53 +00:00
|
|
|
debug(std::cout << "Clearing a pending query" << std::endl << std::flush;);
|
2003-10-27 01:59:53 +00:00
|
|
|
|
|
|
|
|
DatabaseQuery & q = pendingQueries.front();
|
|
|
|
|
if (q.second == PGRES_COMMAND_OK) {
|
|
|
|
|
m_queryInProgress = false;
|
|
|
|
|
pendingQueries.pop_front();
|
|
|
|
|
return commandOk();
|
|
|
|
|
} else {
|
|
|
|
|
log(ERROR, "Pending query wants unknown status");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2003-10-24 23:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
2003-10-28 00:18:18 +00:00
|
|
|
bool Database::runMaintainance(int command)
|
2003-10-27 18:01:03 +00:00
|
|
|
{
|
2003-10-28 00:18:18 +00:00
|
|
|
// FIXME VACUUM and REINDEX tables from a common store
|
|
|
|
|
if ((command & MAINTAIN_REINDEX) == MAINTAIN_REINDEX) {
|
|
|
|
|
std::string query("REINDEX TABLE ");
|
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
|
|
|
TableSet::const_iterator Iend = allTables.end();
|
|
|
|
|
for (TableSet::const_iterator I = allTables.begin(); I != Iend; ++I) {
|
2003-10-28 00:18:18 +00:00
|
|
|
debug(std::cout << (query + *I) << std::endl << std::flush;);
|
|
|
|
|
scheduleCommand(query + *I);
|
2003-10-27 18:01:03 +00:00
|
|
|
}
|
2003-10-28 00:18:18 +00:00
|
|
|
}
|
|
|
|
|
if ((command & MAINTAIN_VACUUM) == MAINTAIN_VACUUM) {
|
|
|
|
|
std::string query("VACUUM ");
|
|
|
|
|
if ((command & MAINTAIN_VACUUM_ANALYZE) == MAINTAIN_VACUUM_ANALYZE) {
|
|
|
|
|
query += "ANALYZE ";
|
|
|
|
|
}
|
|
|
|
|
if ((command & MAINTAIN_VACUUM_FULL) == MAINTAIN_VACUUM_FULL) {
|
|
|
|
|
query += "FULL ";
|
|
|
|
|
}
|
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
|
|
|
TableSet::const_iterator Iend = allTables.end();
|
|
|
|
|
for(TableSet::const_iterator I = allTables.begin(); I != Iend; ++I) {
|
2003-10-28 00:18:18 +00:00
|
|
|
debug(std::cout << (query + *I) << std::endl << std::flush;);
|
|
|
|
|
scheduleCommand(query + *I);
|
2003-10-27 18:01:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
2003-10-28 00:18:18 +00:00
|
|
|
return true;
|
2003-10-27 18:01:03 +00:00
|
|
|
}
|
|
|
|
|
|
2002-12-23 00:01:59 +00:00
|
|
|
const char * DatabaseResult::field(const char * column, int row) const
|
2002-12-21 17:11:05 +00:00
|
|
|
{
|
|
|
|
|
int col_num = PQfnumber(m_res, column);
|
|
|
|
|
if (col_num == -1) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return PQgetvalue(m_res, row, col_num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char * DatabaseResult::const_iterator::column(const char * column) const
|
|
|
|
|
{
|
|
|
|
|
int col_num = PQfnumber(m_dr.m_res, column);
|
|
|
|
|
if (col_num == -1) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
return PQgetvalue(m_dr.m_res, m_row, col_num);
|
|
|
|
|
}
|
2004-09-14 16:39:30 +00:00
|
|
|
|
|
|
|
|
void DatabaseResult::const_iterator::readColumn(const char * column,
|
|
|
|
|
int & val) const
|
|
|
|
|
{
|
|
|
|
|
int col_num = PQfnumber(m_dr.m_res, column);
|
|
|
|
|
if (col_num == -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const char * v = PQgetvalue(m_dr.m_res, m_row, col_num);
|
|
|
|
|
val = strtol(v, 0, 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DatabaseResult::const_iterator::readColumn(const char * column,
|
|
|
|
|
float & val) const
|
|
|
|
|
{
|
|
|
|
|
int col_num = PQfnumber(m_dr.m_res, column);
|
|
|
|
|
if (col_num == -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const char * v = PQgetvalue(m_dr.m_res, m_row, col_num);
|
|
|
|
|
val = strtof(v, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DatabaseResult::const_iterator::readColumn(const char * column,
|
|
|
|
|
double & val) const
|
|
|
|
|
{
|
|
|
|
|
int col_num = PQfnumber(m_dr.m_res, column);
|
|
|
|
|
if (col_num == -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const char * v = PQgetvalue(m_dr.m_res, m_row, col_num);
|
|
|
|
|
val = strtod(v, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DatabaseResult::const_iterator::readColumn(const char * column,
|
|
|
|
|
std::string & val) const
|
|
|
|
|
{
|
|
|
|
|
int col_num = PQfnumber(m_dr.m_res, column);
|
|
|
|
|
if (col_num == -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const char * v = PQgetvalue(m_dr.m_res, m_row, col_num);
|
|
|
|
|
val = v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DatabaseResult::const_iterator::readColumn(const char * column,
|
|
|
|
|
MapType & val) const
|
|
|
|
|
{
|
|
|
|
|
int col_num = PQfnumber(m_dr.m_res, column);
|
|
|
|
|
if (col_num == -1) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const char * v = PQgetvalue(m_dr.m_res, m_row, col_num);
|
|
|
|
|
Database::instance()->decodeObject(v, val);
|
|
|
|
|
}
|