mirror of
https://github.com/worldforge/cyphesis
synced 2026-08-13 12:26:04 -04:00
* Substantial re-work of object model. Moved many attributes out of BaseEntity class. Changed WoldRouter so it now handles objects in terms of Entity, rather than BaseEntity. * Code cleanups, including removing reduntant includes, and getting rid of C style comments. * Fixed the way attributes are handled in Set operations and when merging from an Atlas::Message::Object. This fixed problem with setting gender of characters. * rulesets/Pedestrian.*, rulesets/Movement.*: Re-named Movement variables to make them clearer. Added in separate handling for collisions from moving to target position. Modified collision handling so objects can slide next to each other. * rulesets/Thing.cpp, rulesets/Character.cpp: Cleaned up and rationalised movement code. Much shorter, faster and more compact than before. * Made better use of iterators throughout, eliminating unnecessary lookups, and copying of data. * Moved all virtual functions out of header files, making less work for the linker. * Made more use of const references to avoid the need to copy data before being able to inspect it. Al Riddoch <alriddoch@zepler.org>
77 lines
2.1 KiB
C++
77 lines
2.1 KiB
C++
// This file may be redistributed and modified only under the terms of
|
|
// the GNU General Public License (See COPYING for details).
|
|
// Copyright (C) 2000,2001 Alistair Riddoch
|
|
|
|
#ifndef COMM_CLIENT_H
|
|
#define COMM_CLIENT_H
|
|
|
|
#include <Atlas/Objects/Decoder.h>
|
|
#include <Atlas/Objects/Encoder.h>
|
|
#include <Atlas/Codec.h>
|
|
|
|
#include <fstream>
|
|
|
|
#include <common/const.h>
|
|
|
|
class CommServer;
|
|
class Connection;
|
|
|
|
class sockbuf : public filebuf {
|
|
public:
|
|
sockbuf() { }
|
|
sockbuf(int fd) : filebuf(fd) { }
|
|
virtual streampos sys_seek(streamoff, _seek_dir) { return streampos(); }
|
|
};
|
|
|
|
class CommClient : Atlas::Objects::Decoder {
|
|
public:
|
|
CommServer & commServer;
|
|
|
|
private:
|
|
int clientFd;
|
|
sockbuf clientBuf;
|
|
iostream clientIos;
|
|
Atlas::Codec<iostream> * codec;
|
|
Atlas::Objects::Encoder * encoder;
|
|
Connection & connection;
|
|
|
|
protected:
|
|
virtual void UnknownObjectArrived(const Atlas::Message::Object&);
|
|
virtual void ObjectArrived(const Atlas::Objects::Operation::Login & op);
|
|
virtual void ObjectArrived(const Atlas::Objects::Operation::Create & op);
|
|
virtual void ObjectArrived(const Atlas::Objects::Operation::Move & op);
|
|
virtual void ObjectArrived(const Atlas::Objects::Operation::Set & op);
|
|
virtual void ObjectArrived(const Atlas::Objects::Operation::Touch & op);
|
|
virtual void ObjectArrived(const Atlas::Objects::Operation::Look & op);
|
|
virtual void ObjectArrived(const Atlas::Objects::Operation::Talk & op);
|
|
virtual void ObjectArrived(const Atlas::Objects::Operation::Get & op);
|
|
|
|
public:
|
|
CommClient(CommServer & svr, int fd, int port);
|
|
virtual ~CommClient();
|
|
|
|
int read() {
|
|
if (clientIos) {
|
|
codec->Poll();
|
|
return(0);
|
|
} else {
|
|
return(-1);
|
|
}
|
|
}
|
|
|
|
void send(const RootOperation * op) {
|
|
if (op) {
|
|
encoder->StreamMessage(op);
|
|
clientIos << flush;
|
|
}
|
|
}
|
|
|
|
int peek() { return clientIos.peek(); }
|
|
int eof() { return clientIos.eof(); }
|
|
int getFd() { return clientFd; }
|
|
|
|
void message(const RootOperation &);
|
|
int setup();
|
|
};
|
|
|
|
#endif // COMM_CLIENT_H
|