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>
100 lines
2.8 KiB
C++
100 lines
2.8 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
|
|
|
|
#include <common/BaseEntity.h>
|
|
#include <rulesets/EntityFactory.h>
|
|
|
|
#include "CommClient.h"
|
|
#include "CreatorClient.h"
|
|
|
|
using Atlas::Message::Object;
|
|
|
|
CommClient::CommClient()
|
|
{
|
|
}
|
|
|
|
Object::MapType
|
|
CommClient::createPlayer(const std::string & name,
|
|
const std::string & password)
|
|
{
|
|
playerName = name;
|
|
Object::MapType player_ent;
|
|
player_ent["id"] = name;
|
|
player_ent["password"] = password;
|
|
player_ent["parents"] = Object::ListType(1, "player");
|
|
|
|
cout << "Loggin " << name << " in with " << password << " as password"
|
|
<< endl << flush;
|
|
|
|
Create createAccountOp(Create::Instantiate());
|
|
createAccountOp.SetArgs(Object::ListType(1,player_ent));
|
|
send(createAccountOp);
|
|
|
|
if (connection.wait()) {
|
|
Login loginAccountOp(Login::Instantiate());
|
|
loginAccountOp.SetArgs(Object::ListType(1,player_ent));
|
|
send(loginAccountOp);
|
|
if (connection.wait()) {
|
|
std::cerr << "ERROR: Failed to log into server" << std::endl
|
|
<< std::flush;
|
|
return Object::MapType();
|
|
}
|
|
}
|
|
|
|
Object::MapType ent = connection.getReply();
|
|
|
|
//if (ent.find("characters") != ent.end()) {
|
|
//}
|
|
|
|
return ent;
|
|
}
|
|
|
|
CreatorClient * CommClient::createCharacter(const std::string & type)
|
|
{
|
|
Object::MapType character;
|
|
character["name"] = playerName;
|
|
character["parents"] = Object::ListType(1,type);
|
|
|
|
Create createOp=Create::Instantiate();
|
|
createOp.SetFrom(playerName);
|
|
createOp.SetArgs(Object::ListType(1,character));
|
|
send(createOp);
|
|
|
|
if (connection.wait()) {
|
|
std::cerr << "ERROR: Failed to create character type: "
|
|
<< type << std::endl << std::flush;
|
|
return NULL;
|
|
}
|
|
Object::MapType body=connection.getReply();
|
|
|
|
const std::string & id = body.find("id")->second.AsString();
|
|
|
|
edict_t tmp;
|
|
|
|
CreatorClient * obj = new CreatorClient(id, type, connection);
|
|
obj->merge(body);
|
|
obj->getLocation(body, tmp);
|
|
// obj = EntityFactory::instance()->newThing(type, body, tmp);
|
|
// FIXME Do we need to create a local entity for this as is done in
|
|
// the python version? If so, do we need to keep track of a full world
|
|
// model here, or just in the minds (when we become an AI client
|
|
return obj;
|
|
}
|
|
|
|
// I'm making this pure virtual, to see if that is desired.
|
|
//void CommClient::idle() {
|
|
// time.sleep(0.1);
|
|
//}
|
|
|
|
void CommClient::handleNet()
|
|
{
|
|
RootOperation * input;
|
|
while ((input = connection.pop()) != NULL) {
|
|
oplist result = character->message(*input);
|
|
for (oplist::const_iterator I=result.begin(); I != result.end(); I++) {
|
|
send(*(*I));
|
|
}
|
|
delete input;
|
|
}
|
|
}
|