cyphesis/client/CharacterClient.cpp
Al Riddoch e491d6995a 2002-03-12 Al Riddoch <alriddoch@zepler.org>
* server/server.cpp, rulesets/Python_API.cpp, rulesets/Line.cpp,
	  modules/Location.cpp, client/CreatorClient.cpp:
	  Removed some obsolete comments.

	* server/WorldRouter.h, server/WorldRouter.cpp: Add member to
	  deliver operation to known entity. Make use if it to avoid
	  having to recurse in operation() when broadcasting. Ensure
	  that the container of new entities is managed from here.

	* rulesets/Thing.cpp: Tell world to create new entities at the
	  same position as the creator if no other info is provided.
	  Do not attempt to handle setting up the default containership
	  of entity once created, as this is always handled by the
	  WorldRouter from now on.

	* rulesets/Py_World.cpp: Implement getting time info from world.

	* rulesets/Py_Location.cpp: Implement handling of the orientation
	  attribute from python.

	* rulesets/MemMap.cpp: Update comments about unimplemented code.

	* rulesets/Creator.cpp: Check for string.empty() instead of "".

	* rulesets/BaseMind.cpp: Remove reference python code.
	  Cleanly handle and delete operations returned when savinf mind state.

	* client/CharacterClient.cpp: Move delete to the right place.
2002-03-12 18:08:56 +00:00

89 lines
2.5 KiB
C++

// This file may be redistributed and modified only under the terms of
// the GNU Lesser General Public License (See COPYING for details).
// Copyright (C) 2001 Alistair Riddoch
#include "CharacterClient.h"
#include "ClientConnection.h"
CharacterClient::CharacterClient(const std::string & id,
const std::string & name,
ClientConnection & c) :
BaseMind(id,name), connection(c)
{
}
OpVector CharacterClient::sightImaginaryOperation(const Sight &, Imaginary &)
{
return OpVector();
}
OpVector CharacterClient::soundTalkOperation(const Sound & op, Talk & subop)
{
return OpVector();
}
#if 0
//FIXME Dunno what all this trigger lark is about.
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)
{
op.SetFrom(getId());
connection.send(op);
}
inline bool CharacterClient::findRefnoOp(const RootOperation & op, long refno)
{
if (refno == op.GetRefno()) {
return true;
}
return false;
}
inline bool CharacterClient::findRefno(const RootOperation & msg, long refno)
{
return findRefnoOp(msg,refno);
}
OpVector CharacterClient::sendAndWaitReply(RootOperation & op)
{
send(op);
long no = op.GetSerialno();
while (true) {
if (connection.pending()) {
RootOperation * input=CharacterClient::connection.pop();
if (input != NULL) {
// What the hell is this!
OpVector result = message(*input);
OpVector::const_iterator I;
for (I=result.begin();I!=result.end();I++) {
send(*(*I));
}
if (findRefno(*input,no)) {
return OpVector(1,input);
}
delete input;
}
} else {
connection.wait();
}
}
}