2001-08-14 12:49:04 +00:00
|
|
|
// This file may be redistributed and modified only under the terms of
|
2003-09-22 Al Riddoch <alriddoch@zepler.org>
* aiclient/ClientAccount.cpp, aiclient/ClientAccount.h,
aiclient/ClientConnection.cpp, aiclient/ClientConnection.h,
aiclient/client.cpp, aiclient/client.h,
client/CharacterClient.cpp, client/CharacterClient.h,
client/ClientConnection.cpp, client/ClientConnection.h,
client/CreatorClient.h, example/client/CyphesisClient.cpp,
example/client/CyphesisClient.h, example/client/CyphesisClient2.cpp,
example/client/CyphesisClient2.h,
example/client/InheritanceClient.cpp,
example/client/InheritanceClient.h, tools/cycmd.cpp,
tools/cyconfig.cpp: Remove stray references to the LGPL.
2003-09-22 00:40:40 +00:00
|
|
|
// the GNU General Public License (See COPYING for details).
|
2001-08-14 12:49:04 +00:00
|
|
|
// Copyright (C) 2001 Alistair Riddoch
|
|
|
|
|
|
|
|
|
|
#include "CharacterClient.h"
|
2002-07-14 21:04:50 +00:00
|
|
|
|
2001-08-14 12:49:04 +00:00
|
|
|
#include "ClientConnection.h"
|
|
|
|
|
|
2003-03-07 00:22:12 +00:00
|
|
|
#include "common/debug.h"
|
2002-08-30 Al Riddoch <alriddoch@zepler.org>
* common/globals.cpp: Only persist this sessions command line
options if the user is overriding the installation directory.
* cyphesis.vconf, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp:
Add client functionality to allow diferent scripts to be run to
perform different functions on the server.
* client/CharacterClient.cpp: Add debug option.
* rulesets/Character.h: Make mind operation functions virtual,
so they can be overridden.
* common/BaseWorld.h, server/WorldRouter.cpp,
server/WorldRouter.h: Add server functions to search for
entities by name or type.
* rulesets/Creator.h, rulesets/Creator.cpp: Allow creator to
specify a look without an id to search for entities with
a given name or type.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/ObserverClient.cpp, client/ObserverClient.h,
client/Py_CreatorClient.cpp, rulesets/basic/editor.py,
rulesets/mason/define_world.py:
Add support for looking for entities in the world by name or
type from client script, so client scripts can modify existing
world.
* rulesets/Entity.cpp, rulesets/Movement.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/Player.cpp, server/ServerRouting.cpp,
server/server.cpp, tools/cycmd.cpp,
tools/cywatchdog.cpp: Code formatting cleanups.
* rulesets/basic/world/objects/tools/Bow.py: Fix up bow so it now
fires correctly.
2002-08-30 13:48:39 +00:00
|
|
|
|
2004-01-22 18:39:48 +00:00
|
|
|
#include <Atlas/Objects/Operation/RootOperation.h>
|
|
|
|
|
|
2002-08-30 Al Riddoch <alriddoch@zepler.org>
* common/globals.cpp: Only persist this sessions command line
options if the user is overriding the installation directory.
* cyphesis.vconf, client/Py_CreatorClient.cpp,
client/Py_CreatorClient.h, client/client.cpp:
Add client functionality to allow diferent scripts to be run to
perform different functions on the server.
* client/CharacterClient.cpp: Add debug option.
* rulesets/Character.h: Make mind operation functions virtual,
so they can be overridden.
* common/BaseWorld.h, server/WorldRouter.cpp,
server/WorldRouter.h: Add server functions to search for
entities by name or type.
* rulesets/Creator.h, rulesets/Creator.cpp: Allow creator to
specify a look without an id to search for entities with
a given name or type.
* client/CreatorClient.cpp, client/CreatorClient.h,
client/ObserverClient.cpp, client/ObserverClient.h,
client/Py_CreatorClient.cpp, rulesets/basic/editor.py,
rulesets/mason/define_world.py:
Add support for looking for entities in the world by name or
type from client script, so client scripts can modify existing
world.
* rulesets/Entity.cpp, rulesets/Movement.cpp,
rulesets/Py_Object.cpp, rulesets/Py_Operation.cpp,
rulesets/Py_Oplist.cpp, rulesets/Python_API.cpp,
rulesets/Stackable.cpp, rulesets/Thing.cpp,
rulesets/World.cpp, server/Account.cpp,
server/CommServer.cpp, server/Connection.cpp,
server/Player.cpp, server/ServerRouting.cpp,
server/server.cpp, tools/cycmd.cpp,
tools/cywatchdog.cpp: Code formatting cleanups.
* rulesets/basic/world/objects/tools/Bow.py: Fix up bow so it now
fires correctly.
2002-08-30 13:48:39 +00:00
|
|
|
static const bool debug_flag = false;
|
|
|
|
|
|
2001-08-14 12:49:04 +00:00
|
|
|
CharacterClient::CharacterClient(const std::string & id,
|
|
|
|
|
const std::string & name,
|
|
|
|
|
ClientConnection & c) :
|
|
|
|
|
BaseMind(id,name), connection(c)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-03 Al Riddoch <alriddoch@zepler.org>
* client/CharacterClient.cpp, client/CharacterClient.h,
client/CommClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/OOGThing.cpp,
common/OOGThing.h, common/op_switch.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/Food.cpp, rulesets/Food.h,
rulesets/Missile.h, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Stackable.cpp, rulesets/Stackable.h, rulesets/Thing.cpp,
rulesets/Thing.h, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/Connection.cpp,
server/Connection.h, server/ExternalMind.cpp, server/ExternalMind.h,
server/Lobby.cpp, server/Lobby.h, server/Player.cpp,
server/Player.h, server/WorldRouter.cpp:
Re-work basic op dispatch mechanism so result is passed by
a reference argument rather than returning by value.
2004-09-03 00:33:19 +00:00
|
|
|
void CharacterClient::sightImaginaryOperation(const Sight &,
|
|
|
|
|
Imaginary &, OpVector &)
|
2001-08-14 12:49:04 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-03 Al Riddoch <alriddoch@zepler.org>
* client/CharacterClient.cpp, client/CharacterClient.h,
client/CommClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/OOGThing.cpp,
common/OOGThing.h, common/op_switch.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/Food.cpp, rulesets/Food.h,
rulesets/Missile.h, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Stackable.cpp, rulesets/Stackable.h, rulesets/Thing.cpp,
rulesets/Thing.h, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/Connection.cpp,
server/Connection.h, server/ExternalMind.cpp, server/ExternalMind.h,
server/Lobby.cpp, server/Lobby.h, server/Player.cpp,
server/Player.h, server/WorldRouter.cpp:
Re-work basic op dispatch mechanism so result is passed by
a reference argument rather than returning by value.
2004-09-03 00:33:19 +00:00
|
|
|
void CharacterClient::soundTalkOperation(const Sound & , Talk &, OpVector &)
|
2001-08-14 12:49:04 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
2001-08-19 18:37:38 +00:00
|
|
|
//FIXME Dunno what all this trigger lark is about.
|
2001-08-14 12:49:04 +00:00
|
|
|
bad_type CharacterClient::add_trigger(bad_type event_name, bad_type func) {
|
|
|
|
|
dictlist.add_value(CharacterClient::event_triggers,event_name, func);
|
|
|
|
|
}
|
|
|
|
|
bad_type CharacterClient::call_triggers(bad_type op) {
|
|
|
|
|
event_name, sub_op = CharacterClient::get_op_name_and_sub(op);
|
|
|
|
|
reply = Message();
|
|
|
|
|
for (/*func in CharacterClient::event_triggers.get(event_name,[])*/) {
|
|
|
|
|
reply = reply + func(op, sub_op);
|
|
|
|
|
}
|
|
|
|
|
return reply;
|
|
|
|
|
}
|
|
|
|
|
bad_type CharacterClient::set_from_op(bad_type op) {
|
|
|
|
|
op.from_=self;
|
|
|
|
|
}
|
|
|
|
|
bad_type CharacterClient::set_from(bad_type msg) {
|
|
|
|
|
CharacterClient::apply_to_operation(CharacterClient::set_from_op,msg);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void CharacterClient::send(RootOperation & op)
|
|
|
|
|
{
|
2003-08-07 23:03:26 +00:00
|
|
|
op.setFrom(getId());
|
2001-08-14 12:49:04 +00:00
|
|
|
connection.send(op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool CharacterClient::findRefnoOp(const RootOperation & op, long refno)
|
|
|
|
|
{
|
2003-08-07 23:03:26 +00:00
|
|
|
if (refno == op.getRefno()) {
|
2001-08-14 12:49:04 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
inline bool CharacterClient::findRefno(const RootOperation & msg, long refno)
|
|
|
|
|
{
|
|
|
|
|
return findRefnoOp(msg,refno);
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-08 14:58:40 +00:00
|
|
|
OpVector CharacterClient::sendAndWaitReply(RootOperation & op)
|
2001-08-14 12:49:04 +00:00
|
|
|
{
|
|
|
|
|
send(op);
|
2003-08-07 23:03:26 +00:00
|
|
|
long no = op.getSerialno();
|
2001-08-14 12:49:04 +00:00
|
|
|
while (true) {
|
* tools/cycmd.cpp: Ensure that login op is flushed after it is sent.
* server/Player.cpp: Arg order of std::string.compare() is
incompatable between recent libstdc++ versions. Switch
back to old version, still in most common use.
* rulesets/Thing.cpp: Set refno on ops handled in game.
* rulesets/Python_API.cpp: Modify Entity() python constructor
so that commonly used attributes from old atlas are translated
to their modern equivalents.
* rulesets/Py_Thing.cpp, rulesets/Py_Mind.cpp: Differentiate
between previously identical error messages in several places.
* rulesets/Py_Object.cpp: Rework conversion of python dict to
Atlas map to be more efficient and clean.
* rulesets/Py_Location.cpp: Rework setting of vector parts of
location so that it can accept vectors from python in more
formats, including lists and tuples.
* rulesets/Creator.h, rulesets/Character.h, common/BaseEntity.h:
Re-order virtual methods declarations to fit a convention.
* common/stringstream.h: Hardcode use of local stringstream class,
as the version provided with older libstdc++ seems to be broken.
* common/database.cpp: Use the common header to pick the right
stringstream implementation.
* common/BaseWorld.cpp, server/Persistance.cpp: Removed unused
stringstream include.
* rulesets/Creator.cpp: Added extra debug output.
* client/define_world.h, client/define_world.cpp, client/CommClient.h:
Use CreatorClient to store Creators mind, instead of BaseMind.
* client/client.cpp,
client/ObserverClient.h, client/ObserverClient.cpp,
client/CreatorClient.h, client/CommClient.h, client/CommClient.cpp:
Modify method names to fit capitalisation conventions.
* client/CreatorClient.cpp: Implement creation of in-game entities,
using creator entity.
* client/CommClient.cpp: Added correct client side monitoring of
creator entity.
* client/ClientConnection.h, client/ClientConnection.cpp: Added
pending method to establish if ops are in the queue. Switched send()
method so we only send ops. Add setting of serialno of sent
ops, starting with an offset of 512.
* client/CharacterClient.h: Removed unused member, opFound.
* client/CharacterClient.cpp: Debugged sendAndWait() method.
Al Riddoch <alriddoch@zepler.org>
2001-08-16 17:39:42 +00:00
|
|
|
if (connection.pending()) {
|
|
|
|
|
RootOperation * input=CharacterClient::connection.pop();
|
|
|
|
|
if (input != NULL) {
|
|
|
|
|
// What the hell is this!
|
2004-09-03 Al Riddoch <alriddoch@zepler.org>
* client/CharacterClient.cpp, client/CharacterClient.h,
client/CommClient.cpp, common/BaseEntity.cpp,
common/BaseEntity.h, common/OOGThing.cpp,
common/OOGThing.h, common/op_switch.h,
rulesets/BaseMind.cpp, rulesets/BaseMind.h,
rulesets/Character.cpp, rulesets/Character.h,
rulesets/Creator.cpp, rulesets/Creator.h, rulesets/Entity.cpp,
rulesets/Entity.h, rulesets/Food.cpp, rulesets/Food.h,
rulesets/Missile.h, rulesets/Plant.cpp, rulesets/Plant.h,
rulesets/PythonMindScript.cpp, rulesets/PythonThingScript.cpp,
rulesets/Stackable.cpp, rulesets/Stackable.h, rulesets/Thing.cpp,
rulesets/Thing.h, rulesets/World.cpp, rulesets/World.h,
server/Account.cpp, server/Account.h, server/Admin.cpp,
server/Admin.h, server/CommClient.cpp, server/Connection.cpp,
server/Connection.h, server/ExternalMind.cpp, server/ExternalMind.h,
server/Lobby.cpp, server/Lobby.h, server/Player.cpp,
server/Player.h, server/WorldRouter.cpp:
Re-work basic op dispatch mechanism so result is passed by
a reference argument rather than returning by value.
2004-09-03 00:33:19 +00:00
|
|
|
OpVector result;
|
|
|
|
|
operation(*input, result);
|
2002-03-08 14:58:40 +00:00
|
|
|
OpVector::const_iterator I;
|
* tools/cycmd.cpp: Ensure that login op is flushed after it is sent.
* server/Player.cpp: Arg order of std::string.compare() is
incompatable between recent libstdc++ versions. Switch
back to old version, still in most common use.
* rulesets/Thing.cpp: Set refno on ops handled in game.
* rulesets/Python_API.cpp: Modify Entity() python constructor
so that commonly used attributes from old atlas are translated
to their modern equivalents.
* rulesets/Py_Thing.cpp, rulesets/Py_Mind.cpp: Differentiate
between previously identical error messages in several places.
* rulesets/Py_Object.cpp: Rework conversion of python dict to
Atlas map to be more efficient and clean.
* rulesets/Py_Location.cpp: Rework setting of vector parts of
location so that it can accept vectors from python in more
formats, including lists and tuples.
* rulesets/Creator.h, rulesets/Character.h, common/BaseEntity.h:
Re-order virtual methods declarations to fit a convention.
* common/stringstream.h: Hardcode use of local stringstream class,
as the version provided with older libstdc++ seems to be broken.
* common/database.cpp: Use the common header to pick the right
stringstream implementation.
* common/BaseWorld.cpp, server/Persistance.cpp: Removed unused
stringstream include.
* rulesets/Creator.cpp: Added extra debug output.
* client/define_world.h, client/define_world.cpp, client/CommClient.h:
Use CreatorClient to store Creators mind, instead of BaseMind.
* client/client.cpp,
client/ObserverClient.h, client/ObserverClient.cpp,
client/CreatorClient.h, client/CommClient.h, client/CommClient.cpp:
Modify method names to fit capitalisation conventions.
* client/CreatorClient.cpp: Implement creation of in-game entities,
using creator entity.
* client/CommClient.cpp: Added correct client side monitoring of
creator entity.
* client/ClientConnection.h, client/ClientConnection.cpp: Added
pending method to establish if ops are in the queue. Switched send()
method so we only send ops. Add setting of serialno of sent
ops, starting with an offset of 512.
* client/CharacterClient.h: Removed unused member, opFound.
* client/CharacterClient.cpp: Debugged sendAndWait() method.
Al Riddoch <alriddoch@zepler.org>
2001-08-16 17:39:42 +00:00
|
|
|
for (I=result.begin();I!=result.end();I++) {
|
|
|
|
|
send(*(*I));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (findRefno(*input,no)) {
|
2002-03-08 14:58:40 +00:00
|
|
|
return OpVector(1,input);
|
* tools/cycmd.cpp: Ensure that login op is flushed after it is sent.
* server/Player.cpp: Arg order of std::string.compare() is
incompatable between recent libstdc++ versions. Switch
back to old version, still in most common use.
* rulesets/Thing.cpp: Set refno on ops handled in game.
* rulesets/Python_API.cpp: Modify Entity() python constructor
so that commonly used attributes from old atlas are translated
to their modern equivalents.
* rulesets/Py_Thing.cpp, rulesets/Py_Mind.cpp: Differentiate
between previously identical error messages in several places.
* rulesets/Py_Object.cpp: Rework conversion of python dict to
Atlas map to be more efficient and clean.
* rulesets/Py_Location.cpp: Rework setting of vector parts of
location so that it can accept vectors from python in more
formats, including lists and tuples.
* rulesets/Creator.h, rulesets/Character.h, common/BaseEntity.h:
Re-order virtual methods declarations to fit a convention.
* common/stringstream.h: Hardcode use of local stringstream class,
as the version provided with older libstdc++ seems to be broken.
* common/database.cpp: Use the common header to pick the right
stringstream implementation.
* common/BaseWorld.cpp, server/Persistance.cpp: Removed unused
stringstream include.
* rulesets/Creator.cpp: Added extra debug output.
* client/define_world.h, client/define_world.cpp, client/CommClient.h:
Use CreatorClient to store Creators mind, instead of BaseMind.
* client/client.cpp,
client/ObserverClient.h, client/ObserverClient.cpp,
client/CreatorClient.h, client/CommClient.h, client/CommClient.cpp:
Modify method names to fit capitalisation conventions.
* client/CreatorClient.cpp: Implement creation of in-game entities,
using creator entity.
* client/CommClient.cpp: Added correct client side monitoring of
creator entity.
* client/ClientConnection.h, client/ClientConnection.cpp: Added
pending method to establish if ops are in the queue. Switched send()
method so we only send ops. Add setting of serialno of sent
ops, starting with an offset of 512.
* client/CharacterClient.h: Removed unused member, opFound.
* client/CharacterClient.cpp: Debugged sendAndWait() method.
Al Riddoch <alriddoch@zepler.org>
2001-08-16 17:39:42 +00:00
|
|
|
}
|
2002-03-12 18:08:56 +00:00
|
|
|
delete input;
|
2001-08-14 12:49:04 +00:00
|
|
|
}
|
2004-06-21 00:44:54 +00:00
|
|
|
} else if (connection.wait()) {
|
|
|
|
|
return OpVector();
|
2001-08-14 12:49:04 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|