mirror of
https://github.com/worldforge/cyphesis
synced 2026-08-13 12:26:04 -04:00
* 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>
97 lines
2.6 KiB
C++
97 lines
2.6 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)
|
|
{
|
|
}
|
|
|
|
oplist CharacterClient::sightImaginaryOperation(const Sight &, Imaginary &)
|
|
{
|
|
return oplist();
|
|
}
|
|
|
|
#if 0
|
|
oplist CharacterClient::sight_extinguish_operation(self, op): pass;
|
|
oplist telepathy_operation(self, op): ;
|
|
goal_info=op[0];
|
|
char=goal_info.from_;
|
|
char.goal=goal_info[0].description;
|
|
print char,char.goal;
|
|
#endif
|
|
|
|
oplist CharacterClient::soundTalkOperation(const Sound & op, Talk & subop)
|
|
{
|
|
return oplist();
|
|
}
|
|
|
|
#if 0
|
|
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(fullid);
|
|
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);
|
|
}
|
|
|
|
oplist 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!
|
|
oplist result = message(*input);
|
|
oplist::const_iterator I;
|
|
for (I=result.begin();I!=result.end();I++) {
|
|
send(*(*I));
|
|
}
|
|
|
|
if (findRefno(*input,no)) {
|
|
return oplist(1,input);
|
|
}
|
|
}
|
|
delete input;
|
|
} else {
|
|
connection.wait();
|
|
}
|
|
}
|
|
}
|