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>
128 lines
3.6 KiB
C++
128 lines
3.6 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 "ObserverClient.h"
|
|
#include "define_world.h"
|
|
|
|
#include <common/accountbase.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
using Atlas::Message::Object;
|
|
|
|
// bad_type sc(bad_type x,bad_type min,bad_type max,bad_type s) {
|
|
// res=int(s/(max-min)*(x-min));
|
|
// if (res<0) {
|
|
// res=0;
|
|
// }
|
|
// if (res>=s) {
|
|
// res=s-1;
|
|
// }
|
|
// return res;
|
|
// }
|
|
|
|
//def scx(x, min=xmin, max=xmax, s=sizex): return sc(x,min,max,s);
|
|
//def scy(y, min=ymin, max=ymax, s=sizey): return sc(-y,min,max,s);
|
|
|
|
ObserverClient::ObserverClient()
|
|
{
|
|
connect();
|
|
|
|
Object::MapType adminAccount;
|
|
if (!AccountBase::instance()->getAccount("admin", adminAccount)) {
|
|
std::cerr << "Unable to read admin account from database"
|
|
<< std::endl << std::flush;
|
|
return;
|
|
}
|
|
Object::MapType::const_iterator I = adminAccount.find("password");
|
|
if (I == adminAccount.end()) {
|
|
std::cerr << "Unable to read admin account from database"
|
|
<< std::endl << std::flush;
|
|
return;
|
|
}
|
|
const std::string & password = I->second.AsString();
|
|
player = createPlayer("admin",password);
|
|
character = createCharacter("creator");
|
|
}
|
|
|
|
void ObserverClient::loadDefault() {
|
|
DefineWorld::define(character);
|
|
}
|
|
|
|
void ObserverClient::idle()
|
|
{
|
|
usleep(100);
|
|
#if 0
|
|
// time.sleep(0.1);
|
|
if (not ObserverClient::display) {
|
|
return;
|
|
}
|
|
ObserverClient::map=ObserverClient::character.map;
|
|
wait=0.0;
|
|
xmin=-300.0;
|
|
xmax=-xmin;
|
|
ymin=-150.0;
|
|
ymax=-ymin;
|
|
sizex=49;
|
|
sizey=20;
|
|
goal_width=30;
|
|
screen = [None]*sizex;
|
|
for (/*i in range(sizex)*/) {
|
|
screen[i] = ['.'] * sizey;
|
|
}
|
|
house_list=[];
|
|
mind_list=[];
|
|
fire_list=[];
|
|
for (/*t in ObserverClient::map.things.values()*/) {
|
|
if (len(t.type)>=1) {
|
|
typething = string.split(t.type[0], ".");
|
|
if (string.find(typething[-1], "house")>=0) {
|
|
house_list.append(t);
|
|
}
|
|
else if (string.find(typething[-1], "farmer")>=0 or string.find(typething[-1], "smith")>=0 or string.find(typething[-1], "character")>=0 or string.find(typething[-1], "creator")>=0) {
|
|
mind_list.append(t);
|
|
}
|
|
else if (string.find(typething[-1], "fire")) {
|
|
fire_list.append(t);
|
|
}
|
|
}
|
|
else {
|
|
print "CHEAT!: somewhere is entity without type!:",t;
|
|
}
|
|
}
|
|
ObserverClient::time=str(ObserverClient::character.time);
|
|
status_str=ObserverClient::time+" Count of minds: "+`len(mind_list)`;
|
|
print chr(27)+"[H",status_str+" "*(sizex-len(status_str)-1);
|
|
for (/*t in house_list*/) {
|
|
(x,y,z)=t.get_xyz();
|
|
screen[scx(x)][scy(y)]=t.name[0];
|
|
}
|
|
yind=1;
|
|
goal_txt={};
|
|
for (/*m in mind_list*/) {
|
|
(x,y,z)=m.get_xyz();
|
|
x,y=scx(x),scy(y);
|
|
screen[x][y]=m.name[0];
|
|
screen[x+1][y]=m.name[-1];
|
|
if (hasattr(m,"goal")) {
|
|
goal_txt[yind]=(`m`+":"+m.goal+" "*goal_width)[:goal_width];
|
|
yind=yind+1;
|
|
}
|
|
}
|
|
for (/*t in fire_list*/) {
|
|
(x,y,z)=t.get_xyz();
|
|
screen[scx(x)][scy(y)]='F';
|
|
wait=0.2;
|
|
}
|
|
out=[];
|
|
for (/*y in range(sizey)*/) {
|
|
for (/*x in range(sizex)*/) {
|
|
out.append(screen[x][y]);
|
|
}
|
|
out.append(goal_txt.get(y," "*goal_width));
|
|
out.append('\n');
|
|
}
|
|
print string.join(out,'');
|
|
#endif
|
|
}
|